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#ifndef SFML_FTP_H
26#define SFML_FTP_H
27
29// Headers
31#include <SFML/Network/Export.h>
33#include <SFML/Network/Types.h>
34#include <stddef.h>
35
36
47
48
53typedef enum
54{
55 // 1xx: the requested action is being initiated,
56 // expect another reply before proceeding with a new command
61
62 // 2xx: the requested action has been successfully completed
63 sfFtpOk = 200,
78
79 // 3xx: the command has been accepted, but the requested action
80 // is dormant, pending receipt of further information
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
93
94 // 5xx: the command was not accepted and
95 // the requested action did not take place
107
108 // 10xx: SFML custom codes
112 sfFtpInvalidFile = 1003
114
115
123
136
146
156
166
176CSFML_NETWORK_API const char* sfFtpListingResponse_getName(const sfFtpListingResponse* ftpListingResponse, size_t index);
177
185
198
208
218
228
229
237
250
260
270
278
286
307CSFML_NETWORK_API sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, unsigned short port, sfTime timeout);
308
321
335CSFML_NETWORK_API sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* name, const char* password);
336
346
359
372
388
401
411
425
441
455CSFML_NETWORK_API sfFtpResponse* sfFtp_renameFile(sfFtp* ftp, const char* file, const char* newName);
456
472
489CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFile, const char* localPath, sfFtpTransferMode mode);
490
508CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode, sfBool append);
509
528CSFML_NETWORK_API sfFtpResponse* sfFtp_sendCommand(sfFtp* ftp, const char* command, const char* parameter);
529
530
531#endif // SFML_FTP_H
int sfBool
Definition Config.h:153
sfFtpResponse * sfFtp_deleteFile(sfFtp *ftp, const char *name)
Remove an existing file.
void sfFtpDirectoryResponse_destroy(sfFtpDirectoryResponse *ftpDirectoryResponse)
Destroy a FTP directory response.
const char * sfFtpDirectoryResponse_getMessage(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the full message contained in a FTP directory response.
sfFtpResponse * sfFtp_deleteDirectory(sfFtp *ftp, const char *name)
Remove an existing directory.
sfFtpResponse * sfFtp_upload(sfFtp *ftp, const char *localFile, const char *remotePath, sfFtpTransferMode mode, sfBool append)
Upload a file to a FTP server.
sfBool sfFtpDirectoryResponse_isOk(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Check if a FTP directory response status code means a success.
const char * sfFtpListingResponse_getMessage(const sfFtpListingResponse *ftpListingResponse)
Get the full message contained in a FTP listing response.
sfFtpResponse * sfFtp_loginAnonymous(sfFtp *ftp)
Log in using an anonymous account.
sfBool sfFtpResponse_isOk(const sfFtpResponse *ftpResponse)
Check if a FTP response status code means a success.
sfFtpResponse * sfFtp_renameFile(sfFtp *ftp, const char *file, const char *newName)
Rename an existing file.
const char * sfFtpListingResponse_getName(const sfFtpListingResponse *ftpListingResponse, size_t index)
Return a directory/file name contained in a FTP listing response.
size_t sfFtpListingResponse_getCount(const sfFtpListingResponse *ftpListingResponse)
Return the number of directory/file names contained in a FTP listing response.
sfFtpResponse * sfFtp_createDirectory(sfFtp *ftp, const char *name)
Create a new directory.
sfFtpResponse * sfFtp_sendCommand(sfFtp *ftp, const char *command, const char *parameter)
Send a command to the FTP server.
sfFtpTransferMode
Enumeration of transfer modes.
Definition Ftp.h:42
@ sfFtpEbcdic
Text mode using EBCDIC encoding.
Definition Ftp.h:45
@ sfFtpBinary
Binary mode (file is transfered as a sequence of bytes)
Definition Ftp.h:43
@ sfFtpAscii
Text mode using ASCII encoding.
Definition Ftp.h:44
sfFtpResponse * sfFtp_connect(sfFtp *ftp, sfIpAddress server, unsigned short port, sfTime timeout)
Connect to the specified FTP server.
sfFtpStatus sfFtpListingResponse_getStatus(const sfFtpListingResponse *ftpListingResponse)
Get the status code of a FTP listing response.
sfFtpResponse * sfFtp_changeDirectory(sfFtp *ftp, const char *directory)
Change the current working directory.
sfBool sfFtpListingResponse_isOk(const sfFtpListingResponse *ftpListingResponse)
Check if a FTP listing response status code means a success.
sfFtpResponse * sfFtp_keepAlive(sfFtp *ftp)
Send a null command to keep the connection alive.
sfFtpStatus sfFtpResponse_getStatus(const sfFtpResponse *ftpResponse)
Get the status code of a FTP response.
sfFtpResponse * sfFtp_disconnect(sfFtp *ftp)
Close the connection with the server.
const char * sfFtpResponse_getMessage(const sfFtpResponse *ftpResponse)
Get the full message contained in a FTP response.
void sfFtp_destroy(sfFtp *ftp)
Destroy a Ftp object.
void sfFtpListingResponse_destroy(sfFtpListingResponse *ftpListingResponse)
Destroy a FTP listing response.
sfFtpStatus sfFtpDirectoryResponse_getStatus(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the status code of a FTP directory response.
sfFtpDirectoryResponse * sfFtp_getWorkingDirectory(sfFtp *ftp)
Get the current working directory.
sfFtp * sfFtp_create(void)
Create a new Ftp object.
sfFtpResponse * sfFtp_login(sfFtp *ftp, const char *name, const char *password)
Log in using a username and a password.
sfFtpResponse * sfFtp_download(sfFtp *ftp, const char *remoteFile, const char *localPath, sfFtpTransferMode mode)
Download a file from a FTP server.
sfFtpStatus
Status codes possibly returned by a FTP response.
Definition Ftp.h:54
@ sfFtpInvalidFile
Invalid file to upload / download.
Definition Ftp.h:112
@ sfFtpLocalError
Requested action aborted, local error in processing.
Definition Ftp.h:91
@ sfFtpEnteringPassiveMode
Entering passive mode.
Definition Ftp.h:74
@ sfFtpNeedAccountToLogIn
Need account for login.
Definition Ftp.h:82
@ sfFtpServiceReady
Service ready for new user.
Definition Ftp.h:70
@ sfFtpConnectionClosed
Connection with server closed.
Definition Ftp.h:111
@ sfFtpRestartMarkerReply
Restart marker reply.
Definition Ftp.h:57
@ sfFtpServiceUnavailable
Service not available, closing control connection.
Definition Ftp.h:87
@ sfFtpPageTypeUnknown
Requested action aborted, page type unknown.
Definition Ftp.h:104
@ sfFtpNeedInformation
Requested file action pending further information.
Definition Ftp.h:83
@ sfFtpTransferAborted
Connection closed, transfer aborted.
Definition Ftp.h:89
@ sfFtpClosingDataConnection
Closing data connection, requested file action successful.
Definition Ftp.h:73
@ sfFtpInsufficientStorageSpace
Requested action not taken; insufficient storage space in system, file unavailable.
Definition Ftp.h:92
@ sfFtpOk
Command ok.
Definition Ftp.h:63
@ sfFtpDataConnectionOpened
Data connection open, no transfer in progress.
Definition Ftp.h:72
@ sfFtpCommandNotImplemented
Command not implemented.
Definition Ftp.h:98
@ sfFtpFilenameNotAllowed
Requested action not taken, file name not allowed.
Definition Ftp.h:106
@ sfFtpFileUnavailable
Requested action not taken, file unavailable.
Definition Ftp.h:103
@ sfFtpInvalidResponse
Response is not a valid FTP one.
Definition Ftp.h:109
@ sfFtpDataConnectionUnavailable
Can't open data connection.
Definition Ftp.h:88
@ sfFtpPointlessCommand
Command not implemented.
Definition Ftp.h:64
@ sfFtpCommandUnknown
Syntax error, command unrecognized.
Definition Ftp.h:96
@ sfFtpNotEnoughMemory
Requested file action aborted, exceeded storage allocation.
Definition Ftp.h:105
@ sfFtpDirectoryOk
PATHNAME created.
Definition Ftp.h:77
@ sfFtpNeedAccountToStore
Need account for storing files.
Definition Ftp.h:102
@ sfFtpOpeningDataConnection
File status ok, about to open data connection.
Definition Ftp.h:60
@ sfFtpFileStatus
File status.
Definition Ftp.h:67
@ sfFtpFileActionAborted
Requested file action not taken.
Definition Ftp.h:90
@ sfFtpSystemType
NAME system type, where NAME is an official system name from the list in the Assigned Numbers documen...
Definition Ftp.h:69
@ sfFtpLoggedIn
User logged in, proceed. Logged out if appropriate.
Definition Ftp.h:75
@ sfFtpDirectoryStatus
Directory status.
Definition Ftp.h:66
@ sfFtpHelpMessage
Help message.
Definition Ftp.h:68
@ sfFtpSystemStatus
System status, or system help reply.
Definition Ftp.h:65
@ sfFtpParametersUnknown
Syntax error in parameters or arguments.
Definition Ftp.h:97
@ sfFtpDataConnectionAlreadyOpened
Data connection already opened, transfer starting.
Definition Ftp.h:59
@ sfFtpBadCommandSequence
Bad sequence of commands.
Definition Ftp.h:99
@ sfFtpClosingConnection
Service closing control connection.
Definition Ftp.h:71
@ sfFtpConnectionFailed
Connection with server failed.
Definition Ftp.h:110
@ sfFtpServiceReadySoon
Service ready in N minutes.
Definition Ftp.h:58
@ sfFtpFileActionOk
Requested file action ok.
Definition Ftp.h:76
@ sfFtpNotLoggedIn
Not logged in.
Definition Ftp.h:101
@ sfFtpNeedPassword
User name ok, need password.
Definition Ftp.h:81
@ sfFtpParameterNotImplemented
Command not implemented for that parameter.
Definition Ftp.h:100
sfFtpResponse * sfFtp_parentDirectory(sfFtp *ftp)
Go to the parent directory of the current one.
const char * sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse *ftpDirectoryResponse)
Get the directory returned in a FTP directory response.
void sfFtpResponse_destroy(sfFtpResponse *ftpResponse)
Destroy a FTP response.
sfFtpListingResponse * sfFtp_getDirectoryListing(sfFtp *ftp, const char *directory)
Get the contents of the given directory.
#define CSFML_NETWORK_API
struct sfFtpResponse sfFtpResponse
struct sfFtpListingResponse sfFtpListingResponse
struct sfFtp sfFtp
struct sfFtpDirectoryResponse sfFtpDirectoryResponse
Encapsulate an IPv4 network address.
Definition IpAddress.h:40
Represents a time value.
Definition Time.h:39