summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2005-05-20 16:30:13 +0000
committerKevin P. Fleming <kpfleming@digium.com>2005-05-20 16:30:13 +0000
commit102c76a9c8365fe9cb1c61bdec65447585a77012 (patch)
tree64dd4eded77bcd188fbbfead9571d7128314ec5e /utils.c
parentdd0c01fc2fec1b8728a9d1977acb77aa4bac9869 (diff)
make IF dialplan function handle quoted strings properly (bug #4322, with API mods)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5750 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'utils.c')
-rwxr-xr-xutils.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/utils.c b/utils.c
index 594ef6e7b..ee6074348 100755
--- a/utils.c
+++ b/utils.c
@@ -33,17 +33,33 @@
static char base64[64];
static char b2a[256];
-char *ast_strip(char *buf)
+char *ast_strip(char *s)
{
- char *start;
- /* Strip off trailing whitespace, returns, etc */
- while (!ast_strlen_zero(buf) && (buf[strlen(buf)-1]<33))
- buf[strlen(buf)-1] = '\0';
- start = buf;
- /* Strip off leading whitespace, returns, etc */
- while (*start && (*start < 33))
- *start++ = '\0';
- return start;
+ char *e;
+
+ while (*s && (*s < 33)) s++;
+ e = s + strlen(s) - 1;
+ while ((e > s) && (*e < 33)) e--;
+ *++e = '\0';
+
+ return s;
+}
+
+char *ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
+{
+ char *e;
+ char *q;
+
+ s = ast_strip(s);
+ if ((q = strchr(beg_quotes, *s))) {
+ e = s + strlen(s) - 1;
+ if (*e == *(end_quotes + (q - beg_quotes))) {
+ s++;
+ *e = '\0';
+ }
+ }
+
+ return s;
}
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)