settings-parser.h revision d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76
#ifndef SETTINGS_PARSER_H
#define SETTINGS_PARSER_H
struct var_expand_table;
#define SETTINGS_SEPARATOR '/'
#define SETTINGS_SEPARATOR_S "/"
/* STR_VARS pointer begins with either of these initially. Before actually
using the variables all variables in all unexpanded strings need to be
expanded. Afterwards the string pointers should be increased to skip
the initial '1' so it'll be easy to use them. */
#define SETTING_STRVAR_UNEXPANDED "0"
#define SETTING_STRVAR_EXPANDED "1"
enum setting_type {
SET_INTERNAL, /* don't set this variable */
SET_STR_VARS, /* string with %variables */
SET_DEFLIST, /* of type array_t */
SET_STRLIST /* of type ARRAY_TYPE(const_string) */
};
struct setting_define {
enum setting_type type;
const char *key;
const struct setting_parser_info *list_info;
};
((struct struct_name *)0)->name, bool), \
((struct struct_name *)0)->name, unsigned int), \
((struct struct_name *)0)->name, const char *), \
struct setting_parser_info {
const struct setting_define *defines;
const void *defaults;
struct setting_parser_info *parent;
struct dynamic_settings_parser *dynamic_parsers;
};
/* name=NULL-terminated list of parsers. These follow the static settings.
After this list follows the actual settings. */
struct dynamic_settings_parser {
const char *name;
const struct setting_parser_info *info;
};
enum settings_parser_flags {
};
struct setting_parser_context;
struct setting_parser_context *
enum settings_parser_flags flags);
struct setting_parser_context *
const struct setting_parser_info *const *roots,
/* Return pointer to root setting structure. */
/* If there are multiple roots, return list to all of their settings. */
/* Return the last error. */
/* Return the parser info used for the previously parsed line. */
const struct setting_parser_info *
/* Save all parsed input to given string. */
/* Returns TRUE if the given key is a valid setting. */
const char *key);
/* Parse a single line. Returns 1 if OK, 0 if key is unknown, -1 if error. */
/* Parse data already read in input stream. */
/* Read data from input stream and parser it. returns -1 = error,
0 = done, 1 = not finished yet (stream is non-blocking) */
/* Open file and parse it. */
/* Execute the given binary and wait for it to return the configuration. */
const char *bin_path, const char *config_path,
const char *service);
/* Call all check_func()s to see if currently parsed settings are valid. */
const char **error_r);
/* While parsing values, specifies if STR_VARS strings are already expanded. */
bool is_expanded);
/* Mark all the parsed settings with given keys as being already expanded. */
/* Expand all unexpanded variables using the given table. Update the string
pointers so that they can be used without skipping over the '1'. */
const struct var_expand_table *table);
/* Go through all the settings and return the first one that has an unexpanded
setting containing the given %key. */
char var_key, const char *long_var_key,
/* Duplicate the entire settings structure. */
/* Duplicate the entire setting parser. */
struct setting_parser_context *
/* parsers is a name=NULL -terminated list. The parsers are appended as
dynamic_settings_list structures to their parent. All must have the same
parent. The new structures are allocated from the given pool. */
const struct dynamic_settings_parser *parsers);
/* Return pointer to beginning of settings for given name, or NULL if there is
no such registered name. */
#endif