GNUnet  0.10.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 203 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 233 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 246 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 120 of file configuration.c.

References GNUNET_new.

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().

121 {
122  return GNUNET_new (struct GNUNET_CONFIGURATION_Handle);
123 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
configuration data
Definition: configuration.c:85
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 720 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(), and testbed_run().

721 {
723 
726  return ret;
727 }
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.
static int ret
Final status code.
Definition: gnunet-arm.c:89
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:85
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 132 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(), 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().

133 {
134  struct ConfigSection *sec;
135 
136  while (NULL != (sec = cfg->sections))
138  GNUNET_free (cfg);
139 }
char * name
name of the section
Definition: configuration.c:78
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:90
configuration section
Definition: configuration.c:63
#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 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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)
#define GNUNET_YES
Definition: gnunet_common.h:80
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 1749 of file configuration.c.

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

Referenced by GNUNET_CONFIGURATION_load().

1751 {
1752  if (GNUNET_SYSERR ==
1753  GNUNET_DISK_directory_scan (defaults_d,
1755  cfg))
1756  return GNUNET_SYSERR; /* no configuration at all found */
1757  return GNUNET_OK;
1758 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition: disk.c:1233
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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 352 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().

354 {
355  uint64_t fs64;
356  size_t fs;
357  char *fn;
358  char *mem;
359  char *endsep;
360  int dirty;
361  int ret;
362  ssize_t sret;
363 
366  "Asked to parse config file `%s'\n",
367  fn);
368  if (NULL == fn)
369  return GNUNET_SYSERR;
370  dirty = cfg->dirty; /* back up value! */
371  if (GNUNET_SYSERR ==
373  &fs64,
374  GNUNET_YES,
375  GNUNET_YES))
376  {
378  "Error while determining the file size of `%s'\n",
379  fn);
380  GNUNET_free (fn);
381  return GNUNET_SYSERR;
382  }
383  if (fs64 > SIZE_MAX)
384  {
385  GNUNET_break (0); /* File size is more than the heap size */
386  GNUNET_free (fn);
387  return GNUNET_SYSERR;
388  }
389  fs = fs64;
390  mem = GNUNET_malloc (fs);
391  sret = GNUNET_DISK_fn_read (fn,
392  mem,
393  fs);
394  if ( (sret < 0) ||
395  (fs != (size_t) sret) )
396  {
398  _("Error while reading file `%s'\n"),
399  fn);
400  GNUNET_free (fn);
401  GNUNET_free (mem);
402  return GNUNET_SYSERR;
403  }
405  "Deserializing contents of file `%s'\n",
406  fn);
407  endsep = strrchr (fn, (int) '/');
408  if (NULL != endsep)
409  *endsep = '\0';
411  mem,
412  fs,
413  fn);
414  GNUNET_free (fn);
415  GNUNET_free (mem);
416  /* restore dirty flag - anything we set in the meantime
417  * came from disk */
418  cfg->dirty = dirty;
419  return ret;
420 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:97
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define SIZE_MAX
Definition: platform.h:250
#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:208
static char * fn
Filename of the unique file.
static char * filename
#define LOG(kind,...)
Definition: configuration.c:33
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:602
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:289
#define GNUNET_YES
Definition: gnunet_common.h:80
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:1019
#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 446 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().

448 {
449  struct ConfigSection *sec;
450  struct ConfigEntry *ent;
451  char *mem;
452  char *cbuf;
453  char *val;
454  char *pos;
455  int len;
456  size_t m_size;
457  size_t c_size;
458 
459  /* Pass1 : calculate the buffer size required */
460  m_size = 0;
461  for (sec = cfg->sections; NULL != sec; sec = sec->next)
462  {
463  /* For each section we need to add 3 charaters: {'[',']','\n'} */
464  m_size += strlen (sec->name) + 3;
465  for (ent = sec->entries; NULL != ent; ent = ent->next)
466  {
467  if (NULL != ent->val)
468  {
469  /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */
470  pos = ent->val;
471  while (NULL != (pos = strstr (pos, "\n")))
472  {
473  m_size++;
474  pos++;
475  }
476  /* For each key = value pair we need to add 4 characters (2
477  spaces and 1 equal-to character and 1 new line) */
478  m_size += strlen (ent->key) + strlen (ent->val) + 4;
479  }
480  }
481  /* A new line after section end */
482  m_size++;
483  }
484 
485  /* Pass2: Allocate memory and write the configuration to it */
486  mem = GNUNET_malloc (m_size);
487  sec = cfg->sections;
488  c_size = 0;
489  *size = c_size;
490  while (NULL != sec)
491  {
492  len = GNUNET_asprintf (&cbuf, "[%s]\n", sec->name);
493  GNUNET_assert (0 < len);
494  GNUNET_memcpy (mem + c_size, cbuf, len);
495  c_size += len;
496  GNUNET_free (cbuf);
497  for (ent = sec->entries; NULL != ent; ent = ent->next)
498  {
499  if (NULL != ent->val)
500  {
501  val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
502  strcpy (val, ent->val);
503  while (NULL != (pos = strstr (val, "\n")))
504  {
505  memmove (&pos[2], &pos[1], strlen (&pos[1]));
506  pos[0] = '\\';
507  pos[1] = 'n';
508  }
509  len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val);
510  GNUNET_free (val);
511  GNUNET_memcpy (mem + c_size, cbuf, len);
512  c_size += len;
513  GNUNET_free (cbuf);
514  }
515  }
516  GNUNET_memcpy (mem + c_size, "\n", 1);
517  c_size ++;
518  sec = sec->next;
519  }
520  GNUNET_assert (c_size == m_size);
521  *size = c_size;
522  return mem;
523 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:73
configuration entry
Definition: configuration.c:40
char * name
name of the section
Definition: configuration.c:78
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_memcpy(dst, src, n)
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:90
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:46
configuration section
Definition: configuration.c:63
char * key
key for this entry
Definition: configuration.c:51
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:68
#define GNUNET_malloc(size)
Wrapper around malloc.
char * val
current, commited value
Definition: configuration.c:56
#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 189 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_free_non_null, 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().

193 {
194  char *line;
195  char *line_orig;
196  size_t line_size;
197  char *pos;
198  unsigned int nr;
199  size_t r_bytes;
200  size_t to_read;
201  size_t i;
202  int emptyline;
203  int ret;
204  char *section;
205  char *eq;
206  char *tag;
207  char *value;
208 
209  ret = GNUNET_OK;
210  section = GNUNET_strdup ("");
211  nr = 0;
212  r_bytes = 0;
213  line_orig = NULL;
214  while (r_bytes < size)
215  {
216  GNUNET_free_non_null (line_orig);
217  /* fgets-like behaviour on buffer */
218  to_read = size - r_bytes;
219  pos = memchr (&mem[r_bytes], '\n', to_read);
220  if (NULL == pos)
221  {
222  line_orig = GNUNET_strndup (&mem[r_bytes], line_size = to_read);
223  r_bytes += line_size;
224  }
225  else
226  {
227  line_orig = GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes]));
228  r_bytes += line_size + 1;
229  }
230  line = line_orig;
231  /* increment line number */
232  nr++;
233  /* tabs and '\r' are whitespace */
234  emptyline = GNUNET_YES;
235  for (i = 0; i < line_size; i++)
236  {
237  if (line[i] == '\t')
238  line[i] = ' ';
239  if (line[i] == '\r')
240  line[i] = ' ';
241  if (' ' != line[i])
242  emptyline = GNUNET_NO;
243  }
244  /* ignore empty lines */
245  if (GNUNET_YES == emptyline)
246  continue;
247 
248  /* remove tailing whitespace */
249  for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i]));i--)
250  line[i] = '\0';
251 
252  /* remove leading whitespace */
253  for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++);
254 
255  /* ignore comments */
256  if ( ('#' == line[0]) || ('%' == line[0]) )
257  continue;
258 
259  /* handle special "@INLINE@" directive */
260  if (0 == strncasecmp (line,
261  "@INLINE@ ",
262  strlen ("@INLINE@ ")))
263  {
264  /* @INLINE@ value */
265  value = &line[strlen ("@INLINE@ ")];
266  if (NULL != basedir)
267  {
268  char *fn;
269 
270  GNUNET_asprintf (&fn,
271  "%s/%s",
272  basedir,
273  value);
274  if (GNUNET_OK !=
276  fn))
277  {
278  GNUNET_free (fn);
279  ret = GNUNET_SYSERR; /* failed to parse included config */
280  break;
281  }
282  GNUNET_free (fn);
283  }
284  else
285  {
287  "Ignoring parsing @INLINE@ configurations, not allowed!\n");
288  ret = GNUNET_SYSERR;
289  break;
290  }
291  continue;
292  }
293  if ( ('[' == line[0]) && (']' == line[line_size - 1]) )
294  {
295  /* [value] */
296  line[line_size - 1] = '\0';
297  value = &line[1];
298  GNUNET_free (section);
299  section = GNUNET_strdup (value);
300  continue;
301  }
302  if (NULL != (eq = strchr (line, '=')))
303  {
304  /* tag = value */
305  tag = GNUNET_strndup (line, eq - line);
306  /* remove tailing whitespace */
307  for (i = strlen (tag) - 1; (i >= 1) && (isspace ((unsigned char) tag[i]));i--)
308  tag[i] = '\0';
309 
310  /* Strip whitespace */
311  value = eq + 1;
312  while (isspace ((unsigned char) value[0]))
313  value++;
314  for (i = strlen (value) - 1; (i >= 1) && (isspace ((unsigned char) value[i]));i--)
315  value[i] = '\0';
316 
317  /* remove quotes */
318  i = 0;
319  if ( ('"' == value[0]) &&
320  ('"' == value[strlen (value) - 1]) )
321  {
322  value[strlen (value) - 1] = '\0';
323  value++;
324  }
325  GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]);
326  GNUNET_free (tag);
327  continue;
328  }
329  /* parse error */
331  _("Syntax error while deserializing in line %u\n"),
332  nr);
333  ret = GNUNET_SYSERR;
334  break;
335  }
336  GNUNET_free_non_null (line_orig);
337  GNUNET_free (section);
338  GNUNET_assert ( (GNUNET_OK != ret) || (r_bytes == size) );
339  return ret;
340 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
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...
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
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:33
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_YES
Definition: gnunet_common.h:80
#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 534 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(), testing_main(), and tokenizer_cb().

