本文整理汇总了C++中xmlrpc_decompose_value函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlrpc_decompose_value函数的具体用法?C++ xmlrpc_decompose_value怎么用?C++ xmlrpc_decompose_value使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_decompose_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_value_AS_typecheck
static void
test_value_AS_typecheck(void) {
xmlrpc_env env;
xmlrpc_env env2;
xmlrpc_value *v;
xmlrpc_value *v2;
/* Test typechecks for 'A' and 'S'. */
xmlrpc_env_init(&env);
v = xmlrpc_build_value(&env, "s", "foo");
TEST_NO_FAULT(&env);
xmlrpc_env_init(&env2);
xmlrpc_decompose_value(&env2, v, "A", &v2);
TEST_FAULT(&env2, XMLRPC_TYPE_ERROR);
xmlrpc_env_clean(&env2);
xmlrpc_env_init(&env2);
xmlrpc_decompose_value(&env2, v, "S", &v2);
TEST_FAULT(&env2, XMLRPC_TYPE_ERROR);
xmlrpc_env_clean(&env2);
xmlrpc_DECREF(v);
xmlrpc_env_clean(&env);
}
示例2: test_bounds_checks
static void test_bounds_checks (void)
{
xmlrpc_env env;
xmlrpc_value *array;
int i1, i2, i3, i4;
/* Get an array to work with. */
xmlrpc_env_init(&env);
array = xmlrpc_build_value(&env, "(iii)", 100, 200, 300);
TEST_NO_FAULT(&env);
xmlrpc_env_clean(&env);
/* Test xmlrpc_decompose_value with too few values. */
xmlrpc_env_init(&env);
xmlrpc_decompose_value(&env, array, "(iiii)", &i1, &i2, &i3, &i4);
TEST_FAULT(&env, XMLRPC_INDEX_ERROR);
xmlrpc_env_clean(&env);
/* Test xmlrpc_decompose_value with too many values. */
xmlrpc_env_init(&env);
xmlrpc_decompose_value(&env, array, "(ii)", &i1, &i2, &i3, &i4);
TEST_FAULT(&env, XMLRPC_INDEX_ERROR);
xmlrpc_env_clean(&env);
/* Dispose of our array. */
xmlrpc_DECREF(array);
}
示例3: test_value_array_nil
static void
test_value_array_nil(void) {
xmlrpc_value * arrayP;
xmlrpc_env env;
xmlrpc_int32 i1, i2;
xmlrpc_value * itemP;
size_t len;
xmlrpc_env_init(&env);
arrayP = xmlrpc_build_value(&env, "(nini)",
(xmlrpc_int32) 10, (xmlrpc_int32) 20);
TEST_NO_FAULT(&env);
TEST(XMLRPC_TYPE_ARRAY == xmlrpc_value_type(arrayP));
len = xmlrpc_array_size(&env, arrayP);
TEST_NO_FAULT(&env);
TEST(len == 4);
itemP = xmlrpc_array_get_item(&env, arrayP, 0);
TEST_NO_FAULT(&env);
xmlrpc_decompose_value(&env, itemP, "n");
TEST_NO_FAULT(&env);
itemP = xmlrpc_array_get_item(&env, arrayP, 1);
TEST_NO_FAULT(&env);
{
int i;
xmlrpc_decompose_value(&env, itemP, "i", &i);
TEST_NO_FAULT(&env);
TEST(i == 10);
}
xmlrpc_decompose_value(&env, arrayP, "(nini)", &i1, &i2);
TEST_NO_FAULT(&env);
TEST(i1 == 10 && i2 == 20);
/* Test bounds check on xmlrpc_array_get_item. */
xmlrpc_array_read_item(&env, arrayP, 4, &itemP);
TEST_FAULT(&env, XMLRPC_INDEX_ERROR);
xmlrpc_env_clean(&env);
xmlrpc_env_init(&env);
xmlrpc_array_get_item(&env, arrayP, 4);
TEST_FAULT(&env, XMLRPC_INDEX_ERROR);
xmlrpc_env_clean(&env);
xmlrpc_env_init(&env);
xmlrpc_DECREF(arrayP);
xmlrpc_env_clean(&env);
}
示例4: 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);
}
示例5: method_init
/* vcd.user.remove(string username) */
xmlrpc_value *m_vcd_user_remove(xmlrpc_env *env, xmlrpc_value *p, void *c)
{
LOG_TRACEME
xmlrpc_value *params;
char *user;
int rc, uid = 0;
params = method_init(env, p, c, VCD_CAP_AUTH, 0);
method_return_if_fault(env);
xmlrpc_decompose_value(env, params,
"{s:s,*}",
"username", &user);
method_return_if_fault(env);
if (!(uid = auth_getuid(user)))
method_return_fault(env, MENOUSER);
rc = vxdb_exec(
"BEGIN TRANSACTION;"
"DELETE FROM xid_uid_map WHERE uid = %d;"
"DELETE FROM user_caps WHERE uid = %d;"
"DELETE FROM user WHERE uid = %d;"
"COMMIT TRANSACTION;",
uid, uid, uid);
if (rc != VXDB_OK)
method_return_vxdb_fault(env);
return xmlrpc_nil_new(env);
}
示例6: test_default
static xmlrpc_value *
test_default(xmlrpc_env * const envP,
const char * const callInfo,
const char * const methodName,
xmlrpc_value * const paramArrayP,
void * const serverInfo) {
xmlrpc_int32 x, y;
TEST_NO_FAULT(envP);
TEST(paramArrayP != NULL);
TEST(serverInfo == DEFAULT_SERVERINFO);
TEST(streq(methodName, "test.nosuch") ||
streq(methodName, "test.nosuch.old"));
if (streq(methodName, "nosuch.method"))
TEST(callInfo == DEFAULT_CALLINFO);
else if (streq(methodName, "nosuch.method.old"))
TEST(callInfo == NULL);
xmlrpc_decompose_value(envP, paramArrayP, "(ii)", &x, &y);
TEST_NO_FAULT(envP);
TEST(x == 25);
TEST(y == 17);
return xmlrpc_build_value(envP, "i", 2 * (x + y));
}
示例7: c_oneVmInfo
int c_oneVmInfo(int vmid, char* ret_info, int length)
{
xmlrpc_value *resultP;
int return_code;
char *return_string;
int retval = -1;
resultP = xmlrpc_client_call(&one_client.env, one_client.url,
"one.vmget_info", "(si)", one_client.session, vmid);
xmlrpc_decompose_value(&one_client.env, resultP, "(bs)",
&return_code, &return_string);
if( return_code )
{
if (virStrncpy(ret_info, return_string, length-1, length) != NULL)
/* Only set the return value to 0 if we succeeded */
retval = 0;
}
xmlrpc_DECREF(resultP);
VIR_FREE(return_string);
return retval;
}
示例8: std_getblock
xmlrpc_value * std_getblock(xmlrpc_env * envP,
xmlrpc_value * paramArrayP,
void * serverInfo,
void * channelInfo) {
xmlrpc_value * retvalP;
xmlrpc_int32 CheckSum;
xmlrpc_value * DataStructP;
xmlrpc_decompose_value(envP, paramArrayP, "(iS)",
&CheckSum, &DataStructP);
if (envP->fault_occurred)
return NULL;
if (CheckSum != 100) {
xmlrpc_env_set_fault(envP, 0, "Parameter list version must be 1");
return NULL;
}
getDataBlock(envP, DataStructP, &retvalP);
xmlrpc_DECREF(DataStructP);
if (envP->fault_occurred)
return NULL;
return retvalP;
}
示例9: test_value_integer
static void
test_value_integer(void) {
xmlrpc_value * v;
xmlrpc_env env;
xmlrpc_int32 i;
xmlrpc_env_init(&env);
v = xmlrpc_int_new(&env, (xmlrpc_int32) 25);
TEST_NO_FAULT(&env);
TEST(XMLRPC_TYPE_INT == xmlrpc_value_type(v));
xmlrpc_read_int(&env, v, &i);
TEST_NO_FAULT(&env);
TEST(i == 25);
xmlrpc_DECREF(v);
v = xmlrpc_build_value(&env, "i", (xmlrpc_int32) 10);
TEST_NO_FAULT(&env);
TEST(v != NULL);
TEST(XMLRPC_TYPE_INT == xmlrpc_value_type(v));
xmlrpc_decompose_value(&env, v, "i", &i);
xmlrpc_DECREF(v);
TEST_NO_FAULT(&env);
TEST(i == 10);
xmlrpc_env_clean(&env);
}
示例10: handle_sample_add_response
static void
handle_sample_add_response(const char * const serverUrl,
const char * const methodName,
xmlrpc_value * const paramArrayP,
void * const user_data,
xmlrpc_env * const faultP,
xmlrpc_value * const resultP) {
xmlrpc_env env;
xmlrpc_int addend, adder;
/* Initialize our error environment variable */
xmlrpc_env_init(&env);
/* Our first four arguments provide helpful context. Let's grab the
addends from our parameter array.
*/
xmlrpc_decompose_value(&env, paramArrayP, "(ii)", &addend, &adder);
die_if_fault_occurred(&env);
printf("RPC with method '%s' at URL '%s' to add %d and %d "
"has completed\n", methodName, serverUrl, addend, adder);
if (faultP->fault_occurred)
printf("The RPC failed. %s\n", faultP->fault_string);
else {
xmlrpc_int sum;
xmlrpc_read_int(&env, resultP, &sum);
die_if_fault_occurred(&env);
printf("The sum is %d\n", sum);
}
}
示例11: 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);
}
示例12: test_value_double
static void
test_value_double(void) {
xmlrpc_value * v;
xmlrpc_env env;
double d;
xmlrpc_env_init(&env);
TEST(streq(xmlrpc_type_name(XMLRPC_TYPE_DOUBLE), "DOUBLE"));
v = xmlrpc_double_new(&env, -3.25);
TEST_NO_FAULT(&env);
TEST(XMLRPC_TYPE_DOUBLE == xmlrpc_value_type(v));
xmlrpc_read_double(&env, v, &d);
TEST_NO_FAULT(&env);
TEST(d == -3.25);
xmlrpc_DECREF(v);
v = xmlrpc_build_value(&env, "d", 1.0);
TEST_NO_FAULT(&env);
TEST(v != NULL);
TEST(XMLRPC_TYPE_DOUBLE == xmlrpc_value_type(v));
xmlrpc_decompose_value(&env, v, "d", &d);
xmlrpc_DECREF(v);
TEST_NO_FAULT(&env);
TEST(d == 1.0);
xmlrpc_env_clean(&env);
}
示例13: cmd_list
void cmd_list(xmlrpc_env *env, int argc, char **argv)
{
xmlrpc_value *response, *result;
char *username;
int len, i;
if (argc > 0)
username = argv[0];
else
username = "";
response = client_call("vxdb.list",
"{s:s}",
"username", username);
return_if_fault(env);
len = xmlrpc_array_size(env, response);
return_if_fault(env);
for (i = 0; i < len; i++) {
xmlrpc_array_read_item(env, response, i, &result);
return_if_fault(env);
xmlrpc_decompose_value(env, result, "s", &username);
return_if_fault(env);
xmlrpc_DECREF(result);
printf("%s\n", username);
}
xmlrpc_DECREF(response);
}
示例14: cmd_vx_bcaps_get
void cmd_vx_bcaps_get(xmlrpc_env *env, int argc, char **argv)
{
xmlrpc_value *response, *result;
char *name, *bcap;
int len, i;
if (argc < 1)
usage(EXIT_FAILURE);
name = argv[0];
response = client_call("vxdb.vx.bcaps.get",
"{s:s}",
"name", name);
return_if_fault(env);
len = xmlrpc_array_size(env, response);
return_if_fault(env);
for (i = 0; i < len; i++) {
xmlrpc_array_read_item(env, response, i, &result);
return_if_fault(env);
xmlrpc_decompose_value(env, result, "s", &bcap);
return_if_fault(env);
xmlrpc_DECREF(result);
printf("%s\n", bcap);
}
xmlrpc_DECREF(response);
}
示例15: weblab_xmlrpc_test_me
static xmlrpc_value * weblab_xmlrpc_test_me(xmlrpc_env * const env, xmlrpc_value * const param_array, void * const user_data) {
char * arg;
xmlrpc_decompose_value(env, param_array, "(s)", &arg);
if (env->fault_occurred)
return NULL;
return xmlrpc_build_value(env, "s", arg);
}