X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Freadconfig.c;h=6975d724ad50f943e09bff5f035e02b4369a13a0;hp=2fe2d7d3f6082bc610e7241f468c18b0f1f83399;hb=04a3dfc70394a517a79340a7d3ecd9c6a23d0bee;hpb=bd02210b2be64956a952f925a2dcd35fb42f6136 diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 2fe2d7d..6975d72 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -36,9 +36,8 @@ static struct node **opp = NULL; void readconfig(struct node **npp, FILE *ib, char *file, int ctx) { - int state; - char *cp; - char name[NAMESZ], field[BUFSIZ]; + enum state state; + struct field f = {{0}}; struct node *np; struct procstr *ps; @@ -47,46 +46,34 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx) return; } - for (state = FLD;;) { - switch (state = m_getfld(state, name, field, sizeof(field), - ib)) { - case FLD: - case FLDPLUS: + for (state = FLD2;;) { + switch (state = m_getfld2(state, &f, ib)) { + case FLD2: np = mh_xcalloc(1, sizeof(*np)); *npp = np; *(npp = &np->n_next) = NULL; - np->n_name = mh_xstrdup(name); - if (state == FLDPLUS) { - cp = mh_xstrdup(field); - while (state == FLDPLUS) { - state = m_getfld(state, name, field, - sizeof(field), ib); - cp = add(field, cp); - } - np->n_field = trimcpy(cp); - mh_free0(&cp); - } else { - np->n_field = trimcpy(field); - } + np->n_name = mh_xstrdup(f.name); + np->n_field = trimcpy(f.value); np->n_context = ctx; /* ** Now scan the list of `procs' and link in ** the field value to the global variable. */ - for (ps = procs; ps->procname; ps++) + for (ps = procs; ps->procname; ps++) { if (mh_strcasecmp(np->n_name, ps->procname) == 0) { *ps->procnaddr = np->n_field; break; } + } continue; - case BODY: + case BODY2: adios(EX_CONFIG, NULL, "no blank lines are permitted in %s", file); - case FILEEOF: + case FILEEOF2: break; default: