nanoftp.h 3.7 KB

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