projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add typedef for signal return for better portability
[unix-history]
/
usr
/
src
/
usr.bin
/
ftp
/
ftp.c
diff --git
a/usr/src/usr.bin/ftp/ftp.c
b/usr/src/usr.bin/ftp/ftp.c
index
2804ad5
..
9f76af4
100644
(file)
--- a/
usr/src/usr.bin/ftp/ftp.c
+++ b/
usr/src/usr.bin/ftp/ftp.c
@@
-16,7
+16,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)ftp.c 5.2
8
(Berkeley) %G%";
+static char sccsid[] = "@(#)ftp.c 5.2
9
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
@@
-45,7
+45,6
@@
int data = -1;
int abrtflag = 0;
int ptflag = 0;
int connected;
int abrtflag = 0;
int ptflag = 0;
int connected;
-int allbinary;
struct sockaddr_in myctladdr;
uid_t getuid();
struct sockaddr_in myctladdr;
uid_t getuid();
@@
-235,11
+234,15
@@
command(fmt, args)
char *fmt;
{
int r, (*oldintr)(), cmdabort();
char *fmt;
{
int r, (*oldintr)(), cmdabort();
+ char *xxx = "XXX";
abrtflag = 0;
if (debug) {
printf("---> ");
abrtflag = 0;
if (debug) {
printf("---> ");
- _doprnt(fmt, &args, stdout);
+ if (strncmp(fmt, "PASS", 4) == 0)
+ _doprnt(fmt, (int *)&xxx, stdout);
+ else
+ _doprnt(fmt, &args, stdout);
printf("\n");
(void) fflush(stdout);
}
printf("\n");
(void) fflush(stdout);
}
@@
-414,6
+417,8
@@
sendrequest(cmd, local, remote, printnames)
proxtrans(cmd, local, remote);
return;
}
proxtrans(cmd, local, remote);
return;
}
+ if (curtype != type)
+ changetype(type, 0);
closefunc = NULL;
oldintr = NULL;
oldintp = NULL;
closefunc = NULL;
oldintr = NULL;
oldintp = NULL;
@@
-624,7
+629,7
@@
recvrequest(cmd, local, remote, mode, printnames)
{
FILE *fout, *din = 0, *popen();
int (*closefunc)(), pclose(), fclose(), (*oldintr)(), (*oldintp)();
{
FILE *fout, *din = 0, *popen();
int (*closefunc)(), pclose(), fclose(), (*oldintr)(), (*oldintp)();
- int abortrecv(),
oldverbose, oldtype = 0,
is_retr, tcrflag, nfnd;
+ int abortrecv(), is_retr, tcrflag, nfnd;
char *bufp, *gunique(), msg;
static char *buf;
static int bufsize;
char *bufp, *gunique(), msg;
static char *buf;
static int bufsize;
@@
-705,6
+710,11
@@
recvrequest(cmd, local, remote, mode, printnames)
return;
}
}
return;
}
}
+ if (!is_retr) {
+ if (curtype != TYPE_A)
+ changetype(TYPE_A, 0);
+ } else if (curtype != type)
+ changetype(type, 0);
if (initconn()) {
(void) signal(SIGINT, oldintr);
code = -1;
if (initconn()) {
(void) signal(SIGINT, oldintr);
code = -1;
@@
-712,56
+722,17
@@
recvrequest(cmd, local, remote, mode, printnames)
}
if (setjmp(recvabort))
goto abort;
}
if (setjmp(recvabort))
goto abort;
- if (!is_retr) {
- if (type != TYPE_A && (allbinary == 0 || type != TYPE_I)) {
- oldtype = type;
- oldverbose = verbose;
- if (!debug)
- verbose = 0;
- setascii();
- verbose = oldverbose;
- }
- }
+ if (is_retr && restart_point &&
+ command("REST %ld", (long) restart_point) != CONTINUE)
+ return;
if (remote) {
if (command("%s %s", cmd, remote) != PRELIM) {
(void) signal(SIGINT, oldintr);
if (remote) {
if (command("%s %s", cmd, remote) != PRELIM) {
(void) signal(SIGINT, oldintr);
- if (oldtype) {
- if (!debug)
- verbose = 0;
- switch (oldtype) {
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
- verbose = oldverbose;
- }
return;
}
} else {
if (command("%s", cmd) != PRELIM) {
(void) signal(SIGINT, oldintr);
return;
}
} else {
if (command("%s", cmd) != PRELIM) {
(void) signal(SIGINT, oldintr);
- if (oldtype) {
- if (!debug)
- verbose = 0;
- switch (oldtype) {
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
- verbose = oldverbose;
- }
return;
}
}
return;
}
}
@@
-801,7
+772,7
@@
recvrequest(cmd, local, remote, mode, printnames)
bufsize = st.st_blksize;
}
(void) gettimeofday(&start, (struct timezone *)0);
bufsize = st.st_blksize;
}
(void) gettimeofday(&start, (struct timezone *)0);
- switch (type) {
+ switch (
cur
type) {
case TYPE_I:
case TYPE_L:
case TYPE_I:
case TYPE_L:
@@
-891,22
+862,6
@@
break2:
(void) getreply(0);
if (bytes > 0 && is_retr)
ptransfer("received", bytes, &start, &stop);
(void) getreply(0);
if (bytes > 0 && is_retr)
ptransfer("received", bytes, &start, &stop);
- if (oldtype) {
- if (!debug)
- verbose = 0;
- switch (oldtype) {
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
- verbose = oldverbose;
- }
return;
abort:
return;
abort:
@@
-916,22
+871,6
@@
abort:
if (oldintp)
(void) signal(SIGPIPE, oldintr);
(void) signal(SIGINT,SIG_IGN);
if (oldintp)
(void) signal(SIGPIPE, oldintr);
(void) signal(SIGINT,SIG_IGN);
- if (oldtype) {
- if (!debug)
- verbose = 0;
- switch (oldtype) {
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
- verbose = oldverbose;
- }
if (!cpend) {
code = -1;
(void) signal(SIGINT,oldintr);
if (!cpend) {
code = -1;
(void) signal(SIGINT,oldintr);
@@
-1132,6
+1071,7
@@
pswitch(flag)
FILE *in;
FILE *out;
int tpe;
FILE *in;
FILE *out;
int tpe;
+ int curtpe;
int cpnd;
int sunqe;
int runqe;
int cpnd;
int sunqe;
int runqe;
@@
-1142,7
+1082,7
@@
pswitch(flag)
int mapflg;
char mi[MAXPATHLEN];
char mo[MAXPATHLEN];
int mapflg;
char mi[MAXPATHLEN];
char mo[MAXPATHLEN];
-
} proxstruct, tmpstruct;
+ } proxstruct, tmpstruct;
struct comvars *ip, *op;
abrtflag = 0;
struct comvars *ip, *op;
abrtflag = 0;
@@
-1153,8
+1093,7
@@
pswitch(flag)
ip = &tmpstruct;
op = &proxstruct;
proxy++;
ip = &tmpstruct;
op = &proxstruct;
proxy++;
- }
- else {
+ } else {
if (!proxy)
return;
ip = &proxstruct;
if (!proxy)
return;
ip = &proxstruct;
@@
-1179,8
+1118,8
@@
pswitch(flag)
cout = op->out;
ip->tpe = type;
type = op->tpe;
cout = op->out;
ip->tpe = type;
type = op->tpe;
- i
f (!type)
-
type = 1
;
+ i
p->curtpe = curtype;
+
curtype = op->curtpe
;
ip->cpnd = cpend;
cpend = op->cpnd;
ip->sunqe = sunique;
ip->cpnd = cpend;
cpend = op->cpnd;
ip->sunqe = sunique;
@@
-1228,7
+1167,7
@@
abortpt()
proxtrans(cmd, local, remote)
char *cmd, *local, *remote;
{
proxtrans(cmd, local, remote)
char *cmd, *local, *remote;
{
- int (*oldintr)(), abortpt(),
tmptype, oldtype = 0
, secndflag = 0, nfnd;
+ int (*oldintr)(), abortpt(),
prox_type
, secndflag = 0, nfnd;
extern jmp_buf ptabort;
char *cmd2;
struct fd_set mask;
extern jmp_buf ptabort;
char *cmd2;
struct fd_set mask;
@@
-1237,11
+1176,18
@@
proxtrans(cmd, local, remote)
cmd2 = "RETR";
else
cmd2 = runique ? "STOU" : "STOR";
cmd2 = "RETR";
else
cmd2 = runique ? "STOU" : "STOR";
+ if ((prox_type = type) == 0) {
+ if (unix_server && unix_proxy)
+ prox_type = TYPE_I;
+ else
+ prox_type = TYPE_A;
+ }
+ if (curtype != prox_type)
+ changetype(prox_type, 1);
if (command("PASV") != COMPLETE) {
if (command("PASV") != COMPLETE) {
- printf("proxy server does not support third part transfers.\n");
+ printf("proxy server does not support third part
y
transfers.\n");
return;
}
return;
}
- tmptype = type;
pswitch(0);
if (!connected) {
printf("No primary connection\n");
pswitch(0);
if (!connected) {
printf("No primary connection\n");
@@
-1249,40
+1195,9
@@
proxtrans(cmd, local, remote)
code = -1;
return;
}
code = -1;
return;
}
- if (type != tmptype) {
- oldtype = type;
- switch (tmptype) {
- case TYPE_A:
- setascii();
- break;
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
- }
+ if (curtype != prox_type)
+ changetype(prox_type, 1);
if (command("PORT %s", pasv) != COMPLETE) {
if (command("PORT %s", pasv) != COMPLETE) {
- switch (oldtype) {
- case 0:
- break;
- case TYPE_A:
- setascii();
- break;
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
pswitch(1);
return;
}
pswitch(1);
return;
}
@@
-1291,22
+1206,6
@@
proxtrans(cmd, local, remote)
oldintr = signal(SIGINT, abortpt);
if (command("%s %s", cmd, remote) != PRELIM) {
(void) signal(SIGINT, oldintr);
oldintr = signal(SIGINT, abortpt);
if (command("%s %s", cmd, remote) != PRELIM) {
(void) signal(SIGINT, oldintr);
- switch (oldtype) {
- case 0:
- break;
- case TYPE_A:
- setascii();
- break;
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
pswitch(1);
return;
}
pswitch(1);
return;
}
@@
-1320,22
+1219,6
@@
proxtrans(cmd, local, remote)
pswitch(0);
(void) getreply(0);
(void) signal(SIGINT, oldintr);
pswitch(0);
(void) getreply(0);
(void) signal(SIGINT, oldintr);
- switch (oldtype) {
- case 0:
- break;
- case TYPE_A:
- setascii();
- break;
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
pswitch(1);
ptflag = 0;
printf("local: %s remote: %s\n", local, remote);
pswitch(1);
ptflag = 0;
printf("local: %s remote: %s\n", local, remote);
@@
-1350,22
+1233,6
@@
abort:
if (!cpend && !secndflag) { /* only here if cmd = "STOR" (proxy=1) */
if (command("%s %s", cmd2, local) != PRELIM) {
pswitch(0);
if (!cpend && !secndflag) { /* only here if cmd = "STOR" (proxy=1) */
if (command("%s %s", cmd2, local) != PRELIM) {
pswitch(0);
- switch (oldtype) {
- case 0:
- break;
- case TYPE_A:
- setascii();
- break;
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
if (cpend) {
char msg[2];
if (cpend) {
char msg[2];
@@
-1425,22
+1292,6
@@
abort:
if (!cpend && !secndflag) { /* only if cmd = "RETR" (proxy=1) */
if (command("%s %s", cmd2, local) != PRELIM) {
pswitch(0);
if (!cpend && !secndflag) { /* only if cmd = "RETR" (proxy=1) */
if (command("%s %s", cmd2, local) != PRELIM) {
pswitch(0);
- switch (oldtype) {
- case 0:
- break;
- case TYPE_A:
- setascii();
- break;
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
if (cpend) {
char msg[2];
if (cpend) {
char msg[2];
@@
-1513,22
+1364,6
@@
abort:
}
if (proxy)
pswitch(0);
}
if (proxy)
pswitch(0);
- switch (oldtype) {
- case 0:
- break;
- case TYPE_A:
- setascii();
- break;
- case TYPE_I:
- setbinary();
- break;
- case TYPE_E:
- setebcdic();
- break;
- case TYPE_L:
- settenex();
- break;
- }
pswitch(1);
if (ptabflg)
code = -1;
pswitch(1);
if (ptabflg)
code = -1;