nanoftp.h revision 4c2e7c651f6c2f0d1a74f350cbda95f7df3e7017
13473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
2be5869729a416032a4abb5a65430d25831828f75Daniel Veillard * Summary: minimal FTP implementation
3be5869729a416032a4abb5a65430d25831828f75Daniel Veillard * Description: minimal FTP implementation allowing to fetch resources
4be5869729a416032a4abb5a65430d25831828f75Daniel Veillard *              like external subset.
53473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
6be5869729a416032a4abb5a65430d25831828f75Daniel Veillard * Copy: See Copyright for the status of this software.
73473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
8be5869729a416032a4abb5a65430d25831828f75Daniel Veillard * Author: Daniel Veillard
93473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
10f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer
113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifndef __NANO_FTP_H__
123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#define __NANO_FTP_H__
133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/xmlversion.h>
157ae91bcd9e94946a7be41290cb67ffc9c2cf0a9fIgor Zlatkovic
163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef LIBXML_FTP_ENABLED
173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
18f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer/* Needed for portability to Windows 64 bits */
19f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#if defined(__MINGW32__) || defined(_WIN32_WCE)
20f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#include <winsock2.h>
21f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#else
224c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard/**
234c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard * SOCKET:
244c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard *
254c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard * macro used to provide portability of code to windows sockets
264c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard */
27f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#define SOCKET int
284c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard/**
294c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard * INVALID_SOCKET:
304c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard *
314c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard * macro used to provide portability of code to windows sockets
324c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard * the value to be used when the socket is not valid
334c2e7c651f6c2f0d1a74f350cbda95f7df3e7017Daniel Veillard */
34f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#define INVALID_SOCKET (-1)
35f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#endif
36f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer
373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus
383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorextern "C" {
393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
42f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer * ftpListCallback:
433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @userData:  user provided data for the callback
443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @filename:  the file name (including "->" when links are shown)
453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @attrib:  the attribute string
463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @owner:  the owner string
473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @group:  the group string
483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @size:  the file size
493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @links:  the link count
503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @year:  the year
513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @month:  the month
523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @day:  the day
533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @hour:  the hour
543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @minute:  the minute
553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
5661f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * A callback for the xmlNanoFTPList command.
5761f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Note that only one of year and day:minute are specified.
583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylortypedef void (*ftpListCallback) (void *userData,
60963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard	                         const char *filename, const char *attrib,
613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	                         const char *owner, const char *group,
623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 unsigned long size, int links, int year,
633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 const char *month, int day, int hour,
643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 int minute);
653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
66f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer * ftpDataCallback:
67f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @userData: the user provided context
68f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @data: the data received
69f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @len: its size in bytes
70f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard *
7161f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * A callback for the xmlNanoFTPGet command.
723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
73963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillardtypedef void (*ftpDataCallback) (void *userData,
74963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard				 const char *data,
75963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard				 int len);
763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Init
793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
8076874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void XMLCALL
8176874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPInit		(void);
82f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL
8376874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPCleanup	(void);
843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
8661f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Creating/freeing contexts.
873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
88f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void * XMLCALL
8976874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPNewCtxt	(const char *URL);
90f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL
9176874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPFreeCtxt	(void * ctx);
92f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void * XMLCALL
9376874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPConnectTo	(const char *server,
943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 int port);
953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
9661f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Opening/closing session connections.
973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
98f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void * XMLCALL
9976874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPOpen		(const char *URL);
100f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
10176874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPConnect	(void *ctx);
102f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
10376874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPClose		(void *ctx);
104f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
10576874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPQuit		(void *ctx);
106f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL
10776874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPScanProxy	(const char *URL);
108f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL
10976874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPProxy		(const char *host,
1103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 int port,
1113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 const char *user,
1123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 const char *passwd,
1133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 int type);
114f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
11576874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPUpdateURL	(void *ctx,
1163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 const char *URL);
1173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
11961f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Rather internal commands.
1203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
121f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
12276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPGetResponse	(void *ctx);
123f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
12476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPCheckResponse	(void *ctx);
1253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
12761f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * CD/DIR/GET handlers.
1283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
129f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
13076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPCwd		(void *ctx,
13134099b403124601d9cd4bde0846a637bf8952ceaDaniel Veillard				 const char *directory);
132f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
13376874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPDele		(void *ctx,
13434099b403124601d9cd4bde0846a637bf8952ceaDaniel Veillard				 const char *file);
1353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
136f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN SOCKET XMLCALL
13776874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPGetConnection	(void *ctx);
138f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
13976874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPCloseConnection(void *ctx);
140f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
14176874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPList		(void *ctx,
1423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 ftpListCallback callback,
1433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 void *userData,
14434099b403124601d9cd4bde0846a637bf8952ceaDaniel Veillard				 const char *filename);
145f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN SOCKET XMLCALL
14676874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPGetSocket	(void *ctx,
1473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 const char *filename);
148f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
14976874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPGet		(void *ctx,
1503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 ftpDataCallback callback,
1513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 void *userData,
1523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 const char *filename);
153f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL
15476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic	xmlNanoFTPRead		(void *ctx,
1553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 void *dest,
1563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				 int len);
1573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus
1593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
1603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
161a2351322c89608d09ce1a99e5eccd62d00c79890Daniel Veillard#endif /* LIBXML_FTP_ENABLED */
1623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif /* __NANO_FTP_H__ */
163