Removed unused envp from main()
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@629 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -55,6 +55,10 @@ RCSID("$Id$");
|
|||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FTP_NAMES
|
#define FTP_NAMES
|
||||||
#include <arpa/ftp.h>
|
#include <arpa/ftp.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@@ -248,7 +252,7 @@ static void conn_wait(int port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv, char **envp)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int addrlen, ch, on = 1, tos;
|
int addrlen, ch, on = 1, tos;
|
||||||
char *cp, line[LINE_MAX];
|
char *cp, line[LINE_MAX];
|
||||||
@@ -790,6 +794,19 @@ skip:
|
|||||||
end_login();
|
end_login();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_buffer_size(int fd, int read)
|
||||||
|
{
|
||||||
|
#if defined(SO_RCVBUF) && defined(SO_SNDBUF)
|
||||||
|
size_t size = 1048576;
|
||||||
|
while(size >= 131072 &&
|
||||||
|
setsockopt(fd, SOL_SOCKET, read ? SO_RCVBUF : SO_SNDBUF,
|
||||||
|
(char*)&size, sizeof(size)) < 0)
|
||||||
|
size /= 2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
retrieve(char *cmd, char *name)
|
retrieve(char *cmd, char *name)
|
||||||
{
|
{
|
||||||
@@ -845,6 +862,7 @@ retrieve(char *cmd, char *name)
|
|||||||
dout = dataconn(name, st.st_size, "w");
|
dout = dataconn(name, st.st_size, "w");
|
||||||
if (dout == NULL)
|
if (dout == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
set_buffer_size(fileno(dout), 0);
|
||||||
send_data(fin, dout, st.st_blksize);
|
send_data(fin, dout, st.st_blksize);
|
||||||
(void) fclose(dout);
|
(void) fclose(dout);
|
||||||
data = -1;
|
data = -1;
|
||||||
@@ -942,6 +960,7 @@ store(char *name, char *mode, int unique)
|
|||||||
din = dataconn(name, (off_t)-1, "r");
|
din = dataconn(name, (off_t)-1, "r");
|
||||||
if (din == NULL)
|
if (din == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
set_buffer_size(fileno(din), 1);
|
||||||
if (receive_data(din, fout) == 0) {
|
if (receive_data(din, fout) == 0) {
|
||||||
if (unique)
|
if (unique)
|
||||||
reply(226, "Transfer complete (unique file name:%s).",
|
reply(226, "Transfer complete (unique file name:%s).",
|
||||||
@@ -1110,33 +1129,53 @@ send_data(FILE *instr, FILE *outstr, off_t blksize)
|
|||||||
goto data_err;
|
goto data_err;
|
||||||
reply(226, "Transfer complete.");
|
reply(226, "Transfer complete.");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case TYPE_I:
|
case TYPE_I:
|
||||||
case TYPE_L:
|
case TYPE_L:
|
||||||
if ((buf = malloc((u_int)blksize)) == NULL) {
|
#ifdef HAVE_MMAP
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
void *chunk;
|
||||||
|
int in = fileno(instr);
|
||||||
|
if(fstat(in, &st) == 0 && S_ISREG(st.st_mode)){
|
||||||
|
chunk = mmap(0, st.st_size, PROT_READ, MAP_SHARED, in, 0);
|
||||||
|
if(chunk != NULL){
|
||||||
|
auth_write(fileno(outstr), chunk, st.st_size);
|
||||||
|
munmap(chunk, st.st_size);
|
||||||
|
auth_write(fileno(outstr), NULL, 0);
|
||||||
|
cnt = st.st_size;
|
||||||
transflag = 0;
|
transflag = 0;
|
||||||
perror_reply(451, "Local resource failure: malloc");
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
netfd = fileno(outstr);
|
}
|
||||||
filefd = fileno(instr);
|
|
||||||
while ((cnt = read(filefd, buf, (u_int)blksize)) > 0 &&
|
#endif
|
||||||
auth_write(netfd, buf, cnt) == cnt)
|
if(transflag){
|
||||||
byte_count += cnt;
|
if ((buf = malloc(10 * blksize)) == NULL) {
|
||||||
auth_write(netfd, buf, 0); /* to end an encrypted stream */
|
|
||||||
transflag = 0;
|
transflag = 0;
|
||||||
(void)free(buf);
|
perror_reply(451, "Local resource failure: malloc");
|
||||||
if (cnt != 0) {
|
|
||||||
if (cnt < 0)
|
|
||||||
goto file_err;
|
|
||||||
goto data_err;
|
|
||||||
}
|
|
||||||
reply(226, "Transfer complete.");
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
netfd = fileno(outstr);
|
||||||
|
filefd = fileno(instr);
|
||||||
|
while ((cnt = read(filefd, buf, 10 * blksize)) > 0 &&
|
||||||
|
auth_write(netfd, buf, cnt) == cnt)
|
||||||
|
byte_count += cnt;
|
||||||
|
auth_write(netfd, buf, 0); /* to end an encrypted stream */
|
||||||
|
transflag = 0;
|
||||||
|
free(buf);
|
||||||
|
if (cnt != 0) {
|
||||||
|
if (cnt < 0)
|
||||||
|
goto file_err;
|
||||||
|
goto data_err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reply(226, "Transfer complete.");
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
transflag = 0;
|
transflag = 0;
|
||||||
reply(550, "Unimplemented TYPE %d in send_data", type);
|
reply(550, "Unimplemented TYPE %d in send_data", type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data_err:
|
data_err:
|
||||||
@@ -1159,7 +1198,7 @@ static int
|
|||||||
receive_data(FILE *instr, FILE *outstr)
|
receive_data(FILE *instr, FILE *outstr)
|
||||||
{
|
{
|
||||||
int cnt, bare_lfs = 0;
|
int cnt, bare_lfs = 0;
|
||||||
char buf[BUFSIZ];
|
char buf[100*BUFSIZ];
|
||||||
|
|
||||||
transflag++;
|
transflag++;
|
||||||
if (setjmp(urgcatch)) {
|
if (setjmp(urgcatch)) {
|
||||||
|
Reference in New Issue
Block a user