3 * mh.h -- main header file for all of nmh
13 #define NOTOK (-1) /* syscall()s return this on error */
14 #define OK 0 /* ditto on success */
15 #define DONE 1 /* trinary logic */
17 #define Nbby 8 /* number of bits/byte */
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 */
30 typedef unsigned char boolean; /* not int so we can pack in a structure */
33 * user context/profile structure
36 char *n_name; /* key */
37 char *n_field; /* value */
38 char n_context; /* context, not profile */
39 struct node *n_next; /* next entry */
45 #define AMBIGSW (-2) /* from smatch() on ambiguous switch */
46 #define UNKWNSW (-1) /* from smatch() on unknown switch */
51 /* The minchars field is apparently used like this:
53 -# : Switch can be abbreviated to # characters; switch hidden in -help.
54 0 : Switch can't be abbreviated; switch shown in -help.
55 # : Switch can be abbreviated to # characters; switch shown in -help. */
59 extern struct swit anoyes[]; /* standard yes/no switches */
61 #define ATTACHFORMATS 3 /* Number of send attach formats. */
64 * general folder attributes
66 #define READONLY (1<<0) /* No write access to folder */
67 #define SEQMOD (1<<1) /* folder's sequences modifed */
68 #define ALLOW_NEW (1<<2) /* allow the "new" sequence */
69 #define OTHERS (1<<3) /* folder has other files */
70 #define MODIFIED (1<<4) /* msh in-core folder modified */
72 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS\05MODIFIED"
75 * type for holding the sequence set of a message
77 typedef unsigned int seqset_t;
80 * Determine the number of user defined sequences we
81 * can have. The first 5 sequence flags are for
82 * internal nmh message flags.
84 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - 5)
87 * first free slot for user defined sequences
93 * internal messages attributes (sequences)
95 #define EXISTS (1<<0) /* exists */
96 #define DELETED (1<<1) /* deleted */
97 #define SELECTED (1<<2) /* selected for use */
98 #define SELECT_EMPTY (1<<3) /* "new" message */
99 #define SELECT_UNSEEN (1<<4) /* inc/show "unseen" */
101 #define MBITS "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN"
104 * Primary structure of folder/message information
107 int lowmsg; /* Lowest msg number */
108 int hghmsg; /* Highest msg number */
109 int nummsg; /* Actual Number of msgs */
111 int lowsel; /* Lowest selected msg number */
112 int hghsel; /* Highest selected msg number */
113 int numsel; /* Number of msgs selected */
115 int curmsg; /* Number of current msg if any */
117 int msgflags; /* Folder attributes (READONLY, etc) */
118 char *foldpath; /* Pathname of folder */
121 * Name of sequences in this folder. We add an
122 * extra slot, so we can NULL terminate the list.
124 char *msgattrs[NUMATTRS + 1];
127 * bit flags for whether sequence
128 * is public (0), or private (1)
133 * These represent the lowest and highest possible
134 * message numbers we can put in the message status
135 * area, without calling folder_realloc().
141 * This is an array of seqset_t which we allocate dynamically.
142 * Each seqset_t is a set of bits flags for a particular message.
143 * These bit flags represent general attributes such as
144 * EXISTS, SELECTED, etc. as well as track if message is
145 * in a particular sequence.
147 seqset_t *msgstats; /* msg status */
151 * Amount of space to allocate for msgstats. Allocate
152 * the array to have space for messages numbers lo to hi.
154 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
157 * macros for message and sequence manipulation
159 #define clear_msg_flags(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = 0)
160 #define copy_msg_flags(mp,i,j) \
161 ((mp)->msgstats[(i) - mp->lowoff] = (mp)->msgstats[(j) - mp->lowoff])
162 #define get_msg_flags(mp,ptr,msgnum) (*(ptr) = (mp)->msgstats[(msgnum) - mp->lowoff])
163 #define set_msg_flags(mp,ptr,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = *(ptr))
165 #define does_exist(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & EXISTS)
166 #define unset_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~EXISTS)
167 #define set_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= EXISTS)
169 #define is_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECTED)
170 #define unset_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECTED)
171 #define set_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECTED)
173 #define is_select_empty(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_EMPTY)
174 #define set_select_empty(mp,msgnum) \
175 ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_EMPTY)
177 #define is_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_UNSEEN)
178 #define unset_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECT_UNSEEN)
179 #define set_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_UNSEEN)
182 #define set_deleted(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= DELETED)
184 #define in_sequence(mp,seqnum,msgnum) \
185 ((mp)->msgstats[(msgnum) - mp->lowoff] & (1 << (FFATTRSLOT + seqnum)))
186 #define clear_sequence(mp,seqnum,msgnum) \
187 ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~(1 << (FFATTRSLOT + seqnum)))
188 #define add_sequence(mp,seqnum,msgnum) \
189 ((mp)->msgstats[(msgnum) - mp->lowoff] |= (1 << (FFATTRSLOT + seqnum)))
191 #define is_seq_private(mp,seqnum) \
192 ((mp)->attrstats & (1 << (FFATTRSLOT + seqnum)))
193 #define make_seq_public(mp,seqnum) \
194 ((mp)->attrstats &= ~(1 << (FFATTRSLOT + seqnum)))
195 #define make_seq_private(mp,seqnum) \
196 ((mp)->attrstats |= (1 << (FFATTRSLOT + seqnum)))
197 #define make_all_public(mp) \
198 ((mp)->attrstats = 0)
201 * macros for folder attributes
203 #define clear_folder_flags(mp) ((mp)->msgflags = 0)
205 #define is_readonly(mp) ((mp)->msgflags & READONLY)
206 #define set_readonly(mp) ((mp)->msgflags |= READONLY)
208 #define other_files(mp) ((mp)->msgflags & OTHERS)
209 #define set_other_files(mp) ((mp)->msgflags |= OTHERS)
211 #define NULLMP ((struct msgs *) 0)
214 * m_getfld() message parsing
217 #define NAMESZ 128 /* Limit on component name size */
219 #define LENERR (-2) /* Name too long error from getfld */
220 #define FMTERR (-3) /* Message Format error */
221 #define FLD 0 /* Field returned */
222 #define FLDPLUS 1 /* Field returned with more to come */
223 #define FLDEOF 2 /* Field returned ending at eom */
224 #define BODY 3 /* Body returned with more to come */
225 #define BODYEOF 4 /* Body returned ending at eom */
226 #define FILEEOF 5 /* Reached end of input file */
231 #define MS_DEFAULT 0 /* default (one msg per file) */
232 #define MS_UNKNOWN 1 /* type not known yet */
233 #define MS_MBOX 2 /* Unix-style "from" lines */
234 #define MS_MMDF 3 /* string mmdlm2 */
235 #define MS_MSH 4 /* whacko msh */
237 extern int msg_count; /* m_getfld() indicators */
238 extern int msg_style; /* .. */
239 extern char *msg_delim; /* .. */
241 #define NOUSE 0 /* draft being re-used */
243 #define TFOLDER 0 /* path() given a +folder */
244 #define TFILE 1 /* path() given a file */
245 #define TSUBCWF 2 /* path() given a @folder */
247 #define OUTPUTLINELEN 72 /* default line length for headers */
250 * miscellaneous macros
252 #define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp)
255 # define max(a,b) ((a) > (b) ? (a) : (b))
259 # define min(a,b) ((a) < (b) ? (a) : (b))
263 # define abs(a) ((a) > 0 ? (a) : -(a))
269 #define CTXMOD 0x01 /* context information modified */
270 #define DBITS "\020\01CTXMOD"
271 extern char ctxflags;
273 extern char *invo_name; /* command invocation name */
274 extern char *mypath; /* user's $HOME */
275 extern char *defpath; /* pathname of user's profile */
276 extern char *ctxpath; /* pathname of user's context */
277 extern struct node *m_defs; /* list of profile/context entries */
280 * These standard strings are defined in config.c. They are the
281 * only system-dependent parameters in nmh, and thus by redefining
282 * their values and reloading the various modules, nmh will run
285 extern char *buildmimeproc;
286 extern char *catproc;
287 extern char *components;
288 extern char *context;
289 extern char *current;
290 extern char *defaulteditor;
291 extern char *defaultfolder;
292 extern char *digestcomps;
293 extern char *distcomps;
295 extern char *faceproc;
296 extern char *fileproc;
297 extern char *foldprot;
298 extern char *forwcomps;
300 extern char *incproc;
301 extern char *installproc;
303 extern char *mailproc;
304 extern char *mh_defaults;
305 extern char *mh_profile;
307 extern char *mhlformat;
308 extern char *mhlforward;
309 extern char *mhlproc;
310 extern char *mhlreply;
311 extern char *moreproc;
312 extern char *msgprot;
313 extern char *mshproc;
314 extern char *nmhaccessftp;
315 extern char *nmhstorage;
316 extern char *nmhcache;
317 extern char *nmhprivcache;
318 extern char *nsequence;
319 extern char *packproc;
320 extern char *postproc;
321 extern char *pfolder;
322 extern char *psequence;
323 extern char *rcvdistcomps;
324 extern char *rcvstoreproc;
325 extern char *replcomps;
326 extern char *replgroupcomps;
327 extern char *rmfproc;
328 extern char *rmmproc;
329 extern char *sendproc;
330 extern char *showmimeproc;
331 extern char *showproc;
332 extern char *usequence;
333 extern char *version_num;
334 extern char *version_str;
335 extern char *vmhproc;
336 extern char *whatnowproc;
337 extern char *whomproc;
339 #include <h/prototypes.h>