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