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