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)) {
52 np = (struct node *) mh_xmalloc(sizeof(*np));
54 *(npp = &np->n_next) = NULL;
55 np->n_name = getcpy(f.name);
56 np->n_field = trimcpy(f.value);
60 ** Now scan the list of `procs' and link in
61 ** the field value to the global variable.
63 for (ps = procs; ps->procname; ps++) {
64 if (mh_strcasecmp(np->n_name,
66 *ps->procnaddr = np->n_field;
73 adios(EX_CONFIG, NULL, "no blank lines are permitted in %s",
80 adios(EX_CONFIG, NULL, "%s is poorly formatted", file);