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