GNUnet  0.11.x
Typedefs | Functions
Configuration library

Configuration management. More...

Typedefs

typedef int(* GNUNET_CONFIGURATION_Callback) (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Signature of a function to be run with a configuration. More...
 
typedef void(* GNUNET_CONFIGURATION_Iterator) (void *cls, const char *section, const char *option, const char *value)
 Function to iterate over options. More...
 
typedef void(* GNUNET_CONFIGURATION_Section_Iterator) (void *cls, const char *section)
 Function to iterate over section. More...
 

Functions

struct GNUNET_CONFIGURATION_HandleGNUNET_CONFIGURATION_create (void)
 Create a new configuration object. More...
 
struct GNUNET_CONFIGURATION_HandleGNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Duplicate an existing configuration object. More...
 
void GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
 Destroy configuration object. More...
 
int GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
 Load configuration. More...
 
int GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
 Load default configuration. More...
 
int GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
 Parse a configuration file, add all of the options in the file to the configuration environment. More...
 
char * GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
 Serializes the given configuration. More...
 
int GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
 De-serializes configuration. More...
 
int GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
 Write configuration file. More...
 
int GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new, const char *filename)
 Write only configuration entries that have been changed to configuration file. More...
 
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. More...
 
int GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Test if there are configuration options that were changed since the last save. More...
 
int GNUNET_CONFIGURATION_parse_and_run (const char *filename, GNUNET_CONFIGURATION_Callback cb, void *cb_cls)
 Parse a configuration file filename and run the function cb with the resulting configuration object. More...
 
void GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
 Iterate over all options in the configuration. More...
 
void GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Section_Iterator iter, void *iter_cls)
 Iterate over all sections in the configuration. More...
 
void GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
 Remove the given section and all options in it. More...
 
int GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
 Get a configuration value that should be a number. More...
 
int GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number)
 Get a configuration value that should be a floating point number. More...
 
int GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
 Get a configuration value that should be a relative time. More...
 
int GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *size)
 Get a configuration value that should be a size in bytes. More...
 
int GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
 Test if we have a value for a particular option. More...
 
int GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
 Get a configuration value that should be a string. More...
 
int GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
 Get a configuration value that should be the name of a file or directory. More...
 
int GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, GNUNET_FileNameCallback cb, void *cb_cls)
 Iterate over the set of filenames stored in a configuration value. More...
 
void GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
 Iterate over values of a section in the configuration. More...
 
int GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *const *choices, const char **value)
 Get a configuration value that should be in a set of predefined strings. More...
 
int GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
 Get a configuration value that should be in a set of "YES" or "NO". More...
 
int GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, void *buf, size_t buf_size)
 Get Crockford32-encoded fixed-size binary data from a configuration. More...
 
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 environtment "FOO" is set to "DIRECTORY". More...
 
void GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
 Set a configuration value that should be a number. More...
 
void GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
 Set a configuration value that should be a string. More...
 
int GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
 Remove a filename from a configuration value that represents a list of filenames. More...
 
int GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
 Append a filename to a configuration value that represents a list of filenames. More...
 

Detailed Description

Configuration management.

Typedef Documentation

◆ GNUNET_CONFIGURATION_Callback

typedef int(* 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 207 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 237 of file gnunet_configuration_lib.h.

◆ GNUNET_CONFIGURATION_Section_Iterator

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

Function to iterate over section.

Parameters
clsclosure
sectionname of the section

Definition at line 250 of file gnunet_configuration_lib.h.

Function Documentation

◆ GNUNET_CONFIGURATION_create()

struct GNUNET_CONFIGURATION_Handle* GNUNET_CONFIGURATION_create ( void  )

Create a new configuration object.

Returns
fresh configuration object

Create a new configuration object.

Returns
fresh configuration object

Definition at line 118 of file configuration.c.

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, and p.

Referenced by auto_config_cb(), create_unique_cfgs(), gg_load_configuration(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_TEST_experimentation_load(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_get_diff(), GNUNET_CONFIGURATION_parse_and_run(), GNUNET_CRYPTO_eddsa_setup_key(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_extract_config_(), GNUNET_TESTING_service_run(), GNUNET_TESTING_system_create_with_portrange(), GNUNET_TRANSPORT_TESTING_start_peer(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), handle_auto_result(), handle_autoconfig_request(), helper_mst(), iter_check_config(), LEGACY_SERVICE_run(), main(), run(), and tokenizer_cb().

119 {
121  char *p;
122 
124  /* make certain values from the project data available
125  as PATHS */
127  if (NULL != p)
128  {
130  "PATHS",
131  "DATADIR",
132  p);
133  GNUNET_free (p);
134  }
136  if (NULL != p)
137  {
139  "PATHS",
140  "LIBDIR",
141  p);
142  GNUNET_free (p);
143  }
145  if (NULL != p)
146  {
148  "PATHS",
149  "BINDIR",
150  p);
151  GNUNET_free (p);
152  }
154  if (NULL != p)
155  {
157  "PATHS",
158  "PREFIX",
159  p);
160  GNUNET_free (p);
161  }
163  if (NULL != p)
164  {
166  "PATHS",
167  "LOCALEDIR",
168  p);
169  GNUNET_free (p);
170  }
172  if (NULL != p)
173  {
175  "PATHS",
176  "ICONDIR",
177  p);
178  GNUNET_free (p);
179  }
181  if (NULL != p)
182  {
184  "PATHS",
185  "DOCDIR",
186  p);
187  GNUNET_free (p);
188  }
190  if (NULL != p)
191  {
193  "PATHS",
194  "LIBEXECDIR",
195  p);
196  GNUNET_free (p);
197  }
198  return cfg;
199 }
Return the directory where translations are installed (share/locale/)
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
Return the directory where libraries are installed.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Return the "PREFIX" directory given to configure.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
Return the prefix of the path with documentation files, including the license (share/doc/gnunet/).
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation directory.
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.
Return the directory where helper binaries are installed (lib/gnunet/libexec/)
Return the directory where the program binaries are installed.
configuration data
Definition: configuration.c:84
Return the prefix of the path with application icons (share/icons/).
Return the directory where data is installed (share/gnunet/)
#define GNUNET_free(ptr)
Wrapper around free.
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 779 of file configuration.c.

