* uip/sendsbr.c: replaced st_mtim with st_mtime, that's what
[mmh] / h / mh.h
1
2 /*
3  * mh.h -- main header file for all of nmh
4  *
5  * $Id$
6  */
7
8 #include <h/nmh.h>
9
10 /*
11  * Well-used constants
12  */
13 #define NOTOK        (-1)       /* syscall()s return this on error */
14 #define OK             0        /*  ditto on success               */
15 #define DONE           1        /* trinary logic                   */
16 #define ALL           ""
17 #define Nbby           8        /* number of bits/byte */
18
19 #define MAXARGS     1000        /* max arguments to exec                */
20 #define NFOLDERS    1000        /* max folder arguments on command line */
21 #define DMAXFOLDER     4        /* typical number of digits             */
22 #define MAXFOLDER   1000        /* message increment                    */
23
24 #ifndef FALSE
25 #define FALSE 0
26 #endif
27 #ifndef TRUE
28 #define TRUE 1
29 #endif
30 typedef unsigned char  boolean;  /* not int so we can pack in a structure */
31
32 /*
33  * user context/profile structure
34  */
35 struct node {
36     char *n_name;               /* key                  */
37     char *n_field;              /* value                */
38     char  n_context;            /* context, not profile */
39     struct node *n_next;        /* next entry           */
40 };
41
42 /*
43  * switches structure
44  */
45 #define AMBIGSW  (-2)   /* from smatch() on ambiguous switch */
46 #define UNKWNSW  (-1)   /* from smatch() on unknown switch   */
47
48 struct swit {
49     char *sw;
50
51     /* The minchars field is apparently used like this:
52
53        -# : Switch can be abbreviated to # characters; switch hidden in -help.
54        0  : Switch can't be abbreviated;               switch shown in -help.
55        #  : Switch can be abbreviated to # characters; switch shown in -help. */
56     int minchars;
57 };
58
59 extern struct swit anoyes[];    /* standard yes/no switches */
60
61 #define ATTACHFORMATS 3         /* Number of send attach formats. */
62
63 /*
64  * general folder attributes
65  */
66 #define READONLY   (1<<0)       /* No write access to folder    */
67 #define SEQMOD     (1<<1)       /* folder's sequences modifed   */
68 #define ALLOW_NEW  (1<<2)       /* allow the "new" sequence     */
69 #define OTHERS     (1<<3)       /* folder has other files       */
70 #define MODIFIED   (1<<4)       /* msh in-core folder modified  */
71
72 #define FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS\05MODIFIED"
73
74 /*
75  * type for holding the sequence set of a message
76  */
77 typedef unsigned int seqset_t;
78
79 /*
80  * Determine the number of user defined sequences we
81  * can have.  The first 5 sequence flags are for
82  * internal nmh message flags.
83  */
84 #define NUMATTRS  ((sizeof(seqset_t) * Nbby) - 5)
85
86 /*
87  * first free slot for user defined sequences
88  * and attributes
89  */
90 #define FFATTRSLOT  5
91
92 /*
93  * internal messages attributes (sequences)
94  */
95 #define EXISTS        (1<<0)    /* exists            */
96 #define DELETED       (1<<1)    /* deleted           */
97 #define SELECTED      (1<<2)    /* selected for use  */
98 #define SELECT_EMPTY  (1<<3)    /* "new" message     */
99 #define SELECT_UNSEEN (1<<4)    /* inc/show "unseen" */
100
101 #define MBITS "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN"
102
103 /*
104  * Primary structure of folder/message information
105  */
106 struct msgs {
107     int lowmsg;         /* Lowest msg number                 */
108     int hghmsg;         /* Highest msg number                */
109     int nummsg;         /* Actual Number of msgs             */
110
111     int lowsel;         /* Lowest selected msg number        */
112     int hghsel;         /* Highest selected msg number       */
113     int numsel;         /* Number of msgs selected           */
114
115     int curmsg;         /* Number of current msg if any      */
116
117     int msgflags;       /* Folder attributes (READONLY, etc) */
118     char *foldpath;     /* Pathname of folder                */
119
120     /*
121      * Name of sequences in this folder.  We add an
122      * extra slot, so we can NULL terminate the list.
123      */
124     char *msgattrs[NUMATTRS + 1];
125
126     /*
127      * bit flags for whether sequence
128      * is public (0), or private (1)
129      */
130     seqset_t attrstats;
131
132     /*
133      * These represent the lowest and highest possible
134      * message numbers we can put in the message status
135      * area, without calling folder_realloc().
136      */
137     int lowoff;
138     int hghoff;
139
140     /*
141      * This is an array of seqset_t which we allocate dynamically.
142      * Each seqset_t is a set of bits flags for a particular message.
143      * These bit flags represent general attributes such as
144      * EXISTS, SELECTED, etc. as well as track if message is
145      * in a particular sequence.
146      */
147     seqset_t *msgstats;         /* msg status */
148 };
149
150 /*
151  * Amount of space to allocate for msgstats.  Allocate
152  * the array to have space for messages numbers lo to hi.
153  */
154 #define MSGSTATSIZE(mp,lo,hi) ((size_t) (((hi) - (lo) + 1) * sizeof(*(mp)->msgstats)))
155
156 /*
157  * macros for message and sequence manipulation
158  */
159 #define clear_msg_flags(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] = 0)
160 #define copy_msg_flags(mp,i,j) \
161         ((mp)->msgstats[(i) - mp->lowoff] = (mp)->msgstats[(j) - mp->lowoff])
162 #define get_msg_flags(mp,ptr,msgnum)  (*(ptr) = (mp)->msgstats[(msgnum) - mp->lowoff])
163 #define set_msg_flags(mp,ptr,msgnum)  ((mp)->msgstats[(msgnum) - mp->lowoff] = *(ptr))
164
165 #define does_exist(mp,msgnum)     ((mp)->msgstats[(msgnum) - mp->lowoff] & EXISTS)
166 #define unset_exists(mp,msgnum)   ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~EXISTS)
167 #define set_exists(mp,msgnum)     ((mp)->msgstats[(msgnum) - mp->lowoff] |= EXISTS)
168
169 #define is_selected(mp,msgnum)    ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECTED)
170 #define unset_selected(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECTED)
171 #define set_selected(mp,msgnum)   ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECTED)
172
173 #define is_select_empty(mp,msgnum) ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_EMPTY)
174 #define set_select_empty(mp,msgnum) \
175         ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_EMPTY)
176
177 #define is_unseen(mp,msgnum)      ((mp)->msgstats[(msgnum) - mp->lowoff] & SELECT_UNSEEN)
178 #define unset_unseen(mp,msgnum)   ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~SELECT_UNSEEN)
179 #define set_unseen(mp,msgnum)     ((mp)->msgstats[(msgnum) - mp->lowoff] |= SELECT_UNSEEN)
180
181 /* for msh only */
182 #define set_deleted(mp,msgnum)    ((mp)->msgstats[(msgnum) - mp->lowoff] |= DELETED)
183
184 #define in_sequence(mp,seqnum,msgnum) \
185            ((mp)->msgstats[(msgnum) - mp->lowoff] & (1 << (FFATTRSLOT + seqnum)))
186 #define clear_sequence(mp,seqnum,msgnum) \
187            ((mp)->msgstats[(msgnum) - mp->lowoff] &= ~(1 << (FFATTRSLOT + seqnum)))
188 #define add_sequence(mp,seqnum,msgnum) \
189            ((mp)->msgstats[(msgnum) - mp->lowoff] |= (1 << (FFATTRSLOT + seqnum)))
190
191 #define is_seq_private(mp,seqnum) \
192            ((mp)->attrstats & (1 << (FFATTRSLOT + seqnum)))
193 #define make_seq_public(mp,seqnum) \
194            ((mp)->attrstats &= ~(1 << (FFATTRSLOT + seqnum)))
195 #define make_seq_private(mp,seqnum) \
196            ((mp)->attrstats |= (1 << (FFATTRSLOT + seqnum)))
197 #define make_all_public(mp) \
198            ((mp)->attrstats = 0)
199
200 /*
201  * macros for folder attributes
202  */
203 #define clear_folder_flags(mp) ((mp)->msgflags = 0)
204
205 #define is_readonly(mp)     ((mp)->msgflags & READONLY)
206 #define set_readonly(mp)    ((mp)->msgflags |= READONLY)
207
208 #define other_files(mp)     ((mp)->msgflags & OTHERS)
209 #define set_other_files(mp) ((mp)->msgflags |= OTHERS)
210
211 #define NULLMP  ((struct msgs *) 0)
212
213 /*
214  * m_getfld() message parsing
215  */
216
217 #define NAMESZ  128             /* Limit on component name size     */
218
219 #define LENERR  (-2)            /* Name too long error from getfld  */
220 #define FMTERR  (-3)            /* Message Format error             */
221 #define FLD      0              /* Field returned                   */
222 #define FLDPLUS  1              /* Field returned with more to come */
223 #define FLDEOF   2              /* Field returned ending at eom     */
224 #define BODY     3              /* Body  returned with more to come */
225 #define BODYEOF  4              /* Body  returned ending at eom     */
226 #define FILEEOF  5              /* Reached end of input file        */
227
228 /*
229  * Maildrop styles
230  */
231 #define MS_DEFAULT      0       /* default (one msg per file) */
232 #define MS_UNKNOWN      1       /* type not known yet         */
233 #define MS_MBOX         2       /* Unix-style "from" lines    */
234 #define MS_MMDF         3       /* string mmdlm2              */
235 #define MS_MSH          4       /* whacko msh                 */
236
237 extern int msg_count;           /* m_getfld() indicators */
238 extern int msg_style;           /*  .. */
239 extern char *msg_delim;         /*  .. */
240
241 #define NOUSE   0               /* draft being re-used */
242
243 #define TFOLDER 0               /* path() given a +folder */
244 #define TFILE   1               /* path() given a file    */
245 #define TSUBCWF 2               /* path() given a @folder */
246
247 #define OUTPUTLINELEN   72      /* default line length for headers */
248
249 /*
250  * miscellaneous macros
251  */
252 #define pidXwait(pid,cp) pidstatus (pidwait (pid, NOTOK), stdout, cp)
253
254 #ifndef max
255 # define max(a,b) ((a) > (b) ? (a) : (b))
256 #endif
257
258 #ifndef min
259 # define min(a,b) ((a) < (b) ? (a) : (b))
260 #endif
261
262 #ifndef abs
263 # define abs(a) ((a) > 0 ? (a) : -(a))
264 #endif
265
266 /*
267  * GLOBAL VARIABLES
268  */
269 #define CTXMOD  0x01            /* context information modified */
270 #define DBITS   "\020\01CTXMOD"
271 extern char ctxflags;
272
273 extern char *invo_name;         /* command invocation name         */
274 extern char *mypath;            /* user's $HOME                    */
275 extern char *defpath;           /* pathname of user's profile      */
276 extern char *ctxpath;           /* pathname of user's context      */
277 extern struct node *m_defs;     /* list of profile/context entries */
278
279 /*
280  * These standard strings are defined in config.c.  They are the
281  * only system-dependent parameters in nmh, and thus by redefining
282  * their values and reloading the various modules, nmh will run
283  * on any system.
284  */
285 extern char *buildmimeproc;
286 extern char *catproc;
287 extern char *components;
288 extern char *context;
289 extern char *current;
290 extern char *defaulteditor;
291 extern char *defaultfolder;
292 extern char *digestcomps;
293 extern char *distcomps;
294 extern char *draft;
295 extern char *faceproc;
296 extern char *fileproc;
297 extern char *foldprot;
298 extern char *forwcomps;
299 extern char *inbox;
300 extern char *incproc;
301 extern char *installproc;
302 extern char *lproc;
303 extern char *mailproc;
304 extern char *mh_defaults;
305 extern char *mh_profile;
306 extern char *mh_seq;
307 extern char *mhlformat;
308 extern char *mhlforward;
309 extern char *mhlproc;
310 extern char *mhlreply;
311 extern char *moreproc;
312 extern char *msgprot;
313 extern char *mshproc;
314 extern char *nmhaccessftp;
315 extern char *nmhstorage;
316 extern char *nmhcache;
317 extern char *nmhprivcache;
318 extern char *nsequence;
319 extern char *packproc;
320 extern char *postproc;
321 extern char *pfolder;
322 extern char *psequence;
323 extern char *rcvdistcomps;
324 extern char *rcvstoreproc;
325 extern char *replcomps;
326 extern char *replgroupcomps;
327 extern char *rmfproc;
328 extern char *rmmproc;
329 extern char *sendproc;
330 extern char *showmimeproc;
331 extern char *showproc;
332 extern char *usequence;
333 extern char *version_num;
334 extern char *version_str;
335 extern char *vmhproc;
336 extern char *whatnowproc;
337 extern char *whomproc;
338
339 #include <h/prototypes.h>
340