GNUnet  0.11.x
Data Structures | Macros | Functions
configuration.c File Reference

configuration management More...

#include "platform.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_strings_lib.h"
#include "gnunet_os_lib.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_disk_lib.h"
Include dependency graph for configuration.c:

Go to the source code of this file.

Data Structures

struct  ConfigEntry
 configuration entry More...
 
struct  ConfigSection
 configuration section More...
 
struct  GNUNET_CONFIGURATION_Handle
 configuration data More...
 
struct  DiffHandle
 Used for diffing a configuration object against the default one. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "util", __VA_ARGS__)
 
#define LOG_STRERROR_FILE(kind, syscall, filename)   GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
 

Functions

struct GNUNET_CONFIGURATION_HandleGNUNET_CONFIGURATION_create ()
 Create a new configuration object. More...
 
void GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
 Destroy configuration object. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse_and_run (const 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...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *basedir)
 De-serializes configuration. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
 Parse a configuration file, add all of the options in the file to the configuration environment. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Test if there are configuration options that were changed since the last save. More...
 
static bool do_skip (const char *sec, const char *key)
 Should we skip this configuration entry when serializing? More...
 
char * GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
 Serializes the given configuration. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
 Write configuration file. More...
 
void GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
 Iterate over all options in the configuration. More...
 
void GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
 Iterate over values of a section in the configuration. More...
 
void GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_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...
 
static void copy_entry (void *cls, const char *section, const char *option, const char *value)
 Copy a configuration value to the given target configuration. More...
 
struct GNUNET_CONFIGURATION_HandleGNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Duplicate an existing configuration object. More...
 
static struct ConfigSectionfind_section (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
 Find a section entry from a configuration. More...
 
static struct ConfigEntryfind_entry (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
 Find an entry from a configuration. More...
 
static void compare_entries (void *cls, const char *section, const char *option, const char *value)
 A callback function, compares entries from two configurations (default against a new configuration) and write the diffs in a diff-configuration object (the callback object). More...
 
struct GNUNET_CONFIGURATION_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...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new, const char *filename)
 Write only configuration entries that have been changed to configuration file. More...
 
void GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
 Set a configuration value that should be a string. More...
 
void GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
 Set a configuration value that should be a number. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
 Get a configuration value that should be a number. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number)
 Get a configuration value that should be a floating point number. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
 Get a configuration value that should be a relative time. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *size)
 Get a configuration value that should be a size in bytes. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
 Get a configuration value that should be a string. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *const *choices, const char **value)
 Get a configuration value that should be in a set of predefined strings. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, void *buf, size_t buf_size)
 Get Crockford32-encoded fixed-size binary data from a configuration. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
 Test if we have a value for a particular option. More...
 
static char * expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig, unsigned int depth)
 Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or the environment "FOO" is set to "DIRECTORY". More...
 
char * GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig)
 Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or the environment "FOO" is set to "DIRECTORY". More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
 Get a configuration value that should be the name of a file or directory. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
 Get a configuration value that should be in a set of "YES" or "NO". More...
 
int GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, GNUNET_FileNameCallback cb, void *cb_cls)
 Iterate over the set of filenames stored in a configuration value. More...
 
static char * escape_name (const char *value)
 FIXME. More...
 
static enum GNUNET_GenericReturnValue test_match (void *cls, const char *fn)
 FIXME. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
 Append a filename to a configuration value that represents a list of filenames. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
 Remove a filename from a configuration value that represents a list of filenames. More...
 
static enum GNUNET_GenericReturnValue parse_configuration_file (void *cls, const char *filename)
 Wrapper around GNUNET_CONFIGURATION_parse. More...
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
 Load default configuration. More...
 
struct GNUNET_CONFIGURATION_HandleGNUNET_CONFIGURATION_default (void)
 Return GNUnet's default configuration. More...
 

Detailed Description

configuration management

Author
Christian Grothoff

Definition in file configuration.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "util", __VA_ARGS__)

◆ LOG_STRERROR_FILE

#define LOG_STRERROR_FILE (   kind,
  syscall,
  filename 
)    GNUNET_log_from_strerror_file (kind, "util", syscall, filename)

