inpcb: Use netisr_ncpus for listing inpcbs.
[dragonfly.git] / usr.bin / mail / def.h
blobf9958a1162e5457febc076aef355cd3b1061b04b
1 /*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * @(#)def.h 8.4 (Berkeley) 4/20/95
31 * $FreeBSD: src/usr.bin/mail/def.h,v 1.4.6.4 2003/01/06 05:46:03 mikeh Exp $
32 * $DragonFly: src/usr.bin/mail/def.h,v 1.3 2004/09/08 03:01:11 joerg Exp $
36 * Mail -- a mail program
38 * Author: Kurt Shoens (UCB) March 25, 1978
41 #include <sys/param.h>
42 #include <sys/stat.h>
44 #include <ctype.h>
45 #include <err.h>
46 #include <paths.h>
47 #include <signal.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <string.h>
51 #include <termios.h>
52 #include <time.h>
53 #include <unistd.h>
55 #include "pathnames.h"
57 #define APPEND /* New mail goes to end of mailbox */
59 #define ESCAPE '~' /* Default escape for sending */
60 #define NMLSIZE 1024 /* max names in a message list */
61 #define PATHSIZE MAXPATHLEN /* Size of pathnames throughout */
62 #define HSHSIZE 59 /* Hash size for aliases and vars */
63 #define LINESIZE BUFSIZ /* max readable line width */
64 #define STRINGSIZE ((unsigned)128) /* Dynamic allocation units */
65 #define MAXARGC 1024 /* Maximum list of raw strings */
66 #define MAXEXP 25 /* Maximum expansion of aliases */
68 #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
70 struct message {
71 short m_flag; /* flags, see below */
72 short m_offset; /* offset in block of message */
73 long m_block; /* block number of this message */
74 long m_size; /* Bytes in the message */
75 long m_lines; /* Lines in the message */
79 * flag bits.
82 #define MUSED (1<<0) /* entry is used, but this bit isn't */
83 #define MDELETED (1<<1) /* entry has been deleted */
84 #define MSAVED (1<<2) /* entry has been saved */
85 #define MTOUCH (1<<3) /* entry has been noticed */
86 #define MPRESERVE (1<<4) /* keep entry in sys mailbox */
87 #define MMARK (1<<5) /* message is marked! */
88 #define MODIFY (1<<6) /* message has been modified */
89 #define MNEW (1<<7) /* message has never been seen */
90 #define MREAD (1<<8) /* message has been read sometime. */
91 #define MSTATUS (1<<9) /* message status has changed */
92 #define MBOX (1<<10) /* Send this to mbox, regardless */
95 * Given a file address, determine the block number it represents.
97 #define blockof(off) ((int)((off) / 4096))
98 #define boffsetof(off) ((int)((off) % 4096))
99 #define positionof(block, offset) ((off_t)(block) * 4096 + (offset))
102 * Format of the command description table.
103 * The actual table is declared and initialized
104 * in lex.c
106 struct cmd {
107 const char *c_name; /* Name of command */
108 int (*c_func)(); /* Implementor of the command */
109 short c_argtype; /* Type of arglist (see below) */
110 short c_msgflag; /* Required flags of messages */
111 short c_msgmask; /* Relevant flags of messages */
114 /* Yechh, can't initialize unions */
116 #define c_minargs c_msgflag /* Minimum argcount for RAWLIST */
117 #define c_maxargs c_msgmask /* Max argcount for RAWLIST */
120 * Argument types.
123 #define MSGLIST 0 /* Message list type */
124 #define STRLIST 1 /* A pure string */
125 #define RAWLIST 2 /* Shell string list */
126 #define NOLIST 3 /* Just plain 0 */
127 #define NDMLIST 4 /* Message list, no defaults */
129 #define P 040 /* Autoprint dot after command */
130 #define I 0100 /* Interactive command bit */
131 #define M 0200 /* Legal from send mode bit */
132 #define W 0400 /* Illegal when read only bit */
133 #define F 01000 /* Is a conditional command */
134 #define T 02000 /* Is a transparent command */
135 #define R 04000 /* Cannot be called from collect */
138 * Oft-used mask values
141 #define MMNORM (MDELETED|MSAVED)/* Look at both save and delete bits */
142 #define MMNDEL MDELETED /* Look only at deleted bit */
145 * Structure used to return a break down of a head
146 * line (hats off to Bill Joy!)
149 struct headline {
150 char *l_from; /* The name of the sender */
151 char *l_tty; /* His tty string (if any) */
152 char *l_date; /* The entire date string */
155 #define GTO 1 /* Grab To: line */
156 #define GSUBJECT 2 /* Likewise, Subject: line */
157 #define GCC 4 /* And the Cc: line */
158 #define GBCC 8 /* And also the Bcc: line */
159 #define GREPLYTO 0x10 /* And the Reply-To: line */
160 #define GINREPLYTO 0x20 /* The In-Reply-To: line */
161 #define GMASK (GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO)
162 /* Mask of places from whence */
164 #define GNL 0x40 /* Print blank line after */
165 #define GDEL 0x80 /* Entity removed from list */
166 #define GCOMMA 0x100 /* detract puts in commas */
169 * Structure used to pass about the current
170 * state of the user-typed message header.
173 struct header {
174 struct name *h_bcc; /* Blind carbon copies */
175 struct name *h_cc; /* Carbon copies string */
176 struct name *h_smopts; /* Sendmail options */
177 struct name *h_to; /* Dynamic "To:" string */
178 char *h_inreplyto; /* Reference */
179 char *h_replyto; /* Reply address */
180 char *h_subject; /* Subject string */
184 * Structure of namelist nodes used in processing
185 * the recipients of mail and aliases and all that
186 * kind of stuff.
189 struct name {
190 struct name *n_flink; /* Forward link in list. */
191 struct name *n_blink; /* Backward list link */
192 short n_type; /* From which list it came */
193 char *n_name; /* This fella's name */
197 * Structure of a variable node. All variables are
198 * kept on a singly-linked list of these, rooted by
199 * "variables"
202 struct var {
203 struct var *v_link; /* Forward link to next variable */
204 char *v_name; /* The variable's name */
205 char *v_value; /* And it's current value */
208 struct group {
209 struct group *ge_link; /* Next person in this group */
210 char *ge_name; /* This person's user name */
213 struct grouphead {
214 struct grouphead *g_link; /* Next grouphead in list */
215 char *g_name; /* Name of this group */
216 struct group *g_list; /* Users in group. */
220 * Structure of the hash table of ignored header fields
222 struct ignoretab {
223 int i_count; /* Number of entries */
224 struct ignore {
225 struct ignore *i_link; /* Next ignored field in bucket */
226 char *i_field; /* This ignored field */
227 } *i_head[HSHSIZE];
231 * Token values returned by the scanner used for argument lists.
232 * Also, sizes of scanner-related things.
235 #define TEOL 0 /* End of the command line */
236 #define TNUMBER 1 /* A message number */
237 #define TDASH 2 /* A simple dash */
238 #define TSTRING 3 /* A string (possibly containing -) */
239 #define TDOT 4 /* A "." */
240 #define TUP 5 /* An "^" */
241 #define TDOLLAR 6 /* A "$" */
242 #define TSTAR 7 /* A "*" */
243 #define TOPEN 8 /* An '(' */
244 #define TCLOSE 9 /* A ')' */
245 #define TPLUS 10 /* A '+' */
246 #define TERROR 11 /* A lexical error */
248 #define REGDEP 2 /* Maximum regret depth. */
249 #define STRINGLEN 1024 /* Maximum length of string token */
252 * Constants for conditional commands. These describe whether
253 * we should be executing stuff or not.
256 #define CANY 0 /* Execute in send or receive mode */
257 #define CRCV 1 /* Execute in receive mode only */
258 #define CSEND 2 /* Execute in send mode only */
261 * Kludges to handle the change from setexit / reset to setjmp / longjmp
264 #define setexit() setjmp(srbuf)
265 #define reset(x) longjmp(srbuf, x)
268 * Truncate a file to the last character written. This is
269 * useful just before closing an old file that was opened
270 * for read/write.
272 #define trunc(stream) { \
273 fflush(stream); \
274 ftruncate(fileno(stream), (off_t)ftell(stream)); \