Commit | Line | Data |
---|---|---|
46053c99 | 1 | /* def.h 2.15 85/04/18 */ |
43101bb9 | 2 | |
46053c99 | 3 | #include <sys/param.h> /* includes <sys/types.h> */ |
43101bb9 KS |
4 | #include <signal.h> |
5 | #include <stdio.h> | |
7400d084 | 6 | #include <sgtty.h> |
1c265896 | 7 | #include "local.h" |
43101bb9 KS |
8 | |
9 | #undef isalpha | |
10 | #undef isdigit | |
11 | ||
43101bb9 KS |
12 | /* |
13 | * Mail -- a mail program | |
14 | * | |
15 | * Commands are: | |
16 | * t <message list> print out these messages | |
17 | * r <message list> reply to messages | |
18 | * m <user list> mail to users (analogous to send) | |
19 | * e <message list> edit messages | |
20 | * c [directory] chdir to dir or home if none | |
21 | * x exit quickly | |
22 | * w <message list> file save messages in file | |
23 | * q quit, save remaining stuff in mbox | |
24 | * d <message list> delete messages | |
25 | * u <message list> undelete messages | |
26 | * h print message headers | |
27 | * | |
28 | * Author: Kurt Shoens (UCB) March 25, 1978 | |
29 | */ | |
30 | ||
31 | ||
32 | #define ESCAPE '~' /* Default escape for sending */ | |
33 | #define NMLSIZE 20 /* max names in a message list */ | |
e255f09d | 34 | #define PATHSIZE 100 /* Size of pathnames throughout */ |
43101bb9 KS |
35 | #define NAMESIZE 20 /* Max size of user name */ |
36 | #define HSHSIZE 19 /* Hash size for aliases and vars */ | |
37 | #define HDRFIELDS 3 /* Number of header fields */ | |
74f7ed29 | 38 | #define LINESIZE BUFSIZ /* max readable line width */ |
43101bb9 KS |
39 | #define STRINGSIZE ((unsigned) 128)/* Dynamic allocation units */ |
40 | #define MAXARGC 20 /* Maximum list of raw strings */ | |
41 | #define NOSTR ((char *) 0) /* Null string pointer */ | |
42 | #define MAXEXP 25 /* Maximum expansion of aliases */ | |
43 | #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ | |
44 | ||
45 | struct message { | |
46 | short m_flag; /* flags, see below */ | |
47 | short m_block; /* block number of this message */ | |
48 | short m_offset; /* offset in block of message */ | |
ee0b03d5 | 49 | long m_size; /* Bytes in the message */ |
43101bb9 KS |
50 | short m_lines; /* Lines in the message */ |
51 | }; | |
52 | ||
53 | /* | |
54 | * flag bits. | |
55 | */ | |
56 | ||
8a23b6e3 KS |
57 | #define MUSED (1<<0) /* entry is used, but this bit isn't */ |
58 | #define MDELETED (1<<1) /* entry has been deleted */ | |
59 | #define MSAVED (1<<2) /* entry has been saved */ | |
60 | #define MTOUCH (1<<3) /* entry has been noticed */ | |
61 | #define MPRESERVE (1<<4) /* keep entry in sys mailbox */ | |
62 | #define MMARK (1<<5) /* message is marked! */ | |
63 | #define MODIFY (1<<6) /* message has been modified */ | |
64 | #define MNEW (1<<7) /* message has never been seen */ | |
65 | #define MREAD (1<<8) /* message has been read sometime. */ | |
66 | #define MSTATUS (1<<9) /* message status has changed */ | |
67 | #define MBOX (1<<10) /* Send this to mbox, regardless */ | |
43101bb9 KS |
68 | |
69 | /* | |
70 | * Format of the command description table. | |
71 | * The actual table is declared and initialized | |
72 | * in lex.c | |
73 | */ | |
74 | ||
75 | struct cmd { | |
76 | char *c_name; /* Name of command */ | |
77 | int (*c_func)(); /* Implementor of the command */ | |
78 | short c_argtype; /* Type of arglist (see below) */ | |
79 | short c_msgflag; /* Required flags of messages */ | |
80 | short c_msgmask; /* Relevant flags of messages */ | |
81 | }; | |
82 | ||
83 | /* Yechh, can't initialize unions */ | |
84 | ||
85 | #define c_minargs c_msgflag /* Minimum argcount for RAWLIST */ | |
86 | #define c_maxargs c_msgmask /* Max argcount for RAWLIST */ | |
87 | ||
88 | /* | |
89 | * Argument types. | |
90 | */ | |
91 | ||
92 | #define MSGLIST 0 /* Message list type */ | |
93 | #define STRLIST 1 /* A pure string */ | |
94 | #define RAWLIST 2 /* Shell string list */ | |
95 | #define NOLIST 3 /* Just plain 0 */ | |
96 | #define NDMLIST 4 /* Message list, no defaults */ | |
97 | ||
98 | #define P 040 /* Autoprint dot after command */ | |
99 | #define I 0100 /* Interactive command bit */ | |
7798c88e | 100 | #define M 0200 /* Legal from send mode bit */ |
6fff2fd5 | 101 | #define W 0400 /* Illegal when read only bit */ |
726904d6 | 102 | #define F 01000 /* Is a conditional command */ |
6c0822ea | 103 | #define T 02000 /* Is a transparent command */ |
a642148b | 104 | #define R 04000 /* Cannot be called from collect */ |
43101bb9 KS |
105 | |
106 | /* | |
107 | * Oft-used mask values | |
108 | */ | |
109 | ||
110 | #define MMNORM (MDELETED|MSAVED)/* Look at both save and delete bits */ | |
111 | #define MMNDEL MDELETED /* Look only at deleted bit */ | |
112 | ||
113 | /* | |
114 | * Structure used to return a break down of a head | |
115 | * line (hats off to Bill Joy!) | |
116 | */ | |
117 | ||
118 | struct headline { | |
119 | char *l_from; /* The name of the sender */ | |
120 | char *l_tty; /* His tty string (if any) */ | |
121 | char *l_date; /* The entire date string */ | |
122 | }; | |
123 | ||
124 | #define GTO 1 /* Grab To: line */ | |
125 | #define GSUBJECT 2 /* Likewise, Subject: line */ | |
126 | #define GCC 4 /* And the Cc: line */ | |
127 | #define GBCC 8 /* And also the Bcc: line */ | |
128 | #define GMASK (GTO|GSUBJECT|GCC|GBCC) | |
129 | /* Mask of places from whence */ | |
130 | ||
131 | #define GNL 16 /* Print blank line after */ | |
132 | #define GDEL 32 /* Entity removed from list */ | |
133 | #define GCOMMA 64 /* detract puts in commas */ | |
134 | ||
135 | /* | |
136 | * Structure used to pass about the current | |
137 | * state of the user-typed message header. | |
138 | */ | |
139 | ||
140 | struct header { | |
141 | char *h_to; /* Dynamic "To:" string */ | |
142 | char *h_subject; /* Subject string */ | |
143 | char *h_cc; /* Carbon copies string */ | |
144 | char *h_bcc; /* Blind carbon copies */ | |
145 | int h_seq; /* Sequence for optimization */ | |
146 | }; | |
147 | ||
148 | /* | |
149 | * Structure of namelist nodes used in processing | |
150 | * the recipients of mail and aliases and all that | |
151 | * kind of stuff. | |
152 | */ | |
153 | ||
154 | struct name { | |
155 | struct name *n_flink; /* Forward link in list. */ | |
156 | struct name *n_blink; /* Backward list link */ | |
157 | short n_type; /* From which list it came */ | |
158 | char *n_name; /* This fella's name */ | |
159 | }; | |
160 | ||
161 | /* | |
162 | * Structure of a variable node. All variables are | |
163 | * kept on a singly-linked list of these, rooted by | |
164 | * "variables" | |
165 | */ | |
166 | ||
167 | struct var { | |
168 | struct var *v_link; /* Forward link to next variable */ | |
169 | char *v_name; /* The variable's name */ | |
170 | char *v_value; /* And it's current value */ | |
171 | }; | |
172 | ||
173 | struct group { | |
174 | struct group *ge_link; /* Next person in this group */ | |
175 | char *ge_name; /* This person's user name */ | |
176 | }; | |
177 | ||
178 | struct grouphead { | |
179 | struct grouphead *g_link; /* Next grouphead in list */ | |
180 | char *g_name; /* Name of this group */ | |
181 | struct group *g_list; /* Users in group. */ | |
182 | }; | |
183 | ||
184 | #define NIL ((struct name *) 0) /* The nil pointer for namelists */ | |
185 | #define NONE ((struct cmd *) 0) /* The nil pointer to command tab */ | |
186 | #define NOVAR ((struct var *) 0) /* The nil pointer to variables */ | |
187 | #define NOGRP ((struct grouphead *) 0)/* The nil grouphead pointer */ | |
188 | #define NOGE ((struct group *) 0) /* The nil group pointer */ | |
189 | ||
b6264a3d KS |
190 | /* |
191 | * Structure of the hash table of ignored header fields | |
192 | */ | |
193 | struct ignore { | |
194 | struct ignore *i_link; /* Next ignored field in bucket */ | |
195 | char *i_field; /* This ignored field */ | |
196 | }; | |
197 | ||
43101bb9 KS |
198 | /* |
199 | * Token values returned by the scanner used for argument lists. | |
200 | * Also, sizes of scanner-related things. | |
201 | */ | |
202 | ||
203 | #define TEOL 0 /* End of the command line */ | |
204 | #define TNUMBER 1 /* A message number */ | |
205 | #define TDASH 2 /* A simple dash */ | |
206 | #define TSTRING 3 /* A string (possibly containing -) */ | |
207 | #define TDOT 4 /* A "." */ | |
208 | #define TUP 5 /* An "^" */ | |
209 | #define TDOLLAR 6 /* A "$" */ | |
210 | #define TSTAR 7 /* A "*" */ | |
211 | #define TOPEN 8 /* An '(' */ | |
212 | #define TCLOSE 9 /* A ')' */ | |
213 | #define TPLUS 10 /* A '+' */ | |
214 | ||
215 | #define REGDEP 2 /* Maximum regret depth. */ | |
2d5b401e | 216 | #define STRINGLEN 64 /* Maximum length of string token */ |
43101bb9 | 217 | |
6c0822ea KS |
218 | /* |
219 | * Constants for conditional commands. These describe whether | |
220 | * we should be executing stuff or not. | |
221 | */ | |
222 | ||
223 | #define CANY 0 /* Execute in send or receive mode */ | |
224 | #define CRCV 1 /* Execute in receive mode only */ | |
225 | #define CSEND 2 /* Execute in send mode only */ | |
226 | ||
43101bb9 KS |
227 | /* |
228 | * Kludges to handle the change from setexit / reset to setjmp / longjmp | |
229 | */ | |
230 | ||
231 | #define setexit() setjmp(srbuf) | |
232 | #define reset(x) longjmp(srbuf, x) | |
233 | ||
234 | /* | |
235 | * VM/UNIX has a vfork system call which is faster than forking. If we | |
236 | * don't have it, fork(2) will do . . . | |
237 | */ | |
238 | ||
239 | #ifndef VMUNIX | |
240 | #define vfork() fork() | |
241 | #endif | |
ee0b03d5 CS |
242 | #ifndef SIGRETRO |
243 | #define sigchild() | |
244 | #endif | |
43101bb9 | 245 | |
4bc721c3 SL |
246 | /* |
247 | * 4.2bsd signal interface help... | |
248 | */ | |
249 | #ifdef VMUNIX | |
250 | #define sigset(s, a) signal(s, a) | |
4bc721c3 SL |
251 | #define sigsys(s, a) signal(s, a) |
252 | #endif | |
253 | ||
28bcd25d SL |
254 | /* |
255 | * Truncate a file to the last character written. This is | |
256 | * useful just before closing an old file that was opened | |
257 | * for read/write. | |
258 | */ | |
259 | #define trunc(stream) ftruncate(fileno(stream), (long) ftell(stream)) | |
260 | ||
43101bb9 KS |
261 | /* |
262 | * Forward declarations of routine types to keep lint and cc happy. | |
263 | */ | |
264 | ||
265 | FILE *Fdopen(); | |
266 | FILE *collect(); | |
267 | FILE *infix(); | |
268 | FILE *mesedit(); | |
269 | FILE *mespipe(); | |
0dfdcc73 | 270 | FILE *popen(); |
43101bb9 KS |
271 | FILE *setinput(); |
272 | char **unpack(); | |
273 | char *addto(); | |
274 | char *arpafix(); | |
275 | char *calloc(); | |
276 | char *copy(); | |
277 | char *copyin(); | |
278 | char *detract(); | |
279 | char *expand(); | |
280 | char *gets(); | |
281 | char *hfield(); | |
282 | char *index(); | |
d1cc2242 | 283 | char *name1(); |
43101bb9 KS |
284 | char *nameof(); |
285 | char *nextword(); | |
286 | char *getenv(); | |
6fff2fd5 | 287 | char *getfilename(); |
43101bb9 KS |
288 | char *hcontents(); |
289 | char *netmap(); | |
290 | char *netname(); | |
291 | char *readtty(); | |
5959bcea | 292 | char *reedit(); |
43101bb9 KS |
293 | char *rename(); |
294 | char *revarpa(); | |
295 | char *rindex(); | |
296 | char *rpair(); | |
297 | char *salloc(); | |
298 | char *savestr(); | |
d1cc2242 | 299 | char *skin(); |
43101bb9 | 300 | char *snarf(); |
69a9c675 CL |
301 | char *strcat(); |
302 | char *strcpy(); | |
43101bb9 KS |
303 | char *value(); |
304 | char *vcopy(); | |
305 | char *yankword(); | |
306 | off_t fsize(); | |
4bc721c3 | 307 | #ifndef VMUNIX |
91a7b595 | 308 | int (*sigset())(); |
4bc721c3 | 309 | #endif |
43101bb9 KS |
310 | struct cmd *lex(); |
311 | struct grouphead *findgroup(); | |
312 | struct name *cat(); | |
313 | struct name *delname(); | |
314 | struct name *elide(); | |
315 | struct name *extract(); | |
316 | struct name *gexpand(); | |
317 | struct name *map(); | |
318 | struct name *outof(); | |
319 | struct name *put(); | |
320 | struct name *usermap(); | |
321 | struct name *verify(); | |
322 | struct var *lookup(); | |
ee0b03d5 | 323 | long transmit(); |
69a9c675 CL |
324 | int icequal(); |
325 | int cmpdomain(); |