aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_realtime.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 /res/res_realtime.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 'res/res_realtime.c')
-rw-r--r--res/res_realtime.c84
1 files changed, 47 insertions, 37 deletions
diff --git a/res/res_realtime.c b/res/res_realtime.c
index 3981e74f1..e560e02a3 100644
--- a/res/res_realtime.c
+++ b/res/res_realtime.c
@@ -47,68 +47,78 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cli.h"
-static int cli_realtime_load(int fd, int argc, char **argv)
+static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
char *header_format = "%30s %-30s\n";
struct ast_variable *var=NULL;
- if(argc<5) {
- ast_cli(fd, "You must supply a family name, a column to match on, and a value to match to.\n");
- return RESULT_FAILURE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "realtime load";
+ e->usage =
+ "Usage: realtime load <family> <colmatch> <value>\n"
+ " Prints out a list of variables using the RealTime driver.\n"
+ " You must supply a family name, a column to match on, and a value to match to.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
}
- var = ast_load_realtime_all(argv[2], argv[3], argv[4], NULL);
- if(var) {
- ast_cli(fd, header_format, "Column Name", "Column Value");
- ast_cli(fd, header_format, "--------------------", "--------------------");
- while(var) {
- ast_cli(fd, header_format, var->name, var->value);
+ if (a->argc < 5)
+ return CLI_SHOWUSAGE;
+
+ var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], NULL);
+
+ if (var) {
+ ast_cli(a->fd, header_format, "Column Name", "Column Value");
+ ast_cli(a->fd, header_format, "--------------------", "--------------------");
+ while (var) {
+ ast_cli(a->fd, header_format, var->name, var->value);
var = var->next;
}
} else {
- ast_cli(fd, "No rows found matching search criteria.\n");
+ ast_cli(a->fd, "No rows found matching search criteria.\n");
}
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static int cli_realtime_update(int fd, int argc, char **argv) {
+static char *cli_realtime_update(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) {
int res = 0;
- if(argc<7) {
- ast_cli(fd, "You must supply a family name, a column to update on, a new value, column to match, and value to to match.\n");
- ast_cli(fd, "Ex: realtime update sipfriends name bobsphone port 4343\n will execute SQL as UPDATE sipfriends SET port = 4343 WHERE name = bobsphone\n");
- return RESULT_FAILURE;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "realtime update";
+ e->usage =
+ "Usage: realtime update <family> <colupdate> <newvalue> <colmatch> <valuematch>\n"
+ " Update a single variable using the RealTime driver.\n"
+ " You must supply a family name, a column to update on, a new value, column to match, and value to match.\n"
+ " Ex: realtime update sipfriends name bobsphone port 4343\n"
+ " will execute SQL as UPDATE sipfriends SET port = 4343 WHERE name = bobsphone\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
}
- res = ast_update_realtime(argv[2], argv[3], argv[4], argv[5], argv[6], NULL);
+
+ if (a->argc < 7)
+ return CLI_SHOWUSAGE;
+
+ res = ast_update_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], NULL);
if(res < 0) {
- ast_cli(fd, "Failed to update. Check the debug log for possible SQL related entries.\n");
- return RESULT_SUCCESS;
+ ast_cli(a->fd, "Failed to update. Check the debug log for possible SQL related entries.\n");
+ return CLI_FAILURE;
}
- ast_cli(fd, "Updated %d RealTime record%s.\n", res, ESS(res));
+ ast_cli(a->fd, "Updated %d RealTime record%s.\n", res, ESS(res));
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
-static const char cli_realtime_load_usage[] =
-"Usage: realtime load <family> <colmatch> <value>\n"
-" Prints out a list of variables using the RealTime driver.\n";
-
-static const char cli_realtime_update_usage[] =
-"Usage: realtime update <family> <colmatch> <value>\n"
-" Update a single variable using the RealTime driver.\n";
-
static struct ast_cli_entry cli_realtime[] = {
- { { "realtime", "load", NULL, NULL },
- cli_realtime_load, "Used to print out RealTime variables.",
- cli_realtime_load_usage, NULL },
-
- { { "realtime", "update", NULL, NULL },
- cli_realtime_update, "Used to update RealTime variables.",
- cli_realtime_update_usage, NULL },
+ NEW_CLI(cli_realtime_load, "Used to print out RealTime variables."),
+ NEW_CLI(cli_realtime_update, "Used to update RealTime variables."),
};
static int unload_module(void)