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