2 ** mh.h -- main header file for all of nmh
10 #include <sys/types.h>
15 ** Well-used constants
17 #define NOTOK (-1) /* syscall()s return this on error */
18 #define OK 0 /* ditto on success */
19 #define DONE 1 /* trinary logic */
21 #define Nbby 8 /* number of bits/byte */
23 #define MAXARGS 1000 /* max arguments to exec */
24 #define NFOLDERS 1000 /* max folder arguments on command line */
25 #define DMAXFOLDER 4 /* typical number of digits */
26 #define MAXFOLDER 1000 /* message increment */
34 typedef unsigned char boolean; /* not int so we can pack in a structure */
36 /* If we're using gcc then give it some information about
37 ** functions that abort.
40 # define NORETURN __attribute__((__noreturn__))
41 # define CONST __attribute__((const))
42 # define MALLOC __attribute__((malloc))
43 # define NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
44 # define PURE __attribute__((pure))
45 # define ENDNULL __attribute__((sentinel))
55 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
56 # define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
57 # define CHECK_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg)))
59 # define ALLOC_SIZE(...)
60 # define CHECK_PRINTF(fmt, arg)
64 ** we should be getting this value from pathconf(_PC_PATH_MAX)
68 # define PATH_MAX MAXPATHLEN
70 /* so we will just pick something */
71 # define PATH_MAX 1024
76 ** we should be getting this value from sysconf(_SC_OPEN_MAX)
80 # define OPEN_MAX NOFILE
82 /* so we will just pick something */
88 ** user context/profile structure
91 char *n_name; /* key */
92 char *n_field; /* value */
93 char n_context; /* context, not profile */
94 struct node *n_next; /* next entry */
100 #define AMBIGSW (-2) /* from smatch() on ambiguous switch */
101 #define UNKWNSW (-1) /* from smatch() on unknown switch */
106 ** The minchars field is apparently used like this:
108 ** -# : Switch can be abbreviated to # chars; switch hidden in -help.
109 ** 0 : Switch can't be abbreviated; switch shown in -help.
110 ** # : Switch can be abbreviated to # chars; switch shown in -help.
115 extern struct swit anoyes[]; /* standard yes/no switches */
118 ** general folder attributes
120 #define READONLY (1<<0) /* No write access to folder */
121 #define SEQMOD (1<<1) /* folder's sequences modifed */
122 #define ALLOW_BEYOND (1<<2) /* allow the beyond sequence */
123 #define OTHERS (1<<3) /* folder has other files */
125 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_BEYOND\04OTHERS"
128 ** type for holding the sequence set of a message
130 typedef unsigned int seqset_t;
133 ** internal messages attributes (sequences)
135 #define EXISTS (1<<0) /* exists */
136 #define SELECTED (1<<1) /* selected for use */
137 #define SELECT_UNSEEN (1<<2) /* inc/show "unseen" */
139 #define MBITS "\020\01EXISTS\02SELECTED\03UNSEEN"
142 ** first free slot for user-defined sequences
147 ** Determine the number of user defined sequences we
148 ** can have. The first few sequence flags are for
149 ** internal nmh message flags.
151 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - FFATTRSLOT)
154 ** Primary structure of folder/message information
157 int lowmsg; /* Lowest msg number */
158 int hghmsg; /* Highest msg number */
159 int nummsg; /* Actual Number of msgs */
161 int lowsel; /* Lowest selected msg number */
162 int hghsel; /* Highest selected msg number */
163 int numsel; /* Number of msgs selected */
165 int curmsg; /* Number of current msg if any */
167 int msgflags; /* Folder attributes (READONLY, etc) */
168 char *foldpath; /* Pathname of folder */
171 ** Name of sequences in this folder. We add an
172 ** extra slot, so we can NULL terminate the list.
174 char *msgattrs[NUMATTRS + 1];
177 ** bit flags for whether sequence
178 ** is public (0), or private (1)
183 ** These represent the lowest and highest possible
184 ** message numbers we can put in the message status
185 ** area, without calling folder_realloc().
191 ** This is an array of seqset_t which we allocate dynamically.
192 ** Each seqset_t is a set of bits flags for a particular message.
193 ** These bit flags represent general attributes such as
194 ** EXISTS, SELECTED, etc. as well as track if message is
195 ** in a particular sequence.
197 seqset_t *msgstats; /* msg status */
201 ** Amount of space to allocate for msgstats. Allocate
202 ** the array to have space for messages numbers lo to hi.
204 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
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 MAXTEXTPERLN 78
226 /* m_getfld2() returned data */
236 /* m_getfld2() states */
238 LENERR2 = -2, /* Line too long */
239 FMTERR2 = -3, /* Format error in message */
240 IOERR2 = -1, /* Read error */
241 FLD2 = 0, /* Header field returned */
242 BODY2, /* Body line returned */
243 FILEEOF2 /* Reached end of input file */
246 #define NOUSE 0 /* draft being re-used */
248 #define OUTPUTLINELEN 72 /* default line length for headers */
251 ** miscellaneous macros
255 # define max(a,b) ((a) > (b) ? (a) : (b))
259 # define min(a,b) ((a) < (b) ? (a) : (b))
265 #define CTXMOD 0x01 /* context information modified */
266 #define DBITS "\020\01CTXMOD"
267 extern char ctxflags;
269 extern char *invo_name; /* command invocation name */
270 extern char *mypath; /* user's $HOME */
272 extern char *mmhpath;
273 extern char *defpath; /* pathname of user's profile */
274 extern char *ctxpath; /* pathname of user's context */
275 extern struct node *m_defs; /* list of profile/context entries */
276 extern char *mailstore; /* name of mail storage directory */
279 ** These standard strings are defined in config.c. They are the
280 ** only system-dependent parameters in nmh, and thus by redefining
281 ** their values and reloading the various modules, nmh will run
284 extern char *attach_hdr;
285 extern char *sign_hdr;
286 extern char *enc_hdr;
287 extern char *components;
288 extern char *context;
289 extern char *curfolder;
290 extern char *defaulteditor;
291 extern char *defaultpager;
292 extern char *defaultfolder;
293 extern char *digestcomps;
294 extern char *distcomps;
295 extern char *draftfolder;
296 extern char *foldprot;
297 extern char *forwcomps;
299 extern char *listproc;
300 extern char *mhetcdir;
301 extern char *mailspool;
303 extern char *mhlformat;
304 extern char *mhlreply;
305 extern char *mimetypequery;
306 extern char *mimetypequeryproc;
307 extern char *msgprot;
308 extern char *nmhstorage;
309 extern char *nsequence;
310 extern char *profile;
311 extern char *rcvdistcomps;
312 extern char *replcomps;
313 extern char *replgroupcomps;
314 extern char *scanformat;
315 extern char *sendmail;
316 extern char *seq_all;
317 extern char *seq_beyond;
318 extern char *seq_cur;
319 extern char *seq_first;
320 extern char *seq_last;
321 extern char *seq_next;
322 extern char *seq_prev;
323 extern char *seq_unseen;
324 extern char *seq_neg;
325 extern char *trashfolder;
326 extern char *usequence;
327 extern char *version;
328 extern char *lib_version;
329 extern char *whatnowproc;
331 #include <h/charstring.h>
332 #include <h/prototypes.h>