Ftp.h File Reference

#include <SFML/Config.h>
#include <SFML/Network/IPAddress.h>
#include <SFML/Network/Types.h>

Go to the source code of this file.


Enumerations

enum  sfFtpTransferMode {
  sfFtpBinary,
  sfFtpAscii,
  sfFtpEbcdic
}
 Enumerate all the FTP file transfer modes. More...
enum  sfFtpStatus {
  sfFtpRestartMarkerReply = 110,
  sfFtpServiceReadySoon = 120,
  sfFtpDataConnectionAlreadyOpened = 125,
  sfFtpOpeningDataConnection = 150,
  sfFtpOk = 200,
  sfFtpPointlessCommand = 202,
  sfFtpSystemStatus = 211,
  sfFtpDirectoryStatus = 212,
  sfFtpFileStatus = 213,
  sfFtpHelpMessage = 214,
  sfFtpSystemType = 215,
  sfFtpServiceReady = 220,
  sfFtpClosingConnection = 221,
  sfFtpDataConnectionOpened = 225,
  sfFtpClosingDataConnection = 226,
  sfFtpEnteringPassiveMode = 227,
  sfFtpLoggedIn = 230,
  sfFtpFileActionOk = 250,
  sfFtpDirectoryOk = 257,
  sfFtpNeedPassword = 331,
  sfFtpNeedAccountToLogIn = 332,
  sfFtpNeedInformation = 350,
  sfFtpServiceUnavailable = 421,
  sfFtpDataConnectionUnavailable = 425,
  sfFtpTransferAborted = 426,
  sfFtpFileActionAborted = 450,
  sfFtpLocalError = 451,
  sfFtpInsufficientStorageSpace = 452,
  sfFtpCommandUnknown = 500,
  sfFtpParametersUnknown = 501,
  sfFtpCommandNotImplemented = 502,
  sfFtpBadCommandSequence = 503,
  sfFtpParameterNotImplemented = 504,
  sfFtpNotLoggedIn = 530,
  sfFtpNeedAccountToStore = 532,
  sfFtpFileUnavailable = 550,
  sfFtpPageTypeUnknown = 551,
  sfFtpNotEnoughMemory = 552,
  sfFtpFilenameNotAllowed = 553,
  sfFtpInvalidResponse = 1000,
  sfFtpConnectionFailed = 1001,
  sfFtpConnectionClosed = 1002,
  sfFtpInvalidFile = 1003
}
 Enumerate all the valid status codes returned in a FTP response. More...

Functions

CSFML_API void sfFtpListingResponse_Destroy (sfFtpListingResponse *FtpListingResponse)
 Destroy an existing Ftp listing response.
CSFML_API sfBool sfFtpListingResponse_IsOk (sfFtpListingResponse *FtpListingResponse)
 Convenience function to check if the response status code means a success.
CSFML_API sfFtpStatus sfFtpListingResponse_GetStatus (sfFtpListingResponse *FtpListingResponse)
 Get the response status code.
CSFML_API const char * sfFtpListingResponse_GetMessage (sfFtpListingResponse *FtpListingResponse)
 Get the full message contained in the response.
CSFML_API size_t sfFtpListingResponse_GetCount (sfFtpListingResponse *FtpListingResponse)
 Get the number of filenames in the listing.
CSFML_API const char * sfFtpListingResponse_GetFilename (sfFtpListingResponse *FtpListingResponse, size_t Index)
 Get the Index-th filename in the directory.
CSFML_API void sfFtpDirectoryResponse_Destroy (sfFtpDirectoryResponse *FtpDirectoryResponse)
 Destroy an existing Ftp directory response.
CSFML_API sfBool sfFtpDirectoryResponse_IsOk (sfFtpDirectoryResponse *FtpDirectoryResponse)
 Convenience function to check if the response status code means a success.
CSFML_API sfFtpStatus sfFtpDirectoryResponse_GetStatus (sfFtpDirectoryResponse *FtpDirectoryResponse)
 Get the response status code.
CSFML_API const char * sfFtpDirectoryResponse_GetMessage (sfFtpDirectoryResponse *FtpDirectoryResponse)
 Get the full message contained in the response.
CSFML_API const char * sfFtpDirectoryResponse_GetDirectory (sfFtpDirectoryResponse *FtpDirectoryResponse)
 Get the directory returned in the response.
CSFML_API void sfFtpResponse_Destroy (sfFtpResponse *FtpResponse)
 Destroy an existing Ftp response.
CSFML_API sfBool sfFtpResponse_IsOk (sfFtpResponse *FtpResponse)
 Convenience function to check if the response status code means a success.
