void launch(int port, struct ExperimentServer handlers){ xmlrpc_server_abyss_parms serverparm; xmlrpc_registry * registryP; xmlrpc_env env; weblab_handlers.is_up_and_running = handlers.is_up_and_running; weblab_handlers.start_experiment = handlers.start_experiment; weblab_handlers.send_command = handlers.send_command; weblab_handlers.send_file = handlers.send_file; weblab_handlers.dispose = handlers.dispose; xmlrpc_env_init(&env); registryP = xmlrpc_registry_new(&env); xmlrpc_registry_add_method( &env, registryP, NULL, "Util.test_me", &weblab_xmlrpc_test_me, NULL); xmlrpc_registry_add_method( &env, registryP, NULL, "Util.is_up_and_running", &weblab_xmlrpc_is_up_and_running, NULL); xmlrpc_registry_add_method( &env, registryP, NULL, "Util.start_experiment", &weblab_xmlrpc_start_experiment, NULL); xmlrpc_registry_add_method( &env, registryP, NULL, "Util.send_command", &weblab_xmlrpc_send_command_to_device, NULL); xmlrpc_registry_add_method( &env, registryP, NULL, "Util.send_file", &weblab_xmlrpc_send_file_to_device, NULL); xmlrpc_registry_add_method( &env, registryP, NULL, "Util.dispose", &weblab_xmlrpc_dispose, NULL); serverparm.config_file_name = NULL; serverparm.registryP = registryP; serverparm.port_number = port; serverparm.log_file_name = "xmlrpc_log"; printf("Running XML-RPC server on port %i...\n", port); xmlrpc_server_abyss(&env, &serverparm, XMLRPC_APSIZE(log_file_name)); }
/************************************** * XmlHandler * A�ade un metodo *************************************/ int XmlHandler::AddMethod(const char *name,xmlrpc_method method,void *user_data) { xmlrpc_env env; //Build the enviroment xmlrpc_env_init(&env); //Add Methods xmlrpc_registry_add_method(&env, registry, NULL, name, method, user_data); //xmlrpc_registry_add_method_w_doc( &env, registry, NULL, method_name, method, user_data, signature, help); //Salimos return !env.fault_occurred; }
static void run_rpc_server(xmlrpc_env *env, unsigned int port) { xmlrpc_server_abyss_parms serverparm; xmlrpc_registry * registryP; memset(&serverparm, 0, sizeof(serverparm)); registryP = xmlrpc_registry_new(env); xmlrpc_registry_add_method(env, registryP, NULL, "add_flow_destination", &add_flow_destination, NULL); xmlrpc_registry_add_method(env, registryP, NULL, "add_flow_source", &add_flow_source, NULL); xmlrpc_registry_add_method(env, registryP, NULL, "start_flows", &start_flows, NULL); xmlrpc_registry_add_method(env, registryP, NULL, "get_reports", &method_get_reports, NULL); xmlrpc_registry_add_method(env, registryP, NULL, "stop_flow", &method_stop_flow, NULL); xmlrpc_registry_add_method(env, registryP, NULL, "get_version", &method_get_version, NULL); xmlrpc_registry_add_method(env, registryP, NULL, "get_status", &method_get_status, 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.socket_bound = 1; serverparm.log_file_name = NULL; /*"/tmp/xmlrpc_log";*/ /* Increase HTTP keep-alive duration. Using defaults the amount of * sockets in TIME_WAIT state would become too high. */ serverparm.keepalive_timeout = 60; serverparm.keepalive_max_conn = 1000; /* Disable introspection */ serverparm.dont_advertise = 1; logging_log(LOG_NOTICE, "Running XML-RPC server on port %u", port); printf("Running XML-RPC server...\n"); serverparm.socket_handle = bind_rpc_server(rpc_bind_addr, port); xmlrpc_server_abyss(env, &serverparm, XMLRPC_APSIZE(socket_handle)); if (env->fault_occurred) { logging_log(LOG_ALERT, "XML-RPC Fault: %s (%d)\n", env->fault_string, env->fault_code); } /* xmlrpc_server_abyss() never returns */ }
int rcd_rpc_register_method(const char *method_name, xmlrpc_method method, const char *privilege_str, gpointer user_data) { xmlrpc_env env; RCDPrivileges priv; RCDRPCMethodInfo *info; if (!registry) rcd_rpc_init (); rc_debug (RC_DEBUG_LEVEL_DEBUG, "Registering method %s", method_name); if (privilege_str == NULL) privilege_str = ""; priv = rcd_privileges_from_string (privilege_str); xmlrpc_env_init(&env); xmlrpc_registry_add_method( &env, registry, NULL, (char *) method_name, method, user_data); if (env.fault_occurred) { rc_debug (RC_DEBUG_LEVEL_ERROR, "Unable to add \"%s\" method: %s (%d)", method_name, env.fault_string, env.fault_code); return -1; } xmlrpc_env_clean(&env); info = g_new0 (RCDRPCMethodInfo, 1); info->method_name = method_name; info->method = method; info->req_privs = priv; g_hash_table_insert (method_info_hash, (char *) method_name, info); return 0; } /* rcd_rpc_register_method */
int __cdecl wmain( int argc, wchar_t * argv[]) { xmlrpc_server_httpsys_parms serverparm; xmlrpc_registry * registryP; xmlrpc_env env; xmlrpc_env_init(&env); registryP = xmlrpc_registry_new(&env); xmlrpc_registry_add_method( &env, registryP, NULL, "sample.add", &sample_add, NULL); wprintf(L"Starting XML-RPC server...\n"); //Sets the port number we are listening on serverparm.portNum=8080; //if this is set, we will use the authorization function serverparm.authfn=NULL; //serverparm.authfn=&handleAuthorization; //set the logging level and log file serverparm.logLevel=2; serverparm.logFile="C:\\httpsysserverlog.txt"; //set the use of SSL serverparm.useSSL=0; serverparm.registryP = registryP; xmlrpc_server_httpsys(&env, &serverparm, XMLRPC_HSSIZE(authfn)); wprintf(L"Stopping XML-RPC server...\n"); xmlrpc_registry_free(registryP); xmlrpc_env_clean(&env); return 0; }