summaryrefslogtreecommitdiffstats
path: root/lib/libftp/FtpRetr.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-04-25 15:05:11 +0000
committerjkh <jkh@FreeBSD.org>1995-04-25 15:05:11 +0000
commite20597c1efe3291616fa34994320d3b84f438406 (patch)
tree88cfa9d7eaa46d2f2d75ccd97c6e76dd615873a2 /lib/libftp/FtpRetr.c
parente565b4e20cc93af3226a11de3ed04a0fa45f91fe (diff)
parent02ace706173509b7d8549494277ff682b7cefb8a (diff)
downloadFreeBSD-src-e20597c1efe3291616fa34994320d3b84f438406.zip
FreeBSD-src-e20597c1efe3291616fa34994320d3b84f438406.tar.gz
This commit was generated by cvs2svn to compensate for changes in r8064,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'lib/libftp/FtpRetr.c')
-rw-r--r--lib/libftp/FtpRetr.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/lib/libftp/FtpRetr.c b/lib/libftp/FtpRetr.c
new file mode 100644
index 0000000..889621f
--- /dev/null
+++ b/lib/libftp/FtpRetr.c
@@ -0,0 +1,82 @@
+/*
+ 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
+any advises, new components and patches of the existing programs.
+Commercial usage is also possible with participation of it's author.
+
+
+
+*/
+
+#include "FtpLibrary.h"
+
+STATUS FtpRetr (FTP * con , char * command ,
+ char *in , char * out)
+{
+ FILE *o;
+ int c;
+ struct stat st;
+ char buffer[FTPBUFSIZ],buffer2[FTPBUFSIZ];
+ register int size;
+
+ FtpFilenameChecker(&in,&out);
+
+ if ( FtpTestFlag(con,FTP_REST) && stat(out,&st)==0)
+ {
+ con -> seek = st.st_size;
+ if ((o=Ftpfopen(out,"a+"))==NULL)
+ return EXIT(con,LQUIT);
+ }
+ else
+ {
+ con -> seek = 0;
+ if ((o=Ftpfopen(out,"w+"))==NULL)
+ return EXIT(con,LQUIT);
+ }
+
+
+ if ( FtpError(FtpData(con,command,in,"r")))
+ {
+
+ if (con->seek==0) return EXIT(con,con->errno);
+
+ con -> seek = 0;
+ fclose(o);
+
+ if ( FtpError(FtpData(con,command,in,"r")) )
+ {
+ return EXIT(con,con->errno);
+ }
+
+ if ((o=Ftpfopen(out,"w+"))==NULL)
+ return EXIT(con,LQUIT);
+ }
+
+
+ fseek(o,con->seek,0);
+
+ while((size=FtpReadBlock(con,buffer,FTPBUFSIZ))>0)
+ {
+ if (write(fileno(o),buffer,size)!=size)
+ return EXIT(con,LQUIT);
+ }
+
+ Ftpfclose(o);
+ return FtpClose(con);
+}
+
+
+
+
+
+
+
+
+
+
+
+
OpenPOWER on IntegriCloud