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