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 #ifndef _QORE_QOREFTPCLIENT_H
00026
00027 #define _QORE_QOREFTPCLIENT_H
00028
00029 #define DEFAULT_FTP_CONTROL_PORT 21
00030 #define DEFAULT_FTP_DATA_PORT 20
00031
00032 #define DEFAULT_USERNAME "anonymous"
00033 #define DEFAULT_PASSWORD "qore@nohost.com"
00034
00035 class FtpResp;
00036 class Queue;
00037
00039
00059 class QoreFtpClient {
00060 protected:
00062 struct qore_ftp_private *priv;
00063
00064 DLLLOCAL QoreStringNode *getResponse(int &code, ExceptionSink *xsink);
00065 DLLLOCAL QoreStringNode *sendMsg(int &code, const char *cmd, const char *arg, ExceptionSink *xsink);
00066
00067 DLLLOCAL int connectDataExtendedPassive(ExceptionSink *xsink);
00068 DLLLOCAL int connectDataPassive(ExceptionSink *xsink);
00069 DLLLOCAL int connectDataPort(ExceptionSink *xsink);
00070 DLLLOCAL int connectData(ExceptionSink *xsink);
00071 DLLLOCAL int acceptDataConnection(ExceptionSink *xsink);
00072 DLLLOCAL int setBinaryMode(bool t, ExceptionSink *xsink);
00073 DLLLOCAL int disconnectInternal();
00074 DLLLOCAL int connectIntern(class FtpResp *resp, ExceptionSink *xsink);
00075 DLLLOCAL int doAuth(class FtpResp *resp, ExceptionSink *xsink);
00076 DLLLOCAL int doProt(class FtpResp *resp, ExceptionSink *xsink);
00077
00079 DLLLOCAL QoreFtpClient(const QoreFtpClient&);
00080
00082 DLLLOCAL QoreFtpClient& operator=(const QoreFtpClient&);
00083
00084 DLLLOCAL int pre_get(FtpResp &resp, const char *remotepath, ExceptionSink *xsink);
00085 DLLLOCAL void do_event_msg_sent(const char *cmd, const char *arg);
00086 DLLLOCAL void do_event_msg_received(int code, const char *msg);
00087
00088 DLLLOCAL void lock();
00089 DLLLOCAL void unlock();
00090
00091 public:
00093
00098 DLLEXPORT QoreFtpClient(const QoreString *url, ExceptionSink *xsink);
00099
00101 DLLEXPORT ~QoreFtpClient();
00102
00104
00108 DLLEXPORT int connect(ExceptionSink *xsink);
00109
00111
00114 DLLEXPORT int disconnect();
00115
00117
00123 DLLEXPORT int cwd(const char *dir, ExceptionSink *xsink);
00124
00126
00130 DLLEXPORT QoreStringNode *pwd(ExceptionSink *xsink);
00131
00133
00139 DLLEXPORT int put(const char *localpath, const char *remotename, ExceptionSink *xsink);
00140
00142
00148 DLLEXPORT int get(const char *remotepath, const char *localname, ExceptionSink *xsink);
00149
00151
00156 DLLEXPORT QoreStringNode *getAsString(const char *remotepath, ExceptionSink *xsink);
00157
00159
00164 DLLEXPORT BinaryNode *getAsBinary(const char *remotepath, ExceptionSink *xsink);
00165
00167
00173 DLLEXPORT QoreStringNode *list(const char *path, bool long_list, ExceptionSink *xsink);
00174
00176
00181 DLLEXPORT int del(const char *file, ExceptionSink *xsink);
00182
00184 DLLEXPORT int getPort() const;
00185
00187 DLLEXPORT const char *getUserName() const;
00188
00190 DLLEXPORT const char *getPassword() const;
00191
00193 DLLEXPORT const char *getHostName() const;
00194
00196
00201 DLLEXPORT void setURL(const QoreString *url, ExceptionSink *xsink);
00202
00204
00207 DLLEXPORT QoreStringNode *getURL() const;
00208
00210 DLLEXPORT void setPort(int p);
00211
00213 DLLEXPORT void setUserName(const char *u);
00214
00216 DLLEXPORT void setPassword(const char *p);
00217
00219 DLLEXPORT void setHostName(const char *h);
00220
00222
00224 DLLEXPORT int setSecure();
00225
00227
00229 DLLEXPORT int setInsecure();
00230
00232
00236 DLLEXPORT int setInsecureData();
00237
00239
00242 DLLEXPORT bool isSecure() const;
00243
00245
00248 DLLEXPORT bool isDataSecure() const;
00249
00251
00254 DLLEXPORT const char *getSSLCipherName() const;
00255
00257
00260 DLLEXPORT const char *getSSLCipherVersion() const;
00261
00263 DLLEXPORT long verifyPeerCertificate() const;
00264
00266 DLLEXPORT void setModeAuto();
00267
00269 DLLEXPORT void setModeEPSV();
00270
00272 DLLEXPORT void setModePASV();
00273
00275 DLLEXPORT void setModePORT();
00276
00278 DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink);
00279
00281 DLLLOCAL void setDataEventQueue(Queue *cbq, ExceptionSink *xsink);
00282
00284 DLLLOCAL void setControlEventQueue(Queue *cbq, ExceptionSink *xsink);
00285
00286 DLLLOCAL void cleanup(ExceptionSink *xsink);
00287 };
00288
00289 #endif // _QORE_OBJECTS_FTPCLIENT_H