CSFML_API sfFtpStatus sfFtpResponse_GetStatus (sfFtpResponse *FtpResponse)
 Get the response status code.
CSFML_API const char * sfFtpResponse_GetMessage (sfFtpResponse *FtpResponse)
 Get the full message contained in the response.
CSFML_API sfFtpsfFtp_Create ()
 Construct a new Ftp.
CSFML_API void sfFtp_Destroy (sfFtp *Ftp)
 Destroy an existing Ftp.
CSFML_API sfFtpResponsesfFtp_Connect (sfFtp *Ftp, sfIPAddress Server, unsigned short Port, float Timeout)
 Connect to the specified FTP server.
CSFML_API sfFtpResponsesfFtp_LoginAnonymous (sfFtp *Ftp)
 Log in using anonymous account.
CSFML_API sfFtpResponsesfFtp_Login (sfFtp *Ftp, const char *UserName, const char *Password)
 Log in using a username and a password.
CSFML_API sfFtpResponsesfFtp_Disconnect (sfFtp *Ftp)
 Close the connection with FTP server.
CSFML_API sfFtpResponsesfFtp_KeepAlive (sfFtp *Ftp)
 Send a null command just to prevent from being disconnected.
CSFML_API sfFtpDirectoryResponsesfFtp_GetWorkingDirectory (sfFtp *Ftp)
 Get the current working directory.
CSFML_API sfFtpListingResponsesfFtp_GetDirectoryListing (sfFtp *Ftp, const char *Directory)
 Get the contents of the given directory (subdirectories and files).
CSFML_API sfFtpResponsesfFtp_ChangeDirectory (sfFtp *Ftp, const char *Directory)
 Change the current working directory.
CSFML_API sfFtpResponsesfFtp_ParentDirectory (sfFtp *Ftp)
 Go to the parent directory of the current one.
CSFML_API sfFtpResponsesfFtp_MakeDirectory (sfFtp *Ftp, const char *Name)
 Create a new directory.
CSFML_API sfFtpResponsesfFtp_DeleteDirectory (sfFtp *Ftp, const char *Name)
 Remove an existing directory.
CSFML_API sfFtpResponsesfFtp_RenameFile (sfFtp *Ftp, const char *File, const char *NewName)
 Rename a file.
CSFML_API sfFtpResponsesfFtp_DeleteFile (sfFtp *Ftp, const char *Name)
 Remove an existing file.
CSFML_API sfFtpResponsesfFtp_Download (sfFtp *Ftp, const char *DistantFile, const char *DestPath, sfFtpTransferMode Mode)
 Download a file from the server.
CSFML_API sfFtpResponsesfFtp_Upload (sfFtp *Ftp, const char *LocalFile, const char *DestPath, sfFtpTransferMode Mode)
 Upload a file to the server.

Enumeration Type Documentation

Enumerate all the valid status codes returned in a FTP response.

Enumerator:
sfFtpRestartMarkerReply  Restart marker reply.
sfFtpServiceReadySoon  Service ready in N minutes.
sfFtpDataConnectionAlreadyOpened  Data connection already opened, transfer starting.
sfFtpOpeningDataConnection  File status ok, about to open data connection.
sfFtpOk  Command ok.
sfFtpPointlessCommand  Command not implemented.
sfFtpSystemStatus  System status, or system help reply.
sfFtpDirectoryStatus  Directory status.
sfFtpFileStatus  File status.
sfFtpHelpMessage  Help message.
sfFtpSystemType  NAME system type, where NAME is an official system name from the list in the Assigned Numbers document.
sfFtpServiceReady  Service ready for new user.
sfFtpClosingConnection  Service closing control connection.
sfFtpDataConnectionOpened  Data connection open, no transfer in progress.
sfFtpClosingDataConnection  Closing data connection, requested file action successful.
sfFtpEnteringPassiveMode  Entering passive mode.
sfFtpLoggedIn  User logged in, proceed. Logged out if appropriate.
sfFtpFileActionOk  Requested file action ok.
sfFtpDirectoryOk  PATHNAME created.
sfFtpNeedPassword  User name ok, need password.
sfFtpNeedAccountToLogIn  Need account for login.
sfFtpNeedInformation  Requested file action pending further information.
sfFtpServiceUnavailable  Service not available, closing control connection.
sfFtpDataConnectionUnavailable  Can't open data connection.
sfFtpTransferAborted  Connection closed, transfer aborted.
sfFtpFileActionAborted  Requested file action not taken.
sfFtpLocalError  Requested action aborted, local error in processing.
sfFtpInsufficientStorageSpace  Requested action not taken; insufficient storage space in system, file unavailable.
sfFtpCommandUnknown  Syntax error, command unrecognized.
sfFtpParametersUnknown  Syntax error in parameters or arguments.
sfFtpCommandNotImplemented  Command not implemented.
sfFtpBadCommandSequence  Bad sequence of commands.
sfFtpParameterNotImplemented  Command not implemented for that parameter.
sfFtpNotLoggedIn  Not logged in.
sfFtpNeedAccountToStore  Need account for storing files.
sfFtpFileUnavailable  Requested action not taken, file unavailable.
sfFtpPageTypeUnknown  Requested action aborted, page type unknown.
sfFtpNotEnoughMemory  Requested file action aborted, exceeded storage allocation.
sfFtpFilenameNotAllowed  Requested action not taken, file name not allowed.
sfFtpInvalidResponse  Response is not a valid FTP one.
sfFtpConnectionFailed  Connection with server failed.
sfFtpConnectionClosed  Connection with server closed.
sfFtpInvalidFile  Invalid file to upload / download.

