1 /* A simple synchronous XML-RPC client written in C. */
7 #include <xmlrpc_client.h>
9 #define NAME "XML-RPC C Test Client"
12 static void die_if_fault_occurred (xmlrpc_env
*env
)
14 if (env
->fault_occurred
) {
15 fprintf(stderr
, "XML-RPC Fault: %s (%d)\n",
16 env
->fault_string
, env
->fault_code
);
25 const char ** const argv ATTR_UNUSED
) {
32 fprintf(stderr
, "No arguments");
36 /* Start up our XML-RPC client library. */
37 xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS
, NAME
, VERSION
);
39 /* Initialize our error-handling environment. */
40 xmlrpc_env_init(&env
);
42 /* Call the famous server at UserLand. */
43 for ( cc
= 30; cc
< 35; cc
++ )
46 result
= xmlrpc_client_call(&env
, "http://betty.userland.com/RPC2",
47 "examples.getStateName",
48 "(i)", (xmlrpc_int32
) cc
);
49 die_if_fault_occurred(&env
);
51 /* Get our state name and print it out. */
52 xmlrpc_parse_value(&env
, result
, "s", &state_name
);
53 die_if_fault_occurred(&env
);
54 printf("%d: %s\n", cc
, state_name
);
56 /* Dispose of our result value. */
57 xmlrpc_DECREF(result
);
61 /* Clean up our error-handling environment. */
62 xmlrpc_env_clean(&env
);
64 /* Shutdown our XML-RPC client library. */
65 xmlrpc_client_cleanup();