xref: /onnv-gate/usr/src/cmd/mailx/hdr/def.h (revision 13093:48f2dbca79a2)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52931Sas145665  * Common Development and Distribution License (the "License").
62931Sas145665  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
212931Sas145665 
220Sstevel@tonic-gate /*
23*13093SRoger.Faulkner@Oracle.COM  * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
262931Sas145665 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
272931Sas145665 /*	All Rights Reserved   */
282931Sas145665 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
310Sstevel@tonic-gate  * The Regents of the University of California
320Sstevel@tonic-gate  * All Rights Reserved
330Sstevel@tonic-gate  *
340Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
350Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
360Sstevel@tonic-gate  * contributors.
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifndef _MAILX_DEF_H
400Sstevel@tonic-gate #define	_MAILX_DEF_H
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifdef	__cplusplus
430Sstevel@tonic-gate extern "C" {
440Sstevel@tonic-gate #endif
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #include <sys/types.h>
470Sstevel@tonic-gate #include <signal.h>
480Sstevel@tonic-gate #include <stdio.h>
490Sstevel@tonic-gate #include <fcntl.h>
500Sstevel@tonic-gate #include <string.h>
510Sstevel@tonic-gate #include <termio.h>
520Sstevel@tonic-gate #include <setjmp.h>
530Sstevel@tonic-gate #include <time.h>
540Sstevel@tonic-gate #include <sys/stat.h>
550Sstevel@tonic-gate #include <maillock.h>
560Sstevel@tonic-gate #include <ctype.h>
570Sstevel@tonic-gate #include <errno.h>
580Sstevel@tonic-gate #ifndef preSVr4
592931Sas145665 #include <unistd.h>
602931Sas145665 #include <stdlib.h>
612931Sas145665 #include <ulimit.h>
622931Sas145665 #include <wait.h>
630Sstevel@tonic-gate #endif
640Sstevel@tonic-gate #ifdef VMUNIX
650Sstevel@tonic-gate #include <sys/wait.h>
660Sstevel@tonic-gate #endif
670Sstevel@tonic-gate #include "local.h"
680Sstevel@tonic-gate #include "uparm.h"
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  * mailx -- a modified version of a University of California at Berkeley
720Sstevel@tonic-gate  *	mail program
730Sstevel@tonic-gate  */
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #define	SENDESC		'~'		/* Default escape for sending */
760Sstevel@tonic-gate #define	NMLSIZE		1024		/* max names in a message list */
770Sstevel@tonic-gate #define	PATHSIZE	1024		/* Size of pathnames throughout */
780Sstevel@tonic-gate #define	HSHSIZE		59		/* Hash size for aliases and vars */
790Sstevel@tonic-gate #define	HDRFIELDS	3		/* Number of header fields */
800Sstevel@tonic-gate #define	LINESIZE	5120		/* max readable line width */
812931Sas145665 #define	STRINGSIZE	((unsigned)128) /* Dynamic allocation units */
820Sstevel@tonic-gate #define	MAXARGC		1024		/* Maximum list of raw strings */
832931Sas145665 #define	NOSTR		((char *)0)	/* Nill string pointer */
842931Sas145665 #define	NOSTRPTR	((char **)0)	/* Nill pointer to string pointer */
852931Sas145665 #define	NOINTPTR	((int *)0)	/* Nill pointer */
860Sstevel@tonic-gate #define	MAXEXP		25		/* Maximum expansion of aliases */
870Sstevel@tonic-gate 
882931Sas145665 /* A nice function to string compare */
892931Sas145665 #define	equal(a, b)	(strcmp(a, b) == 0)
902931Sas145665 
912931Sas145665 /* Keep a list of all opened files */
922931Sas145665 #define	fopen(s, t)	my_fopen(s, t)
932931Sas145665 
942931Sas145665 /* Delete closed file from the list */
952931Sas145665 #define	fclose(s)	my_fclose(s)
960Sstevel@tonic-gate 
970Sstevel@tonic-gate struct message {
980Sstevel@tonic-gate 	off_t	m_offset;		/* offset in block of message */
990Sstevel@tonic-gate 	long	m_size;			/* Bytes in the message */
1000Sstevel@tonic-gate 	long	m_lines;		/* Lines in the message */
1010Sstevel@tonic-gate 	long	m_clen;			/* Content-Length of the mesg   */
1020Sstevel@tonic-gate 	short	m_flag;			/* flags, see below */
1030Sstevel@tonic-gate 	char	m_text;			/* TRUE if the contents is text */
1040Sstevel@tonic-gate 					/* False otherwise		*/
1050Sstevel@tonic-gate };
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate typedef struct fplst {
1080Sstevel@tonic-gate 	FILE	*fp;
1090Sstevel@tonic-gate 	struct	fplst	*next;
1100Sstevel@tonic-gate } NODE;
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate /*
1130Sstevel@tonic-gate  * flag bits.
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate #define	MUSED		(1<<0)		/* entry is used, but this bit isn't */
1170Sstevel@tonic-gate #define	MDELETED	(1<<1)		/* entry has been deleted */
1180Sstevel@tonic-gate #define	MSAVED		(1<<2)		/* entry has been saved */
1190Sstevel@tonic-gate #define	MTOUCH		(1<<3)		/* entry has been noticed */
1200Sstevel@tonic-gate #define	MPRESERVE	(1<<4)		/* keep entry in sys mailbox */
1210Sstevel@tonic-gate #define	MMARK		(1<<5)		/* message is marked! */
1220Sstevel@tonic-gate #define	MODIFY		(1<<6)		/* message has been modified */
1230Sstevel@tonic-gate #define	MNEW		(1<<7)		/* message has never been seen */
1240Sstevel@tonic-gate #define	MREAD		(1<<8)		/* message has been read sometime. */
1250Sstevel@tonic-gate #define	MSTATUS		(1<<9)		/* message status has changed */
1260Sstevel@tonic-gate #define	MBOX		(1<<10)		/* Send this to mbox, regardless */
1270Sstevel@tonic-gate #define	MBOXED		(1<<11)		/* message has been sent to mbox */
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate #define	H_AFWDCNT	1		/* "Auto-Forward-Count:"  */
1300Sstevel@tonic-gate #define	H_AFWDFROM	2		/* "Auto-Forwarded-From:" */
1312931Sas145665 #define	H_CLEN		3		/* "Content-Length:"	*/
1322931Sas145665 #define	H_CTYPE		4		/* "Content-Type:"	*/
1332931Sas145665 #define	H_DATE		5		/* "Date:"		*/
1342931Sas145665 #define	H_DEFOPTS	6		/* "Default-Options:"	*/
1352931Sas145665 #define	H_EOH		7		/* "End-of-Header:"	*/
1362931Sas145665 #define	H_FROM		8		/* "From "		*/
1372931Sas145665 #define	H_FROM1		9		/* ">From "		*/
1382931Sas145665 #define	H_FROM2		10		/* "From: "		*/
1392931Sas145665 #define	H_MTSID		11		/* "MTS-Message-ID:"	*/
1402931Sas145665 #define	H_MTYPE		12		/* "Message-Type:"	*/
1412931Sas145665 #define	H_MVERS		13		/* "Message-Version:"	*/
1422931Sas145665 #define	H_MSVC		14		/* "Message-Service:"	*/
1432931Sas145665 #define	H_RECEIVED	15		/* "Received:"		*/
1442931Sas145665 #define	H_RVERS		16		/* "Report-Version:"	*/
1452931Sas145665 #define	H_STATUS	17		/* "Status:"		*/
1462931Sas145665 #define	H_SUBJ		18		/* "Subject:"		*/
1472931Sas145665 #define	H_TO		19		/* "To:"		*/
1482931Sas145665 #define	H_TCOPY		20		/* ">To:"		*/
1490Sstevel@tonic-gate #define	H_TROPTS	21		/* "Transport-Options:"   */
1500Sstevel@tonic-gate #define	H_UAID		22		/* "UA-Content-ID:"	  */
1512931Sas145665 
1522931Sas145665 #define	H_DAFWDFROM	23	/* Hold A-F-F when sending Del. Notf. */
1532931Sas145665 #define	H_DTCOPY	24	/* Hold ">To:" when sending Del. Notf. */
1542931Sas145665 #define	H_DRECEIVED	25	/* Hold Rcvd: when sending Del. Notf. */
1552931Sas145665 #define	H_CONT		26	/* Continuation of previous line */
1562931Sas145665 #define	H_NAMEVALUE	27	/* unrecognized "name: value" hdr line */
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate /*
1590Sstevel@tonic-gate  * Format of the command description table.
1600Sstevel@tonic-gate  * The actual table is declared and initialized
1610Sstevel@tonic-gate  * in lex.c
1620Sstevel@tonic-gate  */
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate struct cmd {
1650Sstevel@tonic-gate 	char	*c_name;		/* Name of command */
1660Sstevel@tonic-gate 	int	(*c_func)(void *);	/* Implementor of the command */
1670Sstevel@tonic-gate 	short	c_argtype;		/* Type of arglist (see below) */
1680Sstevel@tonic-gate 	short	c_msgflag;		/* Required flags of messages */
1690Sstevel@tonic-gate 	short	c_msgmask;		/* Relevant flags of messages */
1700Sstevel@tonic-gate };
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate /* can't initialize unions */
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate #define	c_minargs c_msgflag		/* Minimum argcount for RAWLIST */
1750Sstevel@tonic-gate #define	c_maxargs c_msgmask		/* Max argcount for RAWLIST */
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate /*
1780Sstevel@tonic-gate  * Argument types.
1790Sstevel@tonic-gate  */
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate #define	MSGLIST	 0		/* Message list type */
1820Sstevel@tonic-gate #define	STRLIST	 1		/* A pure string */
1830Sstevel@tonic-gate #define	RAWLIST	 2		/* Shell string list */
1840Sstevel@tonic-gate #define	NOLIST	 3		/* Just plain 0 */
1850Sstevel@tonic-gate #define	NDMLIST	 4		/* Message list, no defaults */
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate #define	P	040		/* Autoprint dot after command */
1880Sstevel@tonic-gate #define	I	0100		/* Interactive command bit */
1890Sstevel@tonic-gate #define	M	0200		/* Legal from send mode bit */
1900Sstevel@tonic-gate #define	W	0400		/* Illegal when read only bit */
1910Sstevel@tonic-gate #define	F	01000		/* Is a conditional command */
1920Sstevel@tonic-gate #define	T	02000		/* Is a transparent command */
1930Sstevel@tonic-gate #define	R	04000		/* Cannot be called from collect */
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate /*
1960Sstevel@tonic-gate  * Oft-used mask values
1970Sstevel@tonic-gate  */
1980Sstevel@tonic-gate 
1992931Sas145665 #define	MMNORM	(MDELETED|MSAVED) /* Look at both save and delete bits */
2002931Sas145665 #define	MMNDEL	MDELETED	/* Look only at deleted bit */
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate /*
2030Sstevel@tonic-gate  * Structure used to return a break down of a head
2040Sstevel@tonic-gate  * line
2050Sstevel@tonic-gate  */
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate struct headline {
2080Sstevel@tonic-gate 	char	*l_from;	/* The name of the sender */
2090Sstevel@tonic-gate 	char	*l_tty;		/* His tty string (if any) */
2100Sstevel@tonic-gate 	char	*l_date;	/* The entire date string */
2110Sstevel@tonic-gate };
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate #define	GTO	1		/* Grab To: line */
2140Sstevel@tonic-gate #define	GSUBJECT 2		/* Likewise, Subject: line */
2150Sstevel@tonic-gate #define	GCC	4		/* And the Cc: line */
2160Sstevel@tonic-gate #define	GBCC	8		/* And also the Bcc: line */
2170Sstevel@tonic-gate #define	GDEFOPT	16		/* And the Default-Options: lines */
2180Sstevel@tonic-gate #define	GNL	32		/* Print blank line after */
2192931Sas145665 #define	GOTHER	64		/* Other header lines */
2200Sstevel@tonic-gate #define	GMASK	(GTO|GSUBJECT|GCC|GBCC|GDEFOPT|GNL|GOTHER)
2210Sstevel@tonic-gate 				/* Mask of all header lines */
2220Sstevel@tonic-gate #define	GDEL	128		/* Entity removed from list */
2230Sstevel@tonic-gate #define	GCLEN	256		/* Include Content-Length header */
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate /*
2260Sstevel@tonic-gate  * Structure used to pass about the current
2270Sstevel@tonic-gate  * state of the user-typed message header.
2280Sstevel@tonic-gate  */
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate struct header {
2310Sstevel@tonic-gate 	char	*h_to;			/* Dynamic "To:" string */
2320Sstevel@tonic-gate 	char	*h_subject;		/* Subject string */
2330Sstevel@tonic-gate 	char	*h_cc;			/* Carbon copies string */
2340Sstevel@tonic-gate 	char	*h_bcc;			/* Blind carbon copies */
2350Sstevel@tonic-gate 	char	*h_defopt;		/* Default options */
2360Sstevel@tonic-gate 	char	**h_others;		/* Other header lines */
2370Sstevel@tonic-gate 	int	h_seq;			/* Sequence for optimization */
2380Sstevel@tonic-gate };
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate /*
2410Sstevel@tonic-gate  * Structure of namelist nodes used in processing
2420Sstevel@tonic-gate  * the recipients of mail and aliases and all that
2430Sstevel@tonic-gate  * kind of stuff.
2440Sstevel@tonic-gate  */
2450Sstevel@tonic-gate 
2460Sstevel@tonic-gate struct name {
2470Sstevel@tonic-gate 	struct	name *n_flink;		/* Forward link in list. */
2480Sstevel@tonic-gate 	struct	name *n_blink;		/* Backward list link */
2490Sstevel@tonic-gate 	short	n_type;			/* From which list it came */
2500Sstevel@tonic-gate 	char	*n_name;		/* This fella's name */
2510Sstevel@tonic-gate 	char	*n_full;		/* Full name */
2520Sstevel@tonic-gate };
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate /*
2550Sstevel@tonic-gate  * Structure of a variable node.  All variables are
2560Sstevel@tonic-gate  * kept on a singly-linked list of these, rooted by
2570Sstevel@tonic-gate  * "variables"
2580Sstevel@tonic-gate  */
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate struct var {
2610Sstevel@tonic-gate 	struct	var *v_link;		/* Forward link to next variable */
2620Sstevel@tonic-gate 	char	*v_name;		/* The variable's name */
2630Sstevel@tonic-gate 	char	*v_value;		/* And it's current value */
2640Sstevel@tonic-gate };
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate struct mgroup {
2670Sstevel@tonic-gate 	struct	mgroup *ge_link;	/* Next person in this group */
2680Sstevel@tonic-gate 	char	*ge_name;		/* This person's user name */
2690Sstevel@tonic-gate };
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate struct grouphead {
2720Sstevel@tonic-gate 	struct	grouphead *g_link;	/* Next grouphead in list */
2730Sstevel@tonic-gate 	char	*g_name;		/* Name of this group */
2740Sstevel@tonic-gate 	struct	mgroup *g_list;		/* Users in group. */
2750Sstevel@tonic-gate };
2760Sstevel@tonic-gate 
2772931Sas145665 #define	NIL	((struct name *)0)	/* The nil pointer for namelists */
2782931Sas145665 #define	NONE	((struct cmd *)0)	/* The nil pointer to command tab */
2792931Sas145665 #define	NOVAR	((struct var *)0)	/* The nil pointer to variables */
2802931Sas145665 #define	NOGRP	((struct grouphead *)0) /* The nil grouphead pointer */
2812931Sas145665 #define	NOGE	((struct mgroup *)0)	/* The nil group pointer */
2822931Sas145665 #define	NOFP	((struct fplst *)0)	/* The nil file pointer */
2830Sstevel@tonic-gate 
2842931Sas145665 #define	TRUE	1
2852931Sas145665 #define	FALSE	0
2860Sstevel@tonic-gate 
2872931Sas145665 #define	DEADPERM	0600		/* permissions of dead.letter */
2882931Sas145665 #define	TEMPPERM	0600		/* permissions of temp files */
2892931Sas145665 #define	MBOXPERM	0600		/* permissions of ~/mbox */
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate #ifndef	MFMODE
2922931Sas145665 #define	MFMODE		0600		/* create mode for `/var/mail' files */
2930Sstevel@tonic-gate #endif
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate /*
2960Sstevel@tonic-gate  * Structure of the hash table of ignored header fields
2970Sstevel@tonic-gate  */
2980Sstevel@tonic-gate struct ignore {
2990Sstevel@tonic-gate 	struct ignore	*i_link;	/* Next ignored field in bucket */
3000Sstevel@tonic-gate 	char		*i_field;	/* This ignored field */
3010Sstevel@tonic-gate };
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate #ifdef preSVr4
3040Sstevel@tonic-gate struct utimbuf {
3050Sstevel@tonic-gate 	time_t	actime;
3060Sstevel@tonic-gate 	time_t	modtime;
3070Sstevel@tonic-gate };
3080Sstevel@tonic-gate #else
3092931Sas145665 #include	<utime.h>
3100Sstevel@tonic-gate #endif
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate /*
3130Sstevel@tonic-gate  * Token values returned by the scanner used for argument lists.
3140Sstevel@tonic-gate  * Also, sizes of scanner-related things.
3150Sstevel@tonic-gate  */
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate #define	TEOL		0		/* End of the command line */
3180Sstevel@tonic-gate #define	TNUMBER		1		/* A message number */
3190Sstevel@tonic-gate #define	TDASH		2		/* A simple dash */
3200Sstevel@tonic-gate #define	TSTRING		3		/* A string (possibly containing -) */
3210Sstevel@tonic-gate #define	TDOT		4		/* A "." */
3220Sstevel@tonic-gate #define	TUP		5		/* An "^" */
3230Sstevel@tonic-gate #define	TDOLLAR		6		/* A "$" */
3240Sstevel@tonic-gate #define	TSTAR		7		/* A "*" */
3250Sstevel@tonic-gate #define	TOPEN		8		/* An '(' */
3260Sstevel@tonic-gate #define	TCLOSE		9		/* A ')' */
3272931Sas145665 #define	TPLUS		10		/* A '+' */
3280Sstevel@tonic-gate 
3290Sstevel@tonic-gate #define	REGDEP		2		/* Maximum regret depth. */
3300Sstevel@tonic-gate #define	STRINGLEN	1024		/* Maximum length of string token */
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate /*
3330Sstevel@tonic-gate  * Constants for conditional commands.  These describe whether
3340Sstevel@tonic-gate  * we should be executing stuff or not.
3350Sstevel@tonic-gate  */
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate #define	CANY		0		/* Execute in send or receive mode */
3380Sstevel@tonic-gate #define	CRCV		1		/* Execute in receive mode only */
3390Sstevel@tonic-gate #define	CSEND		2		/* Execute in send mode only */
3400Sstevel@tonic-gate #define	CTTY		3		/* Execute if attached to a tty only */
3410Sstevel@tonic-gate #define	CNOTTY		4		/* Execute if not attached to a tty */
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate /*
3440Sstevel@tonic-gate  * Flags for msend().
3450Sstevel@tonic-gate  */
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate #define	M_IGNORE	1		/* Do "ignore/retain" processing */
3480Sstevel@tonic-gate #define	M_SAVING	2		/* Saving to a file/folder */
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate /*
3510Sstevel@tonic-gate  * VM/UNIX has a vfork system call which is faster than forking.  If we
3520Sstevel@tonic-gate  * don't have it, fork(2) will do . . .
3530Sstevel@tonic-gate  */
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate #if !defined(VMUNIX) && defined(preSVr4)
3560Sstevel@tonic-gate #define	vfork()	fork()
3570Sstevel@tonic-gate #endif
3580Sstevel@tonic-gate #ifndef	SIGRETRO
3590Sstevel@tonic-gate #define	sigchild()
3600Sstevel@tonic-gate #endif
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate /*
3640Sstevel@tonic-gate  * 4.2bsd signal interface help...
3650Sstevel@tonic-gate  */
3660Sstevel@tonic-gate #ifdef VMUNIX
3670Sstevel@tonic-gate #define	sigset(s, a)	signal(s, a)
3680Sstevel@tonic-gate #define	sigsys(s, a)	signal(s, a)
3690Sstevel@tonic-gate #else
3700Sstevel@tonic-gate #ifndef preSVr4
3710Sstevel@tonic-gate /* SVr4 version of sigset() in fio.c */
3720Sstevel@tonic-gate #define	sigsys(s, a)	signal(s, a)
3730Sstevel@tonic-gate #define	setjmp(x)	sigsetjmp((x), 1)
3740Sstevel@tonic-gate #define	longjmp		siglongjmp
3750Sstevel@tonic-gate #define	jmp_buf		sigjmp_buf
3760Sstevel@tonic-gate #else
3770Sstevel@tonic-gate #define	OLD_BSD_SIGS
3780Sstevel@tonic-gate #endif
3790Sstevel@tonic-gate #endif
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate /*
3820Sstevel@tonic-gate  * Truncate a file to the last character written. This is
3830Sstevel@tonic-gate  * useful just before closing an old file that was opened
3840Sstevel@tonic-gate  * for read/write.
3850Sstevel@tonic-gate  */
3862931Sas145665 #define	trunc(stream)	ftruncate(fileno(stream), (long)ftell(stream))
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate /*
3890Sstevel@tonic-gate  * The pointers for the string allocation routines,
3900Sstevel@tonic-gate  * there are NSPACE independent areas.
3910Sstevel@tonic-gate  * The first holds STRINGSIZE bytes, the next
3920Sstevel@tonic-gate  * twice as much, and so on.
3930Sstevel@tonic-gate  */
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate #define	NSPACE	25			/* Total number of string spaces */
3960Sstevel@tonic-gate struct strings {
3970Sstevel@tonic-gate 	char	*s_topFree;		/* Beginning of this area */
3980Sstevel@tonic-gate 	char	*s_nextFree;		/* Next alloctable place here */
3990Sstevel@tonic-gate 	unsigned s_nleft;		/* Number of bytes left here */
4000Sstevel@tonic-gate };
4010Sstevel@tonic-gate 
4020Sstevel@tonic-gate /* The following typedefs must be used in SVR4 */
4030Sstevel@tonic-gate #ifdef preSVr4
4040Sstevel@tonic-gate #ifndef sun
4050Sstevel@tonic-gate typedef int gid_t;
4060Sstevel@tonic-gate typedef int uid_t;
4070Sstevel@tonic-gate typedef int mode_t;
4080Sstevel@tonic-gate typedef int pid_t;
4090Sstevel@tonic-gate #endif
4100Sstevel@tonic-gate #endif
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate #define	STSIZ	40
4130Sstevel@tonic-gate #define	TMPSIZ	14
4140Sstevel@tonic-gate /*
4150Sstevel@tonic-gate  * Forward declarations of routine types to keep lint and cc happy.
4160Sstevel@tonic-gate  */
4170Sstevel@tonic-gate 
4180Sstevel@tonic-gate extern int		Copy(int *msgvec);
4190Sstevel@tonic-gate extern FILE		*Fdopen(int fildes, char *mode);
4200Sstevel@tonic-gate extern int		Followup(int *msgvec);
4210Sstevel@tonic-gate extern char		*Getf(register char *s);
4220Sstevel@tonic-gate extern int		More(int *msgvec);
4230Sstevel@tonic-gate extern int		Respond(int *msgvec);
4240Sstevel@tonic-gate extern int		Save(int *msgvec);
4250Sstevel@tonic-gate extern int		Sendm(char *str);
4260Sstevel@tonic-gate extern int		Sput(char str[]);
4270Sstevel@tonic-gate extern int		Type(int *msgvec);
4280Sstevel@tonic-gate extern void		Verhogen(void);
4290Sstevel@tonic-gate extern char		*addone(char hf[], char news[]);
4300Sstevel@tonic-gate extern char		*addto(char hf[], char news[]);
4310Sstevel@tonic-gate extern void		alter(char name[]);
4320Sstevel@tonic-gate extern int		alternates(char **namelist);
4330Sstevel@tonic-gate extern void		announce(void);
4340Sstevel@tonic-gate extern int		any(int ch, char *str);
4350Sstevel@tonic-gate extern int		anyof(register char *s1, register char *s2);
4360Sstevel@tonic-gate extern int		argcount(char **argv);
4370Sstevel@tonic-gate extern void		assign(char name[], char value[]);
4380Sstevel@tonic-gate extern int		blankline(const char linebuf[]);
4390Sstevel@tonic-gate extern struct name	*cat(struct name *n1, struct name *n2);
4400Sstevel@tonic-gate extern FILE		*collect(struct header *hp);
4410Sstevel@tonic-gate extern void		commands(void);
4420Sstevel@tonic-gate extern char		*copy(char *str1, char *str2);
4430Sstevel@tonic-gate extern int		copycmd(char str[]);
4440Sstevel@tonic-gate extern int		deassign(register char *s);
4450Sstevel@tonic-gate extern int		delm(int *msgvec);
4460Sstevel@tonic-gate extern struct name	*delname(register struct name *np, char name[]);
4470Sstevel@tonic-gate extern int		deltype(int msgvec[]);
4480Sstevel@tonic-gate extern char		*detract(register struct name *np, int ntype);
4490Sstevel@tonic-gate extern int		docomma(char *s);
4500Sstevel@tonic-gate extern int		dopipe(char str[]);
4510Sstevel@tonic-gate extern int		dosh(char *str);
4520Sstevel@tonic-gate extern int		echo(register char **argv);
4530Sstevel@tonic-gate extern int		editor(int *msgvec);
4540Sstevel@tonic-gate extern int		edstop(int noremove);
4550Sstevel@tonic-gate extern struct name	*elide(struct name *names);
4560Sstevel@tonic-gate extern int		elsecmd(void);
4570Sstevel@tonic-gate extern int		endifcmd(void);
4580Sstevel@tonic-gate extern int		execute(char linebuf[], int contxt);
4590Sstevel@tonic-gate extern char		*expand(char *name);
4600Sstevel@tonic-gate extern struct name	*extract(char line[], int arg_ntype);
4610Sstevel@tonic-gate extern int		fferror(FILE *iob);
4620Sstevel@tonic-gate extern int		field(char str[]);
4630Sstevel@tonic-gate extern int		file(char **argv);
4640Sstevel@tonic-gate extern struct grouphead	*findgroup(char name[]);
4650Sstevel@tonic-gate extern void		findmail(char *name);
4660Sstevel@tonic-gate extern int		first(int f, int m);
4670Sstevel@tonic-gate extern void		flush(void);
4680Sstevel@tonic-gate extern int		folders(char **arglist);
4690Sstevel@tonic-gate extern int		followup(int *msgvec);
4700Sstevel@tonic-gate extern int		from(int *msgvec);
4710Sstevel@tonic-gate extern off_t		fsize(FILE *iob);
4720Sstevel@tonic-gate extern int		getfold(char *name);
4732931Sas145665 extern int	gethfield(register FILE *f, char linebuf[], register long rem);
474*13093SRoger.Faulkner@Oracle.COM extern int	getaline(char *line, int size, FILE *f, int *hasnulls);
4752931Sas145665 extern int	getmessage(char *buf, int *vector, int flags);
4762931Sas145665 extern int	getmsglist(char *buf, int *vector, int flags);
4772931Sas145665 extern int	getname(uid_t uid, char namebuf[]);
4782931Sas145665 extern int	getrawlist(char line[], char **argv, int argc);
4792931Sas145665 extern void	getrecf(char *buf, char *recfile,
4802931Sas145665 		    int useauthor, int sz_recfile);
4812931Sas145665 extern uid_t	getuserid(char name[]);
4822931Sas145665 extern int	grabh(register struct header *hp, int gflags, int subjtop);
4832931Sas145665 extern int	group(char **argv);
4842931Sas145665 extern void	hangup(int);
4852931Sas145665 extern int	hash(char name[]);
4862931Sas145665 extern char	*hcontents(char hfield[]);
4872931Sas145665 extern int	headerp(register char *line);
4882931Sas145665 extern int	headers(int *msgvec);
4892931Sas145665 extern int	help(void);
4902931Sas145665 extern char	*helppath(char *file);
4912931Sas145665 extern char	*hfield(char field[], struct message *mp,
4922931Sas145665 		    char *(*add)(char *, char *));
4932931Sas145665 extern void	holdsigs(void);
4942931Sas145665 extern int	icequal(register char *s1, register char *s2);
4952931Sas145665 extern int	ifcmd(char **argv);
4962931Sas145665 extern int	igfield(char *list[]);
4972931Sas145665 extern int	inc(void);
4982931Sas145665 extern void	inithost(void);
4992931Sas145665 extern int	isdir(char name[]);
5002931Sas145665 extern int	ishead(char linebuf[]);
5012931Sas145665 extern int	ishfield(char linebuf[], char field[]);
5022931Sas145665 extern int	ishost(char *sys, char *rest);
5032931Sas145665 extern int	isign(char *field, int saving);
5042931Sas145665 extern void	istrcpy(char *dest, int dstsize, char *src);
5052931Sas145665 extern void	lcwrite(char *fn, FILE *fi, FILE *fo, int addnl);
5062931Sas145665 extern void	load(char *name);
5072931Sas145665 extern int	loadmsg(char str[]);
5082931Sas145665 extern int	lock(FILE *fp, char *mode, int blk);
5092931Sas145665 extern void	lockmail(void);
5102931Sas145665 extern int	mail(char **people);
5112931Sas145665 extern void	mail1(struct header *hp, int use_to, char *orig_to);
5122931Sas145665 extern void	mapf(register struct name *np, char *from);
5132931Sas145665 extern int	mboxit(int msgvec[]);
5142931Sas145665 extern void	mechk(struct name *names);
5152931Sas145665 extern int	member(register char *realfield,
5162931Sas145665 		    register struct ignore **table);
5172931Sas145665 extern int	messize(int *msgvec);
5182931Sas145665 extern void	minit(void);
5192931Sas145665 extern int	more(int *msgvec);
5202931Sas145665 extern long	msend(struct message *mailp, FILE *obuf,
5212931Sas145665 		    int flag, int (*fp)(const char *, FILE *));
5222931Sas145665 extern int	my_fclose(register FILE *iop);
5232931Sas145665 extern FILE	*my_fopen(char *file, char *mode);
5242931Sas145665 extern char	*nameof(register struct message *mp);
5252931Sas145665 extern char	*netmap(char name[], char from[]);
5262931Sas145665 extern int	newfileinfo(int start);
5272931Sas145665 extern int	next(int *msgvec);
5282931Sas145665 extern int	npclose(FILE *ptr);
5292931Sas145665 extern FILE	*npopen(char *cmd, char *mode);
5302931Sas145665 extern char	*nstrcpy(char *dst, int dstsize, char *src);
5312931Sas145665 extern char	*nstrcat(char *dst, int dstsize, char *src);
5322931Sas145665 extern int	null(char *e);
5332931Sas145665 extern int	outof(struct name *names, FILE *fo);
5340Sstevel@tonic-gate extern struct name	*outpre(struct name *to);
5352931Sas145665 extern void	panic(char *str);
5362931Sas145665 extern void	parse(char line[], struct headline *hl, char pbuf[]);
5372931Sas145665 extern int	pcmdlist(void);
5382931Sas145665 extern int	pdot(void);
5392931Sas145665 extern int	preserve(int *msgvec);
5402931Sas145665 extern void	printgroup(char name[]);
5412931Sas145665 extern void	printhead(int mesg);
5422931Sas145665 extern int	puthead(struct header *hp, FILE *fo, int w, long clen);
5432931Sas145665 extern int	pversion(char *e);
5442931Sas145665 extern void	quit(int noremove);
5452931Sas145665 extern int	readline(FILE *ibuf, char *linebuf);
5462931Sas145665 extern void	receipt(struct message *mp);
5472931Sas145665 extern void	relsesigs(void);
5482931Sas145665 extern int	removefile(char name[]);
5492931Sas145665 extern int	replyall(int *msgvec);
5502931Sas145665 extern int	replysender(int *msgvec);
5512931Sas145665 extern int	respond(int *msgvec);
5522931Sas145665 extern int	retfield(char *list[]);
5532931Sas145665 extern int	rexit(int e);
5542931Sas145665 extern char	*safeexpand(char name[]);
5552931Sas145665 extern void	*salloc(unsigned size);
5562931Sas145665 extern void	*srealloc(void *optr, unsigned size);
5572931Sas145665 extern int	samebody(register char *user, register char *addr,
5582931Sas145665 		    int fuzzy);
5592931Sas145665 extern int	save(char str[]);
5602931Sas145665 extern void	savedead(int s);
5612931Sas145665 extern char	*savestr(char *str);
5622931Sas145665 extern int	schdir(char *str);
5632931Sas145665 extern int	screensize(void);
5642931Sas145665 extern int	scroll(char arg[]);
5652931Sas145665 extern int	sendm(char *str);
5662931Sas145665 extern int	set(char **arglist);
5672931Sas145665 extern void	setclen(register struct message *mp);
5682931Sas145665 extern int	setfile(char *name, int isedit);
5692931Sas145665 extern FILE	*setinput(register struct message *mp);
5702931Sas145665 extern void	setptr(register FILE *ibuf);
5712931Sas145665 extern int	shell(char *str);
5720Sstevel@tonic-gate #ifndef sigchild
5730Sstevel@tonic-gate extern void		sigchild(void);
5740Sstevel@tonic-gate #endif
5750Sstevel@tonic-gate #ifndef sigset
5760Sstevel@tonic-gate extern void		(*sigset())();
5770Sstevel@tonic-gate #endif
5780Sstevel@tonic-gate extern char		*skin(char *name);
5790Sstevel@tonic-gate extern char		*snarf(char linebuf[], int *flag, int erf);
5800Sstevel@tonic-gate extern int		source(char name[]);
5810Sstevel@tonic-gate extern char		*splice(char *addr, char *hdr);
5820Sstevel@tonic-gate extern int		sput(char str[]);
5830Sstevel@tonic-gate extern void		sreset(void);
5840Sstevel@tonic-gate extern void		stop(int s);
5850Sstevel@tonic-gate extern int		stouch(int msgvec[]);
5860Sstevel@tonic-gate extern int		substr(char *string1, char *string2);
5870Sstevel@tonic-gate extern int		swrite(char str[]);
5880Sstevel@tonic-gate extern struct name	*tailof(struct name *name);
5890Sstevel@tonic-gate extern void		tinit(void);
5900Sstevel@tonic-gate extern int		tmail(void);
5910Sstevel@tonic-gate extern int		top(int *msgvec);
5920Sstevel@tonic-gate extern void		touch(int mesg);
5930Sstevel@tonic-gate extern struct name	*translate(struct name *np);
5940Sstevel@tonic-gate extern int		type(int *msgvec);
5950Sstevel@tonic-gate extern int		undelete(int *msgvec);
5960Sstevel@tonic-gate extern int		ungroup(char **argv);
5970Sstevel@tonic-gate extern int		unigfield(char *list[]);
5980Sstevel@tonic-gate extern void		unlockmail(void);
5990Sstevel@tonic-gate extern char		**unpack(struct name *np);
6000Sstevel@tonic-gate extern int		unread(int msgvec[]);
6010Sstevel@tonic-gate extern int		unretfield(char *list[]);
6020Sstevel@tonic-gate extern int		unset(char **arglist);
6030Sstevel@tonic-gate extern int		unstack(void);
6040Sstevel@tonic-gate extern char		*unuucp(char *name);
6050Sstevel@tonic-gate extern struct name	*usermap(struct name *names);
6060Sstevel@tonic-gate extern char		*value(char name[]);
6070Sstevel@tonic-gate extern char		*vcopy(char str[]);
6080Sstevel@tonic-gate extern void		vfree(register char *cp);
6090Sstevel@tonic-gate extern int		visual(int *msgvec);
6100Sstevel@tonic-gate extern char		*yankword(char *name, char *word, int sz, int comma);
6110Sstevel@tonic-gate 
6120Sstevel@tonic-gate /*
6130Sstevel@tonic-gate  * These functions are defined in libmail.a
6140Sstevel@tonic-gate  */
6150Sstevel@tonic-gate #ifdef	__cplusplus
6160Sstevel@tonic-gate extern "C" {
6170Sstevel@tonic-gate #endif
6180Sstevel@tonic-gate extern int		delempty(mode_t, char *);
6190Sstevel@tonic-gate extern char		*maildomain(void);
6200Sstevel@tonic-gate extern void		touchlock(void);
6210Sstevel@tonic-gate extern char		*xgetenv(char *);
6220Sstevel@tonic-gate extern int		xsetenv(char *);
6230Sstevel@tonic-gate #ifdef	__cplusplus
6240Sstevel@tonic-gate }
6250Sstevel@tonic-gate #endif
6260Sstevel@tonic-gate 
6270Sstevel@tonic-gate /*
6280Sstevel@tonic-gate  * Standard functions from the C library.
6290Sstevel@tonic-gate  * These are all defined in <stdlib.h> and <wait.h> in SVr4.
6300Sstevel@tonic-gate  */
6310Sstevel@tonic-gate #ifdef preSVr4
6320Sstevel@tonic-gate extern long		atol();
6330Sstevel@tonic-gate extern char		*getcwd();
6340Sstevel@tonic-gate extern char		*calloc();
6350Sstevel@tonic-gate extern char		*getenv();
6360Sstevel@tonic-gate extern void		exit();
6370Sstevel@tonic-gate extern void		free();
6380Sstevel@tonic-gate extern char		*malloc();
6390Sstevel@tonic-gate extern time_t		time();
6400Sstevel@tonic-gate extern long		ulimit();
6410Sstevel@tonic-gate extern int		utime();
6420Sstevel@tonic-gate extern int		wait();
6430Sstevel@tonic-gate extern int		fputs();
6440Sstevel@tonic-gate #endif
6450Sstevel@tonic-gate 
6460Sstevel@tonic-gate #ifdef	__cplusplus
6470Sstevel@tonic-gate }
6480Sstevel@tonic-gate #endif
6490Sstevel@tonic-gate 
6500Sstevel@tonic-gate #endif	/* _MAILX_DEF_H */
651