Definition at line 34 of file configuration.c.

Function Documentation

◆ do_skip()

static bool do_skip ( const char *  sec,
const char *  key 
)
static

Should we skip this configuration entry when serializing?

Parameters
secsection name
keykey
Returns
true if we should skip it

Definition at line 454 of file configuration.c.

Referenced by GNUNET_CONFIGURATION_serialize().

456 {
457  if (0 != strcasecmp ("PATHS",
458  sec))
459  return false;
460  return ( (0 == strcasecmp ("DATADIR",
461  key)) ||
462  (0 == strcasecmp ("LIBDIR",
463  key)) ||
464  (0 == strcasecmp ("BINDIR",
465  key)) ||
466  (0 == strcasecmp ("PREFIX",
467  key)) ||
468  (0 == strcasecmp ("LOCALEDIR",
469  key)) ||
470  (0 == strcasecmp ("ICONDIR",
471  key)) ||
472  (0 == strcasecmp ("DOCDIR",
473  key)) ||
474  (0 == strcasecmp ("DEFAULTCONFIG",
475  key)) ||
476  (0 == strcasecmp ("LIBEXECDIR",
477  key)) );
478 }
struct GNUNET_HashCode key
The key used in the DHT.
Here is the caller graph for this function:

◆ copy_entry()

static void copy_entry ( void *  cls,
const char *  section,
const char *  option,
const char *  value 
)
static

Copy a configuration value to the given target configuration.

Overwrites existing entries.

Parameters
clsthe destination configuration (struct GNUNET_CONFIGURATION_Handle *)
sectionsection for the value
optionoption name of the value
valuevalue to copy

Definition at line 742 of file configuration.c.

References GNUNET_CONFIGURATION_set_value_string().

Referenced by GNUNET_CONFIGURATION_dup().

746 {
747  struct GNUNET_CONFIGURATION_Handle *dst = cls;
748 
750 }
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.
configuration data
Definition: configuration.c:84
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_section()

static struct ConfigSection* find_section ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  section 
)
static

Find a section entry from a configuration.

Parameters
cfgconfiguration to search in
sectionname of the section to look for
Returns
matching entry, NULL if not found

Definition at line 772 of file configuration.c.

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

Referenced by find_entry(), and GNUNET_CONFIGURATION_set_value_string().

774 {
775  struct ConfigSection *pos;
776 
777  pos = cfg->sections;
778  while ((pos != NULL) && (0 != strcasecmp (section, pos->name)))
779  pos = pos->next;
780  return pos;
781 }
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
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:

◆ find_entry()

static struct ConfigEntry* find_entry ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  section,
const char *  key 
)
static

Find an entry from a configuration.

Parameters
cfghandle to the configuration
sectionsection the option is in
keythe option
Returns
matching entry, NULL if not found

Definition at line 793 of file configuration.c.

References ConfigSection::entries, find_section(), ConfigEntry::key, and ConfigEntry::next.

