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.
18 static struct procstr procs[] = {
19 { "context", &context },
20 { "mh-sequences", &mh_seq },
21 { "backup-prefix", &backup_prefix },
22 { "draft-folder", &draftfolder },
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 { "packproc", &packproc },
34 { "postproc", &postproc },
35 { "rmfproc", &rmfproc },
36 { "rmmproc", &rmmproc },
37 { "sendmail", &sendmail },
38 { "sendproc", &sendproc },
39 { "showmimeproc", &showmimeproc },
40 { "showproc", &showproc },
41 { "whatnowproc", &whatnowproc },
45 static struct node **opp = NULL;
49 readconfig(struct node **npp, FILE *ib, char *file, int ctx)
53 char name[NAMESZ], field[BUFSIZ];
54 register struct node *np;
55 register struct procstr *ps;
57 if (npp == NULL && (npp = opp) == NULL) {
58 admonish(NULL, "bug: readconfig called but pump not primed");
63 switch (state = m_getfld(state, name, field, sizeof(field), ib)) {
67 np = (struct node *) mh_xmalloc(sizeof(*np));
69 *(npp = &np->n_next) = NULL;
70 np->n_name = getcpy(name);
71 if (state == FLDPLUS) {
73 while (state == FLDPLUS) {
74 state = m_getfld(state, name, field, sizeof(field), ib);
77 np->n_field = trimcpy(cp);
80 np->n_field = trimcpy(field);
85 ** Now scan the list of `procs' and link in
86 ** the field value to the global variable.
88 for (ps = procs; ps->procname; ps++)
89 if (mh_strcasecmp(np->n_name,
91 *ps->procnaddr = np->n_field;
100 adios(NULL, "no blank lines are permitted in %s", file);
106 adios(NULL, "%s is poorly formatted", file);