X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=blobdiff_plain;f=configfile.c;h=5ed02d6eb22c37863968fc9ca7da89878e363384;hp=5200159357e8a09276c532c2727deac9c4cf56ec;hb=663c89819b6990c99427d1cf5b0fcae21e4201bc;hpb=9f08a817761251fa1c0070e3c03558ddfda5a162 diff --git a/configfile.c b/configfile.c index 5200159..5ed02d6 100644 --- a/configfile.c +++ b/configfile.c @@ -28,6 +28,22 @@ #include "configfile.h" +#define MAXLINE 1024 + +/* regex matching blank lines or comments */ +#define REGEX_IGNORE "^[[:space:]]*(#|$)" +#define REGEX_IGNORE_FLAGS REG_EXTENDED|REG_NOSUB + +/* regex matching foo = "bar", with arbitrary whitespace at beginning and end + of line and surrounding the = */ +#define REGEX_CONFIG1 "^[[:space:]]*([^=[:space:]]+)[[:space:]]*=[[:space:]]*\"(.*)\"[[:space:]]*$" +#define REGEX_CONFIG1_FLAGS REG_EXTENDED + +/* regex matching foo = bar, with arbitrary whitespace at beginning of line and + surrounding the = */ +#define REGEX_CONFIG2 "^[[:space:]]*([^=[:space:]]+)[[:space:]]*=[[:space:]]*(.*)$" +#define REGEX_CONFIG2_FLAGS REG_EXTENDED|REG_NEWLINE + static regex_t re_ignore, re_config1, re_config2; static int re_init = 0; @@ -95,6 +111,7 @@ void parse_config_file_end(void) { regfree(&re_ignore); regfree(&re_config1); regfree(&re_config2); + re_init = 0; } /* Read the next line from a config file and store it into a swb_config_line, @@ -127,7 +144,6 @@ int parse_config_file_line(FILE *fp, struct swb_config_line *line) { else return -1; } - printf("%s", line->key); /* no need to parse blank lines and comments */ if (!regexec(&re_ignore, line->key, 0, NULL, 0)) @@ -161,7 +177,6 @@ int parse_config_file_line(FILE *fp, struct swb_config_line *line) { /* done parsing the line */ line->parsed = 1; - printf("%s: '%s'\n", line->key, line->value); finish: if (!line->parsed) {