GNUnet 0.28.1-dev.4-46-g92a0edb0d
 
Loading...
Searching...
No Matches
Configuration library

Configuration management. More...

Collaboration diagram for Configuration library:

Data Structures

struct  GNUNET_CONFIGURATION_ConfigSettings
 Closure for GNUNET_CONFIGURATION_config_tool_run() with settings for what should be done with the configuration. More...
 

Macros

#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs)
 Macro that expands to a set of GNUNET-getopt directives to initialize a struct GNUNET_CONFIGURATION_ConfigSettings from the command line.
 

Typedefs

typedef enum GNUNET_GenericReturnValue(* GNUNET_CONFIGURATION_Callback) (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Signature of a function to be run with a configuration.
 
typedef void(* GNUNET_CONFIGURATION_Iterator) (void *cls, const char *section, const char *option, const char *value)
 Function to iterate over options.
 
typedef void(* GNUNET_CONFIGURATION_SectionIterator) (void *cls, const char *section)
 Function to iterate over all configuration sections.
 

Functions

struct GNUNET_CONFIGURATION_HandleGNUNET_CONFIGURATION_create (const struct GNUNET_OS_ProjectData *pd)
 Create a new configuration object.
 
struct GNUNET_CONFIGURATION_HandleGNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Duplicate an existing configuration object.
 
void GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
 Destroy configuration object.
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
 Load configuration.
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
 Load default configuration.
 
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.
 
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.
 
char * GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
 Serializes the given configuration.
 
char * GNUNET_CONFIGURATION_serialize_diagnostics (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Serializes the given configuration with diagnostics information.
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename)
 De-serializes configuration.
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
 Write configuration file.
 
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.
 
struct GNUNET_CONFIGURATION_HandleGNUNET_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.
 
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.
 
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.
 
void GNUNET_CONFIGURATION_enable_diagnostics (struct GNUNET_CONFIGURATION_Handle *cfg)
 Enable extra diagnostics.
 
const struct GNUNET_OS_ProjectDataGNUNET_CONFIGURATION_get_project_data (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Return the project data associated with this configuration.
 
void GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
 Iterate over all options in the configuration.
 
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.
 
void GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
 Remove the given section and all options in it.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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".
 
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.
 
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".
 
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.
 
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.
 
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.
 
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.
 
void GNUNET_CONFIGURATION_config_settings_free (struct GNUNET_CONFIGURATION_ConfigSettings *cs)
 Free resources associated with cs.
 
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.
 
char * GNUNET_CONFIGURATION_get_suid_binary_path (const struct GNUNET_OS_ProjectData *pd, const struct GNUNET_CONFIGURATION_Handle *cfg, const char *progname)
 Given the name of a helper, service or daemon binary construct the full path to the binary using the SUID_BINARY_PATH in the PATHS section of the configuration.
 

Detailed Description

Configuration management.

Macro Definition Documentation

◆ GNUNET_CONFIGURATION_CONFIG_OPTIONS

#define GNUNET_CONFIGURATION_CONFIG_OPTIONS (   cs)

Macro that expands to a set of GNUNET-getopt directives to initialize a struct GNUNET_CONFIGURATION_ConfigSettings from the command line.

Parameters
csconfiguration settings to initialize

Definition at line 764 of file gnunet_configuration_lib.h.

864{
865#endif
866#ifdef __cplusplus
867}
868#endif
869
870#endif
871
/* end of group configuration */
873
/* end of group addition */

Typedef Documentation

◆ GNUNET_CONFIGURATION_Callback

typedef enum GNUNET_GenericReturnValue(* GNUNET_CONFIGURATION_Callback) (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)

Signature of a function to be run with a configuration.

Parameters
clsclosure
cfgthe configuration
Returns
status code

Definition at line 237 of file gnunet_configuration_lib.h.

◆ GNUNET_CONFIGURATION_Iterator

typedef void(* GNUNET_CONFIGURATION_Iterator) (void *cls, const char *section, const char *option, const char *value)

Function to iterate over options.

Parameters
clsclosure
sectionname of the section
optionname of the option
valuevalue of the option

Definition at line 303 of file gnunet_configuration_lib.h.

◆ GNUNET_CONFIGURATION_SectionIterator

typedef void(* GNUNET_CONFIGURATION_SectionIterator) (void *cls, const char *section)

Function to iterate over all configuration sections.

Parameters
clsclosure
sectionname of the section

Definition at line 316 of file gnunet_configuration_lib.h.

Function Documentation

◆ GNUNET_CONFIGURATION_create()

struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create ( const struct GNUNET_OS_ProjectData pd)

Create a new configuration object.

Parameters
pdproject data to use to determine paths
Returns
fresh configuration object

Definition at line 227 of file configuration.c.

228{
230 char *p;
231
233 cfg->pd = pd;
234 /* make certain values from the project data available
235 as PATHS */
238 if (NULL != p)
239 {
241 "PATHS",
242 "DATADIR",
243 p);
244 GNUNET_free (p);
245 }
248 if (NULL != p)
249 {
251 "PATHS",
252 "LIBDIR",
253 p);
254 GNUNET_free (p);
255 }
258 if (NULL != p)
259 {
261 "PATHS",
262 "BINDIR",
263 p);
264 GNUNET_free (p);
265 }
268 if (NULL != p)
269 {
271 "PATHS",
272 "PREFIX",
273 p);
274 GNUNET_free (p);
275 }
278 if (NULL != p)
279 {
281 "PATHS",
282 "LOCALEDIR",
283 p);
284 GNUNET_free (p);
285 }
288 if (NULL != p)
289 {
291 "PATHS",
292 "ICONDIR",
293 p);
294 GNUNET_free (p);
295 }
298 if (NULL != p)
299 {
301 "PATHS",
302 "DOCDIR",
303 p);
304 GNUNET_free (p);
305 }
308 if (NULL != p)
309 {
311 "PATHS",
312 "LIBEXECDIR",
313 p);
314 GNUNET_free (p);
315 }
316 return cfg;
317}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static struct GNUNET_Process * p
Helper process we started.
Definition gnunet-uri.c:38
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_OS_installation_get_path(const struct GNUNET_OS_ProjectData *pd, enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
@ GNUNET_OS_IPK_ICONDIR
Return the prefix of the path with application icons (share/icons/).
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
@ GNUNET_OS_IPK_DOCDIR
Return the prefix of the path with documentation files, including the license (share/doc/gnunet/).
@ GNUNET_OS_IPK_LOCALEDIR
Return the directory where translations are installed (share/locale/)
@ GNUNET_OS_IPK_LIBDIR
Return the directory where libraries are installed.
@ GNUNET_OS_IPK_PREFIX
Return the "PREFIX" directory given to configure.
@ GNUNET_OS_IPK_BINDIR
Return the directory where the program binaries are installed.
@ GNUNET_OS_IPK_LIBEXECDIR
Return the directory where helper binaries are installed (lib/gnunet/libexec/)
const struct GNUNET_OS_ProjectData * pd
Project data for this configuration object.

References cfg, GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_new, 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, p, and GNUNET_CONFIGURATION_Handle::pd.

Referenced by auto_config_cb(), create_unique_cfgs(), gg_load_configuration(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_diff(), GNUNET_CONFIGURATION_parse_and_run(), GNUNET_PROGRAM_conf_and_options(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_TESTING_get_topo_from_string_(), GNUNET_TRANSPORT_TESTING_start_peer(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), handle_auto_result(), handle_autoconfig_request(), handle_inline(), iter_check_config(), load_member(), load_member_session(), load_member_session_next(), load_operation(), main(), main(), run(), run(), save_member(), save_member_session(), save_operation(), start_peer_run(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_dup()

struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup ( const struct GNUNET_CONFIGURATION_Handle cfg)

Duplicate an existing configuration object.

Parameters
cfgconfiguration to duplicate
Returns
duplicate configuration

Definition at line 1708 of file configuration.c.

1710{
1712
1715 &copy_entry,
1716 ret);
1717 return ret;
1718}
static void copy_entry(void *cls, const char *section, const char *option, const char *value)
Copy a configuration value to the given target configuration.
static int ret
Final status code.
Definition gnunet-arm.c:93
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.

References cfg, copy_entry(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_iterate(), GNUNET_CONFIGURATION_Handle::pd, and ret.

Referenced by auto_config_cb(), create_unique_cfgs(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_NAT_autoconfig_start(), handle_autoconfig_request(), run(), run(), run(), and set_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_destroy()

void GNUNET_CONFIGURATION_destroy ( struct GNUNET_CONFIGURATION_Handle cfg)

Destroy configuration object.

Parameters
cfgconfiguration to destroy

Definition at line 321 of file configuration.c.

322{
323 struct ConfigSection *sec;
324 struct ConfigFile *cf;
325
326 while (NULL != (sec = cfg->sections))
328 while (NULL != (cf = cfg->loaded_files_head))
329 {
334 cf);
335 GNUNET_free (cf);
336 }
339}
void GNUNET_CONFIGURATION_remove_section(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Remove the given section and all options in it.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
char * hint_restrict_section
Was this configuration file parsed via @inline-secret@?
char * source_filename
Source filename.
configuration section
char * name
name of the section
struct ConfigFile * loaded_files_tail
Linked list of loaded files.
struct ConfigSection * sections
Configuration sections.
struct ConfigFile * loaded_files_head
Linked list of loaded files.
char * main_filename
Name of the entry point configuration file.

References cfg, GNUNET_CONFIGURATION_remove_section(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, ConfigFile::hint_restrict_section, GNUNET_CONFIGURATION_Handle::loaded_files_head, GNUNET_CONFIGURATION_Handle::loaded_files_tail, GNUNET_CONFIGURATION_Handle::main_filename, ConfigSection::name, GNUNET_CONFIGURATION_Handle::sections, and ConfigFile::source_filename.

Referenced by auto_config_cb(), clean_node(), conclude_autoconfig_request(), create_unique_cfgs(), do_shutdown(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_parse_and_run(), GNUNET_CONFIGURATION_write_diffs(), GNUNET_NAT_autoconfig_cancel(), GNUNET_PROGRAM_conf_and_options(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_TESTING_get_topo_from_string_(), GNUNET_TRANSPORT_TESTING_start_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop(), handle_auto_result(), handle_autoconfig_request(), handle_inline(), load_member(), load_member_session(), load_member_session_next(), load_operation(), main(), next_phase(), save_member(), save_member_session(), save_operation(), shutdown_task(), shutdown_task(), shutdown_task(), start_peer_cleanup(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_load()

enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load ( struct GNUNET_CONFIGURATION_Handle cfg,
const char *  filename 
)

Load configuration.

This function will first parse the defaults and then parse the specific configuration file to overwrite the defaults.

Parameters
[in,out]cfgconfiguration to update
filenamename of the configuration file, NULL to load defaults
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 2701 of file configuration.c.

2704{
2705 char *baseconfig;
2706 const char *base_config_varname;
2707
2708 if (cfg->load_called)
2709 {
2710 /* FIXME: Make this a GNUNET_assert later */
2711 GNUNET_break (0);
2713 }
2714 cfg->load_called = true;
2715 if (NULL != filename)
2716 {
2719 }
2720
2721 base_config_varname = cfg->pd->base_config_varname;
2722
2723 if ((NULL != base_config_varname)
2724 && (NULL != (baseconfig = getenv (base_config_varname))))
2725 {
2726 baseconfig = GNUNET_strdup (baseconfig);
2727 }
2728 else
2729 {
2730 char *ipath;
2731
2734 if (NULL == ipath)
2735 {
2736 GNUNET_break (0);
2737 return GNUNET_SYSERR;
2738 }
2739 GNUNET_asprintf (&baseconfig,
2740 "%s%s",
2741 ipath,
2742 "config.d");
2743 GNUNET_free (ipath);
2744 }
2745
2746 {
2747 char *dname = GNUNET_STRINGS_filename_expand (baseconfig);
2748
2749 GNUNET_free (baseconfig);
2750
2751 if ((GNUNET_YES ==
2753 GNUNET_YES)) &&
2754 (GNUNET_SYSERR ==
2756 dname)))
2757 {
2759 "Failed to load base configuration from '%s'\n",
2760 filename);
2761 GNUNET_free (dname);
2762 return GNUNET_SYSERR; /* no configuration at all found */
2763 }
2764 GNUNET_free (dname);
2765 }
2766 if ((NULL != filename) &&
2767 (GNUNET_OK !=
2769 filename)))
2770 {
2771 /* specified configuration not found */
2773 "Failed to load configuration from file '%s'\n",
2774 filename);
2775 return GNUNET_SYSERR;
2776 }
2777 if (((GNUNET_YES !=
2779 "PATHS",
2780 "DEFAULTCONFIG"))) &&
2781 (filename != NULL))
2783 "PATHS",
2784 "DEFAULTCONFIG",
2785 filename);
2786 return GNUNET_OK;
2787}
#define LOG(kind,...)
char * getenv()
static char * filename
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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load_from(struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
Load default configuration.
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.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition disk.c:466
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_SYSERR
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition strings.c:531
bool load_called
Was the configuration ever loaded via GNUNET_CONFIGURATION_load?
const char * base_config_varname
Name of an environment variable that can be used to override the location from which default configur...

References GNUNET_OS_ProjectData::base_config_varname, cfg, filename, getenv(), GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_have_value(), GNUNET_CONFIGURATION_load_from(), GNUNET_CONFIGURATION_parse(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_OK, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_DATADIR, GNUNET_strdup, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, GNUNET_YES, GNUNET_CONFIGURATION_Handle::load_called, LOG, GNUNET_CONFIGURATION_Handle::main_filename, and GNUNET_CONFIGURATION_Handle::pd.

Referenced by auto_config_cb(), create_unique_cfgs(), gg_load_configuration(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_parse_and_run(), GNUNET_PROGRAM_conf_and_options(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_TRANSPORT_TESTING_start_peer(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), iter_check_config(), main(), main(), start_peer_run(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_load_from()

enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load_from ( struct GNUNET_CONFIGURATION_Handle cfg,
const char *  defaults_d 
)

Load default configuration.

This function will parse the defaults from the given defaults_d directory.

Parameters
cfgconfiguration to update
defaults_ddirectory with the defaults
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 2603 of file configuration.c.

2606{
2607 struct CollectFilesContext files_context = {
2608 .files = NULL,
2609 .files_length = 0,
2610 };
2611 enum GNUNET_GenericReturnValue fun_ret = GNUNET_NO;
2612
2613 if (GNUNET_SYSERR ==
2614 GNUNET_DISK_directory_scan (defaults_d,
2616 &files_context))
2617 return GNUNET_SYSERR; /* no configuration at all found */
2618 qsort (files_context.files,
2619 files_context.files_length,
2620 sizeof (char *),
2621 &pstrcmp);
2622 for (unsigned int i = 0; i < files_context.files_length; i++)
2623 {
2624 const char *ext;
2625 const char *filename = files_context.files[i];
2626
2627 /* Examine file extension */
2628 ext = strrchr (filename, '.');
2629 if ( (NULL == ext) ||
2630 (0 != strcmp (ext,
2631 ".conf")) )
2632 {
2634 "Skipping file `%s'\n",
2635 filename);
2636 fun_ret = GNUNET_OK;
2637 continue;
2638 }
2640 filename);
2641 if (fun_ret != GNUNET_OK)
2642 break;
2643 }
2644 if (files_context.files_length > 0)
2645 {
2646 for (size_t i = 0; i < files_context.files_length; i++)
2647 GNUNET_free (files_context.files[i]);
2648 GNUNET_array_grow (files_context.files,
2649 files_context.files_length,
2650 0);
2651 }
2652 return fun_ret;
2653}
static int pstrcmp(const void *a, const void *b)
static enum GNUNET_GenericReturnValue collect_files_cb(void *cls, const char *filename)
Function called with a filename.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition disk.c:881
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_NO
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
Closure to collect_files_cb.
char ** files
Collected files from globbing.
unsigned int files_length
Size of the files array.

References cfg, collect_files_cb(), filename, CollectFilesContext::files, CollectFilesContext::files_length, GNUNET_array_grow, GNUNET_CONFIGURATION_parse(), GNUNET_DISK_directory_scan(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, and pstrcmp().

Referenced by GNUNET_CONFIGURATION_load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_default_filename()

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.

Parameters
pdproject data to use to determine paths
Returns
NULL if no default configuration file can be located, a newly allocated string otherwise

Definition at line 2657 of file configuration.c.

2659{
2660 char *cfg_fn;
2661 const char *xdg = getenv ("XDG_CONFIG_HOME");
2662
2663 if (NULL != xdg)
2664 GNUNET_asprintf (&cfg_fn,
2665 "%s%s%s",
2666 xdg,
2668 pd->config_file);
2669 else
2670 cfg_fn = GNUNET_strdup (pd->user_config_file);
2671
2672 if (GNUNET_OK == GNUNET_DISK_file_test_read (cfg_fn))
2673 return cfg_fn;
2674 GNUNET_free (cfg_fn);
2675
2676 /* Fall back to /etc/ for the default configuration.
2677 Should be okay to use forward slashes here. */
2678
2679 GNUNET_asprintf (&cfg_fn,
2680 "/etc/%s",
2681 pd->config_file);
2682 if (GNUNET_OK ==
2684 return cfg_fn;
2685 GNUNET_free (cfg_fn);
2686
2687 GNUNET_asprintf (&cfg_fn,
2688 "/etc/%s/%s",
2689 pd->project_dirname,
2690 pd->config_file);
2691 if (GNUNET_OK ==
2693 return cfg_fn;
2694
2695 GNUNET_free (cfg_fn);
2696 return NULL;
2697}
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test_read(const char *fil)
Check that fil corresponds to a filename and the file has read permissions.
Definition disk.c:565
#define DIR_SEPARATOR_STR
Definition platform.h:167
const char * project_dirname
Name of the project that is used in the "libexec" prefix, For example, "gnunet".
const char * user_config_file
Configuration file name to use (if $XDG_CONFIG_HOME is not set).
const char * config_file
Configuration file name (in $XDG_CONFIG_HOME) to use.

References GNUNET_OS_ProjectData::config_file, DIR_SEPARATOR_STR, getenv(), GNUNET_asprintf(), GNUNET_DISK_file_test_read(), GNUNET_free, GNUNET_OK, GNUNET_strdup, GNUNET_OS_ProjectData::project_dirname, and GNUNET_OS_ProjectData::user_config_file.

Referenced by GNUNET_PROGRAM_run2(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_parse()

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.

Parameters
cfgconfiguration to update
filenamename of the configuration file
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 998 of file configuration.c.

1000{
1001 uint64_t fs64;
1002 size_t fs;
1003 char *fn;
1004 char *mem;
1005 int dirty;
1007 ssize_t sret;
1008
1011 "Asked to parse config file `%s'\n",
1012 fn);
1013 if (NULL == fn)
1014 return GNUNET_SYSERR;
1015
1016
1017 /* Check for cycles */
1018 {
1019 unsigned int lvl = cfg->current_nest_level;
1020 struct ConfigFile *cf = cfg->loaded_files_tail;
1021 struct ConfigFile *parent = NULL;
1022
1023
1024 for (; NULL != cf; parent = cf, cf = cf->prev)
1025 {
1026 /* Check parents based on level, skipping children of siblings. */
1027 if (cf->level >= lvl)
1028 continue;
1029 lvl = cf->level;
1030 if ( (NULL == cf->source_filename) ||
1031 (NULL == filename) )
1032 continue;
1033 if (0 == strcmp (cf->source_filename,
1034 filename))
1035 {
1036 if (NULL == parent)
1037 {
1039 "Forbidden direct cyclic configuration import (%s -> %s)\n",
1040 cf->source_filename,
1041 filename);
1042 }
1043 else
1045 "Forbidden indirect cyclic configuration import (%s -> ... -> %s -> %s)\n",
1046 cf->source_filename,
1047 parent->source_filename,
1048 filename);
1049 GNUNET_free (fn);
1050 return GNUNET_SYSERR;
1051 }
1052 }
1053
1054 }
1055
1056 /* Keep track of loaded files.*/
1057 {
1058 struct ConfigFile *cf = GNUNET_new (struct ConfigFile);
1059
1061 cf->source_filename = GNUNET_strdup (filename ? filename : "<input>");
1064 cf);
1065 }
1066
1067 dirty = cfg->dirty; /* back up value! */
1068 if (GNUNET_SYSERR ==
1070 &fs64,
1071 GNUNET_NO,
1072 GNUNET_YES))
1073 {
1075 "Error while determining the file size of `%s'\n",
1076 fn);
1077 GNUNET_free (fn);
1078 return GNUNET_SYSERR;
1079 }
1080 if (fs64 > SIZE_MAX)
1081 {
1082 GNUNET_break (0); /* File size is more than the heap size */
1083 GNUNET_free (fn);
1084 return GNUNET_SYSERR;
1085 }
1086 fs = fs64;
1087 mem = GNUNET_malloc (fs);
1088 sret = GNUNET_DISK_fn_read (fn,
1089 mem,
1090 fs);
1091 if ((sret < 0) || (fs != (size_t) sret))
1092 {
1094 "Error while reading file `%s'\n",
1095 fn);
1096 GNUNET_free (fn);
1097 GNUNET_free (mem);
1098 return GNUNET_SYSERR;
1099 }
1101 "Deserializing contents of file `%s'\n",
1102 fn);
1104 mem,
1105 fs,
1106 fn);
1107 if (GNUNET_SYSERR == ret)
1108 {
1110 _ ("Failed to parse configuration file `%s'\n"),
1111 fn);
1112 }
1113 GNUNET_free (fn);
1114 GNUNET_free (mem);
1115 /* restore dirty flag - anything we set in the meantime
1116 * came from disk */
1117 cfg->dirty = dirty;
1118 return ret;
1119}
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition gnunet-fs.c:35
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename)
De-serializes configuration.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition disk.c:235
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition disk.c:720
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_malloc(size)
Wrapper around malloc.
#define _(String)
GNU gettext support macro.
Definition platform.h:179
#define SIZE_MAX
Definition platform.h:213
struct ConfigFile * prev
unsigned int level
Level in the tree of loaded config files.
unsigned int current_nest_level
Current nesting level of file loading.
enum GNUNET_GenericReturnValue dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...