Definition at line 51 of file Ftp.h.

Enumerate all the FTP file transfer modes.

Enumerator:
sfFtpBinary  Binary mode (file is transfered as a sequence of bytes).
sfFtpAscii  Text mode using ASCII encoding.
sfFtpEbcdic  Text mode using EBCDIC encoding.

Definition at line 39 of file Ftp.h.


Function Documentation

CSFML_API sfFtpResponse* sfFtp_ChangeDirectory ( sfFtp Ftp,
const char *  Directory 
)

Change the current working directory.

Parameters:
Ftp : Ftp instance
Directory : New directory, relative to the current one
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_Connect ( sfFtp Ftp,
sfIPAddress  Server,
unsigned short  Port,
float  Timeout 
)

Connect to the specified FTP server.

Parameters:
Ftp : Ftp instance
Server : FTP server to connect to
Port : Port used for connection (21 by default, standard FTP port)
Timeout : Maximum time to wait (0 to use no timeout)
Returns:
Server response to the request

CSFML_API sfFtp* sfFtp_Create (  ) 

Construct a new Ftp.

Returns:
Pointer to the new Ftp

CSFML_API sfFtpResponse* sfFtp_DeleteDirectory ( sfFtp Ftp,
const char *  Name 
)

Remove an existing directory.

Parameters:
Ftp : Ftp instance
Name : Name of the directory to remove
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_DeleteFile ( sfFtp Ftp,
const char *  Name 
)

Remove an existing file.

Parameters:
Ftp : Ftp instance
Name : File to remove
Returns:
Server response to the request

CSFML_API void sfFtp_Destroy ( sfFtp Ftp  ) 

Destroy an existing Ftp.

Parameters:
Ftp : Ftp to destroy

CSFML_API sfFtpResponse* sfFtp_Disconnect ( sfFtp Ftp  ) 

Close the connection with FTP server.

Parameters:
Ftp : Ftp instance
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_Download ( sfFtp Ftp,
const char *  DistantFile,
const char *  DestPath,
sfFtpTransferMode  Mode 
)

Download a file from the server.

Parameters:
Ftp : Ftp instance
DistantFile : Path of the distant file to download
DestPath : Where to put to file on the local computer
Mode : Transfer mode (binary by default)
Returns:
Server response to the request

CSFML_API sfFtpListingResponse* sfFtp_GetDirectoryListing ( sfFtp Ftp,
const char *  Directory 
)

Get the contents of the given directory (subdirectories and files).

Parameters:
Ftp : Ftp instance
Directory : Directory to list ("" by default, the current one)
Returns:
Server response to the request

CSFML_API sfFtpDirectoryResponse* sfFtp_GetWorkingDirectory ( sfFtp Ftp  ) 

Get the current working directory.

Parameters:
Ftp : Ftp instance
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_KeepAlive ( sfFtp Ftp  ) 

Send a null command just to prevent from being disconnected.

Parameters:
Ftp : Ftp instance
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_Login ( sfFtp Ftp,
const char *  UserName,
const char *  Password 
)

Log in using a username and a password.

Parameters:
Ftp : Ftp instance
UserName : User name
Password : Password
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_LoginAnonymous ( sfFtp Ftp  ) 

Log in using anonymous account.

Parameters:
Ftp : Ftp instance
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_MakeDirectory ( sfFtp Ftp,
const char *  Name 
)

Create a new directory.

