This commit is contained in:
Brian West 2014-02-23 17:58:57 -06:00
parent 6c71125359
commit 68e1a5635a
1 changed files with 21 additions and 1 deletions

View File

@ -69,6 +69,26 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_mongodb_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_mongodb_shutdown);
SWITCH_MODULE_DEFINITION(mod_cdr_mongodb, mod_cdr_mongodb_load, mod_cdr_mongodb_shutdown, NULL);
static void bson_append_value(bson *cdr, char *name, char *val)
{
//Check the variable and insert it as int, long int or string depending on it's value
char* endptr;
long int lintValue = strtol(val, &endptr, 10);
if (!*endptr){
int intValue = lintValue;
if(intValue == lintValue){
bson_append_int(cdr, name, intValue);
}else{
bson_append_long(cdr, name, lintValue);
}
} else {
bson_append_string(cdr, name, val);
}
}
static void set_bson_profile_data(bson *b, switch_caller_profile_t *caller_profile)
{
bson_append_string(b, "username", caller_profile->username);
@ -162,7 +182,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
if ((hi = switch_channel_variable_first(channel))) {
for (; hi; hi = hi->next) {
if (!zstr(hi->name) && !zstr(hi->value)) {
bson_append_string(&cdr, hi->name, hi->value);
bson_append_value(&cdr, hi->name, hi->value);
}
}
switch_channel_variable_last(channel);