repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / codycam / FtpClient.h
blob0536d5e5f023fe924d0d4cf2abeb55f98c2bb52a
1 #ifndef FTP_CLIENT_H
2 #define FTP_CLIENT_H
5 #include <stdio.h>
6 #include <string>
8 #include <File.h>
9 #include <NetworkKit.h>
10 #include "FileUploadClient.h"
12 using std::string;
16 * Definitions for the TELNET protocol. Snarfed from the BSD source.
18 #define IAC 255
19 #define DONT 254
20 #define DO 253
21 #define WONT 252
22 #define WILL 251
23 #define xEOF 236
26 class FtpClient : public FileUploadClient {
27 public:
28 FtpClient();
29 ~FtpClient();
31 bool Connect(const string& server, const string& login,
32 const string& passwd);
34 bool PutFile(const string& local, const string& remote,
35 ftp_mode mode = binary_mode);
37 bool GetFile(const string& remote, const string& local,
38 ftp_mode mode = binary_mode);
40 bool MoveFile(const string& oldPath, const string& newPath);
41 bool ChangeDir(const string& dir);
42 bool PrintWorkingDir(string& dir);
43 bool ListDirContents(string& listing);
44 bool Chmod(const string& path, const string& mod);
46 void SetPassive(bool on);
48 protected:
49 enum {
50 ftp_complete = 1UL,
51 ftp_connected = 2,
52 ftp_passive = 4
55 bool _TestState(unsigned long state);
56 void _SetState(unsigned long state);
57 void _ClearState(unsigned long state);
59 bool _SendRequest(const string& cmd);
60 bool _GetReply(string& outString, int& outCode, int& codeType);
61 bool _GetReplyLine(string& line);
62 bool _OpenDataConnection();
63 bool _AcceptDataConnection();
65 unsigned long fState;
66 BNetEndpoint* fControl;
67 BNetEndpoint* fData;
71 #endif // FTP_CLIENT_H