CSFML 3.0.0
Loading...
Searching...
No Matches
Ftp.h
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
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#pragma once
26
28// Headers
30#include <CSFML/Network/Export.h>
31
32#include <CSFML/Network/IpAddress.h>
33#include <CSFML/Network/Types.h>
34
35#include <stddef.h>
36
37
42 typedef enum
43{
44 sfFtpBinary,
45 sfFtpAscii,
46 sfFtpEbcdic
47} sfFtpTransferMode;
48
49
54 typedef enum
55{
56 // 1xx: the requested action is being initiated,
57 // expect another reply before proceeding with a new command
58 sfFtpRestartMarkerReply = 110,
59 sfFtpServiceReadySoon = 120,
60 sfFtpDataConnectionAlreadyOpened = 125,
61 sfFtpOpeningDataConnection = 150,
62
63 // 2xx: the requested action has been successfully completed
64 sfFtpOk = 200,
65 sfFtpPointlessCommand = 202,
66 sfFtpSystemStatus = 211,
67 sfFtpDirectoryStatus = 212,
68 sfFtpFileStatus = 213,
69 sfFtpHelpMessage = 214,
70 sfFtpSystemType = 215,
71 sfFtpServiceReady = 220,
72 sfFtpClosingConnection = 221,
73 sfFtpDataConnectionOpened = 225,
74 sfFtpClosingDataConnection = 226,
75 sfFtpEnteringPassiveMode = 227,
76 sfFtpLoggedIn = 230,
77 sfFtpFileActionOk = 250,
78 sfFtpDirectoryOk = 257,
79
80 // 3xx: the command has been accepted, but the requested action
81 // is dormant, pending receipt of further information
82 sfFtpNeedPassword = 331,
83 sfFtpNeedAccountToLogIn = 332,
84 sfFtpNeedInformation = 350,
85
86 // 4xx: the command was not accepted and the requested action did not take place,
87 // but the error condition is temporary and the action may be requested again
88 sfFtpServiceUnavailable = 421,
89 sfFtpDataConnectionUnavailable = 425,
90 sfFtpTransferAborted = 426,
91 sfFtpFileActionAborted = 450,
92 sfFtpLocalError = 451,
93 sfFtpInsufficientStorageSpace = 452,
94
95 // 5xx: the command was not accepted and
96 // the requested action did not take place
97 sfFtpCommandUnknown = 500,
98 sfFtpParametersUnknown = 501,
99 sfFtpCommandNotImplemented = 502,
100 sfFtpBadCommandSequence = 503,
101 sfFtpParameterNotImplemented = 504,
102 sfFtpNotLoggedIn = 530,
103 sfFtpNeedAccountToStore = 532,
104 sfFtpFileUnavailable = 550,
105 sfFtpPageTypeUnknown = 551,
106 sfFtpNotEnoughMemory = 552,
107 sfFtpFilenameNotAllowed = 553,
108
109 // 10xx: SFML custom codes
110 sfFtpInvalidResponse = 1000,
111 sfFtpConnectionFailed = 1001,
112 sfFtpConnectionClosed = 1002,
113 sfFtpInvalidFile = 1003
114} sfFtpStatus;
115
116
123 CSFML_NETWORK_API void sfFtpListingResponse_destroy(const sfFtpListingResponse* ftpListingResponse);
124
136 CSFML_NETWORK_API bool sfFtpListingResponse_isOk(const sfFtpListingResponse* ftpListingResponse);
137
146 CSFML_NETWORK_API sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingResponse* ftpListingResponse);
147
156 CSFML_NETWORK_API const char* sfFtpListingResponse_getMessage(const sfFtpListingResponse* ftpListingResponse);
157
166 CSFML_NETWORK_API size_t sfFtpListingResponse_getCount(const sfFtpListingResponse* ftpListingResponse);
167
177 CSFML_NETWORK_API const char* sfFtpListingResponse_getName(const sfFtpListingResponse* ftpListingResponse, size_t index);
178
185 CSFML_NETWORK_API void sfFtpDirectoryResponse_destroy(const sfFtpDirectoryResponse* ftpDirectoryResponse);
186
198 CSFML_NETWORK_API bool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryResponse* ftpDirectoryResponse);
199
208 CSFML_NETWORK_API sfFtpStatus sfFtpDirectoryResponse_getStatus(const sfFtpDirectoryResponse* ftpDirectoryResponse);
209
218 CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getMessage(const sfFtpDirectoryResponse* ftpDirectoryResponse);
219
231 CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse);
232
233
245 CSFML_NETWORK_API const sfChar32* sfFtpDirectoryResponse_getDirectoryUnicode(const sfFtpDirectoryResponse* ftpDirectoryResponse);
246
247
254 CSFML_NETWORK_API void sfFtpResponse_destroy(const sfFtpResponse* ftpResponse);
255
267 CSFML_NETWORK_API bool sfFtpResponse_isOk(const sfFtpResponse* ftpResponse);
268
277 CSFML_NETWORK_API sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse* ftpResponse);
278
287 CSFML_NETWORK_API const char* sfFtpResponse_getMessage(const sfFtpResponse* ftpResponse);
288
295 CSFML_NETWORK_API sfFtp* sfFtp_create(void);
296
303 CSFML_NETWORK_API void sfFtp_destroy(const sfFtp* ftp);
304
325 CSFML_NETWORK_API sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfTime timeout);
326
338 CSFML_NETWORK_API sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp);
339
353 CSFML_NETWORK_API sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* name, const char* password);
354
363 CSFML_NETWORK_API sfFtpResponse* sfFtp_disconnect(sfFtp* ftp);
364
376 CSFML_NETWORK_API sfFtpResponse* sfFtp_keepAlive(sfFtp* ftp);
377
389 CSFML_NETWORK_API sfFtpDirectoryResponse* sfFtp_getWorkingDirectory(sfFtp* ftp);
390
405 CSFML_NETWORK_API sfFtpListingResponse* sfFtp_getDirectoryListing(sfFtp* ftp, const char* directory);
406
418 CSFML_NETWORK_API sfFtpResponse* sfFtp_changeDirectory(sfFtp* ftp, const char* directory);
419
428 CSFML_NETWORK_API sfFtpResponse* sfFtp_parentDirectory(sfFtp* ftp);
429
442 CSFML_NETWORK_API sfFtpResponse* sfFtp_createDirectory(sfFtp* ftp, const char* name);
443
458 CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteDirectory(sfFtp* ftp, const char* name);
459
473 CSFML_NETWORK_API sfFtpResponse* sfFtp_renameFile(sfFtp* ftp, const char* file, const char* newName);
474
489 CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const char* name);
490
507 CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFile, const char* localPath, sfFtpTransferMode mode);
508
526 CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(
527 sfFtp* ftp,
528 const char* localFile,
529 const char* remotePath,
530 sfFtpTransferMode mode,
531 bool append);
532
551 CSFML_NETWORK_API sfFtpResponse* sfFtp_sendCommand(sfFtp* ftp, const char* command, const char* parameter);
sfChar32
uint32_t sfChar32
Define sfChar32.
Definition Config.h:161
sfFtp_deleteFile
sfFtpResponse * sfFtp_deleteFile(sfFtp *ftp, const char *name)
Remove an existing file.
sfFtpDirectoryResponse_getMessage
const char * sfFtpDirectoryResponse_getMessage(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the full message contained in a FTP directory response.
sfFtpResponse_destroy
void sfFtpResponse_destroy(const sfFtpResponse *ftpResponse)
Destroy a FTP response.
sfFtp_deleteDirectory
sfFtpResponse * sfFtp_deleteDirectory(sfFtp *ftp, const char *name)
Remove an existing directory.
sfFtpResponse_isOk
bool sfFtpResponse_isOk(const sfFtpResponse *ftpResponse)
Check if a FTP response status code means a success.
sfFtpDirectoryResponse_destroy
void sfFtpDirectoryResponse_destroy(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Destroy a FTP directory response.
sfFtpListingResponse_getMessage
const char * sfFtpListingResponse_getMessage(const sfFtpListingResponse *ftpListingResponse)
Get the full message contained in a FTP listing response.
sfFtp_destroy
void sfFtp_destroy(const sfFtp *ftp)
Destroy a Ftp object.
sfFtp_loginAnonymous
sfFtpResponse * sfFtp_loginAnonymous(sfFtp *ftp)
Log in using an anonymous account.
sfFtp_renameFile
sfFtpResponse * sfFtp_renameFile(sfFtp *ftp, const char *file, const char *newName)
Rename an existing file.
sfFtpListingResponse_getName
const char * sfFtpListingResponse_getName(const sfFtpListingResponse *ftpListingResponse, size_t index)
Return a directory/file name contained in a FTP listing response.
sfFtpListingResponse_getCount
size_t sfFtpListingResponse_getCount(const sfFtpListingResponse *ftpListingResponse)
Return the number of directory/file names contained in a FTP listing response.
sfFtp_createDirectory
sfFtpResponse * sfFtp_createDirectory(sfFtp *ftp, const char *name)
Create a new directory.
sfFtp_sendCommand
sfFtpResponse * sfFtp_sendCommand(sfFtp *ftp, const char *command, const char *parameter)
Send a command to the FTP server.
sfFtpTransferMode
sfFtpTransferMode
Enumeration of transfer modes.
Definition Ftp.h:43
sfFtpEbcdic
@ sfFtpEbcdic
Text mode using EBCDIC encoding.
Definition Ftp.h:46
sfFtpBinary
@ sfFtpBinary
Binary mode (file is transferred as a sequence of bytes)
Definition Ftp.h:44
sfFtpAscii
@ sfFtpAscii
Text mode using ASCII encoding.
Definition Ftp.h:45
sfFtp_connect
sfFtpResponse * sfFtp_connect(sfFtp *ftp, sfIpAddress server, unsigned short port, sfTime timeout)
Connect to the specified FTP server.
sfFtpListingResponse_getStatus
sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingResponse *ftpListingResponse)
Get the status code of a FTP listing response.
sfFtp_changeDirectory
sfFtpResponse * sfFtp_changeDirectory(sfFtp *ftp, const char *directory)
Change the current working directory.
sfFtp_keepAlive
sfFtpResponse * sfFtp_keepAlive(sfFtp *ftp)
Send a null command to keep the connection alive.
sfFtpResponse_getStatus
sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse *ftpResponse)
Get the status code of a FTP response.
sfFtp_disconnect
sfFtpResponse * sfFtp_disconnect(sfFtp *ftp)
Close the connection with the server.
sfFtpResponse_getMessage
const char * sfFtpResponse_getMessage(const sfFtpResponse *ftpResponse)
Get the full message contained in a FTP response.
sfFtp_upload
sfFtpResponse * sfFtp_upload(sfFtp *ftp, const char *localFile, const char *remotePath, sfFtpTransferMode mode, bool append)
Upload a file to a FTP server.
sfFtpDirectoryResponse_getStatus
sfFtpStatus sfFtpDirectoryResponse_getStatus(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the status code of a FTP directory response.
sfFtp_getWorkingDirectory
sfFtpDirectoryResponse * sfFtp_getWorkingDirectory(sfFtp *ftp)
Get the current working directory.
sfFtpListingResponse_destroy
void sfFtpListingResponse_destroy(const sfFtpListingResponse *ftpListingResponse)
Destroy a FTP listing response.
sfFtp_create
sfFtp * sfFtp_create(void)
Create a new Ftp object.
sfFtpDirectoryResponse_getDirectoryUnicode
const sfChar32 * sfFtpDirectoryResponse_getDirectoryUnicode(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the directory returned in a FTP directory response.
sfFtpListingResponse_isOk
bool sfFtpListingResponse_isOk(const sfFtpListingResponse *ftpListingResponse)
Check if a FTP listing response status code means a success.
sfFtp_login
sfFtpResponse * sfFtp_login(sfFtp *ftp, const char *name, const char *password)
Log in using a username and a password.
sfFtp_download
sfFtpResponse * sfFtp_download(sfFtp *ftp, const char *remoteFile, const char *localPath, sfFtpTransferMode mode)
Download a file from a FTP server.
sfFtpStatus
sfFtpStatus
Status codes possibly returned by a FTP response.
Definition Ftp.h:55
sfFtpInvalidFile
@ sfFtpInvalidFile
Invalid file to upload / download.
Definition Ftp.h:113
sfFtpLocalError
@ sfFtpLocalError
Requested action aborted, local error in processing.
Definition Ftp.h:92
sfFtpEnteringPassiveMode
@ sfFtpEnteringPassiveMode
Entering passive mode.
Definition Ftp.h:75
sfFtpNeedAccountToLogIn
@ sfFtpNeedAccountToLogIn
Need account for login.
Definition Ftp.h:83
sfFtpServiceReady
@ sfFtpServiceReady
Service ready for new user.
Definition Ftp.h:71
sfFtpConnectionClosed
@ sfFtpConnectionClosed
Connection with server closed.
Definition Ftp.h:112
sfFtpRestartMarkerReply
@ sfFtpRestartMarkerReply
Restart marker reply.
Definition Ftp.h:58
sfFtpServiceUnavailable
@ sfFtpServiceUnavailable
Service not available, closing control connection.
Definition Ftp.h:88
sfFtpPageTypeUnknown
@ sfFtpPageTypeUnknown
Requested action aborted, page type unknown.
Definition Ftp.h:105
sfFtpNeedInformation
@ sfFtpNeedInformation
Requested file action pending further information.
Definition Ftp.h:84
sfFtpTransferAborted
@ sfFtpTransferAborted
Connection closed, transfer aborted.
Definition Ftp.h:90
sfFtpClosingDataConnection
@ sfFtpClosingDataConnection
Closing data connection, requested file action successful.
Definition Ftp.h:74
sfFtpInsufficientStorageSpace
@ sfFtpInsufficientStorageSpace
Requested action not taken; insufficient storage space in system, file unavailable.
Definition Ftp.h:93
sfFtpOk
@ sfFtpOk
Command ok.
Definition Ftp.h:64
sfFtpDataConnectionOpened
@ sfFtpDataConnectionOpened
Data connection open, no transfer in progress.
Definition Ftp.h:73
sfFtpCommandNotImplemented
@ sfFtpCommandNotImplemented
Command not implemented.
Definition Ftp.h:99
sfFtpFilenameNotAllowed
@ sfFtpFilenameNotAllowed
Requested action not taken, file name not allowed.
Definition Ftp.h:107
sfFtpFileUnavailable
@ sfFtpFileUnavailable
Requested action not taken, file unavailable.
Definition Ftp.h:104
sfFtpInvalidResponse
@ sfFtpInvalidResponse
Response is not a valid FTP one.
Definition Ftp.h:110
sfFtpDataConnectionUnavailable
@ sfFtpDataConnectionUnavailable
Can't open data connection.
Definition Ftp.h:89
sfFtpPointlessCommand
@ sfFtpPointlessCommand
Command not implemented.
Definition Ftp.h:65
sfFtpCommandUnknown
@ sfFtpCommandUnknown
Syntax error, command unrecognized.
Definition Ftp.h:97
sfFtpNotEnoughMemory
@ sfFtpNotEnoughMemory
Requested file action aborted, exceeded storage allocation.
Definition Ftp.h:106
sfFtpDirectoryOk
@ sfFtpDirectoryOk
PATHNAME created.
Definition Ftp.h:78
sfFtpNeedAccountToStore
@ sfFtpNeedAccountToStore
Need account for storing files.
Definition Ftp.h:103
sfFtpOpeningDataConnection
@ sfFtpOpeningDataConnection
File status ok, about to open data connection.
Definition Ftp.h:61
sfFtpFileStatus
@ sfFtpFileStatus
File status.
Definition Ftp.h:68
sfFtpFileActionAborted
@ sfFtpFileActionAborted
Requested file action not taken.
Definition Ftp.h:91
sfFtpSystemType
@ sfFtpSystemType
NAME system type, where NAME is an official system name from the list in the Assigned Numbers documen...
Definition Ftp.h:70
sfFtpLoggedIn
@ sfFtpLoggedIn
User logged in, proceed. Logged out if appropriate.
Definition Ftp.h:76
sfFtpDirectoryStatus
@ sfFtpDirectoryStatus
Directory status.
Definition Ftp.h:67
sfFtpHelpMessage
@ sfFtpHelpMessage
Help message.
Definition Ftp.h:69
sfFtpSystemStatus
@ sfFtpSystemStatus
System status, or system help reply.
Definition Ftp.h:66
sfFtpParametersUnknown
@ sfFtpParametersUnknown
Syntax error in parameters or arguments.
Definition Ftp.h:98
sfFtpDataConnectionAlreadyOpened
@ sfFtpDataConnectionAlreadyOpened
Data connection already opened, transfer starting.
Definition Ftp.h:60
sfFtpBadCommandSequence
@ sfFtpBadCommandSequence
Bad sequence of commands.
Definition Ftp.h:100
sfFtpClosingConnection
@ sfFtpClosingConnection
Service closing control connection.
Definition Ftp.h:72
sfFtpConnectionFailed
@ sfFtpConnectionFailed
Connection with server failed.
Definition Ftp.h:111
sfFtpServiceReadySoon
@ sfFtpServiceReadySoon
Service ready in N minutes.
Definition Ftp.h:59
sfFtpFileActionOk
@ sfFtpFileActionOk
Requested file action ok.
Definition Ftp.h:77
sfFtpNotLoggedIn
@ sfFtpNotLoggedIn
Not logged in.
Definition Ftp.h:102
sfFtpNeedPassword
@ sfFtpNeedPassword
User name ok, need password.
Definition Ftp.h:82
sfFtpParameterNotImplemented
@ sfFtpParameterNotImplemented
Command not implemented for that parameter.
Definition Ftp.h:101
sfFtp_parentDirectory
sfFtpResponse * sfFtp_parentDirectory(sfFtp *ftp)
Go to the parent directory of the current one.
sfFtpDirectoryResponse_getDirectory
const char * sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the directory returned in a FTP directory response.
sfFtpDirectoryResponse_isOk
bool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Check if a FTP directory response status code means a success.
sfFtp_getDirectoryListing
sfFtpListingResponse * sfFtp_getDirectoryListing(sfFtp *ftp, const char *directory)
Get the contents of the given directory.
IpAddress.h
Export.h
CSFML_NETWORK_API
#define CSFML_NETWORK_API
Definition Network/Export.h:42
Types.h
sfFtpResponse
struct sfFtpResponse sfFtpResponse
Definition Network/Types.h:30
sfFtpListingResponse
struct sfFtpListingResponse sfFtpListingResponse
Definition Network/Types.h:29
sfFtp
struct sfFtp sfFtp
Definition Network/Types.h:31
sfFtpDirectoryResponse
struct sfFtpDirectoryResponse sfFtpDirectoryResponse
Definition Network/Types.h:28
sfIpAddress
Encapsulate an IPv4 network address.
Definition IpAddress.h:40
sfTime
Represents a time value.
Definition Time.h:38