calls to nonexistant fonts (from gbergman@cartan)
[unix-history] / usr / src / usr.bin / mail / def.h
CommitLineData
761330fe
DF
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 *
cd7ccbb7 6 * @(#)def.h 5.2 (Berkeley) %G%
761330fe 7 */
43101bb9 8
46053c99 9#include <sys/param.h> /* includes <sys/types.h> */
43101bb9
KS
10#include <signal.h>
11#include <stdio.h>
7400d084 12#include <sgtty.h>
1c265896 13#include "local.h"
43101bb9
KS
14
15#undef isalpha
16#undef isdigit
17
43101bb9
KS
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 */
7e9e94c1
S
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 */
43101bb9 43#define HDRFIELDS 3 /* Number of header fields */
74f7ed29 44#define LINESIZE BUFSIZ /* max readable line width */
43101bb9 45#define STRINGSIZE ((unsigned) 128)/* Dynamic allocation units */
7e9e94c1 46#define MAXARGC 1024 /* Maximum list of raw strings */
43101bb9
KS
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
51struct 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 */
ee0b03d5 55 long m_size; /* Bytes in the message */
43101bb9
KS
56 short m_lines; /* Lines in the message */
57};
58
59/*
60 * flag bits.
61 */
62
8a23b6e3
KS
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 */
43101bb9
KS
74
75/*
76 * Format of the command description table.
77 * The actual table is declared and initialized
78 * in lex.c
79 */
80
81struct 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 */
7798c88e 106#define M 0200 /* Legal from send mode bit */
6fff2fd5 107#define W 0400 /* Illegal when read only bit */
726904d6 108#define F 01000 /* Is a conditional command */
6c0822ea 109#define T 02000 /* Is a transparent command */
a642148b 110#define R 04000 /* Cannot be called from collect */
43101bb9
KS
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
124struct 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
146struct header {
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
160struct 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
173struct 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
179struct group {
180 struct group *ge_link; /* Next person in this group */
181 char *ge_name; /* This person's user name */
182};
183
184struct 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
b6264a3d
KS
196/*
197 * Structure of the hash table of ignored header fields
198 */
199struct ignore {
200 struct ignore *i_link; /* Next ignored field in bucket */
201 char *i_field; /* This ignored field */
202};
203
43101bb9
KS
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. */
7e9e94c1 222#define STRINGLEN 1024 /* Maximum length of string token */
43101bb9 223
6c0822ea
KS
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
43101bb9
KS
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
ee0b03d5
CS
248#ifndef SIGRETRO
249#define sigchild()
250#endif
43101bb9 251
4bc721c3
SL
252/*
253 * 4.2bsd signal interface help...
254 */
255#ifdef VMUNIX
256#define sigset(s, a) signal(s, a)
4bc721c3
SL
257#define sigsys(s, a) signal(s, a)
258#endif
259
28bcd25d
SL
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
43101bb9
KS
267/*
268 * Forward declarations of routine types to keep lint and cc happy.
269 */
270
271FILE *Fdopen();
272FILE *collect();
273FILE *infix();
274FILE *mesedit();
275FILE *mespipe();
0dfdcc73 276FILE *popen();
43101bb9
KS
277FILE *setinput();
278char **unpack();
279char *addto();
280char *arpafix();
281char *calloc();
282char *copy();
283char *copyin();
284char *detract();
285char *expand();
286char *gets();
287char *hfield();
288char *index();
d1cc2242 289char *name1();
43101bb9
KS
290char *nameof();
291char *nextword();
292char *getenv();
6fff2fd5 293char *getfilename();
43101bb9
KS
294char *hcontents();
295char *netmap();
296char *netname();
297char *readtty();
5959bcea 298char *reedit();
43101bb9
KS
299char *rename();
300char *revarpa();
301char *rindex();
302char *rpair();
303char *salloc();
304char *savestr();
d1cc2242 305char *skin();
43101bb9 306char *snarf();
69a9c675
CL
307char *strcat();
308char *strcpy();
43101bb9
KS
309char *value();
310char *vcopy();
311char *yankword();
312off_t fsize();
4bc721c3 313#ifndef VMUNIX
91a7b595 314int (*sigset())();
4bc721c3 315#endif
43101bb9
KS
316struct cmd *lex();
317struct grouphead *findgroup();
318struct name *cat();
319struct name *delname();
320struct name *elide();
321struct name *extract();
322struct name *gexpand();
323struct name *map();
324struct name *outof();
325struct name *put();
326struct name *usermap();
327struct name *verify();
328struct var *lookup();
ee0b03d5 329long transmit();
69a9c675
CL
330int icequal();
331int cmpdomain();