536 {
537  char *fn;
538  char *cfg_buf;
539  size_t size;
540  ssize_t sret;
541 
543  if (fn == NULL)
544  return GNUNET_SYSERR;
546  {
547  GNUNET_free (fn);
548  return GNUNET_SYSERR;
549  }
550  cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size);
551  sret = GNUNET_DISK_fn_write (fn, cfg_buf, size,
556  if ( (sret < 0) ||
557  (size != (size_t) sret) )
558  {
559  GNUNET_free (fn);
560  GNUNET_free (cfg_buf);
562  "Writing configuration to file `%s' failed\n",
563  filename);
564  cfg->dirty = GNUNET_SYSERR; /* last write failed */
565  return GNUNET_SYSERR;
566  }
567  GNUNET_free (fn);
568  GNUNET_free (cfg_buf);
569  cfg->dirty = GNUNET_NO; /* last write succeeded */
570  return GNUNET_OK;
571 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:97
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:833
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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:1203
static char * fn
Filename of the unique file.
static char * filename
#define LOG(kind,...)
Definition: configuration.c:33
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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:602
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 832 of file configuration.c.

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

Referenced by auto_config_cb(), and main().

836 {
837  int ret;
838  struct GNUNET_CONFIGURATION_Handle *diff;
839 
840  diff = GNUNET_CONFIGURATION_get_diff (cfg_default, cfg_new);
841  ret = GNUNET_CONFIGURATION_write (diff, filename);
843  return ret;
844 }
int GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
static int ret
Final status code.
Definition: gnunet-arm.c:89
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:85
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 811 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().

813 {
814  struct DiffHandle diffHandle;
815 
816  diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
817  diffHandle.cfg_default = cfg_default;
818  GNUNET_CONFIGURATION_iterate (cfg_new, &compare_entries, &diffHandle);
819  return diffHandle.cfgDiff;
820 }
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 431 of file configuration.c.

References GNUNET_CONFIGURATION_Handle::dirty.

Referenced by auto_config_cb().

