Call spost directly, not via postproc. Remove the postproc profile entry.
[mmh] / sbr / readconfig.c
1 /*
2 ** readconfig.c -- base routine to read nmh configuration files
3 **              -- such as nmh profile, context file, or mhn.defaults.
4 **
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.
8 */
9
10 #include <h/mh.h>
11 #include <h/utils.h>
12
13 struct procstr {
14         char *procname;
15         char **procnaddr;
16 };
17
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 },
31         { NULL, NULL }
32 };
33
34 static struct node **opp = NULL;
35
36
37 void
38 readconfig(struct node **npp, FILE *ib, char *file, int ctx)
39 {
40         register int state;
41         register char *cp;
42         char name[NAMESZ], field[BUFSIZ];
43         register struct node *np;
44         register struct procstr *ps;
45
46         if (npp == NULL && (npp = opp) == NULL) {
47                 admonish(NULL, "bug: readconfig called but pump not primed");
48                 return;
49         }
50
51         for (state = FLD;;) {
52                 switch (state = m_getfld(state, name, field, sizeof(field),
53                                 ib)) {
54                 case FLD:
55                 case FLDPLUS:
56                 case FLDEOF:
57                         np = (struct node *) mh_xmalloc(sizeof(*np));
58                         *npp = np;
59                         *(npp = &np->n_next) = NULL;
60                         np->n_name = getcpy(name);
61                         if (state == FLDPLUS) {
62                                 cp = getcpy(field);
63                                 while (state == FLDPLUS) {
64                                         state = m_getfld(state, name, field,
65                                                         sizeof(field), ib);
66                                         cp = add(field, cp);
67                                 }
68                                 np->n_field = trimcpy(cp);
69                                 free(cp);
70                         } else {
71                                 np->n_field = trimcpy(field);
72                         }
73                         np->n_context = ctx;
74
75                         /*
76                         ** Now scan the list of `procs' and link in
77                         ** the field value to the global variable.
78                         */
79                         for (ps = procs; ps->procname; ps++)
80                                 if (mh_strcasecmp(np->n_name,
81                                                 ps->procname) == 0) {
82                                         *ps->procnaddr = np->n_field;
83                                         break;
84                                 }
85                         if (state == FLDEOF)
86                                 break;
87                         continue;
88
89                 case BODY:
90                 case BODYEOF:
91                         adios(NULL, "no blank lines are permitted in %s",
92                                         file);
93
94                 case FILEEOF:
95                         break;
96
97                 default:
98                         adios(NULL, "%s is poorly formatted", file);
99                 }
100                 break;
101         }
102
103         opp = npp;
104 }