Asterisk - The Open Source Telephony Project GIT-master-5467495
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
cel_pgsql.c File Reference

PostgreSQL CEL logger. More...

#include "asterisk.h"
#include <libpq-fe.h>
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/cel.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
Include dependency graph for cel_pgsql.c:

Go to the source code of this file.

Data Structures

struct  columns
 
struct  psql_columns
 

Macros

#define CEL_SHOW_USERDEF_DEFAULT   0
 show_user_def is off by default
 
#define DATE_FORMAT   "%Y-%m-%d %T.%6q"
 
#define LENGTHEN_BUF(size, var_sql)
 
#define LENGTHEN_BUF1(size)    LENGTHEN_BUF(size, sql);
 
#define LENGTHEN_BUF2(size)    LENGTHEN_BUF(size, sql2);
 
#define PGSQL_BACKEND_NAME   "CEL PGSQL backend"
 
#define PGSQL_MIN_VERSION_SCHEMA   70300
 
#define SEP   (first ? "" : ",")
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int my_load_module (int reload)
 
static int my_unload_module (void)
 
static void pgsql_log (struct ast_event *event)
 
static void pgsql_reconnect (void)
 
static int process_my_load_module (struct ast_config *cfg)
 
static int reload (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PostgreSQL CEL Backend" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, .requires = "cel", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static unsigned char cel_show_user_def
 
static char * config = "cel_pgsql.conf"
 
static PGconn * conn = NULL
 
static int connected = 0
 
static int maxsize = 512
 
static int maxsize2 = 512
 
static char * pgappname
 
static char * pgdbname
 
static char * pgdbport
 
static char * pgdbuser
 
static char * pghostname
 
static char * pgpassword
 
static ast_mutex_t pgsql_lock = AST_MUTEX_INIT_VALUE
 
static struct psql_columns psql_columns = AST_RWLIST_HEAD_INIT_VALUE
 
static PGresult * result = NULL
 
static char * schema
 
static char * table
 
static int usegmtime = 0
 

Detailed Description

PostgreSQL CEL logger.

Author
Steve Murphy murf@.nosp@m.digi.nosp@m.um.co.nosp@m.m PostgreSQL http://www.postgresql.org/

Definition in file cel_pgsql.c.

Macro Definition Documentation

◆ CEL_SHOW_USERDEF_DEFAULT

#define CEL_SHOW_USERDEF_DEFAULT   0

show_user_def is off by default

Definition at line 76 of file cel_pgsql.c.

◆ DATE_FORMAT

#define DATE_FORMAT   "%Y-%m-%d %T.%6q"

Definition at line 53 of file cel_pgsql.c.

◆ LENGTHEN_BUF

#define LENGTHEN_BUF (   size,
  var_sql 
)

Definition at line 97 of file cel_pgsql.c.

98 { \
99 /* Lengthen buffer, if necessary */ \
100 if (ast_str_strlen(var_sql) + size + 1 > ast_str_size(var_sql)) { \
101 if (ast_str_make_space(&var_sql, ((ast_str_size(var_sql) + size + 3) / 512 + 1) * 512) != 0) { \
102 ast_log(LOG_ERROR, "Unable to allocate sufficient memory. Insert CEL '%s:%s' failed.\n", pghostname, table); \
103 ast_free(sql); \
104 ast_free(sql2); \
105 AST_RWLIST_UNLOCK(&psql_columns); \
106 return; \
107 } \
108 } \
109 } while (0)
static char * table
Definition cel_pgsql.c:67
static char * pghostname
Definition cel_pgsql.c:61
#define LOG_ERROR
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition strings.h:730
#define ast_str_make_space(buf, new_len)
Definition strings.h:828
size_t attribute_pure ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
Definition strings.h:742

◆ LENGTHEN_BUF1

#define LENGTHEN_BUF1 (   size)     LENGTHEN_BUF(size, sql);

Definition at line 111 of file cel_pgsql.c.

◆ LENGTHEN_BUF2

#define LENGTHEN_BUF2 (   size)     LENGTHEN_BUF(size, sql2);

Definition at line 113 of file cel_pgsql.c.

◆ PGSQL_BACKEND_NAME

#define PGSQL_BACKEND_NAME   "CEL PGSQL backend"

Definition at line 55 of file cel_pgsql.c.

◆ PGSQL_MIN_VERSION_SCHEMA

#define PGSQL_MIN_VERSION_SCHEMA   70300

Definition at line 57 of file cel_pgsql.c.

◆ SEP

#define SEP   (first ? "" : ",")

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 722 of file cel_pgsql.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 722 of file cel_pgsql.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 722 of file cel_pgsql.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 705 of file cel_pgsql.c.

706{
707 return my_load_module(0);
708}
static int my_load_module(int reload)
Definition cel_pgsql.c:678

References my_load_module().

◆ my_load_module()

static int my_load_module ( int  reload)
static

Definition at line 678 of file cel_pgsql.c.

