|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define _XOPEN_SOURCE 600 |
|
|
#define WIN32_LEAN_AND_MEAN |
|
|
|
|
|
#include <stdlib.h> |
|
|
#include <stdio.h> |
|
|
#include <signal.h> |
|
|
#ifndef _WIN32 |
|
|
# include <unistd.h> |
|
|
#endif |
|
|
|
|
|
#include <xmlrpc-c/base.h> |
|
|
#include <xmlrpc-c/abyss.h> |
|
|
#include <xmlrpc-c/server.h> |
|
|
#include <xmlrpc-c/server_abyss.h> |
|
|
|
|
|
#include "config.h" |
|
|
|
|
|
|
|
|
static void |
|
|
setupSignalHandlers(void) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32 |
|
|
struct sigaction mysigaction; |
|
|
|
|
|
sigemptyset(&mysigaction.sa_mask); |
|
|
mysigaction.sa_flags = 0; |
|
|
mysigaction.sa_handler = SIG_IGN; |
|
|
sigaction(SIGPIPE, &mysigaction, NULL); |
|
|
#endif |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static xmlrpc_value * |
|
|
sample_add(xmlrpc_env * const envP, |
|
|
xmlrpc_value * const paramArrayP, |
|
|
void * const serverInfo, |
|
|
void * const channelInfo) { |
|
|
|
|
|
xmlrpc_int x, y, z; |
|
|
|
|
|
|
|
|
xmlrpc_decompose_value(envP, paramArrayP, "(ii)", &x, &y); |
|
|
if (envP->fault_occurred) |
|
|
return NULL; |
|
|
|
|
|
|
|
|
z = x + y; |
|
|
|
|
|
|
|
|
return xmlrpc_build_value(envP, "i", z); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
main(int const argc, |
|
|
const char ** const argv) { |
|
|
|
|
|
struct xmlrpc_method_info3 const methodInfo = { |
|
|
.methodName = "sample.add", |
|
|
.methodFunction = &sample_add, |
|
|
.serverInfo = NULL |
|
|
}; |
|
|
TServer abyssServer; |
|
|
xmlrpc_registry * registryP; |
|
|
xmlrpc_env env; |
|
|
|
|
|
if (argc-1 != 0) { |
|
|
fprintf(stderr, "There are no arguments. You must supply a " |
|
|
"bound socket on which to listen for client connections " |
|
|
"as Standard Input\n"); |
|
|
if (argv) {} |
|
|
exit(1); |
|
|
} |
|
|
xmlrpc_env_init(&env); |
|
|
|
|
|
registryP = xmlrpc_registry_new(&env); |
|
|
|
|
|
xmlrpc_registry_add_method3(&env, registryP, &methodInfo); |
|
|
|
|
|
ServerCreateNoAccept(&abyssServer, "XmlRpcServer", NULL, NULL); |
|
|
|
|
|
xmlrpc_server_abyss_set_handlers(&abyssServer, registryP); |
|
|
|
|
|
setupSignalHandlers(); |
|
|
|
|
|
ServerRunConn(&abyssServer, STDIN_FILENO); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ServerFree(&abyssServer); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|