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