Go to the source code of this file.
Data Structures | |
struct | ConfigEntry |
configuration entry More... | |
struct | ConfigSection |
configuration section More... | |
struct | ConfigFile |
struct | GNUNET_CONFIGURATION_Handle |
configuration data More... | |
struct | DiffHandle |
Used for diffing a configuration object against the default one. More... | |
struct | CollectFilesContext |
Closure to collect_files_cb. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__) |
#define | LOG_STRERROR_FILE(kind, syscall, filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) |
Functions | |
void | GNUNET_CONFIGURATION_enable_diagnostics (struct GNUNET_CONFIGURATION_Handle *cfg) |
Enable extra diagnostics. More... | |
struct GNUNET_CONFIGURATION_Handle * | GNUNET_CONFIGURATION_create (const struct GNUNET_OS_ProjectData *pd) |
Create a new configuration object. More... | |
void | GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg) |
Destroy configuration object. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_parse_and_run (const struct GNUNET_OS_ProjectData *pd, const char *filename, GNUNET_CONFIGURATION_Callback cb, void *cb_cls) |
Parse a configuration file filename and run the function cb with the resulting configuration object. More... | |
static enum GNUNET_GenericReturnValue | collect_files_cb (void *cls, const char *filename) |
Function called with a filename. More... | |
static struct ConfigSection * | find_section (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) |
Find a section entry from a configuration. More... | |
static int | pstrcmp (const void *a, const void *b) |
static enum GNUNET_GenericReturnValue | handle_inline (struct GNUNET_CONFIGURATION_Handle *cfg, const char *path_or_glob, bool path_is_glob, const char *restrict_section, const char *source_filename, unsigned int source_lineno) |
Handle an inline directive. More... | |
static struct ConfigEntry * | find_entry (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key) |
Find an entry from a configuration. More... | |
static void | set_entry_hint (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *hint_filename, unsigned int hint_line) |
Set a configuration hint. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename) |
De-serializes configuration. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename) |
Parse a configuration file, add all of the options in the file to the configuration environment. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Test if there are configuration options that were changed since the last save. More... | |
static bool | do_skip (const char *sec, const char *key) |
Should we skip this configuration entry when serializing? More... | |
char * | GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size) |
Serializes the given configuration. More... | |
static void | dump_os_ipk (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_Buffer *buf, enum GNUNET_OS_InstallationPathKind ipk) |
Dump an os installation path to a buffer. More... | |
char * | GNUNET_CONFIGURATION_serialize_diagnostics (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Serializes the given configuration with diagnostics information. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename) |
Write configuration file. More... | |
void | GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls) |
Iterate over all options in the configuration. More... | |
void | GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls) |
Iterate over values of a section in the configuration. More... | |
void | GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls) |
Iterate over all sections in the configuration. More... | |
void | GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) |
Remove the given section and all options in it. More... | |
static void | copy_entry (void *cls, const char *section, const char *option, const char *value) |
Copy a configuration value to the given target configuration. More... | |
struct GNUNET_CONFIGURATION_Handle * | GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Duplicate an existing configuration object. More... | |
static void | compare_entries (void *cls, const char *section, const char *option, const char *value) |
A callback function, compares entries from two configurations (default against a new configuration) and write the diffs in a diff-configuration object (the callback object). More... | |
struct GNUNET_CONFIGURATION_Handle * | GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new) |
Compute configuration with only entries that have been changed. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new, const char *filename) |
Write only configuration entries that have been changed to configuration file. More... | |
void | GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value) |
Set a configuration value that should be a string. More... | |
void | GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number) |
Set a configuration value that should be a number. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number) |
Get a configuration value that should be a number. More... | |
void | GNUNET_CONFIGURATION_set_value_float (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float number) |
Set a configuration value that should be a float. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number) |
Get a configuration value that should be a floating point number. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time) |
Get a configuration value that should be a relative time. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *size) |
Get a configuration value that should be a size in bytes. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value) |
Get a configuration value that should be a string. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *const *choices, const char **value) |
Get a configuration value that should be in a set of predefined strings. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, void *buf, size_t buf_size) |
Get Crockford32-encoded fixed-size binary data from a configuration. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option) |
Test if we have a value for a particular option. More... | |
static char * | expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig, unsigned int depth) |
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or the environment "FOO" is set to "DIRECTORY". More... | |
char * | GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig) |
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or the environment "FOO" is set to "DIRECTORY". More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value) |
Get a configuration value that should be the name of a file or directory. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option) |
Get a configuration value that should be in a set of "YES" or "NO". More... | |
int | GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, GNUNET_FileNameCallback cb, void *cb_cls) |
Iterate over the set of filenames stored in a configuration value. More... | |
static char * | escape_name (const char *value) |
FIXME. More... | |
static enum GNUNET_GenericReturnValue | test_match (void *cls, const char *fn) |
FIXME. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value) |
Append a filename to a configuration value that represents a list of filenames. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value) |
Remove a filename from a configuration value that represents a list of filenames. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d) |
Load default configuration. More... | |
char * | GNUNET_CONFIGURATION_default_filename (const struct GNUNET_OS_ProjectData *pd) |
Return the filename of the default configuration filename that is used when no explicit configuration entry point has been specified. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename) |
Load configuration. More... | |
static void | print_filename_option (void *cls, const char *section, const char *option, const char *value) |
Print each option in a given section as a filename. More... | |
static void | print_option (void *cls, const char *section, const char *option, const char *value) |
Print each option in a given section. More... | |
static void | print_section_name (void *cls, const char *section) |
Print out given section name. More... | |
void | GNUNET_CONFIGURATION_config_tool_run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Main task to run to perform operations typical for gnunet-config as per the configuration settings given in cls. More... | |
void | GNUNET_CONFIGURATION_config_settings_free (struct GNUNET_CONFIGURATION_ConfigSettings *cs) |
Free resources associated with cs. More... | |
const struct GNUNET_OS_ProjectData * | GNUNET_CONFIGURATION_get_project_data (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Return the project data associated with this configuration. More... | |
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util", __VA_ARGS__) |
Definition at line 30 of file configuration.c.
#define LOG_STRERROR_FILE | ( | kind, | |
syscall, | |||
filename | |||
) | GNUNET_log_from_strerror_file (kind, "util", syscall, filename) |
Definition at line 32 of file configuration.c.
|
static |
Function called with a filename.
cls | closure |
filename | complete filename (absolute path) |
Definition at line 394 of file configuration.c.
References filename, CollectFilesContext::files, CollectFilesContext::files_length, GNUNET_array_append, GNUNET_OK, and GNUNET_strdup.
Referenced by GNUNET_CONFIGURATION_load_from(), and handle_inline().
|
static |
Find a section entry from a configuration.
cfg | configuration to search in |
section | name of the section to look for |
Definition at line 414 of file configuration.c.
References cfg, ConfigSection::name, ConfigSection::next, and GNUNET_CONFIGURATION_Handle::sections.
Referenced by find_entry(), GNUNET_CONFIGURATION_set_value_string(), and handle_inline().
|
static |
Definition at line 430 of file configuration.c.
Referenced by GNUNET_CONFIGURATION_load_from(), and handle_inline().
|
static |
Handle an inline directive.
Definition at line 444 of file configuration.c.
References cfg, cleanup(), collect_files_cb(), GNUNET_CONFIGURATION_Handle::current_nest_level, GNUNET_CONFIGURATION_Handle::diagnostics, ConfigSection::entries, CollectFilesContext::files, CollectFilesContext::files_length, find_section(), GNUNET_array_grow, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_parse(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_DISK_file_test_read(), GNUNET_DISK_glob(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, ConfigFile::hint_inaccessible, ConfigSection::hint_inlined_from_filename, ConfigSection::hint_inlined_from_line, ConfigFile::hint_restrict_section, ConfigSection::hint_secret_filename, ConfigSection::hint_secret_stat, ConfigSection::inaccessible, ConfigFile::level, GNUNET_CONFIGURATION_Handle::loaded_files_head, GNUNET_CONFIGURATION_Handle::loaded_files_tail, LOG, ConfigSection::name, ConfigEntry::next, ConfigSection::next, GNUNET_CONFIGURATION_Handle::pd, pstrcmp(), GNUNET_CONFIGURATION_Handle::restrict_section, GNUNET_CONFIGURATION_Handle::sections, and ConfigFile::source_filename.
Referenced by GNUNET_CONFIGURATION_deserialize().
|
static |
Find an entry from a configuration.
cfg | handle to the configuration |
section | section the option is in |
key | the option |
Definition at line 671 of file configuration.c.
References cfg, ConfigSection::entries, find_section(), GNUNET_ERROR_TYPE_WARNING, ConfigSection::inaccessible, key, ConfigEntry::key, LOG, and ConfigEntry::next.
Referenced by compare_entries(), GNUNET_CONFIGURATION_get_value_choice(), GNUNET_CONFIGURATION_get_value_float(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_size(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_have_value(), GNUNET_CONFIGURATION_set_value_string(), and set_entry_hint().
|
static |
Set a configuration hint.
cfg | configuration handle |
section | section |
option | config option |
hint_filename | |
hint_line |
Definition at line 707 of file configuration.c.
References cfg, GNUNET_CONFIGURATION_Handle::diagnostics, find_entry(), GNUNET_strdup, ConfigEntry::hint_filename, and ConfigEntry::hint_lineno.
Referenced by GNUNET_CONFIGURATION_deserialize().
|
static |
Should we skip this configuration entry when serializing?
sec | section name |
key | key |
Definition at line 1122 of file configuration.c.
References key.
Referenced by GNUNET_CONFIGURATION_serialize(), and GNUNET_CONFIGURATION_serialize_diagnostics().
|
static |
Dump an os installation path to a buffer.
cfg | configuration |
buf | buffer to write to |
ipk | which path to print |
Definition at line 1256 of file configuration.c.
References cfg, GNUNET_buffer_write_fstr(), GNUNET_free, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_BINDIR, GNUNET_OS_IPK_DATADIR, GNUNET_OS_IPK_DOCDIR, GNUNET_OS_IPK_ICONDIR, GNUNET_OS_IPK_LIBDIR, GNUNET_OS_IPK_LIBEXECDIR, GNUNET_OS_IPK_LOCALEDIR, GNUNET_OS_IPK_PREFIX, GNUNET_OS_IPK_SELF_PREFIX, and GNUNET_CONFIGURATION_Handle::pd.
Referenced by GNUNET_CONFIGURATION_serialize_diagnostics().
|
static |
Copy a configuration value to the given target configuration.
Overwrites existing entries.
cls | the destination configuration (struct GNUNET_CONFIGURATION_Handle * ) |
section | section for the value |
option | option name of the value |
value | value to copy |
Definition at line 1607 of file configuration.c.
References GNUNET_CONFIGURATION_set_value_string(), and value.
Referenced by GNUNET_CONFIGURATION_dup().
|
static |
A callback function, compares entries from two configurations (default against a new configuration) and write the diffs in a diff-configuration object (the callback object).
cls | the diff configuration (struct DiffHandle * ) |
section | section for the value (of the default conf.) |
option | option name of the value (of the default conf.) |
value | value to copy (of the default conf.) |
Definition at line 1646 of file configuration.c.
References DiffHandle::cfg_default, DiffHandle::cfgDiff, find_entry(), GNUNET_CONFIGURATION_set_value_string(), ConfigEntry::val, and value.
Referenced by GNUNET_CONFIGURATION_get_diff().
|
static |
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or the environment "FOO" is set to "DIRECTORY".
We also support default expansion, i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is set in PATHS or the environment, and otherwise to "default". Note that "default" itself can also be a $-expression, thus "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined to VAR2.
cfg | configuration to use for path expansion |
orig | string to $-expand (will be freed!) |
depth | recursion depth, used to detect recursive expansions |
Definition at line 2020 of file configuration.c.
References cfg, end, env, expand_dollar(), getenv(), GNUNET_CONFIGURATION_expand_dollar(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_realloc, GNUNET_strdup, LOG, prefix, result, and start.
Referenced by expand_dollar(), and GNUNET_CONFIGURATION_expand_dollar().
|
static |
FIXME.
value | FIXME |
Definition at line 2338 of file configuration.c.
References GNUNET_malloc, and value.
Referenced by GNUNET_CONFIGURATION_append_value_filename(), and GNUNET_CONFIGURATION_remove_value_filename().
|
static |
FIXME.
cls | string we compare with (const char*) |
fn | filename we are currently looking at |
Definition at line 2377 of file configuration.c.
References GNUNET_OK, and GNUNET_SYSERR.
Referenced by GNUNET_CONFIGURATION_append_value_filename().
|
static |
Print each option in a given section as a filename.
cls | closure |
section | name of the section |
option | name of the option |
value | value of the option |
Definition at line 2705 of file configuration.c.
References cfg, GNUNET_assert, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_free, GNUNET_OK, and GNUNET_STRINGS_filename_expand().
Referenced by GNUNET_CONFIGURATION_config_tool_run().
|
static |
Print each option in a given section.
cls | closure |
section | name of the section |
option | name of the option |
value | value of the option |
Definition at line 2742 of file configuration.c.
References value.
Referenced by GNUNET_CONFIGURATION_config_tool_run().
|
static |
Print out given section name.
cls | unused |
section | a section in the configuration file |
Definition at line 2764 of file configuration.c.
Referenced by GNUNET_CONFIGURATION_config_tool_run().