FTPClient.c example details
FTP Client description
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
#pragma CODE_SECTION(FTP_receive_file, ".nettextslow");
#pragma CODE_SECTION(FTP_send_file, ".nettextslow");
#ifdef __cplusplus
}
#endif
#define FTP_DOWNLOAD UINT32_C(1)
#define FTP_UPLOAD UINT32_C(2)
#ifdef __cplusplus
#pragma DATA_SECTION(".data_slow");
#else
#pragma DATA_SECTION(data_buffer, ".data_slow");
#endif
{
};
{
if ( FTP_client ==
NULL )
{
"Out of memory error\r\n"
return (FALSE);
}
CPuts (
"Connecting..." );
{
case TRUE:
{
switch ( ret )
{
CPrintf (
"Retrieving readme.txt ( %"PRId32
" bytes) successful\r\n", FTP_client-> file_size );
break;
CPuts (
"Error: Port in use\r\n");
break;
CPuts (
"Error: Invalid path\r\n");
break;
default :
CPuts (
"Retrieving readme.txt failure\r\n" );
break;
}
}
else
{
CPuts(
"FTP server login failed\r\n" );
}
break;
default :
CPuts (
"Error connecting FTP server:\r\n");
net_print_error (FTP_client-> control -> error_code,
CPrintf);
break;
}
return (ret);
}
{
if ( FTP_client ==
NULL )
{
"Out of memory error\r\n"
return (FALSE);
}
CPuts(
"Connecting..." );
{
case TRUE:
{
switch ( ret )
{
CPrintf(
"sending logfile.bin ( %"PRId32
" bytes) successful\r\n", FTP_client-> file_size );
break;
CPuts (
"Error: Port in use\r\n");
break;
CPuts (
"Error: Invalid path\r\n");
break;
default :
CPuts (
"sending logfile.bin failure\r\n" );
break;
}
}
else
{
CPuts (
"FTP server login failed\r\n" );
}
break;
default :
CPuts (
"Error connecting FTP server:\r\n");
net_print_error (FTP_client-> control -> error_code,
CPrintf);
break;
}
return (ret);
}
#pragma CODE_SECTION(main , ".commontext");
{
int main_loop = 1;
#ifdef USE_UART_CONTROL
char c;
#endif
CPrintf (
" *** timer %d mapped to CPU int %d ***\r\n",
CPuts (
" network startup time [sec]: ");
"%"PRId32".%03"PRId32"\r\n"
#ifdef USE_UART_CONTROL
#else
CPuts (
"\r\n use test.gel to set action\r\n");
#endif
CPuts (
" entering main loop ...\r\n");
while ( main_loop )
{
{
break;
break;
default :
break;
}
#ifdef USE_KEY_CONTROL
#endif
#ifdef USE_UART_CONTROL
{
}
#endif
}
return (0);
}