mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Make res_snmp fit general coding style (issue #7192 reported by Mithraen)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@39512 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -39,14 +39,14 @@ static pthread_t thread = AST_PTHREADT_NULL;
|
|||||||
|
|
||||||
static int load_config(void)
|
static int load_config(void)
|
||||||
{
|
{
|
||||||
struct ast_variable *var;
|
struct ast_variable *var;
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
char *cat;
|
char *cat;
|
||||||
|
|
||||||
res_snmp_enabled = 0;
|
res_snmp_enabled = 0;
|
||||||
res_snmp_agentx_subagent = 1;
|
res_snmp_agentx_subagent = 1;
|
||||||
cfg = ast_config_load("res_snmp.conf");
|
cfg = ast_config_load("res_snmp.conf");
|
||||||
if (cfg) {
|
if (cfg) {
|
||||||
cat = ast_category_browse(cfg, NULL);
|
cat = ast_category_browse(cfg, NULL);
|
||||||
while (cat) {
|
while (cat) {
|
||||||
var = ast_variable_browse(cfg, cat);
|
var = ast_variable_browse(cfg, cat);
|
||||||
@@ -59,23 +59,20 @@ static int load_config(void)
|
|||||||
else if (ast_false(var->value))
|
else if (ast_false(var->value))
|
||||||
res_snmp_agentx_subagent = 0;
|
res_snmp_agentx_subagent = 0;
|
||||||
else {
|
else {
|
||||||
ast_log(LOG_ERROR, "Value '%s' does not evaluate to true or false.\n",
|
ast_log(LOG_ERROR, "Value '%s' does not evaluate to true or false.\n", var->value);
|
||||||
var->value);
|
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (strcasecmp(var->name, "enabled") == 0) {
|
} else if (strcasecmp(var->name, "enabled") == 0) {
|
||||||
res_snmp_enabled = ast_true(var->value);
|
res_snmp_enabled = ast_true(var->value);
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n",
|
ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat);
|
||||||
var->name, cat);
|
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
var = var->next;
|
var = var->next;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ast_log(LOG_ERROR, "Unrecognized category '%s'\n", cat);
|
ast_log(LOG_ERROR, "Unrecognized category '%s'\n", cat);
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -84,57 +81,57 @@ static int load_config(void)
|
|||||||
cat = ast_category_browse(cfg, cat);
|
cat = ast_category_browse(cfg, cat);
|
||||||
}
|
}
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_module(void *mod)
|
static int load_module(void *mod)
|
||||||
{
|
{
|
||||||
load_config();
|
load_config();
|
||||||
|
|
||||||
ast_verbose(VERBOSE_PREFIX_1 "Loading [Sub]Agent Module\n");
|
ast_verbose(VERBOSE_PREFIX_1 "Loading [Sub]Agent Module\n");
|
||||||
|
|
||||||
res_snmp_dont_stop = 1;
|
res_snmp_dont_stop = 1;
|
||||||
if (res_snmp_enabled)
|
if (res_snmp_enabled)
|
||||||
return ast_pthread_create(&thread, NULL, agent_thread, NULL);
|
return ast_pthread_create(&thread, NULL, agent_thread, NULL);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unload_module(void *mod)
|
static int unload_module(void *mod)
|
||||||
{
|
{
|
||||||
ast_verbose(VERBOSE_PREFIX_1 "Unloading [Sub]Agent Module\n");
|
ast_verbose(VERBOSE_PREFIX_1 "Unloading [Sub]Agent Module\n");
|
||||||
|
|
||||||
res_snmp_dont_stop = 0;
|
res_snmp_dont_stop = 0;
|
||||||
return pthread_join(thread, NULL);
|
return pthread_join(thread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reload(void *mod)
|
static int reload(void *mod)
|
||||||
{
|
{
|
||||||
ast_verbose(VERBOSE_PREFIX_1 "Reloading [Sub]Agent Module\n");
|
ast_verbose(VERBOSE_PREFIX_1 "Reloading [Sub]Agent Module\n");
|
||||||
|
|
||||||
res_snmp_dont_stop = 0;
|
res_snmp_dont_stop = 0;
|
||||||
if (thread != AST_PTHREADT_NULL)
|
if (thread != AST_PTHREADT_NULL)
|
||||||
pthread_join(thread, NULL);
|
pthread_join(thread, NULL);
|
||||||
thread = AST_PTHREADT_NULL;
|
thread = AST_PTHREADT_NULL;
|
||||||
load_config();
|
load_config();
|
||||||
|
|
||||||
res_snmp_dont_stop = 1;
|
res_snmp_dont_stop = 1;
|
||||||
if (res_snmp_enabled)
|
if (res_snmp_enabled)
|
||||||
return ast_pthread_create(&thread, NULL, agent_thread, NULL);
|
return ast_pthread_create(&thread, NULL, agent_thread, NULL);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *key(void)
|
static const char *key(void)
|
||||||
{
|
{
|
||||||
return ASTERISK_GPL_KEY;
|
return ASTERISK_GPL_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *description(void)
|
static const char *description(void)
|
||||||
{
|
{
|
||||||
return MODULE_DESCRIPTION;
|
return MODULE_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
STD_MOD(MOD_0, reload, NULL, NULL);
|
STD_MOD(MOD_0, reload, NULL, NULL);
|
||||||
|
Reference in New Issue
Block a user