|
NetBurner 3.5.7
PDF Version |
Functions | |
| int | FTP_InitializeSession (IPADDR4 server_address, uint16_t port, PCSTR UserName, PCSTR Password, uint32_t time_out) |
| Initialize a FTP session with a FTP server. | |
| int | FTP_CloseSession (int session) |
| Close a FTP session. | |
| int | FTPGetDir (int ftp_Session, char *dir_buf, int nbytes, uint16_t timeout) |
| Get the current working directory. | |
| int | FTPSetDir (int ftp_Session, const char *new_dir, uint16_t timeout) |
| Set the current working directory. | |
| int | FTPDeleteDir (int ftp_Session, const char *dir_to_delete, uint16_t timeout) |
| Delete a directory. | |
| int | FTPMakeDir (int ftp_Session, const char *dir_to_make, uint16_t timeout) |
| Create a new directory. | |
| int | FTPUpDir (int ftp_Session, uint16_t timeout) |
| Move up one directory level. | |
| int | FTPDeleteFile (int ftp_Session, const char *file_name, uint16_t timeout) |
| Delete a file. | |
| int | FTPRenameFile (int ftp_Session, const char *old_file_name, const char *new_file_name, uint16_t timeout) |
| Rename a file. | |
| int | FTPSendFile (int ftp_Session, const char *full_file_name, BOOL bBinaryMode, uint16_t timeout) |
| Initialize the process to send a file to a FTP server. | |
| int | FTPGetFile (int ftp_Session, const char *full_file_name, BOOL bBinaryMode, uint16_t timeout) |
| Initialize the process to get a file from a FTP server. | |
| int | FTPGetList (int ftp_Session, const char *full_dir_name, uint16_t timeout) |
| Initialize the process to receive a directory listing from a FTP server. | |
| int | FTPGetFileNames (int ftp_Session, const char *full_dir_name, uint16_t timeout) |
| Initialize the process to receive just the file names in a directory from a FTP server. | |
| int | FTPRawCommand (int ftp_Session, const char *cmd, char *cmd_buf, int nbytes, uint16_t timeout) |
| Send a FTP command to the FTP server. | |
| int | FTPGetCommandResult (int ftp_Session, char *cmd_buf, int nbytes, uint16_t timeout) |
| Returns the result of the last FTP operation. | |
| int | FTPRawStreamCommand (int ftp_Session, const char *cmd, int *pResult, char *cmd_buf, int nbytes, uint16_t timeout) |
| Send a command and receive a response over a stream connection. | |
| void | FTPActiveMode (int ftp_Session) |
| Set the data connection mode to active (PORT). | |
| void | FTPPassiveMode (int ftp_Session) |
| Set the data connection mode to passive (PASV). | |
#include< ftp.h>
The NetBurner FTP Client API provides a session-based interface for communicating with remote FTP servers. A session is established by calling FTP_InitializeSession(), which returns a session handle used by all subsequent operations. Multiple concurrent sessions to different servers are supported.
Key Features:
The file transfer functions FTPSendFile(), FTPGetFile(), FTPGetList(), and FTPGetFileNames() return a TCP file descriptor rather than transferring data directly. After obtaining the file descriptor:
All timeout parameters are specified in system Time Ticks. Use the TICKS_PER_SECOND constant to specify timeouts in seconds. For example, 5 * TICKS_PER_SECOND for a 5-second timeout.
Most functions return ftpClientReturnCodes on failure (negative values). Functions that return handles or file descriptors return a positive value on success. Always check the return value before proceeding.
Expand for Example Usage
| int FTP_CloseSession | ( | int | session | ) |
#include <ftp.h>
Close a FTP session.
Sends the FTP QUIT command and closes the TCP connection to the FTP server. This function should always be called when done with a session to free resources.
| session | FTP session number to close |
| int FTP_InitializeSession | ( | IPADDR4 | server_address, |
| uint16_t | port, | ||
| PCSTR | UserName, | ||
| PCSTR | Password, | ||
| uint32_t | time_out ) |
#include <ftp.h>
Initialize a FTP session with a FTP server.
Open a connection to a FTP server and log in with the specified username and password. The session handle returned from this call is required by all other FTP client functions to identify the server connection.
| server_address | The IP address of the FTP server |
| port | The listen port number of the FTP server. Typically 21. |
| UserName | Log-in username |
| Password | Log-in password |
| time_out | Timeout in system Time Ticks |
| >0 | A FTP session handle for use with subsequent FTP operations |
| FTP_TIMEOUT | The connection attempt timed out |
| FTP_PASSWORDERROR | Authentication failed with the provided credentials |
| FTP_CONNECTFAIL | Unable to establish a TCP connection to the server |
| void FTPActiveMode | ( | int | ftp_Session | ) |
#include <ftp.h>
Set the data connection mode to active (PORT).
In active mode, the client sends a PORT command telling the server which address and port to connect back to for data transfers. This is the traditional FTP behavior, but may not work when the client is behind a firewall or NAT device.
| ftp_Session | FTP session number |
| int FTPDeleteDir | ( | int | ftp_Session, |
| const char * | dir_to_delete, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Delete a directory.
Removes a directory on the remote FTP server. The directory must typically be empty before it can be deleted.
| ftp_Session | FTP session number |
| dir_to_delete | Directory to delete |
| timeout | Timeout in system Time Ticks |
| int FTPDeleteFile | ( | int | ftp_Session, |
| const char * | file_name, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Delete a file.
Deletes a file on the remote FTP server.
| ftp_Session | FTP session number |
| file_name | Name of file to delete |
| timeout | Timeout in system Time Ticks |
| int FTPGetCommandResult | ( | int | ftp_Session, |
| char * | cmd_buf, | ||
| int | nbytes, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Returns the result of the last FTP operation.
Queries the FTP server for the last FTP operation status.
Must be called after the following functions are used:
| ftp_Session | FTP session number |
| cmd_buf | The buffer to hold the ASCII FTP server response. See FTP Server return codes for details. |
| nbytes | The maximum number of bytes cmd_buf can hold |
| timeout | Timeout in system Time Ticks |
| int FTPGetDir | ( | int | ftp_Session, |
| char * | dir_buf, | ||
| int | nbytes, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Get the current working directory.
Retrieves the current working directory path on the remote FTP server and copies it into the provided buffer.
| ftp_Session | FTP session number |
| dir_buf | The buffer to copy the directory information into |
| nbytes | Maximum number of bytes in the dir_buf |
| timeout | Timeout in system Time Ticks |
| int FTPGetFile | ( | int | ftp_Session, |
| const char * | full_file_name, | ||
| BOOL | bBinaryMode, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Initialize the process to get a file from a FTP server.
This function opens a TCP connection to a FTP server so that a file may be read. It will return a file descriptor that can then be used to read the file data using file I/O functions such as: read() and ReadWithTimeout().
IMPORTANT: After reading the file data you must do 2 things:
| ftp_Session | FTP session number |
| full_file_name | Full file name being read, including the path |
| bBinaryMode | True = read file as binary data, False = read file as ASCII data |
| timeout | Timeout in system Time Ticks |
Expand for Example Usage
| int FTPGetFileNames | ( | int | ftp_Session, |
| const char * | full_dir_name, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Initialize the process to receive just the file names in a directory from a FTP server.
This function opens a TCP connection to a FTP server so that a list of file names may be read. It will return a file descriptor that can then be used to read the name list using file I/O functions such as: read() and ReadWithTimeout(). Unlike FTPGetList(), this returns only file names without additional details such as size or date.
IMPORTANT: After reading the name list you must do 2 things:
| ftp_Session | FTP session number |
| full_dir_name | Full directory name to read, including the path |
| timeout | Timeout in system Time Ticks |
| int FTPGetList | ( | int | ftp_Session, |
| const char * | full_dir_name, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Initialize the process to receive a directory listing from a FTP server.
This function opens a TCP connection to a FTP server so that a directory list may be read. It will return a file descriptor that can then be used to read the listing data using file I/O functions such as: read() and ReadWithTimeout(). The listing includes file names, sizes, dates, and permissions in the standard FTP LIST format.
IMPORTANT: After reading the listing data you must do 2 things:
| ftp_Session | FTP session number |
| full_dir_name | Full directory name to read, including the path |
| timeout | Timeout in system Time Ticks |
| int FTPMakeDir | ( | int | ftp_Session, |
| const char * | dir_to_make, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Create a new directory.
Creates a new directory on the remote FTP server at the specified path.
| ftp_Session | FTP session number |
| dir_to_make | Directory to create |
| timeout | Timeout in system Time Ticks |
| void FTPPassiveMode | ( | int | ftp_Session | ) |
#include <ftp.h>
Set the data connection mode to passive (PASV).
In passive mode, the server provides an address and port for the client to connect to for data transfers. This mode is generally preferred when the client is behind a firewall or NAT device, since the client initiates all connections.
| ftp_Session | FTP session number |
| int FTPRawCommand | ( | int | ftp_Session, |
| const char * | cmd, | ||
| char * | cmd_buf, | ||
| int | nbytes, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Send a FTP command to the FTP server.
Sends an arbitrary FTP protocol command and returns the server's response. Use this function for FTP commands not covered by the other API functions.
| ftp_Session | FTP session number. |
| cmd | The command to send. Do not include termination such as \r\n. |
| cmd_buf | The buffer to hold the FTP server response, in ASCII. |
| nbytes | The maximum number of bytes the cmd_buf can hold. |
| timeout | Timeout in system Time Ticks. |
| int FTPRawStreamCommand | ( | int | ftp_Session, |
| const char * | cmd, | ||
| int * | pResult, | ||
| char * | cmd_buf, | ||
| int | nbytes, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Send a command and receive a response over a stream connection.
The FTP server will close the connection after all the data has been read. This function is the basis for such functions as FTPGetList() and FTPGetFileNames().
IMPORTANT: After reading the data you must call FTPGetCommandResult() to check the result of the operation.
| ftp_Session | FTP session number |
| cmd | Command to send |
| pResult | The server response code integer value |
| cmd_buf | The server response code ASCII value (including \r\n) |
| nbytes | Maximum number of bytes cmd_buf can hold |
| timeout | Timeout in system Time Ticks |
| int FTPRenameFile | ( | int | ftp_Session, |
| const char * | old_file_name, | ||
| const char * | new_file_name, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Rename a file.
Renames a file on the remote FTP server. Can also be used to move a file by specifying a different directory path in the new name.
| ftp_Session | FTP session number |
| old_file_name | Name of file to rename |
| new_file_name | New name of file |
| timeout | Timeout in system Time Ticks |
| int FTPSendFile | ( | int | ftp_Session, |
| const char * | full_file_name, | ||
| BOOL | bBinaryMode, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Initialize the process to send a file to a FTP server.
This function opens a TCP connection to a FTP server so that a file may be sent. It will return a file descriptor that can then be used to send the file data using file I/O write functions such as: write(), writeall(), writestring(), etc.
IMPORTANT: After sending the file data you must do 2 things:
| ftp_Session | FTP session number |
| full_file_name | Name of the file being sent |
| bBinaryMode | True = send file as binary data, False = send file as ASCII data |
| timeout | Timeout in system Time Ticks |
Expand for Example Usage
| int FTPSetDir | ( | int | ftp_Session, |
| const char * | new_dir, | ||
| uint16_t | timeout ) |
#include <ftp.h>
Set the current working directory.
Changes the current working directory on the remote FTP server to the specified path.
| ftp_Session | FTP session number |
| new_dir | Directory path to set |
| timeout | Timeout in system Time Ticks |
| int FTPUpDir | ( | int | ftp_Session, |
| uint16_t | timeout ) |
#include <ftp.h>
Move up one directory level.
Changes the current working directory on the remote FTP server to the parent directory. Equivalent to cd .. on the remote server.
| ftp_Session | FTP session number |
| timeout | Timeout in system Time Ticks |