xref: /netbsd-src/usr.bin/mail/def.h (revision f0a7346d2148aa56c118f3e51cfffc26cebb09ce)
1*f0a7346dSsnj /*	$NetBSD: def.h,v 1.28 2014/10/18 08:33:30 snj Exp $	*/
261f28255Scgd /*
32cb5542fSderaadt  * Copyright (c) 1980, 1993
42cb5542fSderaadt  *	The Regents of the University of California.  All rights reserved.
561f28255Scgd  *
661f28255Scgd  * Redistribution and use in source and binary forms, with or without
761f28255Scgd  * modification, are permitted provided that the following conditions
861f28255Scgd  * are met:
961f28255Scgd  * 1. Redistributions of source code must retain the above copyright
1061f28255Scgd  *    notice, this list of conditions and the following disclaimer.
1161f28255Scgd  * 2. Redistributions in binary form must reproduce the above copyright
1261f28255Scgd  *    notice, this list of conditions and the following disclaimer in the
1361f28255Scgd  *    documentation and/or other materials provided with the distribution.
1489aaa1bbSagc  * 3. Neither the name of the University nor the names of its contributors
1561f28255Scgd  *    may be used to endorse or promote products derived from this software
1661f28255Scgd  *    without specific prior written permission.
1761f28255Scgd  *
1861f28255Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1961f28255Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2061f28255Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2161f28255Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2261f28255Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2361f28255Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2461f28255Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2561f28255Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2661f28255Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2761f28255Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2861f28255Scgd  * SUCH DAMAGE.
2961f28255Scgd  *
3019d35cbcStls  *	@(#)def.h	8.4 (Berkeley) 4/20/95
31*f0a7346dSsnj  *	$NetBSD: def.h,v 1.28 2014/10/18 08:33:30 snj Exp $
3261f28255Scgd  */
3361f28255Scgd 
3461f28255Scgd /*
3561f28255Scgd  * Mail -- a mail program
3661f28255Scgd  *
3761f28255Scgd  * Author: Kurt Shoens (UCB) March 25, 1978
3861f28255Scgd  */
3961f28255Scgd 
40798fbc60Schristos #ifndef __DEF_H__
41798fbc60Schristos #define __DEF_H__
42798fbc60Schristos 
437c81c8f3Slukem #include <sys/types.h>
447c81c8f3Slukem #include <sys/file.h>
457c81c8f3Slukem #include <sys/ioctl.h>
462cb5542fSderaadt #include <sys/stat.h>
477c81c8f3Slukem #include <sys/param.h>
482cb5542fSderaadt #include <sys/time.h>
497c81c8f3Slukem #include <sys/wait.h>
502cb5542fSderaadt 
517c81c8f3Slukem #include <ctype.h>
527c81c8f3Slukem #include <err.h>
537c81c8f3Slukem #include <errno.h>
547c81c8f3Slukem #include <fcntl.h>
557c81c8f3Slukem #include <paths.h>
567c81c8f3Slukem #include <pwd.h>
57ca13337dSchristos #include <setjmp.h>
582cb5542fSderaadt #include <signal.h>
597c81c8f3Slukem #include <stdio.h>
607c81c8f3Slukem #include <stdlib.h>
617c81c8f3Slukem #include <string.h>
6266f0c16fSmycroft #include <termios.h>
636f197c5bSkleink #include <time.h>
642cb5542fSderaadt #include <unistd.h>
65ca13337dSchristos #include <vis.h>
66ca13337dSchristos 
672cb5542fSderaadt #include "pathnames.h"
682cb5542fSderaadt 
6961f28255Scgd #define	APPEND				/* New mail goes to end of mailbox */
7061f28255Scgd 
71798fbc60Schristos #define COMMENT_CHAR	'#'		/* Comment character when sourcing */
7261f28255Scgd #define	ESCAPE		'~'		/* Default escape for sending */
7361f28255Scgd #define	NMLSIZE		1024		/* max names in a message list */
7461f28255Scgd #define	PATHSIZE	MAXPATHLEN	/* Size of pathnames throughout */
7561f28255Scgd #define	HSHSIZE		59		/* Hash size for aliases and vars */
7661f28255Scgd #define	LINESIZE	BUFSIZ		/* max readable line width */
7761f28255Scgd #define	MAXARGC		1024		/* Maximum list of raw strings */
7861f28255Scgd #define	MAXEXP		25		/* Maximum expansion of aliases */
7961f28255Scgd 
80f3098750Schristos #define PUBLIC			/* make it easy to find the entry points */
81f3098750Schristos 
82798fbc60Schristos /*
83798fbc60Schristos  * User environment variable names.
84f3098750Schristos  * See complete.h, mime.h, and thread.h for names specific to those modules.
85798fbc60Schristos  */
86f3098750Schristos #define	ENAME_INDENT_POSTSCRIPT	"indentpostscript"
87f3098750Schristos #define	ENAME_INDENT_PREAMBLE	"indentpreamble"
88f3098750Schristos #define ENAME_APPEND		"append"
89f3098750Schristos #define ENAME_ASK		"ask"
90f3098750Schristos #define ENAME_ASKBCC		"askbcc"
91f3098750Schristos #define ENAME_ASKCC		"askcc"
92f3098750Schristos #define ENAME_ASKSUB		"asksub"
93f3098750Schristos #define ENAME_AUTOINC		"autoinc"
94f3098750Schristos #define ENAME_AUTOPRINT		"autoprint"
95f3098750Schristos #define ENAME_CRT		"crt"
96f3098750Schristos #define ENAME_DEAD		"DEAD"
97f3098750Schristos #define ENAME_DEBUG		"debug"
98f3098750Schristos #define ENAME_DONTSENDEMPTY	"dontsendempty"
99f3098750Schristos #define ENAME_DOT		"dot"
100f3098750Schristos #define ENAME_EDITOR		"EDITOR"
101f3098750Schristos #define ENAME_ENABLE_PIPES	"enable-pipes"
102f3098750Schristos #define ENAME_ESCAPE		"escape"
103f3098750Schristos #define ENAME_FOLDER		"folder"
104f3098750Schristos #define ENAME_HEADER_FORMAT	"header-format"
105f3098750Schristos #define ENAME_HOLD		"hold"
106f3098750Schristos #define ENAME_IGNORE		"ignore"
107f3098750Schristos #define ENAME_IGNOREEOF		"ignoreeof"
108f3098750Schristos #define ENAME_INDENTPREFIX	"indentprefix"
109f3098750Schristos #define ENAME_INTERACTIVE	"interactive"
110f3098750Schristos #define ENAME_KEEP		"keep"
111f3098750Schristos #define ENAME_KEEPSAVE		"keepsave"
112f3098750Schristos #define ENAME_LISTER		"LISTER"
113f3098750Schristos #define ENAME_MBOX		"MBOX"
114f3098750Schristos #define ENAME_METOO		"metoo"
115f3098750Schristos #define ENAME_NOHEADER		"noheader"
116f3098750Schristos #define ENAME_NOSAVE		"nosave"
117ca13337dSchristos #define ENAME_PAGE_ALSO		"page-also"
118f3098750Schristos #define ENAME_PAGER		"PAGER"
119f3098750Schristos #define ENAME_PAGER_OFF		"pager-off"
120f3098750Schristos #define ENAME_PROMPT		"prompt"
121f3098750Schristos #define ENAME_QUIET		"quiet"
122798fbc60Schristos #define ENAME_RECORD		"record"
123f3098750Schristos #define ENAME_REGEX_SEARCH	"regex-search"
124f3098750Schristos #define ENAME_REPLYALL		"Replyall"
125f3098750Schristos #define ENAME_REPLYASRECIPIENT	"ReplyAsRecipient"
126f3098750Schristos #define ENAME_SCREEN		"screen"
127f3098750Schristos #define ENAME_SCREENHEIGHT	"screenheight"
128f3098750Schristos #define ENAME_SCREENWIDTH	"screenwidth"
129f3098750Schristos #define ENAME_SEARCHHEADERS	"searchheaders"
130f3098750Schristos #define ENAME_SENDMAIL		"sendmail"
131f3098750Schristos #define ENAME_SHELL		"SHELL"
132f3098750Schristos #define ENAME_SHOW_RCPT		"show-rcpt"
133f3098750Schristos #define ENAME_SMOPTS_VERIFY	"smopts-verify"
134f3098750Schristos #define ENAME_TOPLINES		"toplines"
135f3098750Schristos #define ENAME_VERBOSE		"verbose"
136f3098750Schristos #define ENAME_VISUAL		"VISUAL"
137798fbc60Schristos 
13861f28255Scgd #define	equal(a, b)	(strcmp(a,b)==0)/* A nice function to string compare */
13961f28255Scgd 
14061f28255Scgd struct message {
14161f28255Scgd 	short	m_flag;			/* flags, see below */
14261f28255Scgd 	short	m_offset;		/* offset in block of message */
143ca286310Schristos 	long	m_block;		/* block number of this message */
14419d35cbcStls 	long	m_lines;		/* Lines in the message */
145ca286310Schristos 	off_t	m_size;			/* Bytes in the message */
1463038d491Sross 	long	m_blines;		/* Body (non-header) lines */
147f3098750Schristos 
148f3098750Schristos 	/*
149f3098750Schristos 	 * threading fields
150f3098750Schristos 	 */
151f3098750Schristos 	int		m_index;	/* message index in this thread */
152f3098750Schristos 	int		m_depth;	/* depth in thread */
153f3098750Schristos 	struct message *m_flink;	/* link to next message */
154f3098750Schristos 	struct message *m_blink;	/* link to previous message */
155f3098750Schristos 	struct message *m_clink;	/* link to child of this message */
156f3098750Schristos 	struct message *m_plink;	/* link to parent of thread */
15761f28255Scgd };
1588207b28aSchristos typedef struct mime_info mime_info_t;	/* phantom structure only to attach.c */
15961f28255Scgd 
16061f28255Scgd /*
16161f28255Scgd  * flag bits.
16261f28255Scgd  */
16361f28255Scgd 
16461f28255Scgd #define	MUSED		(1<<0)		/* entry is used, but this bit isn't */
16561f28255Scgd #define	MDELETED	(1<<1)		/* entry has been deleted */
16661f28255Scgd #define	MSAVED		(1<<2)		/* entry has been saved */
16761f28255Scgd #define	MTOUCH		(1<<3)		/* entry has been noticed */
16861f28255Scgd #define	MPRESERVE	(1<<4)		/* keep entry in sys mailbox */
16961f28255Scgd #define	MMARK		(1<<5)		/* message is marked! */
170f3098750Schristos #define	MMODIFY		(1<<6)		/* message has been modified */
17161f28255Scgd #define	MNEW		(1<<7)		/* message has never been seen */
17261f28255Scgd #define	MREAD		(1<<8)		/* message has been read sometime. */
17361f28255Scgd #define	MSTATUS		(1<<9)		/* message status has changed */
17461f28255Scgd #define	MBOX		(1<<10)		/* Send this to mbox, regardless */
175f3098750Schristos #define MTAGGED		(1<<11)		/* message has been tagged */
17661f28255Scgd 
17761f28255Scgd /*
17861f28255Scgd  * Given a file address, determine the block number it represents.
17961f28255Scgd  */
18061f28255Scgd #define blockof(off)			((int) ((off) / 4096))
181fc687570Sdogcow #define blkoffsetof(off)		((int) ((off) % 4096))
18261f28255Scgd #define positionof(block, offset)	((off_t)(block) * 4096 + (offset))
18361f28255Scgd 
18461f28255Scgd /*
18561f28255Scgd  * Format of the command description table.
18661f28255Scgd  * The actual table is declared and initialized
18761f28255Scgd  * in lex.c
18861f28255Scgd  */
18961f28255Scgd struct cmd {
190ece0fd5cSchristos 	const char *c_name;		/* Name of command */
191b127ccccSwiz 	int	(*c_func)(void *);	/* Implementor of the command */
192f3098750Schristos 	int	c_pipe;			/* Pipe output through the pager */
193f3098750Schristos # define C_PIPE_PAGER	1		/* enable use of pager */
1946e70cbd2Schristos # define C_PIPE_CRT	2		/* use the pager if CRT is defined */
1956e70cbd2Schristos # define C_PIPE_SHELL	4		/* enable shell pipes */
1968207b28aSchristos #ifdef USE_EDITLINE
19785c81c58Schristos 	const char *c_complete;		/* String describing completion */
19885c81c58Schristos #endif
19961f28255Scgd 	short	c_argtype;		/* Type of arglist (see below) */
20061f28255Scgd 	short	c_msgflag;		/* Required flags of messages */
20161f28255Scgd 	short	c_msgmask;		/* Relevant flags of messages */
20261f28255Scgd };
20361f28255Scgd 
20461f28255Scgd /* Yechh, can't initialize unions */
20561f28255Scgd 
20661f28255Scgd #define	c_minargs c_msgflag		/* Minimum argcount for RAWLIST */
20761f28255Scgd #define	c_maxargs c_msgmask		/* Max argcount for RAWLIST */
20861f28255Scgd 
20961f28255Scgd /*
21061f28255Scgd  * Argument types.
21161f28255Scgd  */
21261f28255Scgd 
21361f28255Scgd #define	MSGLIST	 0		/* Message list type */
21461f28255Scgd #define	STRLIST	 1		/* A pure string */
21561f28255Scgd #define	RAWLIST	 2		/* Shell string list */
21661f28255Scgd #define	NOLIST	 3		/* Just plain 0 */
21761f28255Scgd #define	NDMLIST	 4		/* Message list, no defaults */
21861f28255Scgd 
219f3098750Schristos #define	P	0x010		/* Autoprint dot after command */
220f3098750Schristos #define	I	0x020		/* Interactive command bit */
221f3098750Schristos #define	M	0x040		/* Legal from send mode bit */
222f3098750Schristos #define	W	0x080		/* Illegal when read only bit */
223f3098750Schristos #define	F	0x100		/* Is a conditional command */
224f3098750Schristos #define	T	0x200		/* Is a transparent command */
225f3098750Schristos #define	R	0x400		/* Cannot be called from collect */
226f3098750Schristos #define ARGTYPE_MASK	~(P|I|M|W|F|T|R)
22761f28255Scgd 
22861f28255Scgd /*
22961f28255Scgd  * Oft-used mask values
23061f28255Scgd  */
23161f28255Scgd 
23261f28255Scgd #define	MMNORM		(MDELETED|MSAVED)/* Look at both save and delete bits */
23361f28255Scgd #define	MMNDEL		MDELETED	/* Look only at deleted bit */
23461f28255Scgd 
23561f28255Scgd /*
23661f28255Scgd  * Structure used to return a break down of a head
23761f28255Scgd  * line (hats off to Bill Joy!)
23861f28255Scgd  */
23961f28255Scgd 
24061f28255Scgd struct headline {
24161f28255Scgd 	char	*l_from;	/* The name of the sender */
24261f28255Scgd 	char	*l_tty;		/* His tty string (if any) */
24361f28255Scgd 	char	*l_date;	/* The entire date string */
24461f28255Scgd };
24561f28255Scgd 
24685c81c58Schristos #define	GTO	 0x001		/* Grab To: line */
24785c81c58Schristos #define	GSUBJECT 0x002		/* Likewise, Subject: line */
24885c81c58Schristos #define	GCC	 0x004		/* And the Cc: line */
24985c81c58Schristos #define	GBCC	 0x008		/* And also the Bcc: line */
25085c81c58Schristos #define GSMOPTS  0x010		/* Grab the sendmail options */
251f3098750Schristos #define GMISC	 0x020		/* miscellaneous extra fields for sending */
2528207b28aSchristos #ifdef MIME_SUPPORT
253f3098750Schristos #define GMIME    0x040		/* mime flag */
2548207b28aSchristos #endif
25585c81c58Schristos #define	GMASK	(GTO | GSUBJECT | GCC | GBCC | GSMOPTS)
25661f28255Scgd 				/* Mask of places from whence */
25761f28255Scgd 
25885c81c58Schristos #define	GNL	 0x100		/* Print blank line after */
25985c81c58Schristos #define	GDEL	 0x200		/* Entity removed from list */
26085c81c58Schristos #define	GCOMMA	 0x400		/* detract puts in commas */
26161f28255Scgd 
2628207b28aSchristos #ifdef MIME_SUPPORT
2638207b28aSchristos /*
2648207b28aSchristos  * Structure of MIME content.
2658207b28aSchristos  */
2668207b28aSchristos struct Content {
2678207b28aSchristos 	const char *C_type;		/* content type */
2688207b28aSchristos 	const char *C_encoding;		/* content transfer encoding */
2698207b28aSchristos 	const char *C_disposition;	/* content disposition */
2708207b28aSchristos 	const char *C_description;	/* content description */
2718207b28aSchristos 	const char *C_id;		/* content id */
2728207b28aSchristos };
2738207b28aSchristos /* Header strings corresponding to the above Content fields. */
2748207b28aSchristos #define MIME_HDR_TYPE		"Content-Type"
2758207b28aSchristos #define MIME_HDR_ENCODING	"Content-Transfer-Encoding"
2768207b28aSchristos #define MIME_HDR_DISPOSITION	"Content-Disposition"
2778207b28aSchristos #define MIME_HDR_ID		"Content-ID"
2788207b28aSchristos #define MIME_HDR_DESCRIPTION	"Content-Description"
2798207b28aSchristos #define MIME_HDR_VERSION	"MIME-Version"
2808207b28aSchristos /* the value of the MIME-Version field */
2818207b28aSchristos #define MIME_VERSION		"1.0"
2828207b28aSchristos 
2838207b28aSchristos typedef enum {
2848207b28aSchristos 	ATTACH_INVALID = 0,	/* do not use! */
2858207b28aSchristos 	ATTACH_FNAME = 1,
2868207b28aSchristos 	ATTACH_MSG = 2,
2878207b28aSchristos 	ATTACH_FILENO = 3
2888207b28aSchristos } attach_t;
2898207b28aSchristos 
2908207b28aSchristos /*
2918207b28aSchristos  * Structure of a MIME attachment.
2928207b28aSchristos  */
2938207b28aSchristos struct attachment {
2948207b28aSchristos 	struct attachment *a_flink;	/* Forward link in list. */
2958207b28aSchristos 	struct attachment *a_blink;	/* Backward list link */
2968207b28aSchristos 
2978207b28aSchristos 	attach_t a_type;		/* attachment type */
2988207b28aSchristos #if 1
2998207b28aSchristos 	union {
3008207b28aSchristos 		char *u_name;		/* file name */
3018207b28aSchristos 		struct message *u_msg;	/* message */
3028207b28aSchristos 		int u_fileno;		/* file number */
3038207b28aSchristos 	} a_u;
3048207b28aSchristos 
3058207b28aSchristos 	#define a_name		a_u.u_name
3068207b28aSchristos 	#define a_msg		a_u.u_msg
3078207b28aSchristos 	#define a_fileno	a_u.u_fileno
3088207b28aSchristos #else
3098207b28aSchristos 	char *a_name;			/* file name */
3108207b28aSchristos 	struct message *a_msg;		/* message */
3118207b28aSchristos 	int a_fileno;			/* file number */
3128207b28aSchristos #endif
3138207b28aSchristos 
3148207b28aSchristos 	struct Content a_Content;	/* MIME content strings */
3158207b28aSchristos };
3168207b28aSchristos #endif /* MIME_SUPPORT */
3178207b28aSchristos 
31861f28255Scgd /*
31961f28255Scgd  * Structure used to pass about the current
32061f28255Scgd  * state of the user-typed message header.
32161f28255Scgd  */
32261f28255Scgd 
32361f28255Scgd struct header {
32461f28255Scgd 	struct name	*h_to;		/* Dynamic "To:" string */
32561f28255Scgd 	char		*h_subject;	/* Subject string */
32661f28255Scgd 	struct name	*h_cc;		/* Carbon copies string */
32761f28255Scgd 	struct name	*h_bcc;		/* Blind carbon copies */
32861f28255Scgd 	struct name	*h_smopts;	/* Sendmail options */
329ca13337dSchristos 	char		*h_in_reply_to;	/* In-Reply-To: field */
330ca13337dSchristos 	struct name	*h_references;	/* References: field */
331ca13337dSchristos 	struct name	*h_extra;	/* extra header fields */
3328207b28aSchristos #ifdef MIME_SUPPORT
3338207b28aSchristos 	char *h_mime_boundary;		/* MIME multipart boundary string */
3348207b28aSchristos 	struct Content h_Content;	/* MIME content for message */
3358207b28aSchristos 	struct attachment *h_attach;	/* MIME attachments */
3368207b28aSchristos #endif
33761f28255Scgd };
33861f28255Scgd 
33961f28255Scgd /*
34061f28255Scgd  * Structure of namelist nodes used in processing
34161f28255Scgd  * the recipients of mail and aliases and all that
34261f28255Scgd  * kind of stuff.
34361f28255Scgd  */
34461f28255Scgd 
34561f28255Scgd struct name {
34661f28255Scgd 	struct	name *n_flink;		/* Forward link in list. */
34761f28255Scgd 	struct	name *n_blink;		/* Backward list link */
34861f28255Scgd 	short	n_type;			/* From which list it came */
34961f28255Scgd 	char	*n_name;		/* This fella's name */
35061f28255Scgd };
35161f28255Scgd 
35261f28255Scgd /*
35361f28255Scgd  * Structure of a variable node.  All variables are
35461f28255Scgd  * kept on a singly-linked list of these, rooted by
35561f28255Scgd  * "variables"
35661f28255Scgd  */
35761f28255Scgd 
35861f28255Scgd struct var {
35961f28255Scgd 	struct	var *v_link;		/* Forward link to next variable */
36061f28255Scgd 	char	*v_name;		/* The variable's name */
361*f0a7346dSsnj 	char	*v_value;		/* And its current value */
36261f28255Scgd };
36361f28255Scgd 
36461f28255Scgd struct group {
36561f28255Scgd 	struct	group *ge_link;		/* Next person in this group */
36661f28255Scgd 	char	*ge_name;		/* This person's user name */
36761f28255Scgd };
36861f28255Scgd 
36961f28255Scgd struct grouphead {
37061f28255Scgd 	struct	grouphead *g_link;	/* Next grouphead in list */
37161f28255Scgd 	char	*g_name;		/* Name of this group */
37261f28255Scgd 	struct	group *g_list;		/* Users in group. */
37361f28255Scgd };
37461f28255Scgd 
375798fbc60Schristos struct smopts_s {
376798fbc60Schristos 	struct smopts_s *s_link;	/* Link to next smopts_s in list */
377798fbc60Schristos 	char *s_name;			/* Name of this smopts_s */
378798fbc60Schristos 	struct name *s_smopts;		/* sendmail options name list */
379798fbc60Schristos };
380798fbc60Schristos 
38161f28255Scgd /*
38261f28255Scgd  * Structure of the hash table of ignored header fields
38361f28255Scgd  */
38461f28255Scgd struct ignoretab {
385ca286310Schristos 	size_t i_count;			/* Number of entries */
38661f28255Scgd 	struct ignore {
38761f28255Scgd 		struct ignore *i_link;	/* Next ignored field in bucket */
38861f28255Scgd 		char *i_field;		/* This ignored field */
38961f28255Scgd 	} *i_head[HSHSIZE];
39061f28255Scgd };
39161f28255Scgd 
39261f28255Scgd /*
393f3098750Schristos  * Constants for conditional commands.  These control whether we
394f3098750Schristos  * should be executing commands or not.
39561f28255Scgd  */
396f3098750Schristos struct cond_stack_s {
397f3098750Schristos 	struct cond_stack_s *c_next;
398f3098750Schristos 	int c_cond;
399f3098750Schristos };
400f3098750Schristos #define	CNONE		0x00		/* Execute everything */
401f3098750Schristos #define	CSKIP		0x01		/* Do not execute commands */
402f3098750Schristos #define	CIF		0x02		/* Inside if/endif block */
403f3098750Schristos #define	CELSE		0x04		/* The last conditional was else */
404f3098750Schristos #define	CIGN		0x08		/* Conditional in a skipped block */
40561f28255Scgd 
406f3098750Schristos enum mailmode_e {
407f3098750Schristos 	mm_receiving,			/* receiving mail mode */
408f3098750Schristos 	mm_sending,			/* sending mail mode */
409f3098750Schristos 	mm_hdrsonly			/* headers only mode */
410f3098750Schristos };
41161f28255Scgd 
41261f28255Scgd /*
41361f28255Scgd  * Truncate a file to the last character written. This is
41461f28255Scgd  * useful just before closing an old file that was opened
41561f28255Scgd  * for read/write.
41661f28255Scgd  */
417a28a03c9Scgd #define trunc(stream) {							\
418a28a03c9Scgd 	(void)fflush(stream); 						\
419353b511dSjtc 	(void)ftruncate(fileno(stream), (off_t)ftell(stream));		\
420a28a03c9Scgd }
4218207b28aSchristos 
4228207b28aSchristos /*
423d727506fSchristos  * White Space (WSP) as specified in see RFC 2822.
424d727506fSchristos  *
425d727506fSchristos  * NOTE: Use this in place of isblank() so it is inline.  Also, unlike
426d727506fSchristos  * the table implemented ctype(3) routines, this does not have input
427d727506fSchristos  * range issues caused by sign extensions.
428d727506fSchristos  *
429d727506fSchristos  * See mime_header.h for the related is_FWS().
4308207b28aSchristos  */
431d727506fSchristos static inline int
is_WSP(int c)432d727506fSchristos is_WSP(int c)
4338207b28aSchristos {
434d727506fSchristos 	return c == ' ' || c == '\t';
435d727506fSchristos }
436d727506fSchristos 
437d727506fSchristos static inline char *
skip_WSP(const char * cp)438d727506fSchristos skip_WSP(const char *cp)
439d727506fSchristos {
440d727506fSchristos 	while (is_WSP(*cp))
4418207b28aSchristos 		cp++;
442d727506fSchristos 	return __UNCONST(cp);
443d727506fSchristos }
444d727506fSchristos 
445d727506fSchristos static inline char *
skip_space(char * p)446d727506fSchristos skip_space(char *p)
447d727506fSchristos {
448d727506fSchristos 	while (isspace((unsigned char)*p))
449d727506fSchristos 		p++;
450d727506fSchristos 	return p;
4518207b28aSchristos }
452798fbc60Schristos 
453ca13337dSchristos /*
454ca13337dSchristos  * strip trailing white space
455ca13337dSchristos  */
456ca13337dSchristos static inline char *
strip_WSP(char * line)457ca13337dSchristos strip_WSP(char *line)
458ca13337dSchristos {
459ca13337dSchristos 	char *cp;
460ca13337dSchristos 
461ca13337dSchristos 	cp = line + strlen(line) - 1;
462ca13337dSchristos 	while (cp >= line && is_WSP(*cp))
463ca13337dSchristos 		cp--;
464ca13337dSchristos 	*++cp = '\0';
465ca13337dSchristos 	return cp;
466ca13337dSchristos }
467ca13337dSchristos 
468798fbc60Schristos #endif /* __DEF_H__ */
469