1 /*=============================================================================
3 ===============================================================================
4 This is the Libwww XML transport of the C++ XML-RPC client library for
6 =============================================================================*/
12 #include "xmlrpc-c/girerr.hpp"
15 #include "xmlrpc-c/girmem.hpp"
16 using girmem::autoObjectPtr;
17 using girmem::autoObject;
18 #include "env_wrap.hpp"
19 #include "xmlrpc-c/base.h"
20 #include "xmlrpc-c/client.h"
21 #include "xmlrpc-c/transport.h"
22 #include "xmlrpc-c/base_int.h"
24 #include "xmlrpc_libwww_transport.h"
26 /* transport_config.h defines MUST_BUILD_LIBWWW_CLIENT */
27 #include "transport_config.h"
29 #include "xmlrpc-c/client_transport.hpp"
33 using namespace xmlrpc_c;
38 class globalConstant {
46 globalConstant::globalConstant() {
50 xmlrpc_transport_setup setupFn;
52 #if MUST_BUILD_LIBWWW_CLIENT
53 setupFn = xmlrpc_libwww_transport_ops.setup_global_const;
60 setupFn(&env.env_c); // Not thread safe
62 if (env.env_c.fault_occurred)
63 throwf("Failed to do global initialization "
64 "of Libwww transport code. %s", env.env_c.fault_string);
70 globalConstant::~globalConstant() {
74 xmlrpc_transport_teardown teardownFn;
76 #if MUST_BUILD_LIBWWW_CLIENT
77 teardownFn = xmlrpc_libwww_transport_ops.teardown_global_const;
82 teardownFn(); // not thread safe
86 globalConstant globalConst;
87 // This object is never accessed. Its whole purpose to to be born and
88 // to die, which it does automatically as part of C++ program
89 // program initialization and termination.
96 carriageParm_libwww0::carriageParm_libwww0(
97 string const serverUrl
100 this->instantiate(serverUrl);
105 carriageParm_libwww0Ptr::carriageParm_libwww0Ptr() {
106 // Base class constructor will construct pointer that points to nothing
111 carriageParm_libwww0Ptr::carriageParm_libwww0Ptr(
112 carriageParm_libwww0 * const carriageParmP) {
113 this->point(carriageParmP);
118 carriageParm_libwww0 *
119 carriageParm_libwww0Ptr::operator->() const {
121 autoObject * const p(this->objectP);
122 return dynamic_cast<carriageParm_libwww0 *>(p);
127 #if MUST_BUILD_LIBWWW_CLIENT
129 clientXmlTransport_libwww::clientXmlTransport_libwww(
130 string const appname,
131 string const appversion) {
133 this->c_transportOpsP = &xmlrpc_libwww_transport_ops;
137 xmlrpc_libwww_transport_ops.create(
138 &env.env_c, 0, appname.c_str(), appversion.c_str(), NULL, 0,
139 &this->c_transportP);
141 if (env.env_c.fault_occurred)
142 throw(error(env.env_c.fault_string));
145 #else // MUST_BUILD_LIBWWW_CLIENT
146 clientXmlTransport_libwww::clientXmlTransport_libwww(string, string) {
148 throw(error("There is no Libwww client XML transport "
149 "in this XML-RPC client library"));
155 clientXmlTransport_libwww::~clientXmlTransport_libwww() {
157 this->c_transportOpsP->destroy(this->c_transportP);