@ -47,7 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
# include "asterisk/module.h"
# include "asterisk/module.h"
# include "asterisk/translate.h"
# include "asterisk/translate.h"
# include "asterisk/indications.h"
# include "asterisk/indications.h"
# include "asterisk/utils.h"
/* Globals */
/* Globals */
static const char dtext [ ] = " Indications Configuration " ;
static const char dtext [ ] = " Indications Configuration " ;
@ -94,13 +94,10 @@ static int handle_add_indication(int fd, int argc, char *argv[])
if ( ! tz ) {
if ( ! tz ) {
/* country does not exist, create it */
/* country does not exist, create it */
ast_log ( LOG_NOTICE , " Country '%s' does not exist, creating it. \n " , argv [ 2 ] ) ;
ast_log ( LOG_NOTICE , " Country '%s' does not exist, creating it. \n " , argv [ 2 ] ) ;
tz = malloc ( sizeof ( struct tone_zone ) ) ;
if ( ! ( tz = ast_calloc ( 1 , sizeof ( * tz ) ) ) ) {
if ( ! tz ) {
ast_log ( LOG_WARNING , " Out of memory \n " ) ;
return - 1 ;
return - 1 ;
}
}
memset ( tz , 0 , sizeof ( struct tone_zone ) ) ;
ast_copy_string ( tz - > country , argv [ 2 ] , sizeof ( tz - > country ) ) ;
ast_copy_string ( tz - > country , argv [ 2 ] , sizeof ( tz - > country ) ) ;
if ( ast_register_indication_country ( tz ) ) {
if ( ast_register_indication_country ( tz ) ) {
ast_log ( LOG_WARNING , " Unable to register new country \n " ) ;
ast_log ( LOG_WARNING , " Unable to register new country \n " ) ;
@ -257,14 +254,11 @@ static int ind_load_module(void)
if ( ! strcasecmp ( cxt , " general " ) ) {
if ( ! strcasecmp ( cxt , " general " ) ) {
cxt = ast_category_browse ( cfg , cxt ) ;
cxt = ast_category_browse ( cfg , cxt ) ;
continue ;
continue ;
}
}
tones = malloc ( sizeof ( struct tone_zone ) ) ;
if ( ! ( tones = ast_calloc ( 1 , sizeof ( * tones ) ) ) ) {
if ( ! tones ) {
ast_log ( LOG_WARNING , " Out of memory \n " ) ;
ast_config_destroy ( cfg ) ;
ast_config_destroy ( cfg ) ;
return - 1 ;
return - 1 ;
}
}
memset ( tones , 0 , sizeof ( struct tone_zone ) ) ;
ast_copy_string ( tones - > country , cxt , sizeof ( tones - > country ) ) ;
ast_copy_string ( tones - > country , cxt , sizeof ( tones - > country ) ) ;
v = ast_variable_browse ( cfg , cxt ) ;
v = ast_variable_browse ( cfg , cxt ) ;
@ -281,10 +275,8 @@ static int ind_load_module(void)
ast_log ( LOG_WARNING , " Invalid ringcadence given '%s' at line %d. \n " , ring , v - > lineno ) ;
ast_log ( LOG_WARNING , " Invalid ringcadence given '%s' at line %d. \n " , ring , v - > lineno ) ;
ring = strsep ( & c , " , " ) ;
ring = strsep ( & c , " , " ) ;
continue ;
continue ;
}
}
tmp = realloc ( tones - > ringcadence , ( tones - > nrringcadence + 1 ) * sizeof ( int ) ) ;
if ( ! ( tmp = ast_realloc ( tones - > ringcadence , ( tones - > nrringcadence + 1 ) * sizeof ( int ) ) ) ) {
if ( ! tmp ) {
ast_log ( LOG_WARNING , " Out of memory \n " ) ;
ast_config_destroy ( cfg ) ;
ast_config_destroy ( cfg ) ;
return - 1 ;
return - 1 ;
}
}
@ -299,13 +291,11 @@ static int ind_load_module(void)
c = countries ;
c = countries ;
country = strsep ( & c , " , " ) ;
country = strsep ( & c , " , " ) ;
while ( country ) {
while ( country ) {
struct tone_zone * azone = malloc ( sizeof ( struct tone_zone ) ) ;
struct tone_zone * azone ;
if ( ! azone ) {
if ( ! ( azone = ast_calloc ( 1 , sizeof ( * azone ) ) ) ) {
ast_log ( LOG_WARNING , " Out of memory \n " ) ;
ast_config_destroy ( cfg ) ;
ast_config_destroy ( cfg ) ;
return - 1 ;
return - 1 ;
}
}
memset ( azone , 0 , sizeof ( struct tone_zone ) ) ;
ast_copy_string ( azone - > country , country , sizeof ( azone - > country ) ) ;
ast_copy_string ( azone - > country , country , sizeof ( azone - > country ) ) ;
ast_copy_string ( azone - > alias , cxt , sizeof ( azone - > alias ) ) ;
ast_copy_string ( azone - > alias , cxt , sizeof ( azone - > alias ) ) ;
if ( ast_register_indication_country ( azone ) ) {
if ( ast_register_indication_country ( azone ) ) {
@ -325,10 +315,8 @@ static int ind_load_module(void)
goto out ;
goto out ;
}
}
}
}
/* not there, add it to the back */
/* not there, add it to the back */
ts = malloc ( sizeof ( struct tone_zone_sound ) ) ;
if ( ! ( ts = ast_malloc ( sizeof ( * ts ) ) ) ) {
if ( ! ts ) {
ast_log ( LOG_WARNING , " Out of memory \n " ) ;
ast_config_destroy ( cfg ) ;
ast_config_destroy ( cfg ) ;
return - 1 ;
return - 1 ;
}
}