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