This file is indexed.

/usr/include/smbios/ISmbios.h is in libsmbios-dev 2.3.0-0ubuntu1.

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
419
420
421
422
423
424
425
426
427
// vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
/*
 * Copyright (C) 2005 Dell Inc.
 *  by Michael Brown <Michael_E_Brown@dell.com>
 * Licensed under the Open Software License version 2.1
 *
 * Alternatively, you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 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 General Public License for more details.
 */


#ifndef SMBIOSINTERFACE_H
#define SMBIOSINTERFACE_H

// compat header should always be first header
#include "smbios/compat.h"

#include <cstdlib>		// Provides size_t and NULL
#include <iostream>
#include <map>
#include <memory>

// types.h should be first user-defined header.
#include "smbios/types.h"
#include "smbios/IFactory.h"
#include "smbios/IException.h"
#include "smbios/SmbiosLowLevel.h"

// abi_prefix should be last header included before declarations
#include "smbios/config/abi_prefix.hpp"

namespace smbios
{
    // Exception Classes
    DECLARE_EXCEPTION( SmbiosException );
    DECLARE_EXCEPTION_EX( ParameterException, smbios, SmbiosException );
    DECLARE_EXCEPTION_EX( ParseException, smbios, SmbiosException );
    DECLARE_EXCEPTION_EX( StringUnavailable, smbios, SmbiosException );
    DECLARE_EXCEPTION_EX( DataOutOfBounds, smbios, SmbiosException );
    DECLARE_EXCEPTION_EX( ItemNotFound, smbios, SmbiosException );


    //forward declarations... defined 'for real' below...
    class ISmbiosTable;
    class ISmbiosItem;
    class SmbiosTableIterator;
    class ConstSmbiosTableIterator;

    //!AbstractFactory that produces ISmbiosTable objects.
    /** The SmbiosFactory class is based on the Factory design pattern.
    * The SmbiosFactory is the recommended method to create ISmbiosTable
    * objects.
    *
    * The getSingleton() is the recommended method to call to create
    * tables. You need not delete the pointer returned by this method, it
    * will be delete by the factory when it is reset() or destructed.
    *
    * Most users of the factory need call nothing more than getFactory()
    * and then getSingleton() on the returned factory object.
    *
    * Advanced users can call setParameter() to set up internal factory
    * variables that control creation of tables.
    */
    class SmbiosFactory : public virtual factory::IFactory
    {
    public:
        //! Create a factory object that you can use to create ISmbiosTable objects.
        /** Factory entry point: This is the method to call to get a handle
         * to the SmbiosFactory. The SmbiosFactory is the recommended method
         * to create ISmbiosTable objects.
         *
         * The getSingleton() is the recommended method to call to create
         * tables. You need not delete the pointer returned by this method, it
         * will be deleted by the factory when it is reset() or destructed.
         *
         * \returns Singleton SmbiosFactory object pointer.
         */
        static SmbiosFactory *getFactory();
        virtual ~SmbiosFactory() throw();

        //! Recommended way to get an ISmbiosTable object.
        /** getSingleton() returns a pointer to a Singleton ISmbiosTable
         * object. The user need not delete the pointer returned by this method.
         * The singleton will be deleted when the factory is destructed or
         * the reset() method is called
         * \returns (ISmbiosTable *) -- Factory manages lifetime, do not delete.
         */
        virtual ISmbiosTable *getSingleton() = 0;

        //! Create a new ISmbiosTable object that the caller must delete. (NOT RECOMMENDED)
        /** The makeNew() method returns a pointer to a newly allocated
         * ISmbiosTable object. The caller is responsible for deleting this
         * reference when it is finished with it. It is recommended that the
         * caller store the pointer in an std::auto_ptr<ISmbiosTable>.
         *
         * The getSingleton() method is preferred over this method.
         *
         * \returns (ISmbiosTable *) -- caller must delete
         */
        virtual ISmbiosTable *makeNew() = 0;
    protected:
        //! Use getFactory() to get a factory.
        SmbiosFactory();
    };

