summaryrefslogtreecommitdiff
path: root/apps/app_chanspy.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2007-07-23 19:51:41 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2007-07-23 19:51:41 +0000
commit55b1ee298e926c594f45456e5afbc25c79e3889b (patch)
treec9c73917bfd120da30c16650000c7296781fae50 /apps/app_chanspy.c
parentd8d1b6c8f242dbc1be319ceef5442378a5bda885 (diff)
Merge the dialplan_aesthetics branch. Most of this patch simply converts applications
using old methods of parsing arguments to using the standard macros. However, the big change is that the really old way of specifying application and arguments separated by a comma will no longer work (e.g. NoOp,foo|bar). Instead, the way that has been recommended since long before 1.0 will become the only method available (e.g. NoOp(foo,bar). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@76703 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r--apps/app_chanspy.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 80f3c530c..788174515 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -626,33 +626,27 @@ exit:
static int chanspy_exec(struct ast_channel *chan, void *data)
{
- char *options = NULL;
- char *spec = NULL;
- char *argv[2];
char *mygroup = NULL;
char *recbase = NULL;
int fd = 0;
struct ast_flags flags;
int oldwf = 0;
- int argc = 0;
int volfactor = 0;
int res;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(spec);
+ AST_APP_ARG(options);
+ );
+ char *opts[OPT_ARG_ARRAY_SIZE];
data = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, data);
- if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
- spec = argv[0];
- if (argc > 1)
- options = argv[1];
+ if (args.spec && !strcmp(args.spec, "all"))
+ args.spec = NULL;
- if (ast_strlen_zero(spec) || !strcmp(spec, "all"))
- spec = NULL;
- }
-
- if (options) {
- char *opts[OPT_ARG_ARRAY_SIZE];
-
- ast_app_parse_options(spy_opts, &flags, opts, options);
+ if (args.options) {
+ ast_app_parse_options(spy_opts, &flags, opts, args.options);
if (ast_test_flag(&flags, OPTION_GROUP))
mygroup = opts[OPT_ARG_GROUP];
@@ -690,7 +684,7 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
}
}
- res = common_exec(chan, &flags, volfactor, fd, mygroup, spec, NULL, NULL);
+ res = common_exec(chan, &flags, volfactor, fd, mygroup, args.spec, NULL, NULL);
if (fd)
close(fd);
@@ -703,35 +697,35 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
static int extenspy_exec(struct ast_channel *chan, void *data)
{
- char *options = NULL;
- char *exten = NULL;
- char *context = NULL;
- char *argv[2];
+ char *ptr, *exten = NULL;
char *mygroup = NULL;
char *recbase = NULL;
int fd = 0;
struct ast_flags flags;
int oldwf = 0;
- int argc = 0;
int volfactor = 0;
int res;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(context);
+ AST_APP_ARG(options);
+ );
data = ast_strdupa(data);
- if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
- context = argv[0];
- if (!ast_strlen_zero(argv[0]))
- exten = strsep(&context, "@");
- if (ast_strlen_zero(context))
- context = ast_strdupa(chan->context);
- if (argc > 1)
- options = argv[1];
+ AST_STANDARD_APP_ARGS(args, data);
+ if (!ast_strlen_zero(args.context) && (ptr = strchr(args.context, '@'))) {
+ exten = args.context;
+ *ptr++ = '\0';
+ args.context = ptr;
}
- if (options) {
+ if (ast_strlen_zero(args.context))
+ args.context = ast_strdupa(chan->context);
+
+ if (args.options) {
char *opts[OPT_ARG_ARRAY_SIZE];
- ast_app_parse_options(spy_opts, &flags, opts, options);
+ ast_app_parse_options(spy_opts, &flags, opts, args.options);
if (ast_test_flag(&flags, OPTION_GROUP))
mygroup = opts[OPT_ARG_GROUP];
@@ -769,7 +763,7 @@ static int extenspy_exec(struct ast_channel *chan, void *data)
}
}
- res = common_exec(chan, &flags, volfactor, fd, mygroup, NULL, exten, context);
+ res = common_exec(chan, &flags, volfactor, fd, mygroup, NULL, exten, args.context);
if (fd)
close(fd);