FTPServer.c example details
FTP Server description
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include <time.h>
#include <string.h>
#include "efs.def"
#ifdef __cplusplus
extern "C" {
#endif
#pragma CODE_SECTION(FTP_CheckClients , ".commontext");
#pragma CODE_SECTION(FTP_PrintResult , ".commontext");
#ifdef __cplusplus
}
#endif
{
if (ret != clients)
{
clients = ret;
CPrintf (
"\r\n connection status changed: %"PRId32
" client(s) connected\r\n", clients);
return (1);
}
return (0);
}
{
switch ( ftp_ret-> reason )
{
CPuts (
" File upload... ");
break;
CPuts (
" Boot command... ");
if (ftp_ret-> offset >= 0x30000)
else
return;
CPuts (
" Delete command... ");
break;
CPrintf (
" New connection established from %s\r\n",
inet_ntoa(ftp_ret-> offset, buffer));
return;
return;
default:
break;
}
switch ( ftp_ret-> error_code )
{
fp = ftp_ret-> fp;
if (ftp_ret-> offset==0)
{
if (!strncmp(fp->
dir,
"0:",2))
{
CPuts (
" RAM-disc:\r\n");
}
if (!strncmp(fp->
dir,
"1:",2))
{
CPuts (
" NAND-disc:\r\n");
}
#ifdef USE_SPIDRIVE
if (!strncmp(fp->
dir,
"2:",2))
{
}
#endif
}
else
{
CPrintf (
" EFS offset: 0x%08"PRIx32
"\r\n", ftp_ret-> offset);
}
CPrintf (
" file name: %s\r\n", fp-> name);
CPrintf (
" file size: %"PRId32
"\r\n", ftp_ret-> fp-> size);
break;
default:
net_print_error (ftp_ret-> error_code,
CPrintf);
break;
}
}
#pragma CODE_SECTION(main , ".commontext");
{
int main_loop = 1;
CPrintf (
" *** timer %d mapped to CPU int %d ***\r\n",
if ( ftp_serv == FALSE )
{
}
CPuts (
" network startup time [sec]: ");
"%"PRId32".%03"PRId32"\r\n"
CPuts (
"\r\n 3 different users have FTP access:\r\n\n");
CPuts (
" user: admin password: xxxx\r\n");
CPuts (
" user: guest password: -\r\n");
CPuts (
" user: anonymous password: -\r\n\n");
while ( main_loop )
{
{
{
main_loop = 0;
}
}
}
{
}
return (0);
}