Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / h / mh.h
1 /* mh.h - main header file for all of MH */
2 /* @(#)$Id: mh.h,v 2.19 1993/02/26 21:53:29 jromine Exp $ */
3
4
5 /* Well-used constants */
6
7 #define NOTOK           (-1)    /* syscall()s return this on error */
8 #define OK              0       /*  ditto on success */
9 #define DONE            1       /* trinary logic */
10 #define ALL             ""
11 #define NULLCP          ((char *) 0)
12 #define NULLVP          ((char **) 0)
13 #define Nbby            8       /* number of bits/byte */
14
15 #define MAXARGS         1000    /* max arguments to exec */
16
17 #define NFOLDERS         300    /* max folder arguments on command line */
18
19 #ifndef UCI
20 #define MAXFOLDER       1000    /* message increment */
21 #else
22 #define MAXFOLDER       1500    /* message increment */
23 #endif
24 #define DMAXFOLDER         4    /* typical number of digits */
25
26 #if (!defined(BSD42) && !defined(BSD41A) && !defined(VMUNIX) && !defined(hpux)) || defined(_AIX)
27 #define vfork           fork
28 #endif  /* not BSD */           /* how sad... */
29
30 /* \f */
31
32 /* profile structure */
33
34 struct node {
35     char   *n_name;             /* key */
36     char   *n_field;            /* value */
37
38     char    n_context;          /* context, not profile */
39
40     struct node *n_next;        /* next entry */
41 };
42
43
44 /* switches structure */
45
46 #define AMBIGSW         (-2)    /* from smatch() on ambiguous switch */
47 #define UNKWNSW         (-1)    /*  ditto on unknown switch */
48
49 struct swit {
50     char   *sw;
51     int     minchars;
52 };
53
54 extern struct swit  anoyes[];   /* standard yes/no switches */
55
56
57 /* messages structure */
58
59 struct msgs {
60     int     hghmsg;             /* Highest msg in directory     */
61     int     nummsg;             /* Actual Number of msgs        */
62     int     lowmsg;             /* Lowest msg number            */
63     int     curmsg;             /* Number of current msg if any */
64
65     int     lowsel;             /* Lowest selected msg number   */
66     int     hghsel;             /* Highest selected msg number  */
67     int     numsel;             /* Number of msgs selected      */
68
69     char   *foldpath;           /* Pathname of folder           */
70
71     int     msgflags;           /* Folder status bits           */
72 #ifndef MTR
73     char    pad1[sizeof (int) - sizeof (char)];
74 #endif /* not MTR */
75 #define READONLY  0x01          /*     No write access to folder */
76 #define SEQMOD    0x02          /*     folder's sequences modifed */
77 #define MHPATH    0x04          /*     mhpath-style folder handling */
78 #define OTHERS    0x08          /*     folder has other files   */
79 #define MODIFIED  0x10          /*     msh in-core folder modified */
80 #define FBITS   "\020\01READONLY\02SEQMOD\03MHPATH\04OTHERS\05MODIFIED"
81
82 /* Note well: msgstats[] is a int, so we have 16 or 32 bits to work
83         with.  The first 5 are for standard MH message flags,
84         this leaves us 11 (or 27) for user-defined attributes.  Of
85         these, 1 is reserved for future internal use, so this leaves
86         users 10 (or 26).                                       */
87 #define NATTRS  ((sizeof(int)*Nbby)-6)          /*  see above   */
88     char   *msgattrs[NATTRS + 1];/* folder attributes           */
89     int     attrstats;          /* public=0/private=1           */
90
91     int     lowoff;             /* low element in msgstats[] */
92     int     hghoff;             /* hgh element in msgstats[] */
93
94 #ifndef MTR
95     int     msgstats[1];        /* msg status                   */
96 #else /* MTR */
97     int    *msgbase;            /* msg base                     */
98     int    *msgstats;           /* msg status                   */
99 #endif /* MTR */
100 #define EXISTS          0x0001  /*     exists                   */
101 #define DELETED         0x0002  /*     deleted                  */
102 #define SELECTED        0x0004  /*     selected for use         */
103 #define SELECT_EMPTY    0x0008  /*     mhpath "new"             */
104 #define UNSEEN          0x0010  /*     inc/show "unseen"        */
105 #define FFATTRSLOT      5       /*     user-defined attributes  */
106                                 /*      first free slot is      */
107                                 /*      (1 << 5) or 0x20        */
108 #define MBITS   "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN"
109
110 #ifndef MTR
111 #define MHSIZE(mp,lo,hi)        \
112                 ((unsigned) (sizeof *mp + ((hi) + 2) * sizeof *mp -> msgstats))
113 #else /* MTR */
114 #define MHSIZE(mp,lo,hi)        ((unsigned) sizeof *mp)
115 #define MHSIZEX(mp,lo,hi)       \
116                 ((unsigned) (((hi) - (lo) + 1) * sizeof *mp -> msgstats))
117 #endif /* MTR */
118 };
119
120 #define NULLMP  ((struct msgs *) 0)
121
122 /* \f */
123
124 /* m_getfld() message parsing */
125
126 #define NAMESZ  128             /* Limit on component name size         */
127
128 #define LENERR  (-2)            /* Name too long error from getfld      */
129 #define FMTERR  (-3)            /* Message Format error                 */
130 #define FLD      0              /* Field returned                       */
131 #define FLDPLUS  1              /* Field " with more to come            */
132 #define FLDEOF   2              /* Field " ending at eom                */
133 #define BODY     3              /* Body  " with more to come            */
134 #define BODYEOF  4              /* Body  " ending at eom                */
135 #define FILEEOF  5              /* Reached end of input file            */
136
137
138 /* Maildrop styles */
139
140 #define MS_DEFAULT      0       /* default (one msg per file) */
141 #define MS_UNKNOWN      1       /* type not known yet */
142 #define MS_UUCP         2       /* Unix-style "from" lines */
143 #define MS_MMDF         3       /* string mmdlm2 */
144 #define MS_MSH          4       /* whacko msh */
145
146 extern int msg_count;           /* m_getfld() indicators */
147 extern int msg_style;           /*  .. */
148 extern char *msg_delim;         /*  .. */
149
150
151 #define NOUSE   0               /* draft being re-used */
152
153 #define TFOLDER 0               /* path() given a +folder */
154 #define TFILE   1               /* path() given a file */
155 #define TSUBCWF 2               /* path() given a @folder */
156
157 #ifndef LINK
158 #define LINK    "@"
159 #endif /* not LINK */
160
161 #ifndef SBACKUP
162 #define SBACKUP ","
163 #endif /* not SBACKUP */
164
165
166 #define OUTPUTLINELEN   72      /* default line length for headers */
167
168 /* \f */
169
170 /*
171  * These standard strings are defined in config.c.  They are the
172  * only system-dependent parameters in MH, and thus by redefining
173  * their values and reloading the various modules, MH will run
174  * on any system.
175  */
176
177 extern char *components;
178 extern char *context;
179 extern char *current;
180 extern char *defalt;
181 extern char *digestcomps;
182 extern char *distcomps;
183 extern char *draft;
184 extern char *faceproc;
185 extern char *fileproc;
186 extern char *foldprot;
187 extern char *forwcomps;
188 extern char *inbox;
189 extern char *incproc;
190 extern char *installproc;
191 extern char *lproc;
192 extern char *mailproc;
193 extern char *mh_defaults;
194 extern char *mh_profile;
195 extern char *mh_seq;
196 extern char *mhlformat;
197 extern char *mhlforward;
198 extern char *mhlproc;
199 extern char *moreproc;
200 extern char *msgprot;
201 extern char *mshproc;
202 extern char *nsequence;
203 extern char *packproc;
204 extern char *postproc;
205 extern char *pfolder;
206 extern char *psequence;
207 extern char *rcvdistcomps;
208 extern char *replcomps;
209 extern char *rmfproc;
210 extern char *rmmproc;
211 extern char *sendproc;
212 extern char *showproc;
213 extern char *slocalproc;
214 extern char *sysed;
215 extern char *usequence;
216 extern char *version;
217 extern char *vmhproc;
218 extern char *whatnowproc;
219 extern char *whomproc;
220
221 /* \f */
222
223 /* global variables -sigh- */
224
225 extern char ctxflags;
226 #define CTXMOD  0x01            /* context information modified */
227 #define DBITS   "\020\01CTXMOD"
228
229 #ifdef  OVERHEAD
230 extern int  fd_def;
231 extern int  fd_ctx;
232 #endif /* OVERHEAD */
233
234 extern char *invo_name;         /* pgm invocation name */
235 extern char *mypath;            /* user's $HOME */
236 extern char *defpath;           /* pathname of user's profile */
237 extern char *ctxpath;           /* pathname of user's context */
238
239 extern struct node *m_defs;
240
241 /* \f */
242
243 /* from the MH subroutine library */
244
245 char   *add ();
246 void    adios ();
247 void    admonish ();
248 void    advise ();
249 void    advertise ();
250 void    ambigsw ();
251 int     atooi ();
252 char  **brkstring ();
253 void    closefds ();
254 char   *concat ();
255 char   *copy ();
256 char  **copyip ();
257 void    cpydata ();
258 void    cpydgst ();
259 void    discard ();
260 void    done ();
261 int     fdcompare ();
262 int     gans ();
263 char  **getans ();
264 int     getanswer ();
265 char   *getcpy ();
266 void    help ();
267 char   *libpath ();
268 int     m_atoi ();
269 char   *m_backup ();
270 int     m_convert ();
271 int     m_delete ();
272 char   *m_draft ();
273 void    m_eomsbr ();
274 int     m_file ();
275 char   *m_find ();
276 void    m_fmsg ();
277 void    m_foil ();
278 void    m_getdefs ();
279 int     m_getfld ();
280 char   *m_getfolder ();
281 int     m_gmprot ();
282 struct msgs *m_gmsg ();
283 char   *m_maildir ();
284 char   *m_mailpath ();
285 char   *m_name ();
286 int     m_putenv ();
287 void    m_readefs ();
288 struct msgs *m_remsg ();
289 void    m_replace ();
290 char   *m_scratch ();
291 char   *m_seq ();
292 int     m_seqadd ();
293 char   *m_seqbits ();
294 int     m_seqdel ();
295 int     m_seqflag ();
296 int     m_seqnew ();
297 void    m_setcur ();
298 void    m_setseq ();
299 void    m_setvis ();
300 void    m_sync ();
301 char   *m_tmpfil ();
302 void    m_unknown ();
303 void    m_update ();
304 int     m_whatnow ();
305 int     makedir ();
306 char   *path ();
307 int     peekc ();
308 int     pidwait ();
309 #define pidXwait(id,cp) pidstatus (pidwait (id, NOTOK), stdout, cp)
310 int     pidstatus ();
311 void    printsw ();
312 void    push ();
313 char   *pwd ();
314 char   *r1bindex ();
315 int     refile ();
316 int     remdir ();
317 int     showfile ();
318 int     smatch ();
319 char   *sprintb();
320 int     ssequal ();
321 int     stringdex ();
322 char   *trimcpy ();
323 int     type ();
324 int     uleq ();
325 int     unputenv ();
326 int     uprf ();
327 int     vfgets ();
328
329 /* \f */
330
331 #include "../h/strings.h"
332
333 /* should be in <stdio.h> */
334
335 #if     !defined(SYS5) && !defined(ncr) && !defined(_AIX) && !defined(OSF1) && !defined(__convex__) && !defined(__386BSD__) && !defined(BSD44)
336 typedef struct _iobuf  *FP;
337 FP   popen ();
338 #else /* SYS5 */
339 #define FP      FILE*
340 #endif /* SYS5 */
341
342
343 /* miscellaneous */
344
345 #if !defined(BSD42) && !defined(hpux) && !defined(ncr) && !defined(_AIX) && !defined(RENAME)
346 #define rename(f1,f2)   (link (f1, f2) != NOTOK ? unlink (f1) : NOTOK)
347 #endif  /* not BSD42 */
348
349 #define setsig(s,f)     if (signal (s, SIG_IGN) != SIG_IGN) \
350                             (void) signal (s, f)
351 #define setsigx(i,s,f)  if ((i = signal (s, SIG_IGN)) != SIG_IGN) \
352                             (void) signal (s, f)
353
354 #if     defined(sun) && !defined(NFS)
355 #define NFS
356 #endif
357
358 #ifdef  NFS
359 #define ruserpass       _ruserpass
360 #endif
361
362 #if (defined(BSD44) || defined(SUN40) || defined(hpux) \
363         || defined(_AIX) || defined (sgi)) && !defined(UNISTD)
364 #define       UNISTD
365 #endif