CSFML

- Main Page
- Data Structures
- Files

- File List
- Globals

Ftp.h
Go to the documentation of this file.
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_FTP_H
26 #define SFML_FTP_H
27
29 // Headers
31 #include <SFML/Network/Export.h>
32 #include <SFML/Network/IpAddress.h>
33 #include <SFML/Network/Types.h>
34 #include <stddef.h>
35
36
41 typedef enum
42 {
43 sfFtpBinary,
44 sfFtpAscii,
45 sfFtpEbcdic
46 } sfFtpTransferMode;
47
48
53 typedef enum
54 {
55 // 1xx: the requested action is being initiated,
56 // expect another reply before proceeding with a new command
57 sfFtpRestartMarkerReply = 110,
58 sfFtpServiceReadySoon = 120,
59 sfFtpDataConnectionAlreadyOpened = 125,
60 sfFtpOpeningDataConnection = 150,
61
62 // 2xx: the requested action has been successfully completed
63 sfFtpOk = 200,
64 sfFtpPointlessCommand = 202,
65 sfFtpSystemStatus = 211,
66 sfFtpDirectoryStatus = 212,
67 sfFtpFileStatus = 213,
68 sfFtpHelpMessage = 214,
69 sfFtpSystemType = 215,
70 sfFtpServiceReady = 220,
71 sfFtpClosingConnection = 221,
72 sfFtpDataConnectionOpened = 225,
73 sfFtpClosingDataConnection = 226,
74 sfFtpEnteringPassiveMode = 227,
75 sfFtpLoggedIn = 230,
76 sfFtpFileActionOk = 250,
77 sfFtpDirectoryOk = 257,
78
79 // 3xx: the command has been accepted, but the requested action
80 // is dormant, pending receipt of further information
81 sfFtpNeedPassword = 331,
82 sfFtpNeedAccountToLogIn = 332,
83 sfFtpNeedInformation = 350,
84
85 // 4xx: the command was not accepted and the requested action did not take place,
86 // but the error condition is temporary and the action may be requested again
87 sfFtpServiceUnavailable = 421,
88 sfFtpDataConnectionUnavailable = 425,
89 sfFtpTransferAborted = 426,
90 sfFtpFileActionAborted = 450,
91 sfFtpLocalError = 451,
92 sfFtpInsufficientStorageSpace = 452,
93
94 // 5xx: the command was not accepted and
95 // the requested action did not take place
96 sfFtpCommandUnknown = 500,
97 sfFtpParametersUnknown = 501,
98 sfFtpCommandNotImplemented = 502,
99 sfFtpBadCommandSequence = 503,
100 sfFtpParameterNotImplemented = 504,
101 sfFtpNotLoggedIn = 530,
102 sfFtpNeedAccountToStore = 532,
103 sfFtpFileUnavailable = 550,
104 sfFtpPageTypeUnknown = 551,
105 sfFtpNotEnoughMemory = 552,
106 sfFtpFilenameNotAllowed = 553,
107
108 // 10xx: SFML custom codes
109 sfFtpInvalidResponse = 1000,
110 sfFtpConnectionFailed = 1001,
111 sfFtpConnectionClosed = 1002,
112 sfFtpInvalidFile = 1003
113 } sfFtpStatus;
114
115
122 CSFML_NETWORK_API void sfFtpListingResponse_destroy(sfFtpListingResponse* ftpListingResponse);
123
135 CSFML_NETWORK_API sfBool sfFtpListingResponse_isOk(const sfFtpListingResponse* ftpListingResponse);
136
145 CSFML_NETWORK_API sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingResponse* ftpListingResponse);
146
155 CSFML_NETWORK_API const char* sfFtpListingResponse_getMessage(const sfFtpListingResponse* ftpListingResponse);
156
165 CSFML_NETWORK_API size_t sfFtpListingResponse_getCount(const sfFtpListingResponse* ftpListingResponse);
166
176 CSFML_NETWORK_API const char* sfFtpListingResponse_getName(const sfFtpListingResponse* ftpListingResponse, size_t index);
177
184 CSFML_NETWORK_API void sfFtpDirectoryResponse_destroy(sfFtpDirectoryResponse* ftpDirectoryResponse);
185
197 CSFML_NETWORK_API sfBool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryResponse* ftpDirectoryResponse);
198
207 CSFML_NETWORK_API sfFtpStatus sfFtpDirectoryResponse_getStatus(const sfFtpDirectoryResponse* ftpDirectoryResponse);
208
217 CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getMessage(const sfFtpDirectoryResponse* ftpDirectoryResponse);
218
227 CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse);
228
229
236 CSFML_NETWORK_API void sfFtpResponse_destroy(sfFtpResponse* ftpResponse);
237
249 CSFML_NETWORK_API sfBool sfFtpResponse_isOk(const sfFtpResponse* ftpResponse);
250
259 CSFML_NETWORK_API sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse* ftpResponse);
260
269 CSFML_NETWORK_API const char* sfFtpResponse_getMessage(const sfFtpResponse* ftpResponse);
270
277 CSFML_NETWORK_API sfFtp* sfFtp_create(void);
278
285 CSFML_NETWORK_API void sfFtp_destroy(sfFtp* ftp);
286
307 CSFML_NETWORK_API sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfTime timeout);
308
320 CSFML_NETWORK_API sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp);
321
335 CSFML_NETWORK_API sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* userName, const char* password);
336
345 CSFML_NETWORK_API sfFtpResponse* sfFtp_disconnect(sfFtp* ftp);
346
358 CSFML_NETWORK_API sfFtpResponse* sfFtp_keepAlive(sfFtp* ftp);
359
371 CSFML_NETWORK_API sfFtpDirectoryResponse* sfFtp_getWorkingDirectory(sfFtp* ftp);
372
387 CSFML_NETWORK_API sfFtpListingResponse* sfFtp_getDirectoryListing(sfFtp* ftp, const char* directory);
388
400 CSFML_NETWORK_API sfFtpResponse* sfFtp_changeDirectory(sfFtp* ftp, const char* directory);
401
410 CSFML_NETWORK_API sfFtpResponse* sfFtp_parentDirectory(sfFtp* ftp);
411
424 CSFML_NETWORK_API sfFtpResponse* sfFtp_createDirectory(sfFtp* ftp, const char* name);
425
440 CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteDirectory(sfFtp* ftp, const char* name);
441
455 CSFML_NETWORK_API sfFtpResponse* sfFtp_renameFile(sfFtp* ftp, const char* file, const char* newName);
456
471 CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const char* name);
472
489 CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* distantFile, const char* destPath, sfFtpTransferMode mode);
490
507 CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* destPath, sfFtpTransferMode mode);
508
509
510 #endif // SFML_FTP_H
sfFtpOk
Command ok.
Definition: Ftp.h:63
Types.h
sfFtp_renameFile
CSFML_NETWORK_API sfFtpResponse * sfFtp_renameFile(sfFtp *ftp, const char *file, const char *newName)
Rename an existing file.
sfFtp_connect
CSFML_NETWORK_API sfFtpResponse * sfFtp_connect(sfFtp *ftp, sfIpAddress server, unsigned short port, sfTime timeout)
Connect to the specified FTP server.
sfFtp_loginAnonymous
CSFML_NETWORK_API sfFtpResponse * sfFtp_loginAnonymous(sfFtp *ftp)
Log in using an anonymous account.
sfFtpAscii
Text mode using ASCII encoding.
Definition: Ftp.h:44
sfFtpNeedAccountToStore
Need account for storing files.
Definition: Ftp.h:102
sfFtpHelpMessage
Help message.
Definition: Ftp.h:68
CSFML_NETWORK_API
#define CSFML_NETWORK_API
Definition: Network/Export.h:43
sfFtpDirectoryResponse_isOk
CSFML_NETWORK_API sfBool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Check if a FTP directory response status code means a success.
sfFtpLoggedIn
User logged in, proceed. Logged out if appropriate.
Definition: Ftp.h:75
sfFtpDataConnectionAlreadyOpened
Data connection already opened, transfer starting.
Definition: Ftp.h:59
sfFtpListingResponse_getStatus
CSFML_NETWORK_API sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingResponse *ftpListingResponse)
Get the status code of a FTP listing response.
sfFtp
struct sfFtp sfFtp
Definition: Network/Types.h:32
sfFtpDataConnectionOpened
Data connection open, no transfer in progress.
Definition: Ftp.h:72
sfFtp_login
CSFML_NETWORK_API sfFtpResponse * sfFtp_login(sfFtp *ftp, const char *userName, const char *password)
Log in using a username and a password.
sfFtpResponse_isOk
CSFML_NETWORK_API sfBool sfFtpResponse_isOk(const sfFtpResponse *ftpResponse)
Check if a FTP response status code means a success.
sfFtpDirectoryStatus
Directory status.
Definition: Ftp.h:66
sfFtpFileStatus
File status.
Definition: Ftp.h:67
sfFtpSystemType
NAME system type, where NAME is an official system name from the list in the Assigned Numbers documen...
Definition: Ftp.h:69
sfFtpTransferMode
sfFtpTransferMode
Enumeration of transfer modes.
Definition: Ftp.h:41
sfFtp_changeDirectory
CSFML_NETWORK_API sfFtpResponse * sfFtp_changeDirectory(sfFtp *ftp, const char *directory)
Change the current working directory.
sfFtpDirectoryResponse_destroy
CSFML_NETWORK_API void sfFtpDirectoryResponse_destroy(sfFtpDirectoryResponse *ftpDirectoryResponse)
Destroy a FTP directory response.
sfFtpDirectoryResponse_getStatus
CSFML_NETWORK_API sfFtpStatus sfFtpDirectoryResponse_getStatus(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the status code of a FTP directory response.
sfFtpListingResponse_destroy
CSFML_NETWORK_API void sfFtpListingResponse_destroy(sfFtpListingResponse *ftpListingResponse)
Destroy a FTP listing response.
sfFtpConnectionClosed
Connection with server closed.
Definition: Ftp.h:111
sfFtp_createDirectory
CSFML_NETWORK_API sfFtpResponse * sfFtp_createDirectory(sfFtp *ftp, const char *name)
Create a new directory.
sfFtpNeedPassword
User name ok, need password.
Definition: Ftp.h:81
sfFtpResponse
struct sfFtpResponse sfFtpResponse
Definition: Network/Types.h:31
sfFtpListingResponse_getCount
CSFML_NETWORK_API size_t sfFtpListingResponse_getCount(const sfFtpListingResponse *ftpListingResponse)
Return the number of directory/file names contained in a FTP listing response.
sfIpAddress
Encapsulate an IPv4 network address.
Definition: IpAddress.h:39
sfFtpCommandNotImplemented
Command not implemented.
Definition: Ftp.h:98
sfFtpDataConnectionUnavailable
Can&#39;t open data connection.
Definition: Ftp.h:88
sfFtpResponse_getStatus
CSFML_NETWORK_API sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse *ftpResponse)
Get the status code of a FTP response.
sfFtpPageTypeUnknown
Requested action aborted, page type unknown.
Definition: Ftp.h:104
sfFtp_keepAlive
CSFML_NETWORK_API sfFtpResponse * sfFtp_keepAlive(sfFtp *ftp)
Send a null command to keep the connection alive.
sfBool
int sfBool
Definition: Config.h:106
sfFtpRestartMarkerReply
Restart marker reply.
Definition: Ftp.h:57
sfFtpListingResponse_getName
CSFML_NETWORK_API const char * sfFtpListingResponse_getName(const sfFtpListingResponse *ftpListingResponse, size_t index)
Return a directory/file name contained in a FTP listing response.
sfFtpBinary
Binary mode (file is transfered as a sequence of bytes)
Definition: Ftp.h:43
sfFtpEbcdic
Text mode using EBCDIC encoding.
Definition: Ftp.h:45
sfFtpListingResponse_isOk
CSFML_NETWORK_API sfBool sfFtpListingResponse_isOk(const sfFtpListingResponse *ftpListingResponse)
Check if a FTP listing response status code means a success.
sfFtpLocalError
Requested action aborted, local error in processing.
Definition: Ftp.h:91
sfTime
Represents a time value.
Definition: Time.h:38
sfFtpResponse_getMessage
CSFML_NETWORK_API const char * sfFtpResponse_getMessage(const sfFtpResponse *ftpResponse)
Get the full message contained in a FTP response.
sfFtpFilenameNotAllowed
Requested action not taken, file name not allowed.
Definition: Ftp.h:106
sfFtpTransferAborted
Connection closed, transfer aborted.
Definition: Ftp.h:89
sfFtpInvalidFile
Invalid file to upload / download.
Definition: Ftp.h:112
sfFtpListingResponse
struct sfFtpListingResponse sfFtpListingResponse
Definition: Network/Types.h:30
sfFtp_getWorkingDirectory
CSFML_NETWORK_API sfFtpDirectoryResponse * sfFtp_getWorkingDirectory(sfFtp *ftp)
Get the current working directory.
sfFtpNeedAccountToLogIn
Need account for login.
Definition: Ftp.h:82
IpAddress.h
sfFtpClosingConnection
Service closing control connection.
Definition: Ftp.h:71
sfFtp_download
CSFML_NETWORK_API sfFtpResponse * sfFtp_download(sfFtp *ftp, const char *distantFile, const char *destPath, sfFtpTransferMode mode)
Download a file from a FTP server.
sfFtpServiceReadySoon
Service ready in N minutes.
Definition: Ftp.h:58
sfFtpInsufficientStorageSpace
Requested action not taken; insufficient storage space in system, file unavailable.
Definition: Ftp.h:92
sfFtpNotLoggedIn
Not logged in.
Definition: Ftp.h:101
sfFtpServiceReady
Service ready for new user.
Definition: Ftp.h:70
sfFtp_upload
CSFML_NETWORK_API sfFtpResponse * sfFtp_upload(sfFtp *ftp, const char *localFile, const char *destPath, sfFtpTransferMode mode)
Upload a file to a FTP server.
sfFtpNeedInformation
Requested file action pending further information.
Definition: Ftp.h:83
sfFtpDirectoryResponse
struct sfFtpDirectoryResponse sfFtpDirectoryResponse
Definition: Network/Types.h:29
sfFtpSystemStatus
System status, or system help reply.
Definition: Ftp.h:65
sfFtpFileUnavailable
Requested action not taken, file unavailable.
Definition: Ftp.h:103
sfFtpPointlessCommand
Command not implemented.
Definition: Ftp.h:64
sfFtpInvalidResponse
Response is not a valid FTP one.
Definition: Ftp.h:109
sfFtpStatus
sfFtpStatus
Status codes possibly returned by a FTP response.
Definition: Ftp.h:53
sfFtp_getDirectoryListing
CSFML_NETWORK_API sfFtpListingResponse * sfFtp_getDirectoryListing(sfFtp *ftp, const char *directory)
Get the contents of the given directory.
sfFtpDirectoryResponse_getDirectory
CSFML_NETWORK_API const char * sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the directory returned in a FTP directory response.
sfFtpServiceUnavailable
Service not available, closing control connection.
Definition: Ftp.h:87
sfFtpParameterNotImplemented
Command not implemented for that parameter.
Definition: Ftp.h:100
sfFtpCommandUnknown
Syntax error, command unrecognized.
Definition: Ftp.h:96
sfFtpDirectoryOk
PATHNAME created.
Definition: Ftp.h:77
sfFtp_create
CSFML_NETWORK_API sfFtp * sfFtp_create(void)
Create a new Ftp object.
sfFtpBadCommandSequence
Bad sequence of commands.
Definition: Ftp.h:99
sfFtpFileActionOk
Requested file action ok.
Definition: Ftp.h:76
sfFtpResponse_destroy
CSFML_NETWORK_API void sfFtpResponse_destroy(sfFtpResponse *ftpResponse)
Destroy a FTP response.
sfFtpEnteringPassiveMode
Entering passive mode.
Definition: Ftp.h:74
sfFtp_deleteFile
CSFML_NETWORK_API sfFtpResponse * sfFtp_deleteFile(sfFtp *ftp, const char *name)
Remove an existing file.
sfFtp_parentDirectory
CSFML_NETWORK_API sfFtpResponse * sfFtp_parentDirectory(sfFtp *ftp)
Go to the parent directory of the current one.
sfFtpClosingDataConnection
Closing data connection, requested file action successful.
Definition: Ftp.h:73
sfFtpListingResponse_getMessage
CSFML_NETWORK_API const char * sfFtpListingResponse_getMessage(const sfFtpListingResponse *ftpListingResponse)
Get the full message contained in a FTP listing response.
sfFtp_destroy
CSFML_NETWORK_API void sfFtp_destroy(sfFtp *ftp)
Destroy a Ftp object.
Export.h
sfFtp_deleteDirectory
CSFML_NETWORK_API sfFtpResponse * sfFtp_deleteDirectory(sfFtp *ftp, const char *name)
Remove an existing directory.
sfFtpNotEnoughMemory
Requested file action aborted, exceeded storage allocation.
Definition: Ftp.h:105
sfFtpDirectoryResponse_getMessage
CSFML_NETWORK_API const char * sfFtpDirectoryResponse_getMessage(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the full message contained in a FTP directory response.
sfFtpConnectionFailed
Connection with server failed.
Definition: Ftp.h:110
sfFtpFileActionAborted
Requested file action not taken.
Definition: Ftp.h:90
sfFtp_disconnect
CSFML_NETWORK_API sfFtpResponse * sfFtp_disconnect(sfFtp *ftp)
Close the connection with the server.
sfFtpOpeningDataConnection
File status ok, about to open data connection.
Definition: Ftp.h:60
sfFtpParametersUnknown
Syntax error in parameters or arguments.
Definition: Ftp.h:97