References _, cfg, GNUNET_CONFIGURATION_Handle::current_nest_level, GNUNET_CONFIGURATION_Handle::dirty, filename, fs, GNUNET_break, GNUNET_CONFIGURATION_deserialize(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_DISK_file_size(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, GNUNET_YES, ConfigFile::level, GNUNET_CONFIGURATION_Handle::loaded_files_head, GNUNET_CONFIGURATION_Handle::loaded_files_tail, LOG, ConfigFile::prev, ret, SIZE_MAX, and ConfigFile::source_filename.

Referenced by GNUNET_CONFIGURATION_load(), GNUNET_CONFIGURATION_load_from(), handle_inline(), load_member(), load_member_session(), load_member_session_next(), load_operation(), main(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_serialize()

char * GNUNET_CONFIGURATION_serialize ( const struct GNUNET_CONFIGURATION_Handle cfg,
size_t *  size 
)

Serializes the given configuration.

Parameters
cfgconfiguration to serialize
sizewill be set to the size of the serialized memory block
Returns
the memory block where the serialized configuration is present. This memory should be freed by the caller

Definition at line 1165 of file configuration.c.

1167{
1168 char *mem;
1169 char *cbuf;
1170 char *val;
1171 char *pos;
1172 size_t m_size;
1173 size_t c_size;
1174
1175 /* Pass1 : calculate the buffer size required */
1176 m_size = 0;
1177 for (struct ConfigSection *sec = cfg->sections;
1178 NULL != sec;
1179 sec = sec->next)
1180 {
1181 if (sec->inaccessible && (NULL == sec->entries))
1182 continue;
1183 /* For each section we need to add 3 characters: {'[',']','\n'} */
1184 m_size += strlen (sec->name) + 3;
1185 for (struct ConfigEntry *ent = sec->entries;
1186 NULL != ent;
1187 ent = ent->next)
1188 {
1189 if (do_skip (sec->name,
1190 ent->key))
1191 continue;
1192 if (NULL != ent->val)
1193 {
1194 /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */
1195 pos = ent->val;
1196 while (NULL != (pos = strstr (pos, "\n")))
1197 {
1198 m_size++;
1199 pos++;
1200 }
1201 /* For each key = value pair we need to add 4 characters (2
1202 spaces and 1 equal-to character and 1 new line) */
1203 m_size += strlen (ent->key) + strlen (ent->val) + 4;
1204 }
1205 }
1206 /* A new line after section end */
1207 m_size++;
1208 }
1209
1210 /* Pass2: Allocate memory and write the configuration to it */
1211 mem = GNUNET_malloc (m_size);
1212 c_size = 0;
1213 *size = c_size;
1214 for (struct ConfigSection *sec = cfg->sections;
1215 NULL != sec;
1216 sec = sec->next)
1217 {
1218 int len;
1219
1220 len = GNUNET_asprintf (&cbuf,
1221 "[%s]\n",
1222 sec->name);
1223 GNUNET_assert (0 < len);
1224 GNUNET_memcpy (mem + c_size,
1225 cbuf,
1226 len);
1227 c_size += len;
1228 GNUNET_free (cbuf);
1229 for (struct ConfigEntry *ent = sec->entries;
1230 NULL != ent;
1231 ent = ent->next)
1232 {
1233 if (do_skip (sec->name,
1234 ent->key))
1235 continue;
1236 if (NULL != ent->val)
1237 {
1238 val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
1239 strcpy (val, ent->val);
1240 while (NULL != (pos = strstr (val, "\n")))
1241 {
1242 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1243 pos[0] = '\\';
1244 pos[1] = 'n';
1245 }
1246 len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val);
1247 GNUNET_free (val);
1248 GNUNET_memcpy (mem + c_size, cbuf, len);
1249 c_size += len;
1250 GNUNET_free (cbuf);
1251 }
1252 }
1253 GNUNET_memcpy (mem + c_size, "\n", 1);
1254 c_size++;
1255 }
1256 GNUNET_assert (c_size == m_size);
1257 *size = c_size;
1258 return mem;
1259}
static bool do_skip(const char *sec, const char *key)
Should we skip this configuration entry when serializing?
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static unsigned int size
Size of the "table".
Definition peer.c:68
configuration entry

References cfg, do_skip(), GNUNET_asprintf(), GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_CONFIGURATION_Handle::sections, and size.

Referenced by conclude_autoconfig_request(), GNUNET_CONFIGURATION_write(), and GNUNET_NAT_AUTO_autoconfig_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_serialize_diagnostics()

char * GNUNET_CONFIGURATION_serialize_diagnostics ( const struct GNUNET_CONFIGURATION_Handle cfg)

Serializes the given configuration with diagnostics information.

Diagnostics information will only be available if diagnostics have been enabled before parsing.

Parameters
cfgconfiguration to serialize
Returns
the memory block where the serialized configuration is present. This memory should be freed by the caller

Definition at line 1319 of file configuration.c.

1321{
1322 struct GNUNET_Buffer buf = { 0 };
1323
1325 "#\n# Configuration file diagnostics\n#\n");
1327 "# Entry point: %s\n",
1329 "<none>");
1331 "#\n# Files Loaded:\n");
1332
1333 for (struct ConfigFile *cfil = cfg->loaded_files_head;
1334 NULL != cfil;
1335 cfil = cfil->next)
1336 {
1338 "# ");
1339 for (unsigned int i = 0; i < cfil->level; i++)
1341 "+");
1342 if (0 != cfil->level)
1344 " ");
1345
1347 "%s",
1348 cfil->source_filename);
1349
1350 if (NULL != cfil->hint_restrict_section)
1352 " (%s secret section %s)",
1353 cfil->hint_inaccessible
1354 ? "inaccessible"
1355 : "loaded",
1356 cfil->hint_restrict_section);
1357
1359 "\n");
1360 }
1361
1363 "#\n# Installation paths:\n");
1364
1374
1375
1377 "#\n\n");
1378
1379 for (struct ConfigSection *sec = cfg->sections;
1380 NULL != sec;
1381 sec = sec->next)
1382 {
1383 if (sec->hint_secret_filename)
1385 "# secret section from %s\n# secret file stat %s\n",
1386 sec->hint_secret_filename,
1387 sec->hint_secret_stat);
1388 if (sec->hint_inlined_from_filename)
1389 {
1391 "# inlined from %s:%u\n",
1392 sec->hint_inlined_from_filename,
1393 sec->hint_inlined_from_line);
1394 }
1396 "[%s]\n\n",
1397 sec->name);
1398 if (sec->inaccessible && (NULL == sec->entries))
1399 {
1401 "# <section contents inaccessible>\n\n\n");
1402 continue;
1403 }
1404 for (struct ConfigEntry *ent = sec->entries;
1405 NULL != ent;
1406 ent = ent->next)
1407 {
1408 if (do_skip (sec->name,
1409 ent->key))
1410 continue;
1411 if (NULL != ent->val)
1412 {
1413 char *pos;
1414 char *val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
1415 strcpy (val, ent->val);
1416 while (NULL != (pos = strstr (val, "\n")))
1417 {
1418 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1419 pos[0] = '\\';
1420 pos[1] = 'n';
1421 }
1422 if (NULL != ent->hint_filename)
1423 {
1425 "# %s:%u\n",
1426 ent->hint_filename,
1427 ent->hint_lineno);
1428 }
1430 "%s = %s\n",
1431 ent->key,
1432 val);
1433 GNUNET_free (val);
1434 }
1435 GNUNET_buffer_write_str (&buf, "\n");
1436 }
1437 if (sec->inaccessible)
1438 {
1440 "# <additional section contents inaccessible>\n\n\n");
1441 continue;
1442 }
1443
1444 GNUNET_buffer_write_str (&buf, "\n");
1445 }
1446 return GNUNET_buffer_reap_str (&buf);
1447}
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.
char * GNUNET_buffer_reap_str(struct GNUNET_Buffer *buf)
Clear the buffer and return the string it contained.
Definition buffer.c:89
void GNUNET_buffer_write_fstr(struct GNUNET_Buffer *buf, const char *fmt,...) __attribute__((format(printf
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator.
void GNUNET_buffer_write_str(struct GNUNET_Buffer *buf, const char *str)
Write a 0-terminated string to a buffer, excluding the 0-terminator.
Definition buffer.c:77
@ GNUNET_OS_IPK_SELF_PREFIX
Return the installation directory of this application, not the one of the overall GNUnet installation...
Dynamically growing buffer.

References cfg, do_skip(), dump_os_ipk(), GNUNET_buffer_reap_str(), GNUNET_buffer_write_fstr(), GNUNET_buffer_write_str(), GNUNET_free, GNUNET_malloc, 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, GNUNET_CONFIGURATION_Handle::loaded_files_head, GNUNET_CONFIGURATION_Handle::main_filename, and GNUNET_CONFIGURATION_Handle::sections.

Referenced by GNUNET_CONFIGURATION_config_tool_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_deserialize()

enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize ( struct GNUNET_CONFIGURATION_Handle cfg,
const char *  mem,
size_t  size,
const char *  source_filename 
)

De-serializes configuration.

Parameters
cfgconfiguration to update
memthe memory block of serialized configuration
sizethe size of the memory block
source_filenamesource filename, will be used to resolve relative @INLINE@ statements
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 733 of file configuration.c.

737{
738 size_t line_size;
739 unsigned int nr;
740 size_t r_bytes;
741 size_t to_read;
743 char *section;
744 char *eq;
745 char *tag;
746 char *value;
747 char *line_orig = NULL;
748
749 ret = GNUNET_OK;
750 section = NULL;
751 nr = 0;
752 r_bytes = 0;
753 while (r_bytes < size)
754 {
755 const char *pos;
756 char *line;
757 bool emptyline;
758
759 GNUNET_free (line_orig);
760 /* fgets-like behaviour on buffer */
761 to_read = size - r_bytes;
762 pos = memchr (&mem[r_bytes], '\n', to_read);
763 if (NULL == pos)
764 {
765 line_orig = GNUNET_strndup (&mem[r_bytes],
766 line_size = to_read);
767 r_bytes += line_size;
768 }
769 else
770 {
771 line_orig = GNUNET_strndup (&mem[r_bytes],
772 line_size = (pos - &mem[r_bytes]));
773 r_bytes += line_size + 1;
774 }
775 line = line_orig;
776 /* increment line number */
777 nr++;
778 /* tabs and '\r' are whitespace */
779 emptyline = GNUNET_YES;
780 for (size_t i = 0; i < line_size; i++)
781 {
782 if (line[i] == '\t')
783 line[i] = ' ';
784 if (line[i] == '\r')
785 line[i] = ' ';
786 if (' ' != line[i])
787 emptyline = GNUNET_NO;
788 }
789 /* ignore empty lines */
790 if (GNUNET_YES == emptyline)
791 continue;
792
793 /* remove tailing whitespace */
794 for (size_t i = line_size - 1;
795 (i >= 1) && (isspace ((unsigned char) line[i]));
796 i--)
797 line[i] = '\0';
798
799 /* remove leading whitespace */
800 for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++)
801 ;
802
803 /* ignore comments */
804 if ( ('#' == line[0]) ||
805 ('%' == line[0]) )
806 continue;
807
808 /* Handle special directives. */
809 if ('@' == line[0])
810 {
811 char *end = strchr (line + 1, '@');
812 char *directive;
813 enum GNUNET_GenericReturnValue directive_ret;
814
815 if (NULL != cfg->restrict_section)
816 {
818 "Illegal directive in line %u (parsing restricted section %s)\n",
819 nr,
822 break;
823 }
824
825 if (NULL == end)
826 {
828 "Bad directive in line %u\n",
829 nr);
831 break;
832 }
833 *end = '\0';
834 directive = line + 1;
835
836 if (0 == strcasecmp (directive,
837 "INLINE"))
838 {
839 const char *path = end + 1;
840
841 /* Skip space before path */
842 for (; isspace (*path); path++)
843 ;
844
845 directive_ret = handle_inline (cfg,
846 path,
847 false,
848 NULL,
849 source_filename,
850 nr);
851 }
852 else if (0 == strcasecmp (directive,
853 "INLINE-MATCHING"))
854 {
855 const char *path = end + 1;
856
857 /* Skip space before path */
858 for (; isspace (*path); path++)
859 ;
860
861 directive_ret = handle_inline (cfg,
862 path,
863 true,
864 NULL,
865 source_filename,
866 nr);
867 }
868 else if (0 == strcasecmp (directive,
869 "INLINE-SECRET"))
870 {
871 char *secname = end + 1;
872 char *secname_end;
873 const char *path;
874
875 /* Skip space before secname */
876 for (; isspace (*secname); secname++)
877 ;
878
879 secname_end = strchr (secname, ' ');
880
881 if (NULL == secname_end)
882 {
884 "Bad inline-secret directive in line %u\n",
885 nr);
887 break;
888 }
889 *secname_end = '\0';
890 path = secname_end + 1;
891
892 /* Skip space before path */
893 for (; isspace (*path); path++)
894 ;
895
896 directive_ret = handle_inline (cfg,
897 path,
898 false,
899 secname,
900 source_filename,
901 nr);
902 }
903 else
904 {
906 "Unknown or malformed directive '%s' in line %u\n",
907 directive,
908 nr);
910 break;
911 }
912 if (GNUNET_OK != directive_ret)
913 {
914 ret = directive_ret;
915 break;
916 }
917 continue;
918 }
919 if ( ('[' == line[0]) &&
920 (']' == line[line_size - 1]) )
921 {
922 /* [value] */
923 line[line_size - 1] = '\0';
924 value = &line[1];
925 GNUNET_free (section);
926 section = GNUNET_strdup (value);
927 continue;
928 }
929 if (NULL != (eq = strchr (line, '=')))
930 {
931
932 if (NULL == section)
933 {
935 "Syntax error while deserializing in line %u (option without section)\n",
936 nr);
938 break;
939 }
940
941 /* tag = value */
942 tag = GNUNET_strndup (line, eq - line);
943 /* remove tailing whitespace */
944 for (int i = strlen (tag) - 1;
945 (i >= 1) && (isspace ((unsigned char) tag[i]));
946 i--)
947 tag[i] = '\0';
948
949 /* Strip whitespace */
950 value = eq + 1;
951 while (isspace ((unsigned char) value[0]))
952 value++;
953 for (int i = strlen (value) - 1;
954 (i >= 1) && (isspace ((unsigned char) value[i]));
955 i--)
956 value[i] = '\0';
957
958 /* remove quotes */
959 if ( ('"' == value[0]) &&
960 ('"' == value[strlen (value) - 1]) )
961 {
962 value[strlen (value) - 1] = '\0';
963 value++;
964 }
966 section,
967 tag,
968 value);
969 if (cfg->diagnostics)
970 {
972 section,
973 tag,
974 source_filename
975 ? source_filename
976 : "<input>",
977 nr);
978 }
979 GNUNET_free (tag);
980 continue;
981 }
982 /* parse error */
984 "Syntax error while deserializing in line %u\n",
985 nr);
987 break;
988 }
989 GNUNET_free (line_orig);
990 GNUNET_free (section);
991 GNUNET_assert ( (GNUNET_OK != ret) ||
992 (r_bytes == size) );
993 return ret;
994}
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.
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.
static int end
Set if we are to shutdown all services (including ARM).
Definition gnunet-arm.c:33
static char * line
Desired phone line (string to be converted to a hash).
static char * value
Value of the record to add/remove.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
bool diagnostics
Enable diagnostics.
const char * restrict_section
When parsing into this configuration, and this value is non-NULL, only parse sections of the same nam...

