1995-04-25 17:05:11 +02:00
|
|
|
/*
|
|
|
|
Library for ftpd clients.(libftp)
|
|
|
|
Copyright by Oleg Orel
|
|
|
|
All rights reserved.
|
1995-05-30 07:51:47 +02:00
|
|
|
|
|
|
|
This library is desined for free, non-commercial software creation.
|
|
|
|
It is changeable and can be improved. The author would greatly appreciate
|
1995-04-25 17:05:11 +02:00
|
|
|
any advises, new components and patches of the existing programs.
|
|
|
|
Commercial usage is also possible with participation of it's author.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "FtpLibrary.h"
|
|
|
|
|
|
|
|
void FtpDebug(FTP *ftp)
|
|
|
|
{
|
|
|
|
STATUS FtpDebugDebug(),
|
|
|
|
FtpDebugError(),
|
|
|
|
FtpDebugIO();
|
|
|
|
|
|
|
|
FtpSetDebugHandler(ftp,FtpDebugDebug);
|
|
|
|
FtpSetErrorHandler(ftp,FtpDebugError);
|
|
|
|
FtpSetIOHandler(ftp,FtpDebugIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
STATUS FtpDebugDebug(FTP *ftp,int n, char * Message)
|
|
|
|
{
|
|
|
|
String tmp;
|
|
|
|
|
1995-05-30 07:51:47 +02:00
|
|
|
|
1995-04-25 17:05:11 +02:00
|
|
|
strcpy(tmp,Message);
|
1995-05-30 07:51:47 +02:00
|
|
|
|
1995-04-25 17:05:11 +02:00
|
|
|
if (strncmp(tmp,"PASS ",5)==0)
|
|
|
|
{
|
|
|
|
char *p=tmp+5;
|
|
|
|
while ( *p != '\0') *p++='*';
|
|
|
|
};
|
1995-05-30 07:51:47 +02:00
|
|
|
|
1995-04-25 17:05:11 +02:00
|
|
|
FtpLog(ftp->title,tmp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATUS FtpDebugError(FTP *ftp,int n, char * Message)
|
|
|
|
{
|
1995-05-30 07:51:47 +02:00
|
|
|
|
1995-04-25 17:05:11 +02:00
|
|
|
FtpLog("FtpDebugError","");
|
|
|
|
FtpLog(ftp->title,Message);
|
|
|
|
if ( ! FtpTestFlag(ftp,FTP_NOEXIT))
|
|
|
|
exit(1);
|
1995-04-25 17:08:02 +02:00
|
|
|
return 0;
|
1995-04-25 17:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
STATUS FtpDebugIO(FTP *ftp,int n, char * Message)
|
|
|
|
{
|
|
|
|
FtpLog("FtpDebugIO","");
|
|
|
|
FtpLog(ftp->title,Message);
|
|
|
|
if ( ! FtpTestFlag(ftp,FTP_NOEXIT))
|
|
|
|
exit(1);
|
1995-04-25 17:08:02 +02:00
|
|
|
return 0;
|
1995-04-25 17:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
STATUS FtpLog(char *name,char *str)
|
|
|
|
{
|
|
|
|
time_t t=time((time_t *)0);
|
|
|
|
struct tm *lt=localtime(&t);
|
|
|
|
fprintf(stderr,"%02d:%02d:%02d %s %s\n",lt->tm_hour,
|
|
|
|
lt->tm_min,lt->tm_sec,name,str);
|
|
|
|
fflush(stderr);
|
1995-04-25 17:08:02 +02:00
|
|
|
return 0;
|
1995-04-25 17:05:11 +02:00
|
|
|
}
|
|
|
|
|
1995-04-25 17:08:02 +02:00
|
|
|
int
|
1995-04-25 17:05:11 +02:00
|
|
|
FtpHash(FTP *ftp, unsigned long chars)
|
|
|
|
{
|
1995-05-30 07:51:47 +02:00
|
|
|
|
1995-04-25 17:05:11 +02:00
|
|
|
if (chars==0) return ftp->counter=0;
|
|
|
|
ftp->counter+=chars;
|
1995-04-25 17:08:02 +02:00
|
|
|
fprintf(stdout,"%10u bytes transfered\r",(unsigned int)ftp->counter);
|
1995-04-25 17:05:11 +02:00
|
|
|
fflush(stdout);
|
|
|
|
return ftp->counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
STATUS FtpBadReply550(char *s)
|
|
|
|
{
|
|
|
|
if(
|
|
|
|
(strstr(s,"unreachable")!=NULL) ||
|
|
|
|
(strstr(s,"Broken pipe")!=NULL)
|
1995-05-30 07:51:47 +02:00
|
|
|
)
|
1995-04-25 17:05:11 +02:00
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|