version 1.15, 1997/03/14 23:25:46 |
version 1.16, 1997/03/21 20:59:29 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: ftp.c,v 1.23 1997/03/13 06:23:17 lukem Exp $ */ |
/* $NetBSD: ftp.c,v 1.24 1997/03/16 14:24:19 lukem Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1985, 1989, 1993, 1994 |
* Copyright (c) 1985, 1989, 1993, 1994 |
|
|
struct stat st; |
struct stat st; |
time_t mtime; |
time_t mtime; |
int oprogress; |
int oprogress; |
|
int opreserve; |
|
|
hashbytes = mark; |
hashbytes = mark; |
direction = "received"; |
direction = "received"; |
bytes = 0; |
bytes = 0; |
filesize = -1; |
filesize = -1; |
oprogress = progress; |
oprogress = progress; |
|
opreserve = preserve; |
is_retr = strcmp(cmd, "RETR") == 0; |
is_retr = strcmp(cmd, "RETR") == 0; |
if (is_retr && verbose && printnames) { |
if (is_retr && verbose && printnames) { |
if (local && *local != '-') |
if (local && *local != '-') |
|
|
if (oldinti) |
if (oldinti) |
(void)signal(SIGINFO, oldinti); |
(void)signal(SIGINFO, oldinti); |
progress = oprogress; |
progress = oprogress; |
|
preserve = opreserve; |
code = -1; |
code = -1; |
return; |
return; |
} |
} |
|
|
if (strcmp(local, "-") == 0) { |
if (strcmp(local, "-") == 0) { |
fout = stdout; |
fout = stdout; |
progress = 0; |
progress = 0; |
|
preserve = 0; |
} else if (*local == '|') { |
} else if (*local == '|') { |
oldintp = signal(SIGPIPE, SIG_IGN); |
oldintp = signal(SIGPIPE, SIG_IGN); |
fout = popen(local + 1, "w"); |
fout = popen(local + 1, "w"); |
|
|
goto abort; |
goto abort; |
} |
} |
progress = 0; |
progress = 0; |
|
preserve = 0; |
closefunc = pclose; |
closefunc = pclose; |
} else { |
} else { |
fout = fopen(local, lmode); |
fout = fopen(local, lmode); |
|
|
lseek(fileno(fout), restart_point, SEEK_SET) < 0) { |
lseek(fileno(fout), restart_point, SEEK_SET) < 0) { |
warn("local: %s", local); |
warn("local: %s", local); |
progress = oprogress; |
progress = oprogress; |
|
preserve = opreserve; |
if (closefunc != NULL) |
if (closefunc != NULL) |
(*closefunc)(fout); |
(*closefunc)(fout); |
return; |
return; |
|
|
done: |
done: |
warn("local: %s", local); |
warn("local: %s", local); |
progress = oprogress; |
progress = oprogress; |
|
preserve = opreserve; |
if (closefunc != NULL) |
if (closefunc != NULL) |
(*closefunc)(fout); |
(*closefunc)(fout); |
return; |
return; |
|
|
} |
} |
progressmeter(1); |
progressmeter(1); |
progress = oprogress; |
progress = oprogress; |
|
preserve = opreserve; |
if (closefunc != NULL) |
if (closefunc != NULL) |
(*closefunc)(fout); |
(*closefunc)(fout); |
(void)signal(SIGINT, oldintr); |
(void)signal(SIGINT, oldintr); |
|
|
/* abort using RFC959 recommended IP,SYNC sequence */ |
/* abort using RFC959 recommended IP,SYNC sequence */ |
|
|
progress = oprogress; |
progress = oprogress; |
|
preserve = opreserve; |
if (oldintp) |
if (oldintp) |
(void)signal(SIGPIPE, oldintp); |
(void)signal(SIGPIPE, oldintp); |
(void)signal(SIGINT, SIG_IGN); |
(void)signal(SIGINT, SIG_IGN); |