References cfg, GNUNET_CONFIGURATION_Handle::diagnostics, end, GNUNET_assert, GNUNET_CONFIGURATION_set_value_string(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_strndup, GNUNET_SYSERR, GNUNET_YES, handle_inline(), line, LOG, GNUNET_CONFIGURATION_Handle::restrict_section, ret, set_entry_hint(), size, and value.

Referenced by GNUNET_CONFIGURATION_parse(), GNUNET_TESTING_get_topo_from_string_(), handle_auto_result(), handle_autoconfig_request(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_write()

enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write ( struct GNUNET_CONFIGURATION_Handle cfg,
const char *  filename 
)

Write configuration file.

Parameters
cfgconfiguration to write
filenamewhere to write the configuration
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 1451 of file configuration.c.

1454{
1455 char *fn;
1456 char *tfn;
1457 char *cfg_buf;
1458 size_t size;
1459
1461 if (fn == NULL)
1462 return GNUNET_SYSERR;
1464 {
1465 GNUNET_free (fn);
1466 return GNUNET_SYSERR;
1467 }
1468 {
1469 /* If @a filename is a symlink, replace what it points at, the way
1470 truncating it in place used to. */
1471 char *rfn = realpath (fn,
1472 NULL);
1473
1474 if (NULL != rfn)
1475 {
1476 GNUNET_free (fn);
1477 fn = GNUNET_strdup (rfn);
1478 free (rfn);
1479 }
1480 }
1482 &size);
1483 /* Never rewrite the configuration in place: opening it with O_TRUNC leaves
1484 it observably empty until we have written the new contents, and anyone
1485 parsing the file in that instant -- say a daemon that was just started
1486 with this very configuration -- reads a truncated file and fails. So
1487 write a sibling file and rename(2) it over the target; readers then
1488 always see either the complete old or the complete new configuration. */
1489 GNUNET_asprintf (&tfn,
1490 "%s.%u.tmp",
1491 fn,
1492 (unsigned int) getpid ());
1493 {
1494 struct GNUNET_DISK_FileHandle *h;
1495
1496 h = GNUNET_DISK_file_open (tfn,
1504 if (NULL == h)
1505 {
1506 GNUNET_free (tfn);
1507 GNUNET_free (fn);
1508 GNUNET_free (cfg_buf);
1509 return GNUNET_SYSERR;
1510 }
1511 if (((ssize_t) size) !=
1513 cfg_buf,
1514 size))
1515 {
1517 "write",
1518 tfn);
1520 (void) unlink (tfn);
1521 GNUNET_free (tfn);
1522 GNUNET_free (fn);
1523 GNUNET_free (cfg_buf);
1524 cfg->dirty = GNUNET_SYSERR; /* last write failed */
1525 return GNUNET_SYSERR;
1526 }
1527 /* Get the contents onto the disk before the rename publishes them, so
1528 that a crash cannot leave an empty configuration behind. */
1529 (void) GNUNET_DISK_file_sync (h);
1532 }
1533 {
1534 struct stat sbuf;
1535
1536 /* rename(2) replaces the inode, so carry over the permissions of the
1537 configuration we are about to replace (we just created @a tfn). */
1538 if ( (0 == stat (fn,
1539 &sbuf)) &&
1540 (0 != chmod (tfn,
1541 sbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) )
1543 "chmod",
1544 tfn);
1545 }
1546 if (0 != rename (tfn,
1547 fn))
1548 {
1550 "rename",
1551 fn);
1552 (void) unlink (tfn);
1553 GNUNET_free (tfn);
1554 GNUNET_free (fn);
1555 GNUNET_free (cfg_buf);
1556 cfg->dirty = GNUNET_SYSERR; /* last write failed */
1557 return GNUNET_SYSERR;
1558 }
1559 GNUNET_free (tfn);
1560 GNUNET_free (fn);
1561 GNUNET_free (cfg_buf);
1562 cfg->dirty = GNUNET_NO; /* last write succeeded */
1563 return GNUNET_OK;
1564}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition disk.c:1308
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition disk.c:745
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition disk.c:1507
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition disk.c:1386
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition disk.c:664
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_GROUP_WRITE
Group can write.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
Handle used to access files (and pipes).

