1 | |
---|
2 | /* |
---|
3 | * mh.h -- main header file for all of nmh |
---|
4 | * |
---|
5 | * $Id: mh.h,v 1.1.1.1 1999-02-07 18:14:06 danw Exp $ |
---|
6 | */ |
---|
7 | |
---|
8 | #include <h/nmh.h> |
---|
9 | |
---|
10 | /* |
---|
11 | * Well-used constants |
---|
12 | */ |
---|
13 | #define NOTOK (-1) /* syscall()s return this on error */ |
---|
14 | #define OK 0 /* ditto on success */ |
---|
15 | #define DONE 1 /* trinary logic */ |
---|
16 | #define ALL "" |
---|
17 | #define Nbby 8 /* number of bits/byte */ |
---|
18 | |
---|
19 | #define MAXARGS 1000 /* max arguments to exec */ |
---|
20 | #define NFOLDERS 1000 /* max folder arguments on command line */ |
---|
21 | #define DMAXFOLDER 4 /* typical number of digits */ |
---|
22 | #define MAXFOLDER 1000 /* message increment */ |
---|
23 | |
---|
24 | /* |
---|
25 | * user context/profile structure |
---|
26 | */ |
---|
27 | struct node { |
---|
28 | char *n_name; /* key */ |
---|
29 | char *n_field; /* value */ |
---|
30 | char n_context; /* context, not profile */ |
---|
31 | struct node *n_next; /* next entry */ |
---|
32 | }; |
---|
33 | |
---|
34 | /* |
---|
35 | * switches structure |
---|
36 | */ |
---|
37 | #define AMBIGSW (-2) /* from smatch() on ambiguous switch */ |
---|
38 | #define UNKWNSW (-1) /* from smatch() on unknown switch */ |
---|
39 | |
---|
40 | struct swit { |
---|
41 | char *sw; |
---|
42 | int minchars; |
---|
43 | }; |
---|
44 | |
---|
45 | extern struct swit anoyes[]; /* standard yes/no switches */ |
---|
46 | |
---|
47 | /* |
---|
48 | * general folder attributes |
---|
49 | */ |
---|
50 | #define READONLY (1<<0) /* No write access to folder */ |
---|
51 | #define SEQMOD (1<<1) /* folder's sequences modifed */ |
---|
52 | #define ALLOW_NEW (1<<2) /* allow the "new" sequence */ |
---|
53 | #define OTHERS (1<<3) /* folder has other files */ |
---|
54 | #define MODIFIED (1<<4) /* msh in-core folder modified */ |
---|
55 | |
---|
56 | #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS\05MODIFIED" |
---|
57 | |
---|
58 | /* |
---|
59 | * type for holding the sequence set of a message |
---|
60 | */ |
---|
61 | typedef unsigned int seqset_t; |
---|
62 | |
---|
63 | /* |
---|
64 | * Determine the number of user defined sequences we |
---|
65 | * can have. The first 5 sequence flags are for |
---|
66 | * internal nmh message flags. |
---|
67 | */ |
---|
68 | #define NUMATTRS ((sizeof(seqset_t) * Nbby) - 5) |
---|
69 | |
---|
70 | /* |
---|
71 | * first free slot for user defined sequences |
---|
72 | * and attributes |
---|
73 | */ |
---|
74 | #define FFATTRSLOT 5 |
---|
75 | |
---|
76 | /* |
---|
77 | * internal messages attributes (sequences) |
---|
78 | */ |
---|
79 | #define EXISTS (1<<0) /* exists */ |
---|
80 | #define DELETED (1<<1) /* deleted */ |
---|
81 | #define SELECTED (1<<2) /* selected for use */ |
---|
82 | #define SELECT_EMPTY (1<<3) /* "new" message */ |
---|
83 | #define SELECT_UNSEEN (1<<4) /* inc/show "unseen" */ |
---|
84 | |
---|
85 | #define MBITS "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN" |
---|
86 | |
---|
87 | /* |
---|
88 | * Primary structure of folder/message information |
---|
89 | */ |
---|
90 | struct msgs { |
---|
91 | int lowmsg; /* Lowest msg number */ |
---|
92 | int hghmsg; /* Highest msg number */ |
---|
93 | int nummsg; /* Actual Number of msgs */ |
---|
94 | |
---|
95 | int lowsel; /* Lowest selected msg number */ |
---|
96 | int hghsel; /* Highest selected msg number */ |
---|
97 | int numsel; /* Number of msgs selected */ |
---|
98 | |
---|
99 | int curmsg; /* Number of current msg if any */ |
---|
100 | |
---|
101 | int msgflags; /* Folder attributes (READONLY, etc) */ |
---|
102 | char *foldpath; /* Pathname of folder */ |
---|
103 | |
---|
104 | /* |
---|
105 | * Name of sequences in this folder. We add an |
---|
106 | * extra slot, so we can NULL terminate the list. |
---|
107 | */ |
---|
108 | char *msgattrs[NUMATTRS + 1]; |
---|
109 | |
---|
110 | /* |
---|
111 | * bit flags for whether sequence |
---|
112 | * is public (0), or private (1) |
---|
113 | */ |
---|
114 | seqset_t attrstats; |
---|
115 | |
---|
116 | /* |
---|
117 | * These represent the lowest and highest possible |
---|
118 | * message numbers we can put in the message status |
---|
119 | * area, without calling folder_realloc(). |
---|
120 | */ |
---|
121 | int lowoff; |
---|
122 | int hghoff; |
---|
123 | |
---|
124 | /* |
---|
125 | * This is an array of seqset_t which we allocate dynamically. |
---|
126 | * Each seqset_t is a set of bits flags for a particular message. |
---|
127 | * These bit flags represent general attributes such as |
---|
128 | * EXISTS, SELECTED, etc. as well as track if message is |
---|
129 | * in a particular sequence. |
---|
130 | */ |
---|
131 | seqset_t *msgstats; /* msg status */ |
---|
132 | }; |
---|
133 | |
---|
134 | /* |
---|
135 | * Amount of space to allocate for msgstats. Allocate |
---|
136 | * the array to have space for messages numbers lo to hi. |
---|
137 | */ |
---|
138 | #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats))) |
---|
139 | |
---|
140 | /* |
---|
141 | * macros for message and sequence manipulation |
---|
142 | */ |
---|
143 | #define clear_msg_flags(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = 0) |
---|
144 | #define copy_msg_flags(mp,i,j) \ |
---|
145 | ((mp)->msgstats[(i) - mp->lowoff] = (mp)->msgstats[(j) - mp->lowoff]) |
---|
146 | #define get_msg_flags(mp,ptr,msgnum) (*(ptr) = (mp)->msgstats[(msgnum) - mp->lowoff]) |
---|
147 | #define set_msg_flags(mp,ptr,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = *(ptr)) |
---|
148 | |
---|
149 | #define does_exist(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & EXISTS) |
---|
150 | #define unset_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~EXISTS) |
---|
151 | #define set_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= EXISTS) |
---|
152 | |
---|
153 | #define is_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECTED) |
---|
154 | #define unset_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECTED) |
---|
155 | #define set_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECTED) |
---|
156 | |
---|
157 | #define is_select_empty(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_EMPTY) |
---|
158 | #define set_select_empty(mp,msgnum) \ |
---|
159 | ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_EMPTY) |
---|
160 | |
---|
161 | #define is_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_UNSEEN) |
---|
162 | #define unset_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECT_UNSEEN) |
---|
163 | #define set_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_UNSEEN) |
---|
164 | |
---|
165 | /* for msh only */ |
---|
166 | #define set_deleted(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= DELETED) |
---|
167 | |
---|
168 | #define in_sequence(mp,seqnum,msgnum) \ |
---|
169 | ((mp)->msgstats[(msgnum) - mp->lowoff] & (1 << (FFATTRSLOT + seqnum))) |
---|
170 | #define clear_sequence(mp,seqnum,msgnum) \ |
---|
171 | ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~(1 << (FFATTRSLOT + seqnum))) |
---|
172 | #define add_sequence(mp,seqnum,msgnum) \ |
---|
173 | ((mp)->msgstats[(msgnum) - mp->lowoff] |= (1 << (FFATTRSLOT + seqnum))) |
---|
174 | |
---|
175 | #define is_seq_private(mp,seqnum) \ |
---|
176 | ((mp)->attrstats & (1 << (FFATTRSLOT + seqnum))) |
---|
177 | #define make_seq_public(mp,seqnum) \ |
---|
178 | ((mp)->attrstats &= ~(1 << (FFATTRSLOT + seqnum))) |
---|
179 | #define make_seq_private(mp,seqnum) \ |
---|
180 | ((mp)->attrstats |= (1 << (FFATTRSLOT + seqnum))) |
---|
181 | #define make_all_public(mp) \ |
---|
182 | ((mp)->attrstats = 0) |
---|
183 | |
---|
184 | /* |
---|
185 | * macros for folder attributes |
---|
186 | */ |
---|
187 | #define clear_folder_flags(mp) ((mp)->msgflags = 0) |
---|
188 | |
---|
189 | #define is_readonly(mp) ((mp)->msgflags & READONLY) |
---|
190 | #define set_readonly(mp) ((mp)->msgflags |= READONLY) |
---|
191 | |
---|
192 | #define other_files(mp) ((mp)->msgflags & OTHERS) |
---|
193 | #define set_other_files(mp) ((mp)->msgflags |= OTHERS) |
---|
194 | |
---|
195 | #define NULLMP ((struct msgs *) 0) |
---|
196 | |
---|
197 | /* |
---|
198 | * m_getfld() message parsing |
---|
199 | */ |
---|
200 | |
---|
201 | #define NAMESZ 128 /* Limit on component name size */ |
---|
202 | |
---|
203 | #define LENERR (-2) /* Name too long error from getfld */ |
---|
204 | #define FMTERR (-3) /* Message Format error */ |
---|
205 | #define FLD 0 /* Field returned */ |
---|
206 | #define FLDPLUS 1 /* Field returned with more to come */ |
---|
207 | #define FLDEOF 2 /* Field returned ending at eom */ |
---|
208 | #define BODY 3 /* Body returned with more to come */ |
---|
209 | #define BODYEOF 4 /* Body returned ending at eom */ |
---|
210 | #define FILEEOF 5 /* Reached end of input file */ |
---|
211 | |
---|
212 | /* |
---|
213 | * Maildrop styles |
---|
214 | */ |
---|
215 | #define MS_DEFAULT 0 /* default (one msg per file) */ |
---|
216 | #define MS_UNKNOWN 1 /* type not known yet */ |
---|
217 | #define MS_MBOX 2 /* Unix-style "from" lines */ |
---|
218 | #define MS_MMDF 3 /* string mmdlm2 */ |
---|
219 | #define MS_MSH 4 /* whacko msh */ |
---|
220 | |
---|
221 | extern int msg_count; /* m_getfld() indicators */ |
---|
222 | extern int msg_style; /* .. */ |
---|
223 | extern char *msg_delim; /* .. */ |
---|
224 | |
---|
225 | #define NOUSE 0 /* draft being re-used */ |
---|
226 | |
---|
227 | #define TFOLDER 0 /* path() given a +folder */ |
---|
228 | #define TFILE 1 /* path() given a file */ |
---|
229 | #define TSUBCWF 2 /* path() given a @folder */ |
---|
230 | |
---|
231 | #define OUTPUTLINELEN 72 /* default line length for headers */ |
---|
232 | |
---|
233 | /* |
---|
234 | * miscellaneous macros |
---|
235 | */ |
---|
236 | #define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp) |
---|
237 | |
---|
238 | #ifndef max |
---|
239 | # define max(a,b) ((a) > (b) ? (a) : (b)) |
---|
240 | #endif |
---|
241 | |
---|
242 | #ifndef min |
---|
243 | # define min(a,b) ((a) < (b) ? (a) : (b)) |
---|
244 | #endif |
---|
245 | |
---|
246 | #ifndef abs |
---|
247 | # define abs(a) ((a) > 0 ? (a) : -(a)) |
---|
248 | #endif |
---|
249 | |
---|
250 | /* |
---|
251 | * GLOBAL VARIABLES |
---|
252 | */ |
---|
253 | #define CTXMOD 0x01 /* context information modified */ |
---|
254 | #define DBITS "\020\01CTXMOD" |
---|
255 | extern char ctxflags; |
---|
256 | |
---|
257 | extern char *invo_name; /* command invocation name */ |
---|
258 | extern char *mypath; /* user's $HOME */ |
---|
259 | extern char *defpath; /* pathname of user's profile */ |
---|
260 | extern char *ctxpath; /* pathname of user's context */ |
---|
261 | extern struct node *m_defs; /* list of profile/context entries */ |
---|
262 | |
---|
263 | /* |
---|
264 | * These standard strings are defined in config.c. They are the |
---|
265 | * only system-dependent parameters in nmh, and thus by redefining |
---|
266 | * their values and reloading the various modules, nmh will run |
---|
267 | * on any system. |
---|
268 | */ |
---|
269 | extern char *buildmimeproc; |
---|
270 | extern char *catproc; |
---|
271 | extern char *components; |
---|
272 | extern char *context; |
---|
273 | extern char *current; |
---|
274 | extern char *defaulteditor; |
---|
275 | extern char *defaultfolder; |
---|
276 | extern char *digestcomps; |
---|
277 | extern char *distcomps; |
---|
278 | extern char *draft; |
---|
279 | extern char *faceproc; |
---|
280 | extern char *fileproc; |
---|
281 | extern char *foldprot; |
---|
282 | extern char *forwcomps; |
---|
283 | extern char *inbox; |
---|
284 | extern char *incproc; |
---|
285 | extern char *installproc; |
---|
286 | extern char *lproc; |
---|
287 | extern char *mailproc; |
---|
288 | extern char *mh_defaults; |
---|
289 | extern char *mh_profile; |
---|
290 | extern char *mh_seq; |
---|
291 | extern char *mhlformat; |
---|
292 | extern char *mhlforward; |
---|
293 | extern char *mhlproc; |
---|
294 | extern char *mhlreply; |
---|
295 | extern char *moreproc; |
---|
296 | extern char *msgprot; |
---|
297 | extern char *mshproc; |
---|
298 | extern char *nmhaccessftp; |
---|
299 | extern char *nmhstorage; |
---|
300 | extern char *nmhcache; |
---|
301 | extern char *nmhprivcache; |
---|
302 | extern char *nsequence; |
---|
303 | extern char *packproc; |
---|
304 | extern char *postproc; |
---|
305 | extern char *pfolder; |
---|
306 | extern char *psequence; |
---|
307 | extern char *rcvdistcomps; |
---|
308 | extern char *rcvstoreproc; |
---|
309 | extern char *replcomps; |
---|
310 | extern char *replgroupcomps; |
---|
311 | extern char *rmfproc; |
---|
312 | extern char *rmmproc; |
---|
313 | extern char *sendproc; |
---|
314 | extern char *showmimeproc; |
---|
315 | extern char *showproc; |
---|
316 | extern char *usequence; |
---|
317 | extern char *version_num; |
---|
318 | extern char *version_str; |
---|
319 | extern char *vmhproc; |
---|
320 | extern char *whatnowproc; |
---|
321 | extern char *whomproc; |
---|
322 | |
---|
323 | #include <h/prototypes.h> |
---|
324 | |
---|