Ftp.h

Go to the documentation of this file.
00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_FTP_H
00026 #define SFML_FTP_H
00027 
00029 // Headers
00031 #include <SFML/Config.h>
00032 #include <SFML/Network/IPAddress.h>
00033 
00034 
00038 enum sfFtpTransferMode
00039 {
00040     sfFtpBinary, 
00041     sfFtpAscii,  
00042     sfFtpEbcdic  
00043 };
00044 
00045 
00050 enum sfFtpStatus
00051 {
00052     // 1xx: the requested action is being initiated,
00053     // expect another reply before proceeding with a new command
00054     sfFtpRestartMarkerReply          = 110, 
00055     sfFtpServiceReadySoon            = 120, 
00056     sfFtpDataConnectionAlreadyOpened = 125, 
00057     sfFtpOpeningDataConnection       = 150, 
00058 
00059     // 2xx: the requested action has been successfully completed
00060     sfFtpOk                    = 200, 
00061     sfFtpPointlessCommand      = 202, 
00062     sfFtpSystemStatus          = 211, 
00063     sfFtpDirectoryStatus       = 212, 
00064     sfFtpFileStatus            = 213, 
00065     sfFtpHelpMessage           = 214, 
00066     sfFtpSystemType            = 215, 
00067     sfFtpServiceReady          = 220, 
00068     sfFtpClosingConnection     = 221, 
00069     sfFtpDataConnectionOpened  = 225, 
00070     sfFtpClosingDataConnection = 226, 
00071     sfFtpEnteringPassiveMode   = 227, 
00072     sfFtpLoggedIn              = 230, 
00073     sfFtpFileActionOk          = 250, 
00074     sfFtpDirectoryOk           = 257, 
00075 
00076     // 3xx: the command has been accepted, but the requested action
00077     // is dormant, pending receipt of further information
00078     sfFtpNeedPassword       = 331, 
00079     sfFtpNeedAccountToLogIn = 332, 
00080     sfFtpNeedInformation    = 350, 
00081 
00082     // 4xx: the command was not accepted and the requested action did not take place,
00083     // but the error condition is temporary and the action may be requested again
00084     sfFtpServiceUnavailable        = 421, 
00085     sfFtpDataConnectionUnavailable = 425, 
00086     sfFtpTransferAborted           = 426, 
00087     sfFtpFileActionAborted         = 450, 
00088     sfFtpLocalError                = 451, 
00089     sfFtpInsufficientStorageSpace  = 452, 
00090 
00091     // 5xx: the command was not accepted and
00092     // the requested action did not take place
00093     sfFtpCommandUnknown          = 500, 
00094     sfFtpParametersUnknown       = 501, 
00095     sfFtpCommandNotImplemented   = 502, 
00096     sfFtpBadCommandSequence      = 503, 
00097     sfFtpParameterNotImplemented = 504, 
00098     sfFtpNotLoggedIn             = 530, 
00099     sfFtpNeedAccountToStore      = 532, 
00100     sfFtpFileUnavailable         = 550, 
00101     sfFtpPageTypeUnknown         = 551, 
00102     sfFtpNotEnoughMemory         = 552, 
00103     sfFtpFilenameNotAllowed      = 553, 
00104 
00105     // 10xx: SFML custom codes
00106     sfFtpInvalidResponse  = 1000, 
00107     sfFtpConnectionFailed = 1001, 
00108     sfFtpConnectionClosed = 1002, 
00109     sfFtpInvalidFile      = 1003  
00110 };
00111 
00112 
00120 typedef struct sfFtpListingResponse sfFtpListingResponse;
00121 
00122 
00129 CSFML_API void sfFtpListingResponse_Destroy(sfFtpListingResponse* FtpListingResponse);
00130 
00140 CSFML_API sfBool sfFtpListingResponse_IsOk(sfFtpListingResponse* FtpListingResponse);
00141 
00150 CSFML_API sfFtpStatus sfFtpListingResponse_GetStatus(sfFtpListingResponse* FtpListingResponse);
00151 
00160 CSFML_API const char* sfFtpListingResponse_GetMessage(sfFtpListingResponse* FtpListingResponse);
00161 
00170 CSFML_API size_t sfFtpListingResponse_GetCount(sfFtpListingResponse* FtpListingResponse);
00171 
00181 CSFML_API const char* sfFtpListingResponse_GetFilename(sfFtpListingResponse* FtpListingResponse, size_t Index);
00182 
00183 
00190 typedef struct sfFtpDirectoryResponse sfFtpDirectoryResponse;
00191 
00192 
00199 CSFML_API void sfFtpDirectoryResponse_Destroy(sfFtpDirectoryResponse* FtpDirectoryResponse);
00200 
00210 CSFML_API sfBool sfFtpDirectoryResponse_IsOk(sfFtpDirectoryResponse* FtpDirectoryResponse);
00211 
00220 CSFML_API sfFtpStatus sfFtpDirectoryResponse_GetStatus(sfFtpDirectoryResponse* FtpDirectoryResponse);
00221 
00230 CSFML_API const char* sfFtpDirectoryResponse_GetMessage(sfFtpDirectoryResponse* FtpDirectoryResponse);
00231 
00240 CSFML_API const char* sfFtpDirectoryResponse_GetDirectory(sfFtpDirectoryResponse* FtpDirectoryResponse);
00241 
00242 
00248 typedef struct sfFtpResponse sfFtpResponse;
00249 
00250 
00257 CSFML_API void sfFtpResponse_Destroy(sfFtpResponse* FtpResponse);
00258 
00268 CSFML_API sfBool sfFtpResponse_IsOk(sfFtpResponse* FtpResponse);
00269 
00278 CSFML_API sfFtpStatus sfFtpResponse_GetStatus(sfFtpResponse* FtpResponse);
00279 
00288 CSFML_API const char* sfFtpResponse_GetMessage(sfFtpResponse* FtpResponse);
00289 
00290 
00297 typedef struct sfFtp sfFtp;
00298 
00299 
00306 CSFML_API sfFtp* sfFtp_Create();
00307 
00314 CSFML_API void sfFtp_Destroy(sfFtp* Ftp);
00315 
00327 CSFML_API sfFtpResponse* sfFtp_Connect(sfFtp* Ftp, sfIPAddress Server, unsigned short Port, float Timeout);
00328 
00337 CSFML_API sfFtpResponse* sfFtp_LoginAnonymous(sfFtp* Ftp);
00338 
00349 CSFML_API sfFtpResponse* sfFtp_Login(sfFtp* Ftp, const char* UserName, const char* Password);
00350 
00359 CSFML_API sfFtpResponse* sfFtp_Disconnect(sfFtp* Ftp);
00360 
00369 CSFML_API sfFtpResponse* sfFtp_KeepAlive(sfFtp* Ftp);
00370 
00379 CSFML_API sfFtpDirectoryResponse* sfFtp_GetWorkingDirectory(sfFtp* Ftp);
00380 
00391 CSFML_API sfFtpListingResponse* sfFtp_GetDirectoryListing(sfFtp* Ftp, const char* Directory);
00392 
00402 CSFML_API sfFtpResponse* sfFtp_ChangeDirectory(sfFtp* Ftp, const char* Directory);
00403 
00412 CSFML_API sfFtpResponse* sfFtp_ParentDirectory(sfFtp* Ftp);
00413 
00423 CSFML_API sfFtpResponse* sfFtp_MakeDirectory(sfFtp* Ftp, const char* Name);
00424 
00434 CSFML_API sfFtpResponse* sfFtp_DeleteDirectory(sfFtp* Ftp, const char* Name);
00435 
00446 CSFML_API sfFtpResponse* sfFtp_RenameFile(sfFtp* Ftp, const char* File, const char* NewName);
00447 
00457 CSFML_API sfFtpResponse* sfFtp_DeleteFile(sfFtp* Ftp, const char* Name);
00458 
00470 CSFML_API sfFtpResponse* sfFtp_Download(sfFtp* Ftp, const char* DistantFile, const char* DestPath, sfFtpTransferMode Mode);
00471 
00483 CSFML_API sfFtpResponse* sfFtp_Upload(sfFtp* Ftp, const char* LocalFile, const char* DestPath, sfFtpTransferMode Mode);
00484 
00485 
00486 #endif // SFML_FTP_H