This file is indexed.

/usr/include/xmlrpc-c/oldcppwrapper.hpp is in libxmlrpc-c++8-dev 1.33.14-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
// -*- C++ -*-   <-- an Emacs control

// Copyright information is at the bottom of the file.

//=========================================================================
//  XML-RPC C++ API
//=========================================================================


#ifndef XMLRPCCPP_H_INCLUDED
#define XMLRPCCPP_H_INCLUDED

/*
  XMLRPC_OLDCPPWRAPPER_EXPORTED marks a symbol in this file that is exported
  from libxmlrpc_cpp.

  XMLRPC_BUILDING_OLDCPPWRAPPER says this compilation is part of
  libxmlrpc_cpp, as opposed to something that _uses_ libxmlrpc_cpp.
*/
#ifdef XMLRPC_BUILDING_OLDCPPWRAPPER
#define XMLRPC_OLDCPPWRAPPER_EXPORTED XMLRPC_DLLEXPORT
#else
#define XMLRPC_OLDCPPWRAPPER_EXPORTED
#endif

#include <cstdlib>
#include <string>

#include <xmlrpc-c/c_util.h>
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/client.h>
#include <xmlrpc-c/server.h>

//=========================================================================
//  XmlRpcFault
//=========================================================================
//  A C++ exception class representing an XML-RPC fault.

class XMLRPC_OLDCPPWRAPPER_EXPORTED XmlRpcFault {

private:
    xmlrpc_env   mFault;

    XmlRpcFault& operator= (XmlRpcFault const& f)
        { if (true || f.getFaultCode()) abort(); return (XmlRpcFault&) f; }

public:
    XmlRpcFault (const XmlRpcFault &fault);
    XmlRpcFault (const int faultCode, const std::string faultString);
    XmlRpcFault (const xmlrpc_env *env);
    ~XmlRpcFault (void);

    inline int getFaultCode (void) const;
    std::string getFaultString (void) const;
    inline xmlrpc_env * getFaultEnv (void);
};

inline int XmlRpcFault::getFaultCode (void) const {
    return mFault.fault_code;
}

inline xmlrpc_env *XmlRpcFault::getFaultEnv (void) {
    return &mFault;
}


//=========================================================================
//  XmlRpcEnv
//=========================================================================
//  This class can be used to wrap xmlrpc_env object. Use it as follows:
//
//    XmlRpcEnv env;
//    xmlrpc_parse_value(env, v, "(i)", &i);
//    env.throwIfFaultOccurred();        

class XMLRPC_OLDCPPWRAPPER_EXPORTED XmlRpcEnv {

private:
    xmlrpc_env   mEnv;

    void         throwMe (void) const;
    XmlRpcEnv&   operator= (XmlRpcEnv const& e)
        { if (true || e.faultOccurred()) abort(); return (XmlRpcEnv&) e;}

public:
    XmlRpcEnv (const XmlRpcEnv &env);
    XmlRpcEnv (void) { xmlrpc_env_init(&mEnv); }
    ~XmlRpcEnv (void) { xmlrpc_env_clean(&mEnv); }
    
    bool     faultOccurred (void) const {return (mEnv.fault_occurred != 0);};
    bool         hasFaultOccurred (void) const { return faultOccurred(); };
        /* hasFaultOccurred() is for backward compatibility.
           faultOccurred() is a superior name for this.
        */
    std::string  getFaultString() const { return mEnv.fault_string; };
    XmlRpcFault  getFault (void) const;

    void         throwIfFaultOccurred (void) const;

    operator xmlrpc_env * (void) { return &mEnv; }
};

inline void XmlRpcEnv::throwIfFaultOccurred (void) const {
    if (faultOccurred())
        throwMe();
}


//=========================================================================
//  XmlRpcValue
//=========================================================================
//  An object in this class is an XML-RPC value.
//
//  We have a complex structure to allow C code mixed in with C++ code
//  which uses this class to refer to the same XML-RPC value object.
//  This is especially important because there aren't proper C++ facilities
//  for much of Xmlrpc-c; you have to use the C facilities even if you'd
//  rather use proper C++.
//
//  The XmlRpcValue object internally represents the value as an
//  xmlrpc_value.  It holds one reference to the xmlrpc_value.  Users
//  of XmlRpcValue never see that xmlrpc_value, but C code can.  the
//  C code might create the xmlrpc_value and then bind it to an XmlRpcValue,
//  or it might get the xmlrpc_value handle from the XmlRpcValue.  Finally,
//  C code can simply use the XmlRpcValue where an xmlrpc_value handle is
//  required and it gets converted automatically.
//
//  So reference counting for the xmlrpc_value is quite a nightmare.