    //!Interface definition for Smbios Table operations.
    /**
     * \copydoc smbios_theory
     */
    class ISmbiosTable
    {
    public:
        // Std container typedefs. Everybody expects to
        // say 'iterator' or 'const_iterator'
        typedef SmbiosTableIterator iterator;
        typedef ConstSmbiosTableIterator const_iterator;

        // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
        ISmbiosTable();
        // Interface class: no default or copy constructor
        virtual ~ISmbiosTable ();

        // ITERATORS
        //
        //! Standard iterator interface. Points to first table item.
        /**
         * \returns iterator or const_iterator
         * Example Iterator Usage:
\code
    smbios::ISmbiosTable *table = smbios::SmbiosFactory::getFactory()->getSingleton();
    smbios::ISmbiosTable::iterator item = table->begin();
    while( item != table->end() )
    {
        cout << "Type of Item: " << item->getType();
        ++item;
    }
\endcode
        */
        virtual iterator begin () = 0;
        //! Standard iterator interface. Points to first table item.
        /** \copydoc begin() */
        virtual const_iterator begin () const = 0;

        //! Standard iterator interface. Points to one-past-the-last table item.
        /** \copydoc begin() */
        virtual iterator end () = 0;

        //! Standard iterator interface. Points to one-past-the-last table item.
        /** Used by const_iterator.
         * \copydoc begin() */
        virtual const_iterator end () const = 0;

        //! Standard indexed access by integer item type.
        /** The operator[] method returns an \a iterator that can be used to
         * iterator over all items in the table of the supplied \a type. So, for
         * example, if you want to perform an operation on all SMBIOS type 0x01
         * (System Information Block) structures, just index the table object
         * using the [] operator.
         * \returns iterator or const_iterator
         * Sample usage:
\code
// Integer indexing example
smbios::ISmbiosTable *table = smbios::SmbiosFactory::getFactory()->getSingleton();
smbios::ISmbiosTable::iterator item1 = (*table)[0];
cout << "The BIOS Version is: " << item1->getString(0x05) << endl;
\endcode
         * \sa operator[]( const std::string & ) const
         */
        virtual iterator operator[]( const int ) = 0;

        //! Standard indexed access by integer item type.
         /** \copydoc operator[]( const int ) */
        virtual const_iterator operator[]( const int ) const = 0;

        // MEMBERS
        //! Disables all workarounds for _new_ items created by the table.
        /** Any new item generated by the table will not have workarounds
         * applied to them. However, any previously-existing items that have had
         * workarounds applied still exist. If this is not what you want,
         * recommend calling clearItemCache() prior to calling rawMode().
         * \param m pass in a bool value to turn raw mode on or off.
         */
        virtual void rawMode(bool m = true) const = 0;

        //! Clears out any cached SmbiosItem entries in the cache
        /** This API is useful for two instances. First, you can use this to
         * reduce memory usage if you know that you do not need any
         * ISmbiosItem(s) out of the table for a while. The cached
         * ISmbiosItem(s) will be deleted and then re-populated on demand when
         * queries are made for them.
         *
         * Next, this API is used internally when reReadTable() is called to
         * clear out all old ISmbiosItems.
         *
         * \warning All previous references or pointers to ISmbiosItem objects
         * created from this table become invalid and attempts to access them
         * will cause undefined behaviour (most likely your code will crash.)
         *
         * \todo clearItemCache() needs to be made an abstract function and the
         * definition needs to be moved to the SmbiosItem class. This needs to
         * happen at the same time that itemList is moved.
         */
        virtual void clearItemCache() const = 0;

        //! Returns the number of table items, per SMBIOS table header
        virtual int getNumberOfEntries () const = 0;  // used by unit-test code
        //! Returns  the table entry point structure
        // Used by the validateBios code.
        virtual smbiosLowlevel::smbios_table_entry_point getTableEPS() const = 0;

