3 * mh.h -- main header file for all of nmh
10 /* A quick fix for Linux systems. According to the vfork manual page,
11 there is little difference in performance, so we aren't losing much.
12 But this fixes a minor message bug so why not? On NetBSD, this should
13 probably not happen. */
22 #define NOTOK (-1) /* syscall()s return this on error */
23 #define OK 0 /* ditto on success */
24 #define DONE 1 /* trinary logic */
26 #define Nbby 8 /* number of bits/byte */
28 #define MAXARGS 1000 /* max arguments to exec */
29 #define NFOLDERS 1000 /* max folder arguments on command line */
30 #define DMAXFOLDER 4 /* typical number of digits */
31 #define MAXFOLDER 1000 /* message increment */
39 typedef unsigned char boolean; /* not int so we can pack in a structure */
42 * user context/profile structure
45 char *n_name; /* key */
46 char *n_field; /* value */
47 char n_context; /* context, not profile */
48 struct node *n_next; /* next entry */
54 #define AMBIGSW (-2) /* from smatch() on ambiguous switch */
55 #define UNKWNSW (-1) /* from smatch() on unknown switch */
60 /* The minchars field is apparently used like this:
62 -# : Switch can be abbreviated to # characters; switch hidden in -help.
63 0 : Switch can't be abbreviated; switch shown in -help.
64 # : Switch can be abbreviated to # characters; switch shown in -help. */
68 extern struct swit anoyes[]; /* standard yes/no switches */
71 * general folder attributes
73 #define READONLY (1<<0) /* No write access to folder */
74 #define SEQMOD (1<<1) /* folder's sequences modifed */
75 #define ALLOW_NEW (1<<2) /* allow the "new" sequence */
76 #define OTHERS (1<<3) /* folder has other files */
77 #define MODIFIED (1<<4) /* msh in-core folder modified */
79 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS\05MODIFIED"
82 * type for holding the sequence set of a message
84 typedef unsigned int seqset_t;
87 * Determine the number of user defined sequences we
88 * can have. The first 5 sequence flags are for
89 * internal nmh message flags.
91 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - 5)
94 * first free slot for user defined sequences
100 * internal messages attributes (sequences)
102 #define EXISTS (1<<0) /* exists */
103 #define DELETED (1<<1) /* deleted */
104 #define SELECTED (1<<2) /* selected for use */
105 #define SELECT_EMPTY (1<<3) /* "new" message */
106 #define SELECT_UNSEEN (1<<4) /* inc/show "unseen" */
108 #define MBITS "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN"
111 * Primary structure of folder/message information
114 int lowmsg; /* Lowest msg number */
115 int hghmsg; /* Highest msg number */
116 int nummsg; /* Actual Number of msgs */
118 int lowsel; /* Lowest selected msg number */
119 int hghsel; /* Highest selected msg number */
120 int numsel; /* Number of msgs selected */
122 int curmsg; /* Number of current msg if any */
124 int msgflags; /* Folder attributes (READONLY, etc) */
125 char *foldpath; /* Pathname of folder */
128 * Name of sequences in this folder. We add an
129 * extra slot, so we can NULL terminate the list.
131 char *msgattrs[NUMATTRS + 1];
134 * bit flags for whether sequence
135 * is public (0), or private (1)
140 * These represent the lowest and highest possible
141 * message numbers we can put in the message status
142 * area, without calling folder_realloc().
148 * This is an array of seqset_t which we allocate dynamically.
149 * Each seqset_t is a set of bits flags for a particular message.
150 * These bit flags represent general attributes such as
151 * EXISTS, SELECTED, etc. as well as track if message is
152 * in a particular sequence.
154 seqset_t *msgstats; /* msg status */
158 * Amount of space to allocate for msgstats. Allocate
159 * the array to have space for messages numbers lo to hi.
161 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
164 * macros for message and sequence manipulation
166 #define clear_msg_flags(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = 0)
167 #define copy_msg_flags(mp,i,j) \
168 ((mp)->msgstats[(i) - mp->lowoff] = (mp)->msgstats[(j) - mp->lowoff])
169 #define get_msg_flags(mp,ptr,msgnum) (*(ptr) = (mp)->msgstats[(msgnum) - mp->lowoff])
170 #define set_msg_flags(mp,ptr,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = *(ptr))
172 #define does_exist(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & EXISTS)
173 #define unset_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~EXISTS)
174 #define set_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= EXISTS)
176 #define is_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECTED)
177 #define unset_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECTED)
178 #define set_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECTED)
180 #define is_select_empty(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_EMPTY)
181 #define set_select_empty(mp,msgnum) \
182 ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_EMPTY)
184 #define is_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_UNSEEN)
185 #define unset_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECT_UNSEEN)
186 #define set_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_UNSEEN)
189 #define set_deleted(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= DELETED)
191 #define in_sequence(mp,seqnum,msgnum) \
192 ((mp)->msgstats[(msgnum) - mp->lowoff] & (1 << (FFATTRSLOT + seqnum)))
193 #define clear_sequence(mp,seqnum,msgnum) \
194 ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~(1 << (FFATTRSLOT + seqnum)))
195 #define add_sequence(mp,seqnum,msgnum) \
196 ((mp)->msgstats[(msgnum) - mp->lowoff] |= (1 << (FFATTRSLOT + seqnum)))
198 #define is_seq_private(mp,seqnum) \
199 ((mp)->attrstats & (1 << (FFATTRSLOT + seqnum)))
200 #define make_seq_public(mp,seqnum) \
201 ((mp)->attrstats &= ~(1 << (FFATTRSLOT + seqnum)))
202 #define make_seq_private(mp,seqnum) \
203 ((mp)->attrstats |= (1 << (FFATTRSLOT + seqnum)))
204 #define make_all_public(mp) \
205 ((mp)->attrstats = 0)
208 * macros for folder attributes
210 #define clear_folder_flags(mp) ((mp)->msgflags = 0)
212 #define is_readonly(mp) ((mp)->msgflags & READONLY)
213 #define set_readonly(mp) ((mp)->msgflags |= READONLY)
215 #define other_files(mp) ((mp)->msgflags & OTHERS)
216 #define set_other_files(mp) ((mp)->msgflags |= OTHERS)
218 #define NULLMP ((struct msgs *) 0)
221 * m_getfld() message parsing
224 #define NAMESZ 128 /* Limit on component name size */
226 #define LENERR (-2) /* Name too long error from getfld */
227 #define FMTERR (-3) /* Message Format error */
228 #define FLD 0 /* Field returned */
229 #define FLDPLUS 1 /* Field returned with more to come */
230 #define FLDEOF 2 /* Field returned ending at eom */
231 #define BODY 3 /* Body returned with more to come */
232 #define BODYEOF 4 /* Body returned ending at eom */
233 #define FILEEOF 5 /* Reached end of input file */
238 #define MS_DEFAULT 0 /* default (one msg per file) */
239 #define MS_UNKNOWN 1 /* type not known yet */
240 #define MS_MBOX 2 /* Unix-style "from" lines */
241 #define MS_MMDF 3 /* string mmdlm2 */
242 #define MS_MSH 4 /* whacko msh */
244 extern int msg_count; /* m_getfld() indicators */
245 extern int msg_style; /* .. */
246 extern char *msg_delim; /* .. */
248 #define NOUSE 0 /* draft being re-used */
250 #define TFOLDER 0 /* path() given a +folder */
251 #define TFILE 1 /* path() given a file */
252 #define TSUBCWF 2 /* path() given a @folder */
254 #define OUTPUTLINELEN 72 /* default line length for headers */
257 * miscellaneous macros
259 #define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp)
262 # define max(a,b) ((a) > (b) ? (a) : (b))
266 # define min(a,b) ((a) < (b) ? (a) : (b))
270 # define abs(a) ((a) > 0 ? (a) : -(a))
276 #define CTXMOD 0x01 /* context information modified */
277 #define DBITS "\020\01CTXMOD"
278 extern char ctxflags;
280 extern char *invo_name; /* command invocation name */
281 extern char *mypath; /* user's $HOME */
282 extern char *defpath; /* pathname of user's profile */
283 extern char *ctxpath; /* pathname of user's context */
284 extern struct node *m_defs; /* list of profile/context entries */
287 * These standard strings are defined in config.c. They are the
288 * only system-dependent parameters in nmh, and thus by redefining
289 * their values and reloading the various modules, nmh will run
292 extern char *buildmimeproc;
293 extern char *catproc;
294 extern char *components;
295 extern char *context;
296 extern char *current;
297 extern char *defaulteditor;
298 extern char *defaultfolder;
299 extern char *digestcomps;
300 extern char *distcomps;
302 extern char *faceproc;
303 extern char *fileproc;
304 extern char *foldprot;
305 extern char *forwcomps;
307 extern char *incproc;
308 extern char *installproc;
310 extern char *mailproc;
311 extern char *mh_defaults;
312 extern char *mh_profile;
314 extern char *mhlformat;
315 extern char *mhlforward;
316 extern char *mhlproc;
317 extern char *mhlreply;
318 extern char *moreproc;
319 extern char *msgprot;
320 extern char *mshproc;
321 extern char *nmhaccessftp;
322 extern char *nmhstorage;
323 extern char *nmhcache;
324 extern char *nmhprivcache;
325 extern char *nsequence;
326 extern char *packproc;
327 extern char *postproc;
328 extern char *pfolder;
329 extern char *psequence;
330 extern char *rcvdistcomps;
331 extern char *rcvstoreproc;
332 extern char *replcomps;
333 extern char *replgroupcomps;
334 extern char *rmfproc;
335 extern char *rmmproc;
336 extern char *sendproc;
337 extern char *showmimeproc;
338 extern char *showproc;
339 extern char *usequence;
340 extern char *version_num;
341 extern char *version_str;
342 extern char *vmhproc;
343 extern char *whatnowproc;
344 extern char *whomproc;
346 #include <h/prototypes.h>