nanoftp.h revision 76874e4516a1d7b467d400604f8aef77be015727
13473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 23473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * nanohttp.c: minimalist FTP implementation to fetch external subsets. 33473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * 43473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * See Copyright for the status of this software. 53473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * 6c5d64345cf19bfd72418eb0a837869b0462e9130Daniel Veillard * daniel@veillard.com 73473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 83473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 93473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifndef __NANO_FTP_H__ 103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#define __NANO_FTP_H__ 113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/xmlversion.h> 137ae91bcd9e94946a7be41290cb67ffc9c2cf0a9fIgor Zlatkovic 143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef LIBXML_FTP_ENABLED 153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus 173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorextern "C" { 183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif 193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/** 213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * ftpListCallback: 223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @userData: user provided data for the callback 233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @filename: the file name (including "->" when links are shown) 243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @attrib: the attribute string 253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @owner: the owner string 263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @group: the group string 273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @size: the file size 283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @links: the link count 293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @year: the year 303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @month: the month 313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @day: the day 323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @hour: the hour 333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @minute: the minute 343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * 3561f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * A callback for the xmlNanoFTPList command. 3661f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Note that only one of year and day:minute are specified. 373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylortypedef void (*ftpListCallback) (void *userData, 39963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard const char *filename, const char *attrib, 403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *owner, const char *group, 413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor unsigned long size, int links, int year, 423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *month, int day, int hour, 433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int minute); 443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/** 453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * ftpDataCallback: 46f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @userData: the user provided context 47f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @data: the data received 48f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @len: its size in bytes 49f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * 5061f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * A callback for the xmlNanoFTPGet command. 513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 52963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillardtypedef void (*ftpDataCallback) (void *userData, 53963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard const char *data, 54963d2ae41574066f9b44bcae610dd280c1e57dd8Daniel Veillard int len); 553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Init 583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 5976874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void XMLCALL 6076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPInit (void); 6176874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void XMLCALL 6276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCleanup (void); 633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 6561f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Creating/freeing contexts. 663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 6776874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void * XMLCALL 6876874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPNewCtxt (const char *URL); 6976874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void XMLCALL 7076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPFreeCtxt (void * ctx); 7176874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void * XMLCALL 7276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPConnectTo (const char *server, 733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int port); 743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 7561f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Opening/closing session connections. 763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 7776874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void * XMLCALL 7876874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPOpen (const char *URL); 7976874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 8076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPConnect (void *ctx); 8176874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 8276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPClose (void *ctx); 8376874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 8476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPQuit (void *ctx); 8576874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void XMLCALL 8676874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPScanProxy (const char *URL); 8776874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN void XMLCALL 8876874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPProxy (const char *host, 893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int port, 903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *user, 913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *passwd, 923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int type); 9376874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 9476874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPUpdateURL (void *ctx, 953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *URL); 963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 9861f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * Rather internal commands. 993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 10076874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 10176874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGetResponse (void *ctx); 10276874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 10376874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCheckResponse (void *ctx); 1043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 1053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 10661f261749f44d6e6f938441598bc724cd1375c51Daniel Veillard * CD/DIR/GET handlers. 1073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 10876874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 10976874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCwd (void *ctx, 1103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor char *directory); 11176874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 11276874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPDele (void *ctx, 1136c73cb8b67f3332b6bd2b2ff0480482770713838Daniel Veillard char *file); 1143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 11576874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 11676874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGetConnection (void *ctx); 11776874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 11876874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPCloseConnection(void *ctx); 11976874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 12076874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPList (void *ctx, 1213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor ftpListCallback callback, 1223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *userData, 1233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor char *filename); 12476874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 12576874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGetSocket (void *ctx, 1263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *filename); 12776874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 12876874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPGet (void *ctx, 1293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor ftpDataCallback callback, 1303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *userData, 1313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *filename); 13276874e4516a1d7b467d400604f8aef77be015727Igor ZlatkovicXMLPUBFUN int XMLCALL 13376874e4516a1d7b467d400604f8aef77be015727Igor Zlatkovic xmlNanoFTPRead (void *ctx, 1343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *dest, 1353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int len); 1363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 1373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus 1383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor} 1393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif /* LIBXML_FTP_ENABLED */ 1403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif 1413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif /* __NANO_FTP_H__ */ 142