        friend class SmbiosTableIteratorBase;
    protected:
        virtual const ISmbiosItem & getSmbiosItem (const u8 *current) const = 0;
        virtual ISmbiosItem & getSmbiosItem (const u8 *current) = 0;
        virtual const u8 * nextSmbiosStruct ( const u8 * current = 0) const = 0;

        //! Used by operator << (std::ostream & cout, const ISmbiosTable & ) to
        //output table information.
        /** Users normally would not need or want to call this API. The normal
         * operator<<() has been overloaded to call this function internally.
         */
        virtual std::ostream & streamify(std::ostream & cout ) const = 0;
        friend std::ostream & operator << (std::ostream & cout, const ISmbiosTable & item);

    private:
        explicit ISmbiosTable(const ISmbiosTable &); ///< not implemented (explicitly disallowed)
        void operator =( const ISmbiosTable & ); ///< not implemented (explicitly disallowed)
    };

    //!Interface definition for Smbios Item operations.
    /**
     * \copydoc item_theory
     */
    class ISmbiosItem
    {
    public:
        /** Destructor */
        virtual ~ISmbiosItem ();
        ISmbiosItem();

        virtual std::auto_ptr<const ISmbiosItem> clone() const = 0;
        virtual std::auto_ptr<ISmbiosItem> clone() = 0;

        /** Returns the Type field of the SMBIOS Item.
         * This field is standard for all SMBIOS tables and is defined
         * in the SMBIOS standard.
         * \returns The Type value.
         */
        virtual u8 getType() const = 0;

        /** Returns the Length field of the SMBIOS Item.
         * This field is standard for all SMBIOS tables and is defined
         * in the SMBIOS standard.
         * \returns The Length value.
         */
        virtual u8 getLength() const = 0;

        /** Returns the Handle field of the SMBIOS Item.
         * This field is standard for all SMBIOS tables and is defined
         * in the SMBIOS standard.
         * \returns The Handle value.
         */
        virtual u16 getHandle() const = 0;

        /** Set of accessor functions: getU8(), getU16(), getU32(), and getU64()
         * Returns a (byte|word|dword|qword) field from the Item.
         *
         * The \a offset specified is an int representing the a valid offset
         * within the table.  Method will return a u8/u16/u32/u64
         * (depending on function called).
         *
         * These methods all check the offset parameter for out of bounds
         * conditions. They will throw exceptions on attempts to access data
         * outside the length of the present item.
         *
         * \param offset The offset to the field within the Item.
         * \param out  void pointer to where to store output data
         * \param size  size of data to return
         *
         * \returns The (byte|word|dword|qword) at \a offset.  Throws
         * smbios::SmbiosItemDataOutOfBounds or smbios::SmbiosParseException
         * on error.
         *
         *
         * \warning These methods are unchecked access. There is no verification
         * that (for example) when you use getU8() that the location you are
         * trying to access is actually a U8.
         */
        virtual void getData( unsigned int offset, u8 *out, size_t size ) const = 0;

        virtual const u8* getBufferCopy(size_t &length) const = 0;

        //! Returns the buffer size of the item.
        // The validateBios.cpp calls this function.
        virtual size_t getBufferSize() const = 0;

        /** Not likely to be useful to regular client code. It is public
         * mainly to help in writing Unit Tests. Clients should normally
         * use getString().
         */
        virtual const char *getStringByStringNumber (u8) const = 0;

        enum {
            FIELD_LEN_BYTE=1,
            FIELD_LEN_WORD=2,
            FIELD_LEN_DWORD=4,
            FIELD_LEN_QWORD=8
        };

    protected:
        /** Used by 'std::ostream &smbios::operator <<( std::ostream &, ISmbiosItem&)'
         * to print out the item info.
         *
         * Not particularly useful for clients. Use operator<< instead.
         */
        virtual std::ostream & streamify( std::ostream & cout ) const = 0;
        friend std::ostream & operator << (std::ostream & cout, const ISmbiosItem & item);
    };

    u8 getItemType(const ISmbiosItem &item);
    u8 getItemLength(const ISmbiosItem &item);
    u16 getItemHandle(const ISmbiosItem &item);

    u8 getU8_FromItem(const ISmbiosItem &item, unsigned int offset);
    u16 getU16_FromItem(const ISmbiosItem &item, unsigned int offset);
    u32 getU32_FromItem(const ISmbiosItem &item, unsigned int offset);
    u64 getU64_FromItem(const ISmbiosItem &item, unsigned int offset);
    const char *getString_FromItem(const ISmbiosItem &item, unsigned int offset);
    void *getBits_FromItem(const ISmbiosItem &item, unsigned int offset, void *out, unsigned int lsb=0, unsigned int msb=0 );
    bool isBitSet(const ISmbiosItem *itemPtr, unsigned int offset, unsigned int bitToTest);

    template <class R>
    R &getData(const ISmbiosItem &item, unsigned int offset, R &out)
    {
        item.getData(offset, &out, sizeof(R));
        return out;
    }

    //! Iterator base class for ISmbiosTable objects.
    /** The base class for iterators over ISmbiosTable. This class has all of
     * the data items to keep track of the position. There is no good way to
     * implement this as a pure abstract base class (interface) because of the
     * way STL iterators were designed (I think.)
     *
     * This class is stable and should not be modified.
     */
    class SmbiosTableIteratorBase
    {
    public:
        typedef std::forward_iterator_tag iterator_category;
        typedef std::ptrdiff_t difference_type;


        explicit SmbiosTableIteratorBase(const ISmbiosTable * initialTable = 0, int typeToMatch = -1 );
        SmbiosTableIteratorBase &operator=(const SmbiosTableIteratorBase&);
        virtual ~SmbiosTableIteratorBase() throw();
        bool operator == (const SmbiosTableIteratorBase &other) const;
        bool operator != (const SmbiosTableIteratorBase &other) const;
        void incrementIterator ();
        const ISmbiosItem & dereference () const;
        ISmbiosItem & dereference ();

        void reset();
        bool eof();

    protected:
        int matchType;
        const ISmbiosTable * table;
        const u8 * current;
    };

    class SmbiosTableIterator:
        public SmbiosTableIteratorBase,
        public std::iterator < std::forward_iterator_tag, ISmbiosItem >
    {
    public:
        typedef ISmbiosItem value_type;
        typedef value_type& reference;
        typedef value_type* pointer;

        virtual ~SmbiosTableIterator() throw();
        explicit SmbiosTableIterator(ISmbiosTable * initialTable = 0, int typeToMatch = -1 );
        reference operator * ();
        pointer   operator -> ();
        SmbiosTableIterator & operator ++ (); // ++Prefix
        const SmbiosTableIterator operator ++ (int);  //Postfix++
    };

    class ConstSmbiosTableIterator:
        public SmbiosTableIteratorBase,
        public std::iterator < std::forward_iterator_tag, const ISmbiosItem >
    {
    public:
        typedef const ISmbiosItem value_type;
        typedef value_type& reference;
        typedef value_type* pointer;

        virtual ~ConstSmbiosTableIterator() throw();
        explicit ConstSmbiosTableIterator(const ISmbiosTable * initialTable = 0, int typeToMatch = -1 );
        ConstSmbiosTableIterator &operator=(const SmbiosTableIteratorBase&);

        reference operator * () const;
        pointer   operator -> () const;
        ConstSmbiosTableIterator & operator ++ (); // ++Prefix
        const ConstSmbiosTableIterator operator ++ (int);  //Postfix++
    };

    //
    // Non-member functions
    //
    std::ostream & operator << (std::ostream & cout, const ISmbiosTable & item);
    std::ostream & operator << (std::ostream & cout, const ISmbiosItem & item);

}


// always should be last thing in header file
#include "smbios/config/abi_suffix.hpp"

#endif  /* SMBIOSINTERFACE_H */