class XMLRPC_OLDCPPWRAPPER_EXPORTED XmlRpcValue {

private:
    xmlrpc_value *mValue;

public:
    enum ReferenceBehavior {
        MAKE_REFERENCE,
        CONSUME_REFERENCE
    };

    typedef xmlrpc_int32 int32;
    
    XmlRpcValue (void);
    XmlRpcValue (xmlrpc_value *value,
                 ReferenceBehavior behavior = MAKE_REFERENCE);
    XmlRpcValue (const XmlRpcValue& value);
    ~XmlRpcValue (void);
    
    XmlRpcValue&  operator= (const XmlRpcValue& value);

    // Accessing the value's type (think of this as lightweight RTTI).
    xmlrpc_type getType(void) const;
    
    // We don't supply an automatic conversion operator--you need to say
    // whether you want to make or borrow this object's reference.
    // XXX - Is it really OK for these to be const?
    xmlrpc_value *makeReference (void) const;
    xmlrpc_value *borrowReference (void) const;

    // Some static "constructor" functions.
    static XmlRpcValue makeInt      (const XmlRpcValue::int32 i);
    static XmlRpcValue makeBool     (const bool b);
    static XmlRpcValue makeDouble   (const double d);
    static XmlRpcValue makeDateTime (const std::string& dateTime);
    static XmlRpcValue makeString   (const std::string& str);
    static XmlRpcValue makeString   (const char *const str);
    static XmlRpcValue makeString   (const char *const str, size_t len);
    static XmlRpcValue makeArray    (void);
    static XmlRpcValue makeStruct   (void);
    static XmlRpcValue makeBase64   (const unsigned char *const data,
                                     size_t len);
    /*
    // An interface to xmlrpc_build_value.
    static XmlRpcValue buildValue (const char *const format, ...);
    */

    // Some functions to get the underlying data.
    // These will throw an XmlRpcFault if the data is the wrong type.
    XmlRpcValue::int32 getInt   (void) const;
    bool         getBool        (void) const;
    double       getDouble      (void) const;
    std::string  getRawDateTime (void) const;
    std::string  getString      (void) const;
    XmlRpcValue  getArray       (void) const;
    XmlRpcValue  getStruct      (void) const;

    // This returns an internal pointer which will become invalid when
    // all references to the underlying value are destroyed.
    void         getBase64      (const unsigned char *& out_data,
                                 size_t& out_len) const;

    /*
    // An interface to xmlrpc_parse_value.
    void parseValue (const char *const format, ...);
    */

    // Array functions. These will throw an XmlRpcFault if the value
    // isn't an array.
    size_t       arraySize (void) const;
    void         arrayAppendItem (const XmlRpcValue& value);
    XmlRpcValue  arrayGetItem (int index) const;
    
    // Struct functions. These will throw an XmlRpcFault if the value
    // isn't a struct.
    size_t       structSize (void) const;
    bool         structHasKey (const std::string& key) const;
    XmlRpcValue  structGetValue (const std::string& key) const;
    void         structSetValue (const std::string& key, 
                                 const XmlRpcValue& value);
    void         structGetKeyAndValue (const int index,
                                       std::string& out_key,
                                       XmlRpcValue& out_value) const;
};

inline XmlRpcValue::XmlRpcValue (xmlrpc_value *value,
                                 ReferenceBehavior behavior) 
{
    mValue = value;

    if (behavior == MAKE_REFERENCE)
        xmlrpc_INCREF(value);
}

inline XmlRpcValue::XmlRpcValue (const XmlRpcValue& value) {
    mValue = value.mValue;
    xmlrpc_INCREF(mValue);
}

inline XmlRpcValue::~XmlRpcValue (void) {
    xmlrpc_DECREF(mValue);
}

inline XmlRpcValue& XmlRpcValue::operator= (const XmlRpcValue& value) {
    // Must increment before we decrement, in case of assignment to self.
    xmlrpc_INCREF(value.mValue);
    xmlrpc_DECREF(mValue);
    mValue = value.mValue;
    return *this;
}

inline xmlrpc_type XmlRpcValue::getType (void) const {
    return xmlrpc_value_type(mValue);
}

