本文整理汇总了C++中xmlrpc_build_value函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlrpc_build_value函数的具体用法?C++ xmlrpc_build_value怎么用?C++ xmlrpc_build_value使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_build_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_value_invalid_struct
static void
test_value_invalid_struct(void) {
xmlrpc_value * v;
xmlrpc_env env;
/* Note that even though the format strings are invalid, we have
to supply the variable arguments that xmlrpc_build_value() will
be looking for as it tries to parse it. Otherwise, we get wild
memory references and consequent Valgrind flags.
*/
xmlrpc_env_init(&env);
v = xmlrpc_build_value(&env, "{s:ii", "key1", 9, 9);
TEST_FAULT(&env, XMLRPC_INTERNAL_ERROR);
v = xmlrpc_build_value(&env, "{si:", "key1", 9);
TEST_FAULT(&env, XMLRPC_INTERNAL_ERROR);
v = xmlrpc_build_value(&env, "{s", "key1");
TEST_FAULT(&env, XMLRPC_INTERNAL_ERROR);
xmlrpc_env_clean(&env);
}
示例2: xmlrpc_parse_value
xmlrpc_value *tcos_lockscreen(xmlrpc_env *env, xmlrpc_value *in, void *ud)
#endif
{
char *user;
char *pass;
char *login_ok;
/* Parse app string */
xmlrpc_parse_value(env, in, "(ss)", &user, &pass);
if (env->fault_occurred)
return xmlrpc_build_value(env, "s", "params error");
/* need login first */
login_ok=validate_login(user,pass);
if( strcmp(login_ok, LOGIN_OK ) != 0 )
return xmlrpc_build_value(env, "s", login_ok );
if ( strcmp(TCOS_PATH, "/sbin" ) )
job_exe(TCOS_PATH"/lockscreen");
else
job_exe("lockscreen");
return xmlrpc_build_value(env, "s", "OK" );
}
示例3: callOneMethod
static void
callOneMethod(xmlrpc_env * const envP,
xmlrpc_registry * const registryP,
xmlrpc_value * const rpcDescP,
void * const callInfo,
xmlrpc_value ** const resultPP) {
const char * methodName;
xmlrpc_value * paramArrayP;
XMLRPC_ASSERT_ENV_OK(envP);
if (xmlrpc_value_type(rpcDescP) != XMLRPC_TYPE_STRUCT)
xmlrpc_env_set_fault_formatted(
envP, XMLRPC_TYPE_ERROR,
"An element of the multicall array is type %u, but should "
"be a struct (with members 'methodName' and 'params')",
xmlrpc_value_type(rpcDescP));
else {
xmlrpc_decompose_value(envP, rpcDescP, "{s:s,s:A,*}",
"methodName", &methodName,
"params", ¶mArrayP);
if (!envP->fault_occurred) {
/* Watch out for a deep recursion attack. */
if (xmlrpc_streq(methodName, "system.multicall"))
xmlrpc_env_set_fault_formatted(
envP,
XMLRPC_REQUEST_REFUSED_ERROR,
"Recursive system.multicall forbidden");
else {
xmlrpc_env env;
xmlrpc_value * resultValP;
xmlrpc_env_init(&env);
xmlrpc_dispatchCall(&env, registryP, methodName, paramArrayP,
callInfo,
&resultValP);
if (env.fault_occurred) {
/* Method failed, so result is a fault structure */
*resultPP =
xmlrpc_build_value(
envP, "{s:i,s:s}",
"faultCode", (xmlrpc_int32) env.fault_code,
"faultString", env.fault_string);
} else {
*resultPP = xmlrpc_build_value(envP, "(V)", resultValP);
xmlrpc_DECREF(resultValP);
}
xmlrpc_env_clean(&env);
}
xmlrpc_DECREF(paramArrayP);
xmlrpc_strfree(methodName);
}
}
}
示例4: xmlrpc_decompose_value
static xmlrpc_value *freeswitch_api(xmlrpc_env * const envP, xmlrpc_value * const paramArrayP, void *const userData, void *const callInfo)
{
char *command = NULL, *arg = NULL;
switch_stream_handle_t stream = { 0 };
xmlrpc_value *val = NULL;
switch_bool_t freed = 0;
/* Parse our argument array. */
xmlrpc_decompose_value(envP, paramArrayP, "(ss)", &command, &arg);
if (envP->fault_occurred) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Request!\n");
return NULL;
}
if (!is_authorized((const TSession *) callInfo, command)) {
val = xmlrpc_build_value(envP, "s", "UNAUTHORIZED!");
goto end;
}
if (switch_stristr("unload", command) && switch_stristr("mod_xml_rpc", arg)) {
switch_safe_free(command);
switch_safe_free(arg);
freed = 1;
command = "bgapi";
arg = "unload mod_xml_rpc";
} else if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", arg)) {
switch_safe_free(command);
switch_safe_free(arg);
freed = 1;
command = "bgapi";
arg = "reload mod_xml_rpc";
}
SWITCH_STANDARD_STREAM(stream);
if (switch_api_execute(command, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
/* Return our result. */
val = xmlrpc_build_value(envP, "s", stream.data);
free(stream.data);
} else {
val = xmlrpc_build_value(envP, "s", "ERROR!");
}
end:
/* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */
if (!freed) {
switch_safe_free(command);
switch_safe_free(arg);
}
return val;
}
示例5: UNUSED
xmlrpc_value *tcos_standalone(xmlrpc_env *env, xmlrpc_value *in, void *ud)
#endif
{
FILE *fp;
char line[BIG_BUFFER];
char *info;
char *group;
size_t *len;
char *fret;
UNUSED(fret);
/* read what info search */
xmlrpc_parse_value(env, in, "(ss#)", &info, &group, &len);
dbgtcos("tcosxmlrpc::tcos_standalone() searching for standalone=\"%s\"\n", info);
if ( strcmp(info, "get_user") == 0 )
fp=(FILE*)popen(STANDALONE_USER, "r");
else if ( strcmp(info, "get_exclude") == 0 ) {
snprintf( line, BSIZE, "%s=%s 2>/dev/null", STANDALONE_EXCLUDE, group);
fp=(FILE*)popen(line, "r");
}
else if ( strcmp(info, "get_process") == 0 )
fp=(FILE*)popen(STANDALONE_PROCESS, "r");
else if ( strcmp(info, "get_server") == 0 ) {
snprintf( line, BSIZE, "%s %s 2>/dev/null", STANDALONE_SERVER, group);
fp=(FILE*)popen(line, "r");
}
else if ( strcmp(info, "get_multiseat") == 0 ) {
snprintf( line, BSIZE, "%s %s 2>/dev/null", STANDALONE_MULTISEAT, group);
fp=(FILE*)popen(line, "r");
}
else if ( strcmp(info, "get_time") == 0 )
fp=(FILE*)popen(STANDALONE_TIME, "r");
/* default method = error */
else
return xmlrpc_build_value(env, "s", STANDALONE_UNKNOW );
if (fp == NULL)
return xmlrpc_build_value(env, "s", STANDALONE_UNKNOW );
/* put error into line */
strncpy(line, STANDALONE_ERROR, BIG_BUFFER);
fret=fgets( line, sizeof line, fp);
remove_line_break(line);
pclose(fp);
dbgtcos("tcosxmlrpc::tcos_standalone() line=\"%s\"\n", line);
return xmlrpc_build_value(env, "s", line );
}
示例6: UNUSED
xmlrpc_value *tcos_dpms(xmlrpc_env *env, xmlrpc_value *in, void *ud)
#endif
{
FILE *fp;
char line[BIG_BUFFER];
char *action;
char *user;
char *pass;
char *login_ok;
char cmd[BIG_BUFFER];
char *fret;
UNUSED(fret);
/* read what info search */
xmlrpc_parse_value(env, in, "(sss)", &action, &user, &pass);
if (env->fault_occurred)
return xmlrpc_build_value(env, "s", "params error");
/* need login first */
login_ok=validate_login(user,pass);
if( strcmp(login_ok, LOGIN_OK ) != 0 )
return xmlrpc_build_value(env, "s", login_ok );
dbgtcos("tcosxmlrpc::tcos_dpms() login ok, action=%s \n", action);
/* read action */
if( strcmp(action, "off" ) == 0 ) {
sprintf( cmd , "%s dpms force off; echo $?", DPMS_CONTROLLER);
}
else if( strcmp(action, "on" ) == 0 ) {
sprintf( cmd , "%s dpms force on; echo $?", DPMS_CONTROLLER);
}
else {
/* show status */
sprintf( cmd , "%s q| awk '/Monitor/ {print $3}'", DPMS_CONTROLLER);
}
dbgtcos("tcosxmlrpc::tcos_dpms() cmd=\"%s\"\n", cmd);
/* put error in line */
strncpy(line, DPMS_CMD_ERROR, BIG_BUFFER);
fp=(FILE*)popen(cmd, "r");
fret=fgets( line, sizeof line, fp);
remove_line_break(line);
pclose(fp);
dbgtcos("tcosxmlrpc::tcos_dpms() line=\"%s\"\n", line);
return xmlrpc_build_value(env, "s", line );
}
示例7: test_build_decomp_datetime
static void
test_build_decomp_datetime(void) {
const char * datestring = "19980717T14:08:55";
time_t const datetime = 900684535;
xmlrpc_env env;
xmlrpc_value * v;
time_t dt;
const char * ds;
xmlrpc_env_init(&env);
v = xmlrpc_build_value(&env, "t", datetime);
TEST_NO_FAULT(&env);
TEST(v != NULL);
TEST(xmlrpc_value_type(v) == XMLRPC_TYPE_DATETIME);
dt = 0;
xmlrpc_read_datetime_sec(&env, v, &dt);
TEST(dt == datetime);
dt = 0;
xmlrpc_decompose_value(&env, v, "t", &dt);
xmlrpc_DECREF(v);
TEST_NO_FAULT(&env);
TEST(dt == datetime);
v = xmlrpc_int_new(&env, 9);
TEST_NO_FAULT(&env);
xmlrpc_decompose_value(&env, v, "t", &dt);
TEST_FAULT(&env, XMLRPC_TYPE_ERROR);
xmlrpc_env_clean(&env);
xmlrpc_env_init(&env);
xmlrpc_decompose_value(&env, v, "8", &ds);
TEST_FAULT(&env, XMLRPC_TYPE_ERROR);
xmlrpc_env_clean(&env);
xmlrpc_env_init(&env);
xmlrpc_DECREF(v);
v = xmlrpc_build_value(&env, "8", datestring);
TEST_NO_FAULT(&env);
TEST(v != NULL);
TEST(xmlrpc_value_type(v) == XMLRPC_TYPE_DATETIME);
xmlrpc_decompose_value(&env, v, "8", &ds);
xmlrpc_DECREF(v);
TEST_NO_FAULT(&env);
TEST(streq(ds, datestring));
strfree(ds);
xmlrpc_env_clean(&env);
}
示例8: xmlok
xmlrpc_value* xmlok (xmlrpc_env *env,xmlrpc_value *array)
{
//Si es null ponemos uno vacio
if (array==NULL)
array = xmlrpc_build_value(env,"()");
//Creamos el valor de retorno
xmlrpc_value *ret = xmlrpc_build_value(env,"{s:i,s:A}","returnCode",1,"returnVal",array);
//Decrementamos el contador
xmlrpc_DECREF(array);
//Y salimos
return ret;
}
示例9: you_license
static xmlrpc_value *
you_license (xmlrpc_env *env,
xmlrpc_value *param_array,
void *user_data)
{
xmlrpc_value *xmlrpc_patches = NULL;
RCYouPatchSList *patches = NULL;
GSList *licenses = NULL;
xmlrpc_value *xmlrpc_licenses = NULL;
GSList *iter;
xmlrpc_parse_value (env, param_array, "(A)", &xmlrpc_patches);
XMLRPC_FAIL_IF_FAULT (env);
patches = rc_xmlrpc_array_to_rc_you_patch_slist
(xmlrpc_patches, env, RC_YOU_PATCH_FROM_XMLRPC_PATCH);
XMLRPC_FAIL_IF_FAULT (env);
licenses = rc_you_patch_slist_lookup_licenses (patches);
xmlrpc_licenses = xmlrpc_build_value (env, "()");
XMLRPC_FAIL_IF_FAULT (env);
for (iter = licenses; iter; iter = iter->next) {
xmlrpc_value *xmlrpc_text;
xmlrpc_text = xmlrpc_build_value (env, "s", (char *) iter->data);
XMLRPC_FAIL_IF_FAULT (env);
xmlrpc_array_append_item (env, xmlrpc_licenses, xmlrpc_text);
XMLRPC_FAIL_IF_FAULT (env);
xmlrpc_DECREF (xmlrpc_text);
}
cleanup:
if (patches) {
rc_you_patch_slist_unref (patches);
g_slist_free (patches);
}
g_slist_free (licenses);
if (env->fault_occurred)
return NULL;
return xmlrpc_licenses;
}
示例10: license_lookup_from_packages
static xmlrpc_value *
license_lookup_from_packages (xmlrpc_env *env,
xmlrpc_value *param_array,
void *user_data)
{
xmlrpc_value *xmlrpc_packages;
RCPackageSList *packages = NULL;
GSList *licenses = NULL;
xmlrpc_value *license_texts = NULL;
GSList *iter;
xmlrpc_parse_value (env, param_array, "(A)", &xmlrpc_packages);
XMLRPC_FAIL_IF_FAULT (env);
packages = rcd_xmlrpc_array_to_rc_package_slist (xmlrpc_packages, env,
RCD_PACKAGE_FROM_XMLRPC_PACKAGE);
XMLRPC_FAIL_IF_FAULT (env);
licenses = rcd_license_lookup_from_package_slist (packages);
license_texts = xmlrpc_build_value (env, "()");
XMLRPC_FAIL_IF_FAULT (env);
for (iter = licenses; iter; iter = iter->next) {
xmlrpc_value *xmlrpc_text;
xmlrpc_text = xmlrpc_build_value (env, "s", (char *) iter->data);
XMLRPC_FAIL_IF_FAULT (env);
xmlrpc_array_append_item (env, license_texts, xmlrpc_text);
XMLRPC_FAIL_IF_FAULT (env);
xmlrpc_DECREF (xmlrpc_text);
}
cleanup:
if (packages) {
rc_package_slist_unref (packages);
g_slist_free (packages);
}
g_slist_free (licenses);
if (env->fault_occurred)
return NULL;
return license_texts;
}
示例11: recur_build_response_array
static int recur_build_response_array( xmlrpc_env * env, struct mi_node * tree,
str * buf )
{
for ( ; tree ; tree = tree->next ) {
if (!(tree->flags & MI_WRITTEN)) {
if ( xr_write_node( buf, tree ) != 0 ) {
LM_ERR("failed to get MI node data!\n");
return -1;
}
/* we are sure that this node has been written
* => avoid writing it again */
tree->flags |= MI_WRITTEN;
}
reply_buffer[reply_buffer_len-buf->len] = 0;
reply_item = xmlrpc_build_value(env, "s", reply_buffer);
xmlrpc_array_append_item(env, xr_response, reply_item);
buf->s = reply_buffer;
buf->len = reply_buffer_len;
if ( tree->kids ) {
if ( recur_build_response_array(env, tree->kids, buf) != 0 )
return -1;
}
}
return 0;
}
示例12: FLVStartReceivingVideo
xmlrpc_value* FLVStartReceivingVideo(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
{
FLVServer *flv = (FLVServer *)user_data;
FLVSession *session = NULL;
//Parseamos
int sessionId;
xmlrpc_parse_value(env, param_array, "(i)", &sessionId);
//Comprobamos si ha habido error
if(env->fault_occurred)
return 0;
//Obtenemos la referencia
if(!flv->GetSessionRef(sessionId,&session))
return xmlerror(env,"La sessionerencia no existe\n");
//La borramos
int recVideoPort = session->StartReceivingVideo();
//Liberamos la referencia
flv->ReleaseSessionRef(sessionId);
//Salimos
if(!recVideoPort)
return xmlerror(env,"No se ha podido terminar la sessionerencia\n");
//Devolvemos el resultado
return xmlok(env,xmlrpc_build_value(env,"(i)",recVideoPort));
}
示例13: FLVCreateSession
//CreateSession
xmlrpc_value* FLVCreateSession(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
{
FLVServer *flv = (FLVServer *)user_data;
FLVSession *session = NULL;
//Parseamos
char *str;
xmlrpc_parse_value(env, param_array, "(s)", &str);
//Creamos la sessionerencia
int sessionId = flv->CreateSession(str);
//Si error
if (!sessionId>0)
return xmlerror(env,"No se puede crear la sessionerencia");
//Obtenemos la referencia
if(!flv->GetSessionRef(sessionId,&session))
return xmlerror(env,"Conferencia borrada antes de poder iniciarse\n");
//La iniciamos
int port = session->Init();
//Liberamos la referencia
flv->ReleaseSessionRef(sessionId);
//Salimos
if(!port)
return xmlerror(env,"No se ha podido iniciar la sessionerencia\n");
//Devolvemos el resultado
return xmlok(env,xmlrpc_build_value(env,"(ii)",sessionId,port));
}
示例14: test_value_bool
static void
test_value_bool(void) {
xmlrpc_value * v;
xmlrpc_env env;
xmlrpc_bool b;
/* Test booleans. */
xmlrpc_env_init(&env);
TEST(streq(xmlrpc_type_name(XMLRPC_TYPE_BOOL), "BOOL"));
v = xmlrpc_bool_new(&env, (xmlrpc_bool) 1);
TEST_NO_FAULT(&env);
TEST(XMLRPC_TYPE_BOOL == xmlrpc_value_type(v));
xmlrpc_read_bool(&env, v, &b);
TEST_NO_FAULT(&env);
TEST(b);
xmlrpc_DECREF(v);
v = xmlrpc_build_value(&env, "b", (xmlrpc_bool) 0);
TEST_NO_FAULT(&env);
TEST(v != NULL);
TEST(XMLRPC_TYPE_BOOL == xmlrpc_value_type(v));
xmlrpc_decompose_value(&env, v, "b", &b);
xmlrpc_DECREF(v);
TEST_NO_FAULT(&env);
TEST(!b);
xmlrpc_env_clean(&env);
}
示例15: test_value_AS
static void
test_value_AS(void) {
xmlrpc_value *v;
xmlrpc_value *v2;
xmlrpc_value *v3;
xmlrpc_env env;
size_t len;
/* Test parsing of 'A' and 'S'. */
xmlrpc_env_init(&env);
v = xmlrpc_build_value(&env, "((){})");
TEST_NO_FAULT(&env);
xmlrpc_decompose_value(&env, v, "(AS)", &v2, &v3);
xmlrpc_DECREF(v);
TEST_NO_FAULT(&env);
TEST(XMLRPC_TYPE_ARRAY == xmlrpc_value_type(v2));
TEST(XMLRPC_TYPE_STRUCT == xmlrpc_value_type(v3));
len = xmlrpc_array_size(&env, v2);
TEST_NO_FAULT(&env);
TEST(len == 0);
len = xmlrpc_struct_size(&env, v3);
TEST_NO_FAULT(&env);
TEST(len == 0);
xmlrpc_DECREF(v2);
xmlrpc_DECREF(v3);
xmlrpc_env_clean(&env);
}