Remove not used code (JLR define)
[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 <sysexits.h>
11 #include <h/mh.h>
12 #include <h/utils.h>
13
14 struct procstr {
15         char *procname;
16         char **procnaddr;
17 };
18
19 static struct procstr procs[] = {
20         { "attachment-header",  &attach_hdr },
21         { "sign-header",   &sign_hdr },
22         { "enc-header",    &enc_hdr },
23         { "context",       &context },
24         { "mh-sequences",  &mh_seq },
25         { "draft-folder",  &draftfolder },
26         { "listproc",      &listproc },
27         { "sendmail",      &sendmail },
28         { "trash-folder",  &trashfolder },
29         { "whatnowproc",   &whatnowproc },
30         { NULL, NULL }
31 };
32
33 static struct node **opp = NULL;
34
35
36 void
37 readconfig(struct node **npp, FILE *ib, char *file, int ctx)
38 {
39         enum state state;
40         struct field f = {{0}};
41         struct node *np;
42         struct procstr *ps;
43
44         if (npp == NULL && (npp = opp) == NULL) {
45                 admonish(NULL, "bug: readconfig called but pump not primed");
46                 return;
47         }
48
49         for (state = FLD2;;) {
50                 switch (state = m_getfld2(state, &f, ib)) {
51                 case LENERR2:
52                         state = FLD2;
53                         /* FALL */
54                 case FLD2:
55                         np = mh_xcalloc(1, sizeof(*np));
56                         *npp = np;
57                         *(npp = &np->n_next) = NULL;
58                         np->n_name = mh_xstrdup(f.name);
59                         np->n_field = trimcpy(f.value);
60                         np->n_context = ctx;
61
62                         /*
63                         ** Now scan the list of `procs' and link in
64                         ** the field value to the global variable.
65                         */
66                         for (ps = procs; ps->procname; ps++) {
67                                 if (mh_strcasecmp(np->n_name,
68                                                 ps->procname) == 0) {
69                                         *ps->procnaddr = np->n_field;
70                                         break;
71                                 }
72                         }
73                         continue;
74                 case FMTERR2:
75                         advise(NULL, "%s is poorly formatted", file);
76                         state = FLD2;
77                         continue;
78                 case BODY2:
79                         adios(EX_CONFIG, NULL, "no blank lines are permitted in %s",
80                                         file);
81
82                 case FILEEOF2:
83                         break;
84
85                 case IOERR2:
86                         adios(EX_IOERR, NULL, "m_getfld2", "some error happened");
87                         break;
88
89                 default:
90                         adios(EX_CONFIG, NULL, "%s is poorly formatted", file);
91                 }
92                 break;
93         }
94
95         opp = npp;
96 }