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)
40 struct field f = {{0}};
44 if (npp == NULL && (npp = opp) == NULL) {
45 admonish(NULL, "bug: readconfig called but pump not primed");
49 for (state = FLD2;;) {
50 switch (state = m_getfld2(state, &f, ib)) {
55 np = mh_xcalloc(1, sizeof(*np));
57 *(npp = &np->n_next) = NULL;
58 np->n_name = mh_xstrdup(f.name);
59 np->n_field = trimcpy(f.value);
63 ** Now scan the list of `procs' and link in
64 ** the field value to the global variable.
66 for (ps = procs; ps->procname; ps++) {
67 if (mh_strcasecmp(np->n_name,
69 *ps->procnaddr = np->n_field;
75 advise(NULL, "%s is poorly formatted", file);
79 adios(EX_CONFIG, NULL, "no blank lines are permitted in %s",
86 adios(EX_IOERR, NULL, "m_getfld2", "some error happened");
90 adios(EX_CONFIG, NULL, "%s is poorly formatted", file);