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 { "attachment-header", &attach_hdr },
20 { "context", &context },
21 { "mh-sequences", &mh_seq },
22 { "backup-prefix", &backup_prefix },
23 { "draft-folder", &draftfolder },
24 { "altmsg-link", &altmsglink },
25 { "fileproc", &fileproc },
26 { "listproc", &listproc },
27 { "rmmproc", &rmmproc },
28 { "sendmail", &sendmail },
29 { "sendproc", &sendproc },
30 { "whatnowproc", &whatnowproc },
34 static struct node **opp = NULL;
38 readconfig(struct node **npp, FILE *ib, char *file, int ctx)
42 char name[NAMESZ], field[BUFSIZ];
43 register struct node *np;
44 register struct procstr *ps;
46 if (npp == NULL && (npp = opp) == NULL) {
47 admonish(NULL, "bug: readconfig called but pump not primed");
52 switch (state = m_getfld(state, name, field, sizeof(field),
57 np = (struct node *) mh_xmalloc(sizeof(*np));
59 *(npp = &np->n_next) = NULL;
60 np->n_name = getcpy(name);
61 if (state == FLDPLUS) {
63 while (state == FLDPLUS) {
64 state = m_getfld(state, name, field,
68 np->n_field = trimcpy(cp);
71 np->n_field = trimcpy(field);
76 ** Now scan the list of `procs' and link in
77 ** the field value to the global variable.
79 for (ps = procs; ps->procname; ps++)
80 if (mh_strcasecmp(np->n_name,
82 *ps->procnaddr = np->n_field;
91 adios(NULL, "no blank lines are permitted in %s",
98 adios(NULL, "%s is poorly formatted", file);