2 ** mh.h -- main header file for all of nmh
10 #define NOTOK (-1) /* syscall()s return this on error */
11 #define OK 0 /* ditto on success */
12 #define DONE 1 /* trinary logic */
14 #define Nbby 8 /* number of bits/byte */
16 #define MAXARGS 1000 /* max arguments to exec */
17 #define NFOLDERS 1000 /* max folder arguments on command line */
18 #define DMAXFOLDER 4 /* typical number of digits */
19 #define MAXFOLDER 1000 /* message increment */
27 typedef unsigned char boolean; /* not int so we can pack in a structure */
29 /* If we're using gcc then give it some information about
30 ** functions that abort.
33 # define NORETURN __attribute__((__noreturn__))
39 ** user context/profile structure
42 char *n_name; /* key */
43 char *n_field; /* value */
44 char n_context; /* context, not profile */
45 struct node *n_next; /* next entry */
51 #define AMBIGSW (-2) /* from smatch() on ambiguous switch */
52 #define UNKWNSW (-1) /* from smatch() on unknown switch */
57 ** The minchars field is apparently used like this:
59 ** -# : Switch can be abbreviated to # chars; switch hidden in -help.
60 ** 0 : Switch can't be abbreviated; switch shown in -help.
61 ** # : Switch can be abbreviated to # chars; switch shown in -help.
66 extern struct swit anoyes[]; /* standard yes/no switches */
69 ** general folder attributes
71 #define READONLY (1<<0) /* No write access to folder */
72 #define SEQMOD (1<<1) /* folder's sequences modifed */
73 #define ALLOW_BEYOND (1<<2) /* allow the beyond sequence */
74 #define OTHERS (1<<3) /* folder has other files */
76 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_BEYOND\04OTHERS"
79 ** type for holding the sequence set of a message
81 typedef unsigned int seqset_t;
84 ** internal messages attributes (sequences)
86 #define EXISTS (1<<0) /* exists */
87 #define SELECTED (1<<1) /* selected for use */
88 #define SELECT_UNSEEN (1<<2) /* inc/show "unseen" */
90 #define MBITS "\020\01EXISTS\02SELECTED\03UNSEEN"
93 ** first free slot for user-defined sequences
98 ** Determine the number of user defined sequences we
99 ** can have. The first few sequence flags are for
100 ** internal nmh message flags.
102 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - FFATTRSLOT)
105 ** Primary structure of folder/message information
108 int lowmsg; /* Lowest msg number */
109 int hghmsg; /* Highest msg number */
110 int nummsg; /* Actual Number of msgs */
112 int lowsel; /* Lowest selected msg number */
113 int hghsel; /* Highest selected msg number */
114 int numsel; /* Number of msgs selected */
116 int curmsg; /* Number of current msg if any */
118 int msgflags; /* Folder attributes (READONLY, etc) */
119 char *foldpath; /* Pathname of folder */
122 ** Name of sequences in this folder. We add an
123 ** extra slot, so we can NULL terminate the list.
125 char *msgattrs[NUMATTRS + 1];
128 ** bit flags for whether sequence
129 ** is public (0), or private (1)
134 ** These represent the lowest and highest possible
135 ** message numbers we can put in the message status
136 ** area, without calling folder_realloc().
142 ** This is an array of seqset_t which we allocate dynamically.
143 ** Each seqset_t is a set of bits flags for a particular message.
144 ** These bit flags represent general attributes such as
145 ** EXISTS, SELECTED, etc. as well as track if message is
146 ** in a particular sequence.
148 seqset_t *msgstats; /* msg status */
152 ** Amount of space to allocate for msgstats. Allocate
153 ** the array to have space for messages numbers lo to hi.
155 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
158 ** macros for message and sequence manipulation
160 #define clear_msg_flags(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = 0)
161 #define copy_msg_flags(mp,i,j) \
162 ((mp)->msgstats[(i) - mp->lowoff] = (mp)->msgstats[(j) - mp->lowoff])
163 #define get_msg_flags(mp,ptr,msgnum) (*(ptr) = (mp)->msgstats[(msgnum) - mp->lowoff])
164 #define set_msg_flags(mp,ptr,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = *(ptr))
166 #define does_exist(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & EXISTS)
167 #define unset_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~EXISTS)
168 #define set_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= EXISTS)
170 #define is_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECTED)
171 #define unset_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECTED)
172 #define set_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECTED)
174 #define is_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_UNSEEN)
175 #define unset_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECT_UNSEEN)
176 #define set_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_UNSEEN)
179 #define in_sequence(mp,seqnum,msgnum) \
180 ((mp)->msgstats[(msgnum) - mp->lowoff] & (1 << (FFATTRSLOT + seqnum)))
181 #define clear_sequence(mp,seqnum,msgnum) \
182 ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~(1 << (FFATTRSLOT + seqnum)))
183 #define add_sequence(mp,seqnum,msgnum) \
184 ((mp)->msgstats[(msgnum) - mp->lowoff] |= (1 << (FFATTRSLOT + seqnum)))
186 #define is_seq_private(mp,seqnum) \
187 ((mp)->attrstats & (1 << (FFATTRSLOT + seqnum)))
188 #define make_seq_public(mp,seqnum) \
189 ((mp)->attrstats &= ~(1 << (FFATTRSLOT + seqnum)))
190 #define make_seq_private(mp,seqnum) \
191 ((mp)->attrstats |= (1 << (FFATTRSLOT + seqnum)))
192 #define make_all_public(mp) \
193 ((mp)->attrstats = 0)
196 ** macros for folder attributes
198 #define clear_folder_flags(mp) ((mp)->msgflags = 0)
200 #define is_readonly(mp) ((mp)->msgflags & READONLY)
201 #define set_readonly(mp) ((mp)->msgflags |= READONLY)
203 #define other_files(mp) ((mp)->msgflags & OTHERS)
204 #define set_other_files(mp) ((mp)->msgflags |= OTHERS)
206 #define NULLMP ((struct msgs *) 0)
209 ** m_getfld() message parsing
212 #define NAMESZ 999 /*
213 ** Limit on component name size.
214 ** RFC 2822 limits line lengths to
215 ** 998 characters, so a header name
216 ** can be at most that long.
217 ** m_getfld limits header names to 2
218 ** less than NAMESZ, which is fine,
219 ** because header names must be
220 ** followed by a colon. Add one for
224 #define LENERR (-2) /* Name too long error from getfld */
225 #define FMTERR (-3) /* Message Format error */
226 #define FLD 0 /* Field returned */
227 #define FLDPLUS 1 /* Field returned with more to come */
228 #define FLDEOF 2 /* Field returned ending at eom */
229 #define BODY 3 /* Body returned with more to come */
230 #define BODYEOF 4 /* Body returned ending at eom */
231 #define FILEEOF 5 /* Reached end of input file */
233 extern int msg_count; /* m_getfld() indicators (That's a hack!) */
235 #define NOUSE 0 /* draft being re-used */
237 #define OUTPUTLINELEN 72 /* default line length for headers */
240 ** miscellaneous macros
243 #define pidXwait(pid,cp) pidstatus(pidwait(pid, NOTOK), stdout, cp)
246 # define max(a,b) ((a) > (b) ? (a) : (b))
250 # define min(a,b) ((a) < (b) ? (a) : (b))
256 #define CTXMOD 0x01 /* context information modified */
257 #define DBITS "\020\01CTXMOD"
258 extern char ctxflags;
260 extern char *invo_name; /* command invocation name */
261 extern char *mypath; /* user's $HOME */
263 extern char *mmhpath;
264 extern char *defpath; /* pathname of user's profile */
265 extern char *ctxpath; /* pathname of user's context */
266 extern struct node *m_defs; /* list of profile/context entries */
267 extern char *mailstore; /* name of mail storage directory */
270 ** These standard strings are defined in config.c. They are the
271 ** only system-dependent parameters in nmh, and thus by redefining
272 ** their values and reloading the various modules, nmh will run
275 extern char *attach_hdr;
276 extern char *components;
277 extern char *context;
278 extern char *curfolder;
279 extern char *defaulteditor;
280 extern char *defaultpager;
281 extern char *defaultfolder;
282 extern char *digestcomps;
283 extern char *distcomps;
284 extern char *draftfolder;
285 extern char *foldprot;
286 extern char *forwcomps;
288 extern char *listproc;
289 extern char *mhetcdir;
290 extern char *mailspool;
292 extern char *mhlformat;
293 extern char *mhlreply;
294 extern char *mimetypequery;
295 extern char *mimetypequeryproc;
296 extern char *msgprot;
297 extern char *nmhstorage;
298 extern char *nsequence;
299 extern char *profile;
300 extern char *psequence;
301 extern char *rcvdistcomps;
302 extern char *replcomps;
303 extern char *replgroupcomps;
304 extern char *sendmail;
305 extern char *seq_all;
306 extern char *seq_beyond;
307 extern char *seq_cur;
308 extern char *seq_first;
309 extern char *seq_last;
310 extern char *seq_next;
311 extern char *seq_prev;
312 extern char *seq_unseen;
313 extern char *seq_neg;
314 extern char *trashfolder;
315 extern char *usequence;
316 extern char *version_num;
317 extern char *version_str;
318 extern char *whatnowproc;
320 extern void (*done) (int) NORETURN;
322 #include <h/prototypes.h>