home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-14 | 42.3 KB | 1,593 lines |
- Newsgroups: comp.sources.misc
- From: orel@oea.ihep.su (Oleg Orel)
- Subject: v41i038: libftp - A C library interface for the FTP protocol, v1.2, Part05/05
- Message-ID: <1993Dec14.154930.25991@sparky.sterling.com>
- X-Md4-Signature: bd84091d33a5414e5c2be76707878074
- Sender: kent@sparky.sterling.com (Kent Landfield)
- Organization: Sterling Software
- Date: Tue, 14 Dec 1993 15:49:30 GMT
- Approved: kent@sparky.sterling.com
-
- Submitted-by: orel@oea.ihep.su (Oleg Orel)
- Posting-number: Volume 41, Issue 38
- Archive-name: libftp/part05
- Environment: UNIX
- Supersedes: libftp: Volume 38, Issue 52
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: libftp/FtpBye.c libftp/FtpClose.c libftp/FtpCommand.c
- # libftp/FtpConnect.c libftp/FtpDebug.c libftp/FtpFopen.c
- # libftp/FtpGetMessage.c libftp/FtpGetString.c libftp/FtpGood.c
- # libftp/FtpInitMessage.c libftp/FtpLibrary.h libftp/FtpLogin.c
- # libftp/FtpMessage.c libftp/FtpMove.c libftp/FtpNumber.c
- # libftp/FtpOpenDir.c libftp/FtpPort.c libftp/FtpPwd.c
- # libftp/FtpRead.c libftp/FtpRetrTimeout.c libftp/FtpSendMessage.c
- # libftp/FtpStorTimeout.c libftp/FtpType.c libftp/FtpWrite.c
- # libftp/Makefile libftp/examples/fcp.c libftp/examples/get.c
- # libftp/utils/Makefile
- # Wrapped by kent@sparky on Tue Dec 14 09:21:00 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 5 (of 5)."'
- if test -f 'libftp/FtpBye.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpBye.c'\"
- else
- echo shar: Extracting \"'libftp/FtpBye.c'\" \(730 characters\)
- sed "s/^X//" >'libftp/FtpBye.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpBye(FTP *sock)
- X{
- X String S1;
- X int i;
- X
- X if ( FtpSendMessage(sock,"QUIT") == QUIT )
- X return EXIT(sock,QUIT);
- X
- X if ( (i=FtpGetMessage(sock,S1)) == QUIT )
- X return EXIT(sock,QUIT);
- X
- X if ( i != 221 )
- X return EXIT(sock,-i);
- X
- X close(sock->sock);
- X free(sock);
- X return 0;
- X}
- X
- END_OF_FILE
- if test 730 -ne `wc -c <'libftp/FtpBye.c'`; then
- echo shar: \"'libftp/FtpBye.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpBye.c'
- fi
- if test -f 'libftp/FtpClose.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpClose.c'\"
- else
- echo shar: Extracting \"'libftp/FtpClose.c'\" \(644 characters\)
- sed "s/^X//" >'libftp/FtpClose.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpClose(FTP *sock)
- X{
- X int i;
- X String S1;
- X
- X fclose(sock->data);
- X
- X if ((i=FtpGetMessage(sock,S1))==QUIT)
- X return EXIT(sock,QUIT);
- X if ( i != 226 )
- X return EXIT(sock,-i);
- X return EXIT(sock,i);
- X}
- END_OF_FILE
- if test 644 -ne `wc -c <'libftp/FtpClose.c'`; then
- echo shar: \"'libftp/FtpClose.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpClose.c'
- fi
- if test -f 'libftp/FtpCommand.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpCommand.c'\"
- else
- echo shar: Extracting \"'libftp/FtpCommand.c'\" \(1198 characters\)
- sed "s/^X//" >'libftp/FtpCommand.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- X#include <varargs.h>
- X
- XSTATUS FtpCommand(va_alist)
- X va_dcl
- X{
- X FTP *con;
- X char *command, *param;
- X int Answer[MAX_ANSWERS];
- X va_list args;
- X String S1;
- X int i,counter=0;
- X
- X va_start(args);
- X
- X con = va_arg(args,FTP *);
- X command = va_arg(args,char *);
- X param = va_arg(args, char *);
- X
- X while ( 1 )
- X {
- X if (counter == MAX_ANSWERS)
- X return EXIT(con,QUIT);
- X Answer[counter] = va_arg(args,int);
- X if (Answer[counter] == EOF ) break;
- X counter++;
- X }
- X
- X va_end(args);
- X
- X
- X sprintf(S1,command,param);
- X
- X if ( FtpSendMessage(con,S1) == QUIT )
- X return EXIT(con,QUIT);
- X
- X if ( (i=FtpGetMessage(con,S1)) == QUIT )
- X return EXIT(con,QUIT);
- X
- X if ( ! FtpGood1 ( i , Answer ))
- X return EXIT(con,-i);
- X
- X return EXIT(con,i);
- X}
- X
- X
- X
- END_OF_FILE
- if test 1198 -ne `wc -c <'libftp/FtpCommand.c'`; then
- echo shar: \"'libftp/FtpCommand.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpCommand.c'
- fi
- if test -f 'libftp/FtpConnect.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpConnect.c'\"
- else
- echo shar: Extracting \"'libftp/FtpConnect.c'\" \(1841 characters\)
- sed "s/^X//" >'libftp/FtpConnect.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpConnect(FTP **con,char * hostname)
- X{
- X struct sockaddr_in unit;
- X register struct hostent *host;
- X register struct servent *service;
- X register int sock;
- X String S1;
- X STATUS x;
- X
- X *con = ( FTP * ) malloc ( sizeof (FTP));
- X
- X if ((host=FtpGetHost(hostname))==NULL)
- X return EXIT((*con),QUIT);
- X if ((service=(struct servent *) getservbyname("ftp","tcp"))==0)
- X return EXIT((*con),QUIT);
- X
- X unit.sin_family = host -> h_addrtype;
- X
- X bcopy(host-> h_addr_list[0],(char *)&unit.sin_addr,host->h_length);
- X if ( ( sock = socket ( unit.sin_family , SOCK_STREAM , 0)) < 0)
- X return EXIT((*con),QUIT);
- X
- X unit.sin_port = service -> s_port;
- X
- X while ( connect ( sock , &unit , sizeof unit ) < 0 )
- X {
- X host -> h_addr_list ++;
- X if (host -> h_addr_list[0]==NULL) {
- X close(sock);
- X return EXIT((*con),QUIT);
- X }
- X bcopy(host -> h_addr_list[0],(char *)&unit,host->h_length);
- X close(sock);
- X if ( ( sock = socket ( unit.sin_family , SOCK_STREAM , 0)) < 0)
- X {
- X close(sock);
- X return EXIT((*con),QUIT);
- X }
- X }
- X
- X (*con) -> sock = sock;
- X (*con) -> mode = 'A';
- X (*con) -> data = 0;
- X (*con) -> func = NULL;
- X (*con) -> debug = NULL;
- X
- X if (ftplib_debug) FtpDebug(*con);
- X
- X if ( (x=FtpGetMessage(*con,S1)) == QUIT )
- X return EXIT((*con),QUIT);
- X if ( ! FtpGood(x,120,220,EOF))
- X {
- X close(sock);
- X return EXIT((*con),-x);
- X }
- X return EXIT((*con),x);
- X}
- X
- X
- X
- END_OF_FILE
- if test 1841 -ne `wc -c <'libftp/FtpConnect.c'`; then
- echo shar: \"'libftp/FtpConnect.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpConnect.c'
- fi
- if test -f 'libftp/FtpDebug.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpDebug.c'\"
- else
- echo shar: Extracting \"'libftp/FtpDebug.c'\" \(1065 characters\)
- sed "s/^X//" >'libftp/FtpDebug.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xint ftplib_debug=FTP_nodebug;
- X
- X#define __EXIT if (ftplib_debug!=FTP_noexit) exit(-1)
- X
- Xvoid FtpDebug(FTP *ftp)
- X{
- X STATUS FtpDebugDebug(),
- X FtpDebugError(),
- X FtpDebugIO();
- X
- X FtpSetDebugHandler(ftp,FtpDebugDebug);
- X FtpSetErrorHandler(ftp,FtpDebugError);
- X FtpSetIOHandler(ftp,FtpDebugIO);
- X}
- X
- XSTATUS FtpDebugDebug(FTP *ftp,int n, char * Message)
- X{
- X fprintf(stderr,"DEBUG:: %s\n",Message);
- X return 1;
- X}
- X
- XSTATUS FtpDebugError(FTP *ftp,int n, char * Message)
- X{
- X fprintf(stderr,"Abort:: %s\n",Message);
- X __EXIT;
- X}
- X
- XSTATUS FtpDebugIO(FTP *ftp,int n, char * Message)
- X{
- X fprintf(stderr,"IO");
- X perror("");
- X __EXIT;
- X}
- X
- X
- X
- END_OF_FILE
- if test 1065 -ne `wc -c <'libftp/FtpDebug.c'`; then
- echo shar: \"'libftp/FtpDebug.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpDebug.c'
- fi
- if test -f 'libftp/FtpFopen.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpFopen.c'\"
- else
- echo shar: Extracting \"'libftp/FtpFopen.c'\" \(749 characters\)
- sed "s/^X//" >'libftp/FtpFopen.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include <FtpLibrary.h>
- X
- X
- XFILE *Ftpfopen(char *filename,char *mode)
- X{
- X
- X
- X if (strcmp(filename,"*STDIN*")==0)
- X return fdopen(stdin->_file,mode);
- X
- X if (strcmp(filename,"*STDOUT*")==0)
- X return fdopen(stdout->_file,mode);
- X
- X if (strcmp(filename,"*STDERR*")==0)
- X return fdopen(stderr->_file,mode);
- X
- X return fopen(filename,mode);
- X}
- X
- END_OF_FILE
- if test 749 -ne `wc -c <'libftp/FtpFopen.c'`; then
- echo shar: \"'libftp/FtpFopen.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpFopen.c'
- fi
- if test -f 'libftp/FtpGetMessage.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpGetMessage.c'\"
- else
- echo shar: Extracting \"'libftp/FtpGetMessage.c'\" \(1037 characters\)
- sed "s/^X//" >'libftp/FtpGetMessage.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xextern char * FtpMessageList[];
- X
- Xint FtpGetMessage(FTP *con , char * Message )
- X{
- X int i=0,n;
- X FILE *in=fdopen(con->sock,"r");
- X String tmp;
- X
- X while(1)
- X {
- X if (fgets(tmp,sizeof tmp,in)==NULL) return QUIT;
- X tmp[strlen(tmp)-1]='\0';
- X if (tmp[3]!='-') break;
- X if ( con -> debug != NULL )
- X (*con->debug)(con,n,tmp);
- X }
- X
- X strcpy(Message,tmp);
- X FtpInitMessageList();
- X FtpMessageList[n=FtpNumber(Message)] =
- X ( char * ) malloc ( strlen(Message) + 1);
- X strcpy(FtpMessageList[n] , Message );
- X if ( con -> debug != NULL )
- X (*con->debug)(con,n,Message);
- X
- X return n;
- X}
- X
- END_OF_FILE
- if test 1037 -ne `wc -c <'libftp/FtpGetMessage.c'`; then
- echo shar: \"'libftp/FtpGetMessage.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpGetMessage.c'
- fi
- if test -f 'libftp/FtpGetString.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpGetString.c'\"
- else
- echo shar: Extracting \"'libftp/FtpGetString.c'\" \(659 characters\)
- sed "s/^X//" >'libftp/FtpGetString.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpGetString(FTP *con ,char * str )
- X{
- X int i=0;
- X while ( (str[i]=FtpRead(con)) != '\n' && str[i] != EOF ) i++;
- X if ( str[i] != EOF )
- X {
- X str[i] = '\0';
- X return i;
- X }
- X str[i] = '\0';
- X return EOF;
- X}
- X
- END_OF_FILE
- if test 659 -ne `wc -c <'libftp/FtpGetString.c'`; then
- echo shar: \"'libftp/FtpGetString.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpGetString.c'
- fi
- if test -f 'libftp/FtpGood.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpGood.c'\"
- else
- echo shar: Extracting \"'libftp/FtpGood.c'\" \(1014 characters\)
- sed "s/^X//" >'libftp/FtpGood.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- X#include <varargs.h>
- X
- XSTATUS FtpGood(va_alist)
- X va_dcl
- X{
- X va_list args;
- X int Number;
- X int Answer[MAX_ANSWERS];
- X int counter=0;
- X
- X va_start(args);
- X
- X Number = va_arg(args,int);
- X
- X while ( 1 )
- X {
- X if (counter == MAX_ANSWERS)
- X return 0;
- X Answer[counter] = va_arg(args,int);
- X if (Answer[counter] == EOF ) break;
- X counter++;
- X }
- X
- X va_end(args);
- X
- X return FtpGood1(Number,Answer);
- X}
- X
- X
- XSTATUS FtpGood1(int Number , int *Answer)
- X{
- X while (1)
- X {
- X if ( *Answer == Number) return 1;
- X if ( *Answer == EOF ) return 0;
- X Answer++;
- X }
- X}
- X
- END_OF_FILE
- if test 1014 -ne `wc -c <'libftp/FtpGood.c'`; then
- echo shar: \"'libftp/FtpGood.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpGood.c'
- fi
- if test -f 'libftp/FtpInitMessage.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpInitMessage.c'\"
- else
- echo shar: Extracting \"'libftp/FtpInitMessage.c'\" \(620 characters\)
- sed "s/^X//" >'libftp/FtpInitMessage.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xchar * FtpMessageList[1000];
- X
- XSTATUS FtpInitMessageList()
- X{
- X int i;
- X static u = 0;
- X
- X if ( u )
- X return 1;
- X
- X u = 1;
- X
- X for (i=0;i<1000;i++)
- X FtpMessageList[i]=NULL;
- X
- X return 1;
- X}
- END_OF_FILE
- if test 620 -ne `wc -c <'libftp/FtpInitMessage.c'`; then
- echo shar: \"'libftp/FtpInitMessage.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpInitMessage.c'
- fi
- if test -f 'libftp/FtpLibrary.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpLibrary.h'\"
- else
- echo shar: Extracting \"'libftp/FtpLibrary.h'\" \(5437 characters\)
- sed "s/^X//" >'libftp/FtpLibrary.h' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#ifndef __FTPLIBRARY_H
- X#define __FTPLIBRARY_H
- X
- X
- X#ifdef __cplusplus
- X extern "C" {
- X#endif
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include <sys/socket.h>
- X#include <arpa/ftp.h>
- X#include <netinet/in.h>
- X#include <netdb.h>
- X
- X#ifdef _AIX
- Xint accept (int, struct sockaddr_in*, int*);
- Xchar *bcopy (char*, char*, size_t);
- Xint bind (int, const void*, int);
- Xint connect (int, struct sockaddr_in*, int);
- Xint gethostname (char*, size_t);
- Xint getsockname (int, struct sockaddr_in*, int*);
- Xint getpeername (int, struct sockaddr_in*, int*);
- Xint getsockopt (int, int, int, void*, int*);
- Xint listen(int, int);
- Xint setsockopt (int, int, int, (size_t);
- Xint socket (int, int, int);
- Xvoid free (void*);
- Xvoid *malloc (size_t);
- X#endif
- X
- Xextern int errno;
- X
- X
- X /* Standard Macros & Definitions */
- X
- X
- X
- X#define EXIT(con,e) \
- X ( con -> errno = e, \
- X ((con->func != NULL) && (e < 0) )?(*(con->func))(con,e,FtpMessage(e)) : 0,\
- X ((e==QUIT)&&(con->IO != NULL))?(*(con->IO))(con,errno,strerror(errno)):0,\
- X e\
- X )
- X
- X#define MAX_ANSWERS 10 /* Number of known goodest answers for reqest */
- X#define QUIT 0
- X#define Ctrl(x) ((x) - '@')
- X#define FREE(x) memset ( &x , '\0' , sizeof x )
- X#define CUT(x) ((x)&0xff)
- X
- Xtypedef int STATUS;
- Xtypedef char String[256];
- X
- X
- X /* Common Information Structure */
- X
- Xtypedef struct
- X{
- X int sock;
- X FILE *data;
- X char mode;
- X int errno;
- X int ch;
- X STATUS (*func)();
- X STATUS (*debug)();
- X STATUS (*IO)();
- X} FTP;
- X
- Xenum {FTP_nodebug,FTP_debug,FTP_noexit};
- X
- Xextern int ftplib_debug;
- X
- X/* Connect & disconnect */
- X
- XSTATUS FtpConnect(FTP **con,char *hostname);
- X#define FtpUser(ftp,user) FtpCommand(ftp,"USER %s",user,230,331,332,EOF)
- X#define FtpPassword(ftp,pas) FtpCommand(ftp,"PASS %s",pas,230,332,EOF)
- X#define FtpAccount(ftp,acc) FtpCommand(ftp,"ACCT %s",acc,230,EOF)
- XSTATUS FtpLogin(FTP **con,char *host ,char *user,char *pass,char *acct);
- XSTATUS FtpBye (FTP * con);
- X
- X/* Set type of transfer */
- X
- X#define FtpAscii(ftp) FtpType(ftp,"A")
- X#define FtpBinary(ftp) FtpType(ftp,"I")
- X
- X
- X/* Receive Procedures */
- X
- XSTATUS FtpRetrTimeout(FTP *con, char *command,char *inp,char *out,long time);
- X#define FtpRetr(ftp,com,inp,out) FtpRetrTimeout(ftp,com,inp,out,0)
- X#define FtpGet(ftp,in,out) FtpRetr(ftp,"RETR %s",in,out)
- X#define FtpGetTimeout(ftp,in,out,t) FtpRetrTimeout(ftp,"RETR %s",in,out,t)
- X#define FtpDirectory(ftp,pat,out) FtpRetr(ftp,"LIST %s",pat,out)
- X#define FtpDir(ftp,out) FtpRetr(ftp,"LIST","",out)
- X
- X/* Send Procedures */
- X
- XSTATUS FtpStorTimeout(FTP *con ,char*command ,char *inp,char *out,long time);
- X#define FtpStor(ftp,com,inp,out) FtpStorTimeout(ftp,com,imp,out,0)
- X#define FtpPut(ftp,in,out) FtpStor(ftp,"STOR %s",in,out)
- X#define FtpPutTimeout(ftp,in,out,t) FtpStorTimeout(ftp,"STOR %s",in,out,t)
- X
- X/* Command for remote server for startup transfer */
- X
- X#define FtpGetFile(ftp,file) FtpCommand(ftp,"RETR %s",file,\
- X 200,125,150,250,EOF)
- X#define FtpPutFile(ftp,file) FtpCommand(ftp,"STOR %s",file,\
- X 200,125,150,250,EOF)
- X
- X/* Command for remote server for startup transfer and make data connection */
- X
- XSTATUS FtpData( FTP * con , char * command , char * param , char *mode);
- XSTATUS FtpPort ( FTP *con ,int ,int ,int ,int ,int ,int );
- X#define FtpOpenRead(ftp,file) FtpData(ftp,"RETR %s",file,"r")
- X#define FtpOpenWrite(ftp,file) FtpData(ftp,"STOR %s",file,"w")
- X#define FtpOpenAppend(ftp,file) FtpData(ftp,"APPE %s",file,"r")
- XSTATUS FtpOpenDir( FTP * con , char * files );
- XSTATUS FtpClose ( FTP *);
- X
- X/* Command for handing transfer */
- X
- XSTATUS FtpGetString ( FTP * con , char * str );
- XSTATUS FtpRead ( FTP * con);
- XSTATUS FtpWrite ( FTP * con , char c);
- X
- X
- X/* Manipulation commands for remote server */
- X
- XSTATUS FtpCommand ();
- X#define FtpChdir(ftp,dir) FtpCommand(ftp,"CWD %s",dir,200,250,EOF)
- X#define FtpMkdir(ftp,dir) FtpCommand(ftp,"MKD %s",dir,200,257,EOF)
- X#define FtpRm(ftp,dir) FtpCommand(ftp,"DELE %s",dir,200,250,EOF)
- Xchar *FtpPwd(FTP *con);
- XSTATUS FtpMove ( FTP *con,char * old,char *new);
- X
- X/* Procedures for dialog with remote server */
- X
- XSTATUS FtpInitMessageList();
- XSTATUS FtpSendMessage( FTP * con , char * Message );
- Xint FtpGetMessage( FTP * con , char * Message);
- Xchar *FtpMessage(int Number);
- Xint FtpNumber ( char * Message );
- X
- X
- X/* Debug */
- X
- X#define FtpSetErrorHandler(con,f) con->func = f
- X#define FtpSetDebugHandler(con,f) con->debug = f
- X#define FtpSetIOHandler(con,f) con->IO =f
- X#define FtplibDebug(t) ftplib_debug=t
- XSTATUS FtpDebugDebug ( FTP *con, int errno, char * Message);
- XSTATUS FtpDebugError ( FTP *con, int errno, char * Message);
- XSTATUS FtpDebugIO ( FTP *con, int errno, char * Message);
- Xvoid FtpDebug ( FTP * con );
- X
- X
- X/* Other Procedures */
- X
- XFILE *FtpFullOpen(char * file,char * mode );
- XFILE *Ftpfopen(char *filename,char *mode);
- XSTATUS FtpFullClose(FILE *);
- XSTATUS FtpGood ();
- Xstruct hostent *FtpGetHost(char *host);
- X
- X#ifdef __cplusplus
- X}
- X#endif
- X
- X
- X#endif /* __FTPLIBRARYH_ */
- X
- X
- X
- END_OF_FILE
- if test 5437 -ne `wc -c <'libftp/FtpLibrary.h'`; then
- echo shar: \"'libftp/FtpLibrary.h'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpLibrary.h'
- fi
- if test -f 'libftp/FtpLogin.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpLogin.c'\"
- else
- echo shar: Extracting \"'libftp/FtpLogin.c'\" \(885 characters\)
- sed "s/^X//" >'libftp/FtpLogin.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpLogin ( FTP ** con, char * host , char * user ,
- X char * password , char * account)
- X{
- X STATUS x;
- X
- X if ( (x=FtpConnect(con,host)) < 1)
- X return x;
- X if ( (x=FtpUser(*con,user)) < 1)
- X return x;
- X if ( x==230 )
- X return x;
- X if ( x==332)
- X {
- X if ( account == NULL )
- X return EXIT((*con),x);
- X if ( (x=FtpAccount( *con , account )) < 1 )
- X return x;
- X if ( x==230 )
- X return x;
- X }
- X return FtpPassword(*con,password);
- X}
- END_OF_FILE
- if test 885 -ne `wc -c <'libftp/FtpLogin.c'`; then
- echo shar: \"'libftp/FtpLogin.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpLogin.c'
- fi
- if test -f 'libftp/FtpMessage.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpMessage.c'\"
- else
- echo shar: Extracting \"'libftp/FtpMessage.c'\" \(660 characters\)
- sed "s/^X//" >'libftp/FtpMessage.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xextern char * FtpMessageList[];
- X
- Xchar *FtpMessage(int number)
- X{
- X FtpInitMessageList();
- X if ( number == 0 )
- X return "I/O Error , use perror";
- X return (FtpMessageList[abs(number)]==NULL)?
- X "":FtpMessageList[abs(number)];
- X}
- END_OF_FILE
- if test 660 -ne `wc -c <'libftp/FtpMessage.c'`; then
- echo shar: \"'libftp/FtpMessage.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpMessage.c'
- fi
- if test -f 'libftp/FtpMove.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpMove.c'\"
- else
- echo shar: Extracting \"'libftp/FtpMove.c'\" \(646 characters\)
- sed "s/^X//" >'libftp/FtpMove.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpMove(FTP *con,char * oldname , char * newname )
- X{
- X STATUS i;
- X
- X if ((i=FtpCommand(con,"RNFR %s",oldname,200,350,EOF)) > 1 )
- X return FtpCommand(con,"RNTO %s",newname,200,250,EOF);
- X else
- X return i;
- X}
- END_OF_FILE
- if test 646 -ne `wc -c <'libftp/FtpMove.c'`; then
- echo shar: \"'libftp/FtpMove.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpMove.c'
- fi
- if test -f 'libftp/FtpNumber.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpNumber.c'\"
- else
- echo shar: Extracting \"'libftp/FtpNumber.c'\" \(558 characters\)
- sed "s/^X//" >'libftp/FtpNumber.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xint FtpNumber(char *Message)
- X{
- X return (Message[0] - '0') * 100 +
- X (Message[1] - '0') * 10 +
- X (Message[2] - '0') ;
- X}
- END_OF_FILE
- if test 558 -ne `wc -c <'libftp/FtpNumber.c'`; then
- echo shar: \"'libftp/FtpNumber.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpNumber.c'
- fi
- if test -f 'libftp/FtpOpenDir.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpOpenDir.c'\"
- else
- echo shar: Extracting \"'libftp/FtpOpenDir.c'\" \(659 characters\)
- sed "s/^X//" >'libftp/FtpOpenDir.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpOpenDir(FTP * con,char * file)
- X{
- X String command;
- X
- X if ( file == NULL || *file == '\0' )
- X strcpy(command,"NLST");
- X else
- X sprintf(command,"NLST %s",file);
- X
- X return FtpCommand(con,command,"",120,150,200,EOF);
- X}
- END_OF_FILE
- if test 659 -ne `wc -c <'libftp/FtpOpenDir.c'`; then
- echo shar: \"'libftp/FtpOpenDir.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpOpenDir.c'
- fi
- if test -f 'libftp/FtpPort.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpPort.c'\"
- else
- echo shar: Extracting \"'libftp/FtpPort.c'\" \(776 characters\)
- sed "s/^X//" >'libftp/FtpPort.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpPort(FTP *con,int a,int b,int c,int d,int e,int f)
- X{
- X String cmd;
- X int i;
- X
- X sprintf(cmd,"PORT %d,%d,%d,%d,%d,%d",a,b,c,d,e,f);
- X if ( FtpSendMessage(con,cmd) == QUIT)
- X return QUIT;
- X if ( (i=FtpGetMessage(con,cmd)) == QUIT)
- X return QUIT;
- X
- X if ( ! FtpGood ( i , 200 , EOF ))
- X return EXIT(con,-i);
- X
- X return EXIT(con,i);
- X}
- END_OF_FILE
- if test 776 -ne `wc -c <'libftp/FtpPort.c'`; then
- echo shar: \"'libftp/FtpPort.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpPort.c'
- fi
- if test -f 'libftp/FtpPwd.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpPwd.c'\"
- else
- echo shar: Extracting \"'libftp/FtpPwd.c'\" \(782 characters\)
- sed "s/^X//" >'libftp/FtpPwd.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xchar * FtpPwd(FTP * con)
- X{
- X String tmp,tmp1;
- X int i;
- X
- X if ( FtpSendMessage(con,"PWD") == QUIT )
- X return (char *) EXIT(con,QUIT);
- X if ( (i=FtpGetMessage(con,tmp)) == QUIT )
- X return (char *) EXIT(con,QUIT);
- X
- X if ( i != 257 )
- X return (char *) EXIT(con,-i);
- X
- X sscanf(tmp,"%*[^\"]%*c%[^\"]%*s",tmp1);
- X con -> errno = i;
- X return tmp1;
- X}
- END_OF_FILE
- if test 782 -ne `wc -c <'libftp/FtpPwd.c'`; then
- echo shar: \"'libftp/FtpPwd.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpPwd.c'
- fi
- if test -f 'libftp/FtpRead.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpRead.c'\"
- else
- echo shar: Extracting \"'libftp/FtpRead.c'\" \(819 characters\)
- sed "s/^X//" >'libftp/FtpRead.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xint FtpRead(FTP *con)
- X{
- X int c;
- X
- X if ( con -> mode == 'I' )
- X return getc(con->data);
- X
- X if ( con->ch != EOF )
- X {
- X c=con->ch;
- X con->ch=EOF;
- X return c;
- X }
- X
- X c=getc(con->data);
- X
- X if ( c == Ctrl('M') )
- X {
- X c = getc ( con->data);
- X
- X if ( c == Ctrl('J') )
- X return '\n';
- X con->ch = c;
- X return Ctrl('M');
- X }
- X return c;
- X}
- X
- END_OF_FILE
- if test 819 -ne `wc -c <'libftp/FtpRead.c'`; then
- echo shar: \"'libftp/FtpRead.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpRead.c'
- fi
- if test -f 'libftp/FtpRetrTimeout.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpRetrTimeout.c'\"
- else
- echo shar: Extracting \"'libftp/FtpRetrTimeout.c'\" \(1070 characters\)
- sed "s/^X//" >'libftp/FtpRetrTimeout.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X#include <setjmp.h>
- X#include <signal.h>
- X
- XSTATUS hook();
- Xjmp_buf env;
- X
- XSTATUS FtpRetrTimeout (FTP * con , char * command ,
- X char *in , char * out,long timeout)
- X{
- X FILE *o;
- X int c;
- X
- X if (setjmp(env)!=0)
- X {
- X if (con->data!=NULL) fclose(con->data);
- X close(con->sock);
- X return EXIT(con,QUIT);
- X }
- X
- X signal(SIGALRM,hook);
- X
- X if ( FtpData(con,command,in,"r") < 1 )
- X return EXIT(con,con->errno);
- X
- X if ( (o=Ftpfopen(out,"w")) == NULL )
- X return EXIT(con,QUIT);
- X while ( (c=(alarm(timeout),FtpRead(con))) != EOF )
- X putc(c,o);
- X fclose(o);
- X return FtpClose(con);
- X}
- X
- Xstatic hook()
- X{
- X longjmp(env,1);
- X}
- X
- END_OF_FILE
- if test 1070 -ne `wc -c <'libftp/FtpRetrTimeout.c'`; then
- echo shar: \"'libftp/FtpRetrTimeout.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpRetrTimeout.c'
- fi
- if test -f 'libftp/FtpSendMessage.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpSendMessage.c'\"
- else
- echo shar: Extracting \"'libftp/FtpSendMessage.c'\" \(708 characters\)
- sed "s/^X//" >'libftp/FtpSendMessage.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpSendMessage(FTP *con,char * Message )
- X{
- X if ( write ( con -> sock , Message , strlen (Message)) == -1 )
- X return QUIT;
- X if ( write ( con -> sock , "\015\012",2) == -1 )
- X return QUIT;
- X if ( con -> debug != NULL )
- X (*con->debug)(con,0,Message);
- X return 1;
- X}
- END_OF_FILE
- if test 708 -ne `wc -c <'libftp/FtpSendMessage.c'`; then
- echo shar: \"'libftp/FtpSendMessage.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpSendMessage.c'
- fi
- if test -f 'libftp/FtpStorTimeout.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpStorTimeout.c'\"
- else
- echo shar: Extracting \"'libftp/FtpStorTimeout.c'\" \(1069 characters\)
- sed "s/^X//" >'libftp/FtpStorTimeout.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X#include <setjmp.h>
- X#include <signal.h>
- X
- XSTATUS hook();
- Xjmp_buf env;
- X
- XSTATUS FtpStorTimeout (FTP * con , char * command ,
- X char *in , char * out,long timeout)
- X{
- X FILE *i;
- X int c;
- X
- X if (setjmp(env)!=0)
- X {
- X if (con->data!=NULL) fclose(con->data);
- X close(con->sock);
- X return EXIT(con,QUIT);
- X }
- X
- X signal(SIGALRM,hook);
- X
- X if ( FtpData(con,command,out,"w") < 1 )
- X return EXIT(con,con->errno);
- X
- X if ( (i=Ftpfopen(in,"r")) == NULL )
- X return EXIT(con,QUIT);
- X while ( (c=getc(i)) != EOF )
- X alarm(timeout),FtpWrite(con,c);
- X fclose(i);
- X return FtpClose(con);
- X}
- X
- Xstatic hook()
- X{
- X longjmp(env,1);
- X}
- X
- END_OF_FILE
- if test 1069 -ne `wc -c <'libftp/FtpStorTimeout.c'`; then
- echo shar: \"'libftp/FtpStorTimeout.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpStorTimeout.c'
- fi
- if test -f 'libftp/FtpType.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpType.c'\"
- else
- echo shar: Extracting \"'libftp/FtpType.c'\" \(577 characters\)
- sed "s/^X//" >'libftp/FtpType.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- XSTATUS FtpType(FTP *ftp, char *type)
- X{
- X STATUS p;
- X
- X if ((p=FtpCommand(ftp,"TYPE %s",type,200,EOF))>0)
- X ftp->mode=type[0];
- X return p;
- X}
- X
- X
- END_OF_FILE
- if test 577 -ne `wc -c <'libftp/FtpType.c'`; then
- echo shar: \"'libftp/FtpType.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpType.c'
- fi
- if test -f 'libftp/FtpWrite.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/FtpWrite.c'\"
- else
- echo shar: Extracting \"'libftp/FtpWrite.c'\" \(819 characters\)
- sed "s/^X//" >'libftp/FtpWrite.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xint FtpWrite(FTP *con,char c)
- X{
- X int i;
- X
- X if ( con -> mode == 'I' )
- X {
- X if (putc(c,con->data)==EOF)
- X return EXIT(con,QUIT);
- X else
- X return 0;
- X }
- X
- X if ( c == '\n' )
- X {
- X if (putc(Ctrl('M'),con->data)==EOF)
- X return EXIT(con,QUIT);
- X i=putc(Ctrl('J'),con->data);
- X }
- X else
- X i = putc ( c , con->data );
- X if (i==EOF) return EXIT(con,QUIT);
- X return i;
- X}
- END_OF_FILE
- if test 819 -ne `wc -c <'libftp/FtpWrite.c'`; then
- echo shar: \"'libftp/FtpWrite.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/FtpWrite.c'
- fi
- if test -f 'libftp/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/Makefile'\"
- else
- echo shar: Extracting \"'libftp/Makefile'\" \(1073 characters\)
- sed "s/^X//" >'libftp/Makefile' <<'END_OF_FILE'
- X#
- X# Library for ftpd clients.(libftp)
- X# Copyright by Oleg Orel
- X# All rights reserved.
- X#
- X#This library is desined for free, non-commercial software creation.
- X#It is changeable and can be improved. The author would greatly appreciate
- X#any advises, new components and patches of the existing programs.
- X#Commercial usage is also possible with participation of it's author.
- X#
- X
- X
- XLIBDIR = /usr/lib
- XINCDIR = /usr/include
- XCFLAGS =
- X
- XOBJS = FtpBye.o \
- X FtpType.o \
- X FtpClose.o \
- X FtpCommand.o \
- X FtpConnect.o \
- X FtpData.o \
- X FtpDebug.o \
- X FtpFopen.o \
- X FtpFull.o \
- X FtpGetHost.o \
- X FtpGetMessage.o \
- X FtpGetString.o \
- X FtpGood.o \
- X FtpInitMessage.o \
- X FtpLogin.o \
- X FtpMessage.o \
- X FtpMove.o \
- X FtpNumber.o \
- X FtpOpenDir.o \
- X FtpPort.o \
- X FtpPwd.o \
- X FtpRead.o \
- X FtpRetrTimeout.o \
- X FtpStorTimeout.o \
- X FtpSendMessage.o \
- X FtpWrite.o
- X
- X
- Xall: libftp.a
- X
- Xlibftp.a: $(OBJS)
- X rm -f $@
- X ar cq $@ $* $(OBJS)
- X ranlib $@
- X
- X
- Xinstall: all
- X cp libftp.a $(LIBDIR)
- X cp FtpLibrary.h $(INCDIR)
- X
- X
- Xclean:
- X rm -f libftp.a $(OBJS)
- END_OF_FILE
- if test 1073 -ne `wc -c <'libftp/Makefile'`; then
- echo shar: \"'libftp/Makefile'\" unpacked with wrong size!
- fi
- # end of 'libftp/Makefile'
- fi
- if test -f 'libftp/examples/fcp.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/examples/fcp.c'\"
- else
- echo shar: Extracting \"'libftp/examples/fcp.c'\" \(906 characters\)
- sed "s/^X//" >'libftp/examples/fcp.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xmain(int a,char **b)
- X{
- X FILE *out,*in;
- X int c;
- X extern int ftplib_debug;
- X
- X
- X FtplibDebug(1);
- X
- X if ( a != 3 )
- X {
- X fprintf(stderr,
- X "Usage: %s node/user/pass:input-file node/user/pass:out-file\n",
- X b[0]);
- X exit(1);
- X }
- X
- X if ((in=FtpFullOpen(b[1],"rb"))==NULL)
- X perror(b[1]),exit(1);
- X if ((out=FtpFullOpen(b[2],"w"))==NULL)
- X perror(b[2]),exit(1);
- X
- X
- X while((c=getc(in))!=EOF)
- X putc(c,out);
- X FtpFullClose(in);
- X FtpFullClose(out);
- X}
- END_OF_FILE
- if test 906 -ne `wc -c <'libftp/examples/fcp.c'`; then
- echo shar: \"'libftp/examples/fcp.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/examples/fcp.c'
- fi
- if test -f 'libftp/examples/get.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/examples/get.c'\"
- else
- echo shar: Extracting \"'libftp/examples/get.c'\" \(882 characters\)
- sed "s/^X//" >'libftp/examples/get.c' <<'END_OF_FILE'
- X/*
- X Library for ftpd clients.(libftp)
- X Copyright by Oleg Orel
- X All rights reserved.
- X
- XThis library is desined for free, non-commercial software creation.
- XIt is changeable and can be improved. The author would greatly appreciate
- Xany advises, new components and patches of the existing programs.
- XCommercial usage is also possible with participation of it's author.
- X
- X
- X
- X*/
- X
- X#include "FtpLibrary.h"
- X
- Xmain(int a,char **b)
- X{
- X FILE *out,*in;
- X String localfile;
- X int c;
- X
- X
- X if ( a != 2 )
- X {
- X fprintf(stderr,
- X "Usage: %s node/user/pass:input-file\n",
- X b[0]);
- X exit(1);
- X }
- X if ((in=FtpFullOpen(b[1],"r"))==NULL)
- X perror(b[1]),exit(1);
- X sscanf(b[1],"%*[^:]:%s",localfile);
- X if ((out=fopen(localfile,"w"))==NULL)
- X perror(b[2]),exit(1);
- X
- X while((c=getc(in))!=EOF)
- X putc(c,out);
- X FtpFullClose(in);
- X fclose(out);
- X}
- END_OF_FILE
- if test 882 -ne `wc -c <'libftp/examples/get.c'`; then
- echo shar: \"'libftp/examples/get.c'\" unpacked with wrong size!
- fi
- # end of 'libftp/examples/get.c'
- fi
- if test -f 'libftp/utils/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libftp/utils/Makefile'\"
- else
- echo shar: Extracting \"'libftp/utils/Makefile'\" \(134 characters\)
- sed "s/^X//" >'libftp/utils/Makefile' <<'END_OF_FILE'
- XCFLAGS = -g -I.. -L..
- XALL=ftptry
- X
- Xall: $(ALL)
- X
- Xftptry: ftptry.o
- X cc $(CFLAGS) -o ftptry ftptry.o -lftp
- X
- Xclean:
- X rm -f $(ALL) *~ *.o
- X
- END_OF_FILE
- if test 134 -ne `wc -c <'libftp/utils/Makefile'`; then
- echo shar: \"'libftp/utils/Makefile'\" unpacked with wrong size!
- fi
- # end of 'libftp/utils/Makefile'
- fi
- echo shar: End of archive 5 \(of 5\).
- cp /dev/null ark5isdone
- MISSING=""
- for I in 1 2 3 4 5 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 5 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-