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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*b7d62af5Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*b7d62af5Sceastha /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*b7d62af5Sceastha /* All Rights Reserved */ 29*b7d62af5Sceastha 307c478bd9Sstevel@tonic-gate #ifndef _MAIL_H 317c478bd9Sstevel@tonic-gate #define _MAIL_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * All global externs defined here. All variables are initialized 377c478bd9Sstevel@tonic-gate * in init.c 387c478bd9Sstevel@tonic-gate * 397c478bd9Sstevel@tonic-gate * !!!!!IF YOU CHANGE (OR ADD) IT HERE, DO IT THERE ALSO !!!!!!!! 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate #include <errno.h> 437c478bd9Sstevel@tonic-gate #include <fcntl.h> 447c478bd9Sstevel@tonic-gate #include <stdio.h> 457c478bd9Sstevel@tonic-gate #include <ctype.h> 467c478bd9Sstevel@tonic-gate #include <sys/types.h> 477c478bd9Sstevel@tonic-gate #include <errno.h> 487c478bd9Sstevel@tonic-gate #include <pwd.h> 497c478bd9Sstevel@tonic-gate #include <signal.h> 507c478bd9Sstevel@tonic-gate #include <string.h> 517c478bd9Sstevel@tonic-gate #include <grp.h> 527c478bd9Sstevel@tonic-gate /* The following is a kludge to allow for inconsistent header files in SVR4 */ 537c478bd9Sstevel@tonic-gate #define _CLOCK_T 547c478bd9Sstevel@tonic-gate #include <time.h> 557c478bd9Sstevel@tonic-gate #include <sys/stat.h> 567c478bd9Sstevel@tonic-gate #include <setjmp.h> 577c478bd9Sstevel@tonic-gate #include <sys/utsname.h> 587c478bd9Sstevel@tonic-gate #include <limits.h> 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #ifdef SVR3 617c478bd9Sstevel@tonic-gate struct utimbuf { 627c478bd9Sstevel@tonic-gate time_t actime; 637c478bd9Sstevel@tonic-gate time_t modtime; 647c478bd9Sstevel@tonic-gate }; 657c478bd9Sstevel@tonic-gate #else 667c478bd9Sstevel@tonic-gate # include <utime.h> 677c478bd9Sstevel@tonic-gate #endif 687c478bd9Sstevel@tonic-gate #include "libmail.h" 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* The following typedefs must be used in SVR4 */ 717c478bd9Sstevel@tonic-gate #ifdef SVR3 727c478bd9Sstevel@tonic-gate # ifndef sun 737c478bd9Sstevel@tonic-gate typedef int gid_t; 747c478bd9Sstevel@tonic-gate typedef int uid_t; 757c478bd9Sstevel@tonic-gate # endif 767c478bd9Sstevel@tonic-gate typedef int pid_t; 777c478bd9Sstevel@tonic-gate #endif 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #define CHILD 0 807c478bd9Sstevel@tonic-gate #define SAME 0 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate #define BELL 07 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate # define PIPER "/usr/lib/mail/mail_pipe" 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #define SENDMAIL "/usr/lib/sendmail" 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #define CERROR -1 897c478bd9Sstevel@tonic-gate #define CSUCCESS 0 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #define TRUE 1 927c478bd9Sstevel@tonic-gate #define FALSE 0 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #define HEAD 1 957c478bd9Sstevel@tonic-gate #define TAIL 0 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate #define REAL 1 987c478bd9Sstevel@tonic-gate #define DEFAULT 0 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* findSurg() return values */ 1017c478bd9Sstevel@tonic-gate #define NOMATCH -1 1027c478bd9Sstevel@tonic-gate #define DELIVER 0 1037c478bd9Sstevel@tonic-gate #define POSTDELIVER 1 1047c478bd9Sstevel@tonic-gate #define DENY 2 1057c478bd9Sstevel@tonic-gate #define TRANSLATE 3 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* sendsurg() return values */ 1087c478bd9Sstevel@tonic-gate #define FAILURE 0 1097c478bd9Sstevel@tonic-gate #define CONTINUE 1 1107c478bd9Sstevel@tonic-gate #define SUCCESS 2 1117c478bd9Sstevel@tonic-gate /* TRANSLATE 3 */ 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #define HDRSIZ 1024 /* maximum length of header line */ 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #define E_FLGE 1 /* flge error */ 1167c478bd9Sstevel@tonic-gate #define E_FLGE_OM 2 /* flgE error, mail present but already accessed */ 1177c478bd9Sstevel@tonic-gate #define E_REMOTE 1 /* unknown remote */ 1187c478bd9Sstevel@tonic-gate #define E_FILE 2 /* file error */ 1197c478bd9Sstevel@tonic-gate #define E_SPACE 3 /* no space */ 1207c478bd9Sstevel@tonic-gate #define E_FRWD 4 /* cannot forward */ 1217c478bd9Sstevel@tonic-gate #define E_SYNTAX 5 /* syntax error */ 1227c478bd9Sstevel@tonic-gate #define E_FRWL 6 /* forwarding loop */ 1237c478bd9Sstevel@tonic-gate #define E_SNDR 7 /* invalid sender */ 1247c478bd9Sstevel@tonic-gate #define E_USER 8 /* invalid user */ 1257c478bd9Sstevel@tonic-gate #define E_FROM 9 /* too many From lines */ 1267c478bd9Sstevel@tonic-gate #define E_PERM 10 /* bad permissions */ 1277c478bd9Sstevel@tonic-gate #define E_MBOX 11 /* mbox problem */ 1287c478bd9Sstevel@tonic-gate #define E_TMP 12 /* temporary file problem */ 1297c478bd9Sstevel@tonic-gate #define E_DEAD 13 /* Cannot create dead.letter */ 1307c478bd9Sstevel@tonic-gate #define E_UNBND 14 /* Unbounded forwarding */ 1317c478bd9Sstevel@tonic-gate #define E_LOCK 15 /* cannot create lock file */ 1327c478bd9Sstevel@tonic-gate #define E_GROUP 16 /* no group id of 'mail' */ 1337c478bd9Sstevel@tonic-gate #define E_MEM 17 /* malloc failure */ 1347c478bd9Sstevel@tonic-gate #define E_FORK 18 /* could not fork */ 1357c478bd9Sstevel@tonic-gate #define E_PIPE 19 /* could not pipe */ 1367c478bd9Sstevel@tonic-gate #define E_OWNR 20 /* invoker does not own mailfile */ 1377c478bd9Sstevel@tonic-gate #define E_DENY 21 /* permission denied by mailsurr file */ 1387c478bd9Sstevel@tonic-gate #define E_SURG 22 /* surrogate command failed - rc != 0 || 99 */ 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate #define H_AFWDCNT 1 /* "Auto-Forward-Count:" */ 1417c478bd9Sstevel@tonic-gate #define H_AFWDFROM 2 /* "Auto-Forwarded-From:" */ 1427c478bd9Sstevel@tonic-gate #define H_CLEN 3 /* "Content-Length:" */ 1437c478bd9Sstevel@tonic-gate #define H_CTYPE 4 /* "Content-Type:" */ 1447c478bd9Sstevel@tonic-gate #define H_DATE 5 /* "Date:" */ 1457c478bd9Sstevel@tonic-gate #define H_DEFOPTS 6 /* "Default-Options:" */ 1467c478bd9Sstevel@tonic-gate #define H_EOH 7 /* "End-of-Header:" */ 1477c478bd9Sstevel@tonic-gate #define H_FROM 8 /* "From " */ 1487c478bd9Sstevel@tonic-gate #define H_FROM1 9 /* ">From " */ 1497c478bd9Sstevel@tonic-gate #define H_FROM2 10 /* "From: " */ 1507c478bd9Sstevel@tonic-gate #define H_MIMEVERS 11 /* "MIME-Version:" */ 1517c478bd9Sstevel@tonic-gate #define H_MTSID 12 /* "MTS-Message-ID:" */ 1527c478bd9Sstevel@tonic-gate #define H_MTYPE 13 /* "Message-Type:" */ 1537c478bd9Sstevel@tonic-gate #define H_MVERS 14 /* "Message-Version:" */ 1547c478bd9Sstevel@tonic-gate #define H_MSVC 15 /* "Message-Service:" */ 1557c478bd9Sstevel@tonic-gate #define H_RECEIVED 16 /* "Received:" */ 1567c478bd9Sstevel@tonic-gate #define H_RVERS 17 /* "Report-Version:" */ 1577c478bd9Sstevel@tonic-gate #define H_SUBJ 18 /* "Subject:" */ 1587c478bd9Sstevel@tonic-gate #define H_TO 19 /* "To:" */ 1597c478bd9Sstevel@tonic-gate #define H_TCOPY 20 /* ">To:" */ 1607c478bd9Sstevel@tonic-gate #define H_TROPTS 21 /* "Transport-Options:" */ 1617c478bd9Sstevel@tonic-gate #define H_UAID 22 /* "UA-Content-ID:" */ 1627c478bd9Sstevel@tonic-gate #define H_DAFWDFROM 23 /* Hold A-F-F when sending Del. Notf. */ 1637c478bd9Sstevel@tonic-gate #define H_DTCOPY 24 /* Hold ">To:" when sending Del. Notf.*/ 1647c478bd9Sstevel@tonic-gate #define H_DRECEIVED 25 /* Hold Rcvd: when sending Del. Notf.*/ 1657c478bd9Sstevel@tonic-gate #define H_CONT 26 /* Continuation of previous line */ 1667c478bd9Sstevel@tonic-gate #define H_NAMEVALUE 27 /* unrecognized "name: value" hdr line*/ 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* MTA Transport Options */ 1697c478bd9Sstevel@tonic-gate #define DELIVERY 001 1707c478bd9Sstevel@tonic-gate #define NODELIVERY 002 1717c478bd9Sstevel@tonic-gate #define REPORT 010 1727c478bd9Sstevel@tonic-gate #define RETURN 020 1737c478bd9Sstevel@tonic-gate #define IGNORE 040 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate /* 1767c478bd9Sstevel@tonic-gate copylet flags 1777c478bd9Sstevel@tonic-gate */ 1787c478bd9Sstevel@tonic-gate #define REMOTE 1 /* remote mail, add rmtmsg */ 1797c478bd9Sstevel@tonic-gate #define ORDINARY 2 1807c478bd9Sstevel@tonic-gate #define ZAP 3 /* zap header and trailing empty line */ 1817c478bd9Sstevel@tonic-gate #define FORWARD 4 1827c478bd9Sstevel@tonic-gate #define TTY 5 /* suppress binary to tty */ 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate #define LSIZE (2*BUFSIZ) /* maximum size of a line */ 1857c478bd9Sstevel@tonic-gate #define MAXLET 1000 /* maximum number of letters */ 1867c478bd9Sstevel@tonic-gate #define FROMLEVELS 20 /* maxium number of forwards */ 1877c478bd9Sstevel@tonic-gate #ifdef FILENAME_MAX 1887c478bd9Sstevel@tonic-gate # define MAXFILENAME FILENAME_MAX /* max length of a filename */ 1897c478bd9Sstevel@tonic-gate #else 1907c478bd9Sstevel@tonic-gate # define MAXFILENAME 512 /* max length of a filename */ 1917c478bd9Sstevel@tonic-gate #endif 1927c478bd9Sstevel@tonic-gate #define DEADPERM 0600 /* permissions of dead.letter */ 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate #ifndef MFMODE 1957c478bd9Sstevel@tonic-gate #define MFMODE 0660 /* create mode for `/var/mail' files */ 1967c478bd9Sstevel@tonic-gate #endif 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate #define A_OK 0 /* return value for access */ 1997c478bd9Sstevel@tonic-gate #define A_EXECUTE 1 2007c478bd9Sstevel@tonic-gate #define A_EXIST 0 /* access check for existence */ 2017c478bd9Sstevel@tonic-gate #define A_WRITE 2 /* access check for write permission */ 2027c478bd9Sstevel@tonic-gate #define A_READ 4 /* access check for read permission */ 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate # define MAILSURR "/etc/mail/mailsurr" 2057c478bd9Sstevel@tonic-gate # define MAILCNFG "/etc/mail/mailcnfg" 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate struct hdr { 2087c478bd9Sstevel@tonic-gate char *tag; 2097c478bd9Sstevel@tonic-gate int default_display; 2107c478bd9Sstevel@tonic-gate }; 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate struct hdrs { 2137c478bd9Sstevel@tonic-gate struct hdrs *next; 2147c478bd9Sstevel@tonic-gate struct hdrs *prev; 2157c478bd9Sstevel@tonic-gate struct hdrs *cont; /* Continuation lines */ 2167c478bd9Sstevel@tonic-gate char value[HDRSIZ+1]; 2177c478bd9Sstevel@tonic-gate }; 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate struct hdrlines { 2207c478bd9Sstevel@tonic-gate struct hdrs *head; 2217c478bd9Sstevel@tonic-gate struct hdrs *tail; 2227c478bd9Sstevel@tonic-gate }; 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate typedef struct recip { 2257c478bd9Sstevel@tonic-gate struct recip *next; 2267c478bd9Sstevel@tonic-gate char *name; 2277c478bd9Sstevel@tonic-gate } recip; 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate typedef struct reciplist { 2307c478bd9Sstevel@tonic-gate recip *last_recip; 2317c478bd9Sstevel@tonic-gate recip recip_list; 2327c478bd9Sstevel@tonic-gate } reciplist; 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate struct let { 2357c478bd9Sstevel@tonic-gate long adr; /* offset in mailfile of letter n */ 2367c478bd9Sstevel@tonic-gate char change; /* disposition status of letter n */ 2377c478bd9Sstevel@tonic-gate char text; /* 1 ==> text content, 0 ==> binary content. 2387c478bd9Sstevel@tonic-gate * This is determined INDEPENDENTLY of what 2397c478bd9Sstevel@tonic-gate * the Content-type, if present, says... 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate }; 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate typedef enum t_surrtype 2447c478bd9Sstevel@tonic-gate { 2457c478bd9Sstevel@tonic-gate t_eof, t_transport = '<', 2467c478bd9Sstevel@tonic-gate t_accept = 'a', t_deny = 'd', 2477c478bd9Sstevel@tonic-gate t_translate = 't', t_postprocess = '>' 2487c478bd9Sstevel@tonic-gate } t_surrtype; 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate typedef struct t_surrfile 2517c478bd9Sstevel@tonic-gate { 2527c478bd9Sstevel@tonic-gate /* originator's regular expression */ 2537c478bd9Sstevel@tonic-gate string *orig_pattern; 2547c478bd9Sstevel@tonic-gate char *orig_regex; 2557c478bd9Sstevel@tonic-gate int orig_reglen; 2567c478bd9Sstevel@tonic-gate int orig_nbra; 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate /* recipient's regular expression */ 2597c478bd9Sstevel@tonic-gate string *recip_pattern; 2607c478bd9Sstevel@tonic-gate char *recip_regex; 2617c478bd9Sstevel@tonic-gate int recip_reglen; 2627c478bd9Sstevel@tonic-gate int recip_nbra; 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate /* the type of the command string */ 2657c478bd9Sstevel@tonic-gate t_surrtype surr_type; 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate int batchsize; /* transport translate postprocess */ 2687c478bd9Sstevel@tonic-gate char *statlist; /* transport */ 2697c478bd9Sstevel@tonic-gate string *cmd_left; /* transport translate postprocess */ 2707c478bd9Sstevel@tonic-gate string *cmd_right; /* transport translate postprocess */ 2717c478bd9Sstevel@tonic-gate int fullyresolved; /* translate */ 2727c478bd9Sstevel@tonic-gate } t_surrfile; 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate #ifdef __STDC__ 2757c478bd9Sstevel@tonic-gate # include <stdlib.h> 2767c478bd9Sstevel@tonic-gate # include <unistd.h> 2777c478bd9Sstevel@tonic-gate #else 2787c478bd9Sstevel@tonic-gate extern int chmod(); 2797c478bd9Sstevel@tonic-gate extern int close(); 2807c478bd9Sstevel@tonic-gate extern char *ctime(); 2817c478bd9Sstevel@tonic-gate extern int errno; 2827c478bd9Sstevel@tonic-gate extern int execl(); 2837c478bd9Sstevel@tonic-gate extern int execvp(); 2847c478bd9Sstevel@tonic-gate extern void exit(); 2857c478bd9Sstevel@tonic-gate extern char *getenv(); 2867c478bd9Sstevel@tonic-gate extern char *getlogin(); 2877c478bd9Sstevel@tonic-gate extern long ftell(); 2887c478bd9Sstevel@tonic-gate extern struct group *getgrnam(); 2897c478bd9Sstevel@tonic-gate extern struct passwd *getpwent(); 2907c478bd9Sstevel@tonic-gate extern struct passwd *getpwnam(); 2917c478bd9Sstevel@tonic-gate extern struct passwd *getpwuid(); 2927c478bd9Sstevel@tonic-gate extern char *malloc(); 2937c478bd9Sstevel@tonic-gate extern char *memcpy(); 2947c478bd9Sstevel@tonic-gate extern char *memmove(); 2957c478bd9Sstevel@tonic-gate extern char *mktemp(); 2967c478bd9Sstevel@tonic-gate extern char *realloc(); 2977c478bd9Sstevel@tonic-gate extern void setpwent(); 2987c478bd9Sstevel@tonic-gate extern unsigned sleep(); 2997c478bd9Sstevel@tonic-gate extern char *strchr(); 3007c478bd9Sstevel@tonic-gate extern char *strcpy(); 3017c478bd9Sstevel@tonic-gate extern char *strncpy(); 3027c478bd9Sstevel@tonic-gate extern char *strpbrk(); 3037c478bd9Sstevel@tonic-gate extern char *strrchr(); 3047c478bd9Sstevel@tonic-gate extern time_t time(); 3057c478bd9Sstevel@tonic-gate extern char *tempnam(); 3067c478bd9Sstevel@tonic-gate extern FILE *tmpfile(); 3077c478bd9Sstevel@tonic-gate extern int unlink(); 3087c478bd9Sstevel@tonic-gate #endif 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate extern char *optarg; /* for getopt */ 3117c478bd9Sstevel@tonic-gate extern int optind; 3127c478bd9Sstevel@tonic-gate extern char *sys_errlist[]; 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate #ifdef __STDC__ 3157c478bd9Sstevel@tonic-gate extern void Dout(char *subname, int level, char *fmt, ...); 3167c478bd9Sstevel@tonic-gate extern void Tout(char *subname, char *msg, ...); 3177c478bd9Sstevel@tonic-gate extern int add_recip(reciplist *plist, char *name, int checkdups); 3187c478bd9Sstevel@tonic-gate extern char *altcompile(const char *instring, char *expbuf, char *endbuf); 3197c478bd9Sstevel@tonic-gate extern int areforwarding(char *mailfile); 3207c478bd9Sstevel@tonic-gate extern void cat(char*, char*, char*); 3217c478bd9Sstevel@tonic-gate extern int ckdlivopts(int tcopy_hdr, int *svopts); 3227c478bd9Sstevel@tonic-gate extern void cksaved(char *user); 3237c478bd9Sstevel@tonic-gate extern int cksurg_rc(int surr_num, int rc); 3247c478bd9Sstevel@tonic-gate extern void clr_hinfo(void); 3257c478bd9Sstevel@tonic-gate extern void clrhdr(int hdrtype); 3267c478bd9Sstevel@tonic-gate extern void cmdexpand(int letnum, string *instr, string *outstr, char **lbraslist, char **lbraelist); 3277c478bd9Sstevel@tonic-gate extern void copyback(void); 3287c478bd9Sstevel@tonic-gate extern int copylet(int letnum, FILE *f, int type); 3297c478bd9Sstevel@tonic-gate extern void copymt(FILE *f1, FILE *f2); 3307c478bd9Sstevel@tonic-gate extern void createmf(uid_t uid, char *file); 3317c478bd9Sstevel@tonic-gate extern void del_reciplist (reciplist *list); 3327c478bd9Sstevel@tonic-gate extern void delete(int); 3337c478bd9Sstevel@tonic-gate extern void doFopt(void); 334*b7d62af5Sceastha extern void done(int) __NORETURN; 3357c478bd9Sstevel@tonic-gate extern void sig_done(int); 3367c478bd9Sstevel@tonic-gate extern FILE *doopen(char *file, char *type, int errnum); 3377c478bd9Sstevel@tonic-gate extern int dowait(pid_t pidval); 3387c478bd9Sstevel@tonic-gate extern void dumpaff(int type, int htype, int *didafflines, int *suppress, FILE *f); 3397c478bd9Sstevel@tonic-gate extern void dumprcv(int type, int htype, int *didrcvlines, int *suppress, FILE *f); 3407c478bd9Sstevel@tonic-gate extern void errmsg(int error_value, char *error_message); 3417c478bd9Sstevel@tonic-gate extern int findSurg(int letnum, string *execbuf, int flag, int *psurr_num, int *paccept, string *lorig, string *lrecipname); 3427c478bd9Sstevel@tonic-gate extern void gendeliv(FILE *fp, int rc, char *name); 3437c478bd9Sstevel@tonic-gate extern int getcomment(char *s, char *q); 3447c478bd9Sstevel@tonic-gate extern int gethead(int current, int all); 3457c478bd9Sstevel@tonic-gate extern int getline(char *ptr2line, int max, FILE *f); 3467c478bd9Sstevel@tonic-gate extern int getnumbr(char *s); 3477c478bd9Sstevel@tonic-gate extern int getsurr(FILE *fp, string *buf, int firstfield); 3487c478bd9Sstevel@tonic-gate extern void goback(int letnum); 3497c478bd9Sstevel@tonic-gate extern int init(void); 3507c478bd9Sstevel@tonic-gate extern void initsurrfile(void); 3517c478bd9Sstevel@tonic-gate extern int isheader(char *lp, int *ctfp); 3527c478bd9Sstevel@tonic-gate extern int isit(char *lp, int type); 3537c478bd9Sstevel@tonic-gate extern int islocal(char *user, uid_t *puid); 3547c478bd9Sstevel@tonic-gate extern int istext(unsigned char *s, int size); 3557c478bd9Sstevel@tonic-gate extern int legal(char *file); 3567c478bd9Sstevel@tonic-gate extern void lock(char *user); 357*b7d62af5Sceastha extern void madd_recip(reciplist *plist, char *name, int checkdups); 3587c478bd9Sstevel@tonic-gate extern char *mailcompile(string *pattern, int *retlen, int *retnbra); 3597c478bd9Sstevel@tonic-gate extern void mkdead(void); 3607c478bd9Sstevel@tonic-gate extern void mktmp(void); 3617c478bd9Sstevel@tonic-gate extern void mta_ercode(FILE *outfile); 3627c478bd9Sstevel@tonic-gate extern void new_reciplist (reciplist *list); 3637c478bd9Sstevel@tonic-gate extern int notme(char *fto, char *myname); 3647c478bd9Sstevel@tonic-gate extern int parse(int argc, char **argv); 3657c478bd9Sstevel@tonic-gate extern int pckaffspot(void); 3667c478bd9Sstevel@tonic-gate extern int pckrcvspot(void); 3677c478bd9Sstevel@tonic-gate extern void pickFrom(char *lineptr); 3687c478bd9Sstevel@tonic-gate extern int pipletr(int letter, char *command, int cltype); 3697c478bd9Sstevel@tonic-gate extern void poplist (int hdrtype, int where); 3707c478bd9Sstevel@tonic-gate extern int printhdr (int type, int hdrtype, struct hdrs *hptr, FILE *fp); 3717c478bd9Sstevel@tonic-gate extern void printmail(void); 3727c478bd9Sstevel@tonic-gate extern void pushlist(int hdrtype, int where, char *s, int contflg); 3737c478bd9Sstevel@tonic-gate extern void savdead(void); 3747c478bd9Sstevel@tonic-gate extern void savehdrs(char *s, int hdrtype); 3757c478bd9Sstevel@tonic-gate extern int sel_disp (int type, int hdrtype, char *s); 3767c478bd9Sstevel@tonic-gate extern int sendlist(reciplist *list, int letnum, int level); 3777c478bd9Sstevel@tonic-gate extern void sendmail(int argc, char **argv); 3787c478bd9Sstevel@tonic-gate extern int sendsurg(reciplist *plist, int letnum, int flag, int local); 3797c478bd9Sstevel@tonic-gate extern void setletr(int letter, int status); 3807c478bd9Sstevel@tonic-gate extern void (*setsig(int i, void(*f)()))(); 3817c478bd9Sstevel@tonic-gate extern void setsurg_bt(string *st, int *pbatchsize, int *presolved); 3827c478bd9Sstevel@tonic-gate extern char *setsurg_rc(string *st, int defreal, int *pbatchsize); 3837c478bd9Sstevel@tonic-gate extern char **setup_exec(char*); 3847c478bd9Sstevel@tonic-gate extern void stamp(void); 3857c478bd9Sstevel@tonic-gate extern int systm(char *s); 3867c478bd9Sstevel@tonic-gate extern void tmperr(void); 3877c478bd9Sstevel@tonic-gate extern string *tokdef(string *fld, string *tok, char *name); 3887c478bd9Sstevel@tonic-gate extern int translate(reciplist *plist, char *cmdstr, char *origname); 3897c478bd9Sstevel@tonic-gate extern void unlock(void); 3907c478bd9Sstevel@tonic-gate extern int validmsg(int); 3917c478bd9Sstevel@tonic-gate extern int wtmpf(char *str, int length); 3927c478bd9Sstevel@tonic-gate #else 3937c478bd9Sstevel@tonic-gate extern void Dout(); 3947c478bd9Sstevel@tonic-gate extern void Tout(); 3957c478bd9Sstevel@tonic-gate extern int add_recip(); 3967c478bd9Sstevel@tonic-gate extern char *altcompile(); 3977c478bd9Sstevel@tonic-gate extern int areforwarding(); 3987c478bd9Sstevel@tonic-gate extern void cat(); 3997c478bd9Sstevel@tonic-gate extern int ckdlivopts(); 4007c478bd9Sstevel@tonic-gate extern void cksaved(); 4017c478bd9Sstevel@tonic-gate extern int cksurg_rc(); 4027c478bd9Sstevel@tonic-gate extern void clr_hinfo(); 4037c478bd9Sstevel@tonic-gate extern void clrhdr(); 4047c478bd9Sstevel@tonic-gate extern void cmdexpand(); 4057c478bd9Sstevel@tonic-gate extern void copyback(); 4067c478bd9Sstevel@tonic-gate extern int copylet(); 4077c478bd9Sstevel@tonic-gate extern void copymt(); 4087c478bd9Sstevel@tonic-gate extern void createmf(); 4097c478bd9Sstevel@tonic-gate extern void del_reciplist (); 4107c478bd9Sstevel@tonic-gate extern void delete(); 4117c478bd9Sstevel@tonic-gate extern void doFopt(); 4127c478bd9Sstevel@tonic-gate extern void done(); 4137c478bd9Sstevel@tonic-gate extern void sig_done(); 4147c478bd9Sstevel@tonic-gate extern FILE *doopen(); 4157c478bd9Sstevel@tonic-gate extern int dowait(); 4167c478bd9Sstevel@tonic-gate extern void dumpaff(); 4177c478bd9Sstevel@tonic-gate extern void dumprcv(); 4187c478bd9Sstevel@tonic-gate extern void errmsg(); 4197c478bd9Sstevel@tonic-gate extern int findSurg(); 4207c478bd9Sstevel@tonic-gate extern void gendeliv(); 4217c478bd9Sstevel@tonic-gate extern int getcomment(); 4227c478bd9Sstevel@tonic-gate extern int gethead(); 4237c478bd9Sstevel@tonic-gate extern int getline(); 4247c478bd9Sstevel@tonic-gate extern int getnumbr(); 4257c478bd9Sstevel@tonic-gate extern int getsurr(); 4267c478bd9Sstevel@tonic-gate extern void goback(); 4277c478bd9Sstevel@tonic-gate extern int init(); 4287c478bd9Sstevel@tonic-gate extern void initsurrfile(); 4297c478bd9Sstevel@tonic-gate extern int isheader(); 4307c478bd9Sstevel@tonic-gate extern int isit(); 4317c478bd9Sstevel@tonic-gate extern int islocal(); 4327c478bd9Sstevel@tonic-gate extern int istext(); 4337c478bd9Sstevel@tonic-gate extern int legal(); 4347c478bd9Sstevel@tonic-gate extern void lock(); 435*b7d62af5Sceastha extern void madd_recip(); 4367c478bd9Sstevel@tonic-gate extern char *mailcompile(); 4377c478bd9Sstevel@tonic-gate extern void mkdead(); 4387c478bd9Sstevel@tonic-gate extern void mktmp(); 4397c478bd9Sstevel@tonic-gate extern void mta_ercode(); 4407c478bd9Sstevel@tonic-gate extern void new_reciplist (); 4417c478bd9Sstevel@tonic-gate extern int notme(); 4427c478bd9Sstevel@tonic-gate extern int parse(); 4437c478bd9Sstevel@tonic-gate extern int pckaffspot(); 4447c478bd9Sstevel@tonic-gate extern int pckrcvspot(); 4457c478bd9Sstevel@tonic-gate extern void pickFrom (); 4467c478bd9Sstevel@tonic-gate extern int pipletr(); 4477c478bd9Sstevel@tonic-gate extern void poplist (); 4487c478bd9Sstevel@tonic-gate extern int printhdr (); 4497c478bd9Sstevel@tonic-gate extern void printmail(); 4507c478bd9Sstevel@tonic-gate extern void pushlist(); 4517c478bd9Sstevel@tonic-gate extern void savdead(); 4527c478bd9Sstevel@tonic-gate extern void savehdrs(); 4537c478bd9Sstevel@tonic-gate extern int sel_disp (); 4547c478bd9Sstevel@tonic-gate extern int sendlist(); 4557c478bd9Sstevel@tonic-gate extern void sendmail(); 4567c478bd9Sstevel@tonic-gate extern int sendsurg(); 4577c478bd9Sstevel@tonic-gate extern void setletr(); 4587c478bd9Sstevel@tonic-gate extern void (*setsig())(); 4597c478bd9Sstevel@tonic-gate extern void setsurg_bt(); 4607c478bd9Sstevel@tonic-gate extern char *setsurg_rc(); 4617c478bd9Sstevel@tonic-gate extern char **setup_exec(); 4627c478bd9Sstevel@tonic-gate extern void stamp(); 4637c478bd9Sstevel@tonic-gate extern int systm(); 4647c478bd9Sstevel@tonic-gate extern void tmperr(); 4657c478bd9Sstevel@tonic-gate extern string *tokdef(); 4667c478bd9Sstevel@tonic-gate extern int translate(); 4677c478bd9Sstevel@tonic-gate extern void unlock(); 4687c478bd9Sstevel@tonic-gate extern int validmsg(); 4697c478bd9Sstevel@tonic-gate extern int wtmpf(); 4707c478bd9Sstevel@tonic-gate #endif 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate extern int ac; /* argument list count */ 4737c478bd9Sstevel@tonic-gate extern char **av; /* argument list */ 4747c478bd9Sstevel@tonic-gate extern int affbytecnt; /* Total bytes of Auto-Fwd. info in msg. */ 4757c478bd9Sstevel@tonic-gate extern int affcnt; /* Number of Auto-Fwd.-From: lines in msg. */ 4767c478bd9Sstevel@tonic-gate extern int Daffbytecnt; /* Hold affbytecnt when sending Deliv. Notif. */ 4777c478bd9Sstevel@tonic-gate extern int Daffcnt; /* Hold affcnt when sending Deliv. Notif. */ 4787c478bd9Sstevel@tonic-gate extern char binmsg[]; 4797c478bd9Sstevel@tonic-gate extern int changed; /* > 0 says mailfile has changed */ 4807c478bd9Sstevel@tonic-gate extern char datestring[60]; 4817c478bd9Sstevel@tonic-gate extern char dbgfname[20]; /* name of file for debugging output */ 4827c478bd9Sstevel@tonic-gate extern FILE *dbgfp; /* FILE* for debugging output */ 4837c478bd9Sstevel@tonic-gate extern char dead[]; /* name of dead.letter */ 4847c478bd9Sstevel@tonic-gate extern int debug; /* Controls debugging level. 0 ==> no debugging */ 4857c478bd9Sstevel@tonic-gate extern int delflg; 4867c478bd9Sstevel@tonic-gate extern int dflag; /* 1 says returning unsendable mail */ 4877c478bd9Sstevel@tonic-gate extern char *errlist[]; 4887c478bd9Sstevel@tonic-gate extern int error; /* Local value for error */ 4897c478bd9Sstevel@tonic-gate extern char *failsafe; /* $FAILSAFE */ 4907c478bd9Sstevel@tonic-gate extern int file_size; 4917c478bd9Sstevel@tonic-gate extern int flge; /* 1 ==> 'e' option specified */ 4927c478bd9Sstevel@tonic-gate extern int flgE; /* 1 ==> 'E' option specified */ 4937c478bd9Sstevel@tonic-gate extern int flgF; /* 1 ==> Installing/Removing Forwarding */ 4947c478bd9Sstevel@tonic-gate extern int flgf; /* 1 ==> 'f' option specified */ 4957c478bd9Sstevel@tonic-gate extern int flgh; /* 1 ==> 'h' option specified */ 4967c478bd9Sstevel@tonic-gate extern int flgm; 4977c478bd9Sstevel@tonic-gate extern int flgp; /* 1 ==> 'p' option specified */ 4987c478bd9Sstevel@tonic-gate extern int flgP; /* 1 ==> 'P' option specified */ 4997c478bd9Sstevel@tonic-gate extern int flgr; /* 1 ==> 'r' option -- print in fifo order */ 5007c478bd9Sstevel@tonic-gate extern int flgt; /* 1 ==> 't' option -- add To: line to letter */ 5017c478bd9Sstevel@tonic-gate extern int flgT; /* 1 ==> 'T' option specified */ 5027c478bd9Sstevel@tonic-gate extern int flgw; /* 1 ==> 'w' option specified */ 5037c478bd9Sstevel@tonic-gate extern int fnuhdrtype; /* type of first non-UNIX header line */ 5047c478bd9Sstevel@tonic-gate extern char forwmsg[]; /* " forwarded by %s" */ 5057c478bd9Sstevel@tonic-gate extern char frwlmsg[]; /* "Forwarding loop detected in mailfile" */ 5067c478bd9Sstevel@tonic-gate extern char fromS[1024]; /* stored here by sendmail for sendsurg */ 5077c478bd9Sstevel@tonic-gate extern char fromU[1024]; /* stored here by sendmail for sendsurg */ 5087c478bd9Sstevel@tonic-gate extern char frwrd[]; /* forwarding sentinel */ 5097c478bd9Sstevel@tonic-gate extern char fwdFrom[1024]; 5107c478bd9Sstevel@tonic-gate extern int goerr; /* counts parsing errors */ 5117c478bd9Sstevel@tonic-gate extern struct group *grpptr; /* pointer to struct group */ 5127c478bd9Sstevel@tonic-gate extern struct hdrlines hdrlines[H_CONT]; 5137c478bd9Sstevel@tonic-gate extern struct hdr header[]; /* H_* #define's used to index into array */ 5147c478bd9Sstevel@tonic-gate extern char *help[]; 5157c478bd9Sstevel@tonic-gate extern char *hmbox; /* pointer to $HOME/mbox */ 5167c478bd9Sstevel@tonic-gate extern char *hmdead; /* pointer to $HOME/dead.letter */ 5177c478bd9Sstevel@tonic-gate extern char *home; /* pointer to $HOME */ 5187c478bd9Sstevel@tonic-gate extern time_t iop; 5197c478bd9Sstevel@tonic-gate extern int interactive; /* 1 says user is interactive */ 5207c478bd9Sstevel@tonic-gate extern int ismail; /* default to program=mail */ 5217c478bd9Sstevel@tonic-gate extern int deliverflag; /* -d flag, bypass sendmail and go to mbox */ 5227c478bd9Sstevel@tonic-gate extern int fromflag; /* -f from_user while sending */ 5237c478bd9Sstevel@tonic-gate extern int keepdbgfile; /* does debug file get deleted at end? */ 5247c478bd9Sstevel@tonic-gate extern struct let let[MAXLET]; 5257c478bd9Sstevel@tonic-gate extern char *lettmp; /* pointer to tmp filename */ 5267c478bd9Sstevel@tonic-gate extern char lfil[MAXFILENAME]; 5277c478bd9Sstevel@tonic-gate extern char line[LSIZE]; /* holds a line of a letter in many places */ 5287c478bd9Sstevel@tonic-gate extern char *mailfile; /* pointer to mailfile */ 5297c478bd9Sstevel@tonic-gate extern char mailcnfg[]; /* /etc/mail/mailcnfg */ 5307c478bd9Sstevel@tonic-gate extern char maildir[]; /* directory for mail files */ 5317c478bd9Sstevel@tonic-gate extern gid_t mailgrp; /* numeric id of group 'mail' */ 5327c478bd9Sstevel@tonic-gate extern char mailsave[]; /* dir for save files */ 5337c478bd9Sstevel@tonic-gate extern char *mailsurr; /* surrogate file name */ 5347c478bd9Sstevel@tonic-gate extern FILE *malf; /* File pointer for mailfile */ 5357c478bd9Sstevel@tonic-gate extern int maxerr; /* largest value of error */ 5367c478bd9Sstevel@tonic-gate extern char mbox[]; /* name for mbox */ 5377c478bd9Sstevel@tonic-gate extern uid_t mf_uid; /* uid of user's mailfile */ 5387c478bd9Sstevel@tonic-gate extern gid_t mf_gid; /* gid of user's mailfile */ 5397c478bd9Sstevel@tonic-gate extern char *msgtype; 5407c478bd9Sstevel@tonic-gate extern char my_name[1024]; /* user's name who invoked this command */ 5417c478bd9Sstevel@tonic-gate extern char from_user[1024];/* name of user mail's from, used w/ -f */ 5427c478bd9Sstevel@tonic-gate extern uid_t my_euid; /* user's euid */ 5437c478bd9Sstevel@tonic-gate extern gid_t my_egid; /* user's egid */ 5447c478bd9Sstevel@tonic-gate extern uid_t my_uid; /* user's uid */ 5457c478bd9Sstevel@tonic-gate extern gid_t my_gid; /* user's gid */ 5467c478bd9Sstevel@tonic-gate extern int nlet; /* current number of letters in mailfile */ 5477c478bd9Sstevel@tonic-gate extern int onlet; /* number of letters in mailfile at startup*/ 5487c478bd9Sstevel@tonic-gate extern int optcnt; /* Number of options specified */ 5497c478bd9Sstevel@tonic-gate extern int orig_aff; /* orig. msg. contained H_AFWDFROM lines */ 5507c478bd9Sstevel@tonic-gate extern int orig_dbglvl; /* argument to -x invocation option */ 5517c478bd9Sstevel@tonic-gate extern int orig_rcv; /* orig. msg. contained H_RECEIVED lines */ 5527c478bd9Sstevel@tonic-gate extern int orig_tcopy; /* orig. msg. contained H_TCOPY lines */ 5537c478bd9Sstevel@tonic-gate extern struct passwd *pwd; /* holds passwd entry for this user */ 5547c478bd9Sstevel@tonic-gate extern int pflg; /* binary message display override flag */ 5557c478bd9Sstevel@tonic-gate extern int Pflg; /* Selective display flag; 1 ==> display all */ 5567c478bd9Sstevel@tonic-gate extern char *program; /* program name */ 5577c478bd9Sstevel@tonic-gate extern int rcvbytecnt; /* Total bytes of Received: info in msg. */ 5587c478bd9Sstevel@tonic-gate extern int Drcvbytecnt; /* Hold rcvbytecnt when sending Del. Notif. */ 5597c478bd9Sstevel@tonic-gate extern char *recipname; /* full recipient name/address */ 5607c478bd9Sstevel@tonic-gate extern int replying; /* 1 says we are replying to a letter */ 5617c478bd9Sstevel@tonic-gate extern char RFC822datestring[60];/* Date in RFC822 date format */ 5627c478bd9Sstevel@tonic-gate extern char rmtmsg[]; /* "remote from %s" */ 5637c478bd9Sstevel@tonic-gate extern char Rpath[1024]; /* return path to sender of message */ 5647c478bd9Sstevel@tonic-gate extern char rtrnmsg[]; /* "UNDELIVERABLE MAIL being returned by %s" */ 5657c478bd9Sstevel@tonic-gate extern int sav_errno; 5667c478bd9Sstevel@tonic-gate extern char savefile[MAXFILENAME]; /* holds filename of save file */ 5677c478bd9Sstevel@tonic-gate #ifdef __STDC__ 5687c478bd9Sstevel@tonic-gate extern void (*saveint)(int); 5697c478bd9Sstevel@tonic-gate #else 5707c478bd9Sstevel@tonic-gate extern void (*saveint)(); 5717c478bd9Sstevel@tonic-gate #endif 5727c478bd9Sstevel@tonic-gate extern char *seldisp[]; 5737c478bd9Sstevel@tonic-gate extern int sending; /* TRUE==>sending mail; FALSE==>printing mail */ 5747c478bd9Sstevel@tonic-gate extern char m_sendto[1024]; 5757c478bd9Sstevel@tonic-gate extern jmp_buf sjbuf; 5767c478bd9Sstevel@tonic-gate extern int surg_rc; /* exit code of surrogate command */ 5777c478bd9Sstevel@tonic-gate extern t_surrfile *surrfile; /* the compiled surrogate file */ 5787c478bd9Sstevel@tonic-gate extern int surr_len; /* # entries in surrogate file */ 5797c478bd9Sstevel@tonic-gate extern char *SURRcmdstr; /* save in case of FAILURE */ 5807c478bd9Sstevel@tonic-gate extern FILE *SURRerrfile; /* stderr from surrogate in case of failure */ 5817c478bd9Sstevel@tonic-gate extern char *thissys; /* Holds name of the system we are on */ 5827c478bd9Sstevel@tonic-gate extern FILE *tmpf; /* file pointer for temporary files */ 5837c478bd9Sstevel@tonic-gate extern mode_t umsave; 5847c478bd9Sstevel@tonic-gate extern struct utsname utsn; 5857c478bd9Sstevel@tonic-gate extern struct utimbuf *utimep; 5867c478bd9Sstevel@tonic-gate extern char uval[1024]; 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate #ifdef NOTDEF 5897c478bd9Sstevel@tonic-gate #ifdef sun 5907c478bd9Sstevel@tonic-gate #define _NFILE getdtablesize() 5917c478bd9Sstevel@tonic-gate #endif 5927c478bd9Sstevel@tonic-gate #endif /* NOTDEF */ 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate #endif /* _MAIL_H */ 595