References cfg, GNUNET_CONFIGURATION_Handle::dirty, filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_serialize(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_sync(), GNUNET_DISK_file_write(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_GROUP_READ, GNUNET_DISK_PERM_GROUP_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, h, and size.

Referenced by create_unique_cfgs(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_write_diffs(), handle_delete_message(), handle_rename_message(), save_member(), save_member_session(), save_operation(), set_cont(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_write_diffs()

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.

Parameters
cfg_defaultdefault configuration
cfg_newnew configuration
filenamewhere to write the configuration diff between default and new
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 1769 of file configuration.c.

1773{
1774 int ret;
1775 struct GNUNET_CONFIGURATION_Handle *diff;
1776
1777 diff = GNUNET_CONFIGURATION_get_diff (cfg_default, cfg_new);
1780 return ret;
1781}
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.

References filename, GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_diff(), GNUNET_CONFIGURATION_write(), and ret.

Referenced by auto_config_cb(), GNUNET_CONFIGURATION_config_tool_run(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_diff()

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.

Parameters
cfg_defaultoriginal configuration
cfg_newnew configuration
Returns
configuration with only the differences, never NULL

Definition at line 1752 of file configuration.c.

1755{
1756 struct DiffHandle diffHandle;
1757
1758 GNUNET_break (cfg_default->pd == cfg_new->pd);
1759 diffHandle.cfgDiff = GNUNET_CONFIGURATION_create (cfg_new->pd);
1760 diffHandle.cfg_default = cfg_default;
1763 &diffHandle);
1764 return diffHandle.cfgDiff;
1765}
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) a...
Used for diffing a configuration object against the default one.
const struct GNUNET_CONFIGURATION_Handle * cfg_default

References DiffHandle::cfg_default, DiffHandle::cfgDiff, compare_entries(), GNUNET_break, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_iterate(), and GNUNET_CONFIGURATION_Handle::pd.

Referenced by conclude_autoconfig_request(), GNUNET_CONFIGURATION_write_diffs(), and next_phase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_is_dirty()

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.

Parameters
cfgconfiguration to inspect
Returns
GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed)

Definition at line 1123 of file configuration.c.

1124{
1125 return cfg->dirty;
1126}

References cfg, and GNUNET_CONFIGURATION_Handle::dirty.

Referenced by auto_config_cb().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_parse_and_run()

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.

Then free the configuration object and return the status value from cb.

Parameters
pdproject data to use to determine paths
filenameconfiguration to parse, NULL for "default"
cbfunction to run
cb_clsclosure for cb
Returns
GNUNET_SYSERR if parsing the configuration failed, otherwise return value from cb.

Definition at line 343 of file configuration.c.

347{
350
352 if (GNUNET_OK !=
354 filename))
355 {
356 GNUNET_break (0);
358 return GNUNET_SYSERR;
359 }
360 ret = cb (cb_cls,
361 cfg);
363 return ret;
364}
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.

References cfg, filename, GNUNET_break, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_load(), GNUNET_OK, GNUNET_SYSERR, GNUNET_CONFIGURATION_Handle::pd, and ret.

Referenced by GNUNET_OS_purge_cfg_dir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_enable_diagnostics()

void GNUNET_CONFIGURATION_enable_diagnostics ( struct GNUNET_CONFIGURATION_Handle cfg)

Enable extra diagnostics.

Will produce more log output and allocate more memory.

Parameters
cfgconfiguration handle

Definition at line 219 of file configuration.c.

221{
222 cfg->diagnostics = true;
223}

References cfg, and GNUNET_CONFIGURATION_Handle::diagnostics.

Referenced by GNUNET_CONFIGURATION_config_tool_run().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_project_data()

const struct GNUNET_OS_ProjectData * GNUNET_CONFIGURATION_get_project_data ( const struct GNUNET_CONFIGURATION_Handle cfg)

Return the project data associated with this configuration.

Parameters
cfga configuration
Returns
associated project data, never NULL

Definition at line 3071 of file configuration.c.

3073{
3074 return cfg->pd;
3075}

References cfg, and GNUNET_CONFIGURATION_Handle::pd.

Referenced by GNUNET_BLOCK_context_create(), and GNUNET_DATACACHE_create().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_iterate()

void GNUNET_CONFIGURATION_iterate ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_CONFIGURATION_Iterator  iter,
void *  iter_cls 
)

