]>
diplodocus.org Git - nmh/blob - h/mh.h
3 * mh.h -- main header file for all of nmh
11 #define NOTOK (-1) /* syscall()s return this on error */
12 #define OK 0 /* ditto on success */
13 #define DONE 1 /* trinary logic */
15 #define Nbby 8 /* number of bits/byte */
17 #define MAXARGS 1000 /* max arguments to exec */
18 #define NFOLDERS 1000 /* max folder arguments on command line */
19 #define DMAXFOLDER 4 /* typical number of digits */
20 #define MAXFOLDER 1000 /* message increment */
28 typedef unsigned char boolean
; /* not int so we can pack in a structure */
30 /* If we're using gcc then give it some information about
31 * functions that abort.
34 #define NORETURN __attribute__((__noreturn__))
35 #define NMH_UNUSED(i) (void) i
38 #define NMH_UNUSED(i) i
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 */
65 /* The minchars field is apparently used like this:
67 -# : Switch can be abbreviated to # characters; switch hidden in -help.
68 0 : Switch can't be abbreviated; switch shown in -help.
69 # : Switch can be abbreviated to # characters; switch shown in -help. */
73 * If we pick this switch, return this value from smatch
80 * Macros to use when declaring struct swit arrays.
82 * These macros are what known as X-Macros. In your source code you
85 * #define FOO_SWITCHES \
86 * X("switch1", 0, SWITCHSW) \
87 * X("switch2", 0, SWITCH2SW) \
88 * X("thirdswitch", 2, SWITCH3SW) \
90 * The argument to each entry in FOO_SWITCHES are the switch name (sw),
91 * the minchars field (see above) and the return value for this switch.
93 * After you define FOO_SWITCHES, you instantiate it as follows:
95 * #define X(sw, minchars, id) id,
96 * DEFINE_SWITCH_ENUM(FOO);
99 * #define X(sw, minchars, id) { sw, minchars, id },
100 * DEFINE_SWITCH_ARRAY(FOO);
103 * DEFINE_SWITCH_ENUM defines an extra enum at the end of the list called
107 #define DEFINE_SWITCH_ENUM(name) \
113 #define DEFINE_SWITCH_ARRAY(name, array) \
114 static struct swit array[] = { \
119 extern struct swit anoyes
[]; /* standard yes/no switches */
121 #define ATTACHFORMATS 3 /* Number of send attach formats. */
124 * general folder attributes
126 #define READONLY (1<<0) /* No write access to folder */
127 #define SEQMOD (1<<1) /* folder's sequences modifed */
128 #define ALLOW_NEW (1<<2) /* allow the "new" sequence */
129 #define OTHERS (1<<3) /* folder has other files */
130 #define MODIFIED (1<<4) /* msh in-core folder modified */
132 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS\05MODIFIED"
135 * type for holding the sequence set of a message
137 typedef unsigned int seqset_t
;
140 * Determine the number of user defined sequences we
141 * can have. The first 5 sequence flags are for
142 * internal nmh message flags.
144 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - 5)
147 * first free slot for user defined sequences
153 * internal messages attributes (sequences)
155 #define EXISTS (1<<0) /* exists */
156 #define DELETED (1<<1) /* deleted */
157 #define SELECTED (1<<2) /* selected for use */
158 #define SELECT_EMPTY (1<<3) /* "new" message */
159 #define SELECT_UNSEEN (1<<4) /* inc/show "unseen" */
161 #define MBITS "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN"
164 * Primary structure of folder/message information
167 int lowmsg
; /* Lowest msg number */
168 int hghmsg
; /* Highest msg number */
169 int nummsg
; /* Actual Number of msgs */
171 int lowsel
; /* Lowest selected msg number */
172 int hghsel
; /* Highest selected msg number */
173 int numsel
; /* Number of msgs selected */
175 int curmsg
; /* Number of current msg if any */
177 int msgflags
; /* Folder attributes (READONLY, etc) */
178 char *foldpath
; /* Pathname of folder */
181 * Name of sequences in this folder. We add an
182 * extra slot, so we can NULL terminate the list.
184 char *msgattrs
[NUMATTRS
+ 1];
187 * bit flags for whether sequence
188 * is public (0), or private (1)
193 * These represent the lowest and highest possible
194 * message numbers we can put in the message status
195 * area, without calling folder_realloc().
201 * This is an array of seqset_t which we allocate dynamically.
202 * Each seqset_t is a set of bits flags for a particular message.
203 * These bit flags represent general attributes such as
204 * EXISTS, SELECTED, etc. as well as track if message is
205 * in a particular sequence.
207 seqset_t
*msgstats
; /* msg status */
211 * Amount of space to allocate for msgstats. Allocate
212 * the array to have space for messages numbers lo to hi.
214 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
217 * macros for message and sequence manipulation
219 #define clear_msg_flags(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = 0)
220 #define copy_msg_flags(mp,i,j) \
221 ((mp)->msgstats[(i) - mp->lowoff] = (mp)->msgstats[(j) - mp->lowoff])
222 #define get_msg_flags(mp,ptr,msgnum) (*(ptr) = (mp)->msgstats[(msgnum) - mp->lowoff])
223 #define set_msg_flags(mp,ptr,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = *(ptr))
225 #define does_exist(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & EXISTS)
226 #define unset_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~EXISTS)
227 #define set_exists(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= EXISTS)
229 #define is_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECTED)
230 #define unset_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECTED)
231 #define set_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECTED)
233 #define is_select_empty(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_EMPTY)
234 #define set_select_empty(mp,msgnum) \
235 ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_EMPTY)
237 #define is_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_UNSEEN)
238 #define unset_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECT_UNSEEN)
239 #define set_unseen(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_UNSEEN)
242 #define set_deleted(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] |= DELETED)
244 #define in_sequence(mp,seqnum,msgnum) \
245 ((mp)->msgstats[(msgnum) - mp->lowoff] & (1 << (FFATTRSLOT + seqnum)))
246 #define clear_sequence(mp,seqnum,msgnum) \
247 ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~(1 << (FFATTRSLOT + seqnum)))
248 #define add_sequence(mp,seqnum,msgnum) \
249 ((mp)->msgstats[(msgnum) - mp->lowoff] |= (1 << (FFATTRSLOT + seqnum)))
251 #define is_seq_private(mp,seqnum) \
252 ((mp)->attrstats & (1 << (FFATTRSLOT + seqnum)))
253 #define make_seq_public(mp,seqnum) \
254 ((mp)->attrstats &= ~(1 << (FFATTRSLOT + seqnum)))
255 #define make_seq_private(mp,seqnum) \
256 ((mp)->attrstats |= (1 << (FFATTRSLOT + seqnum)))
257 #define make_all_public(mp) \
258 ((mp)->attrstats = 0)
261 * macros for folder attributes
263 #define clear_folder_flags(mp) ((mp)->msgflags = 0)
265 #define is_readonly(mp) ((mp)->msgflags & READONLY)
266 #define set_readonly(mp) ((mp)->msgflags |= READONLY)
268 #define other_files(mp) ((mp)->msgflags & OTHERS)
269 #define set_other_files(mp) ((mp)->msgflags |= OTHERS)
271 #define NULLMP ((struct msgs *) 0)
274 * m_getfld() message parsing
277 #define NAMESZ 999 /* Limit on component name size.
278 RFC 2822 limits line lengths to
279 998 characters, so a header name
280 can be at most that long.
281 m_getfld limits header names to 2
282 less than NAMESZ, which is fine,
283 because header names must be
284 followed by a colon. Add one for
287 #define LENERR (-2) /* Name too long error from getfld */
288 #define FMTERR (-3) /* Message Format error */
289 #define FLD 0 /* Field returned */
290 #define FLDPLUS 1 /* Field returned with more to come */
291 #define BODY 3 /* Body returned with more to come */
292 #define FILEEOF 5 /* Reached end of input file */
294 struct m_getfld_state
;
295 typedef struct m_getfld_state
*m_getfld_state_t
;
300 #define MS_DEFAULT 0 /* default (one msg per file) */
301 #define MS_UNKNOWN 1 /* type not known yet */
302 #define MS_MBOX 2 /* Unix-style "from" lines */
303 #define MS_MMDF 3 /* string mmdlm2 */
304 #define MS_MSH 4 /* whacko msh */
306 #define NOUSE 0 /* draft being re-used */
308 #define TFOLDER 0 /* path() given a +folder */
309 #define TFILE 1 /* path() given a file */
310 #define TSUBCWF 2 /* path() given a @folder */
312 #define OUTPUTLINELEN 72 /* default line length for headers */
314 #define LINK "@" /* Name of link to file to which you are */
317 #define NMH_ATTACH_HEADER "Nmh-Attachment" /* Default header for -attach */
320 * miscellaneous macros
322 #define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp)
325 # define max(a,b) ((a) > (b) ? (a) : (b))
329 # define min(a,b) ((a) < (b) ? (a) : (b))
333 # define abs(a) ((a) > 0 ? (a) : -(a))
339 #define CTXMOD 0x01 /* context information modified */
340 #define DBITS "\020\01CTXMOD"
341 extern char ctxflags
;
343 extern char *invo_name
; /* command invocation name */
344 extern char *mypath
; /* user's $HOME */
345 extern char *defpath
; /* pathname of user's profile */
346 extern char *ctxpath
; /* pathname of user's context */
347 extern struct node
*m_defs
; /* list of profile/context entries */
349 /* What style to use for generated Message-ID and Content-ID header
350 fields. The localname style is pid.time@localname, where time is
351 in seconds. The random style replaces the localname with some
352 (pseudo)random bytes and uses microsecond-resolution time. */
353 int save_message_id_style (const char *);
354 char *message_id (time_t, int);
357 * These standard strings are defined in config.c. They are the
358 * only system-dependent parameters in nmh, and thus by redefining
359 * their values and reloading the various modules, nmh will run
362 extern char *buildmimeproc
;
363 extern char *catproc
;
364 extern char *components
;
365 extern char *context
;
366 extern char *current
;
367 extern char *defaultfolder
;
368 extern char *digestcomps
;
369 extern char *distcomps
;
371 extern char *fileproc
;
372 extern char *foldprot
;
373 extern char *formatproc
;
374 extern char *forwcomps
;
376 extern char *incproc
;
378 extern char *mailproc
;
379 extern char *mh_defaults
;
380 extern char *mh_profile
;
382 extern char *mhlformat
;
383 extern char *mhlforward
;
384 extern char *mhlproc
;
385 extern char *mhlreply
;
386 extern char *moreproc
;
387 extern char *msgprot
;
388 extern char *mshproc
;
389 extern char *nmhaccessftp
;
390 extern char *nmhstorage
;
391 extern char *nmhcache
;
392 extern char *nmhprivcache
;
393 extern char *nsequence
;
394 extern char *packproc
;
395 extern char *postproc
;
396 extern char *pfolder
;
397 extern char *psequence
;
398 extern char *rcvdistcomps
;
399 extern char *rcvstoreproc
;
400 extern char *replcomps
;
401 extern char *replgroupcomps
;
402 extern char *rmmproc
;
403 extern char *sendproc
;
404 extern char *showmimeproc
;
405 extern char *showproc
;
406 extern char *usequence
;
407 extern char *version_num
;
408 extern char *version_str
;
409 extern char *vmhproc
;
410 extern char *whatnowproc
;
411 extern char *whomproc
;
413 extern void (*done
) (int) NORETURN
;
415 #include <h/prototypes.h>