static char sccsid
[] = "@(#)uux.c 5.3 (Berkeley) %G%";
char *p; for (p = d; *p != '\0';) *cmdp++ = *p++; *cmdp++ = ' '; *cmdp = '\0';}
#define GENSEND(f, a, b, c, d, e) {\
fprintf(f, "S %s %s %s -%s %s 0666\n", a, b, c, d, e); }
#define GENRCV(f, a, b, c) {fprintf(f, "R %s %s %s - \n", a, b, c);}
char cfile
[NAMESIZE
]; /* send commands for files from here */
char dfile
[NAMESIZE
]; /* used for all data files from here */
char rxfile
[NAMESIZE
]; /* to be sent to xqt file (X. ...) */
char tfile
[NAMESIZE
]; /* temporary file name */
char tcfile
[NAMESIZE
]; /* temporary file name */
char t2file
[NAMESIZE
]; /* temporary file name */
int cflag
= 0; /* commands in C. file flag */
int rflag
= 0; /* C. files for receiving flag */
int Copy
= 0; /* Don't Copy spool files */
int Copy
= 1; /* Copy spool files */
int Linkit
= 0; /* Try link before copy */
char syspart
[8], rest
[MAXFULLNAME
];
FILE *fprx
, *fpc
, *fpd
, *fp
;
extern char *getprm(), *lastpart();
while (argc
>1 && argv
[1][0] == '-') {
Debug
= atoi(&argv
[1][2]);
fprintf(stderr
, "unknown flag %s\n", argv
[1]);
fprintf(stderr
, "can't get working directory; will try to continue\n");
strcpy(Wrkdir
, "/UNKNOWN");
DEBUG(4, "\n\n** %s **\n", "START");
for (argv
++; argc
> 1; argc
--) {
DEBUG(4, "arg - %s:", *argv
);
DEBUG(4, "arg - %s\n", inargs
);
ASSERT(ret
>= 0, "CHDIR FAILED", Spool
, ret
);
sprintf(local
, "%.7s", Myname
);
gename(DATAPRE
, local
, 'X', rxfile
);
fprx
= ufopen(rxfile
, "w");
ASSERT(fprx
!= NULL
, "CAN'T OPEN", rxfile
, 0);
gename(DATAPRE
, local
, 'T', tcfile
);
fpc
= ufopen(tcfile
, "w");
ASSERT(fpc
!= NULL
, "CAN'T OPEN", tcfile
, 0);
fprintf(fprx
, "%c %s %s\n", X_USER
, User
, local
);
fprintf(fprx
, "%c\n", X_NONOTI
);
fprintf(fprx
, "%c\n", X_NONZERO
);
if (ReturnTo
== NULL
|| *ReturnTo
== '\0')
fprintf(fprx
, "%c %s\n", X_RETURNTO
, ReturnTo
);
/* find remote system name */
while ((ap
= getprm(ap
, prm
)) != NULL
) {
if (prm
[0] == '>' || prm
[0] == '<') {
sprintf(Rmtname
, "%.7s", xsys
);
DEBUG(4, "xsys %s\n", xsys
);
if (versys(&xsys
) != 0) {
fprintf(stderr
, "bad system name: %s\n", xsys
);
gename(DATAPRE
, local
, 'B', dfile
);
fpd
= ufopen(dfile
, "w");
ASSERT(fpd
!= NULL
, "CAN'T OPEN", dfile
, 0);
ret
= fread(buf
, 1, BUFSIZ
, stdin
);
fwrite(buf
, 1, ret
, fpd
);
if (strcmp(local
, xsys
) != SAME
) {
tfile
[strlen(local
) + 2] = 'S';
GENSEND(fpc
, dfile
, tfile
, User
, "", dfile
);
fprintf(fprx
, "%c %s\n", X_RQDFILE
, tfile
);
fprintf(fprx
, "%c %s\n", X_STDIN
, tfile
);
while ((ap
= getprm(ap
, prm
)) != NULL
) {
DEBUG(4, "prm - %s\n", prm
);
if (prm
[0] == '>' || prm
[0] == '<') {
if (prm
[0] == '|' || prm
[0] == '^') {
/* process command or file or option */
ret
= split(prm
, syspart
, rest
);
DEBUG(4, "s - %s, ", syspart
);
DEBUG(4, "r - %s, ", rest
);
DEBUG(4, "ret - %d\n", ret
);
if (cmdp
== cmd
&& redir
== '\0') {
/* process file or option */
DEBUG(4, "file s- %s, ", syspart
);
DEBUG(4, "local - %s\n", local
);
fprintf(fprx
, "%c %s %s\n", X_STDOUT
, rest
,
if (ret
== NOSYSPART
&& redir
== '\0') {
if (strcmp(xsys
, local
) == SAME
&& strcmp(xsys
, syspart
) == SAME
) {
fprintf(fprx
, "%c %s\n", X_STDIN
, rest
);
if (strcmp(syspart
, local
) == SAME
) {
gename(DATAPRE
, local
, 'A', dfile
);
DEBUG(4, "rest %s\n", rest
);
if ((chkpth(User
, "", rest
) || anyread(rest
)) != 0) {
fprintf(stderr
, "permission denied %s\n", rest
);
if (link(subfile(rest
), subfile(dfile
)) != 0)
GENSEND(fpc
, rest
, dfile
, User
, "", dfile
);
if (Copy
|| link_failed
) {
if (xcp(rest
, dfile
) != 0) {
fprintf(stderr
, "can't copy %s to %s\n", rest
, dfile
);
GENSEND(fpc
, rest
, dfile
, User
, "", dfile
);
GENSEND(fpc
, rest
, dfile
, User
, "c", "D.0");
fprintf(fprx
, "%c %s\n", X_STDIN
, dfile
);
fprintf(fprx
, "%c %s\n", X_RQDFILE
, dfile
);
fprintf(fprx
, "%c %s %s\n", X_RQDFILE
,
if (strcmp(local
, xsys
) == SAME
) {
/* generate local receive */
gename(CMDPRE
, syspart
, 'R', tfile
);
ASSERT(fp
!= NULL
, "CAN'T OPEN", tfile
, 0);
GENRCV(fp
, rest
, dfile
, User
);
fprintf(fprx
, "%c %s\n", X_RQDFILE
, dfile
);
fprintf(fprx
, "%c %s\n", X_STDIN
, dfile
);
fprintf(fprx
, "%c %s %s\n", X_RQDFILE
, dfile
,
if (strcmp(syspart
, xsys
) != SAME
) {
/* generate remote receives */
gename(DATAPRE
, syspart
, 'R', dfile
);
fpd
= ufopen(dfile
, "w");
ASSERT(fpd
!= NULL
, "CAN'T OPEN", dfile
, 0);
gename(DATAPRE
, local
, 'T', t2file
);
GENRCV(fpd
, rest
, t2file
, User
);
GENSEND(fpc
, dfile
, tfile
, User
, "", dfile
);
fprintf(fprx
, "%c %s\n", X_RQDFILE
, t2file
);
fprintf(fprx
, "%c %s\n", X_STDIN
, t2file
);
fprintf(fprx
, "%c %s %s\n", X_RQDFILE
, t2file
,
/* file on remote system */
fprintf(fprx
, "%c %s\n", X_STDIN
, rest
);
* clean up trailing ' ' in command.
if (cmdp
> cmd
&& cmdp
[0] == '\0' && cmdp
[-1] == ' ')
/* block multi-hop uux, which doesn't work */
for (ap
= cmd
; *ap
&& *ap
!= ' '; ap
++)
fprintf(stderr
, "uux handles only adjacent sites.\n");
fprintf(stderr
, "Try uusend for multi-hop delivery.\n");
fprintf(fprx
, "%c %s\n", X_CMD
, cmd
);
logent(cmd
, "XQT QUE'D");
gename(XQTPRE
, local
, Grade
, tfile
);
if (strcmp(xsys
, local
) == SAME
) {
/* rti!trt: xmv() works across filesystems, link(II) doesnt */
GENSEND(fpc
, rxfile
, tfile
, User
, "", rxfile
);
gename(CMDPRE
, xsys
, Grade
, cfile
);
/* rti!trt: use xmv() rather than link(II) */
char Fname
[FTABSIZE
][NAMESIZE
];
* cleanup and unlink if error
* return - none - do exit()
for (i
= 0; i
< Fnamect
; i
++)
unlink(subfile(Fname
[i
]));
fprintf(stderr
, "uux failed. code %d\n", code
);
DEBUG(1, "exit code %d\n", code
);
* open file and record name
strcpy(Fname
[Fnamect
++], file
);
logent("Fname", "TABLE OVERFLOW");
return fopen(subfile(file
), mode
);
* quotes are not stripped from DCL. Do it here.
* Note if we are running under Unix shell we don't
for (; argc
> 0; --argc
, argv
++) {
if (cp
== (char *)0 || *cp
++ != '"')