432 {
433  return cfg->dirty;
434 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:97
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 154 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().

157 {
159  int ret;
160 
162  if (GNUNET_OK !=
164  filename))
165  {
166  GNUNET_break (0);
168  return GNUNET_SYSERR;
169  }
170  ret = cb (cb_cls,
171  cfg);
173  return ret;
174 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create()
Create a GNUNET_CONFIGURATION_Handle.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#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
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
configuration data
Definition: configuration.c:85
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 582 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_().

585 {
586  struct ConfigSection *spos;
587  struct ConfigEntry *epos;
588 
589  for (spos = cfg->sections; NULL != spos; spos = spos->next)
590  for (epos = spos->entries; NULL != epos; epos = epos->next)
591  if (NULL != epos->val)
592  iter (iter_cls, spos->name, epos->key, epos->val);
593 }
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:73
configuration entry
Definition: configuration.c:40
char * name
name of the section
Definition: configuration.c:78
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:90
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:46
configuration section
Definition: configuration.c:63
char * key
key for this entry
Definition: configuration.c:51
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:68
char * val
current, commited value
Definition: configuration.c:56
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 633 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().

636 {
637  struct ConfigSection *spos;
638  struct ConfigSection *next;
639 
640  next = cfg->sections;
641  while (next != NULL)
642  {
643  spos = next;
644  next = spos->next;
645  iter (iter_cls, spos->name);
646  }
647 }
char * name
name of the section
Definition: configuration.c:78
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:90
configuration section
Definition: configuration.c:63
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:68
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 657 of file configuration.c.

References GNUNET_CONFIGURATION_Handle::dirty, ConfigSection::entries, GNUNET_free, GNUNET_free_non_null, 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().

659 {
660  struct ConfigSection *spos;
661  struct ConfigSection *prev;
662  struct ConfigEntry *ent;
663 
664  prev = NULL;
665  spos = cfg->sections;
666  while (NULL != spos)
667  {
668  if (0 == strcasecmp (section, spos->name))
669  {
670  if (NULL == prev)
671  cfg->sections = spos->next;
672  else
673  prev->next = spos->next;
674  while (NULL != (ent = spos->entries))
675  {
676  spos->entries = ent->next;
677  GNUNET_free (ent->key);
678  GNUNET_free_non_null (ent->val);
679  GNUNET_free (ent);
680  cfg->dirty = GNUNET_YES;
681  }
682  GNUNET_free (spos->name);
683  GNUNET_free (spos);
684  return;
685  }
686  prev = spos;
687  spos = spos->next;
688  }
689 }
int dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
Definition: configuration.c:97
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:73
configuration entry
Definition: configuration.c:40
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char * section
Name of the section.
Definition: gnunet-config.c:33
char * name
name of the section
Definition: configuration.c:78
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:90
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:46
configuration section
Definition: configuration.c:63
char * key
key for this entry
Definition: configuration.c:51
#define GNUNET_YES
Definition: gnunet_common.h:80
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:68
char * val
current, commited value
Definition: configuration.c:56
#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 933 of file configuration.c.

References dummy, e, find_entry(), GNUNET_OK, GNUNET_SYSERR, SSCANF, 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_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_ats_ril_init(), 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().

937 {
938  struct ConfigEntry *e;
939  char dummy[2];
940 
941  if (NULL == (e = find_entry (cfg, section, option)))
942  return GNUNET_SYSERR;
943  if (NULL == e->val)
944  return GNUNET_SYSERR;
945  if (1 != SSCANF (e->val,
946  "%llu%1s",
947  number,
948  dummy))
949  return GNUNET_SYSERR;
950  return GNUNET_OK;
951 }
static struct in_addr dummy
Target "dummy" address.
static struct Experiment * e
configuration entry
Definition: configuration.c:40
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define SSCANF
Definition: plibc.h:691
char * val
current, commited value
Definition: configuration.c:56
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 964 of file configuration.c.

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

Referenced by GNUNET_RPS_connect(), libgnunet_plugin_ats_mlp_init(), libgnunet_plugin_ats_proportional_init(), and libgnunet_plugin_ats_ril_init().

968 {
969  struct ConfigEntry *e;
970  char dummy[2];
971 
972  if (NULL == (e = find_entry (cfg, section, option)))
973  return GNUNET_SYSERR;
974  if (NULL == e->val)
975  return GNUNET_SYSERR;
976  if (1 != SSCANF (e->val,
977  "%f%1s",
978  number,
979  dummy))
980  return GNUNET_SYSERR;
981  return GNUNET_OK;
982 }
static struct in_addr dummy
Target "dummy" address.
static struct Experiment * e
configuration entry
Definition: configuration.c:40
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define SSCANF
Definition: plibc.h:691
char * val
current, commited value
Definition: configuration.c:56
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 996 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_SPEEDUP_start_(), GNUNET_TESTBED_run(), GSF_push_init_(), GST_manipulation_init(), libgnunet_plugin_ats_mlp_init(), libgnunet_plugin_ats_ril_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().

1000 {
1001  struct ConfigEntry *e;
1002  int ret;
1003 
1004  if (NULL == (e = find_entry (cfg,
1005  section,
1006  option)))
1007  return GNUNET_SYSERR;
1008  if (NULL == e->val)
1009  return GNUNET_SYSERR;
1011  time);
1012  if (GNUNET_OK != ret)
1014  section,
1015  option,
1016  _("Not a valid relative time specification"));
1017  return ret;
1018 }
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:353
static struct Experiment * e
configuration entry
Definition: configuration.c:40
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char * val
current, commited value
Definition: configuration.c:56
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 1031 of file configuration.c.

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

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

