00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _QORE_QOREFTPCLIENT_H
00027
00028 #define _QORE_QOREFTPCLIENT_H
00029
00030 #define DEFAULT_FTP_CONTROL_PORT 21
00031 #define DEFAULT_FTP_DATA_PORT 20
00032
00033 #define DEFAULT_USERNAME "anonymous"
00034 #define DEFAULT_PASSWORD "qore@nohost.com"
00035
00036 class FtpResp;
00037 class Queue;
00038
00040
00060 class QoreFtpClient {
00061 protected:
00063 struct qore_ftp_private *priv;
00064
00065 DLLLOCAL QoreStringNode *getResponse(int &code, ExceptionSink *xsink);
00066 DLLLOCAL QoreStringNode *sendMsg(int &code, const char *cmd, const char *arg, ExceptionSink *xsink);
00067
00068 DLLLOCAL int connectDataExtendedPassive(ExceptionSink *xsink);
00069 DLLLOCAL int connectDataPassive(ExceptionSink *xsink);
00070 DLLLOCAL int connectDataPort(ExceptionSink *xsink);
00071 DLLLOCAL int connectData(ExceptionSink *xsink);
00072 DLLLOCAL int acceptDataConnection(ExceptionSink *xsink);
00073 DLLLOCAL int setBinaryMode(bool t, ExceptionSink *xsink);
00074 DLLLOCAL int disconnectInternal();
00075 DLLLOCAL int connectIntern(class FtpResp *resp, ExceptionSink *xsink);
00076 DLLLOCAL int doAuth(class FtpResp *resp, ExceptionSink *xsink);
00077 DLLLOCAL int doProt(class FtpResp *resp, ExceptionSink *xsink);
00078
00080 DLLLOCAL QoreFtpClient(const QoreFtpClient&);
00081
00083 DLLLOCAL QoreFtpClient& operator=(const QoreFtpClient&);
00084
00085 DLLLOCAL int pre_get(FtpResp &resp, const char *remotepath, ExceptionSink *xsink);
00086 DLLLOCAL void do_event_msg_sent(const char *cmd, const char *arg);
00087 DLLLOCAL void do_event_msg_received(int code, const char *msg);
00088
00089 DLLLOCAL void lock();
00090 DLLLOCAL void unlock();
00091
00092 public:
00094
00099 DLLEXPORT QoreFtpClient(const QoreString *url, ExceptionSink *xsink);
00100
00102 DLLEXPORT QoreFtpClient();
00103
00105 DLLEXPORT ~QoreFtpClient();
00106
00108
00112 DLLEXPORT int connect(ExceptionSink *xsink);
00113
00115
00118 DLLEXPORT int disconnect();
00119
00121
00127 DLLEXPORT int cwd(const char *dir, ExceptionSink *xsink);
00128
00130
00134 DLLEXPORT QoreStringNode *pwd(ExceptionSink *xsink);
00135
00137
00143 DLLEXPORT int put(const char *localpath, const char *remotename, ExceptionSink *xsink);
00144
00146
00152 DLLEXPORT int get(const char *remotepath, const char *localname, ExceptionSink *xsink);
00153
00155
00160 DLLEXPORT QoreStringNode *getAsString(const char *remotepath, ExceptionSink *xsink);
00161
00163
00168 DLLEXPORT BinaryNode *getAsBinary(const char *remotepath, ExceptionSink *xsink);
00169
00171
00177 DLLEXPORT QoreStringNode *list(const char *path, bool long_list, ExceptionSink *xsink);
00178
00180
00185 DLLEXPORT int del(const char *file, ExceptionSink *xsink);
00186
00188 DLLEXPORT int getPort() const;
00189
00191 DLLEXPORT const char *getUserName() const;
00192
00194 DLLEXPORT const char *getPassword() const;
00195
00197 DLLEXPORT const char *getHostName() const;
00198
00200
00205 DLLEXPORT void setURL(const QoreString *url, ExceptionSink *xsink);
00206
00208
00211 DLLEXPORT QoreStringNode *getURL() const;
00212
00214 DLLEXPORT void setPort(int p);
00215
00217 DLLEXPORT void setUserName(const char *u);
00218
00220 DLLEXPORT void setPassword(const char *p);
00221
00223 DLLEXPORT void setHostName(const char *h);
00224
00226
00228 DLLEXPORT int setSecure();
00229
00231
00233 DLLEXPORT int setInsecure();
00234
00236
00240 DLLEXPORT int setInsecureData();
00241
00243
00246 DLLEXPORT bool isSecure() const;
00247
00249
00252 DLLEXPORT bool isDataSecure() const;
00253
00255
00258 DLLEXPORT const char *getSSLCipherName() const;
00259
00261
00264 DLLEXPORT const char *getSSLCipherVersion() const;
00265
00267 DLLEXPORT long verifyPeerCertificate() const;
00268
00270 DLLEXPORT void setModeAuto();
00271
00273 DLLEXPORT void setModeEPSV();
00274
00276 DLLEXPORT void setModePASV();
00277
00279 DLLEXPORT void setModePORT();
00280
00282 DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink);
00283
00285 DLLLOCAL void setDataEventQueue(Queue *cbq, ExceptionSink *xsink);
00286
00288 DLLLOCAL void setControlEventQueue(Queue *cbq, ExceptionSink *xsink);
00289
00290 DLLLOCAL void cleanup(ExceptionSink *xsink);
00291 };
00292
00293 #endif // _QORE_OBJECTS_FTPCLIENT_H