#define WHITESPACE " \t\n"
#define COMMENTS "#;\n"
+/* Run the user supplied parser for an assignment */
static int next_assignment(const char *filename, unsigned line, const struct pa_config_item *t, const char *lvalue, const char *rvalue, void *userdata) {
assert(filename && t && lvalue && rvalue);
return -1;
}
+/* Returns non-zero when c is contained in s */
static int in_string(char c, const char *s) {
assert(s);
return 0;
}
+/* Remove all whitepsapce from the beginning and the end of *s. *s may
+ * be modified. */
static char *strip(char *s) {
char *b = s+strspn(s, WHITESPACE);
char *e, *l = NULL;
return b;
}
+/* Parse a variable assignment line */
static int parse_line(const char *filename, unsigned line, const struct pa_config_item *t, char *l, void *userdata) {
char *e, *c, *b = l+strspn(l, WHITESPACE);
return next_assignment(filename, line, t, strip(b), strip(e), userdata);
}
-
+/* Go through the file and parse each line */
int pa_config_parse(const char *filename, FILE *f, const struct pa_config_item *t, void *userdata) {
int r = -1;
unsigned line = 0;