static char *sccsid
= "@(#)uusend.c 4.1 (Berkeley) 10/1/80";
* uusend: primative operation to allow uucp like copy of binary files
* but handle indirection over systems.
* usage: uusend [-m ooo] localfile sysname1!sysname2!...!destfile
* uusend [-m ooo] - sysname1!sysname2!...!destfile
* Author: Mark Horton, May 1980.
/* #define DEBUG "/usr/spool/uucp/uusend.log" */
int mode
= -1; /* mode to chmod new file to */
char nextsys
[20]; /* next system in the chain */
char dnbuf
[200]; /* buffer for result of ~user/file */
char cmdbuf
[256]; /* buffer to build uux command in */
struct passwd
*user
; /* entry in /etc/passwd for ~user */
struct passwd
*getpwnam();
char *excl
; /* location of first ! in destname */
char *sl
; /* location of first / in destname */
char *sourcename
; /* argv[1] */
char *destname
; /* argv[2] */
dout
= fopen(DEBUG
, "a");
printf("Cannot append to %s\n", DEBUG
);
freopen(DEBUG
, "a", stdout
);
freopen(DEBUG
, "a", stderr
);
fprintf(dout
, "\nuusend run: ");
fprintf(dout
, "%s ", argv
[c
]);
fprintf(dout
, "%s", ctime(&t
));
while (argc
> 1 && argv
[1][0] == '-' && argv
[1][1]) {
sscanf(argv
[2], "%o", &mode
);
fprintf(stderr
, "Bad flag: %s\n", argv
[1]);
fprintf(stderr
, "Usage: uusend [-m ooo] -/file sys!sys!..!rfile\n");
if (sourcename
[0] == '-')
in
= fopen(sourcename
, "r");
excl
= index(destname
, '!');
* destname is on a remote system.
strncpy(nextsys
, destname
, excl
-destname
);
nextsys
[excl
-destname
] = 0;
fstat(fileno(in
), &stbuf
);
mode
= stbuf
.st_mode
& 0777;
sprintf(cmdbuf
, "uux - \"%s!uusend -m %o - \(%s\)\"",
nextsys
, mode
, destname
);
fprintf(dout
, "remote: nextsys='%s', destname='%s', cmd='%s'\n", nextsys
, destname
, cmdbuf
);
out
= popen(cmdbuf
, "w");
if (destname
[0] == '~') {
fprintf(dout
, "before ~: '%s'\n", destname
);
sl
= index(destname
, '/');
fprintf(stderr
, "Illegal ~user\n");
user
= getpwnam(destname
+1);
fprintf(stderr
, "No such user as %s\n", destname
);
strcpy(dnbuf
, user
->pw_dir
);
out
= fopen(destname
, "w");
fprintf(dout
, "local, file='%s'\n", destname
);
chmod(destname
, mode
); /* don't bother to check it */
* Now, in any case, copy from in to out.
while ((c
=getc(in
)) != EOF
) {
fprintf(dout
, "count %d bytes\n", count
);
fclose(out
); /* really should pclose in that case */
* Return the ptr in sp at which the character c appears;
* NULL if not found. Included so I don't have to fight the