• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(_WIN32) && !defined(__CYGWIN__)
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 #undef  INVALID_SOCKET
35 #define INVALID_SOCKET (-1)
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /**
43  * ftpListCallback:
44  * @userData:  user provided data for the callback
45  * @filename:  the file name (including "->" when links are shown)
46  * @attrib:  the attribute string
47  * @owner:  the owner string
48  * @group:  the group string
49  * @size:  the file size
50  * @links:  the link count
51  * @year:  the year
52  * @month:  the month
53  * @day:  the day
54  * @hour:  the hour
55  * @minute:  the minute
56  *
57  * A callback for the xmlNanoFTPList command.
58  * Note that only one of year and day:minute are specified.
59  */
60 typedef void (*ftpListCallback) (void *userData,
61 	                         const char *filename, const char *attrib,
62 	                         const char *owner, const char *group,
63 				 unsigned long size, int links, int year,
64 				 const char *month, int day, int hour,
65 				 int minute);
66 /**
67  * ftpDataCallback:
68  * @userData: the user provided context
69  * @data: the data received
70  * @len: its size in bytes
71  *
72  * A callback for the xmlNanoFTPGet command.
73  */
74 typedef void (*ftpDataCallback) (void *userData,
75 				 const char *data,
76 				 int len);
77 
78 /*
79  * Init
80  */
81 XMLPUBFUN void XMLCALL
82 	xmlNanoFTPInit		(void);
83 XMLPUBFUN void XMLCALL
84 	xmlNanoFTPCleanup	(void);
85 
86 /*
87  * Creating/freeing contexts.
88  */
89 XMLPUBFUN void * XMLCALL
90 	xmlNanoFTPNewCtxt	(const char *URL);
91 XMLPUBFUN void XMLCALL
92 	xmlNanoFTPFreeCtxt	(void * ctx);
93 XMLPUBFUN void * XMLCALL
94 	xmlNanoFTPConnectTo	(const char *server,
95 				 int port);
96 /*
97  * Opening/closing session connections.
98  */
99 XMLPUBFUN void * XMLCALL
100 	xmlNanoFTPOpen		(const char *URL);
101 XMLPUBFUN int XMLCALL
102 	xmlNanoFTPConnect	(void *ctx);
103 XMLPUBFUN int XMLCALL
104 	xmlNanoFTPClose		(void *ctx);
105 XMLPUBFUN int XMLCALL
106 	xmlNanoFTPQuit		(void *ctx);
107 XMLPUBFUN void XMLCALL
108 	xmlNanoFTPScanProxy	(const char *URL);
109 XMLPUBFUN void XMLCALL
110 	xmlNanoFTPProxy		(const char *host,
111 				 int port,
112 				 const char *user,
113 				 const char *passwd,
114 				 int type);
115 XMLPUBFUN int XMLCALL
116 	xmlNanoFTPUpdateURL	(void *ctx,
117 				 const char *URL);
118 
119 /*
120  * Rather internal commands.
121  */
122 XMLPUBFUN int XMLCALL
123 	xmlNanoFTPGetResponse	(void *ctx);
124 XMLPUBFUN int XMLCALL
125 	xmlNanoFTPCheckResponse	(void *ctx);
126 
127 /*
128  * CD/DIR/GET handlers.
129  */
130 XMLPUBFUN int XMLCALL
131 	xmlNanoFTPCwd		(void *ctx,
132 				 const char *directory);
133 XMLPUBFUN int XMLCALL
134 	xmlNanoFTPDele		(void *ctx,
135 				 const char *file);
136 
137 XMLPUBFUN SOCKET XMLCALL
138 	xmlNanoFTPGetConnection	(void *ctx);
139 XMLPUBFUN int XMLCALL
140 	xmlNanoFTPCloseConnection(void *ctx);
141 XMLPUBFUN int XMLCALL
142 	xmlNanoFTPList		(void *ctx,
143 				 ftpListCallback callback,
144 				 void *userData,
145 				 const char *filename);
146 XMLPUBFUN SOCKET XMLCALL
147 	xmlNanoFTPGetSocket	(void *ctx,
148 				 const char *filename);
149 XMLPUBFUN int XMLCALL
150 	xmlNanoFTPGet		(void *ctx,
151 				 ftpDataCallback callback,
152 				 void *userData,
153 				 const char *filename);
154 XMLPUBFUN int XMLCALL
155 	xmlNanoFTPRead		(void *ctx,
156 				 void *dest,
157 				 int len);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 #endif /* LIBXML_FTP_ENABLED */
163 #endif /* __NANO_FTP_H__ */
164