[ros-ros-comm] 11/16: Final adaptation of the original patches
Leopold Palomo-Avellaneda
leo at alaxarxa.net
Fri May 20 21:20:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
lepalom-guest pushed a commit to branch master
in repository ros-ros-comm.
commit 4914df7aea63192fb06c276f276a7d6f0b625c4c
Author: Leopold Palomo-Avellaneda <leopold.palomo at upc.edu>
Date: Fri May 20 13:41:23 2016 +0200
Final adaptation of the original patches
---
...Move-headers-to-include-xmlrpcpp-adapted.patch} | 1585 +++++++++++++++++++-
debian/patches/series | 2 +-
2 files changed, 1583 insertions(+), 4 deletions(-)
diff --git a/debian/patches/0007-Move-headers-to-include-xmlrpcpp.patch b/debian/patches/0007-Move-headers-to-include-xmlrpcpp-adapted.patch
similarity index 57%
rename from debian/patches/0007-Move-headers-to-include-xmlrpcpp.patch
rename to debian/patches/0007-Move-headers-to-include-xmlrpcpp-adapted.patch
index 869d097..fb9b992 100644
--- a/debian/patches/0007-Move-headers-to-include-xmlrpcpp.patch
+++ b/debian/patches/0007-Move-headers-to-include-xmlrpcpp-adapted.patch
@@ -1,6 +1,6 @@
From: Leopold Palomo-Avellaneda <leopold.palomo at upc.edu>
-Date: Fri, 20 May 2016 08:38:48 +0200
-Subject: Move headers to include xmlrpcpp
+Date: Fri, 20 May 2016 13:39:33 +0200
+Subject: Move headers to include xmlrpcpp adapted
---
clients/roscpp/include/ros/master.h | 2 +-
@@ -16,6 +16,7 @@ Subject: Move headers to include xmlrpcpp
clients/roscpp/src/libros/node_handle.cpp | 2 +-
clients/roscpp/src/libros/service_manager.cpp | 2 +-
clients/roscpp/src/libros/topic_manager.cpp | 2 +-
+ debian/patches/series | 2 +-
test/test_roscpp/test/src/check_master.cpp | 2 +-
tools/rosbag/src/recorder.cpp | 2 +-
utilities/xmlrpcpp/CMakeLists.txt | 3 +-
@@ -32,6 +33,19 @@ Subject: Move headers to include xmlrpcpp
utilities/xmlrpcpp/include/XmlRpcUtil.h | 63 ----
utilities/xmlrpcpp/include/XmlRpcValue.h | 195 -----------
utilities/xmlrpcpp/include/base64.h | 380 ---------------------
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpc.h | 102 ++++++
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcClient.h | 133 ++++++++
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h | 55 +++
+ .../xmlrpcpp/include/xmlrpcpp/XmlRpcDispatch.h | 89 +++++
+ .../xmlrpcpp/include/xmlrpcpp/XmlRpcException.h | 44 +++
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServer.h | 114 +++++++
+ .../include/xmlrpcpp/XmlRpcServerConnection.h | 103 ++++++
+ .../xmlrpcpp/include/xmlrpcpp/XmlRpcServerMethod.h | 49 +++
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSocket.h | 80 +++++
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSource.h | 57 ++++
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcUtil.h | 63 ++++
+ utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h | 195 +++++++++++
+ utilities/xmlrpcpp/include/xmlrpcpp/base64.h | 380 +++++++++++++++++++++
utilities/xmlrpcpp/src/XmlRpcClient.cpp | 6 +-
utilities/xmlrpcpp/src/XmlRpcDispatch.cpp | 6 +-
utilities/xmlrpcpp/src/XmlRpcServer.cpp | 12 +-
@@ -52,7 +66,7 @@ Subject: Move headers to include xmlrpcpp
utilities/xmlrpcpp/test/Validator.cpp | 2 +-
utilities/xmlrpcpp/test/bool_test.cpp | 2 +-
utilities/xmlrpcpp/test/port_zero_server.cpp | 2 +-
- 49 files changed, 55 insertions(+), 1520 deletions(-)
+ 63 files changed, 1520 insertions(+), 1521 deletions(-)
delete mode 100644 utilities/xmlrpcpp/include/XmlRpc.h
delete mode 100644 utilities/xmlrpcpp/include/XmlRpcClient.h
delete mode 100644 utilities/xmlrpcpp/include/XmlRpcDecl.h
@@ -66,6 +80,19 @@ Subject: Move headers to include xmlrpcpp
delete mode 100644 utilities/xmlrpcpp/include/XmlRpcUtil.h
delete mode 100644 utilities/xmlrpcpp/include/XmlRpcValue.h
delete mode 100644 utilities/xmlrpcpp/include/base64.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpc.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcClient.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDispatch.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcException.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServer.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerConnection.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerMethod.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSocket.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSource.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcUtil.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h
+ create mode 100644 utilities/xmlrpcpp/include/xmlrpcpp/base64.h
diff --git a/clients/roscpp/include/ros/master.h b/clients/roscpp/include/ros/master.h
index 9eefdf3..6cabd01 100644
@@ -236,6 +263,16 @@ index 0142cda..c76c9bc 100644
#include <ros/console.h>
+diff --git a/debian/patches/series b/debian/patches/series
+index b4a3e11..1b2a099 100644
+--- a/debian/patches/series
++++ b/debian/patches/series
+@@ -4,4 +4,4 @@
+ 0004-Fix-executable-not-elf-or-script.patch
+ 0005-Add-defaults-to-roswtf.patch
+ 0006-Fix-confusing-copyright-messages-dates.patch
+-0007-Move-headers-to-include-xmlrpcpp.patch
++#0007-Move-headers-to-include-xmlrpcpp.patch
diff --git a/test/test_roscpp/test/src/check_master.cpp b/test/test_roscpp/test/src/check_master.cpp
index 9b03321..4392f2b 100644
--- a/test/test_roscpp/test/src/check_master.cpp
@@ -1818,6 +1855,1548 @@ index c239403..0000000
-
-
-#endif
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpc.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpc.h
+new file mode 100644
+index 0000000..9fd626a
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpc.h
+@@ -0,0 +1,102 @@
++// this file modified by Morgan Quigley on 22 April 2008 to add
++// a std::exception-derived class
++#ifndef _XMLRPC_H_
++#define _XMLRPC_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++// This library is free software; you can redistribute it and/or
++// modify it under the terms of the GNU Lesser General Public
++// License as published by the Free Software Foundation; either
++// version 2.1 of the License, or (at your option) any later version.
++//
++// This library is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// Lesser General Public License for more details.
++//
++// You should have received a copy of the GNU Lesser General Public
++// License along with this library; if not, write to the Free Software
++// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
++//
++
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#ifndef MAKEDEPEND
++# include <string>
++#endif
++
++#include "xmlrpcpp/XmlRpcClient.h"
++#include "xmlrpcpp/XmlRpcException.h"
++#include "xmlrpcpp/XmlRpcServer.h"
++#include "xmlrpcpp/XmlRpcServerMethod.h"
++#include "xmlrpcpp/XmlRpcValue.h"
++#include "xmlrpcpp/XmlRpcUtil.h"
++
++#include <stdexcept>
++
++namespace XmlRpc {
++
++
++ //! An interface allowing custom handling of error message reporting.
++ class XmlRpcErrorHandler {
++ public:
++ virtual ~XmlRpcErrorHandler() { }
++
++ //! Returns a pointer to the currently installed error handling object.
++ static XmlRpcErrorHandler* getErrorHandler()
++ { return _errorHandler; }
++
++ //! Specifies the error handler.
++ static void setErrorHandler(XmlRpcErrorHandler* eh)
++ { _errorHandler = eh; }
++
++ //! Report an error. Custom error handlers should define this method.
++ virtual void error(const char* msg) = 0;
++
++ protected:
++ static XmlRpcErrorHandler* _errorHandler;
++ };
++
++ //! An interface allowing custom handling of informational message reporting.
++ class XmlRpcLogHandler {
++ public:
++ virtual ~XmlRpcLogHandler() { }
++
++ //! Returns a pointer to the currently installed message reporting object.
++ static XmlRpcLogHandler* getLogHandler()
++ { return _logHandler; }
++
++ //! Specifies the message handler.
++ static void setLogHandler(XmlRpcLogHandler* lh)
++ { _logHandler = lh; }
++
++ //! Returns the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
++ static int getVerbosity()
++ { return _verbosity; }
++
++ //! Specify the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
++ static void setVerbosity(int v)
++ { _verbosity = v; }
++
++ //! Output a message. Custom error handlers should define this method.
++ virtual void log(int level, const char* msg) = 0;
++
++ protected:
++ static XmlRpcLogHandler* _logHandler;
++ static int _verbosity;
++ };
++
++ //! Returns log message verbosity. This is short for XmlRpcLogHandler::getVerbosity()
++ int getVerbosity();
++ //! Sets log message verbosity. This is short for XmlRpcLogHandler::setVerbosity(level)
++ void setVerbosity(int level);
++
++
++ //! Version identifier
++ extern const char XMLRPC_VERSION[];
++
++} // namespace XmlRpc
++
++#endif // _XMLRPC_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcClient.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcClient.h
+new file mode 100644
+index 0000000..2154b39
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcClient.h
+@@ -0,0 +1,133 @@
++
++#ifndef _XMLRPCCLIENT_H_
++#define _XMLRPCCLIENT_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++
++#ifndef MAKEDEPEND
++# include <string>
++#endif
++
++#include "xmlrpcpp/XmlRpcDispatch.h"
++#include "xmlrpcpp/XmlRpcSource.h"
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++namespace XmlRpc {
++
++ // Arguments and results are represented by XmlRpcValues
++ class XmlRpcValue;
++
++ //! A class to send XML RPC requests to a server and return the results.
++ class XMLRPCPP_DECL XmlRpcClient : public XmlRpcSource {
++ public:
++ // Static data
++ static const char REQUEST_BEGIN[];
++ static const char REQUEST_END_METHODNAME[];
++ static const char PARAMS_TAG[];
++ static const char PARAMS_ETAG[];
++ static const char PARAM_TAG[];
++ static const char PARAM_ETAG[];
++ static const char REQUEST_END[];
++ // Result tags
++ static const char METHODRESPONSE_TAG[];
++ static const char FAULT_TAG[];
++
++ //! Construct a client to connect to the server at the specified host:port address
++ //! @param host The name of the remote machine hosting the server
++ //! @param port The port on the remote machine where the server is listening
++ //! @param uri An optional string to be sent as the URI in the HTTP GET header
++ XmlRpcClient(const char* host, int port, const char* uri=0);
++
++ //! Destructor
++ virtual ~XmlRpcClient();
++
++ //! Execute the named procedure on the remote server.
++ //! @param method The name of the remote procedure to execute
++ //! @param params An array of the arguments for the method
++ //! @param result The result value to be returned to the client
++ //! @return true if the request was sent and a result received
++ //! (although the result might be a fault).
++ //!
++ //! Currently this is a synchronous (blocking) implementation (execute
++ //! does not return until it receives a response or an error). Use isFault()
++ //! to determine whether the result is a fault response.
++ bool execute(const char* method, XmlRpcValue const& params, XmlRpcValue& result);
++
++ bool executeNonBlock(const char* method, XmlRpcValue const& params);
++ bool executeCheckDone(XmlRpcValue& result);
++
++ //! Returns true if the result of the last execute() was a fault response.
++ bool isFault() const { return _isFault; }
++
++
++ // XmlRpcSource interface implementation
++ //! Close the connection
++ virtual void close();
++
++ //! Handle server responses. Called by the event dispatcher during execute.
++ //! @param eventType The type of event that occurred.
++ //! @see XmlRpcDispatch::EventType
++ virtual unsigned handleEvent(unsigned eventType);
++
++ protected:
++ // Execution processing helpers
++ virtual bool doConnect();
++ virtual bool setupConnection();
++
++ virtual bool generateRequest(const char* method, XmlRpcValue const& params);
++ virtual std::string generateHeader(std::string const& body);
++ virtual bool writeRequest();
++ virtual bool readHeader();
++ virtual bool readResponse();
++ virtual bool parseResponse(XmlRpcValue& result);
++
++ // Possible IO states for the connection
++ enum ClientConnectionState { NO_CONNECTION, CONNECTING, WRITE_REQUEST, READ_HEADER, READ_RESPONSE, IDLE };
++ ClientConnectionState _connectionState;
++
++ // Server location
++ std::string _host;
++ std::string _uri;
++ int _port;
++ public:
++ const std::string &getHost() { return _host; }
++ const std::string &getUri() { return _uri; }
++ int getPort() const { return _port; }
++
++ // The xml-encoded request, http header of response, and response xml
++ std::string _request;
++ std::string _header;
++ std::string _response;
++
++ // Number of times the client has attempted to send the request
++ int _sendAttempts;
++
++ // Number of bytes of the request that have been written to the socket so far
++ int _bytesWritten;
++
++ // True if we are currently executing a request. If you want to multithread,
++ // each thread should have its own client.
++ bool _executing;
++
++ // True if the server closed the connection
++ bool _eof;
++
++ // True if a fault response was returned by the server
++ bool _isFault;
++
++ // Number of bytes expected in the response body (parsed from response header)
++ int _contentLength;
++
++ // Event dispatcher
++ XmlRpcDispatch _disp;
++
++ }; // class XmlRpcClient
++
++} // namespace XmlRpc
++
++#endif // _XMLRPCCLIENT_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h
+new file mode 100644
+index 0000000..8af174a
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDecl.h
+@@ -0,0 +1,55 @@
++/*********************************************************************
++*
++* Software License Agreement (BSD License)
++*
++* Copyright (c) 2009, Willow Garage, Inc.
++* All rights reserved.
++*
++* Redistribution and use in source and binary forms, with or without
++* modification, are permitted provided that the following conditions
++* are met:
++*
++* * Redistributions of source code must retain the above copyright
++* notice, this list of conditions and the following disclaimer.
++* * Redistributions in binary form must reproduce the above
++* copyright notice, this list of conditions and the following
++* disclaimer in the documentation and/or other materials provided
++* with the distribution.
++* * Neither the name of the Willow Garage nor the names of its
++* contributors may be used to endorse or promote products derived
++* from this software without specific prior written permission.
++*
++* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
++* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
++* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
++* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
++* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
++* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
++* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
++* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
++* POSSIBILITY OF SUCH DAMAGE.
++*
++*********************************************************************/
++/*
++ * Cross platform macros.
++ *
++ */
++#ifndef XMLRPCPP_DECL_H_INCLUDED
++#define XMLRPCPP_DECL_H_INCLUDED
++
++#include <ros/macros.h>
++
++#ifdef ROS_BUILD_SHARED_LIBS // ros is being built around shared libraries
++ #ifdef xmlrpcpp_EXPORTS // we are building a shared lib/dll
++ #define XMLRPCPP_DECL ROS_HELPER_EXPORT
++ #else // we are using shared lib/dll
++ #define XMLRPCPP_DECL ROS_HELPER_IMPORT
++ #endif
++#else // ros is being built around static libraries
++ #define XMLRPCPP_DECL
++#endif
++
++#endif /* XMLRPCPP_DECL_H_INCLUDED */
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDispatch.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDispatch.h
+new file mode 100644
+index 0000000..5e90822
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcDispatch.h
+@@ -0,0 +1,89 @@
++
++#ifndef _XMLRPCDISPATCH_H_
++#define _XMLRPCDISPATCH_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++#ifndef MAKEDEPEND
++# include <list>
++#endif
++
++namespace XmlRpc {
++
++ // An RPC source represents a file descriptor to monitor
++ class XmlRpcSource;
++
++ //! An object which monitors file descriptors for events and performs
++ //! callbacks when interesting events happen.
++ class XMLRPCPP_DECL XmlRpcDispatch {
++ public:
++ //! Constructor
++ XmlRpcDispatch();
++ ~XmlRpcDispatch();
++
++ //! Values indicating the type of events a source is interested in
++ enum EventType {
++ ReadableEvent = 1, //!< data available to read
++ WritableEvent = 2, //!< connected/data can be written without blocking
++ Exception = 4 //!< uh oh
++ };
++
++ //! Monitor this source for the event types specified by the event mask
++ //! and call its event handler when any of the events occur.
++ //! @param source The source to monitor
++ //! @param eventMask Which event types to watch for. \see EventType
++ void addSource(XmlRpcSource* source, unsigned eventMask);
++
++ //! Stop monitoring this source.
++ //! @param source The source to stop monitoring
++ void removeSource(XmlRpcSource* source);
++
++ //! Modify the types of events to watch for on this source
++ void setSourceEvents(XmlRpcSource* source, unsigned eventMask);
++
++
++ //! Watch current set of sources and process events for the specified
++ //! duration (in ms, -1 implies wait forever, or until exit is called)
++ void work(double msTime);
++
++ //! Exit from work routine
++ void exit();
++
++ //! Clear all sources from the monitored sources list. Sources are closed.
++ void clear();
++
++ // helper
++ double getTime();
++
++ // A source to monitor and what to monitor it for
++ struct MonitoredSource {
++ MonitoredSource(XmlRpcSource* src, unsigned mask) : _src(src), _mask(mask) {}
++ XmlRpcSource* getSource() const { return _src; }
++ unsigned& getMask() { return _mask; }
++ XmlRpcSource* _src;
++ unsigned _mask;
++ };
++
++ // A list of sources to monitor
++ typedef std::list< MonitoredSource > SourceList;
++
++ // Sources being monitored
++ SourceList _sources;
++ protected:
++
++ // When work should stop (-1 implies wait forever, or until exit is called)
++ double _endTime;
++
++ bool _doClear;
++ bool _inWork;
++
++ };
++} // namespace XmlRpc
++
++#endif // _XMLRPCDISPATCH_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcException.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcException.h
+new file mode 100644
+index 0000000..4e8a2a6
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcException.h
+@@ -0,0 +1,44 @@
++
++#ifndef _XMLRPCEXCEPTION_H_
++#define _XMLRPCEXCEPTION_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#ifndef MAKEDEPEND
++# include <string>
++#endif
++
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++
++namespace XmlRpc {
++
++ //! A class representing an error.
++ //! If server methods throw this exception, a fault response is returned
++ //! to the client.
++ class XMLRPCPP_DECL XmlRpcException {
++ public:
++ //! Constructor
++ //! @param message A descriptive error message
++ //! @param code An integer error code
++ XmlRpcException(const std::string& message, int code=-1) :
++ _message(message), _code(code) {}
++
++ //! Return the error message.
++ const std::string& getMessage() const { return _message; }
++
++ //! Return the error code.
++ int getCode() const { return _code; }
++
++ private:
++ std::string _message;
++ int _code;
++ };
++
++}
++
++#endif // _XMLRPCEXCEPTION_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServer.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServer.h
+new file mode 100644
+index 0000000..ac16dae
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServer.h
+@@ -0,0 +1,114 @@
++// this file modified by Morgan Quigley on 22 Apr 2008.
++// added features: server can be opened on port 0 and you can read back
++// what port the OS gave you
++
++#ifndef _XMLRPCSERVER_H_
++#define _XMLRPCSERVER_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#ifndef MAKEDEPEND
++# include <map>
++# include <string>
++#endif
++
++#include "xmlrpcpp/XmlRpcDispatch.h"
++#include "xmlrpcpp/XmlRpcSource.h"
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++namespace XmlRpc {
++
++
++ // An abstract class supporting XML RPC methods
++ class XmlRpcServerMethod;
++
++ // Class representing connections to specific clients
++ class XmlRpcServerConnection;
++
++ // Class representing argument and result values
++ class XmlRpcValue;
++
++
++ //! A class to handle XML RPC requests
++ class XMLRPCPP_DECL XmlRpcServer : public XmlRpcSource {
++ public:
++ //! Create a server object.
++ XmlRpcServer();
++ //! Destructor.
++ virtual ~XmlRpcServer();
++
++ //! Specify whether introspection is enabled or not. Default is not enabled.
++ void enableIntrospection(bool enabled=true);
++
++ //! Add a command to the RPC server
++ void addMethod(XmlRpcServerMethod* method);
++
++ //! Remove a command from the RPC server
++ void removeMethod(XmlRpcServerMethod* method);
++
++ //! Remove a command from the RPC server by name
++ void removeMethod(const std::string& methodName);
++
++ //! Look up a method by name
++ XmlRpcServerMethod* findMethod(const std::string& name) const;
++
++ //! Create a socket, bind to the specified port, and
++ //! set it in listen mode to make it available for clients.
++ bool bindAndListen(int port, int backlog = 5);
++
++ //! Process client requests for the specified time
++ void work(double msTime);
++
++ //! Temporarily stop processing client requests and exit the work() method.
++ void exit();
++
++ //! Close all connections with clients and the socket file descriptor
++ void shutdown();
++
++ //! Introspection support
++ void listMethods(XmlRpcValue& result);
++
++ // XmlRpcSource interface implementation
++
++ //! Handle client connection requests
++ virtual unsigned handleEvent(unsigned eventType);
++
++ //! Remove a connection from the dispatcher
++ virtual void removeConnection(XmlRpcServerConnection*);
++
++ inline int get_port() { return _port; }
++
++ XmlRpcDispatch *get_dispatch() { return &_disp; }
++
++ protected:
++
++ //! Accept a client connection request
++ virtual void acceptConnection();
++
++ //! Create a new connection object for processing requests from a specific client.
++ virtual XmlRpcServerConnection* createConnection(int socket);
++
++ // Whether the introspection API is supported by this server
++ bool _introspectionEnabled;
++
++ // Event dispatcher
++ XmlRpcDispatch _disp;
++
++ // Collection of methods. This could be a set keyed on method name if we wanted...
++ typedef std::map< std::string, XmlRpcServerMethod* > MethodMap;
++ MethodMap _methods;
++
++ // system methods
++ XmlRpcServerMethod* _listMethods;
++ XmlRpcServerMethod* _methodHelp;
++
++ int _port;
++
++ };
++} // namespace XmlRpc
++
++#endif //_XMLRPCSERVER_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerConnection.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerConnection.h
+new file mode 100644
+index 0000000..ed4d092
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerConnection.h
+@@ -0,0 +1,103 @@
++#ifndef _XMLRPCSERVERCONNECTION_H_
++#define _XMLRPCSERVERCONNECTION_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#ifndef MAKEDEPEND
++# include <string>
++#endif
++
++#include "xmlrpcpp/XmlRpcValue.h"
++#include "xmlrpcpp/XmlRpcSource.h"
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++namespace XmlRpc {
++
++
++ // The server waits for client connections and provides methods
++ class XmlRpcServer;
++ class XmlRpcServerMethod;
++
++ //! A class to handle XML RPC requests from a particular client
++ class XMLRPCPP_DECL XmlRpcServerConnection : public XmlRpcSource {
++ public:
++ // Static data
++ static const char METHODNAME_TAG[];
++ static const char PARAMS_TAG[];
++ static const char PARAMS_ETAG[];
++ static const char PARAM_TAG[];
++ static const char PARAM_ETAG[];
++
++ static const std::string SYSTEM_MULTICALL;
++ static const std::string METHODNAME;
++ static const std::string PARAMS;
++
++ static const std::string FAULTCODE;
++ static const std::string FAULTSTRING;
++
++ //! Constructor
++ XmlRpcServerConnection(int fd, XmlRpcServer* server, bool deleteOnClose = false);
++ //! Destructor
++ virtual ~XmlRpcServerConnection();
++
++ // XmlRpcSource interface implementation
++ //! Handle IO on the client connection socket.
++ //! @param eventType Type of IO event that occurred. @see XmlRpcDispatch::EventType.
++ virtual unsigned handleEvent(unsigned eventType);
++
++ protected:
++
++ bool readHeader();
++ bool readRequest();
++ bool writeResponse();
++
++ // Parses the request, runs the method, generates the response xml.
++ virtual void executeRequest();
++
++ // Parse the methodName and parameters from the request.
++ std::string parseRequest(XmlRpcValue& params);
++
++ // Execute a named method with the specified params.
++ bool executeMethod(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
++
++ // Execute multiple calls and return the results in an array.
++ bool executeMulticall(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
++
++ // Construct a response from the result XML.
++ void generateResponse(std::string const& resultXml);
++ void generateFaultResponse(std::string const& msg, int errorCode = -1);
++ std::string generateHeader(std::string const& body);
++
++
++ // The XmlRpc server that accepted this connection
++ XmlRpcServer* _server;
++
++ // Possible IO states for the connection
++ enum ServerConnectionState { READ_HEADER, READ_REQUEST, WRITE_RESPONSE };
++ ServerConnectionState _connectionState;
++
++ // Request headers
++ std::string _header;
++
++ // Number of bytes expected in the request body (parsed from header)
++ int _contentLength;
++
++ // Request body
++ std::string _request;
++
++ // Response
++ std::string _response;
++
++ // Number of bytes of the response written so far
++ int _bytesWritten;
++
++ // Whether to keep the current client connection open for further requests
++ bool _keepAlive;
++ };
++} // namespace XmlRpc
++
++#endif // _XMLRPCSERVERCONNECTION_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerMethod.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerMethod.h
+new file mode 100644
+index 0000000..90dddcd
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcServerMethod.h
+@@ -0,0 +1,49 @@
++
++#ifndef _XMLRPCSERVERMETHOD_H_
++#define _XMLRPCSERVERMETHOD_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++#ifndef MAKEDEPEND
++# include <string>
++#endif
++
++namespace XmlRpc {
++
++ // Representation of a parameter or result value
++ class XmlRpcValue;
++
++ // The XmlRpcServer processes client requests to call RPCs
++ class XmlRpcServer;
++
++ //! Abstract class representing a single RPC method
++ class XMLRPCPP_DECL XmlRpcServerMethod {
++ public:
++ //! Constructor
++ XmlRpcServerMethod(std::string const& name, XmlRpcServer* server = 0);
++ //! Destructor
++ virtual ~XmlRpcServerMethod();
++
++ //! Returns the name of the method
++ std::string& name() { return _name; }
++
++ //! Execute the method. Subclasses must provide a definition for this method.
++ virtual void execute(XmlRpcValue& params, XmlRpcValue& result) = 0;
++
++ //! Returns a help string for the method.
++ //! Subclasses should define this method if introspection is being used.
++ virtual std::string help() { return std::string(); }
++
++ protected:
++ std::string _name;
++ XmlRpcServer* _server;
++ };
++} // namespace XmlRpc
++
++#endif // _XMLRPCSERVERMETHOD_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSocket.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSocket.h
+new file mode 100644
+index 0000000..bc9a530
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSocket.h
+@@ -0,0 +1,80 @@
++// this file modified by Morgan Quigley on 22 Apr 2008.
++// added features: server can be opened on port 0 and you can read back
++// what port the OS gave you
++
++#ifndef _XMLRPCSOCKET_H_
++#define _XMLRPCSOCKET_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#ifndef MAKEDEPEND
++# include <string>
++#endif
++
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++namespace XmlRpc {
++
++ //! A platform-independent socket API.
++ class XMLRPCPP_DECL XmlRpcSocket {
++ public:
++
++ static bool s_use_ipv6_;
++
++ //! Creates a stream (TCP) socket. Returns -1 on failure.
++ static int socket();
++
++ //! Closes a socket.
++ static void close(int socket);
++
++
++ //! Sets a stream (TCP) socket to perform non-blocking IO. Returns false on failure.
++ static bool setNonBlocking(int socket);
++
++ //! Read text from the specified socket. Returns false on error.
++ static bool nbRead(int socket, std::string& s, bool *eof);
++
++ //! Write text to the specified socket. Returns false on error.
++ static bool nbWrite(int socket, std::string& s, int *bytesSoFar);
++
++
++ // The next four methods are appropriate for servers.
++
++ //! Allow the port the specified socket is bound to to be re-bound immediately so
++ //! server re-starts are not delayed. Returns false on failure.
++ static bool setReuseAddr(int socket);
++
++ //! Bind to a specified port
++ static bool bind(int socket, int port);
++
++ static int get_port(int socket);
++
++ //! Set socket in listen mode
++ static bool listen(int socket, int backlog);
++
++ //! Accept a client connection request
++ static int accept(int socket);
++
++
++
++ //! Connect a socket to a server (from a client)
++ static bool connect(int socket, std::string& host, int port);
++
++
++ //! Returns last errno
++ static int getError();
++
++ //! Returns message corresponding to last error
++ static std::string getErrorMsg();
++
++ //! Returns message corresponding to error
++ static std::string getErrorMsg(int error);
++ };
++
++} // namespace XmlRpc
++
++#endif
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSource.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSource.h
+new file mode 100644
+index 0000000..217f416
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcSource.h
+@@ -0,0 +1,57 @@
++
++#ifndef _XMLRPCSOURCE_H_
++#define _XMLRPCSOURCE_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++namespace XmlRpc {
++
++ //! An RPC source represents a file descriptor to monitor
++ class XMLRPCPP_DECL XmlRpcSource {
++ public:
++ //! Constructor
++ //! @param fd The socket file descriptor to monitor.
++ //! @param deleteOnClose If true, the object deletes itself when close is called.
++ XmlRpcSource(int fd = -1, bool deleteOnClose = false);
++
++ //! Destructor
++ virtual ~XmlRpcSource();
++
++ //! Return the file descriptor being monitored.
++ int getfd() const { return _fd; }
++ //! Specify the file descriptor to monitor.
++ void setfd(int fd) { _fd = fd; }
++
++ //! Return whether the file descriptor should be kept open if it is no longer monitored.
++ bool getKeepOpen() const { return _keepOpen; }
++ //! Specify whether the file descriptor should be kept open if it is no longer monitored.
++ void setKeepOpen(bool b=true) { _keepOpen = b; }
++
++ //! Close the owned fd. If deleteOnClose was specified at construction, the object is deleted.
++ virtual void close();
++
++ //! Return true to continue monitoring this source
++ virtual unsigned handleEvent(unsigned eventType) = 0;
++
++ private:
++
++ // Socket. This should really be a SOCKET (an alias for unsigned int*) on windows...
++ int _fd;
++
++ // In the server, a new source (XmlRpcServerConnection) is created
++ // for each connected client. When each connection is closed, the
++ // corresponding source object is deleted.
++ bool _deleteOnClose;
++
++ // In the client, keep connections open if you intend to make multiple calls.
++ bool _keepOpen;
++ };
++} // namespace XmlRpc
++
++#endif //_XMLRPCSOURCE_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcUtil.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcUtil.h
+new file mode 100644
+index 0000000..acde160
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcUtil.h
+@@ -0,0 +1,63 @@
++#ifndef _XMLRPCUTIL_H_
++#define _XMLRPCUTIL_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#ifndef MAKEDEPEND
++# include <string>
++#endif
++
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++#if defined(_MSC_VER)
++# define snprintf _snprintf_s
++# define vsnprintf _vsnprintf_s
++# define strcasecmp _stricmp
++# define strncasecmp _strnicmp
++#elif defined(__BORLANDC__)
++# define strcasecmp stricmp
++# define strncasecmp strnicmp
++#endif
++
++namespace XmlRpc {
++
++ //! Utilities for XML parsing, encoding, and decoding and message handlers.
++ class XMLRPCPP_DECL XmlRpcUtil {
++ public:
++ // hokey xml parsing
++ //! Returns contents between <tag> and </tag>, updates offset to char after </tag>
++ static std::string parseTag(const char* tag, std::string const& xml, int* offset);
++
++ //! Returns true if the tag is found and updates offset to the char after the tag
++ static bool findTag(const char* tag, std::string const& xml, int* offset);
++
++ //! Returns the next tag and updates offset to the char after the tag, or empty string
++ //! if the next non-whitespace character is not '<'
++ static std::string getNextTag(std::string const& xml, int* offset);
++
++ //! Returns true if the tag is found at the specified offset (modulo any whitespace)
++ //! and updates offset to the char after the tag
++ static bool nextTagIs(const char* tag, std::string const& xml, int* offset);
++
++
++ //! Convert raw text to encoded xml.
++ static std::string xmlEncode(const std::string& raw);
++
++ //! Convert encoded xml to raw text
++ static std::string xmlDecode(const std::string& encoded);
++
++
++ //! Dump messages somewhere
++ static void log(int level, const char* fmt, ...);
++
++ //! Dump error messages somewhere
++ static void error(const char* fmt, ...);
++
++ };
++} // namespace XmlRpc
++
++#endif // _XMLRPCUTIL_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h
+new file mode 100644
+index 0000000..0d72c59
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h
+@@ -0,0 +1,195 @@
++
++#ifndef _XMLRPCVALUE_H_
++#define _XMLRPCVALUE_H_
++//
++// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
++//
++#if defined(_MSC_VER)
++# pragma warning(disable:4786) // identifier was truncated in debug info
++#endif
++
++#include "xmlrpcpp/XmlRpcDecl.h"
++
++#ifndef MAKEDEPEND
++# include <map>
++# include <string>
++# include <vector>
++# include <time.h>
++#endif
++
++namespace XmlRpc {
++
++ //! RPC method arguments and results are represented by Values
++ // should probably refcount them...
++ class XMLRPCPP_DECL XmlRpcValue {
++ public:
++
++
++ enum Type {
++ TypeInvalid,
++ TypeBoolean,
++ TypeInt,
++ TypeDouble,
++ TypeString,
++ TypeDateTime,
++ TypeBase64,
++ TypeArray,
++ TypeStruct
++ };
++
++ // Non-primitive types
++ typedef std::vector<char> BinaryData;
++ typedef std::vector<XmlRpcValue> ValueArray;
++ typedef std::map<std::string, XmlRpcValue> ValueStruct;
++ typedef ValueStruct::iterator iterator;
++
++
++ //! Constructors
++ XmlRpcValue() : _type(TypeInvalid) { _value.asBinary = 0; }
++ XmlRpcValue(bool value) : _type(TypeBoolean) { _value.asBool = value; }
++ XmlRpcValue(int value) : _type(TypeInt) { _value.asInt = value; }
++ XmlRpcValue(double value) : _type(TypeDouble) { _value.asDouble = value; }
++
++ XmlRpcValue(std::string const& value) : _type(TypeString)
++ { _value.asString = new std::string(value); }
++
++ XmlRpcValue(const char* value) : _type(TypeString)
++ { _value.asString = new std::string(value); }
++
++ XmlRpcValue(struct tm* value) : _type(TypeDateTime)
++ { _value.asTime = new struct tm(*value); }
++
++
++ XmlRpcValue(void* value, int nBytes) : _type(TypeBase64)
++ {
++ _value.asBinary = new BinaryData((char*)value, ((char*)value)+nBytes);
++ }
++
++ //! Construct from xml, beginning at *offset chars into the string, updates offset
++ XmlRpcValue(std::string const& xml, int* offset) : _type(TypeInvalid)
++ { if ( ! fromXml(xml,offset)) _type = TypeInvalid; }
++
++ //! Copy
++ XmlRpcValue(XmlRpcValue const& rhs) : _type(TypeInvalid) { *this = rhs; }
++
++ //! Destructor (make virtual if you want to subclass)
++ /*virtual*/ ~XmlRpcValue() { invalidate(); }
++
++ //! Erase the current value
++ void clear() { invalidate(); }
++
++ // Operators
++ XmlRpcValue& operator=(XmlRpcValue const& rhs);
++ XmlRpcValue& operator=(int const& rhs) { return operator=(XmlRpcValue(rhs)); }
++ XmlRpcValue& operator=(double const& rhs) { return operator=(XmlRpcValue(rhs)); }
++ XmlRpcValue& operator=(const char* rhs) { return operator=(XmlRpcValue(std::string(rhs))); }
++
++ bool operator==(XmlRpcValue const& other) const;
++ bool operator!=(XmlRpcValue const& other) const;
++
++ operator bool&() { assertTypeOrInvalid(TypeBoolean); return _value.asBool; }
++ operator int&() { assertTypeOrInvalid(TypeInt); return _value.asInt; }
++ operator double&() { assertTypeOrInvalid(TypeDouble); return _value.asDouble; }
++ operator std::string&() { assertTypeOrInvalid(TypeString); return *_value.asString; }
++ operator BinaryData&() { assertTypeOrInvalid(TypeBase64); return *_value.asBinary; }
++ operator struct tm&() { assertTypeOrInvalid(TypeDateTime); return *_value.asTime; }
++
++ XmlRpcValue const& operator[](int i) const { assertArray(i+1); return _value.asArray->at(i); }
++ XmlRpcValue& operator[](int i) { assertArray(i+1); return _value.asArray->at(i); }
++
++ XmlRpcValue& operator[](std::string const& k) { assertStruct(); return (*_value.asStruct)[k]; }
++ XmlRpcValue& operator[](const char* k) { assertStruct(); std::string s(k); return (*_value.asStruct)[s]; }
++
++ iterator begin() {assertStruct(); return (*_value.asStruct).begin(); }
++ iterator end() {assertStruct(); return (*_value.asStruct).end(); }
++
++ // Accessors
++ //! Return true if the value has been set to something.
++ bool valid() const { return _type != TypeInvalid; }
++
++ //! Return the type of the value stored. \see Type.
++ Type const &getType() const { return _type; }
++
++ //! Return the size for string, base64, array, and struct values.
++ int size() const;
++
++ //! Specify the size for array values. Array values will grow beyond this size if needed.
++ void setSize(int size) { assertArray(size); }
++
++ //! Check for the existence of a struct member by name.
++ bool hasMember(const std::string& name) const;
++
++ //! Decode xml. Destroys any existing value.
++ bool fromXml(std::string const& valueXml, int* offset);
++
++ //! Encode the Value in xml
++ std::string toXml() const;
++
++ //! Write the value (no xml encoding)
++ std::ostream& write(std::ostream& os) const;
++
++ // Formatting
++ //! Return the format used to write double values.
++ static std::string const& getDoubleFormat() { return _doubleFormat; }
++
++ //! Specify the format used to write double values.
++ static void setDoubleFormat(const char* f) { _doubleFormat = f; }
++
++
++ protected:
++ // Clean up
++ void invalidate();
++
++ // Type checking
++ void assertTypeOrInvalid(Type t);
++ void assertArray(int size) const;
++ void assertArray(int size);
++ void assertStruct();
++
++ // XML decoding
++ bool boolFromXml(std::string const& valueXml, int* offset);
++ bool intFromXml(std::string const& valueXml, int* offset);
++ bool doubleFromXml(std::string const& valueXml, int* offset);
++ bool stringFromXml(std::string const& valueXml, int* offset);
++ bool timeFromXml(std::string const& valueXml, int* offset);
++ bool binaryFromXml(std::string const& valueXml, int* offset);
++ bool arrayFromXml(std::string const& valueXml, int* offset);
++ bool structFromXml(std::string const& valueXml, int* offset);
++
++ // XML encoding
++ std::string boolToXml() const;
++ std::string intToXml() const;
++ std::string doubleToXml() const;
++ std::string stringToXml() const;
++ std::string timeToXml() const;
++ std::string binaryToXml() const;
++ std::string arrayToXml() const;
++ std::string structToXml() const;
++
++ // Format strings
++ static std::string _doubleFormat;
++
++ // Type tag and values
++ Type _type;
++
++ // At some point I will split off Arrays and Structs into
++ // separate ref-counted objects for more efficient copying.
++ union {
++ bool asBool;
++ int asInt;
++ double asDouble;
++ struct tm* asTime;
++ std::string* asString;
++ BinaryData* asBinary;
++ ValueArray* asArray;
++ ValueStruct* asStruct;
++ } _value;
++
++ };
++} // namespace XmlRpc
++
++
++std::ostream& operator<<(std::ostream& os, XmlRpc::XmlRpcValue& v);
++
++
++#endif // _XMLRPCVALUE_H_
+diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/base64.h b/utilities/xmlrpcpp/include/xmlrpcpp/base64.h
+new file mode 100644
+index 0000000..c239403
+--- /dev/null
++++ b/utilities/xmlrpcpp/include/xmlrpcpp/base64.h
+@@ -0,0 +1,380 @@
++
++
++// base64.hpp
++// Autor Konstantin Pilipchuk
++// mailto:lostd at ukr.net
++//
++//
++
++#if !defined(__BASE64_H_INCLUDED__)
++#define __BASE64_H_INCLUDED__ 1
++
++#ifndef MAKEDEPEND
++# include <iterator>
++#endif
++
++#include <ios>
++
++static
++int _base64Chars[]= {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
++ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
++ '0','1','2','3','4','5','6','7','8','9',
++ '+','/' };
++
++
++#define _0000_0011 0x03
++#define _1111_1100 0xFC
++#define _1111_0000 0xF0
++#define _0011_0000 0x30
++#define _0011_1100 0x3C
++#define _0000_1111 0x0F
++#define _1100_0000 0xC0
++#define _0011_1111 0x3F
++
++#define _EQUAL_CHAR (-1)
++#define _UNKNOWN_CHAR (-2)
++
++#define _IOS_FAILBIT std::ios_base::failbit
++#define _IOS_EOFBIT std::ios_base::eofbit
++#define _IOS_BADBIT std::ios_base::badbit
++#define _IOS_GOODBIT std::ios_base::goodbit
++
++// TEMPLATE CLASS base64_put
++template<class _E = char, class _Tr = std::char_traits<_E> >
++class base64
++{
++public:
++
++ typedef unsigned char byte_t;
++ typedef _E char_type;
++ typedef _Tr traits_type;
++
++ // base64 requires max line length <= 72 characters
++ // you can fill end of line
++ // it may be crlf, crlfsp, noline or other class like it
++
++
++ struct crlf
++ {
++ template<class _OI>
++ _OI operator()(_OI _To) const{
++ *_To = _Tr::to_char_type('\r'); ++_To;
++ *_To = _Tr::to_char_type('\n'); ++_To;
++
++ return (_To);
++ }
++ };
++
++
++ struct crlfsp
++ {
++ template<class _OI>
++ _OI operator()(_OI _To) const{
++ *_To = _Tr::to_char_type('\r'); ++_To;
++ *_To = _Tr::to_char_type('\n'); ++_To;
++ *_To = _Tr::to_char_type(' '); ++_To;
++
++ return (_To);
++ }
++ };
++
++ struct noline
++ {
++ template<class _OI>
++ _OI operator()(_OI _To) const{
++ return (_To);
++ }
++ };
++
++ struct three2four
++ {
++ void zero()
++ {
++ _data[0] = 0;
++ _data[1] = 0;
++ _data[2] = 0;
++ }
++
++ byte_t get_0() const
++ {
++ return _data[0];
++ }
++ byte_t get_1() const
++ {
++ return _data[1];
++ }
++ byte_t get_2() const
++ {
++ return _data[2];
++ }
++
++ void set_0(byte_t _ch)
++ {
++ _data[0] = _ch;
++ }
++
++ void set_1(byte_t _ch)
++ {
++ _data[1] = _ch;
++ }
++
++ void set_2(byte_t _ch)
++ {
++ _data[2] = _ch;
++ }
++
++ // 0000 0000 1111 1111 2222 2222
++ // xxxx xxxx xxxx xxxx xxxx xxxx
++ // 0000 0011 1111 2222 2233 3333
++
++ int b64_0() const {return (_data[0] & _1111_1100) >> 2;}
++ int b64_1() const {return ((_data[0] & _0000_0011) << 4) + ((_data[1] & _1111_0000)>>4);}
++ int b64_2() const {return ((_data[1] & _0000_1111) << 2) + ((_data[2] & _1100_0000)>>6);}
++ int b64_3() const {return (_data[2] & _0011_1111);}
++
++ void b64_0(int _ch) {_data[0] = ((_ch & _0011_1111) << 2) | (_0000_0011 & _data[0]);}
++
++ void b64_1(int _ch) {
++ _data[0] = ((_ch & _0011_0000) >> 4) | (_1111_1100 & _data[0]);
++ _data[1] = ((_ch & _0000_1111) << 4) | (_0000_1111 & _data[1]); }
++
++ void b64_2(int _ch) {
++ _data[1] = ((_ch & _0011_1100) >> 2) | (_1111_0000 & _data[1]);
++ _data[2] = ((_ch & _0000_0011) << 6) | (_0011_1111 & _data[2]); }
++
++ void b64_3(int _ch){
++ _data[2] = (_ch & _0011_1111) | (_1100_0000 & _data[2]);}
++
++ private:
++ byte_t _data[3];
++
++ };
++
++
++
++
++ template<class _II, class _OI, class _State, class _Endline>
++ _II put(_II _First, _II _Last, _OI _To, _State&, _Endline) const
++ {
++ three2four _3to4;
++ int line_octets = 0;
++
++ while(_First != _Last)
++ {
++ _3to4.zero();
++
++ _3to4.set_0(*_First);
++ _First++;
++
++ if(_First == _Last)
++ {
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_0()]); ++_To;
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_1()]); ++_To;
++ *_To = _Tr::to_char_type('='); ++_To;
++ *_To = _Tr::to_char_type('='); ++_To;
++ goto __end;
++ }
++
++ _3to4.set_1(*_First);
++ _First++;
++
++ if(_First == _Last)
++ {
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_0()]); ++_To;
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_1()]); ++_To;
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_2()]); ++_To;
++ *_To = _Tr::to_char_type('='); ++_To;
++ goto __end;
++ }
++
++ _3to4.set_2(*_First);
++ _First++;
++
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_0()]); ++_To;
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_1()]); ++_To;
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_2()]); ++_To;
++ *_To = _Tr::to_char_type(_base64Chars[_3to4.b64_3()]); ++_To;
++
++ if(line_octets == 17)
++ {
++ //_To = _Endl(_To);
++ *_To = '\n'; ++_To;
++ line_octets = 0;
++ }
++ else
++ ++line_octets;
++ }
++
++ __end: ;
++
++ return (_First);
++
++ }
++
++
++ template<class _II, class _OI, class _State>
++ _II get(_II _First, _II _Last, _OI _To, _State& _St) const
++ {
++ three2four _3to4;
++ int _Char;
++
++ while(_First != _Last)
++ {
++
++ // Take octet
++ _3to4.zero();
++
++ // -- 0 --
++ // Search next valid char...
++ while((_Char = _getCharType(*_First)) < 0 && _Char == _UNKNOWN_CHAR)
++ {
++ if(++_First == _Last)
++ {
++ _St |= _IOS_FAILBIT|_IOS_EOFBIT; return _First; // unexpected EOF
++ }
++ }
++
++ if(_Char == _EQUAL_CHAR){
++ // Error! First character in octet can't be '='
++ _St |= _IOS_FAILBIT;
++ return _First;
++ }
++ else
++ _3to4.b64_0(_Char);
++
++
++ // -- 1 --
++ // Search next valid char...
++ while(++_First != _Last)
++ if((_Char = _getCharType(*_First)) != _UNKNOWN_CHAR)
++ break;
++
++ if(_First == _Last) {
++ _St |= _IOS_FAILBIT|_IOS_EOFBIT; // unexpected EOF
++ return _First;
++ }
++
++ if(_Char == _EQUAL_CHAR){
++ // Error! Second character in octet can't be '='
++ _St |= _IOS_FAILBIT;
++ return _First;
++ }
++ else
++ _3to4.b64_1(_Char);
++
++
++ // -- 2 --
++ // Search next valid char...
++ while(++_First != _Last)
++ if((_Char = _getCharType(*_First)) != _UNKNOWN_CHAR)
++ break;
++
++ if(_First == _Last) {
++ // Error! Unexpected EOF. Must be '=' or base64 character
++ _St |= _IOS_FAILBIT|_IOS_EOFBIT;
++ return _First;
++ }
++
++ if(_Char == _EQUAL_CHAR){
++ // OK!
++ _3to4.b64_2(0);
++ _3to4.b64_3(0);
++
++ // chek for EOF
++ if(++_First == _Last)
++ {
++ // Error! Unexpected EOF. Must be '='. Ignore it.
++ //_St |= _IOS_BADBIT|_IOS_EOFBIT;
++ _St |= _IOS_EOFBIT;
++ }
++ else
++ if(_getCharType(*_First) != _EQUAL_CHAR)
++ {
++ // Error! Must be '='. Ignore it.
++ //_St |= _IOS_BADBIT;
++ }
++ else
++ ++_First; // Skip '='
++
++ // write 1 byte to output
++ *_To = (byte_t) _3to4.get_0();
++ return _First;
++ }
++ else
++ _3to4.b64_2(_Char);
++
++
++ // -- 3 --
++ // Search next valid char...
++ while(++_First != _Last)
++ if((_Char = _getCharType(*_First)) != _UNKNOWN_CHAR)
++ break;
++
++ if(_First == _Last) {
++ // Unexpected EOF. It's error. But ignore it.
++ //_St |= _IOS_FAILBIT|_IOS_EOFBIT;
++ _St |= _IOS_EOFBIT;
++
++ return _First;
++ }
++
++ if(_Char == _EQUAL_CHAR)
++ {
++ // OK!
++ _3to4.b64_3(0);
++
++ // write to output 2 bytes
++ *_To = (byte_t) _3to4.get_0();
++ *_To = (byte_t) _3to4.get_1();
++
++ ++_First; // set position to next character
++
++ return _First;
++ }
++ else
++ _3to4.b64_3(_Char);
++
++
++ // write to output 3 bytes
++ *_To = (byte_t) _3to4.get_0();
++ *_To = (byte_t) _3to4.get_1();
++ *_To = (byte_t) _3to4.get_2();
++
++ ++_First;
++
++
++ } // while(_First != _Last)
++
++ return (_First);
++ }
++
++protected:
++
++ int _getCharType(int _Ch) const
++ {
++ if(_base64Chars[62] == _Ch)
++ return 62;
++
++ if(_base64Chars[63] == _Ch)
++ return 63;
++
++ if((_base64Chars[0] <= _Ch) && (_base64Chars[25] >= _Ch))
++ return _Ch - _base64Chars[0];
++
++ if((_base64Chars[26] <= _Ch) && (_base64Chars[51] >= _Ch))
++ return _Ch - _base64Chars[26] + 26;
++
++ if((_base64Chars[52] <= _Ch) && (_base64Chars[61] >= _Ch))
++ return _Ch - _base64Chars[52] + 52;
++
++ if(_Ch == _Tr::to_int_type('='))
++ return _EQUAL_CHAR;
++
++ return _UNKNOWN_CHAR;
++ }
++
++
++};
++
++
++#endif
diff --git a/utilities/xmlrpcpp/src/XmlRpcClient.cpp b/utilities/xmlrpcpp/src/XmlRpcClient.cpp
index 31cda22..b533059 100644
--- a/utilities/xmlrpcpp/src/XmlRpcClient.cpp
diff --git a/debian/patches/series b/debian/patches/series
index b4a3e11..fcf71e2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,4 +4,4 @@
0004-Fix-executable-not-elf-or-script.patch
0005-Add-defaults-to-roswtf.patch
0006-Fix-confusing-copyright-messages-dates.patch
-0007-Move-headers-to-include-xmlrpcpp.patch
+0007-Move-headers-to-include-xmlrpcpp-adapted.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ros/ros-ros-comm.git
More information about the debian-science-commits
mailing list