/* * The interface to cgit's config file reader. A caller names a file and passes * a callback that receives every name and value in it, in the order they * appear. */ #ifndef CGIT_CONFIG_H #define CGIT_CONFIG_H typedef void (*config_file_value_fn)(const char *name, const char *value); /* * Where the setting being applied was written, for a warning about it to name. * The file is NULL while no config file is being read. */ struct config_origin { const char *file; int line; }; extern struct config_origin config_origin; /* * Returns 0, or an errno value when filename could not be opened or read. A * missing file is ordinary for some callers, so reporting one is left to them. * filename has to stay as it is until the parse returns, since a warning about * a setting in the file names it. */ extern int config_file_parse(const char *filename, config_file_value_fn fn); /* * Read value as atoi does, which is what a number in cgitrc has always meant, * and warn on stderr when it is not a plain whole number, since atoi turns a * word such as "yes" into 0 without a sound. */ extern int config_int(const char *name, const char *value); #endif // CGIT_CONFIG_H