3 * readconfig.c -- base routine to read nmh configuration files
4 * -- such as nmh profile, context file, or mhn.defaults.
6 * This code is Copyright (c) 2002, by the authors of nmh. See the
7 * COPYRIGHT file in the root directory of the nmh distribution for
8 * complete copyright information.
19 static struct procstr procs[] = {
20 { "context", &context },
21 { "mh-sequences", &mh_seq },
22 { "buildmimeproc", &buildmimeproc },
23 { "fileproc", &fileproc },
24 { "formatproc", &formatproc },
25 { "incproc", &incproc },
26 { "installproc", &installproc },
28 { "mailproc", &mailproc },
29 { "mhlproc", &mhlproc },
30 { "moreproc", &moreproc },
31 { "mshproc", &mshproc },
32 { "packproc", &packproc },
33 { "postproc", &postproc },
34 { "rmmproc", &rmmproc },
35 { "sendproc", &sendproc },
36 { "showmimeproc", &showmimeproc },
37 { "showproc", &showproc },
38 { "vmhproc", &vmhproc },
39 { "whatnowproc", &whatnowproc },
40 { "whomproc", &whomproc },
44 static struct node **opp = NULL;
48 readconfig (struct node **npp, FILE *ib, char *file, int ctx)
52 char name[NAMESZ], field[BUFSIZ];
53 register struct node *np;
54 register struct procstr *ps;
56 if (npp == NULL && (npp = opp) == NULL) {
57 admonish (NULL, "bug: readconfig called but pump not primed");
62 switch (state = m_getfld (state, name, field, sizeof(field), ib)) {
66 np = (struct node *) mh_xmalloc (sizeof(*np));
68 *(npp = &np->n_next) = NULL;
69 np->n_name = getcpy (name);
70 if (state == FLDPLUS) {
72 while (state == FLDPLUS) {
73 state = m_getfld (state, name, field, sizeof(field), ib);
76 np->n_field = trimcpy (cp);
79 np->n_field = trimcpy (field);
84 * Now scan the list of `procs' and link in the
85 * field value to the global variable.
87 for (ps = procs; ps->procname; ps++)
88 if (strcmp (np->n_name, ps->procname) == 0) {
89 *ps->procnaddr = np->n_field;
98 adios (NULL, "no blank lines are permitted in %s", file);
104 adios (NULL, "%s is poorly formatted", file);