References copy_entry(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_iterate(), and ret.

Referenced by associate_shared_service(), auto_config_cb(), controller_status_cb(), create_unique_cfgs(), GNUNET_NAT_autoconfig_start(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_host_create_with_id(), GNUNET_TESTBED_host_replace_cfg_(), GNUNET_TESTBED_run(), GNUNET_TESTING_peer_configure(), GST_connection_pool_get_handle(), handle_autoconfig_request(), run(), set_cont(), and testbed_run().

780 {
782 
785  return ret;
786 }
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create()
Create a GNUNET_CONFIGURATION_Handle.
static void copy_entry(void *cls, const char *section, const char *option, const char *value)
Copy a configuration value to the given target configuration.
configuration data
Definition: configuration.c:84
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 208 of file configuration.c.

References GNUNET_CONFIGURATION_remove_section(), GNUNET_free, ConfigSection::name, and GNUNET_CONFIGURATION_Handle::sections.

Referenced by associate_shared_service(), auto_config_cb(), clean_node(), cleanup(), cleanup_prc(), conclude_autoconfig_request(), controller_status_cb(), create_unique_cfgs(), destroy_pooled_connection(), do_shutdown(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_solvers_experimentation_stop(), GNUNET_ATS_TEST_experimentation_load(), GNUNET_CONFIGURATION_parse_and_run(), GNUNET_CONFIGURATION_write_diffs(), GNUNET_CRYPTO_eddsa_setup_key(), GNUNET_NAT_autoconfig_cancel(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTBED_barrier_wait_cancel(), GNUNET_TESTBED_controller_disconnect(), GNUNET_TESTBED_host_destroy(), GNUNET_TESTBED_host_replace_cfg_(), GNUNET_TESTBED_run(), GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_service_run(), GNUNET_TESTING_system_destroy(), GNUNET_TRANSPORT_TESTING_start_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop(), GST_destroy_peer(), GST_destroy_peers(), handle_add_host(), handle_auto_result(), handle_autoconfig_request(), handle_link_controllers_result(), helper_mst(), LEGACY_SERVICE_run(), main(), next_phase(), oprelease_get_slave_config(), oprelease_peer_getinfo(), oprelease_service_connect(), run(), shutdown_task(), tokenizer_cb(), and update_peer_config().

209 {
210  struct ConfigSection *sec;
211 
212  while (NULL != (sec = cfg->sections))
214  GNUNET_free (cfg);
215 }
char * name
name of the section
Definition: configuration.c:77
void GNUNET_CONFIGURATION_remove_section(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Remove the given section and all options in it.
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:89
configuration section
Definition: configuration.c:62
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_load()

int 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
cfgconfiguration to update
filenamename of the configuration file, NULL to load defaults
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Load configuration.

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

Definition at line 42 of file configuration_loader.c.

References GNUNET_OS_ProjectData::base_config_varname, getenv(), GNUNET_asprintf(), GNUNET_CONFIGURATION_have_value(), GNUNET_CONFIGURATION_load_from(), GNUNET_CONFIGURATION_parse(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_DATADIR, GNUNET_OS_project_data_get(), GNUNET_strdup, GNUNET_SYSERR, and GNUNET_YES.

Referenced by auto_config_cb(), create_unique_cfgs(), gg_load_configuration(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_TEST_experimentation_load(), GNUNET_CONFIGURATION_parse_and_run(), GNUNET_CRYPTO_eddsa_setup_key(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_TESTBED_barrier_wait(), GNUNET_TESTING_service_run(), GNUNET_TRANSPORT_TESTING_start_peer(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), iter_check_config(), LEGACY_SERVICE_run(), main(), and run().

44 {
45  char *baseconfig;
46  const char *base_config_varname;
47 
48  base_config_varname = GNUNET_OS_project_data_get ()->base_config_varname;
49 
50  if (NULL != (baseconfig = getenv (base_config_varname)))
51  {
52  baseconfig = GNUNET_strdup (baseconfig);
53  }
54  else
55  {
56  char *ipath;
57 
59  if (NULL == ipath)
60  return GNUNET_SYSERR;
61  GNUNET_asprintf (&baseconfig, "%s%s", ipath, "config.d");
62  GNUNET_free (ipath);
63  }
64 
65  if (GNUNET_SYSERR ==
67  baseconfig))
68  {
69  GNUNET_free (baseconfig);
70  return GNUNET_SYSERR; /* no configuration at all found */
71  }
72  GNUNET_free (baseconfig);
73  if ((NULL != filename) &&
75  {
76  /* specified configuration not found */
77  return GNUNET_SYSERR;
78  }
79  if (((GNUNET_YES !=
80  GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) &&
81  (filename != NULL))
82  GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG",
83  filename);
84  return GNUNET_OK;
85 }
int 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...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
int 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.
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation directory.
static char * filename
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.
int GNUNET_CONFIGURATION_load_from(struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
Load default configuration.
char * getenv()
const char * base_config_varname
Name of an environment variable that can be used to override the location from which default configur...
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
Return the directory where data is installed (share/gnunet/)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_load_from()

int 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

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 1803 of file configuration.c.

References GNUNET_DISK_directory_scan(), GNUNET_OK, GNUNET_SYSERR, and parse_configuration_file().

Referenced by GNUNET_CONFIGURATION_load().

1805 {
1806  if (GNUNET_SYSERR ==
1808  return GNUNET_SYSERR; /* no configuration at all found */
1809  return GNUNET_OK;
1810 }
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition: disk.c:911
static int parse_configuration_file(void *cls, const char *filename)
Wrapper around GNUNET_CONFIGURATION_parse.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_parse()

int 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 423 of file configuration.c.

References _, GNUNET_CONFIGURATION_Handle::dirty, fn, fs, GNUNET_break, GNUNET_CONFIGURATION_deserialize(), GNUNET_DISK_file_size(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, GNUNET_YES, LOG, ret, and SIZE_MAX.

Referenced by GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_load(), parse_configuration_file(), and run().

425 {
426  uint64_t fs64;
427  size_t fs;
428  char *fn;
429  char *mem;
430  char *endsep;
431  int dirty;
432  int ret;
433  ssize_t sret;
434 
436  LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to parse config file `%s'\n", fn);
437  if (NULL == fn)
438  return GNUNET_SYSERR;
439  dirty = cfg->dirty; /* back up value! */
440  if (GNUNET_SYSERR ==
442  {
444  "Error while determining the file size of `%s'\n",
445  fn);
446  GNUNET_free (fn);
447  return GNUNET_SYSERR;
448  }
449  if (fs64 > SIZE_MAX)
450  {
451  GNUNET_break (0); /* File size is more than the heap size */
452  GNUNET_free (fn);
453  return GNUNET_SYSERR;
454  }
455  fs = fs64;
456  mem = GNUNET_malloc (fs);
457  sret = GNUNET_DISK_fn_read (fn, mem, fs);
458  if ((sret < 0) || (fs != (size_t) sret))
459  {
460  LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Error while reading file `%s'\n"), fn);
461  GNUNET_free (fn);
462  GNUNET_free (mem);
463  return GNUNET_SYSERR;
464  }
465  LOG (GNUNET_ERROR_TYPE_DEBUG, "Deserializing contents of file `%s'\n", fn);
466  endsep = strrchr (fn, (int) '/');
467  if (NULL != endsep)
468  *endsep = '\0';
469  ret = GNUNET_CONFIGURATION_deserialize (cfg, mem, fs, fn);
470  GNUNET_free (fn);
471  GNUNET_free (mem);
472  /* restore dirty flag - anything we set in the meantime
473  * came from disk */
474  cfg->dirty = dirty;
475  return ret;
476 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:96
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define SIZE_MAX
Definition: platform.h:220
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
static char * fn
Filename of the unique file.
static char * filename
#define LOG(kind,...)
Definition: configuration.c:32
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:617
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
int 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:257
int GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
De-serializes configuration.
#define GNUNET_malloc(size)
Wrapper around malloc.
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:794
#define GNUNET_free(ptr)
Wrapper around free.
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 502 of file configuration.c.

References ConfigSection::entries, GNUNET_asprintf(), GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, ConfigEntry::key, len, ConfigSection::name, ConfigEntry::next, ConfigSection::next, GNUNET_CONFIGURATION_Handle::sections, and ConfigEntry::val.

Referenced by conclude_autoconfig_request(), GNUNET_CONFIGURATION_write(), GNUNET_NAT_AUTO_autoconfig_start(), GNUNET_TESTBED_compress_cfg_(), GNUNET_TESTBED_create_helper_init_msg_(), GNUNET_TESTBED_peer_update_configuration(), GNUNET_TESTBED_register_host(), handle_peer_get_config(), handle_slave_get_config(), opstart_peer_create(), and tokenizer_cb().

504 {
505  struct ConfigSection *sec;
506  struct ConfigEntry *ent;
507  char *mem;
508  char *cbuf;
509  char *val;
510  char *pos;
511  size_t m_size;
512  size_t c_size;
513 
514  /* Pass1 : calculate the buffer size required */
515  m_size = 0;
516  for (sec = cfg->sections; NULL != sec; sec = sec->next)
517  {
518  /* For each section we need to add 3 charaters: {'[',']','\n'} */
519  m_size += strlen (sec->name) + 3;
520  for (ent = sec->entries; NULL != ent; ent = ent->next)
521  {
522  if (NULL != ent->val)
523  {
524  /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */
525  pos = ent->val;
526  while (NULL != (pos = strstr (pos, "\n")))
527  {
528  m_size++;
529  pos++;
530  }
531  /* For each key = value pair we need to add 4 characters (2
532  spaces and 1 equal-to character and 1 new line) */
533  m_size += strlen (ent->key) + strlen (ent->val) + 4;
534  }
535  }
536  /* A new line after section end */
537  m_size++;
538  }
539 
540  /* Pass2: Allocate memory and write the configuration to it */
541  mem = GNUNET_malloc (m_size);
542  sec = cfg->sections;
543  c_size = 0;
544  *size = c_size;
545  while (NULL != sec)
546  {
547  int len;
548 
549  len = GNUNET_asprintf (&cbuf, "[%s]\n", sec->name);
550  GNUNET_assert (0 < len);
551  GNUNET_memcpy (mem + c_size, cbuf, len);
552  c_size += len;
553  GNUNET_free (cbuf);
554  for (ent = sec->entries; NULL != ent; ent = ent->next)
555  {
556  if (NULL != ent->val)
557  {
558  val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
559  strcpy (val, ent->val);
560  while (NULL != (pos = strstr (val, "\n")))
561  {
562  memmove (&pos[2], &pos[1], strlen (&pos[1]));
563  pos[0] = '\\';
564  pos[1] = 'n';
565  }
566  len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val);
567  GNUNET_free (val);
568  GNUNET_memcpy (mem + c_size, cbuf, len);
569  c_size += len;
570  GNUNET_free (cbuf);
571  }
572  }
573  GNUNET_memcpy (mem + c_size, "\n", 1);
574  c_size++;
575  sec = sec->next;
576  }
577  GNUNET_assert (c_size == m_size);
578  *size = c_size;
579  return mem;
580 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:72
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
configuration entry
Definition: configuration.c:40
char * name
name of the section
Definition: configuration.c:77
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:89
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:45
configuration section
Definition: configuration.c:62
char * key
key for this entry
Definition: configuration.c:50
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:67
#define GNUNET_malloc(size)
Wrapper around malloc.
char * val
current, commited value
Definition: configuration.c:55
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_deserialize()

int GNUNET_CONFIGURATION_deserialize ( struct GNUNET_CONFIGURATION_Handle cfg,
const char *  mem,
size_t  size,
const char *  basedir 
)

De-serializes configuration.

Parameters
cfgconfiguration to update
memthe memory block of serialized configuration
sizethe size of the memory block
allow_inlineset to the base directory if we recursively load configuration from inlined configurations; NULL if not and raise warnings when we come across them
Returns
GNUNET_OK on success, GNUNET_SYSERR on error
Parameters
cfgconfiguration to update
memthe memory block of serialized configuration
sizethe size of the memory block
basedirset to path from which we recursively load configuration from inlined configurations; NULL if not and raise warnings when we come across them
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 262 of file configuration.c.

References _, fn, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_parse(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_strndup, GNUNET_SYSERR, GNUNET_YES, line, LOG, ret, section, and value.

Referenced by GNUNET_CONFIGURATION_parse(), GNUNET_TESTBED_extract_config_(), handle_auto_result(), handle_autoconfig_request(), helper_mst(), and tokenizer_cb().

266 {
267  char *line;
268  char *line_orig;
269  size_t line_size;
270  char *pos;
271  unsigned int nr;
272  size_t r_bytes;
273  size_t to_read;
274  size_t i;
275  int emptyline;
276  int ret;
277  char *section;
278  char *eq;
279  char *tag;
280  char *value;
281 
282  ret = GNUNET_OK;
283  section = GNUNET_strdup ("");
284  nr = 0;
285  r_bytes = 0;
286  line_orig = NULL;
287  while (r_bytes < size)
288  {
289  GNUNET_free (line_orig);
290  /* fgets-like behaviour on buffer */
291  to_read = size - r_bytes;
292  pos = memchr (&mem[r_bytes], '\n', to_read);
293  if (NULL == pos)
294  {
295  line_orig = GNUNET_strndup (&mem[r_bytes], line_size = to_read);
296  r_bytes += line_size;
297  }
298  else
299  {
300  line_orig =
301  GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes]));
302  r_bytes += line_size + 1;
303  }
304  line = line_orig;
305  /* increment line number */
306  nr++;
307  /* tabs and '\r' are whitespace */
308  emptyline = GNUNET_YES;
309  for (i = 0; i < line_size; i++)
310  {
311  if (line[i] == '\t')
312  line[i] = ' ';
313  if (line[i] == '\r')
314  line[i] = ' ';
315  if (' ' != line[i])
316  emptyline = GNUNET_NO;
317  }
318  /* ignore empty lines */
319  if (GNUNET_YES == emptyline)
320  continue;
321 
322  /* remove tailing whitespace */
323  for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i]));
324  i--)
325  line[i] = '\0';
326 
327  /* remove leading whitespace */
328  for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++)
329  ;
330 
331  /* ignore comments */
332  if (('#' == line[0]) || ('%' == line[0]))
333  continue;
334 
335  /* handle special "@INLINE@" directive */
336  if (0 == strncasecmp (line, "@INLINE@ ", strlen ("@INLINE@ ")))
337  {
338  /* @INLINE@ value */
339  value = &line[strlen ("@INLINE@ ")];
340  if (NULL != basedir)
341  {
342  char *fn;
343 
344  GNUNET_asprintf (&fn, "%s/%s", basedir, value);
345  if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, fn))
346  {
347  GNUNET_free (fn);
348  ret = GNUNET_SYSERR; /* failed to parse included config */
349  break;
350  }
351  GNUNET_free (fn);
352  }
353  else
354  {
356  "Ignoring parsing @INLINE@ configurations, not allowed!\n");
357  ret = GNUNET_SYSERR;
358  break;
359  }
360  continue;
361  }
362  if (('[' == line[0]) && (']' == line[line_size - 1]))
363  {
364  /* [value] */
365  line[line_size - 1] = '\0';
366  value = &line[1];
367  GNUNET_free (section);
368  section = GNUNET_strdup (value);
369  continue;
370  }
371  if (NULL != (eq = strchr (line, '=')))
372  {
373  /* tag = value */
374  tag = GNUNET_strndup (line, eq - line);
375  /* remove tailing whitespace */
376  for (i = strlen (tag) - 1; (i >= 1) && (isspace ((unsigned char) tag[i]));
377  i--)
378  tag[i] = '\0';
379 
380  /* Strip whitespace */
381  value = eq + 1;
382  while (isspace ((unsigned char) value[0]))
383  value++;
384  for (i = strlen (value) - 1;
385  (i >= 1) && (isspace ((unsigned char) value[i]));
386  i--)
387  value[i] = '\0';
388 
389  /* remove quotes */
390  i = 0;
391  if (('"' == value[0]) && ('"' == value[strlen (value) - 1]))
392  {
393  value[strlen (value) - 1] = '\0';
394  value++;
395  }
396  GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]);
397  GNUNET_free (tag);
398  continue;
399  }
400  /* parse error */
402  _ ("Syntax error while deserializing in line %u\n"),
403  nr);
404  ret = GNUNET_SYSERR;
405  break;
406  }
407  GNUNET_free (line_orig);
408  GNUNET_free (section);
409  GNUNET_assert ((GNUNET_OK != ret) || (r_bytes == size));
410  return ret;
411 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
int 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...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
static char * section
Name of the section.
Definition: gnunet-config.c:33
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char * line
Desired phone line (string to be converted to a hash).
static char * value
Value of the record to add/remove.
static char * fn
Filename of the unique file.
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 LOG(kind,...)
Definition: configuration.c:32
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_write()

