This file is indexed.

/usr/include/ucommon/keydata.h is in libucommon-dev 6.0.7-1.1.

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
// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
//
// This file is part of GNU uCommon C++.
//
// GNU uCommon C++ 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.
//
// GNU uCommon C++ 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 GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Parsing of config files that have keyword/value pairs.  This includes
 * supporting classes to extract basic config data from files that are stored
 * as []'s, and uses several supporting classes.
 * @file ucommon/keydata.h
 */

/**
 * Some exercise of keydata routines.
 * @example keydata.cpp
 */

#ifndef _UCOMMON_KEYDATA_H_
#define _UCOMMON_KEYDATA_H_

#ifndef _UCOMMON_CONFIG_H_
#include <ucommon/platform.h>
#endif

#ifndef  _UCOMMON_LINKED_H_
#include <ucommon/linked.h>
#endif

#ifndef  _UCOMMON_MEMORY_H_
#include <ucommon/memory.h>
#endif

NAMESPACE_UCOMMON

class keyfile;

/**
 * Data keys parsed from a keyfile.  This is a specific [] section from a
 * fully loaded keyfile, and offers common means to access data members.
 * This is related to the original GNU Common C++ keydata object, although
 * it is formed in a keyfile class which is loaded from a config file all
 * at once.
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT keydata : public OrderedObject
{
private:
    friend class keyfile;
    OrderedIndex index;
    keydata(keyfile *file);
    keydata(keyfile *file, const char *id);
    const char *name;
    keyfile *root;

public:
    /**
     * A key value set is used for iterative access.  Otherwise this class
     * is normally not used as we usually request the keys directly.
     * @author David Sugar <dyfet@gnutelephony.org>
     */
    class __LOCAL keyvalue : public OrderedObject
    {
    private:
        friend class keydata;
        friend class keyfile;
        keyvalue(keyfile *allocator, keydata *section, const char *key, const char *data);
    public:
        const char *id;
        const char *value;
    };

    friend class keyvalue;

    /**
     * Lookup a key value by it's id.
     * @param id to look for.
     * @return value string or NULL if not found.
     */
    const char *get(const char *id) const;

    /**
     * Lookup a key value by it's id.
     * @param id to look for.
     * @return value string or NULL if not found.
     */
    inline const char *operator()(const char *id) const
        {return get(id);};

    /**
     * Set a keyword and value in the keydata structure.  If the keyword
     * already exists, it is replaced.  Removed items still use pager
     * allocated memory.
     * @param id to set.
     * @param value for the id.
     */
    void set(const char *id, const char *value);

    /**
     * Remove a keyword id from the keydata structure.  Removed items
     * still use pager allocated memory.
     * @param id to remove.
     */
    void clear(const char *id);

    /**
     * Get the name of this section.  Useful in iterative examinations.
     * @return name of keydata section.
     */
    inline const char *get(void) const
        {return name;};

    /**
     * Get first value object, for iterative examinations.
     * @return first key value in chain.
     */
    inline keyvalue *begin(void) const
        {return (keyvalue *)index.begin();};

    /**
     * Get last value object, for iterative examinations.
     * @return first key value in chain.
     */
    inline keyvalue *end(void) const
        {return (keyvalue*)index.end();};

    /**
     * Convenience typedef for iterative pointer.
     */
    typedef linked_pointer<keyvalue> iterator;
};

/**
 * Traditional keypair config file parsing class.  This is used to get
 * generic config data either from a /etc/xxx.conf, a windows style
 * xxx.ini file, or a ~/.xxxrc file, and parses [] sections from the
 * entire file at once.
 */
class __EXPORT keyfile : public memalloc
{
private:
    friend class keydata;
    OrderedIndex index;
    keydata *defaults;
    int errcode;

protected:
    keydata *create(const char *section);

#ifdef  _MSWINDOWS_
    void load(HKEY root, keydata *section = NULL, const char *path = NULL);
    bool save(HKEY root, keydata *section = NULL, const char *path = NULL);
#endif

public:
    /**
     * Create an empty key file ready for loading.
     * @param pagesize for memory paging.
     */
    keyfile(size_t pagesize = 0);

    /**
     * Create a key file object from an existing config file.
     * @param path to load from.
     * @param pagesize for memory paging.
     */
    keyfile(const char *path, size_t pagesize = 0);

    keyfile(const keyfile &copy, size_t pagesize = 0);

    /**
     * Load (overlay) another config file over the currently loaded one.
     * This is used to merge key data, such as getting default values from
     * a global config, and then overlaying a local home config file.
     * @param path to load keys from into current object.
     */
    void load(const char *path);

    /**
     * Save (write) a set of config keys to dist.
     * @param path of file to save keys to.
     * @return true on success.
     */
    bool save(const char *path);

    /**
     * Load from an existing keyfile object.
     * @param source to copy from.
     */
    void load(const keyfile *source);

    /**
     * Load a single set of keys.
     * @param source of keys to copy.
     */
    void load(const keydata *source);

    /**
     * Release and re-initialize keyfile.
     */
    void release(void);

    /**
     * Get a keydata section name.
     * @param section name to look for.
     * @return keydata section object if found, NULL if not.
     */
    keydata *get(const char *section) const;

    inline keydata *operator()(const char *section) const
        {return get(section);};

    inline keydata *operator[](const char *section) const
        {return get(section);};

    /**
     * Get the non-sectioned defaults if there are any.
     * @return default key section.
     */
    inline keydata *get(void) const
        {return defaults;};

    /**
     * Get first keydata object, for iterative examinations.
     * @return first key value in chain.
     */
    inline keydata *begin(void) const
        {return (keydata *)index.begin();};

    /**
     * Get last keydata object, for iterative examinations.
     * @return first key value in chain.
     */
    inline keydata *end(void) const
        {return (keydata *)index.end();};

    /**
     * Convenience typedef for iterative pointer.
     */
    typedef linked_pointer<keydata> iterator;

    inline int err(void)
        {return errcode;}
};

END_NAMESPACE

#endif