summaryrefslogtreecommitdiff
path: root/res/res_snmp.c
diff options
context:
space:
mode:
authorMatt O'Gorman <mogorman@digium.com>2006-08-31 21:00:20 +0000
committerMatt O'Gorman <mogorman@digium.com>2006-08-31 21:00:20 +0000
commit05a695af721cb8002f3d462c6952f45f0e9c5d9e (patch)
tree5eac7fd790352b502dbbc4fc21ae517fe7c388ad /res/res_snmp.c
parentf2b836ff4f9f34c48f36b9aca18c633834dc0ace (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: https://origsvn.digium.com/svn/asterisk/trunk@41633 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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");