]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/sbr/RCS/m_readefs.c,v
sbr/mts.c: Delete mmdlm2; use same-valued mmdlm1 instead.
[nmh] / docs / historical / mh-6.8.5 / sbr / RCS / m_readefs.c,v
1 head 1.2;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.2
9 date 94.04.29.04.58.00; author jromine; state Exp;
10 branches;
11 next 1.1;
12
13 1.1
14 date 94.04.29.04.45.25; author jromine; state Exp;
15 branches;
16 next ;
17
18
19 desc
20 @@
21
22
23 1.2
24 log
25 @add id
26 @
27 text
28 @/* m_readefs.c - read a profile/context file */
29 #ifndef lint
30 static char ident[] = "@@(#)$Id:$";
31 #endif
32
33 #include "../h/mh.h"
34 #include <stdio.h>
35
36
37 static struct procs {
38 char *procname;
39 char **procnaddr;
40 } procs [] = {
41 { "context", &context },
42 { "mh-sequences",
43 &mh_seq },
44 { "faceproc", &faceproc },
45 { "fileproc", &fileproc },
46 { "incproc", &incproc },
47 { "installproc",&installproc },
48 { "lproc", &lproc },
49 { "mailproc", &mailproc },
50 { "mhlproc", &mhlproc },
51 { "moreproc", &moreproc },
52 { "mshproc", &mshproc },
53 { "packproc", &packproc },
54 { "postproc", &postproc },
55 { "rmfproc", &rmfproc },
56 { "rmmproc", &rmmproc },
57 { "sendproc", &sendproc },
58 { "showproc", &showproc },
59 { "slocalproc", &slocalproc },
60 { "vmhproc", &vmhproc },
61 { "whatnowproc",
62 &whatnowproc },
63 { "whomproc", &whomproc },
64 { NULL, NULL }
65 };
66
67 static struct node **opp = NULL;
68
69
70 void m_readefs (npp, ib, file, ctx)
71 register struct node **npp;
72 register FILE *ib;
73 register char *file;
74 register int ctx;
75 {
76 register int state;
77 register char *cp;
78 char name[NAMESZ],
79 field[BUFSIZ];
80 register struct node *np;
81 register struct procs *ps;
82
83 if (npp == NULL && (npp = opp) == NULL) {
84 admonish (NULLCP, "bug: m_readefs called but pump not primed");
85 return;
86 }
87
88 for (state = FLD;;) {
89 switch (state = m_getfld (state, name, field, sizeof field, ib)) {
90 case FLD:
91 case FLDPLUS:
92 case FLDEOF:
93 np = (struct node *) malloc (sizeof *np);
94 if (np == NULL)
95 adios (NULLCP, "unable to allocate profile storage");
96 *npp = np;
97 *(npp = &np -> n_next) = NULL;
98 np -> n_name = getcpy (name);
99 if (state == FLDPLUS) {
100 cp = getcpy (field);
101 while (state == FLDPLUS) {
102 state = m_getfld
103 (state, name, field, sizeof field, ib);
104 cp = add (field, cp);
105 }
106 np -> n_field = trimcpy (cp);
107 free (cp);
108 }
109 else
110 np -> n_field = trimcpy (field);
111 np -> n_context = ctx;
112 for (ps = procs; ps -> procname; ps++)
113 if (strcmp (np -> n_name, ps -> procname) == 0) {
114 *ps -> procnaddr = np -> n_field;
115 break;
116 }
117 if (state == FLDEOF)
118 break;
119 continue;
120
121 case BODY:
122 case BODYEOF:
123 adios (NULLCP, "no blank lines are permitted in %s", file);
124
125 case FILEEOF:
126 break;
127
128 default:
129 adios (NULLCP, "%s is poorly formatted", file);
130 }
131 break;
132 }
133
134 opp = npp;
135 }
136 @
137
138
139 1.1
140 log
141 @Initial revision
142 @
143 text
144 @d2 3
145 @