679{
680 struct ast_config *cfg;
681 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
682
683 if ((cfg = ast_config_load(config, config_flags)) == NULL || cfg == CONFIG_STATUS_FILEINVALID) {
684 ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CEL's: %s\n", config);
686 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
688 }
689
690 if (reload) {
692 }
693
696
698 ast_log(LOG_WARNING, "Unable to subscribe to CEL events for pgsql\n");
700 }
701
703}
#define ast_log
Definition astobj2.c:42
int ast_cel_backend_register(const char *name, ast_cel_backend_cb backend_callback)
Register a CEL backend.
Definition cel.c:1836
static int process_my_load_module(struct ast_config *cfg)
Definition cel_pgsql.c:467
static char * config
Definition cel_pgsql.c:59
static int my_unload_module(void)
Definition cel_pgsql.c:413
#define PGSQL_BACKEND_NAME
Definition cel_pgsql.c:55
static void pgsql_log(struct ast_event *event)
Definition cel_pgsql.c:145
static int reload(void)
Definition cel_pgsql.c:710
#define ast_config_load(filename, flags)
Load a config file.
@ CONFIG_FLAG_FILEUNCHANGED
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition extconf.c:1287
#define LOG_WARNING
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition module.h:78
#define NULL
Definition resample.c:96
Structure used to handle boolean flags.
Definition utils.h:220

References ast_cel_backend_register(), ast_config_destroy(), ast_config_load, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, LOG_WARNING, my_unload_module(), NULL, PGSQL_BACKEND_NAME, pgsql_log(), process_my_load_module(), and reload().

Referenced by load_module(), and reload().

◆ my_unload_module()

static int my_unload_module ( void  )
static

Definition at line 413 of file cel_pgsql.c.

414{
415 struct columns *current;
416
419 if (conn) {
420 PQfinish(conn);
421 conn = NULL;
422 }
423 if (pghostname) {
426 }
427 if (pgdbname) {
429 pgdbname = NULL;
430 }
431 if (pgdbuser) {
433 pgdbuser = NULL;
434 }
435 if (pgpassword) {
438 }
439 if (pgappname) {
441 pgappname = NULL;
442 }
443 if (pgdbport) {
445 pgdbport = NULL;
446 }
447 if (table) {
449 table = NULL;
450 }
451 if (schema) {
453 schema = NULL;
454 }
457 }
459 return 0;
460}
#define ast_free(a)
Definition astmm.h:180
int ast_cel_backend_unregister(const char *name)
Unregister a CEL backend.
Definition cel.c:1824
static char * pgdbuser
Definition cel_pgsql.c:63
static char * schema
Definition cel_pgsql.c:68
static char * pgappname
Definition cel_pgsql.c:65
static char * pgdbport
Definition cel_pgsql.c:66
static char * pgdbname
Definition cel_pgsql.c:62
static char * pgpassword
Definition cel_pgsql.c:64
static PGconn * conn
Definition cel_pgsql.c:83
size_t current
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
#define AST_RWLIST_REMOVE_HEAD
struct columns::@5 list

References ast_cel_backend_unregister(), ast_free, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, conn, current, columns::list, NULL, pgappname, pgdbname, pgdbport, pgdbuser, pghostname, pgpassword, PGSQL_BACKEND_NAME, schema, and table.

Referenced by my_load_module(), and unload_module().

◆ pgsql_log()

static void pgsql_log ( struct ast_event event)
static

Definition at line 145 of file cel_pgsql.c.