1035 {
1036  struct ConfigEntry *e;
1037 
1038  if (NULL == (e = find_entry (cfg, section, option)))
1039  return GNUNET_SYSERR;
1040  if (NULL == e->val)
1041  return GNUNET_SYSERR;
1043 }
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:317
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
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
char * val
current, commited value
Definition: configuration.c:56
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 1174 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_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().

1177 {
1178  struct ConfigEntry *e;
1179 
1180  if ((NULL == (e = find_entry (cfg, section, option))) || (NULL == e->val))
1181  return GNUNET_NO;
1182  return GNUNET_YES;
1183 }
static struct Experiment * e
#define GNUNET_NO
Definition: gnunet_common.h:81
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
#define GNUNET_YES
Definition: gnunet_common.h:80
char * val
current, commited value
Definition: configuration.c:56
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 1057 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_quota(), 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_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_ats_mlp_init(), libgnunet_plugin_ats_ril_init(), 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().

1061 {
1062  struct ConfigEntry *e;
1063 
1064  if ( (NULL == (e = find_entry (cfg, section, option))) ||
1065  (NULL == e->val) )
1066  {
1067  *value = NULL;
1068  return GNUNET_SYSERR;
1069  }
1070  *value = GNUNET_strdup (e->val);
1071  return GNUNET_OK;
1072 }
static struct Experiment * e
configuration entry
Definition: configuration.c:40
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char * val
current, commited value
Definition: configuration.c:56
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 1400 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_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_FRIENDS_parse(), GNUNET_FRIENDS_write_start(), GNUNET_HOSTLIST_client_start(), 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().

1404 {
1405  char *tmp;
1406 
1407  if (GNUNET_OK !=
1409  {
1411  "Failed to retrieve filename\n");
1412  *value = NULL;
1413  return GNUNET_SYSERR;
1414  }
1415  tmp = GNUNET_CONFIGURATION_expand_dollar (cfg, tmp);
1417  GNUNET_free (tmp);
1418  if (*value == NULL)
1419  return GNUNET_SYSERR;
1420  return GNUNET_OK;
1421 }
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...
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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:33
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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:602
#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 1463 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().

