]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Strip the preamble from the output also when -rx is not being used
authorTilghman Lesher <tilghman@meg.abyt.es>
Wed, 21 May 2008 18:40:14 +0000 (18:40 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Wed, 21 May 2008 18:40:14 +0000 (18:40 +0000)
(Related to issue #12702)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@117519 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/asterisk.c
pbx/pbx_spool.c

index ef6c64de67d75d6074540b309a9feec820a1a750..e11ee265812f4d688d2c04091fc244d82db3110d 100644 (file)
@@ -2347,6 +2347,14 @@ static void ast_remotecontrol(char * data)
                        if (ebuf[strlen(ebuf)-1] == '\n')
                                ebuf[strlen(ebuf)-1] = '\0';
                        if (!remoteconsolehandler(ebuf)) {
+                               /* Strip preamble from output */
+                               char *tmp;
+                               for (tmp = ebuf; *tmp; tmp++) {
+                                       if (*tmp == 127) {
+                                               memmove(tmp, tmp + 1, strlen(tmp));
+                                               tmp--;
+                                       }
+                               }
                                res = write(ast_consock, ebuf, strlen(ebuf) + 1);
                                if (res < 1) {
                                        ast_log(LOG_WARNING, "Unable to write: %s\n", strerror(errno));
index 8cf38a11652b9657b1bfb1dbed03ee9fc5375073..9316971421d8df4d9e87d31bd94974cd1566c0dc 100644 (file)
@@ -128,7 +128,11 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
        char buf[256];
        char *c, *c2;
        int lineno = 0;
-       struct ast_variable *var;
+       struct ast_variable *var, *last = o->vars;
+
+       while (last && last->next) {
+               last = last->next;
+       }
 
        while(fgets(buf, sizeof(buf), f)) {
                lineno++;
@@ -222,8 +226,13 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
                                        if (c2) {
                                                var = ast_variable_new(c, c2);
                                                if (var) {
-                                                       var->next = o->vars;
-                                                       o->vars = var;
+                                                       /* Always insert at the end, because some people want to treat the spool file as a script */
+                                                       if (last) {
+                                                               last->next = var;
+                                                       } else {
+                                                               o->vars = var;
+                                                       }
+                                                       last = var;
                                                }
                                        } else
                                                ast_log(LOG_WARNING, "Malformed \"%s\" argument.  Should be \"%s: variable=value\"\n", buf, buf);