146{
147 struct ast_tm tm;
148 char timestr[128];
149 char *pgerror;
150 struct ast_cel_event_record record = {
152 };
153
154 if (ast_cel_fill_record(event, &record)) {
155 return;
156 }
157
159
160 ast_localtime(&record.event_time, &tm, usegmtime ? "GMT" : NULL);
161 ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
162
163 if ((!connected) && pghostname && pgdbuser && pgpassword && pgdbname) {
165 if (PQstatus(conn) != CONNECTION_BAD) {
166 connected = 1;
167 } else {
168 pgerror = PQerrorMessage(conn);
169 ast_log(LOG_ERROR, "cel_pgsql: Unable to connect to database server %s. Calls will not be logged!\n", pghostname);
170 ast_log(LOG_ERROR, "cel_pgsql: Reason: %s\n", pgerror);
171 PQfinish(conn);
172 conn = NULL;
173 }
174 }
175 if (connected) {
176 struct columns *cur;
177 struct ast_str *sql = ast_str_create(maxsize), *sql2 = ast_str_create(maxsize2);
178 char buf[257];
179 char *escapebuf = NULL;
180 const char *value;
181 int first = 1;
182 size_t bufsize = 513;
183
184 escapebuf = ast_malloc(bufsize);
185 if (!escapebuf || !sql || !sql2) {
186 goto ast_log_cleanup;
187 }
188
189 ast_str_set(&sql, 0, "INSERT INTO %s (", table);
190 ast_str_set(&sql2, 0, " VALUES (");
191
192#define SEP (first ? "" : ",")
193
195 AST_RWLIST_TRAVERSE(&psql_columns, cur, list) {
196 LENGTHEN_BUF1(strlen(cur->name) + 2);
197 ast_str_append(&sql, 0, "%s\"%s\"", SEP, cur->name);
198
199 if (strcmp(cur->name, "eventtime") == 0) {
200 if (strncmp(cur->type, "int", 3) == 0) {
201 LENGTHEN_BUF2(13);
202 ast_str_append(&sql2, 0, "%s%ld", SEP, (long) record.event_time.tv_sec);
203 } else if (strncmp(cur->type, "float", 5) == 0) {
204 LENGTHEN_BUF2(31);
205 ast_str_append(&sql2, 0, "%s%f",
206 SEP,
207 (double) record.event_time.tv_sec +
208 (double) record.event_time.tv_usec / 1000000.0);
209 } else {
210 /* char, hopefully */
211 LENGTHEN_BUF2(31);
212 ast_localtime(&record.event_time, &tm, usegmtime ? "GMT" : NULL);
213 ast_strftime(buf, sizeof(buf), DATE_FORMAT, &tm);
214 ast_str_append(&sql2, 0, "%s'%s'", SEP, buf);
215 }
216 } else if (strcmp(cur->name, "eventtype") == 0) {
217 if (cur->type[0] == 'i') {
218 /* Get integer, no need to escape anything */
219 LENGTHEN_BUF2(5);
220 ast_str_append(&sql2, 0, "%s%d", SEP, (int) record.event_type);
221 } else if (strncmp(cur->type, "float", 5) == 0) {
222 LENGTHEN_BUF2(31);
223 ast_str_append(&sql2, 0, "%s%f", SEP, (double) record.event_type);
224 } else {
225 /* Char field, probably */
226 const char *event_name;
227 size_t required_size;
228
229 event_name = (!cel_show_user_def
230 && record.event_type == AST_CEL_USER_DEFINED)
231 ? record.user_defined_name : record.event_name;
232 required_size = strlen(event_name) * 2 + 1;
233 if (required_size > bufsize) {
234 char *tmpbuf = ast_realloc(escapebuf, required_size);
235 if (!tmpbuf) {
237 goto ast_log_cleanup;
238 }
239 escapebuf = tmpbuf;
240 bufsize = required_size;
241 }
242 PQescapeStringConn(conn, escapebuf, event_name,
243 strlen(event_name), NULL);
244 LENGTHEN_BUF2(strlen(escapebuf) + 3);
245 ast_str_append(&sql2, 0, "%s'%s'", SEP, escapebuf);
246 }
247 } else if (strcmp(cur->name, "amaflags") == 0) {
248 if (strncmp(cur->type, "int", 3) == 0) {
249 /* Integer, no need to escape anything */
250 LENGTHEN_BUF2(13);
251 ast_str_append(&sql2, 0, "%s%u", SEP, record.amaflag);
252 } else {
253 /* Although this is a char field, there are no special characters in the values for these fields */
254 LENGTHEN_BUF2(31);
255 ast_str_append(&sql2, 0, "%s'%u'", SEP, record.amaflag);
256 }
257 } else {
258 /* Arbitrary field, could be anything */
259 if (strcmp(cur->name, "userdeftype") == 0) {
260 value = record.user_defined_name;
261 } else if (strcmp(cur->name, "cid_name") == 0) {
262 value = record.caller_id_name;
263 } else if (strcmp(cur->name, "cid_num") == 0) {
264 value = record.caller_id_num;
265 } else if (strcmp(cur->name, "cid_ani") == 0) {
266 value = record.caller_id_ani;
267 } else if (strcmp(cur->name, "cid_rdnis") == 0) {
268 value = record.caller_id_rdnis;
269 } else if (strcmp(cur->name, "cid_dnid") == 0) {
270 value = record.caller_id_dnid;
271 } else if (strcmp(cur->name, "exten") == 0) {
272 value = record.extension;
273 } else if (strcmp(cur->name, "context") == 0) {
274 value = record.context;
275 } else if (strcmp(cur->name, "channame") == 0) {
276 value = record.channel_name;
277 } else if (strcmp(cur->name, "appname") == 0) {
278 value = record.application_name;
279 } else if (strcmp(cur->name, "appdata") == 0) {
280 value = record.application_data;
281 } else if (strcmp(cur->name, "accountcode") == 0) {
282 value = record.account_code;
283 } else if (strcmp(cur->name, "peeraccount") == 0) {
284 value = record.peer_account;
285 } else if (strcmp(cur->name, "uniqueid") == 0) {
286 value = record.unique_id;
287 } else if (strcmp(cur->name, "linkedid") == 0) {
288 value = record.linked_id;
289 } else if (strcmp(cur->name, "userfield") == 0) {
290 value = record.user_field;
291 } else if (strcmp(cur->name, "peer") == 0) {
292 value = record.peer;
293 } else if (strcmp(cur->name, "extra") == 0) {
294 value = record.extra;
295 } else {
296 value = NULL;
297 }
298
299 if (value == NULL) {
300 ast_str_append(&sql2, 0, "%sDEFAULT", SEP);
301 } else if (strncmp(cur->type, "int", 3) == 0) {
302 long long whatever;
303 if (value && sscanf(value, "%30lld", &whatever) == 1) {
304 LENGTHEN_BUF2(26);
305 ast_str_append(&sql2, 0, "%s%lld", SEP, whatever);
306 } else {
307 LENGTHEN_BUF2(2);
308 ast_str_append(&sql2, 0, "%s0", SEP);
309 }
310 } else if (strncmp(cur->type, "float", 5) == 0) {
311 long double whatever;
312 if (value && sscanf(value, "%30Lf", &whatever) == 1) {
313 LENGTHEN_BUF2(51);
314 ast_str_append(&sql2, 0, "%s%30Lf", SEP, whatever);
315 } else {
316 LENGTHEN_BUF2(2);
317 ast_str_append(&sql2, 0, "%s0", SEP);
318 }
319 /* XXX Might want to handle dates, times, and other misc fields here XXX */
320 } else {
321 if (value) {
322 size_t required_size = strlen(value) * 2 + 1;
323
324 /* If our argument size exceeds our buffer, grow it,
325 * as PQescapeStringConn() expects the buffer to be
326 * adequitely sized and does *NOT* do size checking.
327 */
328 if (required_size > bufsize) {
329 char *tmpbuf = ast_realloc(escapebuf, required_size);
330
331 if (!tmpbuf) {
333 goto ast_log_cleanup;
334 }
335
336 escapebuf = tmpbuf;
337 bufsize = required_size;
338 }
339 PQescapeStringConn(conn, escapebuf, value, strlen(value), NULL);
340 } else {
341 escapebuf[0] = '\0';
342 }
343 LENGTHEN_BUF2(strlen(escapebuf) + 3);
344 ast_str_append(&sql2, 0, "%s'%s'", SEP, escapebuf);
345 }
346 }
347 first = 0;
348 }
350 LENGTHEN_BUF1(ast_str_strlen(sql2) + 2);
351 ast_str_append(&sql, 0, ")%s)", ast_str_buffer(sql2));
352
353 ast_debug(3, "Inserting a CEL record: [%s].\n", ast_str_buffer(sql));
354 /* Test to be sure we're still connected... */
355 /* If we're connected, and connection is working, good. */
356 /* Otherwise, attempt reconnect. If it fails... sorry... */
357 if (PQstatus(conn) == CONNECTION_OK) {
358 connected = 1;
359 } else {
360 ast_log(LOG_WARNING, "Connection was lost... attempting to reconnect.\n");
361 PQreset(conn);
362 if (PQstatus(conn) == CONNECTION_OK) {
363 ast_log(LOG_NOTICE, "Connection reestablished.\n");
364 connected = 1;
365 } else {
366 pgerror = PQerrorMessage(conn);
367 ast_log(LOG_ERROR, "Unable to reconnect to database server %s. Calls will not be logged!\n", pghostname);
368 ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
369 PQfinish(conn);
370 conn = NULL;
371 connected = 0;
372 goto ast_log_cleanup;
373 }
374 }
375 result = PQexec(conn, ast_str_buffer(sql));
376 if (PQresultStatus(result) != PGRES_COMMAND_OK) {
377 pgerror = PQresultErrorMessage(result);
378 ast_log(LOG_WARNING, "Failed to insert call detail record into database!\n");
379 ast_log(LOG_WARNING, "Reason: %s\n", pgerror);
380 ast_log(LOG_WARNING, "Connection may have been lost... attempting to reconnect.\n");
381 PQreset(conn);
382 if (PQstatus(conn) == CONNECTION_OK) {
383 ast_log(LOG_NOTICE, "Connection reestablished.\n");
384 connected = 1;
385 PQclear(result);
386 result = PQexec(conn, ast_str_buffer(sql));
387 if (PQresultStatus(result) != PGRES_COMMAND_OK) {
388 pgerror = PQresultErrorMessage(result);
389 ast_log(LOG_ERROR, "HARD ERROR! Attempted reconnection failed. DROPPING CALL RECORD!\n");
390 ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
391 }
392 }
393 }
394 PQclear(result);
395
396 /* Next time, just allocate buffers that are that big to start with. */
397 if (ast_str_strlen(sql) > maxsize) {
398 maxsize = ast_str_strlen(sql);
399 }
400 if (ast_str_strlen(sql2) > maxsize2) {
401 maxsize2 = ast_str_strlen(sql2);
402 }
403
404ast_log_cleanup:
405 ast_free(sql);
406 ast_free(sql2);
407 ast_free(escapebuf);
408 }
409
411}
struct sla_ringing_trunk * first
Definition app_sla.c:338
#define ast_realloc(p, len)
A wrapper for realloc()
Definition astmm.h:226
#define ast_malloc(len)
A wrapper for malloc()
Definition astmm.h:191
@ AST_CEL_USER_DEFINED
a user-defined event, the event name field should be set
Definition cel.h:70
int ast_cel_fill_record(const struct ast_event *event, struct ast_cel_event_record *r)
Fill in an ast_cel_event_record from a CEL event.
Definition cel.c:870
#define AST_CEL_EVENT_RECORD_VERSION
struct ABI version
Definition cel.h:162
#define LENGTHEN_BUF2(size)
Definition cel_pgsql.c:113
static int maxsize2
Definition cel_pgsql.c:72
static int maxsize
Definition cel_pgsql.c:72
static void pgsql_reconnect(void)
Definition cel_pgsql.c:116
#define SEP
static int connected
Definition cel_pgsql.c:70
static ast_mutex_t pgsql_lock
Definition cel_pgsql.c:81
static unsigned char cel_show_user_def
Definition cel_pgsql.c:79
static int usegmtime
Definition cel_pgsql.c:73
static PGresult * result
Definition cel_pgsql.c:84
#define DATE_FORMAT
Definition cel_pgsql.c:53
#define LENGTHEN_BUF1(size)
Definition cel_pgsql.c:111
char buf[BUFSIZE]
Definition eagi_proxy.c:66
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_NOTICE
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition linkedlists.h:78
#define AST_RWLIST_TRAVERSE
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition localtime.c:1739
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Definition localtime.c:2524
#define ast_mutex_unlock(a)
Definition lock.h:197
#define ast_mutex_lock(a)
Definition lock.h:196
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition strings.h:1139
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition strings.h:1113
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
Helper struct for getting the fields out of a CEL event.
Definition cel.h:157
const char * caller_id_dnid
Definition cel.h:176
const char * application_data
Definition cel.h:181
const char * account_code
Definition cel.h:182
const char * caller_id_rdnis
Definition cel.h:175
const char * extra
Definition cel.h:190
const char * extension
Definition cel.h:177
const char * caller_id_num
Definition cel.h:173
const char * channel_name
Definition cel.h:179
const char * linked_id
Definition cel.h:185
const char * peer_account
Definition cel.h:183
const char * peer
Definition cel.h:189
enum ast_cel_event_type event_type
Definition cel.h:168
const char * unique_id
Definition cel.h:184
const char * user_defined_name
Definition cel.h:171
const char * context
Definition cel.h:178
const char * application_name
Definition cel.h:180
struct timeval event_time
Definition cel.h:169
uint32_t version
struct ABI version
Definition cel.h:167
const char * user_field
Definition cel.h:188
const char * caller_id_ani
Definition cel.h:174
const char * caller_id_name
Definition cel.h:172
Support for dynamic strings.
Definition strings.h:623
int value
Definition syslog.c:37

References ast_cel_event_record::account_code, ast_cel_event_record::amaflag, ast_cel_event_record::application_data, ast_cel_event_record::application_name, AST_CEL_EVENT_RECORD_VERSION, ast_cel_fill_record(), AST_CEL_USER_DEFINED, ast_debug, ast_free, ast_localtime(), ast_log, ast_malloc, ast_mutex_lock, ast_mutex_unlock, ast_realloc, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_str_strlen(), ast_strftime(), buf, ast_cel_event_record::caller_id_ani, ast_cel_event_record::caller_id_dnid, ast_cel_event_record::caller_id_name, ast_cel_event_record::caller_id_num, ast_cel_event_record::caller_id_rdnis, cel_show_user_def, ast_cel_event_record::channel_name, conn, connected, ast_cel_event_record::context, DATE_FORMAT, ast_cel_event_record::event_name, ast_cel_event_record::event_time, ast_cel_event_record::event_type, ast_cel_event_record::extension, ast_cel_event_record::extra, first, LENGTHEN_BUF1, LENGTHEN_BUF2, ast_cel_event_record::linked_id, LOG_ERROR, LOG_NOTICE, LOG_WARNING, maxsize, maxsize2, columns::name, NULL, ast_cel_event_record::peer, ast_cel_event_record::peer_account, pgdbname, pgdbuser, pghostname, pgpassword, pgsql_lock, pgsql_reconnect(), result, SEP, table, columns::type, ast_cel_event_record::unique_id, usegmtime, ast_cel_event_record::user_defined_name, ast_cel_event_record::user_field, value, and ast_cel_event_record::version.

Referenced by my_load_module().

◆ pgsql_reconnect()

static void pgsql_reconnect ( void  )
static

Definition at line 116 of file cel_pgsql.c.

117{
118 struct ast_str *conn_info = ast_str_create(128);
119 if (!conn_info) {
120 ast_log(LOG_ERROR, "Failed to allocate memory for connection string.\n");
121 return;
122 }
123
124 if (conn) {
125 PQfinish(conn);
126 conn = NULL;
127 }
128
129 ast_str_set(&conn_info, 0, "host=%s port=%s dbname=%s user=%s",
131
133 ast_str_append(&conn_info, 0, " application_name=%s", pgappname);
134 }
135
137 ast_str_append(&conn_info, 0, " password=%s", pgpassword);
138 }
139
140 conn = PQconnectdb(ast_str_buffer(conn_info));
141 ast_free(conn_info);
142}
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65

References ast_free, ast_log, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_strlen_zero(), conn, LOG_ERROR, NULL, pgappname, pgdbname, pgdbport, pgdbuser, pghostname, and pgpassword.

Referenced by pgsql_log(), and process_my_load_module().

◆ process_my_load_module()

static int process_my_load_module ( struct ast_config cfg)
static

Definition at line 467 of file cel_pgsql.c.

468{
469 struct ast_variable *var;
470 char *pgerror;
471 const char *tmp;
472 PGresult *result;
473 struct columns *cur;
474
475 if (!(var = ast_variable_browse(cfg, "global"))) {
476 ast_log(LOG_WARNING,"CEL pgsql config file missing global section.\n");
478 }
479 if (!(tmp = ast_variable_retrieve(cfg,"global","hostname"))) {
480 ast_log(LOG_WARNING,"PostgreSQL server hostname not specified. Assuming unix socket connection\n");
481 tmp = ""; /* connect via UNIX-socket by default */
482 }
483 if (pghostname)
485 if (!(pghostname = ast_strdup(tmp))) {
486 ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying host info\n");
488 }
489 if (!(tmp = ast_variable_retrieve(cfg, "global", "dbname"))) {
490 ast_log(LOG_WARNING,"PostgreSQL database not specified. Assuming asterisk\n");
491 tmp = "asteriskceldb";
492 }
493 if (pgdbname)
495 if (!(pgdbname = ast_strdup(tmp))) {
496 ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying dbname info\n");
498 }
499 if (!(tmp = ast_variable_retrieve(cfg, "global", "user"))) {
500 ast_log(LOG_WARNING,"PostgreSQL database user not specified. Assuming asterisk\n");
501 tmp = "asterisk";
502 }
503 if (pgdbuser)
505 if (!(pgdbuser = ast_strdup(tmp))) {
506 ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying user info\n");
508 }
509 if (!(tmp = ast_variable_retrieve(cfg, "global", "password"))) {
510 ast_log(LOG_WARNING, "PostgreSQL database password not specified. Assuming blank\n");
511 tmp = "";
512 }
513 if (pgpassword)
515 if (!(pgpassword = ast_strdup(tmp))) {
516 ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying password info\n");
518 }
519 if (!(tmp = ast_variable_retrieve(cfg, "global", "appname"))) {
520 tmp = "";
521 }
522 if (pgappname) {
524 }
525 if (!(pgappname = ast_strdup(tmp))) {
526 ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying appname info\n");
528 }
529
530 if (!(tmp = ast_variable_retrieve(cfg,"global","port"))) {
531 ast_log(LOG_WARNING,"PostgreSQL database port not specified. Using default 5432.\n");
532 tmp = "5432";
533 }
534 if (pgdbport)
536 if (!(pgdbport = ast_strdup(tmp))) {
537 ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying port info\n");
539 }
540 if (!(tmp = ast_variable_retrieve(cfg, "global", "table"))) {
541 ast_log(LOG_WARNING,"CEL table not specified. Assuming cel\n");
542 tmp = "cel";
543 }
544 if (table)
546 if (!(table = ast_strdup(tmp))) {
548 }
550 if ((tmp = ast_variable_retrieve(cfg, "global", "show_user_defined"))) {
551 cel_show_user_def = ast_true(tmp) ? 1 : 0;
552 }
553 if ((tmp = ast_variable_retrieve(cfg, "global", "usegmtime"))) {
554 usegmtime = ast_true(tmp);
555 } else {
556 usegmtime = 0;
557 }
558 if (!(tmp = ast_variable_retrieve(cfg, "global", "schema"))) {
559 tmp = "";
560 }
561 if (schema) {
563 }
564 if (!(schema = ast_strdup(tmp))) {
565 ast_log(LOG_WARNING,"PostgreSQL Ran out of memory copying schema info\n");
567 }
568 if (DEBUG_ATLEAST(3)) {
570 ast_log(LOG_DEBUG, "cel_pgsql: using default unix socket\n");
571 } else {
572 ast_log(LOG_DEBUG, "cel_pgsql: got hostname of %s\n", pghostname);
573 }
574 ast_log(LOG_DEBUG, "cel_pgsql: got port of %s\n", pgdbport);
575 ast_log(LOG_DEBUG, "cel_pgsql: got user of %s\n", pgdbuser);
576 ast_log(LOG_DEBUG, "cel_pgsql: got dbname of %s\n", pgdbname);
577 ast_log(LOG_DEBUG, "cel_pgsql: got password of %s\n", pgpassword);
578 ast_log(LOG_DEBUG, "cel_pgsql: got sql table name of %s\n", table);
579 ast_log(LOG_DEBUG, "cel_pgsql: got show_user_defined of %s\n",
580 cel_show_user_def ? "Yes" : "No");
581 }
582
584 if (PQstatus(conn) != CONNECTION_BAD) {
585 char sqlcmd[768];
586 char *fname, *ftype, *flen, *fnotnull, *fdef, *tablename, *tmp_tablename;
587 int i, rows, version;
588
589 ast_debug(1, "Successfully connected to PostgreSQL database.\n");
590 connected = 1;
591
592 version = PQserverVersion(conn);
593 /* Remove any schema name from the table */
594 if ((tmp_tablename = strrchr(table, '.'))) {
595 tmp_tablename++;
596 } else {
597 tmp_tablename = table;
598 }
599 tablename = ast_alloca(strlen(tmp_tablename) * 2 + 1);
600 PQescapeStringConn(conn, tablename, tmp_tablename, strlen(tmp_tablename), NULL);
602 char *schemaname;
603 int lenschema;
604 lenschema = strlen(schema);
605 schemaname = ast_alloca(lenschema * 2 + 1);
606 PQescapeStringConn(conn, schemaname, schema, lenschema, NULL);
607
608 snprintf(sqlcmd, sizeof(sqlcmd),
609 "SELECT a.attname, t.typname, a.attlen, a.attnotnull, pg_catalog.pg_get_expr(d.adbin, d.adrelid) adsrc, a.atttypmod "
610 "FROM (((pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
611 "AND c.relname = '%s' AND n.nspname = %s%s%s) "
612 "INNER JOIN pg_catalog.pg_attribute a ON ("
613 "NOT a.attisdropped) AND a.attnum > 0 AND a.attrelid = c.oid) "
614 "INNER JOIN pg_catalog.pg_type t ON t.oid = a.atttypid) "
615 "LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid "
616 "AND d.adnum = a.attnum "
617 "ORDER BY n.nspname, c.relname, attnum",
618 tablename,
619 lenschema == 0 ? "" : "'", lenschema == 0 ? "current_schema()" : schemaname, lenschema == 0 ? "" : "'");
620 } else {
621 snprintf(sqlcmd, sizeof(sqlcmd),
622 "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod "
623 "FROM pg_class c, pg_type t, pg_attribute a "
624 "LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid "
625 "AND d.adnum = a.attnum WHERE c.oid = a.attrelid AND a.atttypid = t.oid "
626 "AND (a.attnum > 0) AND c.relname = '%s' ORDER BY c.relname, attnum", tablename);
627 }
628 /* Query the columns */
629 result = PQexec(conn, sqlcmd);
630 if (PQresultStatus(result) != PGRES_TUPLES_OK) {
631 pgerror = PQresultErrorMessage(result);
632 ast_log(LOG_ERROR, "Failed to query database columns: %s\n", pgerror);
633 PQclear(result);
636 }
637
638 rows = PQntuples(result);
639 for (i = 0; i < rows; i++) {
640 fname = PQgetvalue(result, i, 0);
641 ftype = PQgetvalue(result, i, 1);
642 flen = PQgetvalue(result, i, 2);
643 fnotnull = PQgetvalue(result, i, 3);
644 fdef = PQgetvalue(result, i, 4);
645 ast_verb(4, "Found column '%s' of type '%s'\n", fname, ftype);
646 cur = ast_calloc(1, sizeof(*cur) + strlen(fname) + strlen(ftype) + 2);
647 if (cur) {
648 sscanf(flen, "%30d", &cur->len);
649 cur->name = (char *)cur + sizeof(*cur);
650 cur->type = (char *)cur + sizeof(*cur) + strlen(fname) + 1;
651 strcpy(cur->name, fname);
652 strcpy(cur->type, ftype);
653 if (*fnotnull == 't') {
654 cur->notnull = 1;
655 } else {
656 cur->notnull = 0;
657 }
658 if (!ast_strlen_zero(fdef)) {
659 cur->hasdefault = 1;
660 } else {
661 cur->hasdefault = 0;
662 }
664 }
665 }
666 PQclear(result);
667 } else {
668 pgerror = PQerrorMessage(conn);
669 ast_log(LOG_ERROR, "cel_pgsql: Unable to connect to database server %s. CALLS WILL NOT BE LOGGED!!\n", pghostname);
670 ast_log(LOG_ERROR, "cel_pgsql: Reason: %s\n", pgerror);
671 connected = 0;
672 PQfinish(conn);
673 conn = NULL;
674 }
676}
#define var
Definition ast_expr2f.c:605
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition astmm.h:288
#define ast_strdup(str)
A wrapper for strdup()
Definition astmm.h:241
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
#define CEL_SHOW_USERDEF_DEFAULT
show_user_def is off by default
Definition cel_pgsql.c:76
#define PGSQL_MIN_VERSION_SCHEMA
Definition cel_pgsql.c:57
static int unload_module(void)
Definition cel_pgsql.c:462
static char version[AST_MAX_EXTENSION]
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition extconf.c:1213
#define DEBUG_ATLEAST(level)
#define LOG_DEBUG
#define ast_verb(level,...)
#define AST_RWLIST_INSERT_TAIL
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition utils.c:2233
Structure for variables, used for configurations and for channel variables.
unsigned int hasdefault
Definition cdr_pgsql.c:94
unsigned int notnull
Definition cdr_pgsql.c:93

