This file is indexed.

/usr/include/srecord/record.h is in libsrecord-dev 1.58-1.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
//
// srecord - manipulate eprom load files
// Copyright (C) 1998, 1999, 2001-2003, 2005-2011 Peter Miller
//
// This program 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 3 of the License, or (at your
// option) any later version.
//
// This program 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 program. If not, see <http://www.gnu.org/licenses/>.
//

#ifndef SRECORD_RECORD_H
#define SRECORD_RECORD_H

#include <cstddef>
#include <stdint.h>

#include <srecord/endian.h>

namespace srecord {

/**
  * The srecord::record class is used to represent a data record read
  * from a file.  (It is not limited to any particular file format.)
  * The records may be of various types.
  */
class record
{
public:
    /**
      * The destructor.  It isn't virtual, so don't derive anything
      * from this class.
      */
    ~record();

    /**
      * The type of the various record types.
      */
    enum type_t
    {
        type_unknown,
        type_header,
        type_data,
        type_data_count,
        type_execution_start_address
    };

    /**
      * The type of record addresses.
      */
    typedef uint32_t address_t;

    /**
      * The type of record data values.
      */
    typedef uint8_t data_t;

    /**
      * The default constructor.  The record will have an
      * indeterminate type, zero address, and no data.
      */
    record();

    /**
      * The copy constructor.
      */
    record(const record &);

    /**
      * A constructor.  The record will have the given type, a zero
      * address and no data.
      */
    record(type_t);

    /**
      * A constructor.  The record will have the given type, the
      * given address and no data.
      */
    record(type_t, address_t);

    /**
      * A constructor.  The record will have the given type, the
      * given address and a copy of the given data.
      *
      * @param the_type
      *     What kind of record this is
      * @param the_address
      *     The memory address of the first byte of data, the rest
      *     increase by one each.
      * @param the_data
      *     The bytes of data for the record.
      * @param the_data_length
      *     How long the data is.
      *     assert(the_data_length < max_data_length);
      */
    record(type_t the_type, address_t the_address, const data_t *the_data,
        size_t the_data_length);

    /**
      * The assignment operator.
      */
    record &operator=(const record &);

    /**
      * The get_address method is used to get the address of the
      * record.
      */
    address_t get_address(void) const { return address; }

    /**
      * The get_address_end method is used to get the address "off
      * the end" of this record.
      */
    address_t get_address_end(void) const { return (address + length); }

    /**
      * The address_range_fits_into_n_bits method is used to test whether or
      * not this record's address range fits within the given number of bits.
      *
      * @param nbits
      *     The number of bits, e.g. 16
      * @returns
      *     true if the address range will fit, or false if it will not fit
      */
    bool address_range_fits_into_n_bits(unsigned nbits) const;

    /**
      * The set_address method is used to set the address of the
      * record.
      */
    void set_address(address_t arg) { address = arg; }

    /**
      * The get_length method is used to get the length (number of
      * bytes) of the record data.
      */
    size_t get_length(void) const { return length; }

    /**
      * The set_length method is used to set the number of data
      * bytes in the record data.
      *
      * @param arg
      *      The new record length.  Note that you can reduce the
      *      length, but you can't increase it.
      */
    void
    set_length(size_t arg)
    {
        if (arg < length)
            length = arg;
    }

    /**
      * The get_data method is used to get a ponter to the baseof
      * the record data.
      *
      * Note: Accessing beyond get_length() bytes will give an
      * undefined value.
      */
    const data_t *get_data(void) const { return data; }

    /**
      * The get_data method is used to fetch the nth data value.
      *
      * Note: For perfoemance reasons, no range checking is
      * performed.  Accessing beyond get_length() bytes will give
      * an undefined value.
      *
      * @param n
      *     The index into the data array, zero based.
      *     Values when n is in excess of #length are undefined.
      */
    int get_data(size_t n) const { return data[n]; }

    /**
      * The is_all_zero method is used to determin if the record
      * contains data bytes which are all zero.
      */
    bool is_all_zero(void) const;

    /**
      * The set_data method is used to set values in the data array.
      * No range checking is performed.  The record length is not
      * consulted or adjusted.
      *
      * @param n
      *     The index into the data array, zero based.
      *     Results when n is in excess of #length are undefined.
      * @param d
      *     The new data value.
      */
    void set_data(size_t n, data_t d) { data[n] = d; }

