int INCHAR
= 0; /*index of incremented character in
char version
[] = "Version 2/6/79";
char remote
[]= "$ remote **,onl";
char toss
[] = "$ sysout toss";
int remotsw
; /*toss-output flag*/
char *pp
= 0; /*recipient of mail*/
char *identf
= 0; /*ident card info*/
char gcosid
[13]; /*gcos userid*/
char cpflag
= 'l'; /*copy/link flag*/
int rmflag
= 0; /*remove flag*/
int gcdebug
= 0; /*GCOS debug switch*/
int archsw
= 0; /*archive switch*/
char buf
[80]; /*used by card */
int nact
= 0; /*number of non-null files to process.*/
int gsize
= 20; /*size of current file in GCOS blocks.*/
long usize
= 20*1200; /*size of current file in bytes.*/
FILE *tff
; /*temporary control card file*/
comopt(o
) /*routine to test for common options.*/
case 'n': /*new option to suppress mail. MRW*/
if(arg
[2] < '1' || arg
[2] > '3')
case 'Z': /*GCOS debugging switch*/
spool1() /*set up common initial GCOS control cards.*/
if((tff
= nfile(tfname
)) == NULL
){
fprintf(stderr
, "%s: Can't create %s.\n", NAME
, tfname
);
card('L', sprintf(buf
, "$ sgrade %c %s", grade
, version
) );
spool2() /*add final control cards, and spool job.*/
if(link(tfname
, dfname
) < 0){
fprintf(stderr
, "%s: Cannot rename %s\n", NAME
, tfname
);
execl("/usr/lib/dpd", "dpd", 0);
execl("/etc/dpd", "dpd", 0);
fprintf(stderr
, "%s: Can't find dpd.\nFiles left in spooling dir.\n", NAME
);
filargs() /*process file arguments for dpr, gcat, fsend, lpr.*/
if(copy(stdin
, mailfile
, GCAT
) == -1)
if(lfname
[INCHAR
]++ >= 'z')
cpflag
= rmflag
? 'c' : 'n';
else if(link(arg
, lfname
) == 0){
if(*arg
== '/' && !rmflag
){
fprintf(stderr
, "%s: Cannot open %s\n", NAME
, arg
);
fprintf(stderr
, "%s: Cannot remove %s\n", NAME
, arg
);
FILE *nfile(name
) /*generate a new file name, and open file.*/
if(!access(name
, 0) || (f
= fopen(name
, "w")) == NULL
)
if((ff
= nfile(cfname
)) == NULL
){
fprintf(stderr
, "%s: Too many copy files; %s not copied\n", NAME
, gname
);
while((c
= getc(f
)) != EOF
){
fprintf(stderr
, "%s: Bad input from %s.\n", NAME
, gname
);
if((putc(c
, ff
) == EOF
) && ferror(ff
)){
fprintf(stderr
, "%s: Write error on copy of %s.\n", NAME
, gname
);
fprintf(stderr
, "%s: Copy file %s is too large\n", NAME
, gname
);
if(size(cfname
,gname
) <= 0)
while( (c
= *s
++) != '\0') putc( c
, tff
);
fprintf(stderr
, "%s: Error writing control file.\n", NAME
);
if(stat(file
,&stbuf
) < 0){
fprintf(stderr
, "%s: Cannot open %s\n", NAME
, file
);
fprintf(stderr
, "%s: File %s is empty.\n", NAME
, name
);
getarg(c
) /*get modifier for complex options --
from either same or next argument. MRW
e.g. either "-ffile" or "-f file"*/
return(arg
= (++argv
)[1]);
fprintf(stderr
, "%s: Incomplete -%c option\n", NAME
,c
);
struct passwd
*getpwuid();
int c
, i
, j
, n
, test
, jsave
;
if((b1
= getpwuid(getuid())) == NULL
) {
fprintf(stderr
, "%s: Invalid user id\n", NAME
);
jsave
= j
; /*use either usg or pwb-style passwd. MRW*/
while((c
= b1
->pw_gecos
[i
++]) && c
!= ':')
while(c
= b1
->pw_name
[i
++])
while((c
=b2
[i
++]) && c
!= ',') {
if('0' <= c
&& c
<= '9') test
+= c
-'0';
fprintf(stderr
, "%s: Invalid IDENT information - %s\n", NAME
, b2
);
while((c
= b2
[i
++]) && c
!= ',') {
card('Q', b2
); /*mail back $IDENT card.*/
pidfn() /*rewrite using mktemp. MRW*/
while(tfname
[INCHAR
] != 'X')
if(signal(SIGHUP
, SIG_IGN
) != SIG_IGN
)
if(signal(SIGINT
, SIG_IGN
) != SIG_IGN
)
if(signal(SIGQUIT
, SIG_IGN
) != SIG_IGN
)
if(signal(SIGTERM
, SIG_IGN
) != SIG_IGN
)
signal(SIGQUIT
, SIG_IGN
);
signal(SIGTERM
, SIG_IGN
);
for(; cfname
[i
] != FIRSTCHAR
; cfname
[i
]--)
if(dfname
[i
] != FIRSTCHAR
)
for(; lfname
[i
] != FIRSTCHAR
; lfname
[i
]--)
if(tfname
[i
] != FIRSTCHAR
)
for(; zfname
[i
] != FIRSTCHAR
; zfname
[i
]--)