slightly clear argument processing
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 14 Sep 2005 17:19:55 +0000 (17:19 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 14 Sep 2005 17:19:55 +0000 (17:19 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6592 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx.c

diff --git a/pbx.c b/pbx.c
index 6bae090..d6d1c47 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -5574,7 +5574,7 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data)
 {
        int res = 0;
        int argc;
-       char *args;
+       char *parse;
        char *argv[4];
        char *options = NULL; 
        char *filename = NULL;
@@ -5583,19 +5583,22 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data)
        char *context = NULL;
        struct ast_flags flags = {0};
 
-       args = ast_strdupa(data);
-
-       if ((argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
-               if (argc > 0) {
+       parse = ast_strdupa(data);
+
+       if ((argc = ast_separate_app_args(parse, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
+               switch (argc) {
+               case 4:
+                       context = argv[3];
+               case 3:
+                       lang = argv[2];
+               case 2:
+                       options = argv[1];
+               case 1:
                        filename = argv[0];
-                       if (argc > 1)
-                               options = argv[1];
-                       if (argc > 2)
-                               lang = argv[2];
-                       if (argc > 3)
-                               context = argv[3];
-               } else {
+                       break;
+               default:
                        ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
+                       break;
                }
        }