git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8545 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2008-05-23 20:56:24 +00:00
parent d2290cfa3a
commit 00654d880e
338 changed files with 55725 additions and 19400 deletions

View File

@@ -2,6 +2,11 @@
#include <stdlib.h>
#include <stdio.h>
#ifdef WIN32
# include <windows.h>
#else
# include <unistd.h>
#endif
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/server.h>
@@ -9,23 +14,38 @@
#include "config.h" /* information about this build environment */
#ifdef WIN32
#define SLEEP(seconds) SleepEx(seconds * 1000, 1);
#else
#define SLEEP(seconds) sleep(seconds);
#endif
static xmlrpc_value *
sample_add(xmlrpc_env * const env,
xmlrpc_value * const param_array,
void * const user_data ATTR_UNUSED) {
sample_add(xmlrpc_env * const envP,
xmlrpc_value * const paramArrayP,
void * const serverInfo ATTR_UNUSED,
void * const channelInfo ATTR_UNUSED) {
xmlrpc_int32 x, y, z;
/* Parse our argument array. */
xmlrpc_decompose_value(env, param_array, "(ii)", &x, &y);
if (env->fault_occurred)
xmlrpc_decompose_value(envP, paramArrayP, "(ii)", &x, &y);
if (envP->fault_occurred)
return NULL;
/* Add our two numbers. */
z = x + y;
/* Sometimes, make it look hard (so client can see what it's like
to do an RPC that takes a while).
*/
if (y == 1)
SLEEP(3);
/* Return our result. */
return xmlrpc_build_value(env, "i", z);
return xmlrpc_build_value(envP, "i", z);
}
@@ -41,7 +61,8 @@ main(int const argc,
if (argc-1 != 1) {
fprintf(stderr, "You must specify 1 argument: The TCP port "
"number on which the server will accept connections "
"for RPCs. You specified %d arguments.\n", argc-1);
"for RPCs (8080 is a common choice). "
"You specified %d arguments.\n", argc-1);
exit(1);
}
@@ -49,17 +70,17 @@ main(int const argc,
registryP = xmlrpc_registry_new(&env);
xmlrpc_registry_add_method(
&env, registryP, NULL, "sample.add", &sample_add, NULL);
xmlrpc_registry_add_method2(
&env, registryP, "sample.add", &sample_add, NULL, NULL, NULL);
/* In the modern form of the Abyss API, we supply parameters in memory
like a normal API. We select the modern form by setting
config_file_name to NULL:
*/
serverparm.config_file_name = NULL;
serverparm.registryP = registryP;
serverparm.port_number = atoi(argv[1]);
serverparm.log_file_name = "/tmp/xmlrpc_log";
serverparm.registryP = registryP;
serverparm.port_number = atoi(argv[1]);
serverparm.log_file_name = "/tmp/xmlrpc_log";
printf("Running XML-RPC server...\n");