Iterate over all options in the configuration.

Parameters
cfgconfiguration to inspect
iterfunction to call on each option
iter_clsclosure for iter

Definition at line 1568 of file configuration.c.

1572{
1573 for (struct ConfigSection *spos = cfg->sections;
1574 NULL != spos;
1575 spos = spos->next)
1576 for (struct ConfigEntry *epos = spos->entries;
1577 NULL != epos;
1578 epos = epos->next)
1579 if (NULL != epos->val)
1580 iter (iter_cls,
1581 spos->name,
1582 epos->key,
1583 epos->val);
1584}

References cfg, and GNUNET_CONFIGURATION_Handle::sections.

Referenced by get_cont(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_diff(), and GNUNET_TESTBED_configuration_create().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_iterate_sections()

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.

Parameters
cfgconfiguration to inspect
iterfunction to call on each section
iter_clsclosure for iter

Definition at line 1621 of file configuration.c.

1625{
1626 struct ConfigSection *spos;
1627 struct ConfigSection *next;
1628
1629 next = cfg->sections;
1630 while (NULL != next)
1631 {
1632 spos = next;
1633 next = spos->next;
1634 if (spos->inaccessible && (NULL == spos->entries))
1635 continue;
1636 iter (iter_cls,
1637 spos->name);
1638 }
1639}
struct ConfigEntry * entries
entries in the section
bool inaccessible
Is the configuration section marked as inaccessible?
struct ConfigSection * next
This is a linked list.

References cfg, ConfigSection::entries, ConfigSection::inaccessible, ConfigSection::name, ConfigSection::next, and GNUNET_CONFIGURATION_Handle::sections.

Referenced by GNUNET_CONFIGURATION_config_tool_run(), GNUNET_TESTBED_configuration_create(), handle_delete_message(), handle_rename_message(), pid_change_cb(), run(), and run().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_remove_section()

void GNUNET_CONFIGURATION_remove_section ( struct GNUNET_CONFIGURATION_Handle cfg,
const char *  section 
)

Remove the given section and all options in it.

Parameters
cfgconfiguration to inspect
sectionname of the section to remove

Definition at line 1643 of file configuration.c.

1645{
1646 struct ConfigSection *spos;
1647 struct ConfigSection *prev;
1648 struct ConfigEntry *ent;
1649
1650 prev = NULL;
1651 spos = cfg->sections;
1652 while (NULL != spos)
1653 {
1654 if (0 == strcasecmp (section,
1655 spos->name))
1656 {
1657 if (NULL == prev)
1658 cfg->sections = spos->next;
1659 else
1660 prev->next = spos->next;
1661 while (NULL != (ent = spos->entries))
1662 {
1663 spos->entries = ent->next;
1664 GNUNET_free (ent->key);
1665 GNUNET_free (ent->val);
1667 GNUNET_free (ent);
1668 cfg->dirty = GNUNET_YES;
1669 }
1670 GNUNET_free (spos->name);
1674 GNUNET_free (spos);
1675 return;
1676 }
1677 prev = spos;
1678 spos = spos->next;
1679 }
1680}
char * hint_filename
Diagnostics information for the filename.
struct ConfigEntry * next
This is a linked list.
char * key
key for this entry
char * val
current, committed value
char * hint_inlined_from_filename
For secret sections: Where was this inlined from?
char * hint_secret_filename
Diagnostics hint for the secret file.
char * hint_secret_stat
Extra information regarding permissions of the secret file.

References cfg, GNUNET_CONFIGURATION_Handle::dirty, ConfigSection::entries, GNUNET_free, GNUNET_YES, ConfigEntry::hint_filename, ConfigSection::hint_inlined_from_filename, ConfigSection::hint_secret_filename, ConfigSection::hint_secret_stat, ConfigEntry::key, ConfigSection::name, ConfigEntry::next, ConfigSection::next, GNUNET_CONFIGURATION_Handle::sections, and ConfigEntry::val.

Referenced by GNUNET_CONFIGURATION_destroy().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_number()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
numberwhere to store the numeric value of the option
Returns
GNUNET_OK on success, GNUNET_NO if option is not set GNUNET_SYSERR on error (value is malformed)

Definition at line 1847 of file configuration.c.

1852{
1853 struct ConfigEntry *e;
1854 char dummy[2];
1855
1856 if (NULL == (e = find_entry (cfg,
1857 section,
1858 option)))
1859 return GNUNET_NO;
1860 if (NULL == e->val)
1861 return GNUNET_NO;
1862 if (1 != sscanf (e->val,
1863 "%llu%1s",
1864 number,
1865 dummy))
1866 return GNUNET_SYSERR;
1867 return GNUNET_OK;
1868}
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
uint32_t number

References cfg, dummy, find_entry(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, number, and ConfigEntry::val.

Referenced by create_service(), create_subnets(), DHTU_ip_init(), GCD_init(), GCO_init(), GDS_NEIGHBOURS_init(), get_server_addresses(), get_server_addresses(), GNUNET_CLIENT_connect(), GNUNET_CLIENT_test(), GNUNET_HOSTLIST_server_start(), GNUNET_NAT_AUTO_test_start(), GNUNET_PROGRAM_run2(), GNUNET_REVOCATION_revoke(), GNUNET_SERVICE_run_(), GNUNET_SOCKS_do_connect(), GNUNET_TESTING_get_topo_from_string_(), GNUNET_TRANSPORT_communicator_connect(), GSF_cadet_start_server(), GSF_pending_request_init_(), libgnunet_plugin_block_revocation_init(), libgnunet_plugin_datastore_heap_init(), load_member_session(), load_operation(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), setup_exit_helper_args(), test_service_configuration(), test_stun(), and update_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_set_value_float()

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.

Note that this possibly truncates your float value.

Parameters
cfgconfiguration to update
sectionsection of interest
optionoption of interest
numbervalue to set

Definition at line 1872 of file configuration.c.

1876{
1877 char s[64];
1878
1879 /* See: #9369 */
1880 const locale_t cl = newlocale (LC_NUMERIC_MASK,
1881 "C",
1882 (locale_t) 0);
1883 locale_t old_locale = uselocale (cl);
1884 GNUNET_snprintf (s,
1885 64,
1886 "%f",
1887 (double) number);
1888 uselocale (old_locale);
1890 section,
1891 option,
1892 s);
1893}
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.

References cfg, GNUNET_CONFIGURATION_set_value_string(), GNUNET_snprintf(), and number.

Here is the call graph for this function:

◆ GNUNET_CONFIGURATION_get_value_float()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
numberwhere to store the floating value of the option
Returns
GNUNET_OK on success, GNUNET_NO if option is not set GNUNET_SYSERR on error (value is malformed)

Definition at line 1897 of file configuration.c.

1902{
1903 struct ConfigEntry *e;
1904 char dummy[2];
1905
1906 if (NULL == (e = find_entry (cfg,
1907 section,
1908 option)))
1909 return GNUNET_NO;
1910 if (NULL == e->val)
1911 return GNUNET_NO;
1912 /* See #9369 */
1913 {
1914 const locale_t cl = newlocale (LC_NUMERIC_MASK,
1915 "C",
1916 (locale_t) 0);
1917 locale_t old_locale = uselocale (cl);
1918
1919 if (1 != sscanf (e->val,
1920 "%f%1s",
1921 number,
1922 dummy))
1923 return GNUNET_SYSERR;
1924 uselocale (old_locale);
1925 }
1926 return GNUNET_OK;
1927}

References cfg, dummy, find_entry(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, number, and ConfigEntry::val.

Referenced by GNUNET_RPS_connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_time()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
timeset to the time value stored in the configuration
Returns
GNUNET_OK on success, GNUNET_NO if option is not set GNUNET_SYSERR on error (value is malformed)

Definition at line 1931 of file configuration.c.

1936{
1937 struct ConfigEntry *e;
1938 int ret;
1939
1940 if (NULL == (e = find_entry (cfg,
1941 section,
1942 option)))
1943 return GNUNET_NO;
1944 if (NULL == e->val)
1945 return GNUNET_NO;
1947 time);
1948 if (GNUNET_OK != ret)
1950 section,
1951 option,
1952 _ ("Not a valid relative time specification"));
1953 return ret;
1954}
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
Definition strings.c:259

