summaryrefslogtreecommitdiff
path: root/radsecproxy.c
diff options
context:
space:
mode:
authorvenaas <venaas>2007-05-24 15:24:40 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2007-05-24 15:24:40 +0000
commit25cada62234909a87658970d0066014b288a43d7 (patch)
tree5daa252dae13c520c75d8304936798c115f6345e /radsecproxy.c
parent79651977517e254035141de0468cf87aa1d20e23 (diff)
added strtokenquote() to replace strtok to enable quoting of values
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@107 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'radsecproxy.c')
-rw-r--r--radsecproxy.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/radsecproxy.c b/radsecproxy.c
index 0410597..1eb84bb 100644
--- a/radsecproxy.c
+++ b/radsecproxy.c
@@ -1977,6 +1977,38 @@ struct peer *server_create(char type) {
return server;
}
+/* returns 0 on error, 1 if ok. E.g. "" will return token with empty string */
+int strtokenquote(char *s, char **token, char *del, char *quote, char *comment) {
+ char *t = s, *q;
+
+ if (!t || !token || !del)
+ return 0;
+ while (strchr(del, *t))
+ t++;
+ if (!*t || comment && strchr(comment, *t)) {
+ *token = NULL;
+ return 1;
+ }
+ if (quote && (q = strchr(quote, *t))) {
+ t++;
+ while (*t && *t != *q)
+ t++;
+ if (!*t)
+ return 0;
+ if (t[1] && !strchr(del, t[1]))
+ return 0;
+ *t = '\0';
+ *token = q + 1;
+ return 1;
+ }
+ *token = t;
+ t++;
+ while (*t && !strchr(del, *t))
+ t++;
+ *t = '\0';
+ return 1;
+}
+
/* Parses config with following syntax:
* One of these:
* option-name value