Referenced by compare_entries(), GNUNET_CONFIGURATION_get_value_choice(), GNUNET_CONFIGURATION_get_value_float(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_size(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_have_value(), and GNUNET_CONFIGURATION_set_value_string().

796 {
797  struct ConfigSection *sec;
798  struct ConfigEntry *pos;
799 
800  if (NULL == (sec = find_section (cfg, section)))
801  return NULL;
802  pos = sec->entries;
803  while ((pos != NULL) && (0 != strcasecmp (key, pos->key)))
804  pos = pos->next;
805  return pos;
806 }
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
static struct ConfigSection * find_section(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Find a section entry from a configuration.
struct GNUNET_HashCode key
The key used in the DHT.
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_entries()

static void compare_entries ( void *  cls,
const char *  section,
const char *  option,
const char *  value 
)
static

A callback function, compares entries from two configurations (default against a new configuration) and write the diffs in a diff-configuration object (the callback object).

Parameters
clsthe diff configuration (struct DiffHandle *)
sectionsection for the value (of the default conf.)
optionoption name of the value (of the default conf.)
valuevalue to copy (of the default conf.)

Definition at line 820 of file configuration.c.

References DiffHandle::cfg_default, DiffHandle::cfgDiff, find_entry(), GNUNET_CONFIGURATION_set_value_string(), and ConfigEntry::val.

Referenced by GNUNET_CONFIGURATION_get_diff().

824 {
825  struct DiffHandle *dh = cls;
826  struct ConfigEntry *entNew;
827 
828  entNew = find_entry (dh->cfg_default, section, option);
829  if ((NULL != entNew) && (NULL != entNew->val) &&
830  (0 == strcmp (entNew->val, value)))
831  return;
833 }
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.
struct GNUNET_CONFIGURATION_Handle * cfgDiff
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.
Used for diffing a configuration object against the default one.
const struct GNUNET_CONFIGURATION_Handle * cfg_default
char * val
current, committed value
Definition: configuration.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand_dollar()

static char* expand_dollar ( const struct GNUNET_CONFIGURATION_Handle cfg,
char *  orig,
unsigned int  depth 
)
static

Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or the environment "FOO" is set to "DIRECTORY".

We also support default expansion, i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is set in PATHS or the environment, and otherwise to "default". Note that "default" itself can also be a $-expression, thus "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined to VAR2.

Parameters
cfgconfiguration to use for path expansion
origstring to $-expand (will be freed!)
depthrecursion depth, used to detect recursive expansions
Returns
$-expanded string, never NULL unless orig was NULL

Definition at line 1123 of file configuration.c.

References _, end, env, getenv(), GNUNET_CONFIGURATION_expand_dollar(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_realloc, GNUNET_strdup, len, LOG, result, and start.

Referenced by GNUNET_CONFIGURATION_expand_dollar().

1126 {
1127  char *prefix;
1128  char *result;
1129  char *start;
1130  const char *post;
1131  const char *env;
1132  char *def;
1133  char *end;
1134  unsigned int lopen;
1135  char erased_char;
1136  char *erased_pos;
1137  size_t len;
1138 
1139  if (NULL == orig)
1140  return NULL;
1141  if (depth > 128)
1142  {
1144  _ (
1145  "Recursive expansion suspected, aborting $-expansion for term `%s'\n"),
1146  orig);
1147  return orig;
1148  }
1149  LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to $-expand %s\n", orig);
1150  if ('$' != orig[0])
1151  {
1152  LOG (GNUNET_ERROR_TYPE_DEBUG, "Doesn't start with $ - not expanding\n");
1153  return orig;
1154  }
1155  erased_char = 0;
1156  erased_pos = NULL;
1157  if ('{' == orig[1])
1158  {
1159  start = &orig[2];
1160  lopen = 1;
1161  end = &orig[1];
1162  while (lopen > 0)
1163  {
1164  end++;
1165  switch (*end)
1166  {
1167  case '}':
1168  lopen--;
1169  break;
1170 
1171  case '{':
1172  lopen++;
1173  break;
1174 
1175  case '\0':
1177  _ ("Missing closing `%s' in option `%s'\n"),
1178  "}",
1179  orig);
1180  return orig;
1181 
1182  default:
1183  break;
1184  }
1185  }
1186  erased_char = *end;
1187  erased_pos = end;
1188  *end = '\0';
1189  post = end + 1;
1190  def = strchr (orig, ':');
1191  if (NULL != def)
1192  {
1193  *def = '\0';
1194  def++;
1195  if (('-' == *def) || ('=' == *def))
1196  def++;
1197  def = GNUNET_strdup (def);
1198  }
1199  }
1200  else
1201  {
1202  int i;
1203 
1204  start = &orig[1];
1205  def = NULL;
1206  i = 0;
1207  while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0') &&
1208  (orig[i] != ' '))
1209  i++;
1210  if (orig[i] == '\0')
1211  {
1212  post = "";
1213  }
1214  else
1215  {
1216  erased_char = orig[i];
1217  erased_pos = &orig[i];
1218  orig[i] = '\0';
1219  post = &orig[i + 1];
1220  }
1221  }
1223  "Split into `%s' and `%s' with default %s\n",
1224  start,
1225  post,
1226  def);
1227  if (GNUNET_OK !=
1228  GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", start, &prefix))
1229  {
1230  if (NULL == (env = getenv (start)))
1231  {
1232  /* try default */
1233  def = expand_dollar (cfg, def, depth + 1);
1234  env = def;
1235  }
1236  if (NULL == env)
1237  {
1238  start = GNUNET_strdup (start);
1239  if (erased_pos)
1240  *erased_pos = erased_char;
1242  _ (
1243  "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n"),
1244  start,
1245  orig);
1246  GNUNET_free (start);
1247  return orig;
1248  }
1249  prefix = GNUNET_strdup (env);
1250  }
1251  prefix = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix);
1252  if ((erased_pos) && ('}' != erased_char))
1253  {
1254  len = strlen (prefix) + 1;
1255  prefix = GNUNET_realloc (prefix, len + 1);
1256  prefix[len - 1] = erased_char;
1257  prefix[len] = '\0';
1258  }
1259  result = GNUNET_malloc (strlen (prefix) + strlen (post) + 1);
1260  strcpy (result, prefix);
1261  strcat (result, post);
1262  GNUNET_free (def);
1263  GNUNET_free (prefix);
1264  GNUNET_free (orig);
1265  return result;
1266 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
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...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
static int result
Global testing status.
#define LOG(kind,...)
Definition: configuration.c:32
char * getenv()
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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_malloc(size)
Wrapper around malloc.
#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:

