Index: cdr/cdr_custom.c =================================================================== RCS file: /usr/cvsroot/asterisk/cdr/cdr_custom.c,v retrieving revision 1.3 diff -u -r1.3 cdr_custom.c --- cdr/cdr_custom.c 31 Mar 2005 05:54:25 -0000 1.3 +++ cdr/cdr_custom.c 31 Mar 2005 09:30:25 -0000 @@ -57,22 +57,33 @@ strcpy(format, ""); strcpy(master, ""); if((cfg = ast_config_load("cdr_custom.conf"))) { + res = 0; var = ast_variable_browse(cfg, "mappings"); while(var) { ast_mutex_lock(&lock); if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) { + if (strlen(var->value) > (sizeof(format) - 2)) + ast_log(LOG_WARNING, "Format string too big, trunkating entry %s at line %d\n", var->name, var->lineno); strncpy(format, var->value, sizeof(format) - 2); strcat(format,"\n"); snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name); ast_mutex_unlock(&lock); - } else + } else { ast_log(LOG_NOTICE, "Mapping must have both filename and format at line %d\n", var->lineno); + res = -1; + } if (var->next) ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); var = var->next; } ast_config_destroy(cfg); } + if (res) { + if (reload) + ast_log(LOG_WARNING, "Failed to reload configuration file for custom CDR. \n"); + else + ast_log(LOG_WARNING, "Failed to load configuration file for custom CDR. Module not activitated.\n"); + } return res; } @@ -135,6 +146,8 @@ ast_log(LOG_ERROR, "Unable to register custom CDR handling\n"); if (mf) fclose(mf); + } else { + res = 0; /* Don't stop Asterisk, continue without activating this module */ } return res; }