aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-31 21:00:20 +0000
committermogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-31 21:00:20 +0000
commit73925ee14a02afb50f6c0aea3cc4e54f99493440 (patch)
tree5eac7fd790352b502dbbc4fc21ae517fe7c388ad
parent43c75db33e757e08cdec37b1713a0e275d9a039b (diff)
everything that loads a config that needs a config file to run
now reports AST_MODULE_LOAD_DECLINE when loading if config file is not there, also fixed an error in res_config_pgsql where it had a non static function when it should. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@41633 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_alarmreceiver.c9
-rw-r--r--apps/app_festival.c6
-rw-r--r--apps/app_followme.c3
-rw-r--r--apps/app_osplookup.c7
-rw-r--r--apps/app_queue.c16
-rw-r--r--apps/app_rpt.c11
-rw-r--r--cdr/cdr_csv.c9
-rw-r--r--cdr/cdr_custom.c5
-rw-r--r--cdr/cdr_manager.c8
-rw-r--r--cdr/cdr_odbc.c1
-rw-r--r--cdr/cdr_pgsql.c2
-rw-r--r--cdr/cdr_radius.c3
-rw-r--r--cdr/cdr_tds.c7
-rw-r--r--channels/chan_agent.c11
-rw-r--r--channels/chan_h323.c2
-rw-r--r--channels/chan_iax2.c3
-rw-r--r--channels/chan_jingle.c2
-rw-r--r--channels/chan_mgcp.c3
-rw-r--r--channels/chan_misdn.c2
-rw-r--r--channels/chan_oss.c2
-rw-r--r--channels/chan_phone.c2
-rw-r--r--channels/chan_sip.c4
-rw-r--r--channels/chan_skinny.c4
-rw-r--r--channels/chan_vpb.cc2
-rw-r--r--channels/chan_zap.c2
-rw-r--r--funcs/func_odbc.c2
-rw-r--r--pbx/pbx_config.c10
-rw-r--r--pbx/pbx_dundi.c3
-rw-r--r--res/res_config_pgsql.c93
-rw-r--r--res/res_features.c276
-rw-r--r--res/res_indications.c5
-rw-r--r--res/res_jabber.c33
-rw-r--r--res/res_odbc.c145
-rw-r--r--res/res_smdi.c2
-rw-r--r--res/res_snmp.c66
35 files changed, 403 insertions, 358 deletions
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index 5b745d0ab..41f715e8e 100644
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -743,6 +743,7 @@ static int load_config(void)
if(option_verbose >= 4)
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: No config file\n");
+ return 0;
}
else{
@@ -809,7 +810,7 @@ static int load_config(void)
}
ast_config_destroy(cfg);
}
- return 0;
+ return 1;
}
@@ -831,8 +832,10 @@ static int unload_module(void)
static int load_module(void)
{
- load_config();
- return ast_register_application(app, alarmreceiver_exec, synopsis, descrip);
+ if(load_config())
+ return ast_register_application(app, alarmreceiver_exec, synopsis, descrip);
+ else
+ return AST_MODULE_LOAD_DECLINE;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Alarm Receiver for Asterisk");
diff --git a/apps/app_festival.c b/apps/app_festival.c
index f6e1d7503..d365b2410 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -533,6 +533,12 @@ static int unload_module(void)
static int load_module(void)
{
+ struct ast_config *cfg = ast_config_load(FESTIVAL_CONFIG);
+ if (!cfg) {
+ ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ ast_config_destroy(cfg);
return ast_register_application(app, festival_exec, synopsis, descrip);
}
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 24f134d85..47bea4099 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -1098,7 +1098,8 @@ static int unload_module(void)
static int load_module(void)
{
- reload_followme();
+ if(!reload_followme())
+ return AST_MODULE_LOAD_DECLINE;
return ast_register_application(app, app_exec, synopsis, descrip);
}
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index c700e81ce..e5fcf9a51 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -1431,10 +1431,11 @@ static int osp_load(void)
ast_config_destroy(cfg);
} else {
ast_log(LOG_WARNING, "OSP: Unable to find configuration. OSP support disabled\n");
+ return 0;
}
ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
- return 0;
+ return 1;
}
static int osp_unload(void)
@@ -1606,7 +1607,9 @@ static int load_module(void)
{
int res;
- osp_load();
+ if(!osp_load())
+ return AST_MODULE_LOAD_DECLINE;
+
res = ast_cli_register(&osp_cli);
res |= ast_register_application(app1, ospauth_exec, synopsis1, descrip1);
res |= ast_register_application(app2, osplookup_exec, synopsis2, descrip2);
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 448e8ca74..878c67a4a 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3642,7 +3642,7 @@ static struct ast_custom_function queuememberlist_function = {
.read = queue_function_queuememberlist,
};
-static void reload_queues(void)
+static int reload_queues(void)
{
struct call_queue *q;
struct ast_config *cfg;
@@ -3656,7 +3656,7 @@ static void reload_queues(void)
if (!(cfg = ast_config_load("queues.conf"))) {
ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n");
- return;
+ return 0;
}
memset(interface, 0, sizeof(interface));
AST_LIST_LOCK(&queues);
@@ -3794,6 +3794,7 @@ static void reload_queues(void)
}
AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_UNLOCK(&queues);
+ return 1;
}
static int __queues_show(struct mansession *s, int manager, int fd, int argc, char **argv, int queue_show)
@@ -4359,7 +4360,10 @@ static int unload_module(void)
static int load_module(void)
{
int res;
-
+ if(!reload_queues())
+ return AST_MODULE_LOAD_DECLINE;
+ if (queue_persistent_members)
+ reload_queue_members();
res = ast_register_application(app, queue_exec, synopsis, descrip);
res |= ast_cli_register(&cli_show_queue);
res |= ast_cli_register(&cli_show_queues);
@@ -4381,12 +4385,6 @@ static int load_module(void)
res |= ast_custom_function_register(&queuewaitingcount_function);
res |= ast_devstate_add(statechange_queue, NULL);
- if (!res) {
- reload_queues();
- if (queue_persistent_members)
- reload_queue_members();
- }
-
return res;
}
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index e1da544c9..858525a58 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -7150,7 +7150,7 @@ char tmpstr[300];
}
-static void *rpt_master(void *ignore)
+static void *rpt_master(void *config)
{
int i,n;
pthread_attr_t attr;
@@ -7160,7 +7160,7 @@ char *this,*val;
/* go thru all the specified repeaters */
this = NULL;
n = 0;
- rpt_vars[n].cfg = ast_config_load("rpt.conf");
+ rpt_vars[n].cfg = config;
cfg = rpt_vars[n].cfg;
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf. Radio Repeater disabled.\n");
@@ -8030,7 +8030,12 @@ static int unload_module(void)
static int load_module(void)
{
- ast_pthread_create(&rpt_master_thread,NULL,rpt_master,NULL);
+ struct ast_config *cfg = ast_config_load("rpt.conf");
+ if (!cfg) {
+ ast_log(LOG_WARNING, "No such configuration file rpt.conf\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ ast_pthread_create(&rpt_master_thread,NULL,rpt_master,cfg);
/* Register cli extensions */
ast_cli_register(&cli_debug);
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index a599fb08f..5e88563b7 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -108,13 +108,13 @@ static int load_config(void)
if (!cfg) {
ast_log(LOG_WARNING, "unable to load config: %s\n", config);
- return -1;
+ return 0;
}
var = ast_variable_browse(cfg, "csv");
if (!var) {
ast_config_destroy(cfg);
- return -1;
+ return 0;
}
tmp = ast_variable_retrieve(cfg, "csv", "usegmtime");
@@ -142,7 +142,7 @@ static int load_config(void)
}
ast_config_destroy(cfg);
- return 0;
+ return 1;
}
static int append_string(char *buf, char *s, size_t bufsize)
@@ -321,7 +321,8 @@ static int load_module(void)
{
int res;
- load_config();
+ if(!load_config())
+ return AST_MODULE_LOAD_DECLINE;
res = ast_cdr_register(name, ast_module_info->description, csv_log);
if (res) {
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c
index e89f022d0..803c3d9b7 100644
--- a/cdr/cdr_custom.c
+++ b/cdr/cdr_custom.c
@@ -153,8 +153,9 @@ static int load_module(void)
ast_log(LOG_ERROR, "Unable to register custom CDR handling\n");
if (mf)
fclose(mf);
- }
- return res;
+ return res;
+ } else
+ return AST_MODULE_LOAD_DECLINE;
}
static int reload(void)
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index 07406734d..4e43a30ff 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -49,7 +49,7 @@ static char *name = "cdr_manager";
static int enablecdr = 0;
-static void loadconfigurationfile(void)
+static int loadconfigurationfile(void)
{
char *cat;
struct ast_config *cfg;
@@ -59,7 +59,7 @@ static void loadconfigurationfile(void)
if (!cfg) {
/* Standard configuration */
enablecdr = 0;
- return;
+ return 0;
}
cat = ast_category_browse(cfg, NULL);
@@ -80,6 +80,7 @@ static void loadconfigurationfile(void)
}
ast_config_destroy(cfg);
+ return 1;
}
static int manager_log(struct ast_cdr *cdr)
@@ -145,7 +146,8 @@ static int load_module(void)
int res;
/* Configuration file */
- loadconfigurationfile();
+ if(loadconfigurationfile())
+ return AST_MODULE_LOAD_DECLINE;
res = ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log);
if (res) {
diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c
index 51d77a140..18ba1654d 100644
--- a/cdr/cdr_odbc.c
+++ b/cdr/cdr_odbc.c
@@ -253,6 +253,7 @@ static int odbc_load_module(void)
cfg = ast_config_load(config);
if (!cfg) {
ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config);
+ res = AST_MODULE_LOAD_DECLINE;
goto out;
}
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index f477584b5..500554cc1 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -289,7 +289,7 @@ static int my_load_module(void)
if (!(cfg = ast_config_load(config))) {
ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
res = process_my_load_module(cfg);
diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c
index ac59d4bd1..dbbdd1715 100644
--- a/cdr/cdr_radius.c
+++ b/cdr/cdr_radius.c
@@ -247,7 +247,8 @@ static int load_module(void)
if ((tmp = ast_variable_retrieve(cfg, "radius", "radiuscfg")))
ast_copy_string(radiuscfg, tmp, sizeof(radiuscfg));
ast_config_destroy(cfg);
- }
+ } else
+ return AST_MODULE_LOAD_DECLINE;
/* start logging */
rc_openlog("asterisk");
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
index 868768e64..07bb17752 100644
--- a/cdr/cdr_tds.c
+++ b/cdr/cdr_tds.c
@@ -504,8 +504,11 @@ static int reload(void)
}
static int load_module(void)
-{
- return tds_load_module();
+
+ if(!tds_load_module())
+ return AST_MODULE_LOAD_DECLINE;
+ else
+ return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 4eeffe99c..2db3faf18 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -1113,7 +1113,7 @@ static int read_agent_config(void)
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&agents);
ast_config_destroy(cfg);
- return 0;
+ return 1;
}
static int check_availability(struct agent_pvt *newlyavailable, int needlock)
@@ -2547,6 +2547,11 @@ static int load_module(void)
ast_log(LOG_ERROR, "Unable to register channel class 'Agent'\n");
return -1;
}
+ /* Read in the config */
+ if (!read_agent_config())
+ return AST_MODULE_LOAD_DECLINE;
+ if (persistent_agents)
+ reload_agents();
/* Dialplan applications */
ast_register_application(app, login_exec, synopsis, descrip);
ast_register_application(app2, callback_exec, synopsis2, descrip2);
@@ -2565,10 +2570,6 @@ static int load_module(void)
/* Dialplan Functions */
ast_custom_function_register(&agent_function);
- /* Read in the config */
- read_agent_config();
- if (persistent_agents)
- reload_agents();
return 0;
}
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index dc498a2d9..ded2afbd5 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -2389,7 +2389,7 @@ static int load_module(void *mod)
}
res = reload_config();
if (res) {
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
} else {
/* Make sure we can register our channel type */
if (ast_channel_register(&oh323_tech)) {
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 60841e0ae..7d90a087a 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -9798,7 +9798,8 @@ static int load_module(void)
ast_manager_register( "IAXpeers", 0, manager_iax2_show_peers, "List IAX Peers" );
ast_manager_register( "IAXnetstats", 0, manager_iax2_show_netstats, "Show IAX Netstats" );
- set_config(config, 0);
+ if(set_config(config, 0) == -1)
+ return AST_MODULE_LOAD_DECLINE;
if (ast_channel_register(&iax2_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", "IAX2");
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index a44b42085..c2dc460f7 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -1668,7 +1668,7 @@ static int load_module(void)
ASTOBJ_CONTAINER_INIT(&jingles);
if (!jingle_load_config()) {
ast_log(LOG_ERROR, "Unable to read config file %s. Not loading module.\n", JINGLE_CONFIG);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
sched = sched_context_create();
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 05ab81edf..1a27fc8f0 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -4262,7 +4262,8 @@ static int load_module(void)
/* And start the monitor for the first time */
restart_monitor();
- }
+ } else
+ return AST_MODULE_LOAD_DECLINE;
return res;
}
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 201d38c39..6815056f2 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -4499,7 +4499,7 @@ static int load_module(void)
if (misdn_cfg_init(max_ports)) {
ast_log(LOG_ERROR, "Unable to initialize misdn_config.\n");
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
g_config_initialized=1;
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index e40aacb0f..9ff6982c5 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -1551,7 +1551,7 @@ static int load_module(void)
ast_config_destroy(cfg);
} else {
ast_log(LOG_NOTICE, "Unable to load config oss.conf\n");
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
if (find_desc(oss_active) == NULL) {
ast_log(LOG_NOTICE, "Device %s not found\n", oss_active);
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index bb31ebae6..6e658ad3a 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -1353,7 +1353,7 @@ static int load_module(void)
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_mutex_lock(&iflock)) {
/* It's a little silly to lock it, but we mind as well just to be sure */
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index aed8b5828..a5c4d694c 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -16533,8 +16533,8 @@ static int load_module(void)
ast_log(LOG_WARNING, "Unable to create I/O context\n");
}
sip_reloadreason = CHANNEL_MODULE_LOAD;
- reload_config(sip_reloadreason); /* Load the configuration from sip.conf */
-
+ if(reload_config(sip_reloadreason)) /* Load the configuration from sip.conf */
+ return AST_MODULE_LOAD_DECLINE;
/* Make sure we can register our sip channel type */
if (ast_channel_register(&sip_tech)) {
ast_log(LOG_ERROR, "Unable to register channel type 'SIP'\n");
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 97c12455e..1f0ec6b33 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -4377,7 +4377,9 @@ static int load_module(void)
}
/* load and parse config */
res = reload_config();
-
+ if(!res) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
ast_rtp_proto_register(&skinny_rtp);
ast_cli_register(&cli_show_devices);
ast_cli_register(&cli_show_lines);
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index 26e1beea0..3d9707a77 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -2872,7 +2872,7 @@ int load_module()
/* We *must* have a config file otherwise stop immediately */
if (!cfg) {
ast_log(LOG_ERROR, "Unable to load config %s\n", config);
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
}
vpb_seterrormode(VPB_ERROR_CODE);
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 7c860ff50..ad3798646 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -11145,7 +11145,7 @@ static int load_module(void)
res = setup_zap(0);
/* Make sure we can register our Zap channel type */
if (res)
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
if (ast_channel_register(&zap_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'Zap'\n");
__unload_module();
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index b380c1b40..30f873e9f 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -486,7 +486,7 @@ static int odbc_load_module(void)
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to load config for func_odbc: %s\n", config);
AST_LIST_UNLOCK(&queries);
- return 0;
+ return AST_MODULE_LOAD_DECLINE;
}
for (catg = ast_category_browse(cfg, NULL);
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index dcfc4dcda..0689691f4 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1336,7 +1336,7 @@ static int unload_module(void)
return 0;
}
-static void pbx_load_config(const char *config_file)
+static int pbx_load_config(const char *config_file)
{
struct ast_config *cfg;
char *end;
@@ -1349,7 +1349,7 @@ static void pbx_load_config(const char *config_file)
cfg = ast_config_load(config_file);
if (!cfg)
- return;
+ return 0;
/* Use existing config to populate the PBX table */
static_config = ast_true(ast_variable_retrieve(cfg, "general", "static"));
@@ -1491,13 +1491,15 @@ static void pbx_load_config(const char *config_file)
}
}
ast_config_destroy(cfg);
+ return 1;
}
static int pbx_load_module(void)
{
struct ast_context *con;
- pbx_load_config(config);
+ if(!pbx_load_config(config))
+ return AST_MODULE_LOAD_DECLINE;
ast_merge_contexts_and_delete(&local_contexts, registrar);
for (con = NULL; (con = ast_walk_contexts(con));)
@@ -1511,7 +1513,7 @@ static int pbx_load_module(void)
static int load_module(void)
{
if (pbx_load_module())
- return -1;
+ return AST_MODULE_LOAD_DECLINE;
ast_cli_register(&context_remove_extension_cli);
ast_cli_register(&context_dont_include_cli);
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 190779c7c..338e77749 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -4488,7 +4488,8 @@ static int load_module(void)
return -1;
}
- set_config("dundi.conf",&sin);
+ if(set_config("dundi.conf",&sin))
+ return AST_MODULE_LOAD_DECLINE;
netsocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index f004bfd13..d3d11446a 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -553,7 +553,8 @@ static struct ast_config_engine pgsql_engine = {
static int load_module(void)
{
- parse_config();
+ if(!parse_config())
+ return AST_MODULE_LOAD_DECLINE;
ast_mutex_lock(&pgsql_lock);
@@ -624,61 +625,63 @@ static int reload(void)
return 0;
}
-int parse_config(void)
+static int parse_config(void)
{
struct ast_config *config;
char *s;
config = ast_config_load(RES_CONFIG_PGSQL_CONF);
- if (config) {
- if (!(s = ast_variable_retrieve(config, "general", "dbuser"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database user found, using 'asterisk' as default.\n");
- strcpy(dbuser, "asterisk");
- } else {
- ast_copy_string(dbuser, s, sizeof(dbuser));
- }
+ if (!config) {
+ ast_log(LOG_WARNING, "Unable to load config %s\n",RES_CONFIG_PGSQL_CONF);
+ return 0;
+ }
+ if (!(s = ast_variable_retrieve(config, "general", "dbuser"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database user found, using 'asterisk' as default.\n");
+ strcpy(dbuser, "asterisk");
+ } else {
+ ast_copy_string(dbuser, s, sizeof(dbuser));
+ }
- if (!(s = ast_variable_retrieve(config, "general", "dbpass"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database password found, using 'asterisk' as default.\n");
- strcpy(dbpass, "asterisk");
- } else {
- ast_copy_string(dbpass, s, sizeof(dbpass));
- }
+ if (!(s = ast_variable_retrieve(config, "general", "dbpass"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database password found, using 'asterisk' as default.\n");
+ strcpy(dbpass, "asterisk");
+ } else {
+ ast_copy_string(dbpass, s, sizeof(dbpass));
+ }
- if (!(s = ast_variable_retrieve(config, "general", "dbhost"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database host found, using localhost via socket.\n");
- dbhost[0] = '\0';
- } else {
- ast_copy_string(dbhost, s, sizeof(dbhost));
- }
+ if (!(s = ast_variable_retrieve(config, "general", "dbhost"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database host found, using localhost via socket.\n");
+ dbhost[0] = '\0';
+ } else {
+ ast_copy_string(dbhost, s, sizeof(dbhost));
+ }
- if (!(s = ast_variable_retrieve(config, "general", "dbname"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database name found, using 'asterisk' as default.\n");
- strcpy(dbname, "asterisk");
- } else {
- ast_copy_string(dbname, s, sizeof(dbname));
- }
+ if (!(s = ast_variable_retrieve(config, "general", "dbname"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database name found, using 'asterisk' as default.\n");
+ strcpy(dbname, "asterisk");
+ } else {
+ ast_copy_string(dbname, s, sizeof(dbname));
+ }
- if (!(s = ast_variable_retrieve(config, "general", "dbport"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database port found, using 5432 as default.\n");
- dbport = 5432;
- } else {
- dbport = atoi(s);
- }
+ if (!(s = ast_variable_retrieve(config, "general", "dbport"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database port found, using 5432 as default.\n");
+ dbport = 5432;
+ } else {
+ dbport = atoi(s);
+ }
- if (dbhost && !(s = ast_variable_retrieve(config, "general", "dbsock"))) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n");
- strcpy(dbsock, "/tmp/pgsql.sock");
- } else {
- ast_copy_string(dbsock, s, sizeof(dbsock));
- }
+ if (dbhost && !(s = ast_variable_retrieve(config, "general", "dbsock"))) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n");
+ strcpy(dbsock, "/tmp/pgsql.sock");
+ } else {
+ ast_copy_string(dbsock, s, sizeof(dbsock));
}
ast_config_destroy(config);
diff --git a/res/res_features.c b/res/res_features.c
index aba923fb8..88c728fdd 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -2113,153 +2113,155 @@ static int load_config(void)
atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
cfg = ast_config_load("features.conf");
- if (cfg) {
- for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
- if (!strcasecmp(var->name, "parkext")) {
- ast_copy_string(parking_ext, var->value, sizeof(parking_ext));
- } else if (!strcasecmp(var->name, "context")) {
- ast_copy_string(parking_con, var->value, sizeof(parking_con));
- } else if (!strcasecmp(var->name, "parkingtime")) {
- if ((sscanf(var->value, "%d", &parkingtime) != 1) || (parkingtime < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid parkingtime\n", var->value);
- parkingtime = DEFAULT_PARK_TIME;
- } else
- parkingtime = parkingtime * 1000;
- } else if (!strcasecmp(var->name, "parkpos")) {
- if (sscanf(var->value, "%d-%d", &start, &end) != 2) {
- ast_log(LOG_WARNING, "Format for parking positions is a-b, where a and b are numbers at line %d of parking.conf\n", var->lineno);
- } else {
- parking_start = start;
- parking_stop = end;
- }
- } else if (!strcasecmp(var->name, "findslot")) {
- parkfindnext = (!strcasecmp(var->value, "next"));
- } else if (!strcasecmp(var->name, "parkinghints")) {
- parkaddhints = ast_true(var->value);
- } else if (!strcasecmp(var->name, "adsipark")) {
- adsipark = ast_true(var->value);
- } else if (!strcasecmp(var->name, "transferdigittimeout")) {
- if ((sscanf(var->value, "%d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid transferdigittimeout\n", var->value);
- transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
- } else
- transferdigittimeout = transferdigittimeout * 1000;
- } else if (!strcasecmp(var->name, "featuredigittimeout")) {
- if ((sscanf(var->value, "%d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid featuredigittimeout\n", var->value);
- featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
- }
- } else if (!strcasecmp(var->name, "atxfernoanswertimeout")) {
- if ((sscanf(var->value, "%d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) {
- ast_log(LOG_WARNING, "%s is not a valid atxfernoanswertimeout\n", var->value);
- atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
- } else
- atxfernoanswertimeout = atxfernoanswertimeout * 1000;
- } else if (!strcasecmp(var->name, "courtesytone")) {
- ast_copy_string(courtesytone, var->value, sizeof(courtesytone));
- } else if (!strcasecmp(var->name, "parkedplay")) {
- if (!strcasecmp(var->value, "both"))
- parkedplay = 2;
- else if (!strcasecmp(var->value, "parked"))
- parkedplay = 1;
- else
- parkedplay = 0;
- } else if (!strcasecmp(var->name, "xfersound")) {
- ast_copy_string(xfersound, var->value, sizeof(xfersound));
- } else if (!strcasecmp(var->name, "xferfailsound")) {
- ast_copy_string(xferfailsound, var->value, sizeof(xferfailsound));
- } else if (!strcasecmp(var->name, "pickupexten")) {
- ast_copy_string(pickup_ext, var->value, sizeof(pickup_ext));
- } else if (!strcasecmp(var->name, "parkedmusicclass")) {
- ast_copy_string(parkmohclass, var->value, sizeof(parkmohclass));
+ if (!cfg) {
+ ast_log(LOG_WARNING,"Could not load features.conf\n");
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
+ if (!strcasecmp(var->name, "parkext")) {
+ ast_copy_string(parking_ext, var->value, sizeof(parking_ext));
+ } else if (!strcasecmp(var->name, "context")) {
+ ast_copy_string(parking_con, var->value, sizeof(parking_con));
+ } else if (!strcasecmp(var->name, "parkingtime")) {
+ if ((sscanf(var->value, "%d", &parkingtime) != 1) || (parkingtime < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid parkingtime\n", var->value);
+ parkingtime = DEFAULT_PARK_TIME;
+ } else
+ parkingtime = parkingtime * 1000;
+ } else if (!strcasecmp(var->name, "parkpos")) {
+ if (sscanf(var->value, "%d-%d", &start, &end) != 2) {
+ ast_log(LOG_WARNING, "Format for parking positions is a-b, where a and b are numbers at line %d of parking.conf\n", var->lineno);
+ } else {
+ parking_start = start;
+ parking_stop = end;
+ }
+ } else if (!strcasecmp(var->name, "findslot")) {
+ parkfindnext = (!strcasecmp(var->value, "next"));
+ } else if (!strcasecmp(var->name, "parkinghints")) {
+ parkaddhints = ast_true(var->value);
+ } else if (!strcasecmp(var->name, "adsipark")) {
+ adsipark = ast_true(var->value);
+ } else if (!strcasecmp(var->name, "transferdigittimeout")) {
+ if ((sscanf(var->value, "%d", &transferdigittimeout) != 1) || (transferdigittimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid transferdigittimeout\n", var->value);
+ transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
+ } else
+ transferdigittimeout = transferdigittimeout * 1000;
+ } else if (!strcasecmp(var->name, "featuredigittimeout")) {
+ if ((sscanf(var->value, "%d", &featuredigittimeout) != 1) || (featuredigittimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid featuredigittimeout\n", var->value);
+ featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
}
+ } else if (!strcasecmp(var->name, "atxfernoanswertimeout")) {
+ if ((sscanf(var->value, "%d", &atxfernoanswertimeout) != 1) || (atxfernoanswertimeout < 1)) {
+ ast_log(LOG_WARNING, "%s is not a valid atxfernoanswertimeout\n", var->value);
+ atxfernoanswertimeout = DEFAULT_NOANSWER_TIMEOUT_ATTENDED_TRANSFER;
+ } else
+ atxfernoanswertimeout = atxfernoanswertimeout * 1000;
+ } else if (!strcasecmp(var->name, "courtesytone")) {
+ ast_copy_string(courtesytone, var->value, sizeof(courtesytone));
+ } else if (!strcasecmp(var->name, "parkedplay")) {
+ if (!strcasecmp(var->value, "both"))
+ parkedplay = 2;
+ else if (!strcasecmp(var->value, "parked"))
+ parkedplay = 1;
+ else
+ parkedplay = 0;
+ } else if (!strcasecmp(var->name, "xfersound")) {
+ ast_copy_string(xfersound, var->value, sizeof(xfersound));
+ } else if (!strcasecmp(var->name, "xferfailsound")) {
+ ast_copy_string(xferfailsound, var->value, sizeof(xferfailsound));
+ } else if (!strcasecmp(var->name, "pickupexten")) {
+ ast_copy_string(pickup_ext, var->value, sizeof(pickup_ext));
+ } else if (!strcasecmp(var->name, "parkedmusicclass")) {
+ ast_copy_string(parkmohclass, var->value, sizeof(parkmohclass));
}
+ }
- unmap_features();
- for (var = ast_variable_browse(cfg, "featuremap"); var; var = var->next) {
- if (remap_feature(var->name, var->value))
- ast_log(LOG_NOTICE, "Unknown feature '%s'\n", var->name);
+ unmap_features();
+ for (var = ast_variable_browse(cfg, "featuremap"); var; var = var->next) {
+ if (remap_feature(var->name, var->value))
+ ast_log(LOG_NOTICE, "Unknown feature '%s'\n", var->name);
+ }
+
+ /* Map a key combination to an application*/
+ ast_unregister_features();
+ for (var = ast_variable_browse(cfg, "applicationmap"); var; var = var->next) {
+ char *tmp_val = ast_strdupa(var->value);
+ char *exten, *activateon, *activatedby, *app, *app_args, *moh_class;
+ struct ast_call_feature *feature;
+
+ /* strsep() sets the argument to NULL if match not found, and it
+ * is safe to use it with a NULL argument, so we don't check
+ * between calls.
+ */
+ exten = strsep(&tmp_val,",");
+ activatedby = strsep(&tmp_val,",");
+ app = strsep(&tmp_val,",");
+ app_args = strsep(&tmp_val,",");
+ moh_class = strsep(&tmp_val,",");
+
+ activateon = strsep(&activatedby, "/");
+
+ /*! \todo XXX var_name or app_args ? */
+ if (ast_strlen_zero(app) || ast_strlen_zero(exten) || ast_strlen_zero(activateon) || ast_strlen_zero(var->name)) {
+ ast_log(LOG_NOTICE, "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",
+ app, exten, activateon, var->name);
+ continue;
}
- /* Map a key combination to an application*/
- ast_unregister_features();
- for (var = ast_variable_browse(cfg, "applicationmap"); var; var = var->next) {
- char *tmp_val = ast_strdupa(var->value);
- char *exten, *activateon, *activatedby, *app, *app_args, *moh_class;
- struct ast_call_feature *feature;
-
- /* strsep() sets the argument to NULL if match not found, and it
- * is safe to use it with a NULL argument, so we don't check
- * between calls.
- */
- exten = strsep(&tmp_val,",");
- activatedby = strsep(&tmp_val,",");
- app = strsep(&tmp_val,",");
- app_args = strsep(&tmp_val,",");
- moh_class = strsep(&tmp_val,",");
-
- activateon = strsep(&activatedby, "/");
-
- /*! \todo XXX var_name or app_args ? */
- if (ast_strlen_zero(app) || ast_strlen_zero(exten) || ast_strlen_zero(activateon) || ast_strlen_zero(var->name)) {
- ast_log(LOG_NOTICE, "Please check the feature Mapping Syntax, either extension, name, or app aren't provided %s %s %s %s\n",
- app, exten, activateon, var->name);
- continue;
- }
+ if ((feature = find_feature(var->name))) {
+ ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n", var->name);
+ continue;
+ }
+
+ if (!(feature = ast_calloc(1, sizeof(*feature))))
+ continue;
- if ((feature = find_feature(var->name))) {
- ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n", var->name);
- continue;
- }
-
- if (!(feature = ast_calloc(1, sizeof(*feature))))
- continue;
+ ast_copy_string(feature->sname, var->name, FEATURE_SNAME_LEN);
+ ast_copy_string(feature->app, app, FEATURE_APP_LEN);
+ ast_copy_string(feature->exten, exten, FEATURE_EXTEN_LEN);
+
+ if (app_args)
+ ast_copy_string(feature->app_args, app_args, FEATURE_APP_ARGS_LEN);
- ast_copy_string(feature->sname, var->name, FEATURE_SNAME_LEN);
- ast_copy_string(feature->app, app, FEATURE_APP_LEN);
- ast_copy_string(feature->exten, exten, FEATURE_EXTEN_LEN);
+ if (moh_class)
+ ast_copy_string(feature->moh_class, moh_class, FEATURE_MOH_LEN);
- if (app_args)
- ast_copy_string(feature->app_args, app_args, FEATURE_APP_ARGS_LEN);
-
- if (moh_class)
- ast_copy_string(feature->moh_class, moh_class, FEATURE_MOH_LEN);
-
- ast_copy_string(feature->exten, exten, sizeof(feature->exten));
- feature->operation = feature_exec_app;
- ast_set_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF);
-
- /* Allow caller and calle to be specified for backwards compatability */
- if (!strcasecmp(activateon, "self") || !strcasecmp(activateon, "caller"))
- ast_set_flag(feature, AST_FEATURE_FLAG_ONSELF);
- else if (!strcasecmp(activateon, "peer") || !strcasecmp(activateon, "callee"))
- ast_set_flag(feature, AST_FEATURE_FLAG_ONPEER);
- else {
- ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
- " must be 'self', or 'peer'\n", var->name);
- continue;
- }
+ ast_copy_string(feature->exten, exten, sizeof(feature->exten));
+ feature->operation = feature_exec_app;
+ ast_set_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF);
+
+ /* Allow caller and calle to be specified for backwards compatability */
+ if (!strcasecmp(activateon, "self") || !strcasecmp(activateon, "caller"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_ONSELF);
+ else if (!strcasecmp(activateon, "peer") || !strcasecmp(activateon, "callee"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_ONPEER);
+ else {
+ ast_log(LOG_NOTICE, "Invalid 'ActivateOn' specification for feature '%s',"
+ " must be 'self', or 'peer'\n", var->name);
+ continue;
+ }
- if (ast_strlen_zero(activatedby))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
- else if (!strcasecmp(activatedby, "caller"))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLER);
- else if (!strcasecmp(activatedby, "callee"))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLEE);
- else if (!strcasecmp(activatedby, "both"))
- ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
- else {
- ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
- " must be 'caller', or 'callee', or 'both'\n", var->name);
- continue;
- }
+ if (ast_strlen_zero(activatedby))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+ else if (!strcasecmp(activatedby, "caller"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLER);
+ else if (!strcasecmp(activatedby, "callee"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYCALLEE);
+ else if (!strcasecmp(activatedby, "both"))
+ ast_set_flag(feature, AST_FEATURE_FLAG_BYBOTH);
+ else {
+ ast_log(LOG_NOTICE, "Invalid 'ActivatedBy' specification for feature '%s',"
+ " must be 'caller', or 'callee', or 'both'\n", var->name);
+ continue;
+ }
- ast_register_feature(feature);
-
- if (option_verbose >= 1)
- ast_verbose(VERBOSE_PREFIX_2 "Mapping Feature '%s' to app '%s(%s)' with code '%s'\n", var->name, app, app_args, exten);
- }
- }
+ ast_register_feature(feature);
+
+ if (option_verbose >= 1)
+ ast_verbose(VERBOSE_PREFIX_2 "Mapping Feature '%s' to app '%s(%s)' with code '%s'\n", var->name, app, app_args, exten);
+ }
ast_config_destroy(cfg);
/* Remove the old parking extension */
diff --git a/res/res_indications.c b/res/res_indications.c
index 18e79e2de..d12868d9c 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -238,7 +238,7 @@ static int ind_load_module(void)
/* yup, checked it out. It is NOT written to. */
cfg = ast_config_load((char *)config);
if (!cfg)
- return 0;
+ return -1;
/* Use existing config to populate the Indication table */
cxt = ast_category_browse(cfg, NULL);
@@ -381,8 +381,7 @@ static int unload_module(void)
static int load_module(void)
{
if (ind_load_module())
- return -1;
-
+ return AST_MODULE_LOAD_DECLINE;
ast_cli_register(&add_indication_cli);
ast_cli_register(&remove_indication_cli);
ast_cli_register(&show_indications_cli);
diff --git a/res/res_jabber.c b/res/res_jabber.c
index ed6d37321..0a98d2693 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -80,7 +80,7 @@ static int aji_show_clients(int fd, int argc, char *argv[]);
static int aji_create_client(char *label, struct ast_variable *var, int debug);
static int aji_create_buddy(char *label, struct aji_client *client);
static int aji_create_transport(char *label, struct aji_client *client);
-static void aji_reload(void);
+static int aji_reload(void);
static int aji_load_config(void);
static void aji_pruneregister(struct aji_client *client);
static int aji_register_transport(void *data, ikspak *pak);
@@ -2263,23 +2263,25 @@ static int manager_jabber_send( struct mansession *s, struct message *m )
}
-static void aji_reload()
+static int aji_reload()
{
ASTOBJ_CONTAINER_MARKALL(&clients);
- if (!aji_load_config())
+ if (!aji_load_config()) {
ast_log(LOG_ERROR, "JABBER: Failed to load config.\n");
- else {
- ASTOBJ_CONTAINER_PRUNE_MARKED(&clients, aji_client_destroy);
- ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
- ASTOBJ_RDLOCK(iterator);
- if(iterator->state == AJI_DISCONNECTED) {
- if (!iterator->thread)
- ast_pthread_create(&iterator->thread, NULL, aji_recv_loop, iterator);
- } else if (iterator->state == AJI_CONNECTING)
- aji_get_roster(iterator);
- ASTOBJ_UNLOCK(iterator);
- });
+ return 0;
}
+ ASTOBJ_CONTAINER_PRUNE_MARKED(&clients, aji_client_destroy);
+ ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
+ ASTOBJ_RDLOCK(iterator);
+ if(iterator->state == AJI_DISCONNECTED) {
+ if (!iterator->thread)
+ ast_pthread_create(&iterator->thread, NULL, aji_recv_loop, iterator);
+ } else if (iterator->state == AJI_CONNECTING)
+ aji_get_roster(iterator);
+ ASTOBJ_UNLOCK(iterator);
+ });
+
+ return 1;
}
static int unload_module(void)
@@ -2307,7 +2309,8 @@ static int unload_module(void)
static int load_module(void)
{
ASTOBJ_CONTAINER_INIT(&clients);
- aji_reload();
+ if(!aji_reload())
+ return AST_MODULE_LOAD_DECLINE;
ast_manager_register2("JabberSend", EVENT_FLAG_SYSTEM, manager_jabber_send,
"Sends a message to a Jabber Client", mandescr_jabber_send);
ast_register_application(app_ajisend, aji_send_exec, ajisend_synopsis, ajisend_descrip);
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 3d927b9a3..1d4f9b5af 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -216,89 +216,91 @@ static int load_odbc_config(void)
struct odbc_class *new;
config = ast_config_load(cfg);
- if (config) {
- for (cat = ast_category_browse(config, NULL); cat; cat=ast_category_browse(config, cat)) {
- if (!strcasecmp(cat, "ENV")) {
- for (v = ast_variable_browse(config, cat); v; v = v->next) {
- setenv(v->name, v->value, 1);
- ast_log(LOG_NOTICE, "Adding ENV var: %s=%s\n", v->name, v->value);
- }
- } else {
- /* Reset all to defaults for each class of odbc connections */
- dsn = username = password = NULL;
- enabled = 1;
- connect = 0;
- pooling = 0;
- limit = 0;
- for (v = ast_variable_browse(config, cat); v; v = v->next) {
- if (!strcasecmp(v->name, "pooling")) {
- pooling = 1;
- } else if (!strcasecmp(v->name, "limit")) {
- sscanf(v->value, "%d", &limit);
- if (ast_true(v->value) && !limit) {
- ast_log(LOG_WARNING, "Limit should be a number, not a boolean: '%s'. Setting limit to 1023 for ODBC class '%s'.\n", v->value, cat);
- limit = 1023;
- } else if (ast_false(v->value)) {
- ast_log(LOG_WARNING, "Limit should be a number, not a boolean: '%s'. Disabling ODBC class '%s'.\n", v->value, cat);
- enabled = 0;
- break;
- }
- } else if (!strcasecmp(v->name, "enabled")) {
- enabled = ast_true(v->value);
- } else if (!strcasecmp(v->name, "pre-connect")) {
- connect = ast_true(v->value);
- } else if (!strcasecmp(v->name, "dsn")) {
- dsn = v->value;
- } else if (!strcasecmp(v->name, "username")) {
- username = v->value;
- } else if (!strcasecmp(v->name, "password")) {
- password = v->value;
+ if (!config) {
+ ast_log(LOG_WARNING, "Unable to load config file res_odbc.conf\n");
+ return -1;
+ }
+ for (cat = ast_category_browse(config, NULL); cat; cat=ast_category_browse(config, cat)) {
+ if (!strcasecmp(cat, "ENV")) {
+ for (v = ast_variable_browse(config, cat); v; v = v->next) {
+ setenv(v->name, v->value, 1);
+ ast_log(LOG_NOTICE, "Adding ENV var: %s=%s\n", v->name, v->value);
+ }
+ } else {
+ /* Reset all to defaults for each class of odbc connections */
+ dsn = username = password = NULL;
+ enabled = 1;
+ connect = 0;
+ pooling = 0;
+ limit = 0;
+ for (v = ast_variable_browse(config, cat); v; v = v->next) {
+ if (!strcasecmp(v->name, "pooling")) {
+ pooling = 1;
+ } else if (!strcasecmp(v->name, "limit")) {
+ sscanf(v->value, "%d", &limit);
+ if (ast_true(v->value) && !limit) {
+ ast_log(LOG_WARNING, "Limit should be a number, not a boolean: '%s'. Setting limit to 1023 for ODBC class '%s'.\n", v->value, cat);
+ limit = 1023;
+ } else if (ast_false(v->value)) {
+ ast_log(LOG_WARNING, "Limit should be a number, not a boolean: '%s'. Disabling ODBC class '%s'.\n", v->value, cat);
+ enabled = 0;
+ break;
}
+ } else if (!strcasecmp(v->name, "enabled")) {
+ enabled = ast_true(v->value);
+ } else if (!strcasecmp(v->name, "pre-connect")) {
+ connect = ast_true(v->value);
+ } else if (!strcasecmp(v->name, "dsn")) {
+ dsn = v->value;
+ } else if (!strcasecmp(v->name, "username")) {
+ username = v->value;
+ } else if (!strcasecmp(v->name, "password")) {
+ password = v->value;
}
+ }
- if (enabled && !ast_strlen_zero(dsn)) {
- new = ast_calloc(1, sizeof(*new));
+ if (enabled && !ast_strlen_zero(dsn)) {
+ new = ast_calloc(1, sizeof(*new));
- if (!new) {
- res = -1;
- break;
- }
+ if (!new) {
+ res = -1;
+ break;
+ }
- if (cat)
- ast_copy_string(new->name, cat, sizeof(new->name));
- if (dsn)
- ast_copy_string(new->dsn, dsn, sizeof(new->dsn));
- if (username)
- ast_copy_string(new->username, username, sizeof(new->username));
- if (password)
- ast_copy_string(new->password, password, sizeof(new->password));
+ if (cat)
+ ast_copy_string(new->name, cat, sizeof(new->name));
+ if (dsn)
+ ast_copy_string(new->dsn, dsn, sizeof(new->dsn));
+ if (username)
+ ast_copy_string(new->username, username, sizeof(new->username));
+ if (password)
+ ast_copy_string(new->password, password, sizeof(new->password));
- SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &new->env);
- res = SQLSetEnvAttr(new->env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
+ SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &new->env);
+ res = SQLSetEnvAttr(new->env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
- if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
- ast_log(LOG_WARNING, "res_odbc: Error SetEnv\n");
- SQLFreeHandle(SQL_HANDLE_ENV, new->env);
- return res;
- }
+ if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+ ast_log(LOG_WARNING, "res_odbc: Error SetEnv\n");
+ SQLFreeHandle(SQL_HANDLE_ENV, new->env);
+ return res;
+ }
- if (pooling) {
- new->haspool = pooling;
- if (limit) {
- new->limit = limit;
- } else {
- ast_log(LOG_WARNING, "Pooling without also setting a limit is pointless. Changing limit from 0 to 5.\n");
- new->limit = 5;
- }
+ if (pooling) {
+ new->haspool = pooling;
+ if (limit) {
+ new->limit = limit;
+ } else {
+ ast_log(LOG_WARNING, "Pooling without also setting a limit is pointless. Changing limit from 0 to 5.\n");
+ new->limit = 5;
}
-
- odbc_register_class(new, connect);
- ast_log(LOG_NOTICE, "Registered ODBC class '%s' dsn->[%s]\n", cat, dsn);
}
+
+ odbc_register_class(new, connect);
+ ast_log(LOG_NOTICE, "Registered ODBC class '%s' dsn->[%s]\n", cat, dsn);
}
}
- ast_config_destroy(config);
}
+ ast_config_destroy(config);
return res;
}
@@ -664,7 +666,8 @@ static int unload_module(void)
static int load_module(void)
{
- load_odbc_config();
+ if(load_odbc_config() == -1)
+ return AST_MODULE_LOAD_DECLINE;
ast_cli_register(&odbc_show_struct);
ast_log(LOG_NOTICE, "res_odbc loaded.\n");
return 0;
diff --git a/res/res_smdi.c b/res/res_smdi.c
index 5bb213bca..c939aba27 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -720,7 +720,7 @@ static int load_module(void)
return res;
} else if (res == 1) {
ast_log(LOG_WARNING, "No SMDI interfaces are available to listen on, not starting SDMI listener.\n");
- return 0;
+ return AST_MODULE_LOAD_DECLINE;;
} else
return 0;
}
diff --git a/res/res_snmp.c b/res/res_snmp.c
index d52329372..fbef97f0a 100644
--- a/res/res_snmp.c
+++ b/res/res_snmp.c
@@ -46,49 +46,51 @@ static int load_config(void)
res_snmp_enabled = 0;
res_snmp_agentx_subagent = 1;
cfg = ast_config_load("res_snmp.conf");
- if (cfg) {
- cat = ast_category_browse(cfg, NULL);
- while (cat) {
- var = ast_variable_browse(cfg, cat);
-
- if (strcasecmp(cat, "general") == 0) {
- while (var) {
- if (strcasecmp(var->name, "subagent") == 0) {
- if (ast_true(var->value))
- res_snmp_agentx_subagent = 1;
- else if (ast_false(var->value))
- res_snmp_agentx_subagent = 0;
- else {
- ast_log(LOG_ERROR, "Value '%s' does not evaluate to true or false.\n", var->value);
- ast_config_destroy(cfg);
- return 1;
- }
- } else if (strcasecmp(var->name, "enabled") == 0) {
- res_snmp_enabled = ast_true(var->value);
- } else {
- ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat);
+ if (!cfg) {
+ ast_log(LOG_WARNING, "Could not load res_snmp.conf\n");
+ return 0;
+ }
+ cat = ast_category_browse(cfg, NULL);
+ while (cat) {
+ var = ast_variable_browse(cfg, cat);
+
+ if (strcasecmp(cat, "general") == 0) {
+ while (var) {
+ if (strcasecmp(var->name, "subagent") == 0) {
+ if (ast_true(var->value))
+ res_snmp_agentx_subagent = 1;
+ else if (ast_false(var->value))
+ res_snmp_agentx_subagent = 0;
+ else {
+ ast_log(LOG_ERROR, "Value '%s' does not evaluate to true or false.\n", var->value);
ast_config_destroy(cfg);
return 1;
}
- var = var->next;
+ } else if (strcasecmp(var->name, "enabled") == 0) {
+ res_snmp_enabled = ast_true(var->value);
+ } else {
+ ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat);
+ ast_config_destroy(cfg);
+ return 1;
}
- } else {
- ast_log(LOG_ERROR, "Unrecognized category '%s'\n", cat);
- ast_config_destroy(cfg);
- return 1;
+ var = var->next;
}
-
- cat = ast_category_browse(cfg, cat);
+ } else {
+ ast_log(LOG_ERROR, "Unrecognized category '%s'\n", cat);
+ ast_config_destroy(cfg);
+ return 1;
}
- ast_config_destroy(cfg);
- }
- return 0;
+ cat = ast_category_browse(cfg, cat);
+ }
+ ast_config_destroy(cfg);
+ return 1;
}
static int load_module(void)
{
- load_config();
+ if(!load_config())
+ return AST_MODULE_LOAD_DECLINE;
ast_verbose(VERBOSE_PREFIX_1 "Loading [Sub]Agent Module\n");