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 */ 345706b6d8767e3c3f2e5b277b54e1af68035bc111Daniel Richard G#undef INVALID_SOCKET 35f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#define INVALID_SOCKET (-1) 36f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer#endif 37f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer 383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus 393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorextern "C" { 403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif 413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/** 43f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer * ftpListCallback: 443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @userData: user provided data for the callback 453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @filename: the file name (including "->" when links are shown) 463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @attrib: the attribute string 473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @owner: the owner string 483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @group: the group string 493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @size: the file size 503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @links: the link count 513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @year: the year 523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @month: the month 533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @day: the day 543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @hour: the hour 553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @minute: the minute 563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * 5761f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * A callback for the xmlNanoFTPList command. 5861f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Note that only one of year and day:minute are specified. 593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylortypedef void (*ftpListCallback) (void *userData, 61963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard const char *filename, const char *attrib, 623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *owner, const char *group, 633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor unsigned long size, int links, int year, 643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *month, int day, int hour, 653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int minute); 663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/** 67f99d222316e1219aa8b95220f6918e6c7018e174Ozkan Sezer * ftpDataCallback: 68f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @userData: the user provided context 69f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @data: the data received 70f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @len: its size in bytes 71f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * 7261f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * A callback for the xmlNanoFTPGet command. 733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 74963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillardtypedef void (*ftpDataCallback) (void *userData, 75963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard const char *data, 76963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard int len); 773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Init 803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 8176874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void XMLCALL 8276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPInit (void); 83f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL 8476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCleanup (void); 853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 8761f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Creating/freeing contexts. 883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 89f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void * XMLCALL 9076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPNewCtxt (const char *URL); 91f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL 9276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPFreeCtxt (void * ctx); 93f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void * XMLCALL 9476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPConnectTo (const char *server, 953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int port); 963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 9761f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Opening/closing session connections. 983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 99f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void * XMLCALL 10076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPOpen (const char *URL); 101f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 10276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPConnect (void *ctx); 103f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 10476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPClose (void *ctx); 105f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 10676874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPQuit (void *ctx); 107f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL 10876874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPScanProxy (const char *URL); 109f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN void XMLCALL 11076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPProxy (const char *host, 1113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int port, 1123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *user, 1133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *passwd, 1143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int type); 115f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 11676874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPUpdateURL (void *ctx, 1173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *URL); 1183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 1193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 12061f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Rather internal commands. 1213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 122f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 12376874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGetResponse (void *ctx); 124f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 12576874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCheckResponse (void *ctx); 1263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 1273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 12861f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * CD/DIR/GET handlers. 1293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 130f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 13176874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCwd (void *ctx, 13234099b403124601d9cd4bde0846a637bf8952ceaDaniel Veillard const char *directory); 133f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 13476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPDele (void *ctx, 13534099b403124601d9cd4bde0846a637bf8952ceaDaniel Veillard const char *file); 1363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 137f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN SOCKET XMLCALL 13876874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGetConnection (void *ctx); 139f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 14076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCloseConnection(void *ctx); 141f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 14276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPList (void *ctx, 1433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor ftpListCallback callback, 1443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *userData, 14534099b403124601d9cd4bde0846a637bf8952ceaDaniel Veillard const char *filename); 146f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN SOCKET XMLCALL 14776874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGetSocket (void *ctx, 1483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *filename); 149f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 15076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGet (void *ctx, 1513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor ftpDataCallback callback, 1523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *userData, 1533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *filename); 154f99d222316e1219aa8b95220f6918e6c7018e174Ozkan SezerXMLPUBFUN int XMLCALL 15576874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPRead (void *ctx, 1563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *dest, 1573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int len); 1583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 1593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus 1603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor} 1613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif 162a2351322c89608d09ce1a99e5eccd62d00c79890Daniel Veillard#endif /* LIBXML_FTP_ENABLED */ 1633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif /* __NANO_FTP_H__ */ 164