]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 233093 via svnmerge from
authorMatthias Nick <mnick@digium.com>
Fri, 4 Dec 2009 20:29:30 +0000 (20:29 +0000)
committerMatthias Nick <mnick@digium.com>
Fri, 4 Dec 2009 20:29:30 +0000 (20:29 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

........
  r233093 | mnick | 2009-12-04 11:15:47 -0600 (Fri, 04 Dec 2009) | 8 lines

  Parse global variables or expressions in hint extensions

  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.6.0@233236 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx/pbx_config.c

index e55dcf51fefe95177316f6d64f76ce39c489a546..1c99021f48c9328dda55cc68427d2f05bb126ca2 100644 (file)
@@ -1426,21 +1426,36 @@ static int pbx_load_config(const char *config_file)
                                                ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno);
                                                ipri = 0;
                                        }
+
                                        appl = S_OR(stringp, "");
                                        /* Find the first occurrence of '(' */
-                                       firstp = strchr(appl, '(');
-                                       if (!firstp) {
+                                       if (!(firstp = strchr(appl, '('))) {
                                                /* No arguments */
                                                data = "";
                                        } else {
+                                               char *orig_appl = ast_strdup(appl);
+
+                                               if (!orig_appl)
+                                                       return -1;
+
                                                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);
+                                                       /* set no data */
+                                                       data = "";
+                                               /* no variable before application found -> go ahead */
                                                } else {
-                                                       ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
+                                                       data = S_OR(stringp, "");
+                                                       if ((end = strrchr(data, ')'))) {
+                                                               *end = '\0';
+                                                       } else {
+                                                               ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
+                                                       }
                                                }
+                                               ast_free(orig_appl);
                                        }
 
                                        if (!data)