Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

tini400_ftpclient.h File Reference


Detailed Description

FTP Client functions for DS80C400.

This library contains functions for FTP Client.

Warning:
The functions in this library are NOT multi-process safe--that is, if you call the same method from two different processes at the same time, the parameters to the function may be destroyed, yielding unpredictable results.
For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.

#include "rom400_sock.h"
#include "stdio.h"
#include "ftpcodes.h"
#include <string.h>
#include <ctype.h>

Go to the source code of this file.

Defines

#define FTPCLIENT_VERSION_NUMBER   1
#define FTPCLIENT_ASCII   0
#define FTPCLIENT_BINARY   1
#define FTPCLIENT_PORTNUMBER   21
#define FTPCLIENT_ACTIVE_MODE   1
#define FTPCLIENT_PASSIVE_MODE   0
#define FTPCLIENT_DETAILED_DIRLISTING   1
#define FTPCLIENT_SHORT_DIRLISTING   0
#define FTPCLIENT_STATUS_SUCCESS   0
#define FTPCLIENT_SOCKET_ERROR   -1
#define FTPCLIENT_FILE_NOT_FOUND   -2
#define FTPCLIENT_FILE_IO_ERROR   -3
#define FTPCLIENT_ALREADY_LOGGEDIN   -4
#define FTPCLIENT_NOT_CONNECTED   -5

Functions

unsigned int ftpclient_version (void)
 Returns version number of ftpclient library.
void ftpclient_init (long milli_seconds)
 Initializes the ftpclient library.
int ftpclient_connect (struct sockaddr_in *sa, char *user, char *passwd)
 Connects with FTP server.
int ftpclient_settransmissionmode (char flag)
 Sets data transfer mode in FTP server.
void ftpclient_setdataconnectionmode (char flag)
 Set data connection mode in ftpclient library.
int ftpclient_getfile (char *filename, char *storeas_filename)
 Downloads file from FTP server.
int ftpclient_putfile (char *filename, char *storeas_filename)
 Uploads tini file to FTP server.
int ftpclient_dir (char *name, char *dir_str, int dir_str_len, char format)
 Returns FTP server directory list.
int ftpclient_pwd (char *path_str, int path_str_len)
 Returns current FTP server directory path.
int ftpclient_cd (char *path_str)
 Changes server working directory.
int ftpclient_rawcmd (char *input_cmd)
 Sends command to FTP server.
int ftpclient_dataconnection ()
 Configures for new data connection. exchange port number and ip address information with FTP server for data connection.
int ftpclient_get_dataconnection_handler ()
 Establishes new data connection and returns socket handler.
int ftpclient_disconnect (void)
 Terminates connection with FTP server.
char * ftpclient_getlaststatus (void)
 Returns last FTP server response string.


Define Documentation

#define FTPCLIENT_ACTIVE_MODE   1
 

Definition for active data connection mode

See also:
ftpclient_setdataconnectionmode

#define FTPCLIENT_ALREADY_LOGGEDIN   -4
 

Error value indicates that client application is already logged-in

#define FTPCLIENT_ASCII   0
 

Definition for ASCII data transfer mode

See also:
ftpclient_settransmissionmode

#define FTPCLIENT_BINARY   1
 

Definition for BINARY data transfer mode

See also:
ftpclient_settransmissionmode

#define FTPCLIENT_DETAILED_DIRLISTING   1
 

Definition for detailed directory listing

See also:
ftpclient_dir

#define FTPCLIENT_FILE_IO_ERROR   -3
 

File operation error value

#define FTPCLIENT_FILE_NOT_FOUND   -2
 

File not found error value

#define FTPCLIENT_NOT_CONNECTED   -5
 

Error value indicates that server is not connected

#define FTPCLIENT_PASSIVE_MODE   0
 

Definition for passive data connection mode

See also:
ftpclient_setdataconnectionmode

#define FTPCLIENT_PORTNUMBER   21
 

Definition for default FTP server port number

See also:
ftpclient_connect

#define FTPCLIENT_SHORT_DIRLISTING   0
 

Definition for short directory listing

See also:
ftpclient_dir

#define FTPCLIENT_SOCKET_ERROR   -1
 

Socket error value

#define FTPCLIENT_STATUS_SUCCESS   0
 

FTP Client Status Success value, this value is returned when operation is completed successfully.

#define FTPCLIENT_VERSION_NUMBER   1
 

Version number associated with this header file. Should be the same as the version number returned by the ftpclient_version function.

See also:
ftpclient_version


Function Documentation

int ftpclient_cd char *  path_str  ) 
 

Changes server working directory.

This function changes server working directory

Parameters:
path_str Address of memory buffer that contains new working directory path name
Returns:
Otherwise, returns FTP server status code

int ftpclient_connect struct sockaddr_in sa,
char *  user,
char *  passwd
 

Connects with FTP server.

This function establishes connection with FTP server. Connection with FTP server must be established before calling any other functions that interact with FTP server.

