nanoftp.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. #ifndef __NANO_FTP_H__
  11. #define __NANO_FTP_H__
  12. #include <libxml/xmlversion.h>
  13. #ifdef LIBXML_FTP_ENABLED
  14. /* Needed for portability to Windows 64 bits */
  15. #if defined(__MINGW32__) || defined(_WIN32_WCE)
  16. #include <winsock2.h>
  17. #else
  18. /**
  19. * SOCKET:
  20. *
  21. * macro used to provide portability of code to windows sockets
  22. */
  23. #define SOCKET int
  24. /**
  25. * INVALID_SOCKET:
  26. *
  27. * macro used to provide portability of code to windows sockets
  28. * the value to be used when the socket is not valid
  29. */
  30. #define INVALID_SOCKET (-1)
  31. #endif
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /**
  36. * ftpListCallback:
  37. * @userData: user provided data for the callback
  38. * @filename: the file name (including "->" when links are shown)
  39. * @attrib: the attribute string
  40. * @owner: the owner string
  41. * @group: the group string
  42. * @size: the file size
  43. * @links: the link count
  44. * @year: the year
  45. * @month: the month
  46. * @day: the day
  47. * @hour: the hour
  48. * @minute: the minute
  49. *
  50. * A callback for the xmlNanoFTPList command.
  51. * Note that only one of year and day:minute are specified.
  52. */
  53. typedef void (*ftpListCallback) (void *userData,
  54. const char *filename, const char *attrib,
  55. const char *owner, const char *group,
  56. unsigned long size, int links, int year,
  57. const char *month, int day, int hour,
  58. int minute);
  59. /**
  60. * ftpDataCallback:
  61. * @userData: the user provided context
  62. * @data: the data received
  63. * @len: its size in bytes
  64. *
  65. * A callback for the xmlNanoFTPGet command.
  66. */
  67. typedef void (*ftpDataCallback) (void *userData,
  68. const char *data,
  69. int len);
  70. /*
  71. * Init
  72. */
  73. XMLPUBFUN void XMLCALL
  74. xmlNanoFTPInit (void);
  75. XMLPUBFUN void XMLCALL
  76. xmlNanoFTPCleanup (void);
  77. /*
  78. * Creating/freeing contexts.
  79. */
  80. XMLPUBFUN void * XMLCALL
  81. xmlNanoFTPNewCtxt (const char *URL);
  82. XMLPUBFUN void XMLCALL
  83. xmlNanoFTPFreeCtxt (void * ctx);
  84. XMLPUBFUN void * XMLCALL
  85. xmlNanoFTPConnectTo (const char *server,
  86. int port);
  87. /*
  88. * Opening/closing session connections.
  89. */
  90. XMLPUBFUN void * XMLCALL
  91. xmlNanoFTPOpen (const char *URL);
  92. XMLPUBFUN int XMLCALL
  93. xmlNanoFTPConnect (void *ctx);
  94. XMLPUBFUN int XMLCALL
  95. xmlNanoFTPClose (void *ctx);
  96. XMLPUBFUN int XMLCALL
  97. xmlNanoFTPQuit (void *ctx);
  98. XMLPUBFUN void XMLCALL
  99. xmlNanoFTPScanProxy (const char *URL);
  100. XMLPUBFUN void XMLCALL
  101. xmlNanoFTPProxy (const char *host,
  102. int port,
  103. const char *user,
  104. const char *passwd,
  105. int type);
  106. XMLPUBFUN int XMLCALL
  107. xmlNanoFTPUpdateURL (void *ctx,
  108. const char *URL);
  109. /*
  110. * Rather internal commands.
  111. */
  112. XMLPUBFUN int XMLCALL
  113. xmlNanoFTPGetResponse (void *ctx);
  114. XMLPUBFUN int XMLCALL
  115. xmlNanoFTPCheckResponse (void *ctx);
  116. /*
  117. * CD/DIR/GET handlers.
  118. */
  119. XMLPUBFUN int XMLCALL
  120. xmlNanoFTPCwd (void *ctx,
  121. const char *directory);
  122. XMLPUBFUN int XMLCALL
  123. xmlNanoFTPDele (void *ctx,
  124. const char *file);
  125. XMLPUBFUN SOCKET XMLCALL
  126. xmlNanoFTPGetConnection (void *ctx);
  127. XMLPUBFUN int XMLCALL
  128. xmlNanoFTPCloseConnection(void *ctx);
  129. XMLPUBFUN int XMLCALL
  130. xmlNanoFTPList (void *ctx,
  131. ftpListCallback callback,
  132. void *userData,
  133. const char *filename);
  134. XMLPUBFUN SOCKET XMLCALL
  135. xmlNanoFTPGetSocket (void *ctx,
  136. const char *filename);
  137. XMLPUBFUN int XMLCALL
  138. xmlNanoFTPGet (void *ctx,
  139. ftpDataCallback callback,
  140. void *userData,
  141. const char *filename);
  142. XMLPUBFUN int XMLCALL
  143. xmlNanoFTPRead (void *ctx,
  144. void *dest,
  145. int len);
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif /* LIBXML_FTP_ENABLED */
  150. #endif /* __NANO_FTP_H__ */