]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Parse global variables or expressions in hint extensions
authorMatthias Nick <mnick@digium.com>
Fri, 4 Dec 2009 16:59:21 +0000 (16:59 +0000)
committerMatthias Nick <mnick@digium.com>
Fri, 4 Dec 2009 16:59:21 +0000 (16:59 +0000)
Parse global variables or expressions in hint extensions. Like: exten => 400,hint,DAHDI/i2/${GLOBAL(var)}

(closes issue #16166)
Reported by: rmudgett
Tested by: mnick, rmudgett

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

pbx/pbx_config.c

index fd79cc48dc6ae78a7f2543199a85fc67c6ee87ff..9c51b130c4fd7ba95402876b482dd270f0eae934 100644 (file)
@@ -2266,16 +2266,30 @@ static int pbx_load_config(const char *config_file)
                                                /* Neither found */
                                                data = "";
                                        } else {
+                                               char *orig_appl = strdup(appl);
+
+                                               if (!orig_appl)
+                                                       return -1;
+
                                                /* Final remaining case is parenthesis found first */
                                                appl = strsep(&stringp, "(");
-                                               data = stringp;
-                                               end = strrchr(data, ')');
-                                               if ((end = strrchr(data, ')'))) {
-                                                       *end = '\0';
+
+                                               /* check if there are variables or expressions without an application, like: exten => 100,hint,DAHDI/g0/${GLOBAL(var)} */
+                                               if (strstr(appl, "${") || strstr(appl, "$[")){
+                                                       /* set appl to original one */
+                                                       strcpy(appl, orig_appl);
+                                                       data = "";
                                                } else {
-                                                       ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
+                                                       data = stringp;
+                                                       end = strrchr(data, ')');
+                                                       if ((end = strrchr(data, ')'))) {
+                                                               *end = '\0';
+                                                       } else {
+                                                               ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
+                                                       }
+                                                       ast_process_quotes_and_slashes(data, ',', '|');
                                                }
-                                               ast_process_quotes_and_slashes(data, ',', '|');
+                                               ast_free(orig_appl);
                                        }
 
                                        if (!data)