Parameters:
sa socket address contains server ip address and FTP server portnumber NOTE: Passing zero value for portnumber enables ftpclient library to use default ftp port number
user User name
passwd Password
Returns:
One of the following values: Otherwise, FTP server status code will be returned for successful or failed authentication
NOTE: In case of error, the server socket will be closed before returning from function

int ftpclient_dataconnection  ) 
 

Configures for new data connection. exchange port number and ip address information with FTP server for data connection.

This function configures for new data connection. For Active mode connection, sends IP address and port number of ftp client to which the data connection have to be established. For passive mode connection, it gets server IP address and port number for data connection

Returns:
FTPCLIENT_SOCKET_ERROR if socket communication error happens. Otherwise, returns FTP server status code

int ftpclient_dir char *  name,
char *  dir_str,
int  dir_str_len,
char  format
 

Returns FTP server directory list.

This function returns FTP server directory list in short format or detailed format. This function can also be used to retrieve information about specific file.

Parameters:
name Name of the file to get file attributes information. If NULL, then information about all entries of current directory will be returned.
dir_str Address of memory buffer where directory information will be stored
dir_str_len Maximum amount of data to be stored in dir_str memory buffer
format Specifies the format of directory listing. The value for this parameter should be either FTPCLIENT_DETAILED_DIRLISTING or FTPCLIENT_SHORT_DIRLISTING
Returns:
Otherwise, returns FTP server status code

int ftpclient_disconnect void   ) 
 

Terminates connection with FTP server.

This function terminates connection with FTP server. the server socket will be closed even if there is any socket error

Returns:
Otherwise, returns FTP server status code

int ftpclient_get_dataconnection_handler  ) 
 

Establishes new data connection and returns socket handler.

This function establishes new data connection and returns socket handler.

IMPORTANT NOTE: For Active mode connection, This function has to be called after sending control command to server to initiate the data transfer as server will establish data connection after receiving control command. For passive mode connection, this function has to be called before sending control command to server to initiate the data transfer as server expects data connection to be made before responding for control connection.

Returns:
FTPCLIENT_SOCKET_ERROR if socket communication error happens. Otherwise, returns FTP server status code

int ftpclient_getfile char *  filename,
char *  storeas_filename
 

Downloads file from FTP server.

This function downloads file from FTP server and store it in tini file system.

Parameters:
filename Name of file to get from the FTP server
storeas_filename Name of file to store on TINI. If value for this parameter is NULL, then the file will be stored under same name as it is on the FTP server.
Returns:
Otherwise, returns FTP server status code

char* ftpclient_getlaststatus void   ) 
 

Returns last FTP server response string.

This function returns the FTP server's response status string for the last control command sent to the server.

Returns:
Pointer to response status string

void ftpclient_init long  milli_seconds  ) 
 

Initializes the ftpclient library.

This function initializes ftpclient library internal datastructure and configures the library with following default configuration

  • ASCII file transfer mode
  • Active data connection mode

Parameters:
milli_seconds socket timeout value

int ftpclient_putfile char *  filename,
char *  storeas_filename
 

Uploads tini file to FTP server.

This function uploads tini file to FTP server.

Parameters:
filename Name of file on the TINI to send to the server
storeas_filename Name to give the file put on the FTP server. If NULL, then the name for the file on TINI will be used.
Returns:
Otherwise, returns FTP server status code

int ftpclient_pwd char *  path_str,
int  path_str_len
 

Returns current FTP server directory path.

This function returns the current FTP server directory path name

Parameters:
path_str Address of memory buffer where the current FTP server path name will be stored
path_str_len Maximum amount of data can be stored in path_str memory buffer
Returns:
Otherwise, returns FTP server status code

int ftpclient_rawcmd char *  input_cmd  ) 
 

Sends command to FTP server.

This function sends command to FTP server through control connection and returns FTP server status code. This function does NOT check whether server is connected.

NOTE: To retrieve the response string of server for control command, call the ftpclient_getlaststatus function

Parameters:
input_cmd command to send to the FTP server
Returns:
FTPCLIENT_SOCKET_ERROR if socket communication error happens. Otherwise, returns FTP server status code

void ftpclient_setdataconnectionmode char  flag  ) 
 

Set data connection mode in ftpclient library.

This function sets data connection mode in ftpclient library. All future data connections will be made in the mode set by this function

Parameters:
flag should be either FTPCLIENT_ACTIVE_MODE or FTPCLIENT_PASSIVE_MODE
Warning:
Invalid value for "flag" yields unexpected behavior of ftpclient data transfer functions

int ftpclient_settransmissionmode char  flag  ) 
 

Sets data transfer mode in FTP server.

This function sets data transfer mode in FTP server and ftpclient library

Parameters:
flag should be either FTPCLIENT_ASCII or FTPCLIENT_BINARY
NOTE: Invalid input for flag will be interpreted as FTPCLIENT_BINARY.

Returns:
returns FTP server status code

unsigned int ftpclient_version void   ) 
 

Returns version number of ftpclient library.

Returns:
Version number of ftpclient library


Copyright 2005 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.