1468 {
1469  char *list;
1470  char *pos;
1471  char *end;
1472  char old;
1473  int ret;
1474 
1475  if (GNUNET_OK !=
1477  return 0;
1478  GNUNET_assert (list != NULL);
1479  ret = 0;
1480  pos = list;
1481  while (1)
1482  {
1483  while (pos[0] == ' ')
1484  pos++;
1485  if (strlen (pos) == 0)
1486  break;
1487  end = pos + 1;
1488  while ((end[0] != ' ') && (end[0] != '\0'))
1489  {
1490  if (end[0] == '\\')
1491  {
1492  switch (end[1])
1493  {
1494  case '\\':
1495  case ' ':
1496  memmove (end, &end[1], strlen (&end[1]) + 1);
1497  case '\0':
1498  /* illegal, but just keep it */
1499  break;
1500  default:
1501  /* illegal, but just ignore that there was a '/' */
1502  break;
1503  }
1504  }
1505  end++;
1506  }
1507  old = end[0];
1508  end[0] = '\0';
1509  if (strlen (pos) > 0)
1510  {
1511  ret++;
1512  if ((cb != NULL) && (GNUNET_OK != cb (cb_cls, pos)))
1513  {
1514  ret = GNUNET_SYSERR;
1515  break;
1516  }
1517  }
1518  if (old == '\0')
1519  break;
1520  pos = end + 1;
1521  }
1522  GNUNET_free (list);
1523  return ret;
1524 }
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.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static int ret
Final status code.
Definition: gnunet-arm.c:89
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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:64
#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 605 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().

610 {
611  struct ConfigSection *spos;
612  struct ConfigEntry *epos;
613 
614  spos = cfg->sections;
615  while ((spos != NULL) && (0 != strcasecmp (spos->name, section)))
616  spos = spos->next;
617  if (NULL == spos)
618  return;
619  for (epos = spos->entries; NULL != epos; epos = epos->next)
620  if (NULL != epos->val)
621  iter (iter_cls, spos->name, epos->key, epos->val);
622 }
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:73
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:78
struct ConfigSection * sections
Configuration sections.
Definition: configuration.c:90
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:46
configuration section
Definition: configuration.c:63
char * key
key for this entry
Definition: configuration.c:51
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:68
char * val
current, commited value
Definition: configuration.c:56
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 1088 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().

1093 {
1094  struct ConfigEntry *e;
1095  unsigned int i;
1096 
1097  if (NULL == (e = find_entry (cfg, section, option)))
1098  return GNUNET_SYSERR;
1099  for (i = 0; NULL != choices[i]; i++)
1100  if (0 == strcasecmp (choices[i], e->val))
1101  break;
1102  if (NULL == choices[i])
1103  {
1105  _("Configuration value '%s' for '%s'"
1106  " in section '%s' is not in set of legal choices\n"),
1107  e->val,
1108  option,
1109  section);
1110  return GNUNET_SYSERR;
1111  }
1112  *value = choices[i];
1113  return GNUNET_OK;
1114 }
static struct Experiment * e
configuration entry
Definition: configuration.c:40
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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:208
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:33
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char * val
current, commited value
Definition: configuration.c:56
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 1434 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(), GSF_pending_request_init_(), GSF_push_init_(), LEGACY_SERVICE_get_server_addresses(), libgnunet_plugin_ats_mlp_init(), libgnunet_plugin_ats_ril_init(), 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(), test_icmp_client(), test_icmp_server(), test_master(), try_unixpath(), udp_address_to_sockaddr(), and update_config().

1437 {
1438  static const char *yesno[] = { "YES", "NO", NULL };
1439  const char *val;
1440  int ret;
1441 
1442  ret =
1444  if (ret == GNUNET_SYSERR)
1445  return ret;
1446  if (val == yesno[0])
1447  return GNUNET_YES;
1448  return GNUNET_NO;
1449 }
#define GNUNET_NO
Definition: gnunet_common.h:81
static int ret
Final status code.
Definition: gnunet-arm.c:89
static char * section
Name of the section.
Definition: gnunet-config.c:33
static char * option
Name of the option.
Definition: gnunet-config.c:38
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_YES
Definition: gnunet_common.h:80
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:56
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 1130 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.

1135 {
1136  char *enc;
1137  int res;
1138  size_t data_size;
1139 
1140  if (GNUNET_OK !=
1142  section,
1143  option,
1144  &enc)))
1145  return res;
1146  data_size = (strlen (enc) * 5) / 8;
1147  if (data_size != buf_size)
1148  {
1149  GNUNET_free (enc);
1150  return GNUNET_SYSERR;
1151  }
1152  if (GNUNET_OK !=
1154  strlen (enc),
1155  buf, buf_size))
1156  {
1157  GNUNET_free (enc);
1158  return GNUNET_SYSERR;
1159  }
1160  GNUNET_free (enc);
1161  return GNUNET_OK;
1162 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static OpusEncoder * enc
OPUS encoder.
static size_t data_size
Number of bytes in data.
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:1021
#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 1367 of file configuration.c.

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

1369 {
1370  char *dup;
1371  size_t i;
1372  size_t len;
1373 
1374  for (i = 0; '\0' != orig[i]; i++)
1375  {
1376  if ('$' != orig[i])
1377  continue;
1378  dup = GNUNET_strdup (orig + i);
1379  dup = expand_dollar (cfg, dup, 0);
1380  len = strlen (dup) + 1;
1381  orig = GNUNET_realloc (orig, i + len);
1382  GNUNET_memcpy (orig + i, dup, len);
1383  GNUNET_free (dup);
1384  }
1385  return orig;
1386 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_memcpy(dst, src, n)
#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 905 of file configuration.c.

References GNUNET_CONFIGURATION_set_value_string(), and GNUNET_snprintf().

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

909 {
910  char s[64];
911 
912  GNUNET_snprintf (s,
913  64,
914  "%llu",
915  number);
917  section,
918  option,
919  s);
920 }
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
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 856 of file configuration.c.

