Qore Programming Language - C/C++ Library  0.8.12.3
QoreFtpClient.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreFtpClient.h
4 
5  thread-safe Qore QoreFtpClient object
6 
7  Qore Programming Language
8 
9  Copyright (C) 2003 - 2016 Qore Technologies, s.r.o.
10 
11  Permission is hereby granted, free of charge, to any person obtaining a
12  copy of this software and associated documentation files (the "Software"),
13  to deal in the Software without restriction, including without limitation
14  the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  and/or sell copies of the Software, and to permit persons to whom the
16  Software is furnished to do so, subject to the following conditions:
17 
18  The above copyright notice and this permission notice shall be included in
19  all copies or substantial portions of the Software.
20 
21  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  DEALINGS IN THE SOFTWARE.
28 
29  Note that the Qore library is released under a choice of three open-source
30  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
31  information.
32 */
33 
34 #ifndef _QORE_QOREFTPCLIENT_H
35 
36 #define _QORE_QOREFTPCLIENT_H
37 
38 #define DEFAULT_FTP_CONTROL_PORT 21
39 #define DEFAULT_FTP_DATA_PORT 20
40 
41 #define DEFAULT_USERNAME "anonymous"
42 #define DEFAULT_PASSWORD "qore@nohost.com"
43 
44 class FtpResp;
45 class Queue;
46 
48 
69 protected:
71  struct qore_ftp_private *priv;
72 
74  DLLLOCAL QoreFtpClient(const QoreFtpClient&);
75 
77  DLLLOCAL QoreFtpClient& operator=(const QoreFtpClient&);
78 
79 public:
81 
86  DLLEXPORT QoreFtpClient(const QoreString *url, ExceptionSink *xsink);
87 
89  DLLEXPORT QoreFtpClient();
90 
92  DLLEXPORT ~QoreFtpClient();
93 
95 
99  DLLEXPORT int connect(ExceptionSink *xsink);
100 
102 
105  DLLEXPORT int disconnect();
106 
108 
114  DLLEXPORT int cwd(const char *dir, ExceptionSink *xsink);
115 
117 
121  DLLEXPORT QoreStringNode *pwd(ExceptionSink *xsink);
122 
124 
130  DLLEXPORT int put(const char *localpath, const char *remotename, ExceptionSink *xsink);
131 
133 
142  DLLEXPORT int get(const char *remotepath, const char *localname, ExceptionSink *xsink);
143 
145 
152  DLLEXPORT int putData(const void *data, qore_size_t len, const char *remotename, ExceptionSink *xsink);
153 
155 
160  DLLEXPORT QoreStringNode *getAsString(const char *remotepath, ExceptionSink *xsink);
161 
163 
168  DLLEXPORT BinaryNode *getAsBinary(const char *remotepath, ExceptionSink *xsink);
169 
171 
177  DLLEXPORT int rename(const char *from, const char *to, ExceptionSink *xsink);
178 
180 
186  DLLEXPORT QoreStringNode *list(const char *path, bool long_list, ExceptionSink *xsink);
187 
189 
194  DLLEXPORT int del(const char *file, ExceptionSink *xsink);
195 
197 
202  DLLEXPORT int mkdir(const char *remotepath, ExceptionSink *xsink);
203 
205 
210  DLLEXPORT int rmdir(const char *remotepath, ExceptionSink *xsink);
211 
213  DLLEXPORT int getPort() const;
214 
216  DLLEXPORT const char *getUserName() const;
217 
219  DLLEXPORT const char *getPassword() const;
220 
222  DLLEXPORT const char *getHostName() const;
223 
225 
230  DLLEXPORT void setURL(const QoreString *url, ExceptionSink *xsink);
231 
233 
236  DLLEXPORT QoreStringNode *getURL() const;
237 
239  DLLEXPORT void setPort(int p);
240 
242  DLLEXPORT void setUserName(const char *u);
243 
245  DLLEXPORT void setPassword(const char *p);
246 
248  DLLEXPORT void setHostName(const char *h);
249 
251 
253  DLLEXPORT int setSecure();
254 
256 
258  DLLEXPORT int setInsecure();
259 
261 
265  DLLEXPORT int setInsecureData();
266 
268 
271  DLLEXPORT bool isSecure() const;
272 
274 
277  DLLEXPORT bool isDataSecure() const;
278 
280 
283  DLLEXPORT const char *getSSLCipherName() const;
284 
286 
289  DLLEXPORT const char *getSSLCipherVersion() const;
290 
292  DLLEXPORT long verifyPeerCertificate() const;
293 
295  DLLEXPORT void setModeAuto();
296 
298  DLLEXPORT void setModeEPSV();
299 
301  DLLEXPORT void setModePASV();
302 
304  DLLEXPORT void setModePORT();
305 
307  DLLEXPORT const char* getMode() const;
308 
309  DLLEXPORT void clearWarningQueue(ExceptionSink* xsink);
310  DLLEXPORT void setWarningQueue(ExceptionSink* xsink, int64 warning_ms, int64 warning_bs, class Queue* wq, AbstractQoreNode* arg, int64 min_ms = 1000);
311  DLLEXPORT QoreHashNode* getUsageInfo() const;
312  DLLEXPORT void clearStats();
313 
315 
317  DLLLOCAL void setTimeout(int timeout_ms);
318 
320 
322  DLLLOCAL int getTimeout() const;
323 
325  DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink);
326 
328  DLLLOCAL void setDataEventQueue(Queue *cbq, ExceptionSink *xsink);
329 
331  DLLLOCAL void setControlEventQueue(Queue *cbq, ExceptionSink *xsink);
332 
333  DLLLOCAL void cleanup(ExceptionSink *xsink);
334 };
335 
336 #endif // _QORE_OBJECTS_FTPCLIENT_H
DLLLOCAL void setControlEventQueue(Queue *cbq, ExceptionSink *xsink)
sets the event queue for the control socket
DLLEXPORT int mkdir(const char *remotepath, ExceptionSink *xsink)
creates a directory on the remote server
struct qore_ftp_private * priv
private implementation of the object
Definition: QoreFtpClient.h:71
DLLEXPORT QoreStringNode * list(const char *path, bool long_list, ExceptionSink *xsink)
returns a string listing the directory contents on the remote host (caller owns the reference count r...
DLLEXPORT void setModeEPSV()
sets the connection mode for the next connection to "EPSV" (extended passive mode) ...
DLLEXPORT int disconnect()
disconnects from the remote host if connected
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:49
DLLEXPORT int setInsecure()
unsets the secure connection parameter flag (to use the FTP protocol)
DLLEXPORT QoreFtpClient()
creates the object with no connection parameters
DLLEXPORT BinaryNode * getAsBinary(const char *remotepath, ExceptionSink *xsink)
gets a file from the remote server and returns it as a binary node
DLLEXPORT ~QoreFtpClient()
disconnects from the host if necessary and frees all memory associated with the object ...
DLLEXPORT QoreStringNode * getAsString(const char *remotepath, ExceptionSink *xsink)
gets a file from the remote server and returns it as a string
DLLEXPORT void setPassword(const char *p)
sets the password connection parameter
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
DLLEXPORT void setModeAuto()
sets the connection mode for the next connection to "auto"
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:71
provides thread-safe access to FTP servers through Qore data structures
Definition: QoreFtpClient.h:68
DLLEXPORT bool isSecure() const
returns the secure connection parameter flag
DLLEXPORT QoreStringNode * pwd(ExceptionSink *xsink)
returns the working directory on the remote host (caller owns the reference count returned) ...
DLLEXPORT long verifyPeerCertificate() const
returns the peer certificate verification code
DLLEXPORT int putData(const void *data, qore_size_t len, const char *remotename, ExceptionSink *xsink)
sends a file data io the remote server
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:82
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
DLLEXPORT QoreStringNode * getURL() const
returns a URL string representing the current connection parameters, caller owns the reference count ...
DLLLOCAL void setDataEventQueue(Queue *cbq, ExceptionSink *xsink)
sets the event queue for the data socket
DLLEXPORT const char * getMode() const
returns a string for the connection mode: "port", "pasv", "epsv", or "auto" if not connected and auto...
DLLEXPORT void setHostName(const char *h)
sets the host name connection parameter
DLLEXPORT int del(const char *file, ExceptionSink *xsink)
deletes the given file on the remote server
DLLEXPORT int connect(ExceptionSink *xsink)
connects to the remote host and logs in
DLLLOCAL QoreFtpClient & operator=(const QoreFtpClient &)
this function is not implemented; it is here as a private function in order to prohibit it from being...
DLLEXPORT void setModePASV()
sets the connection mode for the next connection to "PASV" (passive mode)
DLLEXPORT int getPort() const
returns the port number connection parameter
DLLEXPORT int setInsecureData()
sets the secure data connection parameter flag
DLLEXPORT int rename(const char *from, const char *to, ExceptionSink *xsink)
renames/moves a file on the remote server
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
DLLLOCAL void setTimeout(int timeout_ms)
sets the socket I/O timeout value in milliseconds
DLLEXPORT const char * getHostName() const
returns the hostname connection parameter
DLLEXPORT const char * getUserName() const
returns the user name connection parameter
DLLEXPORT void setPort(int p)
sets the port connection parameter
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:228
DLLEXPORT void setModePORT()
sets the connection mode for the next connection to "PORT"
DLLLOCAL int getTimeout() const
returns the socket I/O timeout value as an integer in milliseconds
DLLEXPORT const char * getPassword() const
returns the password connection parameter
DLLEXPORT void setURL(const QoreString *url, ExceptionSink *xsink)
sets the connection parameters from a URL
DLLEXPORT const char * getSSLCipherVersion() const
returns the version string of the SSL Cipher for the currently-connected control connection, or 0 if there is none
DLLEXPORT bool isDataSecure() const
returns the secure data connection parameter flag
DLLEXPORT void setUserName(const char *u)
sets the user name connection parameter
DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink)
sets the same event queue for data and control sockets
DLLEXPORT int put(const char *localpath, const char *remotename, ExceptionSink *xsink)
sends a file from the local filesystem to the remote server
DLLEXPORT int setSecure()
sets the secure connection parameter flag (to use the FTPS protocol)
DLLEXPORT int rmdir(const char *remotepath, ExceptionSink *xsink)
removes a directory on the remote server
DLLEXPORT int cwd(const char *dir, ExceptionSink *xsink)
changes the working directory on the remote host
holds arbitrary binary data
Definition: BinaryNode.h:41
DLLEXPORT const char * getSSLCipherName() const
returns the name of the SSL Cipher for the currently-connected control connection, or 0 if there is none