Commit 25cada62 authored by venaas's avatar venaas Committed by venaas

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
parent 79651977
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment