]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Modifications to allow the output of SHELL() to be split per line (Issue 8676)
authorTilghman Lesher <tilghman@meg.abyt.es>
Sun, 7 Jan 2007 14:44:49 +0000 (14:44 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Sun, 7 Jan 2007 14:44:49 +0000 (14:44 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49786 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_cut.c
funcs/func_shell.c
funcs/func_strings.c

index 2f488a31dabcba76a4e65a40e90a4d409f506624..9cab185b2dadae811dcd0519c2174eaf9333790f 100644 (file)
@@ -131,7 +131,7 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
        AST_STANDARD_APP_ARGS(args, parse);
 
        /* Check and parse arguments */
-       if(args.argc < 3){
+       if (args.argc < 3) {
                return ERROR_NOARG;
        } else {
                char d, ds[2];
@@ -145,7 +145,19 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
                        return ERROR_NOMEM;
                }
 
-               d = args.delimiter[0] ? args.delimiter[0] : '-';
+               if (args.delimiter[0] == '\\') {
+                       if (args.delimiter[1] == 'n')
+                               d = '\n';
+                       else if (args.delimiter[1] == 't')
+                               d = '\t';
+                       else if (args.delimiter[1])
+                               d = args.delimiter[1];
+                       else
+                               d = '-';
+               } else if (args.delimiter[0])
+                       d = args.delimiter[0];
+               else
+                       d = '-';
 
                /* String form of the delimiter, for use with strsep(3) */
                snprintf(ds, sizeof(ds), "%c", d);
index fc155e9b3e3522bdf7563f3aa3130a5f5e41cbe2..b2557fba96ccfc634d6b178d45a681b05b773860 100644 (file)
@@ -39,7 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
 
-static int shell_helper(struct ast_channel *chan, char *cmd, char *data,
+static int shell_helper(struct ast_channel *chan, const char *cmd, char *data,
                                         char *buf, size_t len)
 {
        if (ast_strlen_zero(data)) {
index 9f843b669be2bacadb97036061ea240cfe56dfd4..de87c197af53d6f6ade7a297fc64783f3c2ebdcd 100644 (file)
@@ -56,6 +56,16 @@ static int function_fieldqty(struct ast_channel *chan, const char *cmd,
        AST_STANDARD_APP_ARGS(args, parse);
        if (args.delim) {
                pbx_retrieve_variable(chan, args.varname, &varval, buf, len, NULL);
+               if (args.delim[0] == '\\') {
+                       if (args.delim[1] == 'n')
+                               ast_copy_string(args.delim, "\n", 2);
+                       else if (args.delim[1] == 't')
+                               ast_copy_string(args.delim, "\t", 2);
+                       else if (args.delim[1])
+                               ast_copy_string(args.delim, &args.delim[1], 2);
+                       else
+                               ast_copy_string(args.delim, "-", 2);
+               }
                while (strsep(&varval, args.delim))
                        fieldcount++;
        } else {