]>
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.
16 static struct procstr procs
[] = {
17 { "context", &context
},
18 { "mh-sequences", &mh_seq
},
19 { "buildmimeproc", &buildmimeproc
},
20 { "faceproc", &faceproc
},
21 { "fileproc", &fileproc
},
22 { "incproc", &incproc
},
23 { "installproc", &installproc
},
25 { "mailproc", &mailproc
},
26 { "mhlproc", &mhlproc
},
27 { "moreproc", &moreproc
},
28 { "mshproc", &mshproc
},
29 { "packproc", &packproc
},
30 { "postproc", &postproc
},
31 { "rmfproc", &rmfproc
},
32 { "rmmproc", &rmmproc
},
33 { "sendproc", &sendproc
},
34 { "showmimeproc", &showmimeproc
},
35 { "showproc", &showproc
},
36 { "vmhproc", &vmhproc
},
37 { "whatnowproc", &whatnowproc
},
38 { "whomproc", &whomproc
},
42 static struct node
**opp
= NULL
;
46 readconfig (struct node
**npp
, FILE *ib
, char *file
, int ctx
)
50 char name
[NAMESZ
], field
[BUFSIZ
];
51 register struct node
*np
;
52 register struct procstr
*ps
;
54 if (npp
== NULL
&& (npp
= opp
) == NULL
) {
55 admonish (NULL
, "bug: readconfig called but pump not primed");
60 switch (state
= m_getfld (state
, name
, field
, sizeof(field
), ib
)) {
64 if (!(np
= (struct node
*) malloc (sizeof(*np
))))
65 adios (NULL
, "unable to allocate profile storage");
67 *(npp
= &np
->n_next
) = NULL
;
68 np
->n_name
= getcpy (name
);
69 if (state
== FLDPLUS
) {
71 while (state
== FLDPLUS
) {
72 state
= m_getfld (state
, name
, field
, sizeof(field
), ib
);
75 np
->n_field
= trimcpy (cp
);
78 np
->n_field
= trimcpy (field
);
83 * Now scan the list of `procs' and link in the
84 * field value to the global variable.
86 for (ps
= procs
; ps
->procname
; ps
++)
87 if (strcmp (np
->n_name
, ps
->procname
) == 0) {
88 *ps
->procnaddr
= np
->n_field
;
97 adios (NULL
, "no blank lines are permitted in %s", file
);
103 adios (NULL
, "%s is poorly formatted", file
);