◆ escape_name()

static char* escape_name ( const char *  value)
static

FIXME.

Parameters
valueFIXME
Returns
FIXME

Definition at line 1414 of file configuration.c.

References GNUNET_malloc, and value.

Referenced by GNUNET_CONFIGURATION_append_value_filename(), and GNUNET_CONFIGURATION_remove_value_filename().

1415 {
1416  char *escaped;
1417  const char *rpos;
1418  char *wpos;
1419 
1420  escaped = GNUNET_malloc (strlen (value) * 2 + 1);
1421  memset (escaped, 0, strlen (value) * 2 + 1);
1422  rpos = value;
1423  wpos = escaped;
1424  while (rpos[0] != '\0')
1425  {
1426  switch (rpos[0])
1427  {
1428  case '\\':
1429  case ' ':
1430  wpos[0] = '\\';
1431  wpos[1] = rpos[0];
1432  wpos += 2;
1433  break;
1434 
1435  default:
1436  wpos[0] = rpos[0];
1437  wpos++;
1438  }
1439  rpos++;
1440  }
1441  return escaped;
1442 }
static char * value
Value of the record to add/remove.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ test_match()

static enum GNUNET_GenericReturnValue test_match ( void *  cls,
const char *  fn 
)
static

FIXME.

Parameters
clsstring we compare with (const char*)
fnfilename we are currently looking at
Returns
GNUNET_OK if the names do not match, GNUNET_SYSERR if they do

Definition at line 1453 of file configuration.c.

References GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_CONFIGURATION_append_value_filename().

1454 {
1455  const char *of = cls;
1456 
1457  return (0 == strcmp (of, fn)) ? GNUNET_SYSERR : GNUNET_OK;
1458 }
static char * fn
Filename of the unique file.
Here is the caller graph for this function:

◆ parse_configuration_file()

static enum GNUNET_GenericReturnValue parse_configuration_file ( void *  cls,
const char *  filename 
)
static

Wrapper around GNUNET_CONFIGURATION_parse.

Called on each file in a directory, we trigger parsing on those files that end with ".conf".

Parameters
clsthe cfg
filenamefile to parse
Returns
GNUNET_OK on success

Definition at line 1582 of file configuration.c.

References cfg, GNUNET_CONFIGURATION_parse(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, and GNUNET_OK.

Referenced by GNUNET_CONFIGURATION_load_from().

1583 {
1584  struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1585  char *ext;
1586 
1587  /* Examine file extension */
1588  ext = strrchr (filename, '.');
1589  if ((NULL == ext) || (0 != strcmp (ext, ".conf")))
1590  {
1591  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Skipping file `%s'\n", filename);
1592  return GNUNET_OK;
1593  }
1594 
1595  return GNUNET_CONFIGURATION_parse (cfg, filename);
1596 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Parse a configuration file, add all of the options in the file to the configuration environment...
static char * filename
configuration data
Definition: configuration.c:84
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function: