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

References GNUNET_CONFIGURATION_set_value_string().

Referenced by GNUNET_CONFIGURATION_dup().

745 {
746  struct GNUNET_CONFIGURATION_Handle *dst = cls;
747 
749 }
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 771 of file configuration.c.

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

Referenced by find_entry(), and GNUNET_CONFIGURATION_set_value_string().

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

795 {
796  struct ConfigSection *sec;
797  struct ConfigEntry *pos;
798 
799  if (NULL == (sec = find_section (cfg, section)))
800  return NULL;
801  pos = sec->entries;
802  while ((pos != NULL) && (0 != strcasecmp (key, pos->key)))
803  pos = pos->next;
804  return pos;
805 }
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 819 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().

823 {
824  struct DiffHandle *dh = cls;
825  struct ConfigEntry *entNew;
826 
827  entNew = find_entry (dh->cfg_default, section, option);
828  if ((NULL != entNew) && (NULL != entNew->val) &&
829  (0 == strcmp (entNew->val, value)))
830  return;
832 }
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 1122 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().

1125 {
1126  char *prefix;
1127  char *result;
1128  char *start;
1129  const char *post;
1130  const char *env;
1131  char *def;
1132  char *end;
1133  unsigned int lopen;
1134  char erased_char;
1135  char *erased_pos;
1136  size_t len;
1137 
1138  if (NULL == orig)
1139  return NULL;
1140  if (depth > 128)
1141  {
1143  _ (
1144  "Recursive expansion suspected, aborting $-expansion for term `%s'\n"),
1145  orig);
1146  return orig;
1147  }
1148  LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to $-expand %s\n", orig);
1149  if ('$' != orig[0])
1150  {
1151  LOG (GNUNET_ERROR_TYPE_DEBUG, "Doesn't start with $ - not expanding\n");
1152  return orig;
1153  }
1154  erased_char = 0;
1155  erased_pos = NULL;
1156  if ('{' == orig[1])
1157  {
1158  start = &orig[2];
1159  lopen = 1;
1160  end = &orig[1];
1161  while (lopen > 0)
1162  {
1163  end++;
1164  switch (*end)
1165  {
1166  case '}':
1167  lopen--;
1168  break;
1169 
1170  case '{':
1171  lopen++;
1172  break;
1173 
1174  case '\0':
1176  _ ("Missing closing `%s' in option `%s'\n"),
1177  "}",
1178  orig);
1179  return orig;
1180 
1181  default:
1182  break;
1183  }
1184  }
1185  erased_char = *end;
1186  erased_pos = end;
1187  *end = '\0';
1188  post = end + 1;
1189  def = strchr (orig, ':');
1190  if (NULL != def)
1191  {
1192  *def = '\0';
1193  def++;
1194  if (('-' == *def) || ('=' == *def))
1195  def++;
1196  def = GNUNET_strdup (def);
1197  }
1198  }
1199  else
1200  {
1201  int i;
1202 
1203  start = &orig[1];
1204  def = NULL;
1205  i = 0;
1206  while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0') &&
1207  (orig[i] != ' '))
1208  i++;
1209  if (orig[i] == '\0')
1210  {
1211  post = "";
1212  }
1213  else
1214  {
1215  erased_char = orig[i];
1216  erased_pos = &orig[i];
1217  orig[i] = '\0';
1218  post = &orig[i + 1];
1219  }
1220  }
1222  "Split into `%s' and `%s' with default %s\n",
1223  start,
1224  post,
1225  def);
1226  if (GNUNET_OK !=
1227  GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", start, &prefix))
1228  {
1229  if (NULL == (env = getenv (start)))
1230  {
1231  /* try default */
1232  def = expand_dollar (cfg, def, depth + 1);
1233  env = def;
1234  }
1235  if (NULL == env)
1236  {
1237  start = GNUNET_strdup (start);
1238  if (erased_pos)
1239  *erased_pos = erased_char;
1241  _ (
1242  "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n"),
1243  start,
1244  orig);
1245  GNUNET_free (start);
1246  return orig;
1247  }
1248  prefix = GNUNET_strdup (env);
1249  }
1250  prefix = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix);
1251  if ((erased_pos) && ('}' != erased_char))
1252  {
1253  len = strlen (prefix) + 1;
1254  prefix = GNUNET_realloc (prefix, len + 1);
1255  prefix[len - 1] = erased_char;
1256  prefix[len] = '\0';
1257  }
1258  result = GNUNET_malloc (strlen (prefix) + strlen (post) + 1);
1259  strcpy (result, prefix);
1260  strcat (result, post);
1261  GNUNET_free (def);
1262  GNUNET_free (prefix);
1263  GNUNET_free (orig);
1264  return result;
1265 }
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:184
#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 1413 of file configuration.c.

References GNUNET_malloc, and value.

Referenced by GNUNET_CONFIGURATION_append_value_filename(), and GNUNET_CONFIGURATION_remove_value_filename().

1414 {
1415  char *escaped;
1416  const char *rpos;
1417  char *wpos;
1418 
1419  escaped = GNUNET_malloc (strlen (value) * 2 + 1);
1420  memset (escaped, 0, strlen (value) * 2 + 1);
1421  rpos = value;
1422  wpos = escaped;
1423  while (rpos[0] != '\0')
1424  {
1425  switch (rpos[0])
1426  {
1427  case '\\':
1428  case ' ':
1429  wpos[0] = '\\';
1430  wpos[1] = rpos[0];
1431  wpos += 2;
1432  break;
1433 
1434  default:
1435  wpos[0] = rpos[0];
1436  wpos++;
1437  }
1438  rpos++;
1439  }
1440  return escaped;
1441 }
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 1452 of file configuration.c.

References GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNUNET_CONFIGURATION_append_value_filename().

1453 {
1454  const char *of = cls;
1455 
1456  return (0 == strcmp (of, fn)) ? GNUNET_SYSERR : GNUNET_OK;
1457 }
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 1581 of file configuration.c.

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

Referenced by GNUNET_CONFIGURATION_load_from().

1582 {
1583  struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1584  char *ext;
1585 
1586  /* Examine file extension */
1587  ext = strrchr (filename, '.');
1588  if ((NULL == ext) || (0 != strcmp (ext, ".conf")))
1589  {
1590  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Skipping file `%s'\n", filename);
1591  return GNUNET_OK;
1592  }
1593 
1594  return GNUNET_CONFIGURATION_parse (cfg, filename);
1595 }
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: