summaryrefslogtreecommitdiff
path: root/cel/cel_odbc.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-02-01 17:42:15 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-02-01 17:42:15 +0000
commit797d633139a52a87736c04b71e31b1cb66e21e08 (patch)
treeed8848795a995d9e2986bdd30a867d1a8f3b7044 /cel/cel_odbc.c
parenta99b3c817baf50cf4edc70e991c0395c3d6d0311 (diff)
Remove inconsistency in CEL eventtype for user defined events.
The CEL eventtype field for ODBC and PGSQL backends should be USER_DEFINED instead of the user defined event name supplied by the CELGenUserEvent application. If the field is output as a number, the user defined name does not have a value and is always output as 21 for USER_DEFINED and the userdeftype field would be required to supply the user defined name. The following CEL backends (cel_odbc, cel_pgsql, cel_custom, cel_manager, and cel_sqlite3_custom) can be independently configured to remove this inconsistency. * Allows cel_manager, cel_custom, and cel_sqlite3_custom to behave the same way. (closes issue ASTERISK-17189) Reported by: Bryant Zimmerman Review: https://reviewboard.asterisk.org/r/1669/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@353648 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'cel/cel_odbc.c')
-rw-r--r--cel/cel_odbc.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/cel/cel_odbc.c b/cel/cel_odbc.c
index 223cb18c9..1a5427169 100644
--- a/cel/cel_odbc.c
+++ b/cel/cel_odbc.c
@@ -53,6 +53,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define CONFIG "cel_odbc.conf"
static struct ast_event_sub *event_sub = NULL;
+/*! \brief show_user_def is off by default */
+#define CEL_SHOW_USERDEF_DEFAULT 0
+
+/*! TRUE if we should set the eventtype field to USER_DEFINED on user events. */
+static unsigned char cel_show_user_def;
+
/* Optimization to reduce number of memory allocations */
static int maxsize = 512, maxsize2 = 512;
@@ -103,7 +109,20 @@ static int load_config(void)
return -1;
}
+ /* Process the general category */
+ cel_show_user_def = CEL_SHOW_USERDEF_DEFAULT;
+ for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
+ if (!strcasecmp(var->name, "show_user_defined")) {
+ cel_show_user_def = ast_true(var->value) ? 1 : 0;
+ } else {
+ /* Unknown option name. */
+ }
+ }
+
for (catg = ast_category_browse(cfg, NULL); catg; catg = ast_category_browse(cfg, catg)) {
+ if (!strcasecmp(catg, "general")) {
+ continue;
+ }
var = ast_variable_browse(cfg, catg);
if (!var)
continue;
@@ -476,7 +495,12 @@ static void odbc_log(const struct ast_event *event, void *userdata)
* form (but only when we're dealing with a character-based field).
*/
if (strcasecmp(entry->name, "eventtype") == 0) {
- snprintf(colbuf, sizeof(colbuf), "%s", record.event_name);
+ const char *event_name;
+
+ event_name = (!cel_show_user_def
+ && record.event_type == AST_CEL_USER_DEFINED)
+ ? record.user_defined_name : record.event_name;
+ snprintf(colbuf, sizeof(colbuf), "%s", event_name);
}
/* Truncate too-long fields */