1 /* A simple standalone XML-RPC server written in C. */
6 #include <xmlrpc-c/base.h>
7 #include <xmlrpc-c/server.h>
8 #include <xmlrpc-c/server_cgi.h>
10 #include "config.h" /* information about this build environment */
13 sample_add(xmlrpc_env * const env,
14 xmlrpc_value * const param_array,
15 void * const user_data ATTR_UNUSED) {
19 /* Parse our argument array. */
20 xmlrpc_decompose_value(env, param_array, "(ii)", &x, &y);
21 if (env->fault_occurred)
24 /* Add our two numbers. */
27 /* Return our result. */
28 return xmlrpc_build_value(env, "i", z);
35 const char ** const argv) {
37 xmlrpc_registry * registryP;
40 if (argc-1 > 0 && argv==argv) {
41 fprintf(stderr, "There are no arguments to a CGI script\n");
45 xmlrpc_env_init(&env);
47 registryP = xmlrpc_registry_new(&env);
49 xmlrpc_registry_add_method(
50 &env, registryP, NULL, "sample.add", &sample_add, NULL);
52 xmlrpc_server_cgi_process_call(registryP);
54 xmlrpc_registry_free(registryP);