Parameters:
Ftp : Ftp instance
Name : Name of the directory to create
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_ParentDirectory ( sfFtp Ftp  ) 

Go to the parent directory of the current one.

Parameters:
Ftp : Ftp instance
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_RenameFile ( sfFtp Ftp,
const char *  File,
const char *  NewName 
)

Rename a file.

Parameters:
Ftp : Ftp instance
File : File to rename
NewName : New name
Returns:
Server response to the request

CSFML_API sfFtpResponse* sfFtp_Upload ( sfFtp Ftp,
const char *  LocalFile,
const char *  DestPath,
sfFtpTransferMode  Mode 
)

Upload a file to the server.

Parameters:
Ftp : Ftp instance
LocalFile : Path of the local file to upload
DestPath : Where to put to file on the server
Mode : Transfer mode (binary by default)
Returns:
Server response to the request

CSFML_API void sfFtpDirectoryResponse_Destroy ( sfFtpDirectoryResponse FtpDirectoryResponse  ) 

Destroy an existing Ftp directory response.

Parameters:
FtpDirectoryResponse : Ftp directory response to destroy

CSFML_API const char* sfFtpDirectoryResponse_GetDirectory ( sfFtpDirectoryResponse FtpDirectoryResponse  ) 

Get the directory returned in the response.

Parameters:
FtpDirectoryResponse : Ftp directory response
Returns:
Directory name

CSFML_API const char* sfFtpDirectoryResponse_GetMessage ( sfFtpDirectoryResponse FtpDirectoryResponse  ) 

Get the full message contained in the response.

Parameters:
FtpDirectoryResponse : Ftp directory response
Returns:
The response message

CSFML_API sfFtpStatus sfFtpDirectoryResponse_GetStatus ( sfFtpDirectoryResponse FtpDirectoryResponse  ) 

Get the response status code.

Parameters:
FtpDirectoryResponse : Ftp directory response
Returns:
Status code

CSFML_API sfBool sfFtpDirectoryResponse_IsOk ( sfFtpDirectoryResponse FtpDirectoryResponse  ) 

Convenience function to check if the response status code means a success.

Parameters:
FtpDirectoryResponse : Ftp directory response
Returns:
sfTrue if status is success (code < 400)

CSFML_API void sfFtpListingResponse_Destroy ( sfFtpListingResponse FtpListingResponse  ) 

Destroy an existing Ftp listing response.

Parameters:
FtpResponse : Ftp listing response to destroy

CSFML_API size_t sfFtpListingResponse_GetCount ( sfFtpListingResponse FtpListingResponse  ) 

Get the number of filenames in the listing.

Parameters:
FtpListingResponse : Ftp listing response
Returns:
Total number of filenames

CSFML_API const char* sfFtpListingResponse_GetFilename ( sfFtpListingResponse FtpListingResponse,
size_t  Index 
)

Get the Index-th filename in the directory.

Parameters:
FtpListingResponse : Ftp listing response
Index : Index of the filename to get
Returns:
Index-th filename

CSFML_API const char* sfFtpListingResponse_GetMessage ( sfFtpListingResponse FtpListingResponse  ) 

Get the full message contained in the response.

Parameters:
FtpListingResponse : Ftp listing response
Returns:
The response message

CSFML_API sfFtpStatus sfFtpListingResponse_GetStatus ( sfFtpListingResponse FtpListingResponse  ) 

Get the response status code.

Parameters:
FtpListingResponse : Ftp listing response
Returns:
Status code

CSFML_API sfBool sfFtpListingResponse_IsOk ( sfFtpListingResponse FtpListingResponse  ) 

Convenience function to check if the response status code means a success.

Parameters:
FtpListingResponse : Ftp listing response
Returns:
sfTrue if status is success (code < 400)

CSFML_API void sfFtpResponse_Destroy ( sfFtpResponse FtpResponse  ) 

Destroy an existing Ftp response.

Parameters:
FtpResponse : Ftp response to destroy

CSFML_API const char* sfFtpResponse_GetMessage ( sfFtpResponse FtpResponse  ) 

Get the full message contained in the response.

Parameters:
FtpResponse : Ftp response
Returns:
The response message

CSFML_API sfFtpStatus sfFtpResponse_GetStatus ( sfFtpResponse FtpResponse  ) 

Get the response status code.

Parameters:
FtpResponse : Ftp response
Returns:
Status code

CSFML_API sfBool sfFtpResponse_IsOk ( sfFtpResponse FtpResponse  ) 

Convenience function to check if the response status code means a success.

Parameters:
FtpResponse : Ftp response
Returns:
sfTrue if status is success (code < 400)