/* uux 2.2 5/24/79 18:33:11 */
static char SiD
[] = "@(#)uux 2.2";
for (p = d; *p != '\0';) *cmdp++ = *p++;\
#define GENSEND(f, a, b, c, d) {\
fprintf(f, "S %s %s %s - %s 0666\n", a, b, c, d);\
#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 */
char syspart
[8], rest
[MAXFULLNAME
];
FILE *fprx
, *fpc
, *fpd
, *fp
;
extern char *getprm(), *index(), *lastpart();
while (argc
>1 && argv
[1][0] == '-') {
Debug
= atoi(&argv
[1][2]);
sprintf(stderr
, "unknown flag %s\n", argv
[1]);
DEBUG(4, "\n\n** %s **\n", "START");
for (argv
++; argc
> 1; argc
--) {
DEBUG(4, "arg - %s:", *argv
);
DEBUG(4, "arg - %s\n", inargs
);
fprintf(stderr
, "can't get working directory; will try to continue\n");
strcpy(Wrkdir
, "/UNKNOWN");
sprintf(local
, "%.7s", Myname
);
gename(DATAPRE
, local
, 'X', rxfile
);
fprx
= fopen(rxfile
, "w");
ASSERT(fprx
!= NULL
, "CAN'T OPEN %s", rxfile
);
gename(DATAPRE
, local
, 'T', tcfile
);
fpc
= fopen(tcfile
, "w");
ASSERT(fpc
!= NULL
, "CAN'T OPEN %s", tcfile
);
fprintf(fprx
, "%c %s %s\n", X_USER
, User
, local
);
/* find remote system name */
while ((ap
= getprm(ap
, prm
)) != NULL
) {
if (prm
[0] == '>' || prm
[0] == '<') {
DEBUG(4, "xsys %s\n", xsys
);
fprintf(stderr
, "bad system name: %s\n", xsys
);
gename(DATAPRE
, xsys
, 'B', dfile
);
ASSERT(fpd
!= NULL
, "CAN'T OPEN %s", dfile
);
while ((c
= getc(stdin
)) != EOF
)
while (fgets(buf
, BUFSIZ
, stdin
) != NULL
)
if (strcmp(local
, xsys
) != SAME
) {
GENSEND(fpc
, dfile
, dfile
, User
, dfile
);
fprintf(fprx
, "%c %s\n", X_RQDFILE
, dfile
);
fprintf(fprx
, "%c %s\n", X_STDIN
, dfile
);
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 (strcmp(xsys
, local
) == SAME
&& strcmp(xsys
, syspart
) == SAME
) {
fprintf(fprx
, "%c %s\n", X_STDIN
, rest
);
if (strcmp(syspart
, local
) == SAME
) {
gename(DATAPRE
, xsys
, 'A', dfile
);
DEBUG(4, "rest %s\n", rest
);
if ((chkpth(User
, "", rest
) || anyread(rest
)) != 0) {
fprintf(stderr
, "permission denied %s\n", rest
);
if (xcp(rest
, dfile
) != 0) {
fprintf(stderr
, "can't copy %s to %s\n", rest
, dfile
);
GENSEND(fpc
, rest
, dfile
, User
, dfile
);
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 %s", tfile
);
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
);
ASSERT(fpd
!= NULL
, "CAN'T OPEN %s", dfile
);
gename(DATAPRE
, xsys
, '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
);
fprintf(fprx
, "%c %s\n", X_CMD
, cmd
);
if (strcmp(xsys
, local
) == SAME
) {
GENSEND(fpc
, rxfile
, tfile
, User
, rxfile
);
gename(CMDPRE
, xsys
, 'A', cfile
);
DEBUG(1, "exit code %d\n", code
);