    /**
      * The set_data_extend method is used to set values in the data array.
      * The record length is adjusted if necessary.
      *
      * @param n
      *     The index into the data array, zero based.
      *     If this is beyond #length, then #length will be extended.
      *     assert(n < max_data_length);
      * @param d
      *     The new data value.
      */
    void set_data_extend(size_t n, data_t d);

    /**
      * The get_type method is used to get the type of the record.
      */
    type_t get_type(void) const { return type; }

    /**
      * The set_type method is used to set the type of the record.
      */
    void set_type(type_t arg) { type = arg; }

    /**
      * The maximum_data_length method is used to determine the
      * maximum data length possible within a record, for a given
      * address.
      *
      * @param addr
      *     The address of the record.  Some formats trade data size of
      *     address size, for a constant maximum line length.
      */
    static size_t maximum_data_length(address_t addr);

    /**
      * The decode_big_endian method is used to extract 'len'
      * bytes from the given 'data' and assemble a big-endian value
      * (most significant byte first).
      *
      * @param data
      *     The data to be decodes
      * @param len
      *     Length of the data, in bytes
      * @returns
      *     the decoded value
      */
    static address_t decode_big_endian(const data_t *data, size_t len);

    /**
      * The decode_little_endian method is used to extract 'len' bytes
      * from the given 'data' and assemble a little-endian value (least
      * significant byte first).
      *
      * @param data
      *     The data to be decodes
      * @param len
      *     Length of the data, in bytes
      * @returns
      *     the decoded value
      */
    static address_t decode_little_endian(const data_t *data, size_t len);

    /**
      * The decode method is used to extract 'len' bytes
      * from the given 'data' and assemble a valu
      *
      * @param data
      *     The data to be decodes
      * @param len
      *     Length of the data, in bytes
      * @param end
      *     The byte order of the data.
      * @returns
      *     the decoded value
      */
    static address_t
    decode(const data_t *data, size_t len, endian_t end)
    {
        return
            (
                end == endian_big
            ?
                decode_big_endian(data, len)
            :
                decode_little_endian(data, len)
            );
    }

    /**
      * The encode_big_endian method is used to break down 'val' into
      * 'len' bytes of 'data' orderdd big-endian (most significan
      * byte first).
      *
      * @param data
      *     Where to place the encoded data
      * @param val
      *     The value to be encoded
      * @param len
      *     The number of bytes to use to encode the data.
      *     Bits above the 8*len resolution will be discarded.
      */
    static void encode_big_endian(data_t *data, address_t val, size_t len);

    /**
      * The encode_little_endian method is used to break down
      * 'val' into 'len' bytes of 'data' orderdd big-endian (least
      * significan byte first).
      *
      * @param data
      *     Where to place the encoded data
      * @param val
      *     The value to be encoded
      * @param len
      *     The number of bytes to use to encode the data.
      *     Bits above the 8*len resolution will be discarded.
      */
    static void encode_little_endian(data_t *data, address_t val, size_t len);

    /**
      * The encode method is used to break down 'val' into 'len' bytes
      * of 'data'
      *
      * @param data
      *     Where to place the encoded data
      * @param val
      *     The value to be encoded
      * @param len
      *     The number of bytes to use to encode the data.
      *     Bits above the 8*len resolution will be discarded.
      * @param end
      *     The byte order
      */
    static void
    encode(data_t *data, address_t val, size_t len, endian_t end)
    {
        if (end == endian_big)
            encode_big_endian(data, val, len);
        else
            encode_little_endian(data, val, len);
    }

    enum {
    /**
      * The max_data_length is the largest number of data bytes
      * which any record can hold.
      */
    max_data_length = 255 };

private:
    /**
      * The type instance variable is used to remember the type of
      * the record.
      */
    type_t type;

    /**
      * The address instance variable is used to remember the address
      * of the record.
      */
    address_t address;

    /**
      * The length instance variable is used to remember the number
      * of valid bytes in the #data array.
      */
    size_t length;

    /**
      * The data instance variable is used to remember the data
      * of the record.  Only the first #length bytes are valid,
      * the rest are undefined.
      */
    data_t data[max_data_length];
};

};

#endif // SRECORD_RECORD_H