References _, cfg, find_entry(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_invalid(), GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_fancy_time_to_relative(), ret, and ConfigEntry::val.

Referenced by GCD_init(), GNUNET_REVOCATION_revoke(), GNUNET_SPEEDUP_start_(), GSF_push_init_(), libgnunet_plugin_block_revocation_init(), RECLAIM_TICKETS_init(), REST_openid_init(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), and token_endpoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_size()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
sizeset to the size in bytes as stored in the configuration
Returns
GNUNET_OK on success, GNUNET_NO if option is not set GNUNET_SYSERR on error (value is malformed)

Definition at line 1958 of file configuration.c.

1963{
1964 struct ConfigEntry *e;
1965
1966 if (NULL == (e = find_entry (cfg,
1967 section,
1968 option)))
1969 return GNUNET_NO;
1970 if (NULL == e->val)
1971 return GNUNET_NO;
1973 size);
1974}
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
Definition strings.c:235

References cfg, find_entry(), GNUNET_NO, GNUNET_STRINGS_fancy_size_to_bytes(), size, and ConfigEntry::val.

Referenced by GNUNET_DATACACHE_create(), run(), run(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_have_value()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
Returns
GNUNET_YES if so, GNUNET_NO if not.

Definition at line 2081 of file configuration.c.

2084{
2085 struct ConfigEntry *e;
2086
2087 if ( (NULL == (e = find_entry (cfg,
2088 section,
2089 option))) ||
2090 (NULL == e->val) )
2091 return GNUNET_NO;
2092 return GNUNET_YES;
2093}

References cfg, find_entry(), GNUNET_NO, GNUNET_YES, and ConfigEntry::val.

Referenced by check_config(), get_server_addresses(), GNUNET_CLIENT_connect(), GNUNET_CLIENT_test(), GNUNET_CONFIGURATION_load(), GNUNET_HOSTLIST_server_start(), GNUNET_PROGRAM_run2(), GNUNET_SOCKS_check_service(), process_acl4(), process_acl6(), run(), setup_service(), start_arm_service(), test_service_configuration(), and update_config_sections().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_string()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
valuewill be set to a freshly allocated configuration value, or NULL if option is not specified
Returns
GNUNET_OK on success, GNUNET_NO if option is not set GNUNET_SYSERR on error (value is malformed)
Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
valuewill be set to a freshly allocated configuration value, or NULL if option is not specified
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 1988 of file configuration.c.

1993{
1994 struct ConfigEntry *e;
1995
1996 if ( (NULL == (e = find_entry (cfg,
1997 section,
1998 option))) ||
1999 (NULL == e->val) )
2000 {
2001 *value = NULL;
2002 return GNUNET_NO;
2003 }
2004 *value = GNUNET_strdup (e->val);
2005 return GNUNET_OK;
2006}

References cfg, find_entry(), GNUNET_NO, GNUNET_OK, GNUNET_strdup, ConfigEntry::val, and value.

Referenced by advertise_dns_exit(), check_authorization(), check_config(), client_connect_cb(), communicator_start(), DHTU_ip_init(), expand_dollar(), get_bootstrap_server(), get_server_addresses(), get_server_addresses(), gg_load_configuration(), GNUNET_CLIENT_connect(), GNUNET_CLIENT_test(), GNUNET_CONFIGURATION_append_value_filename(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_get_data(), GNUNET_CONFIGURATION_get_suid_binary_path(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_iterate_value_filenames(), GNUNET_CONFIGURATION_remove_value_filename(), GNUNET_CONVERSATION_phone_create(), GNUNET_DATACACHE_create(), GNUNET_FS_unindex_do_extract_keywords_(), GNUNET_GNS_lookup_with_tld(), GNUNET_HOSTLIST_client_start(), GNUNET_HOSTLIST_server_start(), GNUNET_PQ_init(), GNUNET_SOCKS_do_connect(), GNUNET_TESTING_get_topo_from_string_(), handle_ego_delete(), handle_ego_rename(), handle_register(), handle_uri(), identity_continuation(), load_member_session(), load_member_session_next(), login_redirect(), mq_init(), mq_init(), process_acl4(), process_acl6(), read_service_conf(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), setup_exit_helper_args(), setup_service(), sock_read(), sock_read(), start_arm_service(), start_peer_run(), start_process(), test_icmp_client(), test_icmp_server(), test_service_configuration(), token_endpoint(), and update_config_sections().

Here is the call graph for this function:

◆ GNUNET_CONFIGURATION_get_value_filename()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
valuewill be set to a freshly allocated configuration value, or NULL if option is not specified
Returns
GNUNET_OK on success, GNUNET_NO if option is not set GNUNET_SYSERR on error (value is malformed)

Definition at line 2292 of file configuration.c.

2297{
2298 char *tmp;
2300
2302 section,
2303 option,
2304 &tmp);
2305 if (GNUNET_OK != ret)
2306 {
2308 "Failed to retrieve filename\n");
2309 *value = NULL;
2310 return ret;
2311 }
2313 tmp);
2315 GNUNET_free (tmp);
2316 if (*value == NULL)
2317 return GNUNET_SYSERR;
2318 return GNUNET_OK;
2319}
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.
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...

References cfg, GNUNET_CONFIGURATION_expand_dollar(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_OK, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, LOG, ret, and value.

Referenced by create_service(), database_connect(), database_setup(), database_setup(), database_setup(), database_setup(), database_setup(), get_oidc_dir_path(), get_pid_file_name(), get_serialization_file_name(), get_serialization_file_name_in_dir(), get_server_addresses(), get_server_addresses(), get_update_information_directory(), get_user_name(), GNUNET_CLIENT_test(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_HOSTLIST_client_start(), GNUNET_PILS_create_key_ring(), GNUNET_PILS_enable_private_key(), GNUNET_PQ_init(), GNUNET_TIME_absolute_get_monotonic(), load(), load_hostlist_file(), load_ikm(), load_ikm(), new_sub(), print_filename_option(), purge_cfg_dir(), read_index_list(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), save(), save_hostlist_file(), setup_service(), start_arm_service(), start_peer_run(), test_service_configuration(), try_unixpath(), write_index_list(), and write_proof().

Here is the call graph for this function:

◆ GNUNET_CONFIGURATION_iterate_value_filenames()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
cbfunction to call on each filename
cb_clsclosure for cb
Returns
number of filenames iterated over, -1 on error

Definition at line 2351 of file configuration.c.

2357{
2358 char *list;
2359 char *pos;
2360 char *end;
2361 char old;
2362 int ret;
2363
2364 if (GNUNET_OK !=
2366 section,
2367 option,
2368 &list))
2369 return 0;
2370 GNUNET_assert (list != NULL);
2371 ret = 0;
2372 pos = list;
2373 while (1)
2374 {
2375 while (pos[0] == ' ')
2376 pos++;
2377 if (strlen (pos) == 0)
2378 break;
2379 end = pos + 1;
2380 while ((end[0] != ' ') && (end[0] != '\0'))
2381 {
2382 if (end[0] == '\\')
2383 {
2384 switch (end[1])
2385 {
2386 case '\\':
2387 case ' ':
2388 memmove (end, &end[1], strlen (&end[1]) + 1);
2389
2390 case '\0':
2391 /* illegal, but just keep it */
2392 break;
2393
2394 default:
2395 /* illegal, but just ignore that there was a '/' */
2396 break;
2397 }
2398 }
2399 end++;
2400 }
2401 old = end[0];
2402 end[0] = '\0';
2403 if (strlen (pos) > 0)
2404 {
2405 ret++;
2406 if ( (NULL != cb) &&
2407 (GNUNET_OK != cb (cb_cls,
2408 pos)))
2409 {
2411 break;
2412 }
2413 }
2414 if (old == '\0')
2415 break;
2416 pos = end + 1;
2417 }
2418 GNUNET_free (list);
2419 return ret;
2420}
static int list
Set if we should print a list of currently running services.
Definition gnunet-arm.c:68

References cfg, end, GNUNET_assert, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_OK, GNUNET_SYSERR, list, and ret.

Referenced by GNUNET_CONFIGURATION_append_value_filename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_iterate_section_values()

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.

Parameters
cfgconfiguration to inspect
sectionthe section
iterfunction to call on each option
iter_clsclosure for iter

Definition at line 1588 of file configuration.c.

1593{
1594 struct ConfigSection *spos;
1595
1596 spos = cfg->sections;
1597 while ((spos != NULL) && (0 != strcasecmp (spos->name, section)))
1598 spos = spos->next;
1599 if (NULL == spos)
1600 return;
1601 for (struct ConfigEntry *epos = spos->entries;
1602 NULL != epos;
1603 epos = epos->next)
1604 if (NULL != epos->val)
1605 iter (iter_cls,
1606 spos->name,
1607 epos->key,
1608 epos->val);
1609 if (spos->inaccessible)
1610 {
1612 "Section '%s' is marked as inaccessible, because a configuration "
1613 "file that contains the section can't be read.\n",
1614 section);
1615 return;
1616 }
1617}

References cfg, ConfigSection::entries, GNUNET_ERROR_TYPE_WARNING, ConfigSection::inaccessible, LOG, ConfigSection::name, ConfigSection::next, and GNUNET_CONFIGURATION_Handle::sections.

