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