Imported Upstream version 2.8.0
[platform/upstream/libxml2.git] / include / libxml / nanoftp.h
1 /*
2  * Summary: minimal FTP implementation
3  * Description: minimal FTP implementation allowing to fetch resources
4  *              like external subset.
5  *
6  * Copy: See Copyright for the status of this software.
7  *
8  * Author: Daniel Veillard
9  */
10
11 #ifndef __NANO_FTP_H__
12 #define __NANO_FTP_H__
13
14 #include <libxml/xmlversion.h>
15
16 #ifdef LIBXML_FTP_ENABLED
17
18 /* Needed for portability to Windows 64 bits */
19 #if defined(__MINGW32__) || defined(_WIN32_WCE)
20 #include <winsock2.h>
21 #else
22 /**
23  * SOCKET:
24  *
25  * macro used to provide portability of code to windows sockets
26  */
27 #define SOCKET int
28 /**
29  * INVALID_SOCKET:
30  *
31  * macro used to provide portability of code to windows sockets
32  * the value to be used when the socket is not valid
33  */
34 #define INVALID_SOCKET (-1)
35 #endif
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /**
42  * ftpListCallback:
43  * @userData:  user provided data for the callback
44  * @filename:  the file name (including "->" when links are shown)
45  * @attrib:  the attribute string
46  * @owner:  the owner string
47  * @group:  the group string
48  * @size:  the file size
49  * @links:  the link count
50  * @year:  the year
51  * @month:  the month
52  * @day:  the day
53  * @hour:  the hour
54  * @minute:  the minute
55  *
56  * A callback for the xmlNanoFTPList command.
57  * Note that only one of year and day:minute are specified.
58  */
59 typedef void (*ftpListCallback) (void *userData,
60                                  const char *filename, const char *attrib,
61                                  const char *owner, const char *group,
62                                  unsigned long size, int links, int year,
63                                  const char *month, int day, int hour,
64                                  int minute);
65 /**
66  * ftpDataCallback:
67  * @userData: the user provided context
68  * @data: the data received
69  * @len: its size in bytes
70  *
71  * A callback for the xmlNanoFTPGet command.
72  */
73 typedef void (*ftpDataCallback) (void *userData,
74                                  const char *data,
75                                  int len);
76
77 /*
78  * Init
79  */
80 XMLPUBFUN void XMLCALL
81         xmlNanoFTPInit          (void);
82 XMLPUBFUN void XMLCALL
83         xmlNanoFTPCleanup       (void);
84
85 /*
86  * Creating/freeing contexts.
87  */
88 XMLPUBFUN void * XMLCALL
89         xmlNanoFTPNewCtxt       (const char *URL);
90 XMLPUBFUN void XMLCALL
91         xmlNanoFTPFreeCtxt      (void * ctx);
92 XMLPUBFUN void * XMLCALL
93         xmlNanoFTPConnectTo     (const char *server,
94                                  int port);
95 /*
96  * Opening/closing session connections.
97  */
98 XMLPUBFUN void * XMLCALL
99         xmlNanoFTPOpen          (const char *URL);
100 XMLPUBFUN int XMLCALL
101         xmlNanoFTPConnect       (void *ctx);
102 XMLPUBFUN int XMLCALL
103         xmlNanoFTPClose         (void *ctx);
104 XMLPUBFUN int XMLCALL
105         xmlNanoFTPQuit          (void *ctx);
106 XMLPUBFUN void XMLCALL
107         xmlNanoFTPScanProxy     (const char *URL);
108 XMLPUBFUN void XMLCALL
109         xmlNanoFTPProxy         (const char *host,
110                                  int port,
111                                  const char *user,
112                                  const char *passwd,
113                                  int type);
114 XMLPUBFUN int XMLCALL
115         xmlNanoFTPUpdateURL     (void *ctx,
116                                  const char *URL);
117
118 /*
119  * Rather internal commands.
120  */
121 XMLPUBFUN int XMLCALL
122         xmlNanoFTPGetResponse   (void *ctx);
123 XMLPUBFUN int XMLCALL
124         xmlNanoFTPCheckResponse (void *ctx);
125
126 /*
127  * CD/DIR/GET handlers.
128  */
129 XMLPUBFUN int XMLCALL
130         xmlNanoFTPCwd           (void *ctx,
131                                  const char *directory);
132 XMLPUBFUN int XMLCALL
133         xmlNanoFTPDele          (void *ctx,
134                                  const char *file);
135
136 XMLPUBFUN SOCKET XMLCALL
137         xmlNanoFTPGetConnection (void *ctx);
138 XMLPUBFUN int XMLCALL
139         xmlNanoFTPCloseConnection(void *ctx);
140 XMLPUBFUN int XMLCALL
141         xmlNanoFTPList          (void *ctx,
142                                  ftpListCallback callback,
143                                  void *userData,
144                                  const char *filename);
145 XMLPUBFUN SOCKET XMLCALL
146         xmlNanoFTPGetSocket     (void *ctx,
147                                  const char *filename);
148 XMLPUBFUN int XMLCALL
149         xmlNanoFTPGet           (void *ctx,
150                                  ftpDataCallback callback,
151                                  void *userData,
152                                  const char *filename);
153 XMLPUBFUN int XMLCALL
154         xmlNanoFTPRead          (void *ctx,
155                                  void *dest,
156                                  int len);
157
158 #ifdef __cplusplus
159 }
160 #endif
161 #endif /* LIBXML_FTP_ENABLED */
162 #endif /* __NANO_FTP_H__ */