Referenced by authorize_endpoint(), auto_config_cb(), get_cont(), GNUNET_CONFIGURATION_config_tool_run(), and run().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_choice()

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.

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
choicesNULL-terminated list of legal values
valuewill be set to an entry in the legal list, or NULL if option is not specified and no default given
Returns
GNUNET_OK on success, GNUNET_NO if option is not set GNUNET_SYSERR on error (value not in choices)

Definition at line 2010 of file configuration.c.

2016{
2017 struct ConfigEntry *e;
2018 unsigned int i;
2019
2020 if (NULL == (e = find_entry (cfg,
2021 section,
2022 option)))
2023 return GNUNET_NO;
2024 for (i = 0; NULL != choices[i]; i++)
2025 if (0 == strcasecmp (choices[i], e->val))
2026 break;
2027 if (NULL == choices[i])
2028 {
2030 _ ("Configuration value '%s' for '%s'"
2031 " in section '%s' is not in set of legal choices\n"),
2032 e->val,
2033 option,
2034 section);
2035 return GNUNET_SYSERR;
2036 }
2037 *value = choices[i];
2038 return GNUNET_OK;
2039}

References _, cfg, find_entry(), GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, LOG, ConfigEntry::val, and value.

Referenced by GNUNET_CONFIGURATION_get_value_yesno(), run(), and start_process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_yesno()

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".

Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
Returns
GNUNET_OK if option is set to "YES" GNUNET_NO if option is not set or "NO" GNUNET_SYSERR on error (neither YES nor NO)

Definition at line 2323 of file configuration.c.

2327{
2328 static const char *yesno[] = {
2329 "YES",
2330 "NO",
2331 NULL
2332 };
2333 const char *val;
2335
2336 ret =
2338 section,
2339 option,
2340 yesno,
2341 &val);
2342 if (GNUNET_OK != ret)
2343 return ret;
2344 if (val == yesno[0])
2345 return GNUNET_YES;
2346 return GNUNET_NO;
2347}
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.

References cfg, GNUNET_CONFIGURATION_get_value_choice(), GNUNET_NO, GNUNET_OK, GNUNET_YES, ret, and ConfigEntry::val.

Referenced by advertise_dns_exit(), create_handle(), create_listen_socket(), create_service(), database_connect(), GDS_NEIGHBOURS_init(), get_server_addresses(), get_server_addresses(), gg_load_configuration(), GNS_resolver_init(), GNUNET_DATACACHE_create(), GNUNET_STATISTICS_create(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), GSF_pending_request_init_(), GSF_push_init_(), libgnunet_plugin_datacache_sqlite_init(), load_underlay(), main_init(), parse_ip_options(), reconnect_setup(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), setup_service(), setup_service(), start_arm_service(), start_process(), test_icmp_client(), test_icmp_server(), test_master(), udp_address_to_sockaddr(), and update_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_data()

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.

Parameters
cfgconfiguration to access
sectionsection to access
optionoption to access
bufwhere to store the decoded binary result
buf_sizeexact number of bytes to store in buf
Returns
GNUNET_OK on success GNUNET_NO is the value does not exist GNUNET_SYSERR on decoding error

Definition at line 2043 of file configuration.c.

2048{
2049 char *enc;
2050 int res;
2051 size_t data_size;
2052
2053 if (GNUNET_OK !=
2054 (res =
2056 section,
2057 option,
2058 &enc)))
2059 return res;
2060 data_size = (strlen (enc) * 5) / 8;
2061 if (data_size != buf_size)
2062 {
2063 GNUNET_free (enc);
2064 return GNUNET_SYSERR;
2065 }
2066 if (GNUNET_OK !=
2068 strlen (enc),
2069 buf,
2070 buf_size))
2071 {
2072 GNUNET_free (enc);
2073 return GNUNET_SYSERR;
2074 }
2075 GNUNET_free (enc);
2076 return GNUNET_OK;
2077}
static OpusEncoder * enc
OPUS encoder.
static char * res
Currently read line or NULL on EOF.
static size_t data_size
Number of bytes in data.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition strings.c:843

References cfg, data_size, enc, GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, and res.

Referenced by load_member(), load_member_session_next(), and load_operation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_expand_dollar()

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".

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.

Parameters
cfgconfiguration to use for path expansion
origstring to $-expand (will be freed!) Note that multiple $-expressions can be present in this string. They will all be $-expanded.
Returns
$-expanded string

Definition at line 2267 of file configuration.c.

2270{
2271 char *dup;
2272 size_t i;
2273 size_t len;
2274
2275 for (i = 0; '\0' != orig[i]; i++)
2276 {
2277 if ('$' != orig[i])
2278 continue;
2279 dup = GNUNET_strdup (orig + i);
2280 dup = expand_dollar (cfg, dup, 0);
2281 GNUNET_assert (NULL != dup); /* make compiler happy */
2282 len = strlen (dup) + 1;
2283 orig = GNUNET_realloc (orig, i + len);
2284 GNUNET_memcpy (orig + i, dup, len);
2285 GNUNET_free (dup);
2286 }
2287 return orig;
2288}
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...
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.

References cfg, expand_dollar(), GNUNET_assert, GNUNET_free, GNUNET_memcpy, GNUNET_realloc, and GNUNET_strdup.

Referenced by expand_dollar(), GNUNET_CONFIGURATION_get_value_filename(), run(), start_arm_service(), and start_process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_set_value_number()

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.

Parameters
cfgconfiguration to update
sectionsection of interest
optionoption of interest
numbervalue to set

Definition at line 1828 of file configuration.c.

1832{
1833 char s[64];
1834
1835 GNUNET_snprintf (s,
1836 64,
1837 "%llu",
1838 number);
1840 section,
1841 option,
1842 s);
1843}

References cfg, GNUNET_CONFIGURATION_set_value_string(), GNUNET_snprintf(), and number.

Referenced by next_phase(), run(), run(), save_member_session(), save_operation(), and set_value().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_set_value_string()

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.

Parameters
cfgconfiguration to update
sectionsection of interest
optionoption of interest
valuevalue to set

Definition at line 1785 of file configuration.c.

1790{
1791 struct ConfigSection *sec;
1792 struct ConfigEntry *e;
1793 char *nv;
1794
1795 e = find_entry (cfg, section, option);
1796 if (NULL != e)
1797 {
1798 if (NULL == value)
1799 {
1800 GNUNET_free (e->val);
1801 e->val = NULL;
1802 }
1803 else
1804 {
1805 nv = GNUNET_strdup (value);
1806 GNUNET_free (e->val);
1807 e->val = nv;
1808 }
1809 return;
1810 }
1811 sec = find_section (cfg, section);
1812 if (sec == NULL)
1813 {
1814 sec = GNUNET_new (struct ConfigSection);
1815 sec->name = GNUNET_strdup (section);
1816 sec->next = cfg->sections;
1817 cfg->sections = sec;
1818 }
1819 e = GNUNET_new (struct ConfigEntry);
1820 e->key = GNUNET_strdup (option);
1821 e->val = GNUNET_strdup (value);
1822 e->next = sec->entries;
1823 sec->entries = e;
1824}
static struct ConfigSection * find_section(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Find a section entry from a configuration.

References cfg, ConfigSection::entries, find_entry(), find_section(), GNUNET_free, GNUNET_new, GNUNET_strdup, ConfigEntry::key, ConfigSection::name, ConfigEntry::next, ConfigSection::next, GNUNET_CONFIGURATION_Handle::sections, ConfigEntry::val, and value.

Referenced by auto_conf_iter(), auto_config_cb(), compare_entries(), copy_entry(), GNUNET_CONFIGURATION_append_value_filename(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_load(), GNUNET_CONFIGURATION_remove_value_filename(), GNUNET_CONFIGURATION_set_value_float(), GNUNET_CONFIGURATION_set_value_number(), GNUNET_NAT_autoconfig_start(), GNUNET_PROGRAM_run2(), GNUNET_TESTBED_configuration_create(), handle_ego_delete(), handle_ego_rename(), handle_inline(), identity_cb(), next_phase(), process_if(), result_callback(), run(), run(), save_member(), save_member_session(), save_operation(), set_external_ipv4(), set_value(), start_peer_run(), test_local_ip(), test_upnpc(), update_config(), update_config_sections(), and update_enable_upnpc_option().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_remove_value_filename()

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.

Parameters
cfgconfiguration to update
sectionsection of interest
optionoption of interest
valuefilename to remove
Returns
GNUNET_OK on success, GNUNET_SYSERR if the filename is not in the list

Definition at line 2519 of file configuration.c.

2524{
2525 char *list;
2526 char *pos;
2527 char *end;
2528 char *match;
2529 char old;
2530
2531 if (GNUNET_OK !=
2533 section,
2534 option,
2535 &list))
2536 return GNUNET_NO;
2537 match = escape_name (value);
2538 pos = list;
2539 while (1)
2540 {
2541 while (pos[0] == ' ')
2542 pos++;
2543 if (strlen (pos) == 0)
2544 break;
2545 end = pos + 1;
2546 while ((end[0] != ' ') && (end[0] != '\0'))
2547 {
2548 if (end[0] == '\\')
2549 {
2550 switch (end[1])
2551 {
2552 case '\\':
2553 case ' ':
2554 end++;
2555 break;
2556
2557 case '\0':
2558 /* illegal, but just keep it */
2559 break;
2560
2561 default:
2562 /* illegal, but just ignore that there was a '/' */
2563 break;
2564 }
2565 }
2566 end++;
2567 }
2568 old = end[0];
2569 end[0] = '\0';
2570 if (0 == strcmp (pos, match))
2571 {
2572 if (old != '\0')
2573 memmove (pos,
2574 &end[1],
2575 strlen (&end[1]) + 1);
2576 else
2577 {
2578 if (pos != list)
2579 pos[-1] = '\0';
2580 else
2581 pos[0] = '\0';
2582 }
2584 section,
2585 option,
2586 list);
2587 GNUNET_free (list);
2588 GNUNET_free (match);
2589 return GNUNET_OK;
2590 }
2591 if (old == '\0')
2592 break;
2593 end[0] = old;
2594 pos = end + 1;
2595 }
2596 GNUNET_free (list);
2597 GNUNET_free (match);
2598 return GNUNET_NO;
2599}
static char * escape_name(const char *value)
FIXME.

