/*! \brief Initialize the ENUM support subsystem */ static int private_enum_init(int reload) { struct ast_config *cfg; struct enum_search *s, *sl; struct ast_variable *v; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; if ((cfg = ast_config_load("enum.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; /* Destroy existing list */ ast_mutex_lock(&enumlock); s = toplevs; while (s) { sl = s; s = s->next; ast_free(sl); } toplevs = NULL; if (cfg) { sl = NULL; v = ast_variable_browse(cfg, "general"); while (v) { if (!strcasecmp(v->name, "search")) { s = enum_newtoplev(v->value); if (s) { if (sl) sl->next = s; else toplevs = s; sl = s; } } v = v->next; } ast_config_destroy(cfg); } else { toplevs = enum_newtoplev(TOPLEV); } enumver++; ast_mutex_unlock(&enumlock); manager_event(EVENT_FLAG_SYSTEM, "Reload", "Module: Enum\r\nStatus: Enabled\r\nMessage: ENUM reload Requested\r\n"); return 0; }
/*--- ast_enum_init: Initialize the ENUM support subsystem */ int ast_enum_init(void) { struct ast_config *cfg; struct enum_search *s, *sl; struct ast_variable *v; /* Destroy existing list */ ast_mutex_lock(&enumlock); s = toplevs; while(s) { sl = s; s = s->next; free(sl); } toplevs = NULL; cfg = ast_config_load("enum.conf"); if (cfg) { sl = NULL; v = ast_variable_browse(cfg, "general"); while(v) { if (!strcasecmp(v->name, "search")) { s = enum_newtoplev(v->value); if (s) { if (sl) sl->next = s; else toplevs = s; sl = s; } } v = v->next; } ast_config_destroy(cfg); } else { toplevs = enum_newtoplev(TOPLEV); } enumver++; ast_mutex_unlock(&enumlock); return 0; }