xref: /illumos-gate/usr/src/cmd/mailx/hdr/def.h (revision 500cf85b)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5eb2b0a61Sas  * Common Development and Distribution License (the "License").
6eb2b0a61Sas  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
22196c7f05SJoshua M. Clulow /*
23*500cf85bSJason King  * Copyright 2018 Joyent, Inc.
24196c7f05SJoshua M. Clulow  */
25196c7f05SJoshua M. Clulow 
267c478bd9Sstevel@tonic-gate /*
2723a1cceaSRoger A. Faulkner  * Copyright (c) 1985, 2010, Oracle and/or its affiliates. All rights reserved.
2848bbca81SDaniel Hoffman  * Copyright (c) 2016 by Delphix. All rights reserved.
297c478bd9Sstevel@tonic-gate  */
31eb2b0a61Sas /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32eb2b0a61Sas /*	All Rights Reserved   */
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
367c478bd9Sstevel@tonic-gate  * The Regents of the University of California
377c478bd9Sstevel@tonic-gate  * All Rights Reserved
387c478bd9Sstevel@tonic-gate  *
397c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
407c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
417c478bd9Sstevel@tonic-gate  * contributors.
427c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate #ifndef _MAILX_DEF_H
457c478bd9Sstevel@tonic-gate #define	_MAILX_DEF_H
477c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
487c478bd9Sstevel@tonic-gate extern "C" {
497c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate #include <sys/types.h>
527c478bd9Sstevel@tonic-gate #include <signal.h>
537c478bd9Sstevel@tonic-gate #include <stdio.h>
547c478bd9Sstevel@tonic-gate #include <fcntl.h>
557c478bd9Sstevel@tonic-gate #include <string.h>
567c478bd9Sstevel@tonic-gate #include <termio.h>
577c478bd9Sstevel@tonic-gate #include <setjmp.h>
587c478bd9Sstevel@tonic-gate #include <time.h>
597c478bd9Sstevel@tonic-gate #include <sys/stat.h>
607c478bd9Sstevel@tonic-gate #include <maillock.h>
617c478bd9Sstevel@tonic-gate #include <ctype.h>
627c478bd9Sstevel@tonic-gate #include <errno.h>
637c478bd9Sstevel@tonic-gate #ifndef preSVr4
64eb2b0a61Sas #include <unistd.h>
65eb2b0a61Sas #include <stdlib.h>
66eb2b0a61Sas #include <ulimit.h>
67eb2b0a61Sas #include <wait.h>
68*500cf85bSJason King #include <libcustr.h>
697c478bd9Sstevel@tonic-gate #endif
707c478bd9Sstevel@tonic-gate #ifdef VMUNIX
717c478bd9Sstevel@tonic-gate #include <sys/wait.h>
727c478bd9Sstevel@tonic-gate #endif
737c478bd9Sstevel@tonic-gate #include "local.h"
747c478bd9Sstevel@tonic-gate #include "uparm.h"
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * mailx -- a modified version of a University of California at Berkeley
787c478bd9Sstevel@tonic-gate  *	mail program
797c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate #define	SENDESC		'~'		/* Default escape for sending */
827c478bd9Sstevel@tonic-gate #define	NMLSIZE		1024		/* max names in a message list */
837c478bd9Sstevel@tonic-gate #define	PATHSIZE	1024		/* Size of pathnames throughout */
847c478bd9Sstevel@tonic-gate #define	HSHSIZE		59		/* Hash size for aliases and vars */
857c478bd9Sstevel@tonic-gate #define	HDRFIELDS	3		/* Number of header fields */
867c478bd9Sstevel@tonic-gate #define	LINESIZE	5120		/* max readable line width */
87eb2b0a61Sas #define	STRINGSIZE	((unsigned)128) /* Dynamic allocation units */
887c478bd9Sstevel@tonic-gate #define	MAXARGC		1024		/* Maximum list of raw strings */
89eb2b0a61Sas #define	NOSTR		((char *)0)	/* Nill string pointer */
90eb2b0a61Sas #define	NOSTRPTR	((char **)0)	/* Nill pointer to string pointer */
91eb2b0a61Sas #define	NOINTPTR	((int *)0)	/* Nill pointer */
927c478bd9Sstevel@tonic-gate #define	MAXEXP		25		/* Maximum expansion of aliases */
94eb2b0a61Sas /* A nice function to string compare */
95eb2b0a61Sas #define	equal(a, b)	(strcmp(a, b) == 0)
97eb2b0a61Sas /* Keep a list of all opened files */
98eb2b0a61Sas #define	fopen(s, t)	my_fopen(s, t)
100eb2b0a61Sas /* Delete closed file from the list */
101eb2b0a61Sas #define	fclose(s)	my_fclose(s)
1037c478bd9Sstevel@tonic-gate struct message {
1047c478bd9Sstevel@tonic-gate 	off_t	m_offset;		/* offset in block of message */
1057c478bd9Sstevel@tonic-gate 	long	m_size;			/* Bytes in the message */
1067c478bd9Sstevel@tonic-gate 	long	m_lines;		/* Lines in the message */
1077c478bd9Sstevel@tonic-gate 	long	m_clen;			/* Content-Length of the mesg   */
1087c478bd9Sstevel@tonic-gate 	short	m_flag;			/* flags, see below */
1097c478bd9Sstevel@tonic-gate 	char	m_text;			/* TRUE if the contents is text */
1107c478bd9Sstevel@tonic-gate 					/* False otherwise		*/
1117c478bd9Sstevel@tonic-gate };
1137c478bd9Sstevel@tonic-gate typedef struct fplst {
1147c478bd9Sstevel@tonic-gate 	FILE	*fp;
1157c478bd9Sstevel@tonic-gate 	struct	fplst	*next;
1167c478bd9Sstevel@tonic-gate } NODE;
1187c478bd9Sstevel@tonic-gate /*
1197c478bd9Sstevel@tonic-gate  * flag bits.
1207c478bd9Sstevel@tonic-gate  */
1227c478bd9Sstevel@tonic-gate #define	MUSED		(1<<0)		/* entry is used, but this bit isn't */
1237c478bd9Sstevel@tonic-gate #define	MDELETED	(1<<1)		/* entry has been deleted */
1247c478bd9Sstevel@tonic-gate #define	MSAVED		(1<<2)		/* entry has been saved */
1257c478bd9Sstevel@tonic-gate #define	MTOUCH		(1<<3)		/* entry has been noticed */
1267c478bd9Sstevel@tonic-gate #define	MPRESERVE	(1<<4)		/* keep entry in sys mailbox */
1277c478bd9Sstevel@tonic-gate #define	MMARK		(1<<5)		/* message is marked! */
1287c478bd9Sstevel@tonic-gate #define	MODIFY		(1<<6)		/* message has been modified */
1297c478bd9Sstevel@tonic-gate #define	MNEW		(1<<7)		/* message has never been seen */
1307c478bd9Sstevel@tonic-gate #define	MREAD		(1<<8)		/* message has been read sometime. */
1317c478bd9Sstevel@tonic-gate #define	MSTATUS		(1<<9)		/* message status has changed */
1327c478bd9Sstevel@tonic-gate #define	MBOX		(1<<10)		/* Send this to mbox, regardless */
1337c478bd9Sstevel@tonic-gate #define	MBOXED		(1<<11)		/* message has been sent to mbox */
1357c478bd9Sstevel@tonic-gate #define	H_AFWDCNT	1		/* "Auto-Forward-Count:"  */
1367c478bd9Sstevel@tonic-gate #define	H_AFWDFROM	2		/* "Auto-Forwarded-From:" */
137eb2b0a61Sas #define	H_CLEN		3		/* "Content-Length:"	*/
138eb2b0a61Sas #define	H_CTYPE		4		/* "Content-Type:"	*/
139eb2b0a61Sas #define	H_DATE		5		/* "Date:"		*/
140eb2b0a61Sas #define	H_DEFOPTS	6		/* "Default-Options:"	*/
141eb2b0a61Sas #define	H_EOH		7		/* "End-of-Header:"	*/
142eb2b0a61Sas #define	H_FROM		8		/* "From "		*/
143eb2b0a61Sas #define	H_FROM1		9		/* ">From "		*/
144eb2b0a61Sas #define	H_FROM2		10		/* "From: "		*/
145eb2b0a61Sas #define	H_MTSID		11		/* "MTS-Message-ID:"	*/
146eb2b0a61Sas #define	H_MTYPE		12		/* "Message-Type:"	*/
147eb2b0a61Sas #define	H_MVERS		13		/* "Message-Version:"	*/
148eb2b0a61Sas #define	H_MSVC		14		/* "Message-Service:"	*/
149eb2b0a61Sas #define	H_RECEIVED	15		/* "Received:"		*/
150eb2b0a61Sas #define	H_RVERS		16		/* "Report-Version:"	*/
151eb2b0a61Sas #define	H_STATUS	17		/* "Status:"		*/
152eb2b0a61Sas #define	H_SUBJ		18		/* "Subject:"		*/
153eb2b0a61Sas #define	H_TO		19		/* "To:"		*/
154eb2b0a61Sas #define	H_TCOPY		20		/* ">To:"		*/
1557c478bd9Sstevel@tonic-gate #define	H_TROPTS	21		/* "Transport-Options:"   */
1567c478bd9Sstevel@tonic-gate #define	H_UAID		22		/* "UA-Content-ID:"	  */
158eb2b0a61Sas #define	H_DAFWDFROM	23	/* Hold A-F-F when sending Del. Notf. */
159eb2b0a61Sas #define	H_DTCOPY	24	/* Hold ">To:" when sending Del. Notf. */
160eb2b0a61Sas #define	H_DRECEIVED	25	/* Hold Rcvd: when sending Del. Notf. */
161eb2b0a61Sas #define	H_CONT		26	/* Continuation of previous line */
162eb2b0a61Sas #define	H_NAMEVALUE	27	/* unrecognized "name: value" hdr line */
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * Format of the command description table.
1667c478bd9Sstevel@tonic-gate  * The actual table is declared and initialized
1677c478bd9Sstevel@tonic-gate  * in lex.c
1687c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate struct cmd {
1717c478bd9Sstevel@tonic-gate 	char	*c_name;		/* Name of command */
1727c478bd9Sstevel@tonic-gate 	int	(*c_func)(void *);	/* Implementor of the command */
1737c478bd9Sstevel@tonic-gate 	short	c_argtype;		/* Type of arglist (see below) */
1747c478bd9Sstevel@tonic-gate 	short	c_msgflag;		/* Required flags of messages */
1757c478bd9Sstevel@tonic-gate 	short	c_msgmask;		/* Relevant flags of messages */
1767c478bd9Sstevel@tonic-gate };
1787c478bd9Sstevel@tonic-gate /* can't initialize unions */
1807c478bd9Sstevel@tonic-gate #define	c_minargs c_msgflag		/* Minimum argcount for RAWLIST */
1817c478bd9Sstevel@tonic-gate #define	c_maxargs c_msgmask		/* Max argcount for RAWLIST */
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * Argument types.
1857c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate #define	MSGLIST	 0		/* Message list type */
1887c478bd9Sstevel@tonic-gate #define	STRLIST	 1		/* A pure string */
1897c478bd9Sstevel@tonic-gate #define	RAWLIST	 2		/* Shell string list */
1907c478bd9Sstevel@tonic-gate #define	NOLIST	 3		/* Just plain 0 */
1917c478bd9Sstevel@tonic-gate #define	NDMLIST	 4		/* Message list, no defaults */
1937c478bd9Sstevel@tonic-gate #define	P	040		/* Autoprint dot after command */
1947c478bd9Sstevel@tonic-gate #define	I	0100		/* Interactive command bit */
1957c478bd9Sstevel@tonic-gate #define	M	0200		/* Legal from send mode bit */
1967c478bd9Sstevel@tonic-gate #define	W	0400		/* Illegal when read only bit */
1977c478bd9Sstevel@tonic-gate #define	F	01000		/* Is a conditional command */
1987c478bd9Sstevel@tonic-gate #define	T	02000		/* Is a transparent command */
1997c478bd9Sstevel@tonic-gate #define	R	04000		/* Cannot be called from collect */
2017c478bd9Sstevel@tonic-gate /*
2027c478bd9Sstevel@tonic-gate  * Oft-used mask values
2037c478bd9Sstevel@tonic-gate  */
205eb2b0a61Sas #define	MMNORM	(MDELETED|MSAVED) /* Look at both save and delete bits */
206eb2b0a61Sas #define	MMNDEL	MDELETED	/* Look only at deleted bit */
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * Structure used to return a break down of a head
2107c478bd9Sstevel@tonic-gate  * line
2117c478bd9Sstevel@tonic-gate  */
213196c7f05SJoshua M. Clulow typedef struct headline {
214196c7f05SJoshua M. Clulow 	custr_t	*hl_from;	/* The name of the sender */
21548bbca81SDaniel Hoffman 	custr_t	*hl_tty;	/* Its tty string (if any) */
216196c7f05SJoshua M. Clulow 	custr_t	*hl_date;	/* The entire date string */
217196c7f05SJoshua M. Clulow } headline_t;
2197c478bd9Sstevel@tonic-gate #define	GTO	1		/* Grab To: line */
2207c478bd9Sstevel@tonic-gate #define	GSUBJECT 2		/* Likewise, Subject: line */
2217c478bd9Sstevel@tonic-gate #define	GCC	4		/* And the Cc: line */
2227c478bd9Sstevel@tonic-gate #define	GBCC	8		/* And also the Bcc: line */
2237c478bd9Sstevel@tonic-gate #define	GDEFOPT	16		/* And the Default-Options: lines */
2247c478bd9Sstevel@tonic-gate #define	GNL	32		/* Print blank line after */
225eb2b0a61Sas #define	GOTHER	64		/* Other header lines */
2267c478bd9Sstevel@tonic-gate #define	GMASK	(GTO|GSUBJECT|GCC|GBCC|GDEFOPT|GNL|GOTHER)
2277c478bd9Sstevel@tonic-gate 				/* Mask of all header lines */
2287c478bd9Sstevel@tonic-gate #define	GDEL	128		/* Entity removed from list */
2297c478bd9Sstevel@tonic-gate #define	GCLEN	256		/* Include Content-Length header */
2317c478bd9Sstevel@tonic-gate /*
2327c478bd9Sstevel@tonic-gate  * Structure used to pass about the current
2337c478bd9Sstevel@tonic-gate  * state of the user-typed message header.
2347c478bd9Sstevel@tonic-gate  */
2367c478bd9Sstevel@tonic-gate struct header {
2377c478bd9Sstevel@tonic-gate 	char	*h_to;			/* Dynamic "To:" string */
2387c478bd9Sstevel@tonic-gate 	char	*h_subject;		/* Subject string */
2397c478bd9Sstevel@tonic-gate 	char	*h_cc;			/* Carbon copies string */
2407c478bd9Sstevel@tonic-gate 	char	*h_bcc;			/* Blind carbon copies */
2417c478bd9Sstevel@tonic-gate 	char	*h_defopt;		/* Default options */
2427c478bd9Sstevel@tonic-gate 	char	**h_others;		/* Other header lines */
2437c478bd9Sstevel@tonic-gate 	int	h_seq;			/* Sequence for optimization */
2447c478bd9Sstevel@tonic-gate };
2467c478bd9Sstevel@tonic-gate /*
2477c478bd9Sstevel@tonic-gate  * Structure of namelist nodes used in processing
2487c478bd9Sstevel@tonic-gate  * the recipients of mail and aliases and all that
2497c478bd9Sstevel@tonic-gate  * kind of stuff.
2507c478bd9Sstevel@tonic-gate  */
2527c478bd9Sstevel@tonic-gate struct name {
2537c478bd9Sstevel@tonic-gate 	struct	name *n_flink;		/* Forward link in list. */
2547c478bd9Sstevel@tonic-gate 	struct	name *n_blink;		/* Backward list link */
2557c478bd9Sstevel@tonic-gate 	short	n_type;			/* From which list it came */
2567c478bd9Sstevel@tonic-gate 	char	*n_name;		/* This fella's name */
2577c478bd9Sstevel@tonic-gate 	char	*n_full;		/* Full name */
2587c478bd9Sstevel@tonic-gate };
2607c478bd9Sstevel@tonic-gate /*
2617c478bd9Sstevel@tonic-gate  * Structure of a variable node.  All variables are
2627c478bd9Sstevel@tonic-gate  * kept on a singly-linked list of these, rooted by
2637c478bd9Sstevel@tonic-gate  * "variables"
2647c478bd9Sstevel@tonic-gate  */
2667c478bd9Sstevel@tonic-gate struct var {
2677c478bd9Sstevel@tonic-gate 	struct	var *v_link;		/* Forward link to next variable */
2687c478bd9Sstevel@tonic-gate 	char	*v_name;		/* The variable's name */
2697c478bd9Sstevel@tonic-gate 	char	*v_value;		/* And it's current value */
2707c478bd9Sstevel@tonic-gate };
2727c478bd9Sstevel@tonic-gate struct mgroup {
2737c478bd9Sstevel@tonic-gate 	struct	mgroup *ge_link;	/* Next person in this group */
2747c478bd9Sstevel@tonic-gate 	char	*ge_name;		/* This person's user name */
2757c478bd9Sstevel@tonic-gate };
2777c478bd9Sstevel@tonic-gate struct grouphead {
2787c478bd9Sstevel@tonic-gate 	struct	grouphead *g_link;	/* Next grouphead in list */
2797c478bd9Sstevel@tonic-gate 	char	*g_name;		/* Name of this group */
2807c478bd9Sstevel@tonic-gate 	struct	mgroup *g_list;		/* Users in group. */
2817c478bd9Sstevel@tonic-gate };
283eb2b0a61Sas #define	NIL	((struct name *)0)	/* The nil pointer for namelists */
284eb2b0a61Sas #define	NONE	((struct cmd *)0)	/* The nil pointer to command tab */
285eb2b0a61Sas #define	NOVAR	((struct var *)0)	/* The nil pointer to variables */
286eb2b0a61Sas #define	NOGRP	((struct grouphead *)0) /* The nil grouphead pointer */
287eb2b0a61Sas #define	NOGE	((struct mgroup *)0)	/* The nil group pointer */
288eb2b0a61Sas #define	NOFP	((struct fplst *)0)	/* The nil file pointer */
290eb2b0a61Sas #define	TRUE	1
291eb2b0a61Sas #define	FALSE	0
293eb2b0a61Sas #define	DEADPERM	0600		/* permissions of dead.letter */
294eb2b0a61Sas #define	TEMPPERM	0600		/* permissions of temp files */
295eb2b0a61Sas #define	MBOXPERM	0600		/* permissions of ~/mbox */
2977c478bd9Sstevel@tonic-gate #ifndef	MFMODE
298eb2b0a61Sas #define	MFMODE		0600		/* create mode for `/var/mail' files */
2997c478bd9Sstevel@tonic-gate #endif
3017c478bd9Sstevel@tonic-gate /*
3027c478bd9Sstevel@tonic-gate  * Structure of the hash table of ignored header fields
3037c478bd9Sstevel@tonic-gate  */
3047c478bd9Sstevel@tonic-gate struct ignore {
3057c478bd9Sstevel@tonic-gate 	struct ignore	*i_link;	/* Next ignored field in bucket */
3067c478bd9Sstevel@tonic-gate 	char		*i_field;	/* This ignored field */
3077c478bd9Sstevel@tonic-gate };
3097c478bd9Sstevel@tonic-gate #ifdef preSVr4
3107c478bd9Sstevel@tonic-gate struct utimbuf {
3117c478bd9Sstevel@tonic-gate 	time_t	actime;
3127c478bd9Sstevel@tonic-gate 	time_t	modtime;
3137c478bd9Sstevel@tonic-gate };
3147c478bd9Sstevel@tonic-gate #else
315eb2b0a61Sas #include	<utime.h>
3167c478bd9Sstevel@tonic-gate #endif
3187c478bd9Sstevel@tonic-gate /*
3197c478bd9Sstevel@tonic-gate  * Token values returned by the scanner used for argument lists.
3207c478bd9Sstevel@tonic-gate  * Also, sizes of scanner-related things.
3217c478bd9Sstevel@tonic-gate  */
3237c478bd9Sstevel@tonic-gate #define	TEOL		0		/* End of the command line */
3247c478bd9Sstevel@tonic-gate #define	TNUMBER		1		/* A message number */
3257c478bd9Sstevel@tonic-gate #define	TDASH		2		/* A simple dash */
3267c478bd9Sstevel@tonic-gate #define	TSTRING		3		/* A string (possibly containing -) */
3277c478bd9Sstevel@tonic-gate #define	TDOT		4		/* A "." */
3287c478bd9Sstevel@tonic-gate #define	TUP		5		/* An "^" */
3297c478bd9Sstevel@tonic-gate #define	TDOLLAR		6		/* A "$" */
3307c478bd9Sstevel@tonic-gate #define	TSTAR		7		/* A "*" */
3317c478bd9Sstevel@tonic-gate #define	TOPEN		8		/* An '(' */
3327c478bd9Sstevel@tonic-gate #define	TCLOSE		9		/* A ')' */
333eb2b0a61Sas #define	TPLUS		10		/* A '+' */
3357c478bd9Sstevel@tonic-gate #define	REGDEP		2		/* Maximum regret depth. */
3367c478bd9Sstevel@tonic-gate #define	STRINGLEN	1024		/* Maximum length of string token */
3387c478bd9Sstevel@tonic-gate /*
3397c478bd9Sstevel@tonic-gate  * Constants for conditional commands.  These describe whether
3407c478bd9Sstevel@tonic-gate  * we should be executing stuff or not.
3417c478bd9Sstevel@tonic-gate  */
3437c478bd9Sstevel@tonic-gate #define	CANY		0		/* Execute in send or receive mode */
3447c478bd9Sstevel@tonic-gate #define	CRCV		1		/* Execute in receive mode only */
3457c478bd9Sstevel@tonic-gate #define	CSEND		2		/* Execute in send mode only */
3467c478bd9Sstevel@tonic-gate #define	CTTY		3		/* Execute if attached to a tty only */
3477c478bd9Sstevel@tonic-gate #define	CNOTTY		4		/* Execute if not attached to a tty */
3497c478bd9Sstevel@tonic-gate /*
3507c478bd9Sstevel@tonic-gate  * Flags for msend().
3517c478bd9Sstevel@tonic-gate  */
3537c478bd9Sstevel@tonic-gate #define	M_IGNORE	1		/* Do "ignore/retain" processing */
3547c478bd9Sstevel@tonic-gate #define	M_SAVING	2		/* Saving to a file/folder */
3567c478bd9Sstevel@tonic-gate /*
3577c478bd9Sstevel@tonic-gate  * VM/UNIX has a vfork system call which is faster than forking.  If we
3587c478bd9Sstevel@tonic-gate  * don't have it, fork(2) will do . . .
3597c478bd9Sstevel@tonic-gate  */
3617c478bd9Sstevel@tonic-gate #if !defined(VMUNIX) && defined(preSVr4)
3627c478bd9Sstevel@tonic-gate #define	vfork()	fork()
3637c478bd9Sstevel@tonic-gate #endif
3647c478bd9Sstevel@tonic-gate #ifndef	SIGRETRO
3657c478bd9Sstevel@tonic-gate #define	sigchild()
3667c478bd9Sstevel@tonic-gate #endif
3697c478bd9Sstevel@tonic-gate /*
3707c478bd9Sstevel@tonic-gate  * 4.2bsd signal interface help...
3717c478bd9Sstevel@tonic-gate  */
3727c478bd9Sstevel@tonic-gate #ifdef VMUNIX
3737c478bd9Sstevel@tonic-gate #define	sigset(s, a)	signal(s, a)
3747c478bd9Sstevel@tonic-gate #define	sigsys(s, a)	signal(s, a)
3757c478bd9Sstevel@tonic-gate #else
3767c478bd9Sstevel@tonic-gate #ifndef preSVr4
3777c478bd9Sstevel@tonic-gate /* SVr4 version of sigset() in fio.c */
3787c478bd9Sstevel@tonic-gate #define	sigsys(s, a)	signal(s, a)
3797c478bd9Sstevel@tonic-gate #define	setjmp(x)	sigsetjmp((x), 1)
3807c478bd9Sstevel@tonic-gate #define	longjmp		siglongjmp
3817c478bd9Sstevel@tonic-gate #define	jmp_buf		sigjmp_buf
3827c478bd9Sstevel@tonic-gate #else
3837c478bd9Sstevel@tonic-gate #define	OLD_BSD_SIGS
3847c478bd9Sstevel@tonic-gate #endif
3857c478bd9Sstevel@tonic-gate #endif
3877c478bd9Sstevel@tonic-gate /*
3887c478bd9Sstevel@tonic-gate  * Truncate a file to the last character written. This is
3897c478bd9Sstevel@tonic-gate  * useful just before closing an old file that was opened
3907c478bd9Sstevel@tonic-gate  * for read/write.
3917c478bd9Sstevel@tonic-gate  */
392eb2b0a61Sas #define	trunc(stream)	ftruncate(fileno(stream), (long)ftell(stream))
3947c478bd9Sstevel@tonic-gate /*
3957c478bd9Sstevel@tonic-gate  * The pointers for the string allocation routines,
3967c478bd9Sstevel@tonic-gate  * there are NSPACE independent areas.
3977c478bd9Sstevel@tonic-gate  * The first holds STRINGSIZE bytes, the next
3987c478bd9Sstevel@tonic-gate  * twice as much, and so on.
3997c478bd9Sstevel@tonic-gate  */
4017c478bd9Sstevel@tonic-gate #define	NSPACE	25			/* Total number of string spaces */
4027c478bd9Sstevel@tonic-gate struct strings {
4037c478bd9Sstevel@tonic-gate 	char	*s_topFree;		/* Beginning of this area */
4047c478bd9Sstevel@tonic-gate 	char	*s_nextFree;		/* Next alloctable place here */
4057c478bd9Sstevel@tonic-gate 	unsigned s_nleft;		/* Number of bytes left here */
4067c478bd9Sstevel@tonic-gate };
4087c478bd9Sstevel@tonic-gate /* The following typedefs must be used in SVR4 */
4097c478bd9Sstevel@tonic-gate #ifdef preSVr4
4107c478bd9Sstevel@tonic-gate #ifndef sun
4117c478bd9Sstevel@tonic-gate typedef int gid_t;
4127c478bd9Sstevel@tonic-gate typedef int uid_t;
4137c478bd9Sstevel@tonic-gate typedef int mode_t;
4147c478bd9Sstevel@tonic-gate typedef int pid_t;
4157c478bd9Sstevel@tonic-gate #endif
4167c478bd9Sstevel@tonic-gate #endif
4187c478bd9Sstevel@tonic-gate #define	STSIZ	40
4197c478bd9Sstevel@tonic-gate #define	TMPSIZ	14
4207c478bd9Sstevel@tonic-gate /*
4217c478bd9Sstevel@tonic-gate  * Forward declarations of routine types to keep lint and cc happy.
4227c478bd9Sstevel@tonic-gate  */
4247c478bd9Sstevel@tonic-gate extern int		Copy(int *msgvec);
4257c478bd9Sstevel@tonic-gate extern FILE		*Fdopen(int fildes, char *mode);
4267c478bd9Sstevel@tonic-gate extern int		Followup(int *msgvec);
4277c478bd9Sstevel@tonic-gate extern char		*Getf(register char *s);
4287c478bd9Sstevel@tonic-gate extern int		More(int *msgvec);
4297c478bd9Sstevel@tonic-gate extern int		Respond(int *msgvec);
4307c478bd9Sstevel@tonic-gate extern int		Save(int *msgvec);
4317c478bd9Sstevel@tonic-gate extern int		Sendm(char *str);
4327c478bd9Sstevel@tonic-gate extern int		Sput(char str[]);
4337c478bd9Sstevel@tonic-gate extern int		Type(int *msgvec);
4347c478bd9Sstevel@tonic-gate extern void		Verhogen(void);
4357c478bd9Sstevel@tonic-gate extern char		*addone(char hf[], char news[]);
4367c478bd9Sstevel@tonic-gate extern char		*addto(char hf[], char news[]);
4377c478bd9Sstevel@tonic-gate extern void		alter(char name[]);
4387c478bd9Sstevel@tonic-gate extern int		alternates(char **namelist);
4397c478bd9Sstevel@tonic-gate extern void		announce(void);
4407c478bd9Sstevel@tonic-gate extern int		any(int ch, char *str);
4417c478bd9Sstevel@tonic-gate extern int		anyof(register char *s1, register char *s2);
4427c478bd9Sstevel@tonic-gate extern int		argcount(char **argv);
4437c478bd9Sstevel@tonic-gate extern void		assign(char name[], char value[]);
4447c478bd9Sstevel@tonic-gate extern int		blankline(const char linebuf[]);
4457c478bd9Sstevel@tonic-gate extern struct name	*cat(struct name *n1, struct name *n2);
4467c478bd9Sstevel@tonic-gate extern FILE		*collect(struct header *hp);
4477c478bd9Sstevel@tonic-gate extern void		commands(void);
4487c478bd9Sstevel@tonic-gate extern char		*copy(char *str1, char *str2);
4497c478bd9Sstevel@tonic-gate extern int		copycmd(char str[]);
4507c478bd9Sstevel@tonic-gate extern int		deassign(register char *s);
4517c478bd9Sstevel@tonic-gate extern int		delm(int *msgvec);
4527c478bd9Sstevel@tonic-gate extern struct name	*delname(register struct name *np, char name[]);
4537c478bd9Sstevel@tonic-gate extern int		deltype(int msgvec[]);
4547c478bd9Sstevel@tonic-gate extern char		*detract(register struct name *np, int ntype);
4557c478bd9Sstevel@tonic-gate extern int		docomma(char *s);
4567c478bd9Sstevel@tonic-gate extern int		dopipe(char str[]);
4577c478bd9Sstevel@tonic-gate extern int		dosh(char *str);
4587c478bd9Sstevel@tonic-gate extern int		echo(register char **argv);
4597c478bd9Sstevel@tonic-gate extern int		editor(int *msgvec);
4607c478bd9Sstevel@tonic-gate extern int		edstop(int noremove);
4617c478bd9Sstevel@tonic-gate extern struct name	*elide(struct name *names);
4627c478bd9Sstevel@tonic-gate extern int		elsecmd(void);
4637c478bd9Sstevel@tonic-gate extern int		endifcmd(void);
4647c478bd9Sstevel@tonic-gate extern int		execute(char linebuf[], int contxt);
4657c478bd9Sstevel@tonic-gate extern char		*expand(char *name);
4667c478bd9Sstevel@tonic-gate extern struct name	*extract(char line[], int arg_ntype);
4677c478bd9Sstevel@tonic-gate extern int		fferror(FILE *iob);
4687c478bd9Sstevel@tonic-gate extern int		field(char str[]);
4697c478bd9Sstevel@tonic-gate extern int		file(char **argv);
4707c478bd9Sstevel@tonic-gate extern struct grouphead	*findgroup(char name[]);
4717c478bd9Sstevel@tonic-gate extern void		findmail(char *name);
4727c478bd9Sstevel@tonic-gate extern int		first(int f, int m);
4737c478bd9Sstevel@tonic-gate extern void		flush(void);
4747c478bd9Sstevel@tonic-gate extern int		folders(char **arglist);
4757c478bd9Sstevel@tonic-gate extern int		followup(int *msgvec);
4767c478bd9Sstevel@tonic-gate extern int		from(int *msgvec);
4777c478bd9Sstevel@tonic-gate extern off_t		fsize(FILE *iob);
4787c478bd9Sstevel@tonic-gate extern int		getfold(char *name);
479eb2b0a61Sas extern int	gethfield(register FILE *f, char linebuf[], register long rem);
48023a1cceaSRoger A. Faulkner extern int	getaline(char *line, int size, FILE *f, int *hasnulls);
481eb2b0a61Sas extern int	getmessage(char *buf, int *vector, int flags);
482eb2b0a61Sas extern int	getmsglist(char *buf, int *vector, int flags);
483eb2b0a61Sas extern int	getname(uid_t uid, char namebuf[]);
484eb2b0a61Sas extern int	getrawlist(char line[], char **argv, int argc);
485eb2b0a61Sas extern void	getrecf(char *buf, char *recfile,
486eb2b0a61Sas 		    int useauthor, int sz_recfile);
487eb2b0a61Sas extern uid_t	getuserid(char name[]);
488eb2b0a61Sas extern int	grabh(register struct header *hp, int gflags, int subjtop);
489eb2b0a61Sas extern int	group(char **argv);
490eb2b0a61Sas extern void	hangup(int);
491eb2b0a61Sas extern int	hash(char name[]);
492eb2b0a61Sas extern char	*hcontents(char hfield[]);
493eb2b0a61Sas extern int	headerp(register char *line);
494eb2b0a61Sas extern int	headers(int *msgvec);
495196c7f05SJoshua M. Clulow extern int	headline_alloc(headline_t **);
496196c7f05SJoshua M. Clulow extern void	headline_free(headline_t *);
497196c7f05SJoshua M. Clulow extern void	headline_reset(headline_t *);
498eb2b0a61Sas extern int	help(void);
499eb2b0a61Sas extern char	*helppath(char *file);
500eb2b0a61Sas extern char	*hfield(char field[], struct message *mp,
501eb2b0a61Sas 		    char *(*add)(char *, char *));
502eb2b0a61Sas extern void	holdsigs(void);
503eb2b0a61Sas extern int	icequal(register char *s1, register char *s2);
504eb2b0a61Sas extern int	ifcmd(char **argv);
505eb2b0a61Sas extern int	igfield(char *list[]);
506eb2b0a61Sas extern int	inc(void);
507eb2b0a61Sas extern void	inithost(void);
508eb2b0a61Sas extern int	isdir(char name[]);
509196c7f05SJoshua M. Clulow extern boolean_t is_headline(const char *);
510eb2b0a61Sas extern int	ishfield(char linebuf[], char field[]);
511eb2b0a61Sas extern int	ishost(char *sys, char *rest);
512eb2b0a61Sas extern int	isign(char *field, int saving);
513eb2b0a61Sas extern void	istrcpy(char *dest, int dstsize, char *src);
514eb2b0a61Sas extern void	lcwrite(char *fn, FILE *fi, FILE *fo, int addnl);
515eb2b0a61Sas extern void	load(char *name);
516eb2b0a61Sas extern int	loadmsg(char str[]);
517eb2b0a61Sas extern int	lock(FILE *fp, char *mode, int blk);
518eb2b0a61Sas extern void	lockmail(void);
519eb2b0a61Sas extern int	mail(char **people);
520eb2b0a61Sas extern void	mail1(struct header *hp, int use_to, char *orig_to);
521eb2b0a61Sas extern void	mapf(register struct name *np, char *from);
522eb2b0a61Sas extern int	mboxit(int msgvec[]);
523eb2b0a61Sas extern void	mechk(struct name *names);
524eb2b0a61Sas extern int	member(register char *realfield,
525eb2b0a61Sas 		    register struct ignore **table);
526eb2b0a61Sas extern int	messize(int *msgvec);
527eb2b0a61Sas extern void	minit(void);
528eb2b0a61Sas extern int	more(int *msgvec);
529eb2b0a61Sas extern long	msend(struct message *mailp, FILE *obuf,
530eb2b0a61Sas 		    int flag, int (*fp)(const char *, FILE *));
531eb2b0a61Sas extern int	my_fclose(register FILE *iop);
532eb2b0a61Sas extern FILE	*my_fopen(char *file, char *mode);
533eb2b0a61Sas extern char	*nameof(register struct message *mp);
534eb2b0a61Sas extern char	*netmap(char name[], char from[]);
535eb2b0a61Sas extern int	newfileinfo(int start);
536eb2b0a61Sas extern int	next(int *msgvec);
537eb2b0a61Sas extern int	npclose(FILE *ptr);
538eb2b0a61Sas extern FILE	*npopen(char *cmd, char *mode);
539eb2b0a61Sas extern char	*nstrcpy(char *dst, int dstsize, char *src);
540eb2b0a61Sas extern char	*nstrcat(char *dst, int dstsize, char *src);
541eb2b0a61Sas extern int	null(char *e);
542eb2b0a61Sas extern int	outof(struct name *names, FILE *fo);
5437c478bd9Sstevel@tonic-gate extern struct name	*outpre(struct name *to);
544eb2b0a61Sas extern void	panic(char *str);
545196c7f05SJoshua M. Clulow extern int	parse_headline(const char *, headline_t *);
546eb2b0a61Sas extern int	pcmdlist(void);
547eb2b0a61Sas extern int	pdot(void);
548eb2b0a61Sas extern int	preserve(int *msgvec);
549eb2b0a61Sas extern void	printgroup(char name[]);
550eb2b0a61Sas extern void	printhead(int mesg);
551eb2b0a61Sas extern int	puthead(struct header *hp, FILE *fo, int w, long clen);
552eb2b0a61Sas extern int	pversion(char *e);
553eb2b0a61Sas extern void	quit(int noremove);
554eb2b0a61Sas extern int	readline(FILE *ibuf, char *linebuf);
555eb2b0a61Sas extern void	receipt(struct message *mp);
556eb2b0a61Sas extern void	relsesigs(void);
557eb2b0a61Sas extern int	removefile(char name[]);
558eb2b0a61Sas extern int	replyall(int *msgvec);
559eb2b0a61Sas extern int	replysender(int *msgvec);
560eb2b0a61Sas extern int	respond(int *msgvec);
561eb2b0a61Sas extern int	retfield(char *list[]);
562eb2b0a61Sas extern int	rexit(int e);
563eb2b0a61Sas extern char	*safeexpand(char name[]);
564eb2b0a61Sas extern void	*salloc(unsigned size);
565eb2b0a61Sas extern void	*srealloc(void *optr, unsigned size);
566eb2b0a61Sas extern int	samebody(register char *user, register char *addr,
567eb2b0a61Sas 		    int fuzzy);
568eb2b0a61Sas extern int	save(char str[]);
569eb2b0a61Sas extern void	savedead(int s);
570eb2b0a61Sas extern char	*savestr(char *str);
571eb2b0a61Sas extern int	schdir(char *str);
572eb2b0a61Sas extern int	screensize(void);
573eb2b0a61Sas extern int	scroll(char arg[]);
574eb2b0a61Sas extern int	sendm(char *str);
575eb2b0a61Sas extern int	set(char **arglist);
576eb2b0a61Sas extern void	setclen(register struct message *mp);
577eb2b0a61Sas extern int	setfile(char *name, int isedit);
578eb2b0a61Sas extern FILE	*setinput(register struct message *mp);
579eb2b0a61Sas extern void	setptr(register FILE *ibuf);
580eb2b0a61Sas extern int	shell(char *str);
5817c478bd9Sstevel@tonic-gate #ifndef sigchild
5827c478bd9Sstevel@tonic-gate extern void		sigchild(void);
5837c478bd9Sstevel@tonic-gate #endif
5847c478bd9Sstevel@tonic-gate #ifndef sigset
5857c478bd9Sstevel@tonic-gate extern void		(*sigset())();
5867c478bd9Sstevel@tonic-gate #endif
5877c478bd9Sstevel@tonic-gate extern char		*skin(char *name);
5887c478bd9Sstevel@tonic-gate extern char		*snarf(char linebuf[], int *flag, int erf);
5897c478bd9Sstevel@tonic-gate extern int		source(char name[]);
5907c478bd9Sstevel@tonic-gate extern char		*splice(char *addr, char *hdr);
5917c478bd9Sstevel@tonic-gate extern int		sput(char str[]);
5927c478bd9Sstevel@tonic-gate extern void		sreset(void);
5937c478bd9Sstevel@tonic-gate extern void		stop(int s);
5947c478bd9Sstevel@tonic-gate extern int		stouch(int msgvec[]);
5957c478bd9Sstevel@tonic-gate extern int		substr(char *string1, char *string2);
5967c478bd9Sstevel@tonic-gate extern int		swrite(char str[]);
5977c478bd9Sstevel@tonic-gate extern struct name	*tailof(struct name *name);
5987c478bd9Sstevel@tonic-gate extern void		tinit(void);
5997c478bd9Sstevel@tonic-gate extern int		tmail(void);
6007c478bd9Sstevel@tonic-gate extern int		top(int *msgvec);
6017c478bd9Sstevel@tonic-gate extern void		touch(int mesg);
6027c478bd9Sstevel@tonic-gate extern struct name	*translate(struct name *np);
6037c478bd9Sstevel@tonic-gate extern int		type(int *msgvec);
6047c478bd9Sstevel@tonic-gate extern int		undelete(int *msgvec);
6057c478bd9Sstevel@tonic-gate extern int		ungroup(char **argv);
6067c478bd9Sstevel@tonic-gate extern int		unigfield(char *list[]);
6077c478bd9Sstevel@tonic-gate extern void		unlockmail(void);
6087c478bd9Sstevel@tonic-gate extern char		**unpack(struct name *np);
6097c478bd9Sstevel@tonic-gate extern int		unread(int msgvec[]);
6107c478bd9Sstevel@tonic-gate extern int		unretfield(char *list[]);
6117c478bd9Sstevel@tonic-gate extern int		unset(char **arglist);
6127c478bd9Sstevel@tonic-gate extern int		unstack(void);
6137c478bd9Sstevel@tonic-gate extern char		*unuucp(char *name);
6147c478bd9Sstevel@tonic-gate extern struct name	*usermap(struct name *names);
6157c478bd9Sstevel@tonic-gate extern char		*value(char name[]);
6167c478bd9Sstevel@tonic-gate extern char		*vcopy(char str[]);
6177c478bd9Sstevel@tonic-gate extern void		vfree(register char *cp);
6187c478bd9Sstevel@tonic-gate extern int		visual(int *msgvec);
6197c478bd9Sstevel@tonic-gate extern char		*yankword(char *name, char *word, int sz, int comma);
6217c478bd9Sstevel@tonic-gate /*
6227c478bd9Sstevel@tonic-gate  * These functions are defined in libmail.a
6237c478bd9Sstevel@tonic-gate  */
6247c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6257c478bd9Sstevel@tonic-gate extern "C" {
6267c478bd9Sstevel@tonic-gate #endif
6277c478bd9Sstevel@tonic-gate extern int		delempty(mode_t, char *);
6287c478bd9Sstevel@tonic-gate extern char		*maildomain(void);
6297c478bd9Sstevel@tonic-gate extern void		touchlock(void);
6307c478bd9Sstevel@tonic-gate extern char		*xgetenv(char *);
6317c478bd9Sstevel@tonic-gate extern int		xsetenv(char *);
6327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6337c478bd9Sstevel@tonic-gate }
6347c478bd9Sstevel@tonic-gate #endif
6367c478bd9Sstevel@tonic-gate /*
6377c478bd9Sstevel@tonic-gate  * Standard functions from the C library.
6387c478bd9Sstevel@tonic-gate  * These are all defined in <stdlib.h> and <wait.h> in SVr4.
6397c478bd9Sstevel@tonic-gate  */
6407c478bd9Sstevel@tonic-gate #ifdef preSVr4
6417c478bd9Sstevel@tonic-gate extern long		atol();
6427c478bd9Sstevel@tonic-gate extern char		*getcwd();
6437c478bd9Sstevel@tonic-gate extern char		*calloc();
6447c478bd9Sstevel@tonic-gate extern char		*getenv();
6457c478bd9Sstevel@tonic-gate extern void		exit();
6467c478bd9Sstevel@tonic-gate extern void		free();
6477c478bd9Sstevel@tonic-gate extern char		*malloc();
6487c478bd9Sstevel@tonic-gate extern time_t		time();
6497c478bd9Sstevel@tonic-gate extern long		ulimit();
6507c478bd9Sstevel@tonic-gate extern int		utime();
6517c478bd9Sstevel@tonic-gate extern int		wait();
6527c478bd9Sstevel@tonic-gate extern int		fputs();
6537c478bd9Sstevel@tonic-gate #endif
6557c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6567c478bd9Sstevel@tonic-gate }
6577c478bd9Sstevel@tonic-gate #endif
6597c478bd9Sstevel@tonic-gate #endif	/* _MAILX_DEF_H */