nanoftp.h revision c5d64345cf19bfd72418eb0a837869b0462e9130
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 12c5d64345cf19bfd72418eb0a837869b0462e9130Daniel Veillard#if defined(WIN32) && defined(_MSC_VER) 13c5d64345cf19bfd72418eb0a837869b0462e9130Daniel Veillard#include <libxml/xmlwin32version.h> 14c5d64345cf19bfd72418eb0a837869b0462e9130Daniel Veillard#else 153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/xmlversion.h> 16c5d64345cf19bfd72418eb0a837869b0462e9130Daniel Veillard#endif 173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef LIBXML_FTP_ENABLED 183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus 203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorextern "C" { 213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif 223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/** 243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * ftpListCallback: 253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @userData: user provided data for the callback 263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @filename: the file name (including "->" when links are shown) 273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @attrib: the attribute string 283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @owner: the owner string 293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @group: the group string 303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @size: the file size 313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @links: the link count 323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @year: the year 333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @month: the month 343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @day: the day 353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @hour: the hour 363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @minute: the minute 373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * 383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * A callback for the xmlNanoFTPList command 393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Note that only one of year and day:minute are specified 403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylortypedef void (*ftpListCallback) (void *userData, 423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *filename, const char* attrib, 433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *owner, const char *group, 443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor unsigned long size, int links, int year, 453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *month, int day, int hour, 463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int minute); 473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/** 483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * ftpDataCallback: 49f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @userData: the user provided context 50f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @data: the data received 51f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * @len: its size in bytes 52f69bb4b5bf3df1982f63a331b02cd7187456492fDaniel Veillard * 533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * A callback for the xmlNanoFTPGet command 543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylortypedef void (*ftpDataCallback) (void *userData, const char *data, int len); 563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Init 593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid xmlNanoFTPInit (void); 613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid xmlNanoFTPCleanup (void); 623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Creating/freeing contexts 653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid * xmlNanoFTPNewCtxt (const char *URL); 673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid xmlNanoFTPFreeCtxt (void * ctx); 683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid * xmlNanoFTPConnectTo (const char *server, 693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int port); 703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Opening/closing session connections 723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid * xmlNanoFTPOpen (const char *URL); 743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPConnect (void *ctx); 753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPClose (void *ctx); 763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPQuit (void *ctx); 773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid xmlNanoFTPScanProxy (const char *URL); 783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid xmlNanoFTPProxy (const char *host, 793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int port, 803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *user, 813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *passwd, 823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int type); 833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPUpdateURL (void *ctx, 843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *URL); 853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Rathern internal commands 883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPGetResponse (void *ctx); 903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPCheckResponse (void *ctx); 913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* 933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * CD/DIR/GET handlers 943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */ 953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPCwd (void *ctx, 963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor char *directory); 973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPGetConnection (void *ctx); 993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPCloseConnection(void *ctx); 1003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPList (void *ctx, 1013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor ftpListCallback callback, 1023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *userData, 1033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor char *filename); 1043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPGetSocket (void *ctx, 1053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *filename); 1063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPGet (void *ctx, 1073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor ftpDataCallback callback, 1083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *userData, 1093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor const char *filename); 1103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint xmlNanoFTPRead (void *ctx, 1113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor void *dest, 1123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor int len); 1133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor 1143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef __cplusplus 1153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor} 1163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif /* LIBXML_FTP_ENABLED */ 1173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif 1183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif /* __NANO_FTP_H__ */ 119