This file is indexed.

/usr/include/xmltooling/util/CurlURLInputStream.h is in libxmltooling-dev 1.6.4-1ubuntu2.

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
/**
 * Licensed to the University Corporation for Advanced Internet
 * Development, Inc. (UCAID) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for
 * additional information regarding copyright ownership.
 *
 * UCAID licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the
 * License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the License.
 */

/**
 * @file xmltooling/util/CurlURLInputStream.h
 *
 * Asynchronous use of curl to fetch data from a URL.
 */

#if !defined(__xmltooling_curlinstr_h__) && !defined(XMLTOOLING_LITE)
#define __xmltooling_curlinstr_h__

#include <xmltooling/logging.h>

#include <string>
#include <vector>
#include <curl/curl.h>
#include <xercesc/util/BinInputStream.hpp>

namespace xmltooling {

    /**
     * Adapted from Xerces-C as a more advanced input stream implementation
     * for subsequent use in parsing remote documents.
     */
    class XMLTOOL_API CurlURLInputStream : public xercesc::BinInputStream
    {
    public :
        /**
         * Constructor.
         *
         * @param url       the URL of the resource to fetch
         * @param cacheTag  optional pointer to string used for cache management
         */
        CurlURLInputStream(const char* url, std::string* cacheTag=nullptr);

        /**
         * Constructor.
         *
         * @param url       the URL of the resource to fetch
         * @param cacheTag  optional pointer to string used for cache management
         */
        CurlURLInputStream(const XMLCh* url, std::string* cacheTag=nullptr);

        /**
         * Constructor taking a DOM element supporting the following content:
         * 
         * <dl>
         *  <dt>uri | url</dt>
         *  <dd>identifies the remote resource</dd>
         *  <dt>verifyHost</dt>
         *  <dd>true iff name of host should be matched against TLS/SSL certificate</dd>
         *  <dt>TransportOption elements, like so:</dt>
         *  <dd>&lt;TransportOption provider="CURL" option="150"&gt;0&lt;/TransportOption&gt;</dd>
         * </dl>
         * 
         * @param e         DOM to supply configuration
         * @param cacheTag  optional pointer to string used for cache management
         */
        CurlURLInputStream(const xercesc::DOMElement* e, std::string* cacheTag=nullptr);

        ~CurlURLInputStream();

#ifdef XMLTOOLING_XERCESC_64BITSAFE
        XMLFilePos
#else
        unsigned int
#endif
        curPos() const {
            return fTotalBytesRead;
        }

#ifdef XMLTOOLING_XERCESC_INPUTSTREAM_HAS_CONTENTTYPE
        const XMLCh* getContentType() const {
            return fContentType;
        }
#endif

        xsecsize_t readBytes(XMLByte* const toFill, const xsecsize_t maxToRead);

        /**
         * Access the OpenSSL context options in place for this object.
         *
         * @return bitmask suitable for use with SSL_CTX_set_options
         */
        int getOpenSSLOps() const {
            return fOpenSSLOps;
        }

    private :
        CurlURLInputStream(const CurlURLInputStream&);
        CurlURLInputStream& operator=(const CurlURLInputStream&);

        // libcurl callbacks for data read/write
        static size_t staticWriteCallback(char *buffer, size_t size, size_t nitems, void *outstream);
        size_t writeCallback(char *buffer, size_t size, size_t nitems);

        void init(const xercesc::DOMElement* e=nullptr);
        bool readMore(int *runningHandles);

        logging::Category&  fLog;
        std::string*        fCacheTag;
        std::string         fURL;
        std::vector<std::string>    fSavedOptions;
        int                 fOpenSSLOps;

        CURLM*              fMulti;
        CURL*               fEasy;
        struct curl_slist*  fHeaders;

        unsigned long       fTotalBytesRead;
        XMLByte*            fWritePtr;
        xsecsize_t          fBytesRead;
        xsecsize_t          fBytesToRead;
        bool                fDataAvailable;

        // Overflow buffer for when curl writes more data to us
        // than we've asked for.
        XMLByte*            fBuffer;
        XMLByte*            fBufferHeadPtr;
        XMLByte*            fBufferTailPtr;
        size_t              fBufferSize;

        XMLCh*              fContentType;
        long                fStatusCode;

        char                fError[CURL_ERROR_SIZE];
    };
};

#endif // __xmltooling_curlinstr_h__