References cfg, end, escape_name(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_NO, GNUNET_OK, list, and value.

Here is the call graph for this function:

◆ GNUNET_CONFIGURATION_append_value_filename()

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.

Parameters
cfgconfiguration to update
sectionsection of interest
optionoption of interest
valuefilename to append
Returns
GNUNET_OK on success, GNUNET_SYSERR if the filename already in the list

Definition at line 2481 of file configuration.c.

2486{
2487 char *escaped;
2488 char *old;
2489 char *nw;
2490
2491 if (GNUNET_SYSERR ==
2493 section,
2494 option,
2495 &test_match,
2496 (void *) value))
2497 return GNUNET_NO; /* already exists */
2498 if (GNUNET_OK !=
2499 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old))
2500 old = GNUNET_strdup ("");
2501 escaped = escape_name (value);
2502 nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2);
2503 strcpy (nw, old);
2504 if (strlen (old) > 0)
2505 strcat (nw, " ");
2506 strcat (nw, escaped);
2508 section,
2509 option,
2510 nw);
2511 GNUNET_free (old);
2512 GNUNET_free (nw);
2513 GNUNET_free (escaped);
2514 return GNUNET_OK;
2515}
static enum GNUNET_GenericReturnValue test_match(void *cls, const char *fn)
FIXME.
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.

References cfg, escape_name(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_iterate_value_filenames(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, test_match(), and value.

Here is the call graph for this function:

◆ GNUNET_CONFIGURATION_config_settings_free()

void GNUNET_CONFIGURATION_config_settings_free ( struct GNUNET_CONFIGURATION_ConfigSettings cs)

Free resources associated with cs.

Parameters
[in]cssettings to free (actual memory of cs itself is not released)

Definition at line 3061 of file configuration.c.

3063{
3064 GNUNET_free (cs->option);
3065 GNUNET_free (cs->section);
3066 GNUNET_free (cs->value);
3067}

References GNUNET_free, GNUNET_CONFIGURATION_ConfigSettings::option, GNUNET_CONFIGURATION_ConfigSettings::section, and GNUNET_CONFIGURATION_ConfigSettings::value.

Referenced by main().

Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_config_tool_run()

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.

Parameters
clsclosure with the struct GNUNET_CONFIGURATION_ConfigSettings
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 2869 of file configuration.c.

2874{
2875 struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
2876 struct GNUNET_CONFIGURATION_Handle *out = NULL;
2877 struct GNUNET_CONFIGURATION_Handle *ncfg = NULL;
2878
2879 (void) args;
2880 if (cs->diagnostics)
2881 {
2882 /* Re-parse the configuration with diagnostics enabled. */
2885 if (GNUNET_OK !=
2887 cfgfile))
2888 {
2889 fprintf (stderr,
2890 _ ("Failed to load config file `%s'"),
2891 cfgfile);
2892 return;
2893 }
2894 cfg = ncfg;
2895 }
2896
2897 if (cs->full)
2898 cs->rewrite = GNUNET_YES;
2899 if (cs->list_sections)
2900 {
2901 fprintf (stderr,
2902 _ ("The following sections are available:\n"));
2905 NULL);
2906 return;
2907 }
2908 if ( (! cs->rewrite) &&
2909 (NULL == cs->section) )
2910 {
2911 char *serialization;
2912
2913 if (! cs->diagnostics)
2914 {
2915 fprintf (stderr,
2916 _ ("%s, %s or %s argument is required\n"),
2917 "--section",
2918 "--list-sections",
2919 "--diagnostics");
2921 return;
2922 }
2924 fprintf (stdout,
2925 "%s",
2926 serialization);
2927 GNUNET_free (serialization);
2928 }
2929 else if ( (NULL != cs->section) &&
2930 (NULL == cs->value) )
2931 {
2932 if (NULL == cs->option)
2933 {
2935 cfg,
2936 cs->section,
2937 cs->is_filename
2939 : &print_option,
2940 (void *) cfg);
2941 }
2942 else
2943 {
2944 char *value;
2945
2946 if (cs->is_filename)
2947 {
2948 if (GNUNET_OK !=
2950 cs->section,
2951 cs->option,
2952 &value))
2953 {
2955 cs->section,
2956 cs->option);
2958 return;
2959 }
2960 }
2961 else
2962 {
2963 if (GNUNET_OK !=
2965 cs->section,
2966 cs->option,
2967 &value))
2968 {
2970 cs->section,
2971 cs->option);
2973 return;
2974 }
2975 }
2976 fprintf (stdout,
2977 "%s\n",
2978 value);
2980 }
2981 }
2982 else if (NULL != cs->section)
2983 {
2984 if (NULL == cs->option)
2985 {
2986 fprintf (stderr,
2987 _ ("--option argument required to set value\n"));
2989 return;
2990 }
2993 cs->section,
2994 cs->option,
2995 cs->value);
2996 cs->rewrite = GNUNET_YES;
2997 }
2998 if (cs->rewrite)
2999 {
3000 char *cfg_fn = NULL;
3001
3002 if (NULL == out)
3004
3005 if (NULL == cfgfile)
3006 {
3007 const char *xdg = getenv ("XDG_CONFIG_HOME");
3008
3009 if (NULL != xdg)
3010 GNUNET_asprintf (&cfg_fn,
3011 "%s%s%s",
3012 xdg,
3014 cfg->pd->config_file);
3015 else
3016 cfg_fn = GNUNET_strdup (cfg->pd->user_config_file);
3017 cfgfile = cfg_fn;
3018 }
3019
3020 if (! cs->full)
3021 {
3022 struct GNUNET_CONFIGURATION_Handle *def;
3023
3025 if (GNUNET_OK !=
3027 NULL))
3028 {
3029 fprintf (stderr,
3030 _ ("failed to load configuration defaults"));
3031 cs->global_ret = 1;
3034 GNUNET_free (cfg_fn);
3035 return;
3036 }
3037 if (GNUNET_OK !=
3039 out,
3040 cfgfile))
3041 cs->global_ret = 2;
3043 }
3044 else
3045 {
3046 if (GNUNET_OK !=
3048 cfgfile))
3049 cs->global_ret = 2;
3050 }
3051 GNUNET_free (cfg_fn);
3052 }
3053 if (NULL != out)
3055 if (NULL != ncfg)
3057}
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.
static void print_section_name(void *cls, const char *section)
Print out given section name.
static void print_option(void *cls, const char *section, const char *option, const char *value)
Print each option in a given section.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
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.
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.
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.
char * GNUNET_CONFIGURATION_serialize_diagnostics(const struct GNUNET_CONFIGURATION_Handle *cfg)
Serializes the given configuration with diagnostics information.
void GNUNET_CONFIGURATION_enable_diagnostics(struct GNUNET_CONFIGURATION_Handle *cfg)
Enable extra diagnostics.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define EXIT_INVALIDARGUMENT
Definition platform.h:258
#define EXIT_NOTCONFIGURED
Definition platform.h:274
Closure for GNUNET_CONFIGURATION_config_tool_run() with settings for what should be done with the con...
int full
Should the generated configuration file contain the whole configuration?
int global_ret
Return value from the operation, to be returned from 'main'.
int diagnostics
Should we give extra diagnostics?
int list_sections
Whether to show the sections.
int rewrite
Should we write out the configuration file, even if no value was changed?
int is_filename
Treat option as a filename.

References _, cfg, GNUNET_OS_ProjectData::config_file, GNUNET_CONFIGURATION_ConfigSettings::diagnostics, DIR_SEPARATOR_STR, EXIT_INVALIDARGUMENT, EXIT_NOTCONFIGURED, GNUNET_CONFIGURATION_ConfigSettings::full, getenv(), GNUNET_CONFIGURATION_ConfigSettings::global_ret, GNUNET_asprintf(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_enable_diagnostics(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_iterate_section_values(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_load(), GNUNET_CONFIGURATION_serialize_diagnostics(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_CONFIGURATION_write_diffs(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_strdup, GNUNET_YES, GNUNET_CONFIGURATION_ConfigSettings::is_filename, GNUNET_CONFIGURATION_ConfigSettings::list_sections, GNUNET_CONFIGURATION_ConfigSettings::option, GNUNET_CONFIGURATION_Handle::pd, print_filename_option(), print_option(), print_section_name(), GNUNET_CONFIGURATION_ConfigSettings::rewrite, GNUNET_CONFIGURATION_ConfigSettings::section, GNUNET_OS_ProjectData::user_config_file, value, and GNUNET_CONFIGURATION_ConfigSettings::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_suid_binary_path()

char * GNUNET_CONFIGURATION_get_suid_binary_path ( const struct GNUNET_OS_ProjectData pd,
const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  progname 
)

Given the name of a helper, service or daemon binary construct the full path to the binary using the SUID_BINARY_PATH in the PATHS section of the configuration.

If that option is not present, fall back to GNUNET_OS_get_libexec_binary_path. If progname is an absolute path, a copy of this path is returned.

Parameters
pdproject data to use to determine paths
cfgconfiguration to inspect
prognamename of the binary
Returns
full path to the binary, if possible, a copy of progname otherwise

Definition at line 3079 of file configuration.c.

3084{
3085 static char *cache;
3086 char *binary = NULL;
3087 char *path = NULL;
3088 size_t path_len;
3089
3090 if (GNUNET_YES ==
3092 GNUNET_NO,
3093 NULL,
3094 NULL))
3095 {
3096 return GNUNET_strdup (progname);
3097 }
3098 if (NULL != cache)
3099 path = cache;
3100 else
3102 "PATHS",
3103 "SUID_BINARY_PATH",
3104 &path);
3105 if ( (NULL == path) ||
3106 (0 == strlen (path)) )
3107 {
3108 if (NULL != path)
3109 GNUNET_free (path);
3110 cache = NULL;
3112 progname);
3113 }
3114 path_len = strlen (path);
3115 GNUNET_asprintf (&binary,
3116 "%s%s%s",
3117 path,
3118 (path[path_len - 1] == DIR_SEPARATOR) ? ""
3120 progname);
3121 cache = path;
3122 return binary;
3123}
char * GNUNET_OS_get_libexec_binary_path(const struct GNUNET_OS_ProjectData *pd, const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
enum GNUNET_GenericReturnValue GNUNET_STRINGS_path_is_absolute(const char *filename, int can_be_uri, int *r_is_uri, char **r_uri_scheme)
Check whether filename is absolute or not, and if it's an URI.
Definition strings.c:1012
#define DIR_SEPARATOR
Definition platform.h:166

References cfg, DIR_SEPARATOR, DIR_SEPARATOR_STR, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_NO, GNUNET_OS_get_libexec_binary_path(), GNUNET_strdup, GNUNET_STRINGS_path_is_absolute(), and GNUNET_YES.

Referenced by GN_request_connection_reversal(), restart_nat_server(), run(), run(), and run().

Here is the call graph for this function:
Here is the caller graph for this function: