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