References e, ConfigSection::entries, find_entry(), find_section(), GNUNET_free_non_null, 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_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(), test_local_ip(), test_upnpc(), update_config(), update_config_sections(), and update_enable_upnpc_option().

859 {
860  struct ConfigSection *sec;
861  struct ConfigEntry *e;
862  char *nv;
863 
864  e = find_entry (cfg, section, option);
865  if (NULL != e)
866  {
867  if (NULL == value)
868  {
870  e->val = NULL;
871  }
872  else
873  {
874  nv = GNUNET_strdup (value);
876  e->val = nv;
877  }
878  return;
879  }
880  sec = find_section (cfg, section);
881  if (sec == NULL)
882  {
883  sec = GNUNET_new (struct ConfigSection);
884  sec->name = GNUNET_strdup (section);
885  sec->next = cfg->sections;
886  cfg->sections = sec;
887  }
888  e = GNUNET_new (struct ConfigEntry);
889  e->key = GNUNET_strdup (option);
890  e->val = GNUNET_strdup (value);
891  e->next = sec->entries;
892  sec->entries = e;
893 }
struct ConfigEntry * entries
entries in the section
Definition: configuration.c:73
static struct Experiment * e
configuration entry
Definition: configuration.c:40
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#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:78
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:90
struct ConfigEntry * next
This is a linked list.
Definition: configuration.c:46
configuration section
Definition: configuration.c:63
char * key
key for this entry
Definition: configuration.c:51
struct ConfigSection * next
This is a linked list.
Definition: configuration.c:68
char * val
current, commited value
Definition: configuration.c:56
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 1637 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.

1641 {
1642  char *list;
1643  char *pos;
1644  char *end;
1645  char *match;
1646  char old;
1647 
1648  if (GNUNET_OK !=
1650  return GNUNET_NO;
1651  match = escape_name (value);
1652  pos = list;
1653  while (1)
1654  {
1655  while (pos[0] == ' ')
1656  pos++;
1657  if (strlen (pos) == 0)
1658  break;
1659  end = pos + 1;
1660  while ((end[0] != ' ') && (end[0] != '\0'))
1661  {
1662  if (end[0] == '\\')
1663  {
1664  switch (end[1])
1665  {
1666  case '\\':
1667  case ' ':
1668  end++;
1669  break;
1670  case '\0':
1671  /* illegal, but just keep it */
1672  break;
1673  default:
1674  /* illegal, but just ignore that there was a '/' */
1675  break;
1676  }
1677  }
1678  end++;
1679  }
1680  old = end[0];
1681  end[0] = '\0';
1682  if (0 == strcmp (pos, match))
1683  {
1684  if (old != '\0')
1685  memmove (pos, &end[1], strlen (&end[1]) + 1);
1686  else
1687  {
1688  if (pos != list)
1689  pos[-1] = '\0';
1690  else
1691  pos[0] = '\0';
1692  }
1694  GNUNET_free (list);
1695  GNUNET_free (match);
1696  return GNUNET_OK;
1697  }
1698  if (old == '\0')
1699  break;
1700  end[0] = old;
1701  pos = end + 1;
1702  }
1703  GNUNET_free (list);
1704  GNUNET_free (match);
1705  return GNUNET_NO;
1706 }
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.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
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:64
#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 1593 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().

1597 {
1598  char *escaped;
1599  char *old;
1600  char *nw;
1601 
1602  if (GNUNET_SYSERR ==
1604  &test_match,
1605  (void *) value))
1606  return GNUNET_NO; /* already exists */
1607  if (GNUNET_OK !=
1609  old = GNUNET_strdup ("");
1610  escaped = escape_name (value);
1611  nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2);
1612  strcpy (nw, old);
1613  if (strlen (old) > 0)
1614  strcat (nw, " ");
1615  strcat (nw, escaped);
1617  GNUNET_free (old);
1618  GNUNET_free (nw);
1619  GNUNET_free (escaped);
1620  return GNUNET_OK;
1621 }
static char * escape_name(const char *value)
FIXME.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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: