xref: /titanic_44/usr/src/cmd/mailx/init.c (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright (c) 1998 by Sun Microsystems, Inc.
28  * All rights reserved.
29  */
30 
31 /*
32  * University Copyright- Copyright (c) 1982, 1986, 1988
33  * The Regents of the University of California
34  * All Rights Reserved
35  *
36  * University Acknowledgment- Portions of this document are derived from
37  * software developed by the University of California, Berkeley, and its
38  * contributors.
39  */
40 
41 #pragma ident	"%Z%%M%	%I%	%E% SMI"
42 
43 /*
44  * mailx -- a modified version of a University of California at Berkeley
45  *	mail program
46  *
47  * A bunch of global variable declarations lie herein.
48  *
49  * All global externs are declared in def.h. All variables are initialized
50  * here!
51  *
52  * !!!!!IF YOU CHANGE (OR ADD) IT HERE, DO IT THERE ALSO !!!!!!!!
53  *
54  */
55 
56 #include	"def.h"
57 #include	<grp.h>
58 #include	<pwd.h>
59 #include	<sys/utsname.h>
60 
61 int	Fflag = 0;			/* -F option (followup) */
62 int	Hflag = 0;			/* print headers and exit */
63 char	*Tflag;				/* -T temp file for netnews */
64 int	UnUUCP = 0;			/* -U flag */
65 char	**altnames;			/* List of alternate names for user */
66 int	askme;
67 int	baud;				/* Output baud rate */
68 char	*bflag;				/* Bcc given from non tty */
69 char	*binmsg = "*** Message content is not printable: pipe to command or save to a file ***";
70 char	*cflag;				/* Cc given from non tty */
71 int	cond;				/* Current state of conditional exc. */
72 NODE	*curptr = NOFP;
73 int	debug;				/* Debug flag set */
74 struct	message	*dot;			/* Pointer to current message */
75 int	edit;				/* Indicates editing a file */
76 char	*editfile;			/* Name of file being edited */
77 int	exitflg = 0;			/* -e for mail test */
78 NODE	*fplist = NOFP;
79 struct	grouphead	*groups[HSHSIZE];/* Pointer to active groups */
80 int	hflag;				/* Sequence number for network -h */
81 char	homedir[PATHSIZE];		/* Name of home directory */
82 struct	ignore		*ignore[HSHSIZE];/* Pointer to ignored fields */
83 int	image;				/* File descriptor for image of msg */
84 FILE	*input;				/* Current command input file */
85 int	intty;				/* True if standard input a tty */
86 int	issysmbox;			/* mailname is a system mailbox */
87 FILE	*itf;				/* Input temp file buffer */
88 int	lexnumber;			/* Number of TNUMBER from scan() */
89 char	lexstring[STRINGLEN];		/* String from TSTRING, scan() */
90 int	loading;			/* Loading user definitions */
91 char	*lockname;			/* named used for locking in /var/mail */
92 #ifdef	USR_SPOOL_MAIL
93 char	*maildir = "/usr/spool/mail/";	/* directory for mail files */
94 #else
95 # ifdef preSVr4
96 char	*maildir = "/usr/mail/";	/* directory for mail files */
97 # else
98 char	*maildir = "/var/mail/";	/* directory for mail files */
99 # endif
100 #endif
101 char	mailname[PATHSIZE];		/* Name of /var/mail system mailbox */
102 off_t	mailsize;			/* Size of system mailbox */
103 int	maxfiles;			/* Maximum number of open files */
104 struct	message	*message;		/* The actual message structure */
105 int	msgCount;			/* Count of messages read in */
106 gid_t	myegid;
107 uid_t	myeuid;
108 char	myname[PATHSIZE];		/* My login id */
109 pid_t	mypid;				/* Current process id */
110 gid_t	myrgid;
111 uid_t	myruid;
112 int	newsflg = 0;			/* -I option for netnews */
113 char	noheader;			/* Suprress initial header listing */
114 int	noreset;			/* String resets suspended */
115 char	nosrc;				/* Don't source /etc/mail/mailx.rc */
116 int	nretained;			/* Number of retained fields */
117 int	numberstack[REGDEP];		/* Stack of regretted numbers */
118 char	origname[PATHSIZE];		/* Name of mailfile before expansion */
119 FILE	*otf;				/* Output temp file buffer */
120 int	outtty;				/* True if standard output a tty */
121 FILE	*pipef;				/* Pipe file we have opened */
122 char	*progname;			/* program name (argv[0]) */
123 char	*prompt = NOSTR;		/* prompt string */
124 int	rcvmode;			/* True if receiving mail */
125 int	readonly;			/* Will be unable to rewrite file */
126 int	regretp;			/* Pointer to TOS of regret tokens */
127 int	regretstack[REGDEP];		/* Stack of regretted tokens */
128 struct	ignore		*retain[HSHSIZE];/* Pointer to retained fields */
129 char	*rflag;				/* -r address for network */
130 int	rmail;				/* Being called as rmail */
131 int	sawcom;				/* Set after first command */
132 int	selfsent;			/* User sent self something */
133 int	senderr;			/* An error while checking */
134 int	rpterr;				/* An error msg was sent to stderr */
135 char	*sflag;				/* Subject given from non tty */
136 int	sourcing;			/* Currently reading variant file */
137 int	space;				/* Current maximum number of messages */
138 jmp_buf	srbuf;
139 int	tflag;				/* Read headers from text */
140 /*
141  * The pointers for the string allocation routines,
142  * there are NSPACE independent areas.
143  * The first holds STRINGSIZE bytes, the next
144  * twice as much, and so on.
145  */
146 struct strings stringdope[NSPACE];
147 char	*stringstack[REGDEP];		/* Stack of regretted strings */
148 char	tempEdit[TMPSIZ];
149 char	tempMail[TMPSIZ];
150 char	tempMesg[TMPSIZ];
151 char	tempQuit[TMPSIZ];
152 char	tempResid[PATHSIZE];		/* temp file in :saved */
153 char	tempZedit[TMPSIZ];
154 uid_t	uid;				/* The invoker's user id */
155 static struct utimbuf	utimeb;
156 struct utimbuf	*utimep = &utimeb;
157 struct	var	*variables[HSHSIZE];	/* Pointer to active var list */
158 int	receipt_flg = 0;		/* Flag for return receipt */
159