~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Utilities/cmxmlrpc/synch_client.c

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* A simple synchronous XML-RPC client written in C. */
2
 
 
3
 
#include <stdio.h>
4
 
#include <stdlib.h>
5
 
 
6
 
#include <xmlrpc.h>
7
 
#include <xmlrpc_client.h>
8
 
 
9
 
#define NAME "XML-RPC C Test Client"
10
 
#define VERSION "0.1"
11
 
 
12
 
static void die_if_fault_occurred (xmlrpc_env *env)
13
 
{
14
 
    if (env->fault_occurred) {
15
 
        fprintf(stderr, "XML-RPC Fault: %s (%d)\n",
16
 
                env->fault_string, env->fault_code);
17
 
        exit(1);
18
 
    }
19
 
}
20
 
 
21
 
 
22
 
 
23
 
int 
24
 
main(int           const argc, 
25
 
     const char ** const argv ATTR_UNUSED) {
26
 
 
27
 
    xmlrpc_env env;
28
 
    char *state_name;
29
 
    int cc;
30
 
 
31
 
    if (argc-1 > 0) {
32
 
        fprintf(stderr, "No arguments");
33
 
        exit(0);
34
 
    }
35
 
 
36
 
    /* Start up our XML-RPC client library. */
37
 
    xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION);
38
 
 
39
 
    /* Initialize our error-handling environment. */
40
 
    xmlrpc_env_init(&env);
41
 
 
42
 
    /* Call the famous server at UserLand. */
43
 
    for ( cc = 30; cc < 35; cc ++ )
44
 
      {
45
 
      xmlrpc_value *result;
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);
50
 
 
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);
55
 
 
56
 
      /* Dispose of our result value. */
57
 
      xmlrpc_DECREF(result);
58
 
 
59
 
      }
60
 
    
61
 
    /* Clean up our error-handling environment. */
62
 
    xmlrpc_env_clean(&env);
63
 
  
64
 
    /* Shutdown our XML-RPC client library. */
65
 
    xmlrpc_client_cleanup();
66
 
 
67
 
    return 0;
68
 
}