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__))
46 ** we should be getting this value from pathconf(_PC_PATH_MAX)
50 # define PATH_MAX MAXPATHLEN
52 /* so we will just pick something */
53 # define PATH_MAX 1024
58 ** we should be getting this value from sysconf(_SC_OPEN_MAX)
62 # define OPEN_MAX NOFILE
64 /* so we will just pick something */
70 ** user context/profile structure
73 char *n_name; /* key */
74 char *n_field; /* value */
75 char n_context; /* context, not profile */
76 struct node *n_next; /* next entry */
82 #define AMBIGSW (-2) /* from smatch() on ambiguous switch */
83 #define UNKWNSW (-1) /* from smatch() on unknown switch */
88 ** The minchars field is apparently used like this:
90 ** -# : Switch can be abbreviated to # chars; switch hidden in -help.
91 ** 0 : Switch can't be abbreviated; switch shown in -help.
92 ** # : Switch can be abbreviated to # chars; switch shown in -help.
97 extern struct swit anoyes[]; /* standard yes/no switches */
100 ** general folder attributes
102 #define READONLY (1<<0) /* No write access to folder */
103 #define SEQMOD (1<<1) /* folder's sequences modifed */
104 #define ALLOW_BEYOND (1<<2) /* allow the beyond sequence */
105 #define OTHERS (1<<3) /* folder has other files */
107 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_BEYOND\04OTHERS"
110 ** type for holding the sequence set of a message
112 typedef unsigned int seqset_t;
115 ** internal messages attributes (sequences)
117 #define EXISTS (1<<0) /* exists */
118 #define SELECTED (1<<1) /* selected for use */
119 #define SELECT_UNSEEN (1<<2) /* inc/show "unseen" */
121 #define MBITS "\020\01EXISTS\02SELECTED\03UNSEEN"
124 ** first free slot for user-defined sequences
129 ** Determine the number of user defined sequences we
130 ** can have. The first few sequence flags are for
131 ** internal nmh message flags.
133 #define NUMATTRS ((sizeof(seqset_t) * Nbby) - FFATTRSLOT)
136 ** Primary structure of folder/message information
139 int lowmsg; /* Lowest msg number */
140 int hghmsg; /* Highest msg number */
141 int nummsg; /* Actual Number of msgs */
143 int lowsel; /* Lowest selected msg number */
144 int hghsel; /* Highest selected msg number */
145 int numsel; /* Number of msgs selected */
147 int curmsg; /* Number of current msg if any */
149 int msgflags; /* Folder attributes (READONLY, etc) */
150 char *foldpath; /* Pathname of folder */
153 ** Name of sequences in this folder. We add an
154 ** extra slot, so we can NULL terminate the list.
156 char *msgattrs[NUMATTRS + 1];
159 ** bit flags for whether sequence
160 ** is public (0), or private (1)
165 ** These represent the lowest and highest possible
166 ** message numbers we can put in the message status
167 ** area, without calling folder_realloc().
173 ** This is an array of seqset_t which we allocate dynamically.
174 ** Each seqset_t is a set of bits flags for a particular message.
175 ** These bit flags represent general attributes such as
176 ** EXISTS, SELECTED, etc. as well as track if message is
177 ** in a particular sequence.
179 seqset_t *msgstats; /* msg status */
183 ** Amount of space to allocate for msgstats. Allocate
184 ** the array to have space for messages numbers lo to hi.
186 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
188 #define NULLMP ((struct msgs *) 0)
191 ** m_getfld() message parsing
194 #define NAMESZ 999 /*
195 ** Limit on component name size.
196 ** RFC 2822 limits line lengths to
197 ** 998 characters, so a header name
198 ** can be at most that long.
199 ** m_getfld limits header names to 2
200 ** less than NAMESZ, which is fine,
201 ** because header names must be
202 ** followed by a colon. Add one for
206 /* m_getfld2() returned data */
215 /* m_getfld2() states */
217 LENERR2 = -2, /* Line too long */
218 FMTERR2 = -3, /* Format error in message */
219 IOERR2 = -1, /* Read error */
220 FLD2 = 0, /* Header field returned */
221 BODY2, /* Body line returned */
222 FILEEOF2, /* Reached end of input file */
225 #define NOUSE 0 /* draft being re-used */
227 #define OUTPUTLINELEN 72 /* default line length for headers */
230 ** miscellaneous macros
234 # define max(a,b) ((a) > (b) ? (a) : (b))
238 # define min(a,b) ((a) < (b) ? (a) : (b))
244 #define CTXMOD 0x01 /* context information modified */
245 #define DBITS "\020\01CTXMOD"
246 extern char ctxflags;
248 extern char *invo_name; /* command invocation name */
249 extern char *mypath; /* user's $HOME */
251 extern char *mmhpath;
252 extern char *defpath; /* pathname of user's profile */
253 extern char *ctxpath; /* pathname of user's context */
254 extern struct node *m_defs; /* list of profile/context entries */
255 extern char *mailstore; /* name of mail storage directory */
258 ** These standard strings are defined in config.c. They are the
259 ** only system-dependent parameters in nmh, and thus by redefining
260 ** their values and reloading the various modules, nmh will run
263 extern char *attach_hdr;
264 extern char *sign_hdr;
265 extern char *enc_hdr;
266 extern char *components;
267 extern char *context;
268 extern char *curfolder;
269 extern char *defaulteditor;
270 extern char *defaultpager;
271 extern char *defaultfolder;
272 extern char *digestcomps;
273 extern char *distcomps;
274 extern char *draftfolder;
275 extern char *foldprot;
276 extern char *forwcomps;
278 extern char *listproc;
279 extern char *mhetcdir;
280 extern char *mailspool;
282 extern char *mhlformat;
283 extern char *mhlreply;
284 extern char *mimetypequery;
285 extern char *mimetypequeryproc;
286 extern char *msgprot;
287 extern char *nmhstorage;
288 extern char *nsequence;
289 extern char *profile;
290 extern char *psequence;
291 extern char *rcvdistcomps;
292 extern char *replcomps;
293 extern char *replgroupcomps;
294 extern char *scanformat;
295 extern char *sendmail;
296 extern char *seq_all;
297 extern char *seq_beyond;
298 extern char *seq_cur;
299 extern char *seq_first;
300 extern char *seq_last;
301 extern char *seq_next;
302 extern char *seq_prev;
303 extern char *seq_unseen;
304 extern char *seq_neg;
305 extern char *trashfolder;
306 extern char *usequence;
307 extern char *version_num;
308 extern char *version_str;
309 extern char *whatnowproc;
311 #include <h/prototypes.h>