aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_snmp.c
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 /res/res_snmp.c
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
Diffstat (limited to 'res/res_snmp.c')
-rw-r--r--res/res_snmp.c66
1 files changed, 34 insertions, 32 deletions
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");