2 ** mh.h -- main header file for all of nmh
13 ** Well-used constants
15 #define NOTOK (-1) /* syscall()s return this on error */
16 #define OK 0 /* ditto on success */
17 #define DONE 1 /* trinary logic */
19 #define Nbby 8 /* number of bits/byte */
21 #define MAXARGS 1000 /* max arguments to exec */
22 #define NFOLDERS 1000 /* max folder arguments on command line */
23 #define DMAXFOLDER 4 /* typical number of digits */
24 #define MAXFOLDER 1000 /* message increment */
32 typedef unsigned char boolean; /* not int so we can pack in a structure */
34 /* If we're using gcc then give it some information about
35 ** functions that abort.
38 # define NORETURN __attribute__((__noreturn__))
44 ** we should be getting this value from pathconf(_PC_PATH_MAX)
48 # define PATH_MAX MAXPATHLEN
50 /* so we will just pick something */
51 # define PATH_MAX 1024
56 ** we should be getting this value from sysconf(_SC_OPEN_MAX)
60 # define OPEN_MAX NOFILE
62 /* so we will just pick something */
68 ** user context/profile structure
71 char *n_name; /* key */
72 char *n_field; /* value */
73 char n_context; /* context, not profile */
74 struct node *n_next; /* next entry */
80 #define AMBIGSW (-2) /* from smatch() on ambiguous switch */
81 #define UNKWNSW (-1) /* from smatch() on unknown switch */
86 ** The minchars field is apparently used like this:
88 ** -# : Switch can be abbreviated to # chars; switch hidden in -help.
89 ** 0 : Switch can't be abbreviated; switch shown in -help.
90 ** # : Switch can be abbreviated to # chars; switch shown in -help.
95 extern struct swit anoyes[]; /* standard yes/no switches */
98 ** general folder attributes
100 #define READONLY (1<<0) /* No write access to folder */
101 #define SEQMOD (1<<1) /* folder's sequences modifed */
102 #define ALLOW_BEYOND (1<<2) /* allow the beyond sequence */
103 #define OTHERS (1<<3) /* folder has other files */
105 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_BEYOND\04OTHERS"
108 ** type for holding the sequence set of a message
110 typedef unsigned int seqset_t;
113 ** internal messages attributes (sequences)
115 #define EXISTS (1<<0) /* exists */
116 #define SELECTED (1<<1) /* selected for use */
117 #define SELECT_UNSEEN (1<<2) /* inc/show "unseen" */
119 #define MBITS "\020\01EXISTS\02SELECTED\03UNSEEN"
122 ** first free slot for user-defined sequences
127 ** Determine the number of user defined sequences we
128 ** can have. The first few sequence flags are for
129 ** internal nmh message flags.
131 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - FFATTRSLOT)
134 ** Primary structure of folder/message information
137 int lowmsg; /* Lowest msg number */
138 int hghmsg; /* Highest msg number */
139 int nummsg; /* Actual Number of msgs */
141 int lowsel; /* Lowest selected msg number */
142 int hghsel; /* Highest selected msg number */
143 int numsel; /* Number of msgs selected */
145 int curmsg; /* Number of current msg if any */
147 int msgflags; /* Folder attributes (READONLY, etc) */
148 char *foldpath; /* Pathname of folder */
151 ** Name of sequences in this folder. We add an
152 ** extra slot, so we can NULL terminate the list.
154 char *msgattrs[NUMATTRS + 1];
157 ** bit flags for whether sequence
158 ** is public (0), or private (1)
163 ** These represent the lowest and highest possible
164 ** message numbers we can put in the message status
165 ** area, without calling folder_realloc().
171 ** This is an array of seqset_t which we allocate dynamically.
172 ** Each seqset_t is a set of bits flags for a particular message.
173 ** These bit flags represent general attributes such as
174 ** EXISTS, SELECTED, etc. as well as track if message is
175 ** in a particular sequence.
177 seqset_t *msgstats; /* msg status */
181 ** Amount of space to allocate for msgstats. Allocate
182 ** the array to have space for messages numbers lo to hi.
184 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
186 #define NULLMP ((struct msgs *) 0)
189 ** m_getfld() message parsing
192 #define NAMESZ 999 /*
193 ** Limit on component name size.
194 ** RFC 2822 limits line lengths to
195 ** 998 characters, so a header name
196 ** can be at most that long.
197 ** m_getfld limits header names to 2
198 ** less than NAMESZ, which is fine,
199 ** because header names must be
200 ** followed by a colon. Add one for
204 #define LENERR (-2) /* Name too long error from getfld */
205 #define FMTERR (-3) /* Message Format error */
206 #define FLD 0 /* Field returned */
207 #define FLDPLUS 1 /* Field returned with more to come */
208 #define FLDEOF 2 /* Field returned ending at eom */
209 #define BODY 3 /* Body returned with more to come */
210 #define BODYEOF 4 /* Body returned ending at eom */
211 #define FILEEOF 5 /* Reached end of input file */
213 extern int msg_count; /* m_getfld() indicators (That's a hack!) */
215 #define NOUSE 0 /* draft being re-used */
217 #define OUTPUTLINELEN 72 /* default line length for headers */
220 ** miscellaneous macros
224 # define max(a,b) ((a) > (b) ? (a) : (b))
228 # define min(a,b) ((a) < (b) ? (a) : (b))
234 #define CTXMOD 0x01 /* context information modified */
235 #define DBITS "\020\01CTXMOD"
236 extern char ctxflags;
238 extern char *invo_name; /* command invocation name */
239 extern char *mypath; /* user's $HOME */
241 extern char *mmhpath;
242 extern char *defpath; /* pathname of user's profile */
243 extern char *ctxpath; /* pathname of user's context */
244 extern struct node *m_defs; /* list of profile/context entries */
245 extern char *mailstore; /* name of mail storage directory */
248 ** These standard strings are defined in config.c. They are the
249 ** only system-dependent parameters in nmh, and thus by redefining
250 ** their values and reloading the various modules, nmh will run
253 extern char *attach_hdr;
254 extern char *sign_hdr;
255 extern char *enc_hdr;
256 extern char *components;
257 extern char *context;
258 extern char *curfolder;
259 extern char *defaulteditor;
260 extern char *defaultpager;
261 extern char *defaultfolder;
262 extern char *digestcomps;
263 extern char *distcomps;
264 extern char *draftfolder;
265 extern char *foldprot;
266 extern char *forwcomps;
268 extern char *listproc;
269 extern char *mhetcdir;
270 extern char *mailspool;
272 extern char *mhlformat;
273 extern char *mhlreply;
274 extern char *mimetypequery;
275 extern char *mimetypequeryproc;
276 extern char *msgprot;
277 extern char *nmhstorage;
278 extern char *nsequence;
279 extern char *profile;
280 extern char *psequence;
281 extern char *rcvdistcomps;
282 extern char *replcomps;
283 extern char *replgroupcomps;
284 extern char *sendmail;
285 extern char *seq_all;
286 extern char *seq_beyond;
287 extern char *seq_cur;
288 extern char *seq_first;
289 extern char *seq_last;
290 extern char *seq_next;
291 extern char *seq_prev;
292 extern char *seq_unseen;
293 extern char *seq_neg;
294 extern char *trashfolder;
295 extern char *usequence;
296 extern char *version_num;
297 extern char *version_str;
298 extern char *whatnowproc;
300 #include <h/prototypes.h>