]>
diplodocus.org Git - nmh/blob - sbr/readconfig.c
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 { "buildmimeproc", &buildmimeproc
},
23 { "faceproc", &faceproc
},
24 { "fileproc", &fileproc
},
25 { "formatproc", &formatproc
},
26 { "incproc", &incproc
},
27 { "installproc", &installproc
},
29 { "mailproc", &mailproc
},
30 { "mhlproc", &mhlproc
},
31 { "moreproc", &moreproc
},
32 { "mshproc", &mshproc
},
33 { "packproc", &packproc
},
34 { "postproc", &postproc
},
35 { "rmmproc", &rmmproc
},
36 { "sendproc", &sendproc
},
37 { "showmimeproc", &showmimeproc
},
38 { "showproc", &showproc
},
39 { "vmhproc", &vmhproc
},
40 { "whatnowproc", &whatnowproc
},
41 { "whomproc", &whomproc
},
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 the
86 * field value to the global variable.
88 for (ps
= procs
; ps
->procname
; ps
++)
89 if (strcmp (np
->n_name
, ps
->procname
) == 0) {
90 *ps
->procnaddr
= np
->n_field
;
99 adios (NULL
, "no blank lines are permitted in %s", file
);
105 adios (NULL
, "%s is poorly formatted", file
);