remove call of _fwalk
[unix-history] / usr / src / usr.bin / mail / def.h
CommitLineData
761330fe
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
0c5f72fb 3 * All rights reserved.
761330fe 4 *
f15db449 5 * %sccs.include.redist.c%
0c5f72fb 6 *
07b0d286 7 * @(#)def.h 5.22 (Berkeley) %G%
761330fe 8 */
43101bb9 9
46053c99 10#include <sys/param.h> /* includes <sys/types.h> */
828615a1 11#include <sys/signal.h>
43101bb9 12#include <stdio.h>
7400d084 13#include <sgtty.h>
828615a1 14#include <ctype.h>
38dde0cd 15#include <string.h>
435e8dff 16#include "pathnames.h"
43101bb9 17
43101bb9
KS
18/*
19 * Mail -- a mail program
20 *
43101bb9
KS
21 * Author: Kurt Shoens (UCB) March 25, 1978
22 */
23
435e8dff 24#define APPEND /* New mail goes to end of mailbox */
43101bb9
KS
25
26#define ESCAPE '~' /* Default escape for sending */
7e9e94c1 27#define NMLSIZE 1024 /* max names in a message list */
f674e088 28#define PATHSIZE MAXPATHLEN /* Size of pathnames throughout */
7e9e94c1 29#define HSHSIZE 59 /* Hash size for aliases and vars */
74f7ed29 30#define LINESIZE BUFSIZ /* max readable line width */
43101bb9 31#define STRINGSIZE ((unsigned) 128)/* Dynamic allocation units */
7e9e94c1 32#define MAXARGC 1024 /* Maximum list of raw strings */
43101bb9
KS
33#define NOSTR ((char *) 0) /* Null string pointer */
34#define MAXEXP 25 /* Maximum expansion of aliases */
828615a1 35
43101bb9
KS
36#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
37
38struct message {
39 short m_flag; /* flags, see below */
40 short m_block; /* block number of this message */
41 short m_offset; /* offset in block of message */
ee0b03d5 42 long m_size; /* Bytes in the message */
43101bb9
KS
43 short m_lines; /* Lines in the message */
44};
45
46/*
47 * flag bits.
48 */
49
8a23b6e3
KS
50#define MUSED (1<<0) /* entry is used, but this bit isn't */
51#define MDELETED (1<<1) /* entry has been deleted */
52#define MSAVED (1<<2) /* entry has been saved */
53#define MTOUCH (1<<3) /* entry has been noticed */
54#define MPRESERVE (1<<4) /* keep entry in sys mailbox */
55#define MMARK (1<<5) /* message is marked! */
56#define MODIFY (1<<6) /* message has been modified */
57#define MNEW (1<<7) /* message has never been seen */
58#define MREAD (1<<8) /* message has been read sometime. */
59#define MSTATUS (1<<9) /* message status has changed */
60#define MBOX (1<<10) /* Send this to mbox, regardless */
43101bb9 61
828615a1
EW
62/*
63 * Given a file address, determine the block number it represents.
64 */
65#define blockof(off) ((int) ((off) / 4096))
66#define offsetof(off) ((int) ((off) % 4096))
67#define positionof(block, offset) ((off_t)(block) * 4096 + (offset))
68
43101bb9
KS
69/*
70 * Format of the command description table.
71 * The actual table is declared and initialized
72 * in lex.c
73 */
74
75struct cmd {
76 char *c_name; /* Name of command */
77 int (*c_func)(); /* Implementor of the command */
78 short c_argtype; /* Type of arglist (see below) */
79 short c_msgflag; /* Required flags of messages */
80 short c_msgmask; /* Relevant flags of messages */
81};
82
83/* Yechh, can't initialize unions */
84
85#define c_minargs c_msgflag /* Minimum argcount for RAWLIST */
86#define c_maxargs c_msgmask /* Max argcount for RAWLIST */
87
88/*
89 * Argument types.
90 */
91
92#define MSGLIST 0 /* Message list type */
93#define STRLIST 1 /* A pure string */
94#define RAWLIST 2 /* Shell string list */
95#define NOLIST 3 /* Just plain 0 */
96#define NDMLIST 4 /* Message list, no defaults */
97
98#define P 040 /* Autoprint dot after command */
99#define I 0100 /* Interactive command bit */
7798c88e 100#define M 0200 /* Legal from send mode bit */
6fff2fd5 101#define W 0400 /* Illegal when read only bit */
726904d6 102#define F 01000 /* Is a conditional command */
6c0822ea 103#define T 02000 /* Is a transparent command */
a642148b 104#define R 04000 /* Cannot be called from collect */
43101bb9
KS
105
106/*
107 * Oft-used mask values
108 */
109
110#define MMNORM (MDELETED|MSAVED)/* Look at both save and delete bits */
111#define MMNDEL MDELETED /* Look only at deleted bit */
112
113/*
114 * Structure used to return a break down of a head
115 * line (hats off to Bill Joy!)
116 */
117
118struct headline {
119 char *l_from; /* The name of the sender */
120 char *l_tty; /* His tty string (if any) */
121 char *l_date; /* The entire date string */
122};
123
124#define GTO 1 /* Grab To: line */
125#define GSUBJECT 2 /* Likewise, Subject: line */
126#define GCC 4 /* And the Cc: line */
127#define GBCC 8 /* And also the Bcc: line */
128#define GMASK (GTO|GSUBJECT|GCC|GBCC)
129 /* Mask of places from whence */
130
131#define GNL 16 /* Print blank line after */
132#define GDEL 32 /* Entity removed from list */
133#define GCOMMA 64 /* detract puts in commas */
134
135/*
136 * Structure used to pass about the current
137 * state of the user-typed message header.
138 */
139
140struct header {
3d6f01e5
EW
141 struct name *h_to; /* Dynamic "To:" string */
142 char *h_subject; /* Subject string */
143 struct name *h_cc; /* Carbon copies string */
144 struct name *h_bcc; /* Blind carbon copies */
145 struct name *h_smopts; /* Sendmail options */
43101bb9
KS
146};
147
148/*
149 * Structure of namelist nodes used in processing
150 * the recipients of mail and aliases and all that
151 * kind of stuff.
152 */
153
154struct name {
155 struct name *n_flink; /* Forward link in list. */
156 struct name *n_blink; /* Backward list link */
157 short n_type; /* From which list it came */
158 char *n_name; /* This fella's name */
159};
160
161/*
162 * Structure of a variable node. All variables are
163 * kept on a singly-linked list of these, rooted by
164 * "variables"
165 */
166
167struct var {
168 struct var *v_link; /* Forward link to next variable */
169 char *v_name; /* The variable's name */
170 char *v_value; /* And it's current value */
171};
172
173struct group {
174 struct group *ge_link; /* Next person in this group */
175 char *ge_name; /* This person's user name */
176};
177
178struct grouphead {
179 struct grouphead *g_link; /* Next grouphead in list */
180 char *g_name; /* Name of this group */
181 struct group *g_list; /* Users in group. */
182};
183
184#define NIL ((struct name *) 0) /* The nil pointer for namelists */
185#define NONE ((struct cmd *) 0) /* The nil pointer to command tab */
186#define NOVAR ((struct var *) 0) /* The nil pointer to variables */
187#define NOGRP ((struct grouphead *) 0)/* The nil grouphead pointer */
188#define NOGE ((struct group *) 0) /* The nil group pointer */
189
b6264a3d
KS
190/*
191 * Structure of the hash table of ignored header fields
192 */
887efe38
EW
193struct ignoretab {
194 int i_count; /* Number of entries */
195 struct ignore {
196 struct ignore *i_link; /* Next ignored field in bucket */
197 char *i_field; /* This ignored field */
198 } *i_head[HSHSIZE];
b6264a3d
KS
199};
200
43101bb9
KS
201/*
202 * Token values returned by the scanner used for argument lists.
203 * Also, sizes of scanner-related things.
204 */
205
206#define TEOL 0 /* End of the command line */
207#define TNUMBER 1 /* A message number */
208#define TDASH 2 /* A simple dash */
209#define TSTRING 3 /* A string (possibly containing -) */
210#define TDOT 4 /* A "." */
211#define TUP 5 /* An "^" */
212#define TDOLLAR 6 /* A "$" */
213#define TSTAR 7 /* A "*" */
214#define TOPEN 8 /* An '(' */
215#define TCLOSE 9 /* A ')' */
216#define TPLUS 10 /* A '+' */
a8a981d5 217#define TERROR 11 /* A lexical error */
43101bb9
KS
218
219#define REGDEP 2 /* Maximum regret depth. */
7e9e94c1 220#define STRINGLEN 1024 /* Maximum length of string token */
43101bb9 221
6c0822ea
KS
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
43101bb9
KS
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
28bcd25d
SL
238/*
239 * Truncate a file to the last character written. This is
240 * useful just before closing an old file that was opened
241 * for read/write.
242 */
243#define trunc(stream) ftruncate(fileno(stream), (long) ftell(stream))
244
43101bb9
KS
245/*
246 * Forward declarations of routine types to keep lint and cc happy.
247 */
248
07b0d286 249FILE *Fopen();
43101bb9 250FILE *Fdopen();
d96977db 251FILE *Popen();
43101bb9
KS
252FILE *collect();
253FILE *infix();
d33aa50d 254FILE *run_editor();
43101bb9
KS
255FILE *setinput();
256char **unpack();
43101bb9
KS
257char *calloc();
258char *copy();
259char *copyin();
260char *detract();
261char *expand();
62e28b79 262char *getdeadletter();
43101bb9
KS
263char *gets();
264char *hfield();
d1cc2242 265char *name1();
43101bb9
KS
266char *nameof();
267char *nextword();
268char *getenv();
f674e088 269char *getname();
d33aa50d 270char *fgets();
828615a1
EW
271char *ishfield();
272char *malloc();
d33aa50d 273char *mktemp();
43101bb9 274char *readtty();
5959bcea 275char *reedit();
43101bb9
KS
276char *salloc();
277char *savestr();
d1cc2242 278char *skin();
43101bb9 279char *snarf();
f674e088 280char *username();
43101bb9
KS
281char *value();
282char *vcopy();
283char *yankword();
284off_t fsize();
d33aa50d 285uid_t getuid();
43101bb9
KS
286struct cmd *lex();
287struct grouphead *findgroup();
3d6f01e5 288struct name *nalloc();
43101bb9
KS
289struct name *cat();
290struct name *delname();
291struct name *elide();
292struct name *extract();
293struct name *gexpand();
43101bb9
KS
294struct name *outof();
295struct name *put();
296struct name *usermap();
43101bb9 297struct var *lookup();