1: #
2:
3: #include <sys/types.h>
4: #include <signal.h>
5: #include <stdio.h>
6: #include <sgtty.h>
7: #include "local.h"
8:
9: #undef isalpha
10: #undef isdigit
11:
12: /*
13: * Sccs Id = "@(#)def.h 2.12 6/15/83";
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 */
38: #define PATHSIZE 100 /* Size of pathnames throughout */
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 */
42: #define LINESIZE BUFSIZ /* max readable line width */
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: long 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<<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 */
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 */
104: #define M 0200 /* Legal from send mode bit */
105: #define W 0400 /* Illegal when read only bit */
106: #define F 01000 /* Is a conditional command */
107: #define T 02000 /* Is a transparent command */
108: #define R 04000 /* Cannot be called from collect */
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 {
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: * Structure of the hash table of ignored header fields
196: */
197: struct ignore {
198: struct ignore *i_link; /* Next ignored field in bucket */
199: char *i_field; /* This ignored field */
200: };
201:
202: /*
203: * Token values returned by the scanner used for argument lists.
204: * Also, sizes of scanner-related things.
205: */
206:
207: #define TEOL 0 /* End of the command line */
208: #define TNUMBER 1 /* A message number */
209: #define TDASH 2 /* A simple dash */
210: #define TSTRING 3 /* A string (possibly containing -) */
211: #define TDOT 4 /* A "." */
212: #define TUP 5 /* An "^" */
213: #define TDOLLAR 6 /* A "$" */
214: #define TSTAR 7 /* A "*" */
215: #define TOPEN 8 /* An '(' */
216: #define TCLOSE 9 /* A ')' */
217: #define TPLUS 10 /* A '+' */
218:
219: #define REGDEP 2 /* Maximum regret depth. */
220: #define STRINGLEN 64 /* Maximum length of string token */
221:
222: /*
223: * Constants for conditional commands. These describe whether
224: * we should be executing stuff or not.
225: */
226:
227: #define CANY 0 /* Execute in send or receive mode */
228: #define CRCV 1 /* Execute in receive mode only */
229: #define CSEND 2 /* Execute in send mode only */
230:
231: /*
232: * Kludges to handle the change from setexit / reset to setjmp / longjmp
233: */
234:
235: #define setexit() setjmp(srbuf)
236: #define reset(x) longjmp(srbuf, x)
237:
238: /*
239: * VM/UNIX has a vfork system call which is faster than forking. If we
240: * don't have it, fork(2) will do . . .
241: */
242:
243: #ifndef VMUNIX
244: #define vfork() fork()
245: #endif
246: #ifndef SIGRETRO
247: #define sigchild()
248: #endif
249:
250: /*
251: * Forward declarations of routine types to keep lint and cc happy.
252: */
253:
254: FILE *Fdopen();
255: FILE *collect();
256: FILE *infix();
257: FILE *mesedit();
258: FILE *mespipe();
259: FILE *popen();
260: FILE *setinput();
261: char **unpack();
262: char *addto();
263: char *arpafix();
264: char *calloc();
265: char *copy();
266: char *copyin();
267: char *detract();
268: char *expand();
269: char *gets();
270: char *hfield();
271: char *index();
272: char *name1();
273: char *nameof();
274: char *nextword();
275: char *getenv();
276: char *getfilename();
277: char *hcontents();
278: char *netmap();
279: char *netname();
280: char *readtty();
281: char *reedit();
282: char *rename();
283: char *revarpa();
284: char *rindex();
285: char *rpair();
286: char *salloc();
287: char *savestr();
288: char *skin();
289: char *snarf();
290: char *strcat();
291: char *strcpy();
292: char *value();
293: char *vcopy();
294: char *yankword();
295: off_t fsize();
296: #ifdef VMUNIX
297: int (*sigset())();
298: #endif
299: struct cmd *lex();
300: struct grouphead *findgroup();
301: struct name *cat();
302: struct name *delname();
303: struct name *elide();
304: struct name *extract();
305: struct name *gexpand();
306: struct name *map();
307: struct name *outof();
308: struct name *put();
309: struct name *usermap();
310: struct name *verify();
311: struct var *lookup();
312: long transmit();
313: int icequal();
314: int cmpdomain();
Defined struct's
cmd
defined in line
79; used 16 times
group
defined in line
177; used 12 times
defined in line
144; used 24 times
message
defined in line
49; used 82 times
- in /usr/src/ucb/Mail/aux.c line
100(2),
190(2),
518(2),
611(2)
- in /usr/src/ucb/Mail/cmd1.c line
24(2),
180(2),
292(2),
358(2),
378(2)
- in /usr/src/ucb/Mail/cmd2.c line
23(2),
123(2),
189(2),
336(2),
376(2)
- in /usr/src/ucb/Mail/cmd3.c line
192(2),
300(2),
324(2),
669(2)
- in /usr/src/ucb/Mail/collect.c line
722-725(4)
- in /usr/src/ucb/Mail/edit.c line
60(2)
- in /usr/src/ucb/Mail/fio.c line
31(2),
209(2),
231(2),
240-242(4),
262(2),
295(2)
- in /usr/src/ucb/Mail/lex.c line
565(2)
- in /usr/src/ucb/Mail/list.c line
26(2),
80(2),
314(2),
514(2),
541(2),
562(2),
627(2)
- in /usr/src/ucb/Mail/quit.c line
24(2),
280(2)
- in /usr/src/ucb/Mail/send.c line
25-28(4),
153(2)
name
defined in line
158; used 126 times
- in line 159-160(4),
301-310(20)
- in /usr/src/ucb/Mail/cmd3.c line
195(2)
- in /usr/src/ucb/Mail/names.c line
19-25(6),
37-41(6),
57-62(4),
102-106(4),
176-180(6),
237-244(6),
418-423(8),
455-462(6),
507-509(4),
521-525(6),
544-547(4),
615-617(4),
632-637(8),
748-750(4),
765(2),
790-796(6),
823-826(4),
838-840(4)
- in /usr/src/ucb/Mail/send.c line
242(2),
417-421(6)
var
defined in line
171; used 18 times
Defined macros
CANY
defined in line
227; used 7 times
CRCV
defined in line
228; used 3 times
F
defined in line
106; used 5 times
GBCC
defined in line
131; used 6 times
GCC
defined in line
130; used 12 times
GDEL
defined in line
136; used 6 times
GNL
defined in line
135; used 6 times
GTO
defined in line
128; used 11 times
I
defined in line
103; used 11 times
M
defined in line
104; used 32 times
MBOX
defined in line
71; used 8 times
MDELETED
defined in line
62; used 27 times
- in line 114-115(2)
- in /usr/src/ucb/Mail/cmd1.c line
44
- in /usr/src/ucb/Mail/cmd2.c line
50,
77,
345,
351,
386
- in /usr/src/ucb/Mail/cmdtab.c line
36
- in /usr/src/ucb/Mail/fio.c line
313-315(2),
362
- in /usr/src/ucb/Mail/lex.c line
394,
586
- in /usr/src/ucb/Mail/list.c line
68(2),
110,
192,
211,
321,
517-518(2),
636,
646,
656
- in /usr/src/ucb/Mail/quit.c line
92,
119
MMARK
defined in line
66; used 5 times
MNEW
defined in line
68; used 19 times
MREAD
defined in line
69; used 14 times
MSAVED
defined in line
63; used 10 times
MUSED
defined in line
61; used 3 times
NIL
defined in line
188; used 58 times
- in /usr/src/ucb/Mail/names.c line
26-27(2),
44-46(3),
66-71(4),
86,
110,
116,
128-132(2),
188,
212-213(2),
220,
255,
362-363(2),
370,
427-431(3),
512,
527-529(2),
596,
619,
639-650(7),
665,
680,
704-709(3),
720,
753-754(2),
769,
798-808(7),
828,
843
- in /usr/src/ucb/Mail/send.c line
275,
297,
423
NOGE
defined in line
192; used 4 times
NOLIST
defined in line
99; used 11 times
NONE
defined in line
189; used 2 times
NOSTR
defined in line
45; used 212 times
- in /usr/src/ucb/Mail/aux.c line
28-29(2),
134,
198-209(4),
242,
311,
339-340(2),
401,
547-550(5),
620-622(2),
692,
743
- in /usr/src/ucb/Mail/cmd1.c line
140,
192,
199,
220,
255,
308,
362,
386,
397
- in /usr/src/ucb/Mail/cmd2.c line
132,
144,
153,
197-199(2),
218,
280
- in /usr/src/ucb/Mail/cmd3.c line
30,
64,
175,
204-217(5),
233(2),
239-241(3),
248-254(4),
264,
281-282(2),
344,
370-377(3),
410,
457-459(2),
483,
503,
543,
559,
621,
651-653(2),
676,
687,
696-702(4)
- in /usr/src/ucb/Mail/collect.c line
55,
94(2),
103,
119,
131-133(3),
268,
306,
459,
528,
682,
806,
854
- in /usr/src/ucb/Mail/edit.c line
24,
38
- in /usr/src/ucb/Mail/fio.c line
236,
304-306(2),
315-322(4),
517,
531,
566,
577
- in /usr/src/ucb/Mail/getname.c line
91
- in /usr/src/ucb/Mail/head.c line
30(2),
70-72(3),
88-92(2),
219-221(2),
237
- in /usr/src/ucb/Mail/lex.c line
149,
393,
456,
546
- in /usr/src/ucb/Mail/list.c line
188,
221,
251,
363,
578
- in /usr/src/ucb/Mail/lock.c line
36
- in /usr/src/ucb/Mail/main.c line
74,
227,
257,
276
- in /usr/src/ucb/Mail/names.c line
65-73(3),
111,
124,
163,
316,
430,
564-571(3),
580,
604
- in /usr/src/ucb/Mail/optim.c line
34,
157,
182-184(2),
203,
269,
297,
338,
345,
364-368(2),
460,
585,
638,
654,
749-751(2)
- in /usr/src/ucb/Mail/quit.c line
90-93(2),
108-110(2),
119-125(3),
152,
187,
209
- in /usr/src/ucb/Mail/send.c line
197-199(3),
220-225(4),
245,
257-259(2),
311,
323,
329,
387,
397,
495-501(4),
572
- in /usr/src/ucb/Mail/strings.c line
36,
44-48(2),
77
- in /usr/src/ucb/Mail/temp.c line
57
- in /usr/src/ucb/Mail/tty.c line
59-90(8),
124-129(2),
136,
170-179(3),
207
- in /usr/src/ucb/Mail/v7.local.c line
39,
56
P
defined in line
102; used 4 times
R
defined in line
108; used 7 times
T
defined in line
107; used 5 times
TDOT
defined in line
211; used 1 times
TEOL
defined in line
207; used 2 times
TUP
defined in line
212; used 1 times
W
defined in line
105; used 9 times
equal
defined in line
47; used 12 times
Usage of this include