aboutsummaryrefslogtreecommitdiffstats
path: root/main/dnsmgr.c
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 22:43:45 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 22:43:45 +0000
commitab51c0d7fad1957b36454533cd8e786ed66efa61 (patch)
treed49317ce7050cdca6ecef46706a320e879421c61 /main/dnsmgr.c
parentcedd5ba68f094ce4082e42b47674c0f1c01d447d (diff)
(issue #10724)
Reported by: eliel Patches: res_features.c.patch uploaded by eliel (license 64) res_agi.c.patch uploaded by seanbright (license 71) res_musiconhold.c.patch uploaded by seanbright (license 71) pbx.c.patch uploaded by moy (license 222) logger.c.patch uploaded by moy (license 222) frame.c.patch uploaded by moy (license 222) manager.c.patch uploaded by moy (license 222) http.c.patch uploaded by moy (license 222) dnsmgr.c.patch uploaded by moy (license 222) res_realtime.c.patch uploaded by eliel (license 64) res_odbc.c.patch uploaded by seanbright (license 71) res_jabber.c.patch uploaded by eliel (license 64) chan_local.c.patch uploaded by eliel (license 64) chan_agent.c.patch uploaded by eliel (license 64) chan_alsa.c.patch uploaded by eliel (license 64) chan_features.c.patch uploaded by eliel (license 64) chan_sip.c.patch uploaded by eliel (license 64) RollUp.1.patch (includes all of the above patches) uploaded by seanbright (license 71) Convert many CLI commands to the NEW_CLI format. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82930 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/dnsmgr.c')
-rw-r--r--main/dnsmgr.c93
1 files changed, 53 insertions, 40 deletions
diff --git a/main/dnsmgr.c b/main/dnsmgr.c
index d1e5dd30b..ea79d85d0 100644
--- a/main/dnsmgr.c
+++ b/main/dnsmgr.c
@@ -255,28 +255,48 @@ void dnsmgr_start_refresh(void)
static int do_reload(int loading);
-static int handle_cli_reload(int fd, int argc, char *argv[])
+static char *handle_cli_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- if (argc > 2)
- return RESULT_SHOWUSAGE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "dnsmgr reload";
+ e->usage =
+ "Usage: dnsmgr reload\n"
+ " Reloads the DNS manager configuration.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+ if (a->argc > 2)
+ return CLI_SHOWUSAGE;
do_reload(0);
- return 0;
+ return CLI_SUCCESS;
}
-static int handle_cli_refresh(int fd, int argc, char *argv[])
+static char *handle_cli_refresh(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct refresh_info info = {
.entries = &entry_list,
.verbose = 1,
};
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "dnsmgr refresh";
+ e->usage =
+ "Usage: dnsmgr refresh [pattern]\n"
+ " Peforms an immediate refresh of the managed DNS entries.\n"
+ " Optional regular expression pattern is used to filter the entries to refresh.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+ if (a->argc > 3)
+ return CLI_SHOWUSAGE;
- if (argc > 3)
- return RESULT_SHOWUSAGE;
-
- if (argc == 3) {
- if (regcomp(&info.filter, argv[2], REG_EXTENDED | REG_NOSUB))
- return RESULT_SHOWUSAGE;
+ if (a->argc == 3) {
+ if ( regcomp(&info.filter, a->argv[2], REG_EXTENDED | REG_NOSUB) )
+ return CLI_SHOWUSAGE;
else
info.regex_present = 1;
}
@@ -286,49 +306,41 @@ static int handle_cli_refresh(int fd, int argc, char *argv[])
if (info.regex_present)
regfree(&info.filter);
- return 0;
+ return CLI_SUCCESS;
}
-static int handle_cli_status(int fd, int argc, char *argv[])
+static char *handle_cli_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int count = 0;
struct ast_dnsmgr_entry *entry;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "dnsmgr status";
+ e->usage =
+ "Usage: dnsmgr status\n"
+ " Displays the DNS manager status.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
- if (argc > 2)
- return RESULT_SHOWUSAGE;
+ if (a->argc > 2)
+ return CLI_SHOWUSAGE;
- ast_cli(fd, "DNS Manager: %s\n", enabled ? "enabled" : "disabled");
- ast_cli(fd, "Refresh Interval: %d seconds\n", refresh_interval);
+ ast_cli(a->fd, "DNS Manager: %s\n", enabled ? "enabled" : "disabled");
+ ast_cli(a->fd, "Refresh Interval: %d seconds\n", refresh_interval);
AST_RWLIST_RDLOCK(&entry_list);
AST_RWLIST_TRAVERSE(&entry_list, entry, list)
count++;
AST_RWLIST_UNLOCK(&entry_list);
- ast_cli(fd, "Number of entries: %d\n", count);
+ ast_cli(a->fd, "Number of entries: %d\n", count);
- return 0;
+ return CLI_SUCCESS;
}
-static struct ast_cli_entry cli_reload = {
- { "dnsmgr", "reload", NULL },
- handle_cli_reload, "Reloads the DNS manager configuration",
- "Usage: dnsmgr reload\n"
- " Reloads the DNS manager configuration.\n"
-};
-
-static struct ast_cli_entry cli_refresh = {
- { "dnsmgr", "refresh", NULL },
- handle_cli_refresh, "Performs an immediate refresh",
- "Usage: dnsmgr refresh [pattern]\n"
- " Peforms an immediate refresh of the managed DNS entries.\n"
- " Optional regular expression pattern is used to filter the entries to refresh.\n",
-};
-
-static struct ast_cli_entry cli_status = {
- { "dnsmgr", "status", NULL },
- handle_cli_status, "Display the DNS manager status",
- "Usage: dnsmgr status\n"
- " Displays the DNS manager status.\n"
-};
+static struct ast_cli_entry cli_reload = NEW_CLI(handle_cli_reload, "Reloads the DNS manager configuration");
+static struct ast_cli_entry cli_refresh = NEW_CLI(handle_cli_refresh, "Performs an immediate refresh");
+static struct ast_cli_entry cli_status = NEW_CLI(handle_cli_status, "Display the DNS manager status");
int dnsmgr_init(void)
{
@@ -338,6 +350,7 @@ int dnsmgr_init(void)
}
ast_cli_register(&cli_reload);
ast_cli_register(&cli_status);
+ ast_cli_register(&cli_refresh);
return do_reload(1);
}