aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_clioriginate.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-11 19:03:06 +0000
commit13b9c5237c9f5b8b3d72634d575665b1d1147ba3 (patch)
tree44dcb2c14abed6932db4f248b17626a01a38f59b /res/res_clioriginate.c
parenta8506328befc2a11643cea88772609610ec11c33 (diff)
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :)
(closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_clioriginate.c')
-rw-r--r--res/res_clioriginate.c135
1 files changed, 60 insertions, 75 deletions
diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c
index 8497f6387..7a9245aba 100644
--- a/res/res_clioriginate.c
+++ b/res/res_clioriginate.c
@@ -43,61 +43,35 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
/*! The timeout for originated calls, in seconds */
#define TIMEOUT 30
-static char orig_help[] =
-" There are two ways to use this command. A call can be originated between a\n"
-"channel and a specific application, or between a channel and an extension in\n"
-"the dialplan. This is similar to call files or the manager originate action.\n"
-"Calls originated with this command are given a timeout of 30 seconds.\n\n"
-
-"Usage1: originate <tech/data> application <appname> [appdata]\n"
-" This will originate a call between the specified channel tech/data and the\n"
-"given application. Arguments to the application are optional. If the given\n"
-"arguments to the application include spaces, all of the arguments to the\n"
-"application need to be placed in quotation marks.\n\n"
-
-"Usage2: originate <tech/data> extension [exten@][context]\n"
-" This will originate a call between the specified channel tech/data and the\n"
-"given extension. If no context is specified, the 'default' context will be\n"
-"used. If no extension is given, the 's' extension will be used.\n";
-
-static int handle_orig(int fd, int argc, char *argv[]);
-static char *complete_orig(const char *line, const char *word, int pos, int state);
-
-struct ast_cli_entry cli_cliorig[] = {
- { { "originate", NULL },
- handle_orig, "Originate a call",
- orig_help, complete_orig },
-};
-
/*!
* \brief orginate a call from the CLI
* \param fd file descriptor for cli
* \param chan channel to create type/data
* \param app application you want to run
* \param appdata data for application
- * \retval RESULT_SUCCESS on success.
- * \retval RESULT_SHOWUSAGE on failure.
+ * \retval CLI_SUCCESS on success.
+ * \retval CLI_SHOWUSAGE on failure.
*/
-static int orig_app(int fd, const char *chan, const char *app, const char *appdata)
+static char *orig_app(int fd, const char *chan, const char *app, const char *appdata)
{
char *chantech;
char *chandata;
int reason = 0;
if (ast_strlen_zero(app))
- return RESULT_SHOWUSAGE;
+ return CLI_SHOWUSAGE;
chandata = ast_strdupa(chan);
chantech = strsep(&chandata, "/");
if (!chandata) {
ast_cli(fd, "*** No data provided after channel type! ***\n");
- return RESULT_SHOWUSAGE;
+ return CLI_SHOWUSAGE;
}
ast_pbx_outgoing_app(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, app, appdata, &reason, 1, NULL, NULL, NULL, NULL, NULL);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
/*!
@@ -105,10 +79,10 @@ static int orig_app(int fd, const char *chan, const char *app, const char *appda
* \param fd file descriptor for cli
* \param chan channel to create type/data
* \param data contains exten\@context
- * \retval RESULT_SUCCESS on success.
- * \retval RESULT_SHOWUSAGE on failure.
+ * \retval CLI_SUCCESS on success.
+ * \retval CLI_SHOWUSAGE on failure.
*/
-static int orig_exten(int fd, const char *chan, const char *data)
+static char *orig_exten(int fd, const char *chan, const char *data)
{
char *chantech;
char *chandata;
@@ -121,7 +95,7 @@ static int orig_exten(int fd, const char *chan, const char *data)
chantech = strsep(&chandata, "/");
if (!chandata) {
ast_cli(fd, "*** No data provided after channel type! ***\n");
- return RESULT_SHOWUSAGE;
+ return CLI_SHOWUSAGE;
}
if (!ast_strlen_zero(data)) {
@@ -136,63 +110,74 @@ static int orig_exten(int fd, const char *chan, const char *data)
ast_pbx_outgoing_exten(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 1, NULL, NULL, NULL, NULL, NULL);
- return RESULT_SUCCESS;
+ return CLI_SUCCESS;
}
/*!
* \brief handle for orgination app or exten.
- * \param fd file descriptor
- * \param argc no of arguements
- * \param argv contains either application or extension arguements
- * \retval RESULT_SUCCESS on success.
- * \retval RESULT_SHOWUSAGE on failure.
+ * \param e pointer to the CLI structure to initialize
+ * \param cmd operation to execute
+ * \param a structure that contains either application or extension arguements
+ * \retval CLI_SUCCESS on success.
+ * \retval CLI_SHOWUSAGE on failure.
*/
-static int handle_orig(int fd, int argc, char *argv[])
+static char *handle_orig(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- int res;
+ static char *choices[] = { "application", "extension", NULL };
+ char *res;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "originate";
+ e->usage =
+ " There are two ways to use this command. A call can be originated between a\n"
+ "channel and a specific application, or between a channel and an extension in\n"
+ "the dialplan. This is similar to call files or the manager originate action.\n"
+ "Calls originated with this command are given a timeout of 30 seconds.\n\n"
+
+ "Usage1: originate <tech/data> application <appname> [appdata]\n"
+ " This will originate a call between the specified channel tech/data and the\n"
+ "given application. Arguments to the application are optional. If the given\n"
+ "arguments to the application include spaces, all of the arguments to the\n"
+ "application need to be placed in quotation marks.\n\n"
+
+ "Usage2: originate <tech/data> extension [exten@][context]\n"
+ " This will originate a call between the specified channel tech/data and the\n"
+ "given extension. If no context is specified, the 'default' context will be\n"
+ "used. If no extension is given, the 's' extension will be used.\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos != 2)
+ return NULL;
+
+ /* ugly, can be removed when CLI entries have ast_module pointers */
+ ast_module_ref(ast_module_info->self);
+ res = ast_cli_complete(a->word, choices, a->n);
+ ast_module_unref(ast_module_info->self);
- if (ast_strlen_zero(argv[1]) || ast_strlen_zero(argv[2]))
- return RESULT_SHOWUSAGE;
+ return res;
+ }
+
+ if (ast_strlen_zero(a->argv[1]) || ast_strlen_zero(a->argv[2]))
+ return CLI_SHOWUSAGE;
/* ugly, can be removed when CLI entries have ast_module pointers */
ast_module_ref(ast_module_info->self);
- if (!strcasecmp("application", argv[2])) {
- res = orig_app(fd, argv[1], argv[3], argv[4]);
- } else if (!strcasecmp("extension", argv[2])) {
- res = orig_exten(fd, argv[1], argv[3]);
+ if (!strcasecmp("application", a->argv[2])) {
+ res = orig_app(a->fd, a->argv[1], a->argv[3], a->argv[4]);
+ } else if (!strcasecmp("extension", a->argv[2])) {
+ res = orig_exten(a->fd, a->argv[1], a->argv[3]);
} else
- res = RESULT_SHOWUSAGE;
+ res = CLI_SHOWUSAGE;
ast_module_unref(ast_module_info->self);
return res;
}
-/*!
- * \brief complete suggestions for orginate command
- * \param line
- * \param word to be completed word
- * \param pos position
- * \param state
- * \retval completed word
- * \retval NULL on failure
-*/
-static char *complete_orig(const char *line, const char *word, int pos, int state)
-{
- static char *choices[] = { "application", "extension", NULL };
- char *ret;
-
- if (pos != 2)
- return NULL;
-
- /* ugly, can be removed when CLI entries have ast_module pointers */
- ast_module_ref(ast_module_info->self);
- ret = ast_cli_complete(word, choices, state);
- ast_module_unref(ast_module_info->self);
-
- return ret;
-}
+static struct ast_cli_entry cli_cliorig[] = {
+ NEW_CLI(handle_orig, "Originate a call"),
+};
/*! \brief Unload orginate module */
static int unload_module(void)