References ast_alloca, ast_calloc, ast_debug, ast_free, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_RWLIST_INSERT_TAIL, ast_strdup, ast_strlen_zero(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verb, cel_show_user_def, CEL_SHOW_USERDEF_DEFAULT, conn, connected, DEBUG_ATLEAST, columns::hasdefault, columns::len, columns::list, LOG_DEBUG, LOG_ERROR, LOG_WARNING, columns::name, columns::notnull, NULL, pgappname, pgdbname, pgdbport, pgdbuser, pghostname, pgpassword, PGSQL_MIN_VERSION_SCHEMA, pgsql_reconnect(), result, schema, table, columns::type, unload_module(), usegmtime, var, and version.

Referenced by my_load_module().

◆ reload()

static int reload ( void  )
static

Definition at line 710 of file cel_pgsql.c.

711{
712 return my_load_module(1);
713}

References my_load_module().

Referenced by my_load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 462 of file cel_pgsql.c.

463{
464 return my_unload_module();
465}

References my_unload_module().

Referenced by process_my_load_module().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PostgreSQL CEL Backend" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, .requires = "cel", }
static

Definition at line 722 of file cel_pgsql.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 722 of file cel_pgsql.c.

◆ cel_show_user_def

unsigned char cel_show_user_def
static

TRUE if we should set the eventtype field to USER_DEFINED on user events.

Definition at line 79 of file cel_pgsql.c.

Referenced by pgsql_log(), and process_my_load_module().

◆ config

char* config = "cel_pgsql.conf"
static

Definition at line 59 of file cel_pgsql.c.

Referenced by my_load_module().

◆ conn

PGconn* conn = NULL
static

Definition at line 83 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_log(), pgsql_reconnect(), and process_my_load_module().

◆ connected

int connected = 0
static

Definition at line 70 of file cel_pgsql.c.

Referenced by pgsql_log(), and process_my_load_module().

◆ maxsize

int maxsize = 512
static

Definition at line 72 of file cel_pgsql.c.

Referenced by pgsql_log().

◆ maxsize2

int maxsize2 = 512
static

Definition at line 72 of file cel_pgsql.c.

Referenced by pgsql_log().

◆ pgappname

char* pgappname
static

Definition at line 65 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_reconnect(), and process_my_load_module().

◆ pgdbname

char* pgdbname
static

Definition at line 62 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_log(), pgsql_reconnect(), and process_my_load_module().

◆ pgdbport

char* pgdbport
static

Definition at line 66 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_reconnect(), and process_my_load_module().

◆ pgdbuser

char* pgdbuser
static

Definition at line 63 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_log(), pgsql_reconnect(), and process_my_load_module().

◆ pghostname

char* pghostname
static

Definition at line 61 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_log(), pgsql_reconnect(), and process_my_load_module().

◆ pgpassword

char* pgpassword
static

Definition at line 64 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_log(), pgsql_reconnect(), and process_my_load_module().

◆ pgsql_lock

ast_mutex_t pgsql_lock = AST_MUTEX_INIT_VALUE
static

Definition at line 81 of file cel_pgsql.c.

Referenced by pgsql_log().

◆ psql_columns

◆ result

PGresult* result = NULL
static

Definition at line 84 of file cel_pgsql.c.

Referenced by __ast_channel_alloc(), __ast_channel_alloc_with_initializers(), __ast_string_field_alloc_space(), __astman_get_header(), _pgsql_exec(), acf_meetme_info(), action_updateconfig(), aeap_transaction_end(), angle_parser(), angle_validator(), ast_app_parse_timelen(), ast_apply_ha(), ast_ari_callback(), ast_build_string(), ast_build_string_va(), ast_channel_publish_varset(), ast_config_internal_load(), ast_config_internal_load(), ast_config_load2(), ast_db_exists(), ast_dns_resolve(), ast_dns_resolve_ipv6_and_ipv4(), ast_dns_result_free(), ast_dns_result_get_answer(), ast_dns_result_get_bogus(), ast_dns_result_get_canonical(), ast_dns_result_get_lowest_ttl(), ast_dns_result_get_rcode(), ast_dns_result_get_records(), ast_dns_result_get_secure(), ast_dnsmgr_get(), ast_dnsmgr_get_family(), ast_dnsmgr_lookup(), ast_dnsmgr_lookup_cb(), ast_format_cap_get_compatible(), ast_format_cap_get_compatible_format(), ast_format_cap_get_format_framing(), ast_geoloc_civicaddr_validate_varlist(), ast_geoloc_eprofile_to_uri(), ast_geoloc_gml_validate_varlist(), ast_geoloc_validate_result_to_str(), ast_get_encoded_char(), ast_get_encoded_str(), ast_gethostbyname(), ast_msg_has_destination(), ast_parse_arg(), ast_privacy_check(), ast_rtp_instance_available_formats(), ast_sip_str_to_dtmf(), ast_sip_will_uri_survive_restart(), ast_sockaddr_apply_netmask(), ast_speech_results_free(), ast_str_substitute_variables_full2(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), ast_translate_available_formats(), ast_websocket_client_connect(), ast_websocket_client_create(), ast_websocket_client_create_with_options(), ast_websocket_result_to_str(), ast_xml_query(), ast_xml_query_with_namespaces(), astman_verify_session_readpermissions(), astman_verify_session_writepermissions(), chan_pjsip_get_codec(), chan_rtp_get_codec(), chat(), check_add_remove_channel(), check_codec(), check_eval(), check_match(), check_translation_path(), cli_complete_registration(), cli_notify(), conf_find_bridge_profile(), conf_find_menu_entry_by_sequence(), conf_find_user_profile(), config_module(), config_mysql(), config_pgsql(), configuration_parse_unsigned_integer(), crs_validator(), db_get_common(), destroy_pgsql(), detect_callback(), detzcode(), detzcode64(), dial_exec_full(), dns_naptr_sort(), dns_query_recurring_resolution_callback(), dns_srv_sort(), dtmf_to_str(), dundi_lookup(), dundi_lookup_internal(), error(), evaluate_history_entry(), evaluate_like(), fax_detect_framehook(), fax_gateway_attach(), fax_gateway_detect_t38(), fax_gateway_framehook(), fax_gateway_start(), filter_cmp_fn(), find_result(), find_table(), find_table(), float_validator(), function_db_keys(), gen_match_to_pattern(), generic_fax_exec(), geoloc_config_cli_reload(), geoloc_config_list_locations(), geoloc_config_list_profiles(), geoloc_config_load(), geoloc_config_show_profiles(), geoloc_gml_list_to_xml(), geoloc_location_apply_handler(), geoloc_profile_apply_handler(), getremainingfilelength(), gmtsub(), handle_msg_cb(), handle_results(), handle_speechrecognize(), handle_standard_bridge_enter_message(), handle_updates(), iax2_codec_pref_index(), inform(), internal_dnsmgr_lookup(), invalid_record_test(), launch_ha_netscript(), ldap_loadentry(), lintocodec2_frameout(), lintogsm_frameout(), lintoilbc_frameout(), lintolpc10_frameout(), lintospeex_frameout(), listfilter(), loadresult2str(), localized_config_load(), localized_config_load_with_comments(), localsub(), mallocconcat(), malloccopy(), mwi_thread(), nominal_test(), odbc_datastore_free(), off_nominal_test(), ogg_speex_open(), ogg_vorbis_open(), ooh323_get_codec(), op_func(), outbound_session_handler_thread(), P3(), parse_double(), parse_field(), parse_legacy_template(), parse_node(), parse_srv(), parsedoublearg(), parsefilearg(), parsefreq(), parseintarg(), parsetime(), parsetimearg(), parsevolarg(), parsevolume(), pgsql_exec(), pgsql_log(), pgsql_log(), phoneprov_callback(), pos_validator(), process_my_load_module(), process_text_line(), publish_async_exec_end(), publish_load_message(), publish_reload_message(), radius_log(), radius_log(), read_credentials(), read_mf_digits(), read_packet(), read_sf_digits(), realtime_arguments_to_fields2(), realtime_ldap_base_ap(), realtime_multi_mysql(), realtime_multi_pgsql(), realtime_mysql(), realtime_pgsql(), receivefax_exec(), require_pgsql(), rfcomm_read_and_append_char(), rfcomm_read_and_expect_char(), say(), scan_exec(), sdp_crypto_alloc(), sendfax_exec(), set_id_from_hdr(), should_send_event(), sorcery_memory_cache_complete_name(), sorcery_memory_cache_complete_object_name(), sort_result(), speech_grammar(), speech_read(), speech_score(), speech_text(), stasis_app_broadcast_wait(), stasis_broadcast_exec(), stasis_message_type_create(), store_pgsql(), t30_phase_e_handler(), test_expected_result(), test_results(), testtime_write(), tmcomp(), transaction_end(), typeof(), tzload(), update2_pgsql(), update_pgsql(), validate_def_varlist(), validate_location_info(), wait_exec(), wait_for_answer(), webchan_call(), websocket_client_args_create(), and websocket_client_create().

◆ schema

char* schema
static

Definition at line 68 of file cel_pgsql.c.

Referenced by load_config(), my_unload_module(), and process_my_load_module().

◆ table

char* table
static

Definition at line 67 of file cel_pgsql.c.

Referenced by my_unload_module(), pgsql_log(), and process_my_load_module().

◆ usegmtime

int usegmtime = 0
static

Definition at line 73 of file cel_pgsql.c.

Referenced by pgsql_log(), and process_my_load_module().