int 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 591 of file configuration.c.

References GNUNET_CONFIGURATION_Handle::dirty, fn, GNUNET_CONFIGURATION_serialize(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_fn_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_NO, GNUNET_OK, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, LOG, and size.

Referenced by associate_shared_service(), create_unique_cfgs(), GNUNET_CONFIGURATION_write_diffs(), GNUNET_TESTING_peer_configure(), handle_delete_message(), handle_rename_message(), handle_set_default_message(), run(), set_cont(), testing_main(), and tokenizer_cb().

593 {
594  char *fn;
595  char *cfg_buf;
596  size_t size;
597  ssize_t sret;
598 
600  if (fn == NULL)
601  return GNUNET_SYSERR;
603  {
604  GNUNET_free (fn);
605  return GNUNET_SYSERR;
606  }
607  cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size);
608  sret = GNUNET_DISK_fn_write (fn,
609  cfg_buf,
610  size,
615  if ((sret < 0) || (size != (size_t) sret))
616  {
617  GNUNET_free (fn);
618  GNUNET_free (cfg_buf);
620  "Writing configuration to file `%s' failed\n",
621  filename);
622  cfg->dirty = GNUNET_SYSERR; /* last write failed */
623  return GNUNET_SYSERR;
624  }
625  GNUNET_free (fn);
626  GNUNET_free (cfg_buf);
627  cfg->dirty = GNUNET_NO; /* last write succeeded */
628  return GNUNET_OK;
629 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:96
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:684
ssize_t GNUNET_DISK_fn_write(const char *fn, const void *buffer, size_t n, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file.
Definition: disk.c:879
static char * fn
Filename of the unique file.
static char * filename
#define LOG(kind,...)
Definition: configuration.c:32
static unsigned int size
Size of the "table".
Definition: peer.c:67
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:617
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_write_diffs()

int 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 891 of file configuration.c.

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

Referenced by auto_config_cb(), and main().

895 {
896  int ret;
897  struct GNUNET_CONFIGURATION_Handle *diff;
898 
899  diff = GNUNET_CONFIGURATION_get_diff (cfg_default, cfg_new);
900  ret = GNUNET_CONFIGURATION_write (diff, filename);
902  return ret;
903 }
int GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
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.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static char * filename
configuration data
Definition: configuration.c:84
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 869 of file configuration.c.

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

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

872 {
873  struct DiffHandle diffHandle;
874 
875  diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
876  diffHandle.cfg_default = cfg_default;
877  GNUNET_CONFIGURATION_iterate (cfg_new, &compare_entries, &diffHandle);
878  return diffHandle.cfgDiff;
879 }
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create()
Create a GNUNET_CONFIGURATION_Handle.
struct GNUNET_CONFIGURATION_Handle * cfgDiff
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_is_dirty()

int 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 487 of file configuration.c.

References GNUNET_CONFIGURATION_Handle::dirty.

Referenced by auto_config_cb().

488 {
489  return cfg->dirty;
490 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:96
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_parse_and_run()

int GNUNET_CONFIGURATION_parse_and_run ( 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
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 230 of file configuration.c.

References cfg, GNUNET_break, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_load(), GNUNET_OK, GNUNET_SYSERR, and ret.

Referenced by GNUNET_DISK_purge_cfg_dir().

233 {
235  int ret;
236 
239  {
240  GNUNET_break (0);
242  return GNUNET_SYSERR;
243  }
244  ret = cb (cb_cls, cfg);
246  return ret;
247 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create()
Create a GNUNET_CONFIGURATION_Handle.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static char * filename
configuration data
Definition: configuration.c:84
Here is the call graph for this function:
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 640 of file configuration.c.

References ConfigSection::entries, ConfigEntry::key, ConfigSection::name, ConfigEntry::next, ConfigSection::next, GNUNET_CONFIGURATION_Handle::sections, and ConfigEntry::val.

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

643 {
644  struct ConfigSection *spos;
645  struct ConfigEntry *epos;
646 
647  for (spos = cfg->sections; NULL != spos; spos = spos->next)
648  for (epos = spos->entries; NULL != epos; epos = epos->next)
649  if (NULL != epos->val)
650  iter (iter_cls, spos->name, epos->key, epos->val);
651 }
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:72
configuration entry
Definition: configuration.c:40
char * name
name of the section
Definition: configuration.c:77
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:89
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:45
configuration section
Definition: configuration.c:62
char * key
key for this entry
Definition: configuration.c:50
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:67
char * val
current, commited value
Definition: configuration.c:55
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_Section_Iterator  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 691 of file configuration.c.

References ConfigSection::name, ConfigEntry::next, ConfigSection::next, and GNUNET_CONFIGURATION_Handle::sections.

Referenced by GNUNET_TESTING_configuration_create_(), handle_delete_message(), handle_rename_message(), and run().

695 {
696  struct ConfigSection *spos;
697  struct ConfigSection *next;
698 
699  next = cfg->sections;
700  while (next != NULL)
701  {
702  spos = next;
703  next = spos->next;
704  iter (iter_cls, spos->name);
705  }
706 }
char * name
name of the section
Definition: configuration.c:77
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:89
configuration section
Definition: configuration.c:62
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:67
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 716 of file configuration.c.

References GNUNET_CONFIGURATION_Handle::dirty, ConfigSection::entries, GNUNET_free, GNUNET_YES, ConfigEntry::key, ConfigSection::name, ConfigEntry::next, ConfigSection::next, GNUNET_CONFIGURATION_Handle::sections, and ConfigEntry::val.

Referenced by GNUNET_CONFIGURATION_destroy(), and GNUNET_TESTING_peer_configure().

718 {
719  struct ConfigSection *spos;
720  struct ConfigSection *prev;
721  struct ConfigEntry *ent;
722 
723  prev = NULL;
724  spos = cfg->sections;
725  while (NULL != spos)
726  {
727  if (0 == strcasecmp (section, spos->name))
728  {
729  if (NULL == prev)
730  cfg->sections = spos->next;
731  else
732  prev->next = spos->next;
733  while (NULL != (ent = spos->entries))
734  {
735  spos->entries = ent->next;
736  GNUNET_free (ent->key);
737  GNUNET_free (ent->val);
738  GNUNET_free (ent);
739  cfg->dirty = GNUNET_YES;
740  }
741  GNUNET_free (spos->name);
742  GNUNET_free (spos);
743  return;
744  }
745  prev = spos;
746  spos = spos->next;
747  }
748 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:96
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:72
configuration entry
Definition: configuration.c:40
static char * section
Name of the section.
Definition: gnunet-config.c:33
char * name
name of the section
Definition: configuration.c:77
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:89
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:45
configuration section
Definition: configuration.c:62
char * key
key for this entry
Definition: configuration.c:50
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:67
char * val
current, commited value
Definition: configuration.c:55
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_number()

int 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_SYSERR on error

Definition at line 987 of file configuration.c.

References dummy, e, find_entry(), GNUNET_OK, GNUNET_SYSERR, and ConfigEntry::val.

Referenced by client_configure_plugin(), event_cb(), GCD_init(), GCO_init(), GDS_NEIGHBOURS_init(), GDS_NSE_init(), get_server_addresses(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_solvers_load_quotas(), GNUNET_ATS_TEST_experimentation_load(), 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_TESTBED_controller_connect(), GNUNET_TESTBED_run(), GNUNET_TRANSPORT_communicator_connect(), GSF_cadet_start_server(), GSF_pending_request_init_(), GST_plugins_load(), iopen(), LEGACY_SERVICE_get_server_addresses(), LEGACY_SERVICE_run(), libgnunet_plugin_block_revocation_init(), libgnunet_plugin_datastore_heap_init(), LIBGNUNET_PLUGIN_TRANSPORT_INIT(), libgnunet_plugin_transport_tcp_init(), libgnunet_plugin_transport_udp_init(), load_episode(), load_op_add_address(), load_op_del_address(), load_op_start_request(), load_op_start_set_preference(), load_op_start_set_property(), load_op_stop_request(), load_op_stop_set_preference(), load_op_stop_set_property(), run(), server_configure_plugin(), server_get_addresses(), setup_exit_helper_args(), test_service_configuration(), test_stun(), testbed_run(), and update_config().

992 {
993  struct ConfigEntry *e;
994  char dummy[2];
995 
996  if (NULL == (e = find_entry (cfg, section, option)))
997  return GNUNET_SYSERR;
998  if (NULL == e->val)
999  return GNUNET_SYSERR;
1000  if (1 != sscanf (e->val, "%llu%1s", number, dummy))
1001  return GNUNET_SYSERR;
1002  return GNUNET_OK;
1003 }
static struct Experiment * e
configuration entry
Definition: configuration.c:40
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
uint32_t number
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_float()

int 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_SYSERR on error

Definition at line 1016 of file configuration.c.

References dummy, e, find_entry(), GNUNET_OK, GNUNET_SYSERR, and ConfigEntry::val.

Referenced by GNUNET_RPS_connect(), and libgnunet_plugin_ats_proportional_init().

1021 {
1022  struct ConfigEntry *e;
1023  char dummy[2];
1024 
1025  if (NULL == (e = find_entry (cfg, section, option)))
1026  return GNUNET_SYSERR;
1027  if (NULL == e->val)
1028  return GNUNET_SYSERR;
1029  if (1 != sscanf (e->val, "%f%1s", number, dummy))
1030  return GNUNET_SYSERR;
1031  return GNUNET_OK;
1032 }
static struct Experiment * e
configuration entry
Definition: configuration.c:40
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
uint32_t number
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_time()

int 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_SYSERR on error

Definition at line 1045 of file configuration.c.

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

Referenced by GCD_init(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_TEST_experimentation_load(), GNUNET_REVOCATION_revoke(), GNUNET_SPEEDUP_start_(), GNUNET_TESTBED_run(), GSF_push_init_(), GST_manipulation_init(), libgnunet_plugin_block_revocation_init(), libgnunet_plugin_transport_tcp_init(), libgnunet_plugin_transport_udp_init(), load_episode(), load_episodes(), load_op_start_set_preference(), load_op_start_set_property(), RECLAIM_TICKETS_init(), run(), setup_service(), testbed_run(), and token_endpoint().

1050 {
1051  struct ConfigEntry *e;
1052  int ret;
1053 
1054  if (NULL == (e = find_entry (cfg, section, option)))
1055  return GNUNET_SYSERR;
1056  if (NULL == e->val)
1057  return GNUNET_SYSERR;
1058  ret = GNUNET_STRINGS_fancy_time_to_relative (e->val, time);
1059  if (GNUNET_OK != ret)
1061  section,
1062  option,
1063  _ ("Not a valid relative time specification"));
1064  return ret;
1065 }
int 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:355
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct Experiment * e
configuration entry
Definition: configuration.c:40
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.
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_size()

int 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_SYSERR on error

Definition at line 1078 of file configuration.c.

References e, find_entry(), GNUNET_STRINGS_fancy_size_to_bytes(), GNUNET_SYSERR, and ConfigEntry::val.

Referenced by GNUNET_DATACACHE_create(), and run().

1083 {
1084  struct ConfigEntry *e;
1085 
1086  if (NULL == (e = find_entry (cfg, section, option)))
1087  return GNUNET_SYSERR;
1088  if (NULL == e->val)
1089  return GNUNET_SYSERR;
1091 }
static struct Experiment * e
int 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:323
configuration entry
Definition: configuration.c:40
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
static unsigned int size
Size of the "table".
Definition: peer.c:67
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_have_value()

int 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 1219 of file configuration.c.

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

Referenced by check_config(), GDS_NSE_init(), get_my_cnf_path(), get_server_addresses(), GNUNET_CLIENT_connect(), GNUNET_CLIENT_test(), GNUNET_CONFIGURATION_load(), GNUNET_HOSTLIST_server_start(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), GNUNET_SOCKS_check_service(), GNUNET_TESTBED_run(), GNUNET_TESTING_peer_configure(), iopen(), LEGACY_SERVICE_get_server_addresses(), LEGACY_SERVICE_run(), LEGACY_SERVICE_stop(), LIBGNUNET_PLUGIN_TRANSPORT_INIT(), process_acl4(), process_acl6(), server_configure_plugin(), server_get_addresses(), setup_service(), start_arm_service(), test_service_configuration(), and update_config_sections().

1222 {
1223  struct ConfigEntry *e;
1224 
1225  if ((NULL == (e = find_entry (cfg, section, option))) || (NULL == e->val))
1226  return GNUNET_NO;
1227  return GNUNET_YES;
1228 }
static struct Experiment * e
configuration entry
Definition: configuration.c:40
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_string()

int 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_SYSERR on error

Definition at line 1105 of file configuration.c.

References e, find_entry(), GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, and ConfigEntry::val.

Referenced by advertise_dns_exit(), check_authorization(), check_config(), client_configure_plugin(), expand_dollar(), GAS_plugin_init(), get_bootstrap_server(), get_server_addresses(), gg_load_configuration(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_solvers_load_quotas(), GNUNET_ATS_TEST_experimentation_load(), GNUNET_CLIENT_connect(), GNUNET_CLIENT_test(), GNUNET_CONFIGURATION_append_value_filename(), GNUNET_CONFIGURATION_get_data(), 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_OS_get_suid_binary_path(), GNUNET_PQ_connect_with_cfg(), GNUNET_SERVICE_run_(), GNUNET_SOCKS_do_connect(), GNUNET_TESTBED_run(), GNUNET_TESTING_peer_configure(), GNUNET_TESTING_service_run(), gnunet_uri(), GPI_plugins_load(), GST_plugins_load(), handle_ego_delete(), handle_ego_rename(), handle_get_default_message(), handle_init(), handle_register(), identity_continuation(), iopen(), LEGACY_SERVICE_get_server_addresses(), LEGACY_SERVICE_run(), LEGACY_SERVICE_stop(), LIBGNUNET_PLUGIN_TRANSPORT_INIT(), libgnunet_plugin_transport_udp_init(), load_episode(), load_op_add_address(), load_op_del_address(), load_op_start_set_preference(), load_op_start_set_property(), load_op_stop_set_preference(), load_op_stop_set_property(), load_quota(), login_redirect(), print_quotas(), process_acl4(), process_acl6(), read_service_conf(), run(), server_configure_plugin(), server_get_addresses(), server_log(), set_result_cb(), setup_exit_helper_args(), setup_service(), start_arm_service(), start_process(), test_icmp_client(), test_icmp_server(), test_service_configuration(), testbed_run(), token_endpoint(), and update_config_sections().

1110 {
1111  struct ConfigEntry *e;
1112 
1113  if ((NULL == (e = find_entry (cfg, section, option))) || (NULL == e->val))
1114  {
1115  *value = NULL;
1116  return GNUNET_SYSERR;
1117  }
1118  *value = GNUNET_strdup (e->val);
1119  return GNUNET_OK;
1120 }
static struct Experiment * e
configuration entry
Definition: configuration.c:40
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.c:38
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:

◆ GNUNET_CONFIGURATION_get_value_filename()

int 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_SYSERR on error

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_SYSERR on error

Definition at line 1445 of file configuration.c.

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

Referenced by database_setup(), get_my_cnf_path(), get_pid_file_name(), get_serialization_file_name(), get_serialization_file_name_in_dir(), get_server_addresses(), get_update_information_directory(), get_user_name(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_ATS_TEST_experimentation_load(), GNUNET_CLIENT_test(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_FRIENDS_parse(), GNUNET_FRIENDS_write_start(), GNUNET_HOSTLIST_client_start(), GNUNET_PQ_connect_with_cfg(), GNUNET_TESTBED_controller_start(), GNUNET_TESTBED_is_host_habitable(), GNUNET_TESTBED_run(), GNUNET_TESTING_peer_configure(), GNUNET_TIME_absolute_get_monotonic(), GST_stats_init(), LEGACY_SERVICE_get_server_addresses(), libgnunet_plugin_transport_unix_init(), load(), load_hostlist_file(), logger_run(), main_init(), new_sub(), print_option(), purge_cfg_dir(), read_index_list(), run(), save(), save_hostlist_file(), server_log(), setup_service(), start_arm_service(), test_service_configuration(), testbed_run(), tokenizer_cb(), try_unixpath(), write_index_list(), and write_proof().

1450 {
1451  char *tmp;
1452 
1453  if (GNUNET_OK !=
1455  {
1456  LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to retrieve filename\n");
1457  *value = NULL;
1458  return GNUNET_SYSERR;
1459  }
1460  tmp = GNUNET_CONFIGURATION_expand_dollar (cfg, tmp);
1462  GNUNET_free (tmp);
1463  if (*value == NULL)
1464  return GNUNET_SYSERR;
1465  return GNUNET_OK;
1466 }
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...
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.c:38
#define LOG(kind,...)
Definition: configuration.c:32
int 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_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:617
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller 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 1509 of file configuration.c.

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

Referenced by GNUNET_CONFIGURATION_append_value_filename().

1515 {
1516  char *list;
1517  char *pos;
1518  char *end;
1519  char old;
1520  int ret;
1521 
1522  if (GNUNET_OK !=
1524  return 0;
1525  GNUNET_assert (list != NULL);
1526  ret = 0;
1527  pos = list;
1528  while (1)
1529  {
1530  while (pos[0] == ' ')
1531  pos++;
1532  if (strlen (pos) == 0)
1533  break;
1534  end = pos + 1;
1535  while ((end[0] != ' ') && (end[0] != '\0'))
1536  {
1537  if (end[0] == '\\')
1538  {
1539  switch (end[1])
1540  {
1541  case '\\':
1542  case ' ':
1543  memmove (end, &end[1], strlen (&end[1]) + 1);
1544 
1545  case '\0':
1546  /* illegal, but just keep it */
1547  break;
1548 
1549  default:
1550  /* illegal, but just ignore that there was a '/' */
1551  break;
1552  }
1553  }
1554  end++;
1555  }
1556  old = end[0];
1557  end[0] = '\0';
1558  if (strlen (pos) > 0)
1559  {
1560  ret++;
1561  if ((cb != NULL) && (GNUNET_OK != cb (cb_cls, pos)))
1562  {
1563  ret = GNUNET_SYSERR;
1564  break;
1565  }
1566  }
1567  if (old == '\0')
1568  break;
1569  pos = end + 1;
1570  }
1571  GNUNET_free (list);
1572  return ret;
1573 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
int 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.
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:69
#define GNUNET_free(ptr)
Wrapper around free.
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 663 of file configuration.c.

References ConfigSection::entries, ConfigEntry::key, ConfigSection::name, ConfigEntry::next, ConfigSection::next, GNUNET_CONFIGURATION_Handle::sections, and ConfigEntry::val.

Referenced by associate_shared_service(), authorize_endpoint(), auto_config_cb(), get_cont(), GNUNET_TESTING_system_create_with_portrange(), read_blacklist_configuration(), and run().

668 {
669  struct ConfigSection *spos;
670  struct ConfigEntry *epos;
671 
672  spos = cfg->sections;
673  while ((spos != NULL) && (0 != strcasecmp (spos->name, section)))
674  spos = spos->next;
675  if (NULL == spos)
676  return;
677  for (epos = spos->entries; NULL != epos; epos = epos->next)
678  if (NULL != epos->val)
679  iter (iter_cls, spos->name, epos->key, epos->val);
680 }
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:72
configuration entry
Definition: configuration.c:40
static char * section
Name of the section.
Definition: gnunet-config.c:33
char * name
name of the section
Definition: configuration.c:77
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:89
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:45
configuration section
Definition: configuration.c:62
char * key
key for this entry
Definition: configuration.c:50
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:67
char * val
current, commited value
Definition: configuration.c:55
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_choice()

int 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_SYSERR on error

Definition at line 1136 of file configuration.c.

References _, e, find_entry(), GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SYSERR, LOG, and ConfigEntry::val.

Referenced by GNUNET_CONFIGURATION_get_value_yesno(), and start_process().

1142 {
1143  struct ConfigEntry *e;
1144  unsigned int i;
1145 
1146  if (NULL == (e = find_entry (cfg, section, option)))
1147  return GNUNET_SYSERR;
1148  for (i = 0; NULL != choices[i]; i++)
1149  if (0 == strcasecmp (choices[i], e->val))
1150  break;
1151  if (NULL == choices[i])
1152  {
1154  _ ("Configuration value '%s' for '%s'"
1155  " in section '%s' is not in set of legal choices\n"),
1156  e->val,
1157  option,
1158  section);
1159  return GNUNET_SYSERR;
1160  }
1161  *value = choices[i];
1162  return GNUNET_OK;
1163 }
static struct Experiment * e
configuration entry
Definition: configuration.c:40
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.c:38
#define LOG(kind,...)
Definition: configuration.c:32
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_value_yesno()

int 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_YES, GNUNET_NO or if option has no valid value, GNUNET_SYSERR
Parameters
cfgconfiguration to inspect
sectionsection of interest
optionoption of interest
Returns
GNUNET_YES, GNUNET_NO or GNUNET_SYSERR

Definition at line 1479 of file configuration.c.

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

Referenced by advertise_dns_exit(), client_configure_plugin(), create_listen_socket(), database_setup(), GDS_NEIGHBOURS_init(), get_server_addresses(), gg_load_configuration(), GNS_resolver_init(), GNUNET_ATS_solvers_experimentation_load(), GNUNET_CONNECTION_create_from_connect_to_unixpath(), GNUNET_DATACACHE_create(), GNUNET_STATISTICS_create(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), GSF_pending_request_init_(), GSF_push_init_(), LEGACY_SERVICE_get_server_addresses(), libgnunet_plugin_datacache_sqlite_init(), libgnunet_plugin_transport_http_server_init(), libgnunet_plugin_transport_tcp_init(), libgnunet_plugin_transport_udp_init(), libgnunet_plugin_transport_unix_init(), main_init(), parse_ip_options(), run(), server_configure_plugin(), setup_broadcast(), setup_service(), sign_ephemeral_key(), start_arm_service(), start_process(), tcp_address_to_sockaddr_port_only(), test_icmp_client(), test_icmp_server(), test_master(), udp_address_to_sockaddr(), and update_config().

1483 {
1484  static const char *yesno[] = { "YES", "NO", NULL };
1485  const char *val;
1486  int ret;
1487 
1488  ret =
1490  if (ret == GNUNET_SYSERR)
1491  return ret;
1492  if (val == yesno[0])
1493  return GNUNET_YES;
1494  return GNUNET_NO;
1495 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
int 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.
char * val
current, commited value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_get_data()

int 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

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 1179 of file configuration.c.

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

1184 {
1185  char *enc;
1186  int res;
1187  size_t data_size;
1188 
1189  if (GNUNET_OK !=
1190  (res =
1192  return res;
1193  data_size = (strlen (enc) * 5) / 8;
1194  if (data_size != buf_size)
1195  {
1196  GNUNET_free (enc);
1197  return GNUNET_SYSERR;
1198  }
1199  if (GNUNET_OK !=
1200  GNUNET_STRINGS_string_to_data (enc, strlen (enc), buf, buf_size))
1201  {
1202  GNUNET_free (enc);
1203  return GNUNET_SYSERR;
1204  }
1205  GNUNET_free (enc);
1206  return GNUNET_OK;
1207 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
static char buf[2048]
static int res
int 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.
static OpusEncoder * enc
OPUS encoder.
int 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:970
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call 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 environtment "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

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 1410 of file configuration.c.

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

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

1413 {
1414  char *dup;
1415  size_t i;
1416  size_t len;
1417 
1418  for (i = 0; '\0' != orig[i]; i++)
1419  {
1420  if ('$' != orig[i])
1421  continue;
1422  dup = GNUNET_strdup (orig + i);
1423  dup = expand_dollar (cfg, dup, 0);
1424  GNUNET_assert (NULL != dup); /* make compiler happy */
1425  len = strlen (dup) + 1;
1426  orig = GNUNET_realloc (orig, i + len);
1427  GNUNET_memcpy (orig + i, dup, len);
1428  GNUNET_free (dup);
1429  }
1430  return orig;
1431 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
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_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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 965 of file configuration.c.

References GNUNET_CONFIGURATION_set_value_string(), and GNUNET_snprintf().

Referenced by handle_peer_create(), next_phase(), run(), and set_value().

969 {
970  char s[64];
971 
972  GNUNET_snprintf (s, 64, "%llu", number);
974 }
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
uint32_t number
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.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.
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 915 of file configuration.c.

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

Referenced by associate_shared_service(), auto_conf_iter(), auto_config_cb(), cfg_copy_iterator(), compare_entries(), copy_entry(), GNUNET_CONFIGURATION_append_value_filename(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_load(), GNUNET_CONFIGURATION_remove_value_filename(), GNUNET_CONFIGURATION_set_value_number(), GNUNET_NAT_autoconfig_start(), GNUNET_PROGRAM_run2(), GNUNET_TESTING_configuration_create_(), handle_ego_delete(), handle_ego_rename(), handle_set_default_message(), helper_mst(), identity_cb(), next_phase(), process_if(), result_callback(), run(), set_external_ipv4(), set_value(), test_local_ip(), test_upnpc(), update_config(), update_config_sections(), and update_enable_upnpc_option().

919 {
920  struct ConfigSection *sec;
921  struct ConfigEntry *e;
922  char *nv;
923 
924  e = find_entry (cfg, section, option);
925  if (NULL != e)
926  {
927  if (NULL == value)
928  {
929  GNUNET_free (e->val);
930  e->val = NULL;
931  }
932  else
933  {
934  nv = GNUNET_strdup (value);
935  GNUNET_free (e->val);
936  e->val = nv;
937  }
938  return;
939  }
940  sec = find_section (cfg, section);
941  if (sec == NULL)
942  {
943  sec = GNUNET_new (struct ConfigSection);
944  sec->name = GNUNET_strdup (section);
945  sec->next = cfg->sections;
946  cfg->sections = sec;
947  }
948  e = GNUNET_new (struct ConfigEntry);
949  e->key = GNUNET_strdup (option);
950  e->val = GNUNET_strdup (value);
951  e->next = sec->entries;
952  sec->entries = e;
953 }
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:72
static struct Experiment * e
configuration entry
Definition: configuration.c:40
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * section
Name of the section.
Definition: gnunet-config.c:33
char * name
name of the section
Definition: configuration.c:77
static struct ConfigSection * find_section(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Find a section entry from a configuration.
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.c:38
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:89
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:45
configuration section
Definition: configuration.c:62
char * key
key for this entry
Definition: configuration.c:50
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:67
char * val
current, commited value
Definition: configuration.c:55
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CONFIGURATION_remove_value_filename()

int 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
Parameters
cfgconfiguration to update
sectionsection of interest
optionoption of interest
valuefilename to remove
Returns
GNUNET_OK on success, GNUNET_NO if the filename is not in the list, GNUNET_SYSERR on error

Definition at line 1690 of file configuration.c.

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

1695 {
1696  char *list;
1697  char *pos;
1698  char *end;
1699  char *match;
1700  char old;
1701 
1702  if (GNUNET_OK !=
1704  return GNUNET_NO;
1705  match = escape_name (value);
1706  pos = list;
1707  while (1)
1708  {
1709  while (pos[0] == ' ')
1710  pos++;
1711  if (strlen (pos) == 0)
1712  break;
1713  end = pos + 1;
1714  while ((end[0] != ' ') && (end[0] != '\0'))
1715  {
1716  if (end[0] == '\\')
1717  {
1718  switch (end[1])
1719  {
1720  case '\\':
1721  case ' ':
1722  end++;
1723  break;
1724 
1725  case '\0':
1726  /* illegal, but just keep it */
1727  break;
1728 
1729  default:
1730  /* illegal, but just ignore that there was a '/' */
1731  break;
1732  }
1733  }
1734  end++;
1735  }
1736  old = end[0];
1737  end[0] = '\0';
1738  if (0 == strcmp (pos, match))
1739  {
1740  if (old != '\0')
1741  memmove (pos, &end[1], strlen (&end[1]) + 1);
1742  else
1743  {
1744  if (pos != list)
1745  pos[-1] = '\0';
1746  else
1747  pos[0] = '\0';
1748  }
1750  GNUNET_free (list);
1751  GNUNET_free (match);
1752  return GNUNET_OK;
1753  }
1754  if (old == '\0')
1755  break;
1756  end[0] = old;
1757  pos = end + 1;
1758  }
1759  GNUNET_free (list);
1760  GNUNET_free (match);
1761  return GNUNET_NO;
1762 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static char * escape_name(const char *value)
FIXME.
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.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.
int 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.
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:69
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_CONFIGURATION_append_value_filename()

int 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
Parameters
cfgconfiguration to update
sectionsection of interest
optionoption of interest
valuefilename to append
Returns
GNUNET_OK on success, GNUNET_NO if the filename already in the list GNUNET_SYSERR on error

Definition at line 1643 of file configuration.c.

References 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, and test_match().

1648 {
1649  char *escaped;
1650  char *old;
1651  char *nw;
1652 
1653  if (GNUNET_SYSERR ==
1655  section,
1656  option,
1657  &test_match,
1658  (void *) value))
1659  return GNUNET_NO; /* already exists */
1660  if (GNUNET_OK !=
1662  old = GNUNET_strdup ("");
1663  escaped = escape_name (value);
1664  nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2);
1665  strcpy (nw, old);
1666  if (strlen (old) > 0)
1667  strcat (nw, " ");
1668  strcat (nw, escaped);
1670  GNUNET_free (old);
1671  GNUNET_free (nw);
1672  GNUNET_free (escaped);
1673  return GNUNET_OK;
1674 }
static char * escape_name(const char *value)
FIXME.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * section
Name of the section.
Definition: gnunet-config.c:33
static int test_match(void *cls, const char *fn)
FIXME.
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.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.
int 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.
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.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function: