improved config parsing of comments
authorvenaas <venaas>
Wed, 30 May 2007 14:50:35 +0000 (14:50 +0000)
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>
Wed, 30 May 2007 14:50:35 +0000 (14:50 +0000)
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@115 e88ac4ed-0b26-0410-9574-a7f39faa03bf

radsecproxy.c

index 673fe9b..37b9228 100644 (file)
@@ -1866,14 +1866,14 @@ struct peer *server_create(char type) {
 }
 
 /* returns NULL on error, where to continue parsing if token and ok. E.g. "" will return token with empty string */
-char *strtokenquote(char *s, char **token, char *del, char *quote) {
+char *strtokenquote(char *s, char **token, char *del, char *quote, char *comment) {
     char *t = s, *q, *r;
 
     if (!t || !token || !del)
        return NULL;
     while (*t && strchr(del, *t))
        t++;
-    if (!*t) {
+    if (!*t || (comment && strchr(comment, *t))) {
        *token = NULL;
        return t + 1; /* needs to be non-NULL, but value doesn't matter */
     }
@@ -1917,7 +1917,7 @@ void getgeneralconfig(FILE *f, char *block, ...) {
     while (fgets(line, 1024, f)) {
        s = line;
        for (tcount = 0; tcount < 3; tcount++) {
-           s = strtokenquote(s, &tokens[tcount], " \t\n", "\"'");
+           s = strtokenquote(s, &tokens[tcount], " \t\n", "\"'", tcount ? NULL : "#");
            if (!s)
                debugx(1, DBG_ERR, "Syntax error in line starting with: %s", line);
            if (!tokens[tcount])