This file is indexed.

/usr/include/nih/config.h is in libnih-dev 1.0.3-4ubuntu9.

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
/* libnih
 *
 * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
 * Copyright © 2009 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2, as
 * published by the Free Software Foundation.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef NIH_CONFIG_H
#define NIH_CONFIG_H

/**
 * Implements a flexible configuration parser based on keyword stanzas and zero
 * or more arguments, handling such matters as quotation, whitespace and
 * commands for you.
 *
 * You describe the stanzas with an array of NihConfigStanza members,
 * each is handled by a function that receives a number of arguments
 * referencing the current position within the file being parsed.
 *
 * The function may then call any of the parsing functions to parse its
 * arguments, consuming as much of the following file as it wishes.  Most
 * will call nih_config_parse_args() to do the hard work.
 *
 * Configuration can be parsed as a file with nih_config_parse_file() or
 * as a string with nih_config_parse().
 **/

#include <sys/types.h>

#include <nih/macros.h>


/**
 * NihConfigHandler:
 * @data: data passed to parser,
 * @stanza: stanza found,
 * @filename: name of file being parsed,
 * @lineno: line number,
 * @file: file or string to parse,
 * @len: length of @file,
 * @pos: offset within @file.
 *
 * A config handler is a function that is called when @stanza is found
 * in a configuration file.
 *
 * @file may be a memory mapped file, in which case @pos is given
 * as the offset within that the stanza's arguments begin, and @len will
 * be the length of the file as a whole.
 *
 * @pos must be updated to point to the next stanza in the configuration
 * file, past whatever terminator is used for the one being parsed.
 *
 * If @lineno is not NULL, it contains the current line number and must be
 * incremented each time a new line is discovered in the file.
 *
 * (These things are taken care of for you if you use the nih_config_*
 * functions).
 *
 * If you encounter errors, you should use the usual logging functions to
 * output warnings using both @filename and @lineno, but only if @filename
 * is not NULL.
 *
 * Returns: zero on success, negative value on raised error.
 **/
typedef struct nih_config_stanza NihConfigStanza;
typedef int (*NihConfigHandler) (void *data, NihConfigStanza *stanza,
				 const char *file, size_t len, size_t *pos,
				 size_t *lineno);


/**
 * NihConfigStanza:
 * @name: stanza name,
 * @handler: function to call.
 *
 * This structure defines a configuration file stanza, when a stanza
 * called @name is found within a configuration file, @handler will be
 * called from a position after the stanza and any following whitespace.
 **/
struct nih_config_stanza {
	char             *name;
	NihConfigHandler  handler;
};


/**
 * NIH_CONFIG_LAST:
 *
 * This macro may be used as the last stanza in the list to avoid typing
 * all those NULLs yourself.
 **/
#define NIH_CONFIG_LAST { NULL, NULL }


/**
 * NIH_CONFIG_WS:
 *
 * Definition of what characters we consider whitespace.
 **/
#define NIH_CONFIG_WS " \t\r"

/**
 * NIH_CONFIG_CNL:
 *
 * Definition of what characters nominally end a line; a comment start
 * character or a newline.
 **/
#define NIH_CONFIG_CNL "#\n"

/**
 * NIH_CONFIG_CNLWS:
 *
 * Defintion of what characters nominally separate tokens.
 **/
#define NIH_CONFIG_CNLWS " \t\r#\n"


NIH_BEGIN_EXTERN

int       nih_config_has_token       (const char *file, size_t len,
				      size_t *pos, size_t *lineno);

int       nih_config_token           (const char *file, size_t len,
				      size_t *pos, size_t *lineno, char *dest,
				      const char *delim, int dequote,
				      size_t *toklen)
	__attribute__ ((warn_unused_result));
char *    nih_config_next_token      (const void *parent, const char *file,
				      size_t len, size_t *pos, size_t *lineno,
				      const char *delim, int dequote)
	__attribute__ ((warn_unused_result, malloc));
char *    nih_config_next_arg        (const void *parent, const char *file,
				      size_t len, size_t *pos, size_t *lineno)
	__attribute__ ((warn_unused_result, malloc));
void      nih_config_next_line       (const char *file, size_t len,
				      size_t *pos, size_t *lineno);

void      nih_config_skip_whitespace (const char *file, size_t len,
				      size_t *pos, size_t *lineno);
int       nih_config_skip_comment    (const char *file, size_t len,
				      size_t *pos, size_t *lineno)
	__attribute__ ((warn_unused_result));

char **   nih_config_parse_args      (const void *parent, const char *file,
				      size_t len, size_t *pos, size_t *lineno)
	__attribute__ ((warn_unused_result, malloc));
char *    nih_config_parse_command   (const void *parent, const char *file,
				      size_t len, size_t *pos, size_t *lineno)
	__attribute__ ((warn_unused_result, malloc));

char *    nih_config_parse_block     (const void *parent, const char *file,
				      size_t len, size_t *pos, size_t *lineno,
				      const char *type)
	__attribute__ ((warn_unused_result, malloc));
int       nih_config_skip_block      (const char *file, size_t len,
				      size_t *lineno, size_t *pos,
				      const char *type, size_t *endpos)
	__attribute__ ((warn_unused_result));

int       nih_config_parse_stanza    (const char *file, size_t len,
				      size_t *pos, size_t *lineno,
				      NihConfigStanza *stanzas, void *data)
	__attribute__ ((warn_unused_result));

int       nih_config_parse_file      (const char *file, size_t len,
				      size_t *pos, size_t *lineno,
				      NihConfigStanza *stanzas, void *data)
	__attribute__ ((warn_unused_result));
int       nih_config_parse           (const char *filename, size_t *pos,
				      size_t *lineno, NihConfigStanza *stanzas,
				      void *data)
	__attribute__ ((warn_unused_result));

NIH_END_EXTERN

#endif /* NIH_CONFIG_H */