1
/*============================================================================
3
==============================================================================
4
This header file defines the interface between xmlrpc.c and its users,
7
Copyright information is at the end of the file.
8
============================================================================*/
10
#ifndef _XMLRPC_CLIENT_H_
11
#define _XMLRPC_CLIENT_H_ 1
15
#endif /* __cplusplus */
18
/*=========================================================================
19
** Initialization and Shutdown
20
**=========================================================================
21
** These routines initialize and terminate the XML-RPC client. If you're
22
** already using libwww on your own, you can pass
23
** XMLRPC_CLIENT_SKIP_LIBWWW_INIT to avoid initializing it twice.
26
#define XMLRPC_CLIENT_NO_FLAGS (0)
27
#define XMLRPC_CLIENT_SKIP_LIBWWW_INIT (1)
30
xmlrpc_client_init(int const flags,
31
const char * const appname,
32
const char * const appversion);
34
struct xmlrpc_clientparms {
35
const char * transport;
38
#define XMLRPC_CP_MEMBER_OFFSET(mbrname) \
39
((unsigned long)(char*)&((struct xmlrpc_clientparms *)0)->mbrname)
40
#define XMLRPC_CP_MEMBER_SIZE(mbrname) \
41
sizeof(((struct xmlrpc_clientparms *)0)->mbrname)
42
#define XMLRPC_CPSIZE(mbrname) \
43
(XMLRPC_CP_MEMBER_OFFSET(mbrname) + XMLRPC_CP_MEMBER_SIZE(mbrname))
45
/* XMLRPC_CPSIZE(xyz) is the minimum size a struct xmlrpc_clientparms
46
must be to include the 'xyz' member. This is essential to forward and
47
backward compatbility, as new members will be added to the end of the
48
struct in future releases. This is how the callee knows whether or
49
not the caller is new enough to have supplied a certain parameter.
53
xmlrpc_client_init2(xmlrpc_env * const env,
55
const char * const appname,
56
const char * const appversion,
57
struct xmlrpc_clientparms * const clientparms,
58
unsigned int const parm_size);
61
xmlrpc_client_cleanup(void);
64
xmlrpc_client_get_default_transport(xmlrpc_env * const env);
66
/*=========================================================================
67
** Required for both internal and external development.
68
**=========================================================================
70
/* A callback function to handle the response to an asynchronous call.
71
** If 'fault->fault_occurred' is true, then response will be NULL. All
72
** arguments except 'user_data' will be deallocated internally; please do
73
** not free any of them yourself.
74
** WARNING: param_array may (or may not) be NULL if fault->fault_occurred
75
** is true, and you set up the call using xmlrpc_client_call_asynch.
76
** WARNING: If asynchronous calls are still pending when the library is
77
** shut down, your handler may (or may not) be called with a fault. */
78
typedef void (*xmlrpc_response_handler) (const char *server_url,
79
const char *method_name,
80
xmlrpc_value *param_array,
83
xmlrpc_value *result);
86
/*=========================================================================
88
**=========================================================================
89
** We normally refer to servers by URL. But sometimes we need to do extra
90
** setup for particular servers. In that case, we can create an
91
** xmlrpc_server_info object, configure it in various ways, and call the
94
** (This interface is also designed to discourage further multiplication
95
** of xmlrpc_client_call APIs. We have enough of those already. Please
96
** add future options and flags using xmlrpc_server_info.)
99
typedef struct _xmlrpc_server_info xmlrpc_server_info;
101
/* Create a new server info record, pointing to the specified server. */
103
xmlrpc_server_info_new(xmlrpc_env * const env,
104
const char * const server_url);
106
/* Create a new server info record, with a copy of the old server. */
107
extern xmlrpc_server_info *
108
xmlrpc_server_info_copy(xmlrpc_env *env, xmlrpc_server_info *src_server);
110
/* Delete a server info record. */
112
xmlrpc_server_info_free (xmlrpc_server_info *server);
114
/* We support rudimentary basic authentication. This lets us talk to Zope
115
** servers and similar critters. When called, this routine makes a copy
116
** of all the authentication information and passes it to future requests.
117
** Only the most-recently-set authentication information is used.
118
** (In general, you shouldn't write XML-RPC servers which require this
119
** kind of authentication--it confuses many client implementations.)
120
** If we fail, leave the xmlrpc_server_info record unchanged. */
122
xmlrpc_server_info_set_basic_auth(xmlrpc_env * const envP,
123
xmlrpc_server_info * const serverP,
124
const char * const username,
125
const char * const password);
128
/*=========================================================================
129
** xmlrpc_client_call
130
**=========================================================================
131
** A synchronous XML-RPC client. Do not attempt to call any of these
132
** functions from inside an asynchronous callback!
136
xmlrpc_client_call(xmlrpc_env * const envP,
137
const char * const server_url,
138
const char * const method_name,
139
const char * const format,
143
xmlrpc_client_call_params (xmlrpc_env * const env,
144
const char * const server_url,
145
const char * const method_name,
146
xmlrpc_value * const param_array);
149
xmlrpc_client_call_server(xmlrpc_env * const envP,
150
xmlrpc_server_info * const server,
151
const char * const method_name,
152
const char * const format,
155
extern xmlrpc_value *
156
xmlrpc_client_call_server_params (xmlrpc_env *env,
157
xmlrpc_server_info *server,
159
xmlrpc_value *param_array);
162
/*=========================================================================
163
** xmlrpc_client_call_asynch
164
**=========================================================================
165
** An asynchronous XML-RPC client.
168
/* Make an asynchronous XML-RPC call. We make internal copies of all
169
** arguments except user_data, so you can deallocate them safely as soon
170
** as you return. Errors will be passed to the callback. You will need
171
** to run the event loop somehow; see below.
172
** WARNING: If an error occurs while building the argument, the
173
** response handler will be called with a NULL param_array. */
175
xmlrpc_client_call_asynch(const char * const server_url,
176
const char * const method_name,
177
xmlrpc_response_handler callback,
178
void * const user_data,
179
const char * const format,
182
/* As above, but use an xmlrpc_server_info object. The server object can be
183
** safely destroyed as soon as this function returns. */
185
xmlrpc_client_call_server_asynch(xmlrpc_server_info * const server,
186
const char * const method_name,
187
xmlrpc_response_handler callback,
188
void * const user_data,
189
const char * const format,
192
/* As above, but the parameter list is supplied as an xmlrpc_value
193
** containing an array.
196
xmlrpc_client_call_asynch_params(const char * const server_url,
197
const char * const method_name,
198
xmlrpc_response_handler callback,
199
void * const user_data,
200
xmlrpc_value * const paramArrayP);
202
/* As above, but use an xmlrpc_server_info object. The server object can be
203
** safely destroyed as soon as this function returns. */
205
xmlrpc_client_call_server_asynch_params(
206
xmlrpc_server_info * const server,
207
const char * const method_name,
208
xmlrpc_response_handler callback,
209
void * const user_data,
210
xmlrpc_value * const paramArrayP);
212
/*=========================================================================
213
** Event Loop Interface
214
**=========================================================================
215
** These functions can be used to run the XML-RPC event loop. If you
216
** don't like these, you can also run the libwww event loop directly.
219
/* Finish all outstanding asynchronous calls. Alternatively, the loop
220
** will exit if someone calls xmlrpc_client_event_loop_end. */
222
xmlrpc_client_event_loop_finish_asynch(void);
225
/* Finish all outstanding asynchronous calls. */
227
xmlrpc_client_event_loop_finish_asynch_timeout(timeout_t const milliseconds);
231
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
233
** Redistribution and use in source and binary forms, with or without
234
** modification, are permitted provided that the following conditions
236
** 1. Redistributions of source code must retain the above copyright
237
** notice, this list of conditions and the following disclaimer.
238
** 2. Redistributions in binary form must reproduce the above copyright
239
** notice, this list of conditions and the following disclaimer in the
240
** documentation and/or other materials provided with the distribution.
241
** 3. The name of the author may not be used to endorse or promote products
242
** derived from this software without specific prior written permission.
244
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
245
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
246
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
247
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
248
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
249
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
250
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
252
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
253
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259
#endif /* __cplusplus */
261
#endif /* _XMLRPC_CLIENT_H_ */