mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 16:50:14 +00:00
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
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user