[Asterisk-cvs] asterisk utils.c,1.44,1.45
kpfleming at lists.digium.com
kpfleming at lists.digium.com
Fri May 20 12:25:21 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv20216
Modified Files:
utils.c
Log Message:
make IF dialplan function handle quoted strings properly (bug #4322, with API mods)
Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- utils.c 15 May 2005 22:33:01 -0000 1.44
+++ utils.c 20 May 2005 16:30:13 -0000 1.45
@@ -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__)
More information about the svn-commits
mailing list