This file is indexed.

/usr/include/libdap/D4StreamMarshaller.h is in libdap-dev 3.15.1-7.

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
// D4StreamMarshaller.h

// -*- mode: c++; c-basic-offset:4 -*-

// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.

// Copyright (c) 2002,2003,2012 OPeNDAP, Inc.
// Author: Patrick West <pwest@ucar.edu>,
//         James Gallagher <jgallagher@opendap.org>
//
// 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  USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.

#ifndef I_D4StreamMarshaller_h
#define I_D4StreamMarshaller_h 1

#include <iostream>

// By default, only support platforms that use IEEE754 for floating point values.
// Hacked up code leftover from an older version of the class; largely untested.
// jhrg 10/3/13
#define USE_XDR_FOR_IEEE754_ENCODING 0

#if USE_XDR_FOR_IEEE754_ENCODING
#ifdef WIN32
#include <rpc.h>
#include <winsock2.h>
#include <xdr.h>
#else
#include <rpc/types.h>
#include <netinet/in.h>
#include <rpc/xdr.h>
#endif
#endif

#include <stdint.h>
#include "crc.h"

#include "Marshaller.h"
#include "InternalErr.h"

namespace libdap {

class Vector;

/** @brief Marshaller that knows how to marshal/serialize dap data objects
 * to a C++ iostream using DAP4's receiver-makes-right scheme. This code
 * adds checksums to the stream and uses the xdr library to encode real
 * values if the underlying representation is not IEEE 754. It also supports
 * computing the checksum only.
 *
 * @note This class uses the Marshaller interface; it could be rewritten
 * to use far fewer methods since all of the put_*() methods take different
 * types.
 */
class D4StreamMarshaller: public Marshaller {

private:
#if USE_XDR_FOR_IEEE754_ENCODING
    XDR d_scalar_sink;
    char d_ieee754_buf[sizeof(dods_float64)]; // used to serialize a float or double
#endif

    ostream &d_out;
    bool d_write_data; // jhrg 1/27/12

    Crc32 d_checksum;


    // These are private so they won't ever get used.
    D4StreamMarshaller();
    D4StreamMarshaller(const D4StreamMarshaller &);
    D4StreamMarshaller & operator=(const D4StreamMarshaller &);

#if USE_XDR_FOR_IEEE754_ENCODING
    void m_serialize_reals(char *val, int64_t num, int width, Type type);
#endif

public:
    D4StreamMarshaller(std::ostream &out, bool write_data = true);
    virtual ~D4StreamMarshaller();

    virtual void reset_checksum();
    virtual string get_checksum();
    virtual void checksum_update(const void *data, unsigned long len);

    virtual void put_checksum();
    virtual void put_count(int64_t count);

    virtual void put_byte(dods_byte val);
    virtual void put_int8(dods_int8 val);

    virtual void put_int16(dods_int16 val);
    virtual void put_int32(dods_int32 val);
    // Added
    virtual void put_int64(dods_int64 val);

    virtual void put_float32(dods_float32 val);
    virtual void put_float64(dods_float64 val);

    virtual void put_uint16(dods_uint16 val);
    virtual void put_uint32(dods_uint32 val);
    // Added
    virtual void put_uint64(dods_uint64 val);

    virtual void put_str(const string &val);
    virtual void put_url(const string &val);

    virtual void put_opaque(char *, unsigned int) {
    	throw InternalErr(__FILE__, __LINE__, "Not implemented for DAP4; use put_opaque_dap4() instead.");
    }

    virtual void put_opaque_dap4(const char *val, int64_t len);

    // Never use put_int() to send length information in DAP4.
    virtual void put_int(int) {
        throw InternalErr(__FILE__, __LINE__, "Not Implemented; use put_length_prefix.");
    }

    virtual void put_vector(char *val, int64_t num_bytes);
    virtual void put_vector(char *val, int64_t num_elem, int elem_size);
    virtual void put_vector_float32(char *val, int64_t num_elem);
    virtual void put_vector_float64(char *val, int64_t num_elem);

    virtual void put_vector(char *, int , Vector &) {
        throw InternalErr(__FILE__, __LINE__, "Not Implemented; use other put_vector() versions.");
    }
    virtual void put_vector(char *, int , int , Vector &) {
        throw InternalErr(__FILE__, __LINE__, "Not Implemented; use other put_vector() versions.");
    }

    /**
     * Prepare to send a single array/vector using a series of 'put' calls.
     * In DAP4 this does nothing because arrays are serialized using the server's
     * binary representation (i.e., using 'reader make right').
     *
     * @param num Ignored
     * @see put_vector_part()
     * @see put_vector_end()
     */
    virtual void put_vector_start(int /*num*/) {
    }

    virtual void put_vector_part(char */*val*/, unsigned int /*num*/, int /*width*/, Type /*type*/);

    /**
     * Close a vector when its values are written using put_vector_part().
     * In DAP4 this does nothing because arrays are serialized using the server's
     * binary representation (i.e., using 'reader make right').
     *
     * @see put_vector_start()
     * @see put_vector_part()
     */
    virtual void put_vector_end() {
    }

    virtual void dump(std::ostream &strm) const;
};

} // namespace libdap

#endif // I_D4StreamMarshaller_h