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 { "backup-prefix", &backup_prefix },
23 { "altmsg-link", &altmsglink },
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 { "sendmail", &sendmail },
39 { "sendproc", &sendproc },
40 { "showmimeproc", &showmimeproc },
41 { "showproc", &showproc },
42 { "vmhproc", &vmhproc },
43 { "whatnowproc", &whatnowproc },
44 { "whomproc", &whomproc },
48 static struct node **opp = NULL;
52 readconfig (struct node **npp, FILE *ib, char *file, int ctx)
56 char name[NAMESZ], field[BUFSIZ];
57 register struct node *np;
58 register struct procstr *ps;
60 if (npp == NULL && (npp = opp) == NULL) {
61 admonish (NULL, "bug: readconfig called but pump not primed");
66 switch (state = m_getfld (state, name, field, sizeof(field), ib)) {
70 np = (struct node *) mh_xmalloc (sizeof(*np));
72 *(npp = &np->n_next) = NULL;
73 np->n_name = getcpy (name);
74 if (state == FLDPLUS) {
76 while (state == FLDPLUS) {
77 state = m_getfld (state, name, field, sizeof(field), ib);
80 np->n_field = trimcpy (cp);
83 np->n_field = trimcpy (field);
88 * Now scan the list of `procs' and link in the
89 * field value to the global variable.
91 for (ps = procs; ps->procname; ps++)
92 if (strcmp (np->n_name, ps->procname) == 0) {
93 *ps->procnaddr = np->n_field;
102 adios (NULL, "no blank lines are permitted in %s", file);
108 adios (NULL, "%s is poorly formatted", file);