コード例 #1
0
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;
    int terminationRequested;  /* A boolean value */
    const char * error;

    if (argc-1 != 1) {
        fprintf(stderr, "You must specify 1 argument:  The TCP port number "
                "on which to listen for XML-RPC calls.  "
                "You specified %d.\n",  argc-1);
        exit(1);
    }

    AbyssInit(&error);
    
    xmlrpc_env_init(&env);

    registryP = xmlrpc_registry_new(&env);

    xmlrpc_registry_add_method3(&env, registryP, &methodInfo);

    xmlrpc_registry_set_shutdown(registryP,
                                 &requestShutdown, &terminationRequested);

    ServerCreate(&abyssServer, "XmlRpcServer", atoi(argv[1]), NULL, NULL);
    
    xmlrpc_server_abyss_set_handlers2(&abyssServer, "/RPC2", registryP);

    ServerInit(&abyssServer);

    setupSignalHandlers();

    terminationRequested = 0;

    while (!terminationRequested) {
        printf("Waiting for next RPC...\n");

        ServerRunOnce(&abyssServer);
            /* This waits for the next connection, accepts it, reads the
               HTTP POST request, executes the indicated RPC, and closes
               the connection.
            */
    }

    ServerFree(&abyssServer);

    AbyssTerm();

    return 0;
}
コード例 #2
0
static void *
xr_rpcListener (Server *svr)
{
    struct xmlrpc_method_info3 const methodInfo[] = {
       /* .methodName   	.methodFunction  	*/ 
	{ "svrping", 		&test_ping,		},
	/*
	{ "sys.abort", 		&xr_requestAbort,	},
	{ "sys.shutdown", 	&xr_requestShutdown,	}
	*/
    };
    register int i = 0;
    TServer abyssServer;
    xmlrpc_registry * registryP;
    xmlrpc_env env;
    const char * error;

    extern void xr_serverRunOnce ();
    extern int  xr_requestAbort ();


    AbyssInit (&error);				/* initialize		*/
    xmlrpc_env_init (&env);
    registryP = xmlrpc_registry_new (&env);


    if (SRVR_DEBUG)
	fprintf (stderr, "single_run_server rpcListener ....\n");

    /*  Setup a test ping method and install the special shutdown handlers.
     */
    for (i=0; i < 1; i++)
    	xmlrpc_registry_add_method3 (&env, registryP, &methodInfo[i]);

    /*  Set default shutdown method.
     */
    xmlrpc_registry_set_shutdown (registryP, &xr_requestShutdown, &svr_done);
    xr_addServerMethod ("sys.abort", xr_requestAbort, NULL);


    /*  Set the default method we'll use to dispatch calls.
     */
    svr->serverparm.enable_shutdown = (xmlrpc_bool) 1;
    xmlrpc_registry_set_default_method (&svr->env, 
        (svr->serverparm.registryP = svr->registry = registryP), 
        (xmlrpc_default_method) &xr_defaultMethod, svr);


    /*  Create the server instance.
     */
    ServerCreate (&abyssServer, "XmlRpcServer", 
	svr->serverparm.port_number, NULL, NULL);

    xmlrpc_server_abyss_set_handlers2 (&abyssServer, "/RPC2",
	svr->serverparm.registryP);

    ServerInit (&abyssServer);

#ifdef XR_SIGPIPE_IGN
    xr_setupSigpipeHandlers ();
#endif


    while (! svr_done ) {
        /*  This waits for the next connection, accepts it, reads the
         *  HTTP POST request, executes the indicated RPC, and closes
         *  the connection.
        ServerRunOnce (&abyssServer);
         */
 	//	ServerRunOnce(&abyssServer);
       (void) xr_serverRunOnce (&abyssServer);
    }

    ServerFree (&abyssServer);			/* shut down		*/
    AbyssTerm ();

    return ((void *) ERR);
}
コード例 #3
0
static void
termAbyss(void) {

    AbyssTerm();
}