inline xmlrpc_value *XmlRpcValue::makeReference (void) const {
    xmlrpc_INCREF(mValue);
    return mValue;
}

inline xmlrpc_value *XmlRpcValue::borrowReference (void) const {
    return mValue;
}


//=========================================================================
//  XmlRpcClient
//=========================================================================

class XMLRPC_OLDCPPWRAPPER_EXPORTED XmlRpcClient {

private:
    std::string mServerUrl;

public:
    static void Initialize (std::string appname, std::string appversion);
    static void Terminate (void);

    XmlRpcClient (const std::string& server_url) : mServerUrl(server_url) {}
    ~XmlRpcClient (void) {}

    XmlRpcClient (const XmlRpcClient& client);
    XmlRpcClient& operator= (const XmlRpcClient& client);

    XmlRpcValue call (std::string method_name, XmlRpcValue param_array);
    void call_asynch (std::string method_name,
                      XmlRpcValue param_array,
                      xmlrpc_response_handler callback,
                      void* user_data);
    void event_loop_asynch (unsigned long milliseconds);
};

inline void XmlRpcClient::call_asynch(std::string method_name,
                                      XmlRpcValue param_array,
                                      xmlrpc_response_handler callback,
                                      void* user_data)
{
    xmlrpc_client_call_asynch_params(
        mServerUrl.c_str(),
        method_name.c_str(),
        callback,
        user_data,
        param_array.borrowReference());
}

inline void XmlRpcClient::event_loop_asynch(unsigned long milliseconds)
{
    xmlrpc_client_event_loop_finish_asynch_timeout(milliseconds);
}


//=========================================================================
//  XmlRpcClient Methods
//=========================================================================
//  These are inline for now, so we don't need to screw with linker issues
//  and build a separate client library.

inline XmlRpcClient::XmlRpcClient (const XmlRpcClient& client)
    : mServerUrl(client.mServerUrl)
{
}

inline XmlRpcClient& XmlRpcClient::operator= (const XmlRpcClient& client) {
    if (this != &client)
        mServerUrl = client.mServerUrl;
    return *this;
}

inline void XmlRpcClient::Initialize (std::string appname, 
                                      std::string appversion) {
    xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS,
                       appname.c_str(),
                       appversion.c_str());
}

inline void XmlRpcClient::Terminate (void) {
    xmlrpc_client_cleanup();
}

inline XmlRpcValue XmlRpcClient::call (std::string method_name,
                                       XmlRpcValue param_array)
{
    XmlRpcEnv env;
    xmlrpc_value *result =
    xmlrpc_client_call_params(env,
                              mServerUrl.c_str(),
                              method_name.c_str(),
                              param_array.borrowReference());
    env.throwIfFaultOccurred();
    return XmlRpcValue(result, XmlRpcValue::CONSUME_REFERENCE);
}

//=========================================================================
//  XmlRpcGenSrv
//=========================================================================

class XMLRPC_OLDCPPWRAPPER_EXPORTED XmlRpcGenSrv {

private:

    xmlrpc_registry*    mRegistry;

    xmlrpc_mem_block* alloc (XmlRpcEnv& env, const std::string& body) const; 

public:

    XmlRpcGenSrv (int flags);
    ~XmlRpcGenSrv (void);

    xmlrpc_registry* getRegistry (void) const;

    XmlRpcGenSrv&   addMethod (const std::string& name,
                               xmlrpc_method method,
                               void *data);
    XmlRpcGenSrv&   addMethod (const std::string& name,
                               xmlrpc_method method,
                               void* data,
                               const std::string& signature,
                               const std::string& help);
    
    std::string handle (const std::string& body) const;
};

inline XmlRpcGenSrv::XmlRpcGenSrv (int) {

    XmlRpcEnv env;

    mRegistry = xmlrpc_registry_new (env);
    env.throwIfFaultOccurred();        
}

inline XmlRpcGenSrv::~XmlRpcGenSrv (void) {

    xmlrpc_registry_free (mRegistry);
}

inline xmlrpc_registry* XmlRpcGenSrv::getRegistry () const {

    return mRegistry;
}


// Copyright (C) 2001 by Eric Kidd. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. 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.
// 3. The name of the author may not be used to endorse or promote products
//    derived from this software without specific prior written permission. 
//  
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.


#endif /* _XMLRPCCPP_H_ */