2 ** mh.h -- main header file for all of nmh
18 #ifdef HAVE_SYS_PARAM_H
19 # include <sys/param.h>
26 ** Well-used constants
28 #define NOTOK (-1) /* syscall()s return this on error */
29 #define OK 0 /* ditto on success */
30 #define DONE 1 /* trinary logic */
32 #define Nbby 8 /* number of bits/byte */
34 #define MAXARGS 1000 /* max arguments to exec */
35 #define NFOLDERS 1000 /* max folder arguments on command line */
36 #define DMAXFOLDER 4 /* typical number of digits */
37 #define MAXFOLDER 1000 /* message increment */
45 typedef unsigned char boolean; /* not int so we can pack in a structure */
47 /* If we're using gcc then give it some information about
48 ** functions that abort.
51 # define NORETURN __attribute__((__noreturn__))
57 ** we should be getting this value from pathconf(_PC_PATH_MAX)
61 # define PATH_MAX MAXPATHLEN
63 /* so we will just pick something */
64 # define PATH_MAX 1024
69 ** we should be getting this value from sysconf(_SC_OPEN_MAX)
73 # define OPEN_MAX NOFILE
75 /* so we will just pick something */
81 ** user context/profile structure
84 char *n_name; /* key */
85 char *n_field; /* value */
86 char n_context; /* context, not profile */
87 struct node *n_next; /* next entry */
93 #define AMBIGSW (-2) /* from smatch() on ambiguous switch */
94 #define UNKWNSW (-1) /* from smatch() on unknown switch */
99 ** The minchars field is apparently used like this:
101 ** -# : Switch can be abbreviated to # chars; switch hidden in -help.
102 ** 0 : Switch can't be abbreviated; switch shown in -help.
103 ** # : Switch can be abbreviated to # chars; switch shown in -help.
108 extern struct swit anoyes[]; /* standard yes/no switches */
111 ** general folder attributes
113 #define READONLY (1<<0) /* No write access to folder */
114 #define SEQMOD (1<<1) /* folder's sequences modifed */
115 #define ALLOW_BEYOND (1<<2) /* allow the beyond sequence */
116 #define OTHERS (1<<3) /* folder has other files */
118 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_BEYOND\04OTHERS"
121 ** type for holding the sequence set of a message
123 typedef unsigned int seqset_t;
126 ** internal messages attributes (sequences)
128 #define EXISTS (1<<0) /* exists */
129 #define SELECTED (1<<1) /* selected for use */
130 #define SELECT_UNSEEN (1<<2) /* inc/show "unseen" */
132 #define MBITS "\020\01EXISTS\02SELECTED\03UNSEEN"
135 ** first free slot for user-defined sequences
140 ** Determine the number of user defined sequences we
141 ** can have. The first few sequence flags are for
142 ** internal nmh message flags.
144 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - FFATTRSLOT)
147 ** Primary structure of folder/message information
150 int lowmsg; /* Lowest msg number */
151 int hghmsg; /* Highest msg number */
152 int nummsg; /* Actual Number of msgs */
154 int lowsel; /* Lowest selected msg number */
155 int hghsel; /* Highest selected msg number */
156 int numsel; /* Number of msgs selected */
158 int curmsg; /* Number of current msg if any */
160 int msgflags; /* Folder attributes (READONLY, etc) */
161 char *foldpath; /* Pathname of folder */
164 ** Name of sequences in this folder. We add an
165 ** extra slot, so we can NULL terminate the list.
167 char *msgattrs[NUMATTRS + 1];
170 ** bit flags for whether sequence
171 ** is public (0), or private (1)
176 ** These represent the lowest and highest possible
177 ** message numbers we can put in the message status
178 ** area, without calling folder_realloc().
184 ** This is an array of seqset_t which we allocate dynamically.
185 ** Each seqset_t is a set of bits flags for a particular message.
186 ** These bit flags represent general attributes such as
187 ** EXISTS, SELECTED, etc. as well as track if message is
188 ** in a particular sequence.
190 seqset_t *msgstats; /* msg status */
194 ** Amount of space to allocate for msgstats. Allocate
195 ** the array to have space for messages numbers lo to hi.
197 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
199 #define NULLMP ((struct msgs *) 0)
202 ** m_getfld() message parsing
205 #define NAMESZ 999 /*
206 ** Limit on component name size.
207 ** RFC 2822 limits line lengths to
208 ** 998 characters, so a header name
209 ** can be at most that long.
210 ** m_getfld limits header names to 2
211 ** less than NAMESZ, which is fine,
212 ** because header names must be
213 ** followed by a colon. Add one for
217 #define LENERR (-2) /* Name too long error from getfld */
218 #define FMTERR (-3) /* Message Format error */
219 #define FLD 0 /* Field returned */
220 #define FLDPLUS 1 /* Field returned with more to come */
221 #define FLDEOF 2 /* Field returned ending at eom */
222 #define BODY 3 /* Body returned with more to come */
223 #define BODYEOF 4 /* Body returned ending at eom */
224 #define FILEEOF 5 /* Reached end of input file */
226 extern int msg_count; /* m_getfld() indicators (That's a hack!) */
228 #define NOUSE 0 /* draft being re-used */
230 #define OUTPUTLINELEN 72 /* default line length for headers */
233 ** miscellaneous macros
237 # define max(a,b) ((a) > (b) ? (a) : (b))
241 # define min(a,b) ((a) < (b) ? (a) : (b))
247 #define CTXMOD 0x01 /* context information modified */
248 #define DBITS "\020\01CTXMOD"
249 extern char ctxflags;
251 extern char *invo_name; /* command invocation name */
252 extern char *mypath; /* user's $HOME */
254 extern char *mmhpath;
255 extern char *defpath; /* pathname of user's profile */
256 extern char *ctxpath; /* pathname of user's context */
257 extern struct node *m_defs; /* list of profile/context entries */
258 extern char *mailstore; /* name of mail storage directory */
261 ** These standard strings are defined in config.c. They are the
262 ** only system-dependent parameters in nmh, and thus by redefining
263 ** their values and reloading the various modules, nmh will run
266 extern char *attach_hdr;
267 extern char *sign_hdr;
268 extern char *enc_hdr;
269 extern char *components;
270 extern char *context;
271 extern char *curfolder;
272 extern char *defaulteditor;
273 extern char *defaultpager;
274 extern char *defaultfolder;
275 extern char *digestcomps;
276 extern char *distcomps;
277 extern char *draftfolder;
278 extern char *foldprot;
279 extern char *forwcomps;
281 extern char *listproc;
282 extern char *mhetcdir;
283 extern char *mailspool;
285 extern char *mhlformat;
286 extern char *mhlreply;
287 extern char *mimetypequery;
288 extern char *mimetypequeryproc;
289 extern char *msgprot;
290 extern char *nmhstorage;
291 extern char *nsequence;
292 extern char *profile;
293 extern char *psequence;
294 extern char *rcvdistcomps;
295 extern char *replcomps;
296 extern char *replgroupcomps;
297 extern char *sendmail;
298 extern char *seq_all;
299 extern char *seq_beyond;
300 extern char *seq_cur;
301 extern char *seq_first;
302 extern char *seq_last;
303 extern char *seq_next;
304 extern char *seq_prev;
305 extern char *seq_unseen;
306 extern char *seq_neg;
307 extern char *trashfolder;
308 extern char *usequence;
309 extern char *version_num;
310 extern char *version_str;
311 extern char *whatnowproc;
313 #include <h/prototypes.h>