summaryrefslogtreecommitdiff
path: root/lib/libftp/FtpIO.c
diff options
context:
space:
mode:
authorRodney W. Grimes <rgrimes@FreeBSD.org>1995-05-30 05:51:47 +0000
committerRodney W. Grimes <rgrimes@FreeBSD.org>1995-05-30 05:51:47 +0000
commit6c06b4e2aa2a28d1f0bbd29ecdce35aaaf600ce8 (patch)
treee1331adb5d216f2b3fa6baa6491752348d2e5f10 /lib/libftp/FtpIO.c
parenta2f0036ac41fe46dd47d6339982567f19437ade9 (diff)
Notes
Diffstat (limited to 'lib/libftp/FtpIO.c')
-rw-r--r--lib/libftp/FtpIO.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/lib/libftp/FtpIO.c b/lib/libftp/FtpIO.c
index ee701001d52c7..b7f6af5dc6d13 100644
--- a/lib/libftp/FtpIO.c
+++ b/lib/libftp/FtpIO.c
@@ -1,9 +1,9 @@
/* Library for ftpd clients.(libftp)
Copyright by Oleg Orel
All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
+
+This library is desined for free, non-commercial software creation.
+It is changeable and can be improved. The author would greatly appreciate
any advises, new components and patches of the exist
ing programs.
Commercial usage is also possible with participation of it's author.
@@ -18,23 +18,23 @@ Commercial usage is also possible with participation of it's author.
int FtpRead(FTP *con)
{
int c;
-
+
if ( con -> mode == 'I' )
return FtpGetc(con,FTPDATA(con));
-
+
if ( con->ch != EOF )
{
c=con->ch;
con->ch=EOF;
return c;
}
-
+
c=FtpGetc(con,FTPDATA(con));
-
+
if ( c == Ctrl('M') )
{
c = FtpGetc(con,FTPDATA(con));
-
+
if ( c == Ctrl('J') )
return '\n';
con->ch = c;
@@ -45,20 +45,20 @@ int FtpRead(FTP *con)
int FtpWrite(FTP *ftp,char c)
{
-
+
if ( ftp -> mode == 'I' || c != '\n' )
return FtpPutc(ftp,FTPDATA(ftp),c);
-
+
FtpPutc(ftp,FTPDATA(ftp),Ctrl('M'));
return FtpPutc(ftp,FTPDATA(ftp),Ctrl('J'));
}
-
+
int FtpGetc(FTP *ftp,FILE *fp)
{
fd_set fds;
char c;
-
+
FD_ZERO(&fds);
FD_SET(fileno(fp),&fds);
@@ -67,9 +67,9 @@ int FtpGetc(FTP *ftp,FILE *fp)
if (read(fileno(fp),&c,1)<1)
return EOF;
-
+
if (ftp->hash!=NULL) (*ftp->hash)(ftp,1);
-
+
return (int)c;
}
@@ -77,13 +77,13 @@ int FtpGetc(FTP *ftp,FILE *fp)
STATUS FtpPutc(FTP *ftp,FILE *fp,char c)
{
fd_set fds;
-
+
FD_ZERO(&fds);
FD_SET(fileno(fp),&fds);
-
+
if (select(getdtablesize(), 0, &fds, 0, &(ftp->timeout))<1)
return EXIT(ftp,QUIT);
-
+
if (write(fileno(fp),&c,1)!=1)
return EXIT(ftp,QUIT);
@@ -96,19 +96,19 @@ STATUS FtpReadBlock(FTP *ftp, char *buffer, int size)
{
fd_set fds;
register int rsize;
-
+
FD_ZERO(&fds);
FD_SET(fileno(FTPDATA(ftp)),&fds);
-
+
if (select(getdtablesize(), &fds,0, 0, &(ftp->timeout))<1)
return EXIT(ftp,QUIT);
-
-
+
+
if ((rsize=read(fileno(FTPDATA(ftp)),buffer,size))<0)
return EXIT(ftp,QUIT);
-
+
if (ftp->hash!=NULL && rsize!=0) (*ftp->hash)(ftp,rsize);
-
+
if (ftp->mode == 'A')
{
char buffer2[size];
@@ -119,7 +119,7 @@ STATUS FtpReadBlock(FTP *ftp, char *buffer, int size)
buffer2[ii]='\n',i++;
else
buffer2[ii]=buffer[i];
-
+
rsize=ii;
bcopy(buffer2,buffer,rsize);
}
@@ -132,14 +132,14 @@ STATUS FtpWriteBlock(FTP *ftp, char *buffer, int size)
fd_set fds;
register int wsize;
char buffer2[size*2];
-
+
FD_ZERO(&fds);
FD_SET(fileno(FTPDATA(ftp)),&fds);
-
+
if (select(getdtablesize(), 0, &fds, 0, &(ftp->timeout))<1)
return EXIT(ftp,QUIT);
-
-
+
+
if (ftp->mode=='A')
{
register int i,ii;
@@ -152,17 +152,17 @@ STATUS FtpWriteBlock(FTP *ftp, char *buffer, int size)
buffer=buffer2;
size=ii;
}
-
- if ((wsize=write(fileno(FTPDATA(ftp)),buffer,size))!=size)
+
+ if ((wsize=write(fileno(FTPDATA(ftp)),buffer,size))!=size)
return EXIT(ftp,QUIT);
-
+
if ( ftp->hash!=NULL && wsize!=0 ) (*ftp->hash)(ftp,wsize);
-
+
return wsize;
}
-
+