From ee15519bc724c5583c7846b9482251ad37ac24dd Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Thu, 2 Aug 2007 16:47:29 +0000 Subject: [PATCH] Highly revolting code to pass curl options through API as void* --- xmltooling/soap/SOAPTransport.h | 15 +++++++++++++++ xmltooling/soap/impl/CURLSOAPTransport.cpp | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/xmltooling/soap/SOAPTransport.h b/xmltooling/soap/SOAPTransport.h index cb8d9b6..3f0644b 100644 --- a/xmltooling/soap/SOAPTransport.h +++ b/xmltooling/soap/SOAPTransport.h @@ -131,6 +131,21 @@ namespace xmltooling { #endif /** + * Sets an implementation-specific transport provider option. + * + *

Requires knowledge of the underlying SOAPTransport implementation. + * Without the proper knowledge and inputs, crashes may result. + * + * @param provider name of the SOAPTransport class the caller believes is in use + * @param option implementation-specific data containing the option to set + * @param value implementation- and option-specific data to use + * @return true iff the transport supports the option and value supplied + */ + virtual bool setProviderOption(const char* provider, void* option, void* value) { + return false; + } + + /** * Sends a stream of data over the transport. The function may return without * having received any data, depending on the nature of the transport. * diff --git a/xmltooling/soap/impl/CURLSOAPTransport.cpp b/xmltooling/soap/impl/CURLSOAPTransport.cpp index 48e1a9e..423a3ba 100644 --- a/xmltooling/soap/impl/CURLSOAPTransport.cpp +++ b/xmltooling/soap/impl/CURLSOAPTransport.cpp @@ -146,6 +146,20 @@ namespace xmltooling { return true; } + bool setProviderOption(const char* provider, void* option, void* value) { + if (!provider || strcmp(provider, "CURL")) + return false; + // For libcurl, the option is an enum and the value type depends on the option. + CURLoption opt = static_cast(reinterpret_cast(option)); + if (opt < CURLOPTTYPE_OBJECTPOINT) + return (curl_easy_setopt(m_handle, opt, reinterpret_cast(value))==CURLE_OK); + else if (opt < CURLOPTTYPE_OFF_T) + return (curl_easy_setopt(m_handle, opt, value)==CURLE_OK); + else if (sizeof(void*) == sizeof(curl_off_t)) + return (curl_easy_setopt(m_handle, opt, reinterpret_cast(value))==CURLE_OK); + return false; + } + void send(istream& in); istream& receive() { -- 2.1.4