diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-28 21:26:20 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-28 21:26:20 (GMT) |
commit | 638eb8e68eb22c4dd048d5a225dffb376b701691 (patch) | |
tree | 36c48226149bccbd92881fcd1aa53b8abf2dd974 | |
parent | a5501b11f63c9fbde9a849a362ed6583b75abd75 (diff) | |
download | CMake-638eb8e68eb22c4dd048d5a225dffb376b701691.zip CMake-638eb8e68eb22c4dd048d5a225dffb376b701691.tar.gz CMake-638eb8e68eb22c4dd048d5a225dffb376b701691.tar.bz2 |
ENH: Add example
-rw-r--r-- | Utilities/cmxmlrpc/CMakeLists.txt | 13 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/synch_client.c | 62 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc.h | 1 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_client.c | 2 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_config.h.in | 5 |
5 files changed, 81 insertions, 2 deletions
diff --git a/Utilities/cmxmlrpc/CMakeLists.txt b/Utilities/cmxmlrpc/CMakeLists.txt index 7a7f823..07f4a42 100644 --- a/Utilities/cmxmlrpc/CMakeLists.txt +++ b/Utilities/cmxmlrpc/CMakeLists.txt @@ -31,7 +31,11 @@ CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T) INCLUDE (TryCompileFromSource) SET(HEADER_INCLUDES "${CURRENT_INCLUDES}") TRY_COMPILE_FROM_SOURCE("va_list list1, list2; list1 = list2" - VA_LIST_IS_ARRAY_DEFINE) + VA_LIST_ISNOT_ARRAY_DEFINE) +SET(VA_LIST_IS_ARRAY_DEFINE 0) +IF(NOT VA_LIST_ISNOT_ARRAY_DEFINE) + SET(VA_LIST_IS_ARRAY_DEFINE 1) +ENDIF(NOT VA_LIST_ISNOT_ARRAY_DEFINE) TRY_COMPILE_FROM_SOURCE("int x __attribute__((__unused__))" ATTR_UNUSED_VAR) SET(ATTR_UNUSED) @@ -42,6 +46,8 @@ ENDIF(ATTR_UNUSED_VAR) SET(HAVE_LIBWWW_SSL) SET(DIRECTORY_SEPARATOR "/") +FIND_PACKAGE(Threads) + INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" @@ -84,4 +90,7 @@ IF(WIN32) ENDIF(WIN32) ADD_LIBRARY(cmXMLRPC ${xmlrpc_SRCS}) -TARGET_LINK_LIBRARIES(cmXMLRPC ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_CURL_LIBRARIES}) +TARGET_LINK_LIBRARIES(cmXMLRPC ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + +ADD_EXECUTABLE(xrtest synch_client.c) +TARGET_LINK_LIBRARIES(xrtest cmXMLRPC) diff --git a/Utilities/cmxmlrpc/synch_client.c b/Utilities/cmxmlrpc/synch_client.c new file mode 100644 index 0000000..15a608f --- /dev/null +++ b/Utilities/cmxmlrpc/synch_client.c @@ -0,0 +1,62 @@ +/* A simple synchronous XML-RPC client written in C. */ + +#include <stdio.h> + +#include <xmlrpc.h> +#include <xmlrpc_client.h> + +#define NAME "XML-RPC C Test Client" +#define VERSION "0.1" + +static void die_if_fault_occurred (xmlrpc_env *env) +{ + if (env->fault_occurred) { + fprintf(stderr, "XML-RPC Fault: %s (%d)\n", + env->fault_string, env->fault_code); + exit(1); + } +} + + + +int +main(int const argc, + const char ** const argv ATTR_UNUSED) { + + xmlrpc_env env; + xmlrpc_value *result; + char *state_name; + + if (argc-1 > 0) { + fprintf(stderr, "No arguments"); + exit(0); + } + + /* Start up our XML-RPC client library. */ + xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION); + + /* Initialize our error-handling environment. */ + xmlrpc_env_init(&env); + + /* Call the famous server at UserLand. */ + result = xmlrpc_client_call(&env, "http://betty.userland.com/RPC2", + "examples.getStateName", + "(i)", (xmlrpc_int32) 41); + die_if_fault_occurred(&env); + + /* Get our state name and print it out. */ + xmlrpc_parse_value(&env, result, "s", &state_name); + die_if_fault_occurred(&env); + printf("%s\n", state_name); + + /* Dispose of our result value. */ + xmlrpc_DECREF(result); + + /* Clean up our error-handling environment. */ + xmlrpc_env_clean(&env); + + /* Shutdown our XML-RPC client library. */ + xmlrpc_client_cleanup(); + + return 0; +} diff --git a/Utilities/cmxmlrpc/xmlrpc.h b/Utilities/cmxmlrpc/xmlrpc.h index cffbc91..9c308c8 100644 --- a/Utilities/cmxmlrpc/xmlrpc.h +++ b/Utilities/cmxmlrpc/xmlrpc.h @@ -29,6 +29,7 @@ #include <stddef.h> #include <stdarg.h> +#include <xmlrpc_config.h> #ifdef HAVE_UNICODE_WCHAR #include <wchar.h> diff --git a/Utilities/cmxmlrpc/xmlrpc_client.c b/Utilities/cmxmlrpc/xmlrpc_client.c index 3603a21..bce5538 100644 --- a/Utilities/cmxmlrpc/xmlrpc_client.c +++ b/Utilities/cmxmlrpc/xmlrpc_client.c @@ -142,6 +142,8 @@ setupTransport(xmlrpc_env * const envP, #if MUST_BUILD_CURL_CLIENT else if (strcmp(transportName, "curl") == 0) clientTransportOps = xmlrpc_curl_transport_ops; + else if (strcmp(transportName, "libcurl") == 0) + clientTransportOps = xmlrpc_curl_transport_ops; #endif #if MUST_BUILD_LIBWWW_CLIENT else if (strcmp(transportName, "libwww") == 0) diff --git a/Utilities/cmxmlrpc/xmlrpc_config.h.in b/Utilities/cmxmlrpc/xmlrpc_config.h.in index 8cf9553..fff0e9d 100644 --- a/Utilities/cmxmlrpc/xmlrpc_config.h.in +++ b/Utilities/cmxmlrpc/xmlrpc_config.h.in @@ -16,6 +16,9 @@ */ #include "xmlrpc_amconfig.h" +#ifndef __xmlrpc_config_h__ +#define __xmlrpc_config_h__ + #define VA_LIST_IS_ARRAY @VA_LIST_IS_ARRAY_DEFINE@ @@ -75,3 +78,5 @@ __inline BOOL setenv(const char* name, const char* value, int i) return (SetEnvironmentVariable(name, value) != 0) ? TRUE : FALSE; } #endif + +#endif |