2 ** readconfig.c -- base routine to read nmh configuration files
3 ** -- such as nmh profile, context file, or mhn.defaults.
5 ** This code is Copyright (c) 2002, by the authors of nmh. See the
6 ** COPYRIGHT file in the root directory of the nmh distribution for
7 ** complete copyright information.
19 static struct procstr procs[] = {
20 { "attachment-header", &attach_hdr },
21 { "sign-header", &sign_hdr },
22 { "enc-header", &enc_hdr },
23 { "context", &context },
24 { "mh-sequences", &mh_seq },
25 { "draft-folder", &draftfolder },
26 { "listproc", &listproc },
27 { "sendmail", &sendmail },
28 { "trash-folder", &trashfolder },
29 { "whatnowproc", &whatnowproc },
33 static struct node **opp = NULL;
37 readconfig(struct node **npp, FILE *ib, char *file, int ctx)
41 char name[NAMESZ], field[BUFSIZ];
45 if (npp == NULL && (npp = opp) == NULL) {
46 admonish(NULL, "bug: readconfig called but pump not primed");
51 switch (state = m_getfld(state, name, field, sizeof(field),
56 np = (struct node *) mh_xmalloc(sizeof(*np));
58 *(npp = &np->n_next) = NULL;
59 np->n_name = getcpy(name);
60 if (state == FLDPLUS) {
62 while (state == FLDPLUS) {
63 state = m_getfld(state, name, field,
67 np->n_field = trimcpy(cp);
70 np->n_field = trimcpy(field);
75 ** Now scan the list of `procs' and link in
76 ** the field value to the global variable.
78 for (ps = procs; ps->procname; ps++)
79 if (mh_strcasecmp(np->n_name,
81 *ps->procnaddr = np->n_field;
90 adios(EX_CONFIG, NULL, "no blank lines are permitted in %s",
97 adios(EX_CONFIG, NULL, "%s is poorly formatted", file);