summaryrefslogtreecommitdiffstats
path: root/lib/libftp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libftp')
-rw-r--r--lib/libftp/FtpAbort.c18
-rw-r--r--lib/libftp/FtpArchie.c22
-rw-r--r--lib/libftp/FtpBye.c10
-rw-r--r--lib/libftp/FtpClose.c8
-rw-r--r--lib/libftp/FtpCommand.c22
-rw-r--r--lib/libftp/FtpConnect.c22
-rw-r--r--lib/libftp/FtpCopy.c12
-rw-r--r--lib/libftp/FtpData.c24
-rw-r--r--lib/libftp/FtpDebug.c18
-rw-r--r--lib/libftp/FtpFilenameChecker.c10
-rw-r--r--lib/libftp/FtpFull.c32
-rw-r--r--lib/libftp/FtpGetHost.c8
-rw-r--r--lib/libftp/FtpGood.c12
-rw-r--r--lib/libftp/FtpIO.c66
-rw-r--r--lib/libftp/FtpInit.c6
-rw-r--r--lib/libftp/FtpLibrary.h36
-rw-r--r--lib/libftp/FtpLogin.c10
-rw-r--r--lib/libftp/FtpMessage.c32
-rw-r--r--lib/libftp/FtpMove.c6
-rw-r--r--lib/libftp/FtpNumber.c6
-rw-r--r--lib/libftp/FtpOpenDir.c6
-rw-r--r--lib/libftp/FtpPasv.c28
-rw-r--r--lib/libftp/FtpPort.c8
-rw-r--r--lib/libftp/FtpPwd.c10
-rw-r--r--lib/libftp/FtpRetr.c22
-rw-r--r--lib/libftp/FtpSize.c10
-rw-r--r--lib/libftp/FtpStor.c20
-rw-r--r--lib/libftp/FtpSyscalls.c6
-rw-r--r--lib/libftp/FtpType.c10
-rw-r--r--lib/libftp/Ftpfopen.c34
-rw-r--r--lib/libftp/doc/example.c14
-rw-r--r--lib/libftp/utils/Makefile6
-rw-r--r--lib/libftp/utils/ftptry.c120
-rw-r--r--lib/libftp/utils/glob.c46
-rw-r--r--lib/libftp/utils/glob.h2
-rw-r--r--lib/libftp/utils/mirror.c8
-rw-r--r--lib/libftp/utils/readline.c42
-rw-r--r--lib/libftp/utils/uftp.c232
-rw-r--r--lib/libftp/utils/uftpcmd.c346
39 files changed, 675 insertions, 675 deletions
diff --git a/lib/libftp/FtpAbort.c b/lib/libftp/FtpAbort.c
index 98d72b8..80943e5 100644
--- a/lib/libftp/FtpAbort.c
+++ b/lib/libftp/FtpAbort.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -21,20 +21,20 @@ FtpAbort(FTP *ftp)
fd_set fds;
char msgc=IAC;
String msg;
-
+
FD_ZERO(&fds);
FD_SET(fileno(FTPCMD(ftp)),&fds);
-
+
FtpPutc(ftp, FTPCMD(ftp), IAC);
FtpPutc(ftp, FTPCMD(ftp), IP);
-
+
if ( send ( fileno(FTPCMD(ftp)), &msgc , 1 ,MSG_OOB) != 1 )
return EXIT(ftp,QUIT);
-
+
FtpPutc(ftp, FTPCMD(ftp), DM);
-
+
FtpSendMessage(ftp,"ABOR");
-
+
while (select ( getdtablesize(), &fds, 0,0, &(ftp->timeout) )>0)
{
FtpGetMessage(ftp,msg);
diff --git a/lib/libftp/FtpArchie.c b/lib/libftp/FtpArchie.c
index 7f039be..22a05e1 100644
--- a/lib/libftp/FtpArchie.c
+++ b/lib/libftp/FtpArchie.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -21,18 +21,18 @@ int FtpArchie ( char *what, ARCHIE *result, int len)
FILE *archie;
String cmd,tmp;
int i;
-
+
bzero(result,sizeof(result[0])*len);
-
+
sprintf(cmd,"archie -l -m %d %s",len,what);
-
+
if ((archie = popen(cmd,"r"))==NULL)
return 0;
for(i=0;i<len;i++)
{
char *p, *pp;
-
+
if (fgets(tmp,sizeof (tmp), archie)==NULL)
break;
@@ -42,15 +42,15 @@ int FtpArchie ( char *what, ARCHIE *result, int len)
result[i].createtime.tm_hour = C2I (tmp[6 ])*10 + C2I(tmp[7]);
result[i].createtime.tm_min = C2I (tmp[8 ])*10 + C2I(tmp[9]);
result[i].createtime.tm_sec = C2I (tmp[10])*10 + C2I(tmp[11]);
-
+
for(p=tmp; *p!=' '; p++);
for(; *p==' '; p++);
-
+
result[i].size = atoi(p);
for(; *p!=' '; p++);
for(; *p==' '; p++);
-
+
for (pp=result[i].host;*p!=' ';p++,pp++) *pp=*p;
*pp=0;
for(; *p==' '; p++);
@@ -58,6 +58,6 @@ int FtpArchie ( char *what, ARCHIE *result, int len)
*pp=0;
}
-
+
return i;
}
diff --git a/lib/libftp/FtpBye.c b/lib/libftp/FtpBye.c
index f664cf6..7094843 100644
--- a/lib/libftp/FtpBye.c
+++ b/lib/libftp/FtpBye.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -23,11 +23,11 @@ STATUS FtpBye(FTP *ftp)
free(ftp);
return 0;
}
-
+
STATUS FtpQuickBye(FTP *ftp)
{
if (ftp == NULL) return 0;
-
+
if (FTPDATA(ftp)!=NULL)
{
shutdown(fileno(FTPDATA(ftp)),2);
diff --git a/lib/libftp/FtpClose.c b/lib/libftp/FtpClose.c
index 26dbc51..a14658e 100644
--- a/lib/libftp/FtpClose.c
+++ b/lib/libftp/FtpClose.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 existing programs.
Commercial usage is also possible with participation of it's author.
*/
@@ -18,7 +18,7 @@ STATUS FtpClose(FTP *ftp)
fflush(FTPDATA(ftp));
shutdown(fileno(FTPDATA(ftp)),2);
fclose(FTPDATA(ftp));
-
+
FtpAssert(ftp,i=FtpGetMessage(ftp,S1));
if ( i != 226 )
return EXIT(ftp,-i);
diff --git a/lib/libftp/FtpCommand.c b/lib/libftp/FtpCommand.c
index 94e8594..25fd460 100644
--- a/lib/libftp/FtpCommand.c
+++ b/lib/libftp/FtpCommand.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -24,7 +24,7 @@ STATUS FtpCommand(va_alist)
va_list args;
String S1;
int i,counter=0;
-
+
va_start(args);
con = va_arg(args,FTP *);
@@ -41,21 +41,21 @@ STATUS FtpCommand(va_alist)
}
va_end(args);
-
-
+
+
sprintf(S1,command,param);
if ( FtpSendMessage(con,S1) == QUIT )
return EXIT(con,QUIT);
-
+
if ( (i=FtpGetMessage(con,S1)) == QUIT )
return EXIT(con,QUIT);
-
+
if ( ! FtpGood1 ( i , Answer ))
return EXIT(con,-i);
return EXIT(con,i);
}
-
-
-
+
+
+
diff --git a/lib/libftp/FtpConnect.c b/lib/libftp/FtpConnect.c
index e114a50..4de95ab 100644
--- a/lib/libftp/FtpConnect.c
+++ b/lib/libftp/FtpConnect.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -22,22 +22,22 @@ STATUS FtpConnect(FTP **con,char * hostname)
register int new_socket;
String S1;
STATUS x;
-
+
*con = FtpCreateObject();
-
+
if ((host=FtpGetHost(hostname))==NULL)
return EXIT((*con),QUIT);
-
+
strcpy((*con) -> title,host -> h_name); /* Default title for FtpLog */
-
+
unit.sin_family = host -> h_addrtype; /* AF_INET */
-
+
bcopy(host-> h_addr_list[0],(char *)&unit.sin_addr,host->h_length);
if ( ( new_socket = socket ( unit.sin_family , SOCK_STREAM , 0)) < 0)
return EXIT((*con),QUIT);
unit.sin_port = htons((*con)->port);
-
+
while ( connect ( new_socket , (struct sockaddr *)&unit , sizeof unit ) < 0 )
{
host -> h_addr_list ++;
@@ -53,7 +53,7 @@ STATUS FtpConnect(FTP **con,char * hostname)
return EXIT((*con),QUIT);
}
}
-
+
FTPCMD(*con) = fdopen(new_socket,"r+");
if ( (x=FtpGetMessage(*con,S1)) == QUIT )
@@ -64,7 +64,7 @@ STATUS FtpConnect(FTP **con,char * hostname)
return EXIT((*con),-x);
}
if ( (*con)->mode != 'A' ) FtpType(*con,(*con)->mode);
-
+
return EXIT((*con),x);
}
diff --git a/lib/libftp/FtpCopy.c b/lib/libftp/FtpCopy.c
index d09fd36..db582d2 100644
--- a/lib/libftp/FtpCopy.c
+++ b/lib/libftp/FtpCopy.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -21,19 +21,19 @@ STATUS FtpCopy (FTP * ftp1 , FTP * ftp2 ,char *in , char * out)
if (!*out) out=in;
- if ( FtpTestFlag(ftp1,FTP_REST) && FtpTestFlag(ftp2,FTP_REST)
+ if ( FtpTestFlag(ftp1,FTP_REST) && FtpTestFlag(ftp2,FTP_REST)
&& (size=FtpSize(ftp1,in))>0
&& FtpCommand(ftp1,"REST 0",0,0,EOF)==350 && FtpCommand(ftp2,"REST 0",0,0,EOF)==350 )
ftp1->seek=ftp2->seek=size;
else
ftp1->seek=ftp2->seek=0;
-
+
FtpAssert(ftp1,FtpData(ftp1,"RETR %s",in,"r"));
FtpAssert(ftp2,FtpData(ftp2,"STOR %s",out,"w"));
while ((size=FtpReadBlock(ftp1,buffer,FTPBUFSIZ))>0)
{
- if (FtpWriteBlock(ftp2,buffer,size)!=size)
+ if (FtpWriteBlock(ftp2,buffer,size)!=size)
return EXIT(ftp2,QUIT);
}
diff --git a/lib/libftp/FtpData.c b/lib/libftp/FtpData.c
index c1bbdb8..066671f 100644
--- a/lib/libftp/FtpData.c
+++ b/lib/libftp/FtpData.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -26,17 +26,17 @@ STATUS FtpData(FTP * con,char * command , char * file ,char * mode)
FREE(data);
FREE(from);
-
+
if ( gethostname( hostname , sizeof hostname ) == -1 )
return EXIT(con,QUIT);
-
+
if ((host=(struct hostent *)gethostbyname(hostname))==0)
return EXIT(con,QUIT);
-
+
data.sin_family = host -> h_addrtype;
-
+
bcopy(host-> h_addr_list[0],(char *)&data.sin_addr,host->h_length);
-
+
if ((NewSocket = socket ( AF_INET , SOCK_STREAM , 0 ))<0)
return EXIT(con,QUIT);
@@ -54,7 +54,7 @@ STATUS FtpData(FTP * con,char * command , char * file ,char * mode)
if ( getsockname ( NewSocket , (struct sockaddr *)&data , &len ) < 0 )
return EXIT(con,QUIT);
-
+
if ( listen ( NewSocket , 1 ) < 0 )
return EXIT(con,QUIT);
@@ -69,10 +69,10 @@ STATUS FtpData(FTP * con,char * command , char * file ,char * mode)
if ((i = FtpCommand ( con, "REST %d" , con -> seek , 0, EOF)) != 350 )
return -i;
}
-
- FtpAssert(con, FtpCommand ( con , command , file ,
+
+ FtpAssert(con, FtpCommand ( con , command , file ,
200, 120 , 150 , 125 , 250 , EOF ));
-
+
if (( Accepted_Socket = accept (NewSocket , (struct sockaddr *)&from , &fromlen )) < 0)
{
close(NewSocket);
diff --git a/lib/libftp/FtpDebug.c b/lib/libftp/FtpDebug.c
index 98686b9..d2b5af9 100644
--- a/lib/libftp/FtpDebug.c
+++ b/lib/libftp/FtpDebug.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -29,22 +29,22 @@ STATUS FtpDebugDebug(FTP *ftp,int n, char * Message)
{
String tmp;
-
+
strcpy(tmp,Message);
-
+
if (strncmp(tmp,"PASS ",5)==0)
{
char *p=tmp+5;
while ( *p != '\0') *p++='*';
};
-
+
FtpLog(ftp->title,tmp);
return 1;
}
STATUS FtpDebugError(FTP *ftp,int n, char * Message)
{
-
+
FtpLog("FtpDebugError","");
FtpLog(ftp->title,Message);
if ( ! FtpTestFlag(ftp,FTP_NOEXIT))
@@ -74,7 +74,7 @@ STATUS FtpLog(char *name,char *str)
int
FtpHash(FTP *ftp, unsigned long chars)
{
-
+
if (chars==0) return ftp->counter=0;
ftp->counter+=chars;
fprintf(stdout,"%10u bytes transfered\r",(unsigned int)ftp->counter);
@@ -88,7 +88,7 @@ STATUS FtpBadReply550(char *s)
if(
(strstr(s,"unreachable")!=NULL) ||
(strstr(s,"Broken pipe")!=NULL)
- )
+ )
return 0;
return 1;
}
diff --git a/lib/libftp/FtpFilenameChecker.c b/lib/libftp/FtpFilenameChecker.c
index 0d486c4..99946eb 100644
--- a/lib/libftp/FtpFilenameChecker.c
+++ b/lib/libftp/FtpFilenameChecker.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 existing programs.
Commercial usage is also possible with participation of it's author.
*/
@@ -13,12 +13,12 @@ Commercial usage is also possible with participation of it's author.
static char * simplename(char *s)
{
char *p;
-
+
if ( (p=(char *)strrchr(s,'/')) == NULL )
return s;
return p+1;
}
-
+
diff --git a/lib/libftp/FtpFull.c b/lib/libftp/FtpFull.c
index e2e6a56..51c87dc 100644
--- a/lib/libftp/FtpFull.c
+++ b/lib/libftp/FtpFull.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -39,8 +39,8 @@ FILE * FtpFullOpen(char * file , char * mode )
switch(mode[0])
{
- case 'r':
- if (FtpError(FtpOpenRead(ftp,RemoteFile)))
+ case 'r':
+ if (FtpError(FtpOpenRead(ftp,RemoteFile)))
return NULL;
ftp_table[fileno(FTPDATA(ftp))] = ftp;
return FTPDATA(ftp);
@@ -80,16 +80,16 @@ STATUS FtpFullSyntax ( String source ,
{
char *in,*out;
String tmp;
-
+
host[0] = user[0] = passwd[0] = file[0] = '\0';
-
+
for ( in=source, out = user;
*in !='\0' && *in != '/' && *in!='@' && *in!=':' ;
*out++ = *in++);
*out = '\0';
-
+
if ( *in == '\0' ) return 0;
-
+
if ( *in == ':' )
{
strcpy(host,user);
@@ -98,7 +98,7 @@ STATUS FtpFullSyntax ( String source ,
sprintf(passwd,"%s@%s",
getpwuid(getuid())->pw_name,gethostbyname(tmp)->h_name);
goto file;
- }
+ }
if ( *in == '/' )
{
@@ -114,25 +114,25 @@ STATUS FtpFullSyntax ( String source ,
sprintf(passwd,"%s@%s",
getpwuid(getuid())->pw_name,gethostbyname(tmp)->h_name);
}
-
-
+
+
for ( in++, out = host;
*in !='\0' && *in!=':' ;
*out++ = *in++);
*out = '\0';
-
+
if ( *in == '\0' ) return 0;
file:
-
+
for ( in++, out = file;
*in !='\0';
*out++ = *in++);
*out = '\0';
-
+
return 1;
}
-
+
diff --git a/lib/libftp/FtpGetHost.c b/lib/libftp/FtpGetHost.c
index 3dca113..7171ba3 100644
--- a/lib/libftp/FtpGetHost.c
+++ b/lib/libftp/FtpGetHost.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -37,7 +37,7 @@ struct hostent *FtpGetHost(char *host)
_host.h_addrtype=AF_INET;
return &_host;
}
-
+
return gethostbyname(host);
}
diff --git a/lib/libftp/FtpGood.c b/lib/libftp/FtpGood.c
index e64959d..20af4e0 100644
--- a/lib/libftp/FtpGood.c
+++ b/lib/libftp/FtpGood.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -22,11 +22,11 @@ STATUS FtpGood(va_alist)
int Number;
int Answer[MAX_ANSWERS];
int counter=0;
-
+
va_start(args);
Number = va_arg(args,int);
-
+
while ( 1 )
{
if (counter == MAX_ANSWERS)
@@ -37,7 +37,7 @@ STATUS FtpGood(va_alist)
}
va_end(args);
-
+
return FtpGood1(Number,Answer);
}
diff --git a/lib/libftp/FtpIO.c b/lib/libftp/FtpIO.c
index ee70100..b7f6af5 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;
}
-
+
diff --git a/lib/libftp/FtpInit.c b/lib/libftp/FtpInit.c
index 184f7fb..4e43c8c 100644
--- a/lib/libftp/FtpInit.c
+++ b/lib/libftp/FtpInit.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
diff --git a/lib/libftp/FtpLibrary.h b/lib/libftp/FtpLibrary.h
index d834e3b..754e5a1 100644
--- a/lib/libftp/FtpLibrary.h
+++ b/lib/libftp/FtpLibrary.h
@@ -2,16 +2,16 @@
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 existing programs.
Commercial usage is also possible with participation of it's author.
*/
-
+
#ifndef __FTPLIBRARY_H
#define __FTPLIBRARY_H
@@ -43,20 +43,20 @@ extern int errno;
/* Standard Macros & Definitions */
-
-
+
+
#define EXIT(con,e) \
( con -> errno = e, \
((e==QUIT||e==LQUIT)&&(con->IO != NULL))?(*(con->IO))(con,e,sys_errlist[errno]):0,\
((con->error != NULL) && (e < 0) )?(*(con->error))(con,e,FtpMessage(e)):0,\
e)
-
-
+
+
#define MAX_ANSWERS 10 /* Number of known goodest answers for reqest */
#define NFDS 64
#define FTPBUFSIZ BUFSIZ
#define LQUIT (-6)
-#define QUIT (-5) /* Few time ago QUIT character been
+#define QUIT (-5) /* Few time ago QUIT character been
equivalence to zero, changed for clear
conflicts with reading functions */
#define Ctrl(x) ((x) - '@')
@@ -90,28 +90,28 @@ typedef struct/* All structure initialize from edited struct FtpInit */
char mode; /* Binary, Ascii, ......... */
int errno; /* Last error code */
int ch; /* Help character for ascii streams */
-
+
STATUS (*error)();
STATUS (*debug)();
STATUS (*IO)();
STATUS (*hash)(); /* Call with reading/writing next "int" characters
- from stream */
+ from stream */
int seek; /*
Warning! If server not supported REST-command,
then seek variable automaticaly turn to zero
*/
- int flags; /* FTP_REST,
+ int flags; /* FTP_REST,
FTP_NOEXIT */
struct timeval timeout;
- /* How long must be waiting next character
+ /* How long must be waiting next character
from server */
int port;
String title; /* Using for FtpLog, FtpConnect lets hostname */
- unsigned long counter;
+ unsigned long counter;
/* Using by FtpHash */
} FTP;
-typedef struct
+typedef struct
{
struct tm createtime;
unsigned long size;
@@ -136,7 +136,7 @@ extern FTP FtpInit;
((ftp)->timeout.tv_sec=tim,(ftp)->timeout.tv_usec=0)
#define FtpSetPort(ftp,prt) ((ftp)->port=(prt))
-/* Connect & disconnect */
+/* Connect & disconnect */
STATUS FtpConnect(FTP **con,char *hostname);
#define FtpUser(ftp,user) FtpCommand(ftp,"USER %s",user,230,331,332,EOF)
@@ -207,7 +207,7 @@ int FtpNumber ( char * Message );
/* Debug */
#define FtpSetErrorHandler(con,f) (con)->error = f
-#define FtpSetDebugHandler(con,f) (con)->debug = f
+#define FtpSetDebugHandler(con,f) (con)->debug = f
#define FtpSetIOHandler(con,f) (con)->IO =f
#define FtpSetHashHandler(con,f) (con)->hash =f
#define FtplibDebug(t) FtpDebug(&FtpInit)
@@ -239,7 +239,7 @@ int FtpArchie(char *what, ARCHIE *, int number);
#ifdef __cplusplus
}
#endif
-
+
/* Additional definitions */
diff --git a/lib/libftp/FtpLogin.c b/lib/libftp/FtpLogin.c
index 27e43ae..e066d55 100644
--- a/lib/libftp/FtpLogin.c
+++ b/lib/libftp/FtpLogin.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -14,10 +14,10 @@ Commercial usage is also possible with participation of it's author.
#include "FtpLibrary.h"
-STATUS FtpLogin ( FTP ** con, char * host , char * user ,
+STATUS FtpLogin ( FTP ** con, char * host , char * user ,
char * password , char * account)
{
-
+
FtpAssert((*con),FtpConnect(con,host));
FtpAssert((*con),FtpUser((*con),user));
if (((*con)->errno)==230 )
diff --git a/lib/libftp/FtpMessage.c b/lib/libftp/FtpMessage.c
index 90106b1..8009d05 100644
--- a/lib/libftp/FtpMessage.c
+++ b/lib/libftp/FtpMessage.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -26,28 +26,28 @@ INLINE static char *___gets(char *s, int maxchars, FTP *ftp)
{
if ((c = FtpGetc(ftp,FTPCMD(ftp))) == EOF)
return NULL;
-
+
if ( c == '\n' && *(p-1) == '\r' )
{
p--;
*p='\0';
return s;
}
-
+
if ( (p-s) > maxchars ) return NULL;
-
+
*p++=(char)c;
}
}
-
-
+
+
int FtpGetMessage(FTP *con , char * Message )
{
int n;
char tmp[1024];
-
+
while(1)
{
if (___gets(tmp,sizeof tmp,con)==NULL)
@@ -60,7 +60,7 @@ int FtpGetMessage(FTP *con , char * Message )
(*con->debug)(con,0,tmp);
}
- strcpy(Message,tmp);
+ strcpy(Message,tmp);
FtpInitMessageList();
FtpMessageList[n=FtpNumber(Message)] =
( char * ) malloc ( strlen(Message) + 1);
@@ -74,10 +74,10 @@ int FtpGetMessage(FTP *con , char * Message )
STATUS FtpSendMessage(FTP *ftp,char * Message )
{
char *msg=Message;
-
- while (*Message)
+
+ while (*Message)
FtpAssert(ftp,FtpPutc(ftp,FTPCMD(ftp),*Message++));
-
+
FtpAssert(ftp,FtpPutc(ftp,FTPCMD(ftp),'\015'));
FtpAssert(ftp,FtpPutc(ftp,FTPCMD(ftp),'\012'));
@@ -90,9 +90,9 @@ char *FtpMessage(int number)
{
extern int sys_nerr,errno;
#ifndef __FreeBSD__
- extern char *sys_errlist[];
+ extern char *sys_errlist[];
#endif
-
+
FtpInitMessageList();
if ( number == 0 )
return (char *)sys_errlist[errno];
@@ -105,7 +105,7 @@ STATUS FtpInitMessageList()
{
int i;
static u = 0;
-
+
if ( u )
return 1;
diff --git a/lib/libftp/FtpMove.c b/lib/libftp/FtpMove.c
index 31d6c25..8037b6b 100644
--- a/lib/libftp/FtpMove.c
+++ b/lib/libftp/FtpMove.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
diff --git a/lib/libftp/FtpNumber.c b/lib/libftp/FtpNumber.c
index 56411f8..a6d7114 100644
--- a/lib/libftp/FtpNumber.c
+++ b/lib/libftp/FtpNumber.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
diff --git a/lib/libftp/FtpOpenDir.c b/lib/libftp/FtpOpenDir.c
index 2d3e56e..3f2bcf1 100644
--- a/lib/libftp/FtpOpenDir.c
+++ b/lib/libftp/FtpOpenDir.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
diff --git a/lib/libftp/FtpPasv.c b/lib/libftp/FtpPasv.c
index 3db132a..3dd52fe 100644
--- a/lib/libftp/FtpPasv.c
+++ b/lib/libftp/FtpPasv.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.
@@ -21,27 +21,27 @@ char * FtpPasv (FTP *ftp)
char *msg;
static String PORT;
char *p=PORT;
-
- if FtpError(FtpCommand(ftp,"PASV","",227,EOF))
+
+ if FtpError(FtpCommand(ftp,"PASV","",227,EOF))
return "";
-
+
msg = FtpMessage (227);
msg+=3;
-
- while (!isdigit(*msg++));
+
+ while (!isdigit(*msg++));
msg--;
while (isdigit(*msg)||*msg==',') *p++=*msg++;
*p=0;
-
+
return PORT;
}
STATUS FtpLink(FTP *ftp1, FTP *ftp2)
{
-
+
String PORT;
strcpy(PORT,FtpPasv(ftp1));
@@ -62,12 +62,12 @@ STATUS FtpPassiveTransfer(FTP *ftp1, FTP *ftp2, char *f1, char *f2)
FtpAssert(ftp2,FtpCommand(ftp2,"STOR %s",f2, 200, 120 , 150 , 125 , 250 , EOF ));
FtpAssert(ftp1,FtpCommand(ftp1,"RETR %s",f1, 200, 120 , 150 , 125 , 250 , EOF ));
-
+
FD_ZERO(&fds);
-
+
FD_SET(fileno(FTPCMD(ftp1)),&fds);
FD_SET(fileno(FTPCMD(ftp2)),&fds);
-
+
if (select(getdtablesize(),&fds,0,0,0)<0)
{
if (ftp1->error!=NULL)
@@ -76,7 +76,7 @@ STATUS FtpPassiveTransfer(FTP *ftp1, FTP *ftp2, char *f1, char *f2)
return (*(ftp2->error))(ftp1,QUIT,sys_errlist[errno]);
return QUIT;
}
-
+
if (FD_ISSET(fileno(FTPCMD(ftp1)),&fds))
{
FtpGetMessage(ftp1,tmp);
diff --git a/lib/libftp/FtpPort.c b/lib/libftp/FtpPort.c
index c6b0ca2..eb15ac0 100644
--- a/lib/libftp/FtpPort.c
+++ b/lib/libftp/FtpPort.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -24,7 +24,7 @@ STATUS FtpPort(FTP *con,int a,int b,int c,int d,int e,int f)
return QUIT;
if ( (i=FtpGetMessage(con,cmd)) == QUIT)
return QUIT;
-
+
if ( ! FtpGood ( i , 200 , EOF ))
return EXIT(con,-i);
diff --git a/lib/libftp/FtpPwd.c b/lib/libftp/FtpPwd.c
index 4299bcc..59c792d 100644
--- a/lib/libftp/FtpPwd.c
+++ b/lib/libftp/FtpPwd.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -19,12 +19,12 @@ char * FtpPwd(FTP * con)
String tmp;
static String tmp1;
int i;
-
+
if ( FtpSendMessage(con,"PWD") == QUIT )
return (char *) EXIT(con,QUIT);
if ( (i=FtpGetMessage(con,tmp)) == QUIT )
return (char *) EXIT(con,QUIT);
-
+
if ( i != 257 )
return (char *) EXIT(con,-i);
diff --git a/lib/libftp/FtpRetr.c b/lib/libftp/FtpRetr.c
index eb19c16..ced19b8 100644
--- a/lib/libftp/FtpRetr.c
+++ b/lib/libftp/FtpRetr.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -24,7 +24,7 @@ STATUS FtpRetr (FTP * con , char * command ,
struct stat st;
char buffer[FTPBUFSIZ];
register int size;
-
+
FtpFilenameChecker(&in,&out);
if ( FtpTestFlag(con,FTP_REST) && stat(out,&st)==0)
@@ -39,28 +39,28 @@ STATUS FtpRetr (FTP * con , char * command ,
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)
diff --git a/lib/libftp/FtpSize.c b/lib/libftp/FtpSize.c
index 040e16b..581e186 100644
--- a/lib/libftp/FtpSize.c
+++ b/lib/libftp/FtpSize.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -21,12 +21,12 @@ int FtpSize(FTP * con, char *filename)
strcpy(tmp,"SIZE ");
strcat(tmp,filename);
-
+
if ( FtpSendMessage(con,tmp) == QUIT )
return EXIT(con,QUIT);
if ( (i=FtpGetMessage(con,tmp)) == QUIT )
return EXIT(con,QUIT);
-
+
if ( i != 213 )
return con -> errno = (-i);
diff --git a/lib/libftp/FtpStor.c b/lib/libftp/FtpStor.c
index 9ddb326..9cd0e4e 100644
--- a/lib/libftp/FtpStor.c
+++ b/lib/libftp/FtpStor.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -27,11 +27,11 @@ STATUS FtpStor (FTP * con , char * command ,
if ( (i=Ftpfopen(in,"rb")) == NULL )
return EXIT(con,LQUIT);
- if ( FtpTestFlag(con,FTP_REST) &&
+ if ( FtpTestFlag(con,FTP_REST) &&
(con->seek=FtpSize(con,out))<0 )
con->seek=0;
-
-
+
+
if ( FtpError(FtpData(con,command,out,"w")))
{
if (con->seek==0) return EXIT(con,con->errno);
@@ -40,12 +40,12 @@ STATUS FtpStor (FTP * con , char * command ,
if ( FtpError(FtpData(con,command,out,"w")) )
return EXIT(con,con->errno);
}
-
+
if (con->seek) fseek(i,con->seek,0);
-
- while ( (size=read ( fileno(i) , buffer, FTPBUFSIZ ))>0)
+
+ while ( (size=read ( fileno(i) , buffer, FTPBUFSIZ ))>0)
FtpWriteBlock(con,buffer,size);
-
+
Ftpfclose(i);
return FtpClose(con);
}
diff --git a/lib/libftp/FtpSyscalls.c b/lib/libftp/FtpSyscalls.c
index 649d16f..67fa4ca 100644
--- a/lib/libftp/FtpSyscalls.c
+++ b/lib/libftp/FtpSyscalls.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
diff --git a/lib/libftp/FtpType.c b/lib/libftp/FtpType.c
index 6c32016..ae0d0ea 100644
--- a/lib/libftp/FtpType.c
+++ b/lib/libftp/FtpType.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -17,10 +17,10 @@ Commercial usage is also possible with participation of it's author.
STATUS FtpType(FTP *ftp, char type)
{
STATUS p;
-
+
if ((p=FtpCommand(ftp,"TYPE %c",type,200,EOF))>0)
ftp->mode=(int)type;
return p;
}
-
+
diff --git a/lib/libftp/Ftpfopen.c b/lib/libftp/Ftpfopen.c
index b7b96d5..9b89bb3 100644
--- a/lib/libftp/Ftpfopen.c
+++ b/lib/libftp/Ftpfopen.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -24,9 +24,9 @@ enum {T_EMPTY=0,T_FILE,T_STREAM,T_PIPE,T_FULL};
FILE *Ftpfopen(char *filename,char *mode)
{
FILE *fp;
-
+
if (!init)
- {
+ {
bzero(fds_types,NFDS*sizeof(fds_types[0]));
init=1;
}
@@ -36,22 +36,22 @@ FILE *Ftpfopen(char *filename,char *mode)
fds_types[fileno(stdin)]=T_STREAM;
return stdin;
}
-
+
if (!strcmp(filename,"*STDOUT*") || (!strcmp(filename,"-") && (mode[0]=='w')))
{
fds_types[fileno(stdout)]=T_STREAM;
return stdout;
}
-
+
if (strcmp(filename,"*STDERR*")==0)
{
fds_types[fileno(stderr)]=T_STREAM;
return stderr;
}
-
- if (*filename=='|')
+
+ if (*filename=='|')
{
fp=popen(filename+1,mode);
if (fp==NULL) return fp;
@@ -63,33 +63,33 @@ FILE *Ftpfopen(char *filename,char *mode)
if (fp==NULL) return fp;
fds_types[fileno(fp)]=T_FILE;
return fp;
-
+
}
int Ftpfclose(FILE *fp)
{
if (!init)
- {
+ {
bzero(fds_types,NFDS*sizeof(fds_types[0]));
init=1;
}
switch (fds_types[fileno(fp)])
{
-
+
case T_FILE:
-
+
return FtpFullClose(fp);
-
+
case T_STREAM:
return fflush(fp);
-
+
case T_PIPE:
-
+
return pclose(fp);
-
+
default:
return -1;
diff --git a/lib/libftp/doc/example.c b/lib/libftp/doc/example.c
index 7f09287..0606592 100644
--- a/lib/libftp/doc/example.c
+++ b/lib/libftp/doc/example.c
@@ -1,7 +1,7 @@
/* Include standard libftp's header */
-#include <FtpLibrary.h>
+#include <FtpLibrary.h>
@@ -10,25 +10,25 @@ main(int argc, char *argv[])
FILE *input,*output;
int c;
-
+
if (argc<3)
exit(fprintf(stderr,"Usage: %s input-file output-file\n",argv[0]));
FtplibDebug(yes);
-
+
if ((input=Ftpfopen(argv[1],"r"))==NULL)
{
perror(argv[1]);
exit(1);
}
-
+
if ((output=Ftpfopen(argv[2],"w"))==NULL)
{
perror(argv[2]);
exit(1);
}
-
+
while ( (c=getc(input)) != EOF && (putc(c,output)!=EOF) );
if (ferror(input))
@@ -36,7 +36,7 @@ main(int argc, char *argv[])
perror(argv[1]);
exit(1);
}
-
+
if (ferror(output))
{
perror(argv[1]);
@@ -47,5 +47,5 @@ main(int argc, char *argv[])
Ftpfclose(output);
exit(0);
-
+
}
diff --git a/lib/libftp/utils/Makefile b/lib/libftp/utils/Makefile
index d750ca7..bae516b 100644
--- a/lib/libftp/utils/Makefile
+++ b/lib/libftp/utils/Makefile
@@ -25,10 +25,10 @@ uftp: uftp.o uftpcmd.o libetc.a
mirror: mirror.o
$(CC) $(CFLAGS) -o mirror mirror.o ${LDADD} -lftp
-clean:
+clean:
rm -f ftptry mirror uftp *~ *.o *.a
-LIBOBJS= readline.o glob.o
-libetc.a: $(LIBOBJS)
+LIBOBJS= readline.o glob.o
+libetc.a: $(LIBOBJS)
ar qc libetc.a $(LIBOBJS)
ranlib libetc.a
diff --git a/lib/libftp/utils/ftptry.c b/lib/libftp/utils/ftptry.c
index 623d0da..7dfb130 100644
--- a/lib/libftp/utils/ftptry.c
+++ b/lib/libftp/utils/ftptry.c
@@ -2,9 +2,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 existing programs.
Commercial usage is also possible with participation of it's author.
@@ -27,7 +27,7 @@ will be described in usage, if the program is started without them.\n\
\n\
The libftp you may transfer from host lpuds.oea.ihep.su via ftp-anonymous.\n\
All question are sent to author via e-mail (orel@oea.ihep.su)\n\
- ";
+ ";
#include <FtpLibrary.h>
#include <sys/types.h>
@@ -95,7 +95,7 @@ main(int argc,char **argv)
if (setjmp(trap)!=0)
exit(1);
-
+
signal(SIGHUP,sighup);
signal(SIGTRAP,done);
signal(SIGINT,done);
@@ -106,13 +106,13 @@ main(int argc,char **argv)
gethost());
progname=argv[0];
-
+
FtpDebug(&FtpInit);
FtpSetErrorHandler(&FtpInit,my_abort);
FtpSetIOHandler(&FtpInit,my_IO);
FtpSetFlag(&FtpInit,FTP_REST);
FtpSetTimeout(&FtpInit,DEFAULT_TIMEOUT);
-
+
setoptions();
optind=1;
options(argc,argv);
@@ -122,7 +122,7 @@ main(int argc,char **argv)
{
case lm_file:
-
+
if (fork()) quit("Deattaching.....");
close(0);close(1);close(2);
@@ -133,7 +133,7 @@ main(int argc,char **argv)
}
else
strcpy(tmp,logfile);
-
+
open(tmp,O_TRUNC|O_CREAT|O_WRONLY,0600);
dup(0);
dup(0);
@@ -142,23 +142,23 @@ main(int argc,char **argv)
case lm_mail:
-
+
if (fork()) quit("Deattaching.....");
-
+
close(0);close(1);close(2);
if (popen("/usr/lib/sendmail -t","w")==NULL)
perror("sendmail"),
quit("");
-
+
dup(0);
dup(0);
-
+
printf("From: %s@%s\n",USERNAME,gethost());
printf("To: %s@%s\n",USERNAME,gethost());
- printf("Subject: ftptry session log\n\n");
-
+ printf("Subject: ftptry session log\n\n");
+
fflush(stdout);
-
+
break;
}
@@ -174,12 +174,12 @@ main(int argc,char **argv)
INLINE noargs(int argc, char **argv, int optind)
{
int i;
-
+
for (i=optind;i<argc;i++)
if (argv[i]!=NULL) return 0;
return 1;
}
-
+
/* Main loop */
@@ -192,15 +192,15 @@ loop(int argc, char **argv, int optind /* First args as filename */ )
String filename;
String localfilename;
char *p1;
-
+
for(i=optind;;(i==argc-1)?i=optind,
sprintf(tmp,"Sleeping %d secs",sleeptime),log(tmp),sleep(sleeptime):
i++)
{
if (noargs(argc,argv,optind))
quit("Nothing doing");
-
- if (strchr(argv[i],':')==NULL)
+
+ if (strchr(argv[i],':')==NULL)
{
if (find_archie(argv[i],machine,filename,localfilename)==0)
argv[i]=NULL;
@@ -226,19 +226,19 @@ transfer(char *machine, char *file, char *localfile)
{
int r;
String tmp;
-
+
if ((r=setjmp(stack))!=0)
return r;
-
+
sprintf(tmp,"Start transfer, machine is %s, remote file is %s, local file is %s",
machine, file, localfile);
DEBUG(tmp);
-
+
FtpLogin(&ftp,machine,user,password,NULL);
if (type==binary)
FtpBinary(ftp);
-
+
switch (mode)
{
@@ -260,11 +260,11 @@ transfer(char *machine, char *file, char *localfile)
case multiget:
domultiget(file);
break;
-
+
}
-
+
FtpBye(ftp);
-
+
DEBUG("Transfer complete");
return OK_;
}
@@ -288,11 +288,11 @@ quit(char *s)
log(s);
longjmp(trap,1);
}
-
+
my_IO(FTP *ftp, int n, char *s )
{
-
+
DEBUG(s);
leave(BREAK_);
}
@@ -312,7 +312,7 @@ domultiget(char *file)
{
String list,localname,tmp_name;
char *p1;
-
+
sprintf(list,"/tmp/ftptry-%s-multiget.XXXXXX",USERNAME);
mktemp(list);
@@ -405,7 +405,7 @@ void done(sig)
options(int argc,char **argv)
{
char c;
-
+
while((c=getopt(argc,argv,"GOIBDru:p:Pdbs:o:l:t:cm"))!=EOF)
{
switch(c)
@@ -414,16 +414,16 @@ options(int argc,char **argv)
case 'G':
mode=multiget;
break;
-
+
case 'c':
if (localfile==NULL) localfile="*STDOUT*";
break;
-
+
case 'I':
fprintf(stderr,intro);
exit(0);
-
+
case 'r':
mode=put;
@@ -444,12 +444,12 @@ options(int argc,char **argv)
localfile=optarg;
break;
-
+
case 'D':
debug=true;
break;
-
+
case 'u':
user=optarg;
@@ -464,7 +464,7 @@ options(int argc,char **argv)
password=(char *)getpass("Password:");
break;
-
+
case 'b':
type=binary;
@@ -480,14 +480,14 @@ options(int argc,char **argv)
logmode=lm_file;
logfile=optarg;
break;
-
+
case 'm':
logmode=lm_mail;
break;
-
+
case 'B':
-
+
logmode=lm_file;
logfile=NULL;
break;
@@ -495,8 +495,8 @@ options(int argc,char **argv)
default:
usage();
-
- }
+
+ }
}
}
@@ -510,14 +510,14 @@ setoptions()
-
+
if ((p=(char *)getenv(FTPTRY))!=NULL && *p!=0)
strcpy(x,p);
else
return;
-
-
+
+
for (argv[0]="",p=x,sp=x,argc=1; *p!=0 ; p++)
{
if (*p==' ')
@@ -529,7 +529,7 @@ setoptions()
}
argv[argc++]=sp;
-
+
options(argc,argv);
}
@@ -562,7 +562,7 @@ find_archie(char *what,char *machine, char *filename, char *localfilename)
static String oldwhat={'\0'};
char *p1;
int i;
-
+
if (!init || strcmp(oldwhat,what)!=0 || last==0)
{
String cmd;
@@ -571,10 +571,10 @@ find_archie(char *what,char *machine, char *filename, char *localfilename)
for (i=0;i<MAXHOPS;i++) result[i][0]=0;
sprintf(cmd,"archie -l -m %d %s",MAXHOPS,what);
DEBUG(cmd);
-
+
if ((archie = popen(cmd,"r"))==NULL)
quit("Archie can't execute");
-
+
for(i=0;i<MAXHOPS;i++)
{
if (fgets(result[i],sizeof (result[i]), archie)==NULL)
@@ -582,17 +582,17 @@ find_archie(char *what,char *machine, char *filename, char *localfilename)
result[i][strlen(result[i])-1]=0;
DEBUG(result[i]);
}
-
-
+
+
last=i;
- if ( last==0 )
+ if ( last==0 )
{
DEBUG("archie not found need file");
return(0);
}
-
-
+
+
init=1;
first=0;
strcpy(oldwhat,what);
@@ -606,23 +606,23 @@ find_archie(char *what,char *machine, char *filename, char *localfilename)
first=i+1;
break;
}
-
+
DEBUG("Archie select is ... (see next line)");
DEBUG(result[i]);
-
+
if (sscanf ( result[i] , "%*[^ ] %*[^ ] %[^ ] %s", machine, filename )!=2)
{
DEBUG("Bad archie output format");
last=0;
return(0);
}
-
-
+
+
if ( (p1=strrchr(filename,'/'))!= NULL)
strcpy(localfilename,p1+1);
else
strcpy(localfilename,filename);
-
+
return(1);
}
diff --git a/lib/libftp/utils/glob.c b/lib/libftp/utils/glob.c
index d80b146..efaeaa6 100644
--- a/lib/libftp/utils/glob.c
+++ b/lib/libftp/utils/glob.c
@@ -58,7 +58,7 @@ static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
* GLOB_TILDE:
* expand ~user/foo to the /home/dir/of/user/foo
* GLOB_BRACE:
- * expand {1,2}{a,b} to 1a 1b 2a 2b
+ * expand {1,2}{a,b} to 1a 1b 2a 2b
* gl_matchc:
* Number of matches in the current invocation of glob.
*/
@@ -173,7 +173,7 @@ glob(pattern, flags, errfunc, pglob)
bufend = bufnext + MAXPATHLEN;
if (flags & GLOB_QUOTE) {
/* Protect the quoted characters. */
- while (bufnext < bufend && (c = *patnext++) != EOS)
+ while (bufnext < bufend && (c = *patnext++) != EOS)
if (c == QUOTE) {
if ((c = *patnext++) == EOS) {
c = QUOTE;
@@ -184,8 +184,8 @@ glob(pattern, flags, errfunc, pglob)
else
*bufnext++ = c;
}
- else
- while (bufnext < bufend && (c = *patnext++) != EOS)
+ else
+ while (bufnext < bufend && (c = *patnext++) != EOS)
*bufnext++ = c;
*bufnext = EOS;
@@ -246,7 +246,7 @@ static int globexp2(ptr, pattern, pglob, rv)
for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
continue;
if (*pe == EOS) {
- /*
+ /*
* We could not find a matching RBRACKET.
* Ignore and just look for RBRACE
*/
@@ -274,7 +274,7 @@ static int globexp2(ptr, pattern, pglob, rv)
for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)
continue;
if (*pm == EOS) {
- /*
+ /*
* We could not find a matching RBRACKET.
* Ignore and just look for RBRACE
*/
@@ -299,7 +299,7 @@ static int globexp2(ptr, pattern, pglob, rv)
/* Append the current string */
for (lm = ls; (pl < pm); *lm++ = *pl++)
continue;
- /*
+ /*
* Append the rest of the pattern after the
* closing brace
*/
@@ -344,15 +344,15 @@ globtilde(pattern, patbuf, pglob)
return pattern;
/* Copy up to the end of the string or / */
- for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH;
+ for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH;
*h++ = *p++)
continue;
*h = EOS;
if (((char *) patbuf)[0] == EOS) {
- /*
- * handle a plain ~ or ~/ by expanding $HOME
+ /*
+ * handle a plain ~ or ~/ by expanding $HOME
* first and then trying the password file
*/
if ((h = getenv("HOME")) == NULL) {
@@ -375,14 +375,14 @@ globtilde(pattern, patbuf, pglob)
/* Copy the home directory */
for (b = patbuf; *h; *b++ = *h++)
continue;
-
+
/* Append the rest of the pattern */
while ((*b++ = *p++) != EOS)
continue;
return patbuf;
}
-
+
/*
* The main glob() routine: compiles the pattern (optionally processing
@@ -440,7 +440,7 @@ glob0(pattern, pglob)
break;
case STAR:
pglob->gl_flags |= GLOB_MAGCHAR;
- /* collapse adjacent stars to one,
+ /* collapse adjacent stars to one,
* to avoid exponential behavior
*/
if (bufnext == patbuf || bufnext[-1] != M_ALL)
@@ -460,17 +460,17 @@ glob0(pattern, pglob)
return(err);
/*
- * If there was no match we are going to append the pattern
+ * If there was no match we are going to append the pattern
* if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
* and the pattern did not contain any magic characters
* GLOB_NOMAGIC is there just for compatibility with csh.
*/
- if (pglob->gl_pathc == oldpathc &&
- ((pglob->gl_flags & GLOB_NOCHECK) ||
+ if (pglob->gl_pathc == oldpathc &&
+ ((pglob->gl_flags & GLOB_NOCHECK) ||
((pglob->gl_flags & GLOB_NOMAGIC) &&
!(pglob->gl_flags & GLOB_MAGCHAR))))
return(globextend(pattern, pglob));
- else if (!(pglob->gl_flags & GLOB_NOSORT))
+ else if (!(pglob->gl_flags & GLOB_NOSORT))
qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
pglob->gl_pathc - oldpathc, sizeof(char *), compare);
return(0);
@@ -519,7 +519,7 @@ glob2(pathbuf, pathend, pattern, pglob)
*pathend = EOS;
if (g_lstat(pathbuf, &sb, pglob))
return(0);
-
+
if (((pglob->gl_flags & GLOB_MARK) &&
pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
#ifdef S_ISLNK
@@ -576,7 +576,7 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob)
*pathend = EOS;
errno = 0;
-
+
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
/* TODO: don't call for ENOENT or ENOTDIR? */
if (pglob->gl_errfunc) {
@@ -602,7 +602,7 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob)
/* Initial DOT must be matched literally. */
if (dp->d_name[0] == DOT && *pattern != DOT)
continue;
- for (sc = (u_char *) dp->d_name, dc = pathend;
+ for (sc = (u_char *) dp->d_name, dc = pathend;
(*dc++ = *sc++) != EOS;)
continue;
if (!match(pathend, pattern, restpattern)) {
@@ -648,7 +648,7 @@ globextend(path, pglob)
const Char *p;
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
- pathv = pglob->gl_pathv ?
+ pathv = pglob->gl_pathv ?
realloc((char *)pglob->gl_pathv, newsize) :
malloc(newsize);
if (pathv == NULL)
@@ -690,7 +690,7 @@ match(name, pat, patend)
case M_ALL:
if (pat == patend)
return(1);
- do
+ do
if (match(name, pat, patend))
return(1);
while (*name++ != EOS);
@@ -829,7 +829,7 @@ g_Ctoc(str, buf)
}
#ifdef DEBUG
-static void
+static void
qprintf(str, s)
const char *str;
register Char *s;
diff --git a/lib/libftp/utils/glob.h b/lib/libftp/utils/glob.h
index bffb28c..b0432b7 100644
--- a/lib/libftp/utils/glob.h
+++ b/lib/libftp/utils/glob.h
@@ -58,7 +58,7 @@ typedef struct {
* and lstat(2).
*/
void (*gl_closedir) __P((void *));
- struct dirent *(*gl_readdir) __P((void *));
+ struct dirent *(*gl_readdir) __P((void *));
void *(*gl_opendir) __P((const char *));
int (*gl_lstat) __P((const char *, struct stat *));
int (*gl_stat) __P((const char *, struct stat *));
diff --git a/lib/libftp/utils/mirror.c b/lib/libftp/utils/mirror.c
index babd840..a0d329c 100644
--- a/lib/libftp/utils/mirror.c
+++ b/lib/libftp/utils/mirror.c
@@ -9,7 +9,7 @@
#include <syslog.h>
#include <FtpLibrary.h>
-/* Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir> */
+/* Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir> */
FTP *ftp;
main(int a,char **b)
@@ -24,7 +24,7 @@ main(int a,char **b)
if ( a < 5 )
quit("Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir>");
-
+
FtplibDebug(yes);
FtpLogin(&ftp,HOST,USER,PASSWD,NULL);
FtpChdir(ftp,REMOTE_DIR);
@@ -53,7 +53,7 @@ doit(char *dirname)
continue;
sprintf(fn,"%s/%s",dirname,de->d_name);
-
+
if ( stat(fn,&st) != 0 ) {
log(fn);
continue;
@@ -72,7 +72,7 @@ doit(char *dirname)
}
closedir(dp);
-
+
}
diff --git a/lib/libftp/utils/readline.c b/lib/libftp/utils/readline.c
index 34612ba..e019bc1 100644
--- a/lib/libftp/utils/readline.c
+++ b/lib/libftp/utils/readline.c
@@ -1,5 +1,5 @@
#ifndef lint
-static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $";
+static char *RCSid = "$Id: readline.c,v 1.1.1.1 1995/04/25 15:05:09 jkh Exp $";
#endif
@@ -8,17 +8,17 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $";
* Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley
*
* Permission to use, copy, and distribute this software and its
- * documentation for any purpose with or without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
+ * documentation for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
- * distribute the modified code. Modifications are to be distributed
+ * distribute the modified code. Modifications are to be distributed
* as patches to released version.
- *
+ *
* This software is provided "as is" without express or implied warranty.
- *
+ *
*
* AUTHORS
*
@@ -27,10 +27,10 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $";
*
* Msdos port and some enhancements:
* Gershon Elber and many others.
- *
+ *
* There is a mailing list for gnuplot users. Note, however, that the
- * newsgroup
- * comp.graphics.gnuplot
+ * newsgroup
+ * comp.graphics.gnuplot
* is identical to the mailing list (they
* both carry the same set of messages). We prefer that you read the
* messages through that newsgroup, to subscribing to the mailing list.
@@ -40,9 +40,9 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $";
*
* The address for mailing to list members is
* info-gnuplot@dartmouth.edu
- * and for mailing administrative requests is
+ * and for mailing administrative requests is
* info-gnuplot-request@dartmouth.edu
- * The mailing list for bug reports is
+ * The mailing list for bug reports is
* bug-gnuplot@dartmouth.edu
* The list of those interested in beta-test versions is
* info-gnuplot-beta@dartmouth.edu
@@ -57,7 +57,7 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $";
#endif
/* a small portable version of GNU's readline */
-/* this is not the BASH or GNU EMACS version of READLINE due to Copyleft
+/* this is not the BASH or GNU EMACS version of READLINE due to Copyleft
restrictions */
/* do not need any terminal capabilities except backspace, */
/* and space overwrites a character */
@@ -123,7 +123,7 @@ static struct ltchars s_ltchars;
#ifdef ISC22
#ifndef ONOCR /* taken from sys/termio.h */
#define ONOCR 0000020 /* true at least for ISC 2.2 */
-#endif
+#endif
#ifndef IUCLC
#define IUCLC 0001000
#endif
@@ -226,7 +226,7 @@ void reset_termio();
/* user_putc and user_puts should be used in the place of
* fputc(ch,stderr) and fputs(str,stderr) for all output
- * of user typed characters. This allows MS-Windows to
+ * of user typed characters. This allows MS-Windows to
* display user input in a different color. */
int
user_putc(ch)
@@ -265,7 +265,7 @@ backspace()
{
user_putc(BACKSPACE);
}
-
+
char *
readline(prompt)
char *prompt;
@@ -322,7 +322,7 @@ char *prompt;
}
}
#endif /*OS2*/
- if((isprint(cur_char)
+ if((isprint(cur_char)
#if defined(ATARI) || defined(_Windows) || defined(MSDOS) || defined(DOS386)
/* this should be used for all 8bit ASCII machines, I guess */
|| ((unsigned char)cur_char > 0x7f)
@@ -455,7 +455,7 @@ char *prompt;
if(cur_entry != NULL) {
cur_entry = cur_entry->next;
clear_line(prompt);
- if(cur_entry != NULL)
+ if(cur_entry != NULL)
copy_line(cur_entry->line);
else
cur_pos = max_pos = 0;
@@ -714,12 +714,12 @@ msdos_getch()
/* Convert Arrow keystrokes to Control characters: TOS version */
-/* the volatile could be necessary to keep gcc from reordering
+/* the volatile could be necessary to keep gcc from reordering
the two Super calls
*/
#define CONTERM ((/*volatile*/ char *)0x484L)
-static void
+static void
remove_conterm()
{
void *ssp=(void*)Super(0L);
@@ -929,7 +929,7 @@ set_termio()
}
#endif /* !MSDOS && !ATARI && !defined(_Windows) */
}
-
+
void
reset_termio()
{
diff --git a/lib/libftp/utils/uftp.c b/lib/libftp/utils/uftp.c
index fe64ffd..4c8961f 100644
--- a/lib/libftp/utils/uftp.c
+++ b/lib/libftp/utils/uftp.c
@@ -37,25 +37,25 @@ main(int argc, char **argv)
register char *p1;
FILE *fp;
String tmp;
-
- if (setjmp(start)!=0)
+
+ if (setjmp(start)!=0)
goto main_loop;
-
+
setsignals();
-
-
+
+
FtpSetErrorHandler(&FtpInit,my_error);
FtpSetIOHandler(&FtpInit,my_error);
-
+
strcpy(defaultuser,getpwuid(getuid())->pw_name);
-
+
memset(ftp,0,sizeof(FTP*)*NFRAMES);
memset(iftp,0,sizeof(LINKINFO)*NFRAMES);
-
-
+
+
batch(SYSTEMRC);
if (access(getrcname(),F_OK))
@@ -69,16 +69,16 @@ main(int argc, char **argv)
else
{
-
+
fprintf(out,"set timeout 120\nset hash\nset debug\nset bin\n");
fprintf(out,"set prompt \"%%T %%u@%%h:%%d\\> \"\n");
fprintf(out,"alias a alias\na ed ! emacs\nalias tn ! telnet\n");
-
+
fclose(out);
}
}
-
+
batch(getrcname());
batch(getaliasrcname());
@@ -88,7 +88,7 @@ main(int argc, char **argv)
strcat(tmp,argv[i]);
if (i+1!=argc) strcat(tmp," ");
}
-
+
if (tmp[0]!=0)
{
String new;
@@ -99,8 +99,8 @@ main(int argc, char **argv)
else
*/
strcpy(new,"open ");
-
- if (ifalias(tmp))
+
+ if (ifalias(tmp))
execute (tmp);
else
strcat(new,tmp),
@@ -111,25 +111,25 @@ main(int argc, char **argv)
main_loop:
setsignals();
-
+
while (1)
{
-
+
setjmp(start);
if (lastcmd) exit(0);
-
+
if (isatty(fileno(stdin)))
p1=readline(getprompt());
else
p1=gets(cmd);
-
- if (p1==NULL)
+
+ if (p1==NULL)
{
putchar('\n');
exit(0);
}
-
+
strcpy(cmd,p1);
if (cmd[0]) add_history(cmd);
@@ -144,15 +144,15 @@ INLINE char *findspace(char *str)
}
-
+
char *word(char *str, int n)
{
String new;
register char *p1, *p2;
register int i;
-
+
strcpy(new,str);
-
+
p1=new;
while (isspace(*p1)) p1++;
@@ -160,7 +160,7 @@ char *word(char *str, int n)
if (n>1 )
for (i=0;i<n-1;i++) /* Skip n-1 words */
{
- if ((*p1=='"')||(*p1=='\''))
+ if ((*p1=='"')||(*p1=='\''))
{
p1=strchr(p1+1,*p1);
if (p1==NULL) return "";
@@ -181,7 +181,7 @@ char *word(char *str, int n)
*p2=0;
return p1+1;
}
-
+
if ((p2=findspace(p1)) != NULL )
{
*p2=0;
@@ -191,8 +191,8 @@ char *word(char *str, int n)
}
-/* Exacute few command separated by ';' . The character ' must use for mark complex
- works*/
+/* Exacute few command separated by ';' . The character ' must use for mark complex
+ works*/
execute (char *cmd)
{
@@ -208,13 +208,13 @@ execute (char *cmd)
{
*p++=*cmd++;
while ( *cmd != '\'' && *cmd != 0 ) *p++=*cmd++;
- if ( *cmd == 0 )
+ if ( *cmd == 0 )
return puts("Unbalanced \', please corrected!\n");
*p++=*cmd;
continue;
}
-
- if ( *cmd == ';' )
+
+ if ( *cmd == ';' )
{
*p=0;
execute(newcmd);
@@ -224,11 +224,11 @@ execute (char *cmd)
*p++=*cmd;
}
-
+
*p=0;
cmd=newcmd;
-
- if ( *cmd=='\\' )
+
+ if ( *cmd=='\\' )
cmd++;
else
{
@@ -238,17 +238,17 @@ execute (char *cmd)
return execute(new);
}
- if ( *cmd == '!' )
+ if ( *cmd == '!' )
{
int pid,_pid;
int status;
-
+
if (!(pid=fork()))
{
execlp((getenv("SHELL")==NULL)?"/bin/sh":(char *)getenv("SHELL"),
"shell","-c",cmd+1,NULL);
}
-
+
while(1)
{
_pid=wait(&status);
@@ -256,8 +256,8 @@ execute (char *cmd)
return;
}
}
-
-
+
+
redir(cmd);
if (cmd[strlen(cmd)-1]=='&')
@@ -271,14 +271,14 @@ execute (char *cmd)
strcpy(cmd,tmp);
}
-
+
strcpy(w1,word(cmd,1));
strcpy(w2,word(cmd,2));
strcpy(w3,word(cmd,3));
strcpy(w4,word(cmd,4));
strcpy(w5,word(cmd,5));
strcpy(w6,word(cmd,6));
-
+
return executev(w1,w2,w3,w4,w5,w6);
}
@@ -286,18 +286,18 @@ executev(ARGS)
{
CMDS *xcmd=&cmds[0];
String tmp;
-
+
if (isdigit(*w1))
- return
+ return
atoi(w1)<NFRAMES?frame=atoi(w1):0,
executev(w2,w3,w4,w5,w6,"");
-
+
while ( xcmd -> cmd != NULL )
{
if ( !strcmp(xcmd->cmd,w1) && (xcmd -> func != NULL) )
{
int status;
-
+
if ( xcmd -> need && LINK == NULL)
return puts("Need connection to server");
iftp[frame].lock=1; unsetsignals();
@@ -308,11 +308,11 @@ executev(ARGS)
}
xcmd++;
}
-
-
+
+
if (LINK!=NULL && glassmode)
return FtpCommand(LINK,cmd,"",0,EOF);
-
+
printf("%s: unknown command\n",w1);
fflush(stdout);
return -1;
@@ -332,7 +332,7 @@ void intr(int sig)
newframe(int connecteble)
{
register int i;
-
+
if (connecteble)
for (i=0; i<NFRAMES; i++) if (ftp[i]!=NULL) return frame=i;
for (i=0; i<NFRAMES; i++) if (ftp[i]==NULL) return frame=i;
@@ -345,7 +345,7 @@ STATUS my_error(FTP *ftp, int code, char *msg)
if (code==LQUIT||(ftp==NULL)) log(msg);
else
FtpLog(ftp->title,msg);
-
+
if ( abs(code) == 530 && (strstr(msg,"anonymous")!=NULL))
{
Ftp_reopen();
@@ -358,7 +358,7 @@ char *getrcname()
{
static String rcpath;
struct passwd *pwd=getpwuid(getuid());
-
+
sprintf(rcpath,"%s/.uftprc",pwd->pw_dir);
return rcpath;
}
@@ -367,7 +367,7 @@ char *getaliasrcname()
{
static String rcpath;
struct passwd *pwd=getpwuid(getuid());
-
+
sprintf(rcpath,"%s/.uftp_aliases",pwd->pw_dir);
return rcpath;
}
@@ -378,14 +378,14 @@ char *makestr(va_alist)
char *p1;
va_list args;
String new={0};
-
+
va_start(args);
while(1)
{
p1=va_arg(args,char *);
if (p1==NULL) break;
- if (*p1!=0)
+ if (*p1!=0)
{
if (new[0]!=0) strcat(new," ");
strcat(new,p1);
@@ -395,7 +395,7 @@ char *makestr(va_alist)
return new;
}
-
+
#define ADD(str,chr) (*str++=chr,*str=0)
INLINE ADDSTR(char **str, char *str1)
@@ -409,59 +409,59 @@ char *expandalias(char *str)
String new={0},w1={0};
char *p,*p1=new,*args;
int dollar=0;
-
+
strcpy(w1,word(str,1));
if ( (p=strchr(str,' '))!=NULL )
args=p+1;
else
args="";
-
- while (a)
+
+ while (a)
{
if (!strcmp(a->name,w1))
break;
a=a->next;
}
-
- if (!a)
+
+ if (!a)
return str;
-
+
for ( p=a->str; *p; p++)
{
- if ( *p != '$' )
+ if ( *p != '$' )
{
ADD(p1,*p);
continue;
}
-
+
dollar=1;
p++;
-
- if (isdigit(*p))
+
+ if (isdigit(*p))
{
ADDSTR(&p1,word(str,(*p)-'0'+1));
continue;
}
- switch (*p)
- {
-
+ switch (*p)
+ {
+
case '\0':
case '$': ADD(p1,'$');continue;
case '*': ADDSTR(&p1,args);continue;
default: ADD(p1,'$');ADD(p1,*p);continue;
}
}
-
- if (!dollar)
+
+ if (!dollar)
{
ADD(p1,' ');
ADDSTR(&p1,args);
}
*p=0;
-
+
return new;
}
@@ -481,12 +481,12 @@ ifalias(char *cmd)
}
return 0;
}
-
+
char *getprompt()
{
-
+
static String _prompt;
String tmp;
char *s;
@@ -499,22 +499,22 @@ char *getprompt()
case '%':
switch (*++s)
{
-
- case 'H':
+
+ case 'H':
strcat(_prompt,iftp[frame].host);
break;
-
+
case 'h':
strcpy(tmp,iftp[frame].host);
if (strchr(tmp,'.')!=NULL) *(char *)strchr(tmp,'.')=0;
strcat(_prompt,tmp);
break;
- case 'M':
+ case 'M':
gethostname(tmp, sizeof tmp);
strcat(_prompt,gethostbyname(tmp)->h_name);
break;
-
+
case 'm':
gethostname(tmp, sizeof tmp);
strcpy(tmp,gethostbyname(tmp)->h_name);
@@ -525,7 +525,7 @@ char *getprompt()
case 'u':
strcat(_prompt,iftp[frame].user);
break;
-
+
case 'd':
strcat(_prompt,iftp[frame].pwd);
break;
@@ -543,16 +543,16 @@ char *getprompt()
sprintf(tmp,"%d",(LINK==NULL)?0:LINK->port);
strcat(_prompt,tmp);
break;
-
+
case 't':
-
+
sprintf(tmp,"%d",(LINK==NULL)?0:LINK->timeout.tv_sec);
strcat(_prompt,tmp);
break;
-
+
case 'T':
-
+
{
time_t t=time((time_t *)0);
struct tm *lt=localtime(&t);
@@ -567,7 +567,7 @@ char *getprompt()
sprintf(tmp,"%d",getpid());
strcat(_prompt,tmp);
break;
-
+
default:
sprintf(tmp,"%%%c",*s);
strcat(_prompt,tmp);
@@ -576,7 +576,7 @@ char *getprompt()
break;
case '^':
-
+
++s;
if (isalpha(*s))
{
@@ -584,17 +584,17 @@ char *getprompt()
strcat(_prompt,tmp);
}
break;
-
+
default:
-
+
sprintf(tmp,"%c",*s);
strcat(_prompt,tmp);
break;
}
return _prompt;
}
-
-
+
+
void noop()
{
int i;
@@ -603,26 +603,26 @@ void noop()
if (noopinterval==0) return;
-
+
curtime = time((time_t *)0);
-
+
signal(SIGALRM,noop);
-
- if (prevtime==0)
+
+ if (prevtime==0)
{
prevtime=curtime;
alarm(noopinterval);
return;
}
-
- if (curtime-prevtime < noopinterval)
+
+ if (curtime-prevtime < noopinterval)
{
alarm(prevtime+noopinterval-curtime);
return;
}
-
+
printf("Waiting...");fflush(stdout);
-
+
for (i=0;i<NFRAMES;i++)
{
if ( ftp[i]==NULL || FTPCMD(ftp[i]) == NULL || iftp[i].lock )
@@ -633,7 +633,7 @@ void noop()
func3=ftp[i]->IO; ftp[i]->IO=NULL;
save = ftp[i]->timeout.tv_sec;
ftp[i]->timeout.tv_sec = nooptimeout;
-
+
FtpCommand(ftp[i],"NOOP","",0,EOF);
ftp[i]->timeout.tv_sec = save;
@@ -642,10 +642,10 @@ void noop()
ftp[i]->IO=func1;
}
-
+
alarm(noopinterval);
prevtime=curtime;
-
+
for (i=0;i<10;i++) putchar(8),putchar(' '),putchar(8);
fflush(stdout);
}
@@ -667,7 +667,7 @@ unsetsignals()
int myhash(FTP *ftp,unsigned int chars)
{
-
+
if (hashmode)
{
if (chars==0) return ftp -> counter=0;
@@ -676,7 +676,7 @@ int myhash(FTP *ftp,unsigned int chars)
fflush(stdout);
}
- if (!lastcmd)
+ if (!lastcmd)
{
noop();
alarm(0);
@@ -688,7 +688,7 @@ int myhash(FTP *ftp,unsigned int chars)
char *makefilename(char *f1, char *f2)
{
char *p;
-
+
if (*f2!=0)
return f2;
@@ -702,21 +702,21 @@ redir(char *cmdline)
char *p=cmdline;
String result;
char *r=result;
-
+
for ( ; *p ; p++ , r++ )
{
- if ( *p == '\\' )
+ if ( *p == '\\' )
{
*r = * ++ p ;
continue;
}
-
+
if ( *p == '>' || *p == '<' )
{
String filename;
char *q=filename;
char c=*p;
-
+
for (p++;isspace(*p)&&*p!=0;p++);
if (*p=='"')
{
@@ -725,10 +725,10 @@ redir(char *cmdline)
}
else
for (; !isspace(*p) && *p!=0 ; p++,q++) *q=*p;
-
+
*q=0;
-
- if ( c == '>' )
+
+ if ( c == '>' )
output(filename);
else
input(filename);
@@ -745,7 +745,7 @@ FILE *is=NULL,*os=NULL;
input(char *filename)
{
-
+
if ((is=Ftpfopen(filename,"r"))==NULL)
{
perror(filename);
@@ -761,13 +761,13 @@ input(char *filename)
output(char *filename)
{
-
+
if ((os=Ftpfopen(filename,"w"))==NULL)
{
perror(filename);
return;
}
-
+
fflush(stdout);
otty=dup(1);
close(1);
@@ -803,10 +803,10 @@ batch(char *filename)
{
FILE *fp;
String tmp;
-
+
if ((fp=fopen(filename,"r"))!=NULL)
{
-
+
while ( fgets(tmp, sizeof tmp, fp) != NULL)
{
tmp[strlen(tmp)-1]=0;
@@ -816,7 +816,7 @@ batch(char *filename)
fclose(fp);
}
}
-
+
diff --git a/lib/libftp/utils/uftpcmd.c b/lib/libftp/utils/uftpcmd.c
index 959de40..2eb3cb2 100644
--- a/lib/libftp/utils/uftpcmd.c
+++ b/lib/libftp/utils/uftpcmd.c
@@ -10,61 +10,61 @@ Ftp_connect_hook(FTP *ftp,int code, char *msg)
{
FtpLog(ftp->title,msg);
longjmp(connectstack,1);
-
+
}
-
-Ftp_connect(ARGS)
+
+Ftp_connect(ARGS)
{
STATUS (*func1)(),(*func2)();
if (*w2==0) w2=readline("Host:");
- if (FtpGetHost(w2)==NULL && FtpInit.IO != NULL)
+ if (FtpGetHost(w2)==NULL && FtpInit.IO != NULL)
{
char *msg;
extern int h_errno;
-
+
switch(h_errno)
{
case HOST_NOT_FOUND: msg = "Host unknown"; break;
case TRY_AGAIN: msg = "Hostname lookup failure";break;
- default: msg = "gethostbyname failure";
+ default: msg = "gethostbyname failure";
}
return (*FtpInit.IO)(LINK,QUIT,msg);
}
-
+
newframe(0);
-
+
func1 = FtpInit.error;
func2 = FtpInit.IO;
-
- if (trymode)
+
+ if (trymode)
{
FtpSetErrorHandler(&FtpInit,Ftp_connect_hook);
FtpSetIOHandler(&FtpInit,Ftp_connect_hook);
setjmp(connectstack);
}
-
+
FtpConnect(&LINK,w2);
strcpy(iftp[frame].host,FtpGetHost(w2)->h_name);
-
+
FtpSetErrorHandler(LINK,func1);
FtpSetErrorHandler(&FtpInit,func1);
FtpSetIOHandler(LINK,func2);
FtpSetIOHandler(&FtpInit,func2);
-
+
return;
}
Ftp_user(ARGS)
{
-
+
if (*w2==0)
{
sprintf(tmp,"login (default %s):",defaultuser);
w2=readline(tmp);
- if (*w2==0)
+ if (*w2==0)
w2=defaultuser;
}
strcpy(iftp[frame].user,w2);
@@ -74,11 +74,11 @@ Ftp_user(ARGS)
Ftp_pass(ARGS)
{
- if (*w2==0)
+ if (*w2==0)
{
String pass;
String host;
-
+
gethostname(host, sizeof host);
strcpy(host,FtpGetHost(host)->h_name);
sprintf(pass,"%s@%s",getpwuid(getuid())->pw_name,host);
@@ -86,7 +86,7 @@ Ftp_pass(ARGS)
w2=getpass(tmp);
if (*w2==0) w2=pass;
}
-
+
strcpy(iftp[frame].pass,w2);
FtpPassword(LINK,w2);
strcpy(iftp[frame].pwd,FtpPwd(LINK));
@@ -96,11 +96,11 @@ Ftp_open(ARGS)
{
register char *p1;
STATUS (*err)();
-
+
Ftp_connect("",w2,"","","","");
Ftp_user("",w3,w4,"","","" );
if (ifalias("autologin")) execute("autologin");
- if (*w5)
+ if (*w5)
Ftp_cd("cd",w5,"","","","");
}
@@ -121,11 +121,11 @@ Ftp_ftp(ARGS)
{
String pass;
String host;
-
+
gethostname(host, sizeof host);
strcpy(host,FtpGetHost(host)->h_name);
sprintf(pass,"%s@%s",getpwuid(getuid())->pw_name,host);
-
+
Ftp_open("",w2,"anonymous",pass,w3,"");
return;
}
@@ -147,14 +147,14 @@ Ftp_lcd(ARGS)
glob_t gl;
bzero(&gl,sizeof gl);
-
+
glob(w2,GLOB_BRACE|GLOB_TILDE|GLOB_QUOTE,
Ftp_mput_handler, &gl);
-
-
+
+
if (gl.gl_matchc<1 || chdir(*gl.gl_pathv))
perror(w2);
-
+
printf("Local directory is \"%s\"\n",getwd(tmp));
}
@@ -163,35 +163,35 @@ Ftp_dir(ARGS)
char *cmd1;
String cmd;
char mode=LINK->mode;
-
- if ( !strcmp(w1,"dir") )
+
+ if ( !strcmp(w1,"dir") )
cmd1="LIST";
else
cmd1="NLST";
-
+
strcpy(cmd,makestr(cmd1,w2,w3,w4,w5,w6,NULL));
if ( LINK->mode != 'A' ) FtpAscii(LINK);
FtpRetr(LINK,cmd,"","-");
if ( LINK->mode != mode ) FtpType(LINK,mode);
-
+
}
Ftp_close(ARGS)
{
register int i;
-
- if (isdigit(*w2))
+
+ if (isdigit(*w2))
{
i=atoi(w2);
}
- else
+ else
{
i=frame;
}
-
+
FtpQuickBye(ftp[i]);
-
+
iftp[i].host[0]=0;
iftp[i].pwd[0]=0;
ftp[i]=NULL;
@@ -203,19 +203,19 @@ INLINE SetLogicalVar(char arg, int * var, char *msg)
{
switch(arg)
{
-
+
case 'y':
-
+
*var=1;
break;
-
+
case 'n':
-
+
*var=0;
break;
-
+
default:
-
+
(*var)?(*var=0):(*var=1);
break;
}
@@ -227,7 +227,7 @@ Ftp_set(ARGS)
{
if (!strcmp("frame",w2))
return atoi(w3)<NFRAMES?frame=atoi(w3):0;
-
+
if (!strcmp("timeout",w2))
{
FtpSetTimeout(&FtpInit,atoi(w3));
@@ -235,17 +235,17 @@ Ftp_set(ARGS)
FtpSetTimeout(LINK,atoi(w3));
return;
}
-
+
if (!strcmp("sleep",w2))
{
sleeptime=atoi(w3);
return;
}
-
+
if (!strcmp("debug",w2))
{
- if ( *w3=='y' || *w3==0)
- {
+ if ( *w3=='y' || *w3==0)
+ {
if (LINK!=NULL) FtpSetDebugHandler(LINK,FtpDebugDebug);
FtpSetDebugHandler(&FtpInit,FtpDebugDebug);
return puts("Debuging on for current and next session");
@@ -257,11 +257,11 @@ Ftp_set(ARGS)
return puts("Debuging off for current and next session");
}
}
-
+
if (!strcmp("bin",w2))
{
- if ( *w3=='y' || *w3==0)
- {
+ if ( *w3=='y' || *w3==0)
+ {
FtpInit.mode='I';
return puts("Binary mode enable");
}
@@ -271,7 +271,7 @@ Ftp_set(ARGS)
return puts("Binary mode disable");
}
}
-
+
if (!strcmp("try",w2))
return SetLogicalVar(*w3,&trymode,"Try mode");
if (!strcmp("hash",w2))
@@ -280,16 +280,16 @@ Ftp_set(ARGS)
return SetLogicalVar(*w3,&glassmode,"Glass mode");
if (!strcmp("rest",w2)||!strcmp(w2,"restore"))
return SetLogicalVar(*w3,&restmode,"Restore mode");
-
+
if (!strcmp("prompt",w2))
{
strcpy(prompt,w3);
return;
}
-
+
if (!strcmp("port",w2))
{
- if ( isdigit(*w3))
+ if ( isdigit(*w3))
return FtpSetPort(&FtpInit,atoi(w3));
puts("Port must be number");
fflush(stdout);
@@ -298,7 +298,7 @@ Ftp_set(ARGS)
if (!strcmp("noopinterval",w2)||!strcmp("noop",w2))
{
- if ( isdigit(*w3))
+ if ( isdigit(*w3))
return noopinterval=(time_t)atoi(w3);
puts("Time must be number");
fflush(stdout);
@@ -307,21 +307,21 @@ Ftp_set(ARGS)
if (!strcmp("nooptimeout",w2))
{
- if ( isdigit(*w3))
+ if ( isdigit(*w3))
return nooptimeout=(time_t)atoi(w3);
puts("Time must be number");
fflush(stdout);
return;
}
-
+
if (!strcmp("user",w2)||!strcmp("login",w2))
{
strcpy(defaultuser,w3);
return;
}
-
+
if (!strcmp("",w2))
{
@@ -342,8 +342,8 @@ Ftp_set(ARGS)
fflush(stdout);
return;
}
- return puts("arg 2 unknown");
-
+ return puts("arg 2 unknown");
+
}
jmp_buf getstack;
@@ -351,13 +351,13 @@ jmp_buf getstack;
Ftp_get_hook(FTP *con,int code, char *msg)
{
- if ( abs(code)==550 && FtpBadReply550(msg) )
+ if ( abs(code)==550 && FtpBadReply550(msg) )
{
FtpLog(con->title,msg);
log("Transfer cancel");
longjmp(getstack,2);
}
-
+
if ( code == LQUIT )
{
log(msg);
@@ -366,7 +366,7 @@ Ftp_get_hook(FTP *con,int code, char *msg)
}
-
+
FtpLog(con->title,msg);
FtpQuickBye(LINK);
LINK=NULL;
@@ -374,11 +374,11 @@ Ftp_get_hook(FTP *con,int code, char *msg)
log("sleeping......");
sleep(sleeptime);
log("try again...");
-
+
longjmp(getstack,1);
-
+
}
-
+
void Ftp_get_intr(int sig)
{
signal(SIGINT,intr);
@@ -393,19 +393,19 @@ Ftp_get(ARGS)
int back=0;
int code;
int status=0;
-
+
OldInit=FtpInit;
-
+
if (strstr(w1,"put")!=NULL) back=1;
-
-
+
+
if (restmode || ((*w1=='r')&&(*(w1+1)=='e')) )
FtpSetFlag(LINK,FTP_REST);
else
- FtpClearFlag(LINK,FTP_REST);
-
-
-
+ FtpClearFlag(LINK,FTP_REST);
+
+
+
if (trymode)
{
FtpSetErrorHandler(LINK,Ftp_get_hook);
@@ -414,28 +414,28 @@ Ftp_get(ARGS)
FTPCMD(&FtpInit)=FTPCMD(&OldInit);
FTPDATA(&FtpInit)=FTPDATA(&OldInit);
}
-
+
signal(SIGINT,Ftp_get_intr);
FtpSetHashHandler(LINK,NULL);
-
-
- if ((status=setjmp(getstack))==2||status==3)
+
+
+ if ((status=setjmp(getstack))==2||status==3)
goto done;
-
+
if ((LINK==NULL)||(LINK->sock==FtpInit.sock))
{
FtpLogin(&LINK,iftp[frame].host,iftp[frame].user,
- iftp[frame].pass,NULL);
+ iftp[frame].pass,NULL);
FtpChdir(LINK,iftp[frame].pwd);
}
-
+
if (hashmode && isatty(fileno(stdout)))
FtpSetHashHandler(LINK,myhash);
else
FtpSetHashHandler(LINK,NULL);
-
+
myhash(LINK,0);
-
+
if (!back)
FtpGet(LINK,w2,makefilename(w2,w3));
else
@@ -443,15 +443,15 @@ Ftp_get(ARGS)
log("Transfer compliete");
-
-
+
+
done:
-
-
+
+
FtpSetHashHandler(LINK,NULL);
FtpSetErrorHandler(LINK,my_error);
FtpSetIOHandler(LINK,my_error);
- FtpClearFlag(LINK,FTP_REST);
+ FtpClearFlag(LINK,FTP_REST);
FtpInit=OldInit;
}
@@ -459,7 +459,7 @@ Ftp_mget(ARGS)
{
FILE *list;
char mode=LINK->mode;
-
+
sprintf(tmp,"/tmp/uftplist-%s.XXXXXX",getpwuid(getuid())->pw_name);
mktemp(tmp);
@@ -487,10 +487,10 @@ Ftp_mget(ARGS)
Ftp_mput(ARGS)
{
glob_t gl;
-
+
glob(w2,GLOB_BRACE|GLOB_TILDE|GLOB_QUOTE,
Ftp_mput_handler, &gl);
-
+
while(gl.gl_matchc--)
{
Ftp_get("put",*gl.gl_pathv,"","","","");
@@ -501,51 +501,51 @@ Ftp_mput(ARGS)
Ftp_bget(ARGS)
{
-
+
String fn,lfn;
char *p;
newframe(0);
-
+
if (!FtpFullSyntax(w2,iftp[frame].host,iftp[frame].user,
iftp[frame].pass,fn))
return puts("Filename syntax error");
-
+
strcpy(iftp[frame].pwd,"/");
-
- if ((p=strrchr(fn,'/'))!=NULL)
+
+ if ((p=strrchr(fn,'/'))!=NULL)
strcpy(lfn,p+1);
else
strcpy(lfn,fn);
-
+
FtpQuickBye(LINK);
LINK=FtpCreateObject();
LINK->sock=NULL;
-
+
Ftp_get("get",fn,(*w3==0)?lfn:w3,"","","");
}
Ftp_bput(ARGS)
{
-
+
String fn,lfn;
char *p;
if (!FtpFullSyntax((*w3==0)?w2:w3,iftp[frame].host,iftp[frame].user,
iftp[frame].pass,fn))
return puts("Filename syntax error");
-
+
strcpy(iftp[frame].pwd,"/");
-
- if ((p=strrchr(fn,'/'))!=NULL)
+
+ if ((p=strrchr(fn,'/'))!=NULL)
strcpy(lfn,p+1);
else
strcpy(lfn,fn);
-
+
FtpQuickBye(LINK);
LINK=FtpCreateObject();
LINK->sock=NULL;
-
+
Ftp_get("put",(*w3==0)?lfn:w2,fn,"","","");
}
@@ -553,10 +553,10 @@ Ftp_copy(ARGS)
{
char *p;
int in,out;
-
+
if ( !*w2 || !*w3 ) return puts("Must pass two args");
-
- if ((p=strchr(w2,'!'))!=NULL)
+
+ if ((p=strchr(w2,'!'))!=NULL)
{
*p=0;
in=atoi(w2);
@@ -565,7 +565,7 @@ Ftp_copy(ARGS)
else
in=frame;
- if ((p=strchr(w3,'!'))!=NULL)
+ if ((p=strchr(w3,'!'))!=NULL)
{
*p=0;
out=atoi(w3);
@@ -573,9 +573,9 @@ Ftp_copy(ARGS)
}
else
in=frame;
-
+
if (in==out) return puts("Files must been from different frames");
-
+
FtpCopy(ftp[in],ftp[out],w2,w3);
}
@@ -583,10 +583,10 @@ Ftp_ccopy(ARGS)
{
char *p;
int in,out;
-
+
if ( !*w2 || !*w3 ) return puts("Must pass two args");
-
- if ((p=strchr(w2,'!'))!=NULL)
+
+ if ((p=strchr(w2,'!'))!=NULL)
{
*p=0;
in=atoi(w2);
@@ -595,7 +595,7 @@ Ftp_ccopy(ARGS)
else
in=frame;
- if ((p=strchr(w3,'!'))!=NULL)
+ if ((p=strchr(w3,'!'))!=NULL)
{
*p=0;
out=atoi(w3);
@@ -603,9 +603,9 @@ Ftp_ccopy(ARGS)
}
else
in=frame;
-
+
if (in==out) return puts("Files must been from different frames");
-
+
FtpPassiveTransfer(ftp[in],ftp[out],w2,w3);
}
@@ -628,17 +628,17 @@ Ftp_cd(ARGS)
Ftp_dup(ARGS)
-{
+{
LINKINFO oldinfo;
FTP oldftp;
-
+
oldinfo=iftp[frame];
oldftp=*LINK;
-
+
newframe(0);
puts("Make alternative connection...");
Ftp_open("",oldinfo.host,oldinfo.user,oldinfo.pass,"","");
- if (strcmp(oldinfo.pwd,iftp[frame].pwd))
+ if (strcmp(oldinfo.pwd,iftp[frame].pwd))
Ftp_cd("",oldinfo.pwd,"","","","");
if (LINK->mode!=oldftp.mode)
FtpType(LINK,oldftp.mode);
@@ -649,23 +649,23 @@ Ftp_dup(ARGS)
FtpSetIOHandler(LINK,oldftp.IO);
FtpSetHashHandler(LINK,oldftp.hash);
}
-
-
+
+
Ftp_bg(ARGS)
{
if (fork())
{
-
+
log("Backgrounding...");
return;
}
else
{
int i=frame;
-
+
lastcmd=1;
-
+
/* Ignoring keypad */
alarm (0);
@@ -680,7 +680,7 @@ Ftp_bg(ARGS)
/* Droping output */
-
+
sprintf(tmp,"/tmp/uftp-%s.XXXXXX",getpwuid(getuid())->pw_name);
mktemp(tmp);
close(0);close(1);close(2);
@@ -693,21 +693,21 @@ Ftp_bg(ARGS)
free(ftp[i]);
ftp[i]=NULL;
}
-
+
return executev(w2,w3,w4,w5,w6,"");
}
}
-
+
Ftp_list()
{
register int i;
-
-#define _FMT "%-5s %-15s %-10s %-25s %-7s %-4s\n"
-#define FMT "%-5d %-15s %-10s %-25s %-7d %-4d\n"
-
+
+#define _FMT "%-5s %-15s %-10s %-25s %-7s %-4s\n"
+#define FMT "%-5d %-15s %-10s %-25s %-7d %-4d\n"
+
printf(_FMT,"Frame","Host name","User's name","Working directory","Timeout","Port");
-
+
for ( i = 0 ; i < NFRAMES ; i++ )
if (ftp[i]!=NULL)
printf(FMT,i,iftp[i].host,iftp[i].user,iftp[i].pwd,
@@ -739,10 +739,10 @@ Ftp_page(ARGS)
{
register char *pager;
String out={'|',0};
-
- if ((pager=(char *)getenv("PAGER"))==NULL)
+
+ if ((pager=(char *)getenv("PAGER"))==NULL)
pager="more";
-
+
strcat(out,pager);
FtpGet(LINK,w2,out);
}
@@ -759,24 +759,24 @@ Ftp_rm(ARGS)
sprintf(tmp,"/tmp/uftplist-%s.XXXXXX",getpwuid(getuid())->pw_name);
mktemp(tmp);
-
- if (*w2==0)
+
+ if (*w2==0)
{
log("Filename specification must present");
return;
}
-
+
FtpRetr(LINK,"NLST %s",w2,tmp);
-
+
if ((list=fopen(tmp,"r"))==NULL)
return FtpLog(tmp,sys_errlist[errno]);
-
+
while ( fgets(tmp,sizeof tmp,list)!=NULL)
{
tmp[strlen(tmp)-1]=0;
FtpCommand(LINK,"DELE %s",tmp,0,EOF);
}
-
+
fclose(list);
}
@@ -791,7 +791,7 @@ Ftp_move(ARGS)
Ftp_help(ARGS)
{
register int i,ii;
-
+
if ( !*w2 )
{
puts("Warrning!!!! \nPlease read general information using command \"help etc\"\n\n");
@@ -806,7 +806,7 @@ Ftp_help(ARGS)
putchar ('\n');
}
}
-
+
for ( i = 0 ; 1; i++)
{
@@ -817,13 +817,13 @@ Ftp_help(ARGS)
}
puts(cmds[i].help);
-
+
}
Ftp_quote(ARGS)
{
String new;
-
+
new[0]=0;
if (*w2!=0) strcpy(new,w2);
@@ -838,8 +838,8 @@ Ftp_quote(ARGS)
Ftp_alias(ARGS)
{
ALIAS *a=firstalias;
-
-
+
+
if ( *w2==0 )
{
while (a!=NULL)
@@ -851,20 +851,20 @@ Ftp_alias(ARGS)
}
- while (1)
+ while (1)
{
if ( a == NULL )
- {
+ {
firstalias = a = (ALIAS *) malloc(sizeof(ALIAS));
memset(a,0,sizeof(ALIAS));
a -> next = NULL;
break;
}
-
+
if (!strcmp(a->name,w2))
break;
-
+
if ( a->next == NULL)
{
a -> next = (ALIAS *) malloc(sizeof(ALIAS));
@@ -875,7 +875,7 @@ Ftp_alias(ARGS)
}
a=a->next;
}
-
+
strcpy(a -> name,w2);
strcpy(a -> str,makestr(w3,w4,w5,w6,NULL));
}
@@ -889,7 +889,7 @@ Ftp_mkalias(ARGS)
sprintf(new,"open \"%s\" \"%s\" \"%s\" \"%s\"",
iftp[frame].host,iftp[frame].user,
iftp[frame].pass,iftp[frame].pwd);
-
+
Ftp_alias("alias",w2,new,"","","");
}
@@ -947,31 +947,31 @@ Ftp_acd(ARGS)
static int targets=0;
static String what={0};
static ARCHIE result[ARCHIE_MAX_TARGETS];
-
+
int i, selected_target;
String tmp;
char *p;
-
+
if ( (what[0] == 0 || strcmp(w2,what) != 0) && *w2!=0 )
{
- if ((targets=FtpArchie(w2,result,ARCHIE_MAX_TARGETS))<1)
+ if ((targets=FtpArchie(w2,result,ARCHIE_MAX_TARGETS))<1)
return puts("Archie failure or target not found");
strcpy(what,w2);
}
-
+
for (i=0;i<targets;i++)
printf("%2d %s:%s\n",i,result[i].host,result[i].file);
-
+
if (strcmp(w1,"archie")==0)
return;
-
-
+
+
p = readline("Your selection? ");
if (p==NULL) return;
-
+
selected_target = atoi(p);
-
+
if ( result[selected_target].file[strlen(result[selected_target].file)-1]
== '/' )
{
@@ -989,25 +989,25 @@ Ftp_acd(ARGS)
CMDS cmds[]={
-
+
"connect", Ftp_connect, 0,
"connect <hostname> - make new ftp connection",
"open", Ftp_open, 0,
"open <hostname> <user> <pass> <directory> - login to server",
-
+
"reopen", Ftp_reopen, 1,
"Open again connection with existing frame information",
-
+
"ftp", Ftp_ftp, 0,
"ftp <hostname> - anonymously login to server",
-
+
"close", Ftp_close, 1,
"Close connection",
-
+
"quit", Ftp_quit, 0,
"Exit from uftp",
-
+
"set", Ftp_set, 0,
"Set variables: (Without args print current settings)\n\
frame <number> - select another session(frame)\n\
@@ -1028,7 +1028,7 @@ CMDS cmds[]={
"prompt", NULL, 0,
"\
-prompt is a string, which may be contains %<char>
+prompt is a string, which may be contains %<char>
or ^<char> combitanion, which have next interprets:
%H, %h - full and short remote host names
@@ -1038,8 +1038,8 @@ or ^<char> combitanion, which have next interprets:
%D - local current directory
%f - number of current frame
%p - the ftp's port number
-%t - timeout
-%T - current time
+%t - timeout
+%T - current time
%P - uftp process id
%% - character %
^<char>- control character
@@ -1114,7 +1114,7 @@ or ^<char> combitanion, which have next interprets:
"bput", Ftp_bput, 0,
"bput [<localfile>] <libftp_file> - full session procedure (See \"help etc\")",
-
+
"copy", Ftp_copy, 1,
"copy [<frame>!]file [<frame>!]file - copy file via client cache",
@@ -1123,7 +1123,7 @@ or ^<char> combitanion, which have next interprets:
"cat", Ftp_type, 1,
"cat <file> - print body of remote file to screen",
-
+
"page", Ftp_page, 1,
"page <file> - print body of remote file to screen via pager",
OpenPOWER on IntegriCloud