@ -751,38 +751,13 @@ static void clear_config_maps(void)
ast_mutex_unlock ( & config_lock ) ;
}
void read_config_maps ( void )
static int append_mapping ( char * name , char * driver , char * database , char * table )
{
struct ast_config * config ;
struct ast_variable * v ;
struct ast_config_map * map ;
int length ;
char * driver , * table , * database , * stringp ;
clear_config_maps ( ) ;
config = ast_config_new ( ) ;
config - > max_include_level = 1 ;
config = ast_config_internal_load ( extconfig_conf , config ) ;
if ( ! config )
return ;
for ( v = ast_variable_browse ( config , " settings " ) ; v ; v = v - > next ) {
stringp = v - > value ;
driver = strsep ( & stringp , " , " ) ;
database = strsep ( & stringp , " , " ) ;
table = strsep ( & stringp , " , " ) ;
if ( ! strcmp ( v - > name , extconfig_conf ) | | ! strcmp ( v - > name , " asterisk.conf " ) ) {
ast_log ( LOG_WARNING , " Cannot bind asterisk.conf or extconfig.conf! \n " ) ;
continue ;
}
if ( ! driver | | ! database )
continue ;
length = sizeof ( * map ) ;
length + = strlen ( v - > name ) + 1 ;
length + = strlen ( name ) + 1 ;
length + = strlen ( driver ) + 1 ;
length + = strlen ( database ) + 1 ;
if ( table )
@ -790,11 +765,11 @@ void read_config_maps(void)
map = malloc ( length ) ;
if ( ! map )
continue ;
return - 1 ;
memset ( map , 0 , length ) ;
map - > name = map - > stuff ;
strcpy ( map - > name , v - > name ) ;
strcpy ( map - > name , name ) ;
map - > driver = map - > name + strlen ( map - > name ) + 1 ;
strcpy ( map - > driver , driver ) ;
map - > database = map - > driver + strlen ( map - > driver ) + 1 ;
@ -810,6 +785,46 @@ void read_config_maps(void)
map - > name , map - > driver , map - > database , map - > table ? map - > table : map - > name ) ;
config_maps = map ;
return 0 ;
}
void read_config_maps ( void )
{
struct ast_config * config ;
struct ast_variable * v ;
char * driver , * table , * database , * stringp ;
clear_config_maps ( ) ;
config = ast_config_new ( ) ;
config - > max_include_level = 1 ;
config = ast_config_internal_load ( extconfig_conf , config ) ;
if ( ! config )
return ;
for ( v = ast_variable_browse ( config , " settings " ) ; v ; v = v - > next ) {
stringp = v - > value ;
driver = strsep ( & stringp , " , " ) ;
database = strsep ( & stringp , " , " ) ;
table = strsep ( & stringp , " , " ) ;
if ( ! strcmp ( v - > name , extconfig_conf ) | | ! strcmp ( v - > name , " asterisk.conf " ) ) {
ast_log ( LOG_WARNING , " Cannot bind asterisk.conf or extconfig.conf! \n " ) ;
continue ;
}
if ( ! driver | | ! database )
continue ;
if ( ! strcasecmp ( v - > name , " sipfriends " ) ) {
ast_log ( LOG_WARNING , " The 'sipfriends' table is obsolete, update your config to use sipusers and sippeers, though they can point to the same table. \n " ) ;
append_mapping ( " sipusers " , driver , database , table ? table : " sipfriends " ) ;
append_mapping ( " sippeers " , driver , database , table ? table : " sipfriends " ) ;
} else if ( ! strcasecmp ( v - > name , " iaxfriends " ) ) {
ast_log ( LOG_WARNING , " The 'iaxfriends' table is obsolete, update your config to use iaxusers and iaxpeers, though they can point to the same table. \n " ) ;
append_mapping ( " iaxusers " , driver , database , table ? table : " iaxfriends " ) ;
append_mapping ( " iaxpeers " , driver , database , table ? table : " iaxfriends " ) ;
} else
append_mapping ( v - > name , driver , database , table ) ;
}
ast_config_destroy ( config ) ;