Add the variable LEN(STRING) to retrieve the length of the STRING
authorMartin Pycko <martinp@digium.com>
Fri, 6 Jun 2003 19:47:59 +0000 (19:47 +0000)
committerMartin Pycko <martinp@digium.com>
Fri, 6 Jun 2003 19:47:59 +0000 (19:47 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1078 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx.c

diff --git a/pbx.c b/pbx.c
index e4041cc..a0c58fa 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -893,6 +893,17 @@ static void pbx_substitute_variables_temp(struct ast_channel *c,const char *var,
                                }
                        }
                }
+               if (!(*ret)) {
+                       int len=strlen(var);
+                       int len_len=strlen("LEN(");
+                       if (len > (len_len+1) && !strncasecmp(var,"LEN(",len_len) && strchr(var+len_len+2,')')) {
+                               char cp3[80];
+                               strncpy(cp3, var, sizeof(cp3) - 1);
+                               cp3[len-len_len-1]='\0';
+                               sprintf(workspace,"%d",strlen(cp3));
+                               *ret = workspace;
+                       } else ast_log(LOG_NOTICE, "Wrong use of LEN(VARIABLE)\n");
+               }
        }
 }