#include <net_config.h>
U16 ftpc_cbfunc (
U8 code, /* Type of data requested by the FTP Client. */
U8* buf, /* Location where to write the requested data. */
U16 buflen ); /* Number of bytes in the output buffer. */
Description
The ftpc_cbfunc function provides additional parameters for
the FTP client session such as, the credentials to logon to FTP
server, local and remote file name for the file operation, etc. The
FTP client calls this function several times to complete the file
operation requested.
The argument code specifies the type of additional
information (user, password, file name, etc.) that the FTP Client
requires. This is shown in the table.
Code
Type
Description
0
Username:
Username for FTP authentication
1
Password:
Password for FTP authentication
2
Working directory:
Working directory path for all commands
3
Filename:
Filename for PUT, GET, APPEND, DELETE or RENAME commands
4
New name:
New filename for RENAME command
5
Directory name:
A directory name for MKDIR or RMDIR command
6
File filter:
A file filter/mask for the LIST command
7
Directory list:
Received directory listing when the LIST command was
given
The argument buf is a pointer to the output buffer where
the ftpc_cbfunc function writes the requested data into. The
argument buflen specifies the length of the output buffer in
bytes.
The ftpc_cbfunc function is part of RL-TCPnet. The
prototype is defined in net_config.h. You must customize the function
in ftpc_uif.c.
note
The length of the output buffer, buflen might vary
because buffer length is determined by the TCP socket Maximum
Segment Size (MSS) negotiation. The buffer length is normally 1460
bytes for local LAN.
If the ftpc_cbfunc function writes more bytes than
buflen into the output buffer, then a system crash resulting from
corruption of memory link pointers is highly likely.
Return Value
The ftpc_cbfunc function returns the number of bytes
written to the output buffer.
#define FTPC_USERNAME "anonymous"
#define FTPC_PASSWORD "test@keil.com"
#define FTPC_PATH "/Logs"
#define FTPC_FILENAME "test.log"
#define FTPC_NEWNAME "renamed.log"
#define FTPC_DIRNAME "New_Folder"
#define FTPC_LISTNAME "*.log"
#define LOCAL_FILE "test.log"
U16 ftpc_cbfunc (U8 code, U8 *buf, U16 buflen) {
/* This function is called by the FTP client to get parameters. */
U32 i,len = 0;
switch (code) {
case 0:
/* Enter Username for login. */
len = str_copy (buf, FTPC_USERNAME);
break;
case 1:
/* Enter Password for login. */
len = str_copy (buf, FTPC_PASSWORD);
break;
case 2:
/* Enter a working directory path. */
len = str_copy (buf, FTPC_PATH);
break;
case 3:
/* Enter a filename for file operations. */
len = str_copy (buf, FTPC_FILENAME);
break;
case 4:
/* Enter a new name for rename command. */
len = str_copy (buf, FTPC_NEWNAME);
break;
case 5:
/* Enter a directory name to create or remove. */
len = str_copy (buf, FTPC_DIRNAME);
break;
case 6:
/* Enter a file filter for list command. */
len = str_copy (buf, FTPC_LISTNAME);
break;
case 7:
/* Process received directory listing in raw format. */
/* Function return value is don't care. */
for (i = 0; i < buflen; i++) {
putchar (buf[i]);
}
break;
}
return ((U16)len);
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.