30#define LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__)
32#define LOG_STRERROR_FILE(kind, syscall, filename) \
33 GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
423 while ((pos != NULL) && (0 != strcasecmp (section, pos->
name)))
433 return strcmp (*((
const char **) a),
434 *((
const char **) b));
445 const char *path_or_glob,
447 const char *restrict_section,
448 const char *source_filename,
449 unsigned int source_lineno)
451 char *inline_path = NULL;
461 GNUNET_assert (! (path_is_glob && (NULL != restrict_section)));
463 if (NULL == source_filename)
466 "Refusing to parse inline configurations, "
467 "not allowed without source filename!\n");
472 if (
'/' == *path_or_glob)
479 char *source_realpath;
482 source_realpath = realpath (source_filename,
484 if (NULL == source_realpath)
492 endsep = strrchr (source_realpath,
'/');
499 free (source_realpath);
507 "processing config glob '%s'\n",
518 for (
int i = 0; i < nret; i++)
530 else if (NULL != restrict_section)
556 if (0 == stat (sfn, &istat))
558 struct passwd *pw = getpwuid (istat.st_uid);
559 struct group *gr = getgrgid (istat.st_gid);
560 pwname = (NULL == pw) ?
"<unknown>" : pw->pw_name;
561 grname = (NULL == gr) ?
"<unknown>" : gr->gr_name;
617 "Configuration file '%s' loaded with @inline-secret@ "
618 "does not contain section '%s'.\n",
649 if (NULL != other_cfg)
683 "Section '%s' is marked as inaccessible, because the configuration "
684 " file that contains the section can't be read. Attempts to use "
685 "option '%s' will fail.\n",
691 while ((pos != NULL) && (0 != strcasecmp (
key, pos->
key)))
711 unsigned int hint_line)
727 const char *source_filename)
738 char *line_orig = NULL;
744 while (r_bytes <
size)
752 to_read =
size - r_bytes;
753 pos = memchr (&mem[r_bytes],
'\n', to_read);
757 line_size = to_read);
758 r_bytes += line_size;
763 line_size = (pos - &mem[r_bytes]));
764 r_bytes += line_size + 1;
771 for (
size_t i = 0; i < line_size; i++)
785 for (
size_t i = line_size - 1;
786 (i >= 1) && (isspace ((
unsigned char)
line[i]));
791 for (;
line[0] !=
'\0' && (isspace ((
unsigned char)
line[0]));
line++)
795 if ( (
'#' ==
line[0]) ||
802 char *
end = strchr (
line + 1,
'@');
809 "Illegal directive in line %u (parsing restricted section %s)\n",
819 "Bad directive in line %u\n",
825 directive =
line + 1;
827 if (0 == strcasecmp (directive,
830 const char *path =
end + 1;
833 for (; isspace (*path); path++)
843 else if (0 == strcasecmp (directive,
846 const char *path =
end + 1;
849 for (; isspace (*path); path++)
859 else if (0 == strcasecmp (directive,
862 char *secname =
end + 1;
867 for (; isspace (*secname); secname++)
870 secname_end = strchr (secname,
' ');
872 if (NULL == secname_end)
875 "Bad inline-secret directive in line %u\n",
881 path = secname_end + 1;
884 for (; isspace (*path); path++)
897 "Unknown or malformed directive '%s' in line %u\n",
910 if ( (
'[' ==
line[0]) &&
911 (
']' ==
line[line_size - 1]) )
914 line[line_size - 1] =
'\0';
920 if (NULL != (eq = strchr (
line,
'=')))
926 "Syntax error while deserializing in line %u (option without section)\n",
935 for (
int i = strlen (tag) - 1;
936 (i >= 1) && (isspace ((
unsigned char) tag[i]));
942 while (isspace ((
unsigned char)
value[0]))
944 for (
int i = strlen (
value) - 1;
945 (i >= 1) && (isspace ((
unsigned char)
value[i]));
950 if ( (
'"' ==
value[0]) &&
975 "Syntax error while deserializing in line %u\n",
1013 for (; NULL != cf; parent = cf, cf = cf->
prev)
1016 if (cf->
level >= lvl)
1026 "Forbidden direct cyclic configuration import (%s -> %s)\n",
1032 "Forbidden indirect cyclic configuration import (%s -> ... -> %s -> %s)\n",
1062 "Error while determining the file size of `%s'\n",
1076 if ((sret < 0) || (
fs != (
size_t) sret))
1079 "Error while reading file `%s'\n",
1086 "Deserializing contents of file `%s'\n",
1095 _ (
"Failed to parse configuration file `%s'\n"),
1125 if (0 != strcasecmp (
"PATHS",
1128 return ( (0 == strcasecmp (
"DATADIR",
1130 (0 == strcasecmp (
"LIBDIR",
1132 (0 == strcasecmp (
"BINDIR",
1134 (0 == strcasecmp (
"PREFIX",
1136 (0 == strcasecmp (
"LOCALEDIR",
1138 (0 == strcasecmp (
"ICONDIR",
1140 (0 == strcasecmp (
"DOCDIR",
1142 (0 == strcasecmp (
"DEFAULTCONFIG",
1144 (0 == strcasecmp (
"LIBEXECDIR",
1166 if (sec->inaccessible)
1169 m_size += strlen (sec->name) + 3;
1177 if (NULL != ent->val)
1181 while (NULL != (pos = strstr (pos,
"\n")))
1188 m_size += strlen (ent->key) + strlen (ent->val) + 4;
1221 if (NULL != ent->val)
1224 strcpy (val, ent->val);
1225 while (NULL != (pos = strstr (val,
"\n")))
1227 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1263 const char *ipkname;
1267 ipkname =
"IPK_DATADIR";
1270 ipkname =
"IPK_BINDIR";
1273 ipkname =
"IPK_LIBDIR";
1276 ipkname =
"IPK_PREFIX";
1278 ipkname =
"IPK_LOCALEDIR";
1281 ipkname =
"IPK_ICONDIR";
1283 ipkname =
"IPK_DOCDIR";
1286 ipkname =
"IPK_LIBEXECDIR";
1289 ipkname =
"IPK_SELF_PREFIX";
1310 "#\n# Configuration file diagnostics\n#\n");
1312 "# Entry point: %s\n",
1316 "#\n# Files Loaded:\n");
1324 for (
unsigned int i = 0; i < cfil->level; i++)
1327 if (0 != cfil->level)
1333 cfil->source_filename);
1335 if (NULL != cfil->hint_restrict_section)
1337 " (%s secret section %s)",
1338 cfil->hint_inaccessible
1341 cfil->hint_restrict_section);
1348 "#\n# Installation paths:\n");
1368 if (sec->hint_secret_filename)
1370 "# secret section from %s\n# secret file stat %s\n",
1371 sec->hint_secret_filename,
1372 sec->hint_secret_stat);
1373 if (sec->hint_inlined_from_filename)
1376 "# inlined from %s:%u\n",
1377 sec->hint_inlined_from_filename,
1378 sec->hint_inlined_from_line);
1383 if (sec->inaccessible)
1386 "# <section contents inaccessible>\n\n\n");
1396 if (NULL != ent->val)
1400 strcpy (val, ent->val);
1401 while (NULL != (pos = strstr (val,
"\n")))
1403 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1407 if (NULL != ent->hint_filename)
1464 if (((ssize_t)
size) !=
1501 if (NULL != epos->val)
1512 const char *section,
1520 while ((spos != NULL) && (0 != strcasecmp (spos->
name, section)))
1527 "Section '%s' is marked as inaccessible, because the configuration "
1528 " file that contains the section can't be read.\n",
1532 for (epos = spos->
entries; NULL != epos; epos = epos->
next)
1533 if (NULL != epos->
val)
1534 iter (iter_cls, spos->
name, epos->
key, epos->
val);
1548 while (
next != NULL)
1552 iter (iter_cls, spos->
name);
1559 const char *section)
1567 while (NULL != spos)
1569 if (0 == strcasecmp (section, spos->
name))
1575 while (NULL != (ent = spos->
entries))
1608 const char *section,
1647 const char *section,
1655 if ((NULL != entNew) && (NULL != entNew->
val) &&
1656 (0 == strcmp (entNew->
val,
value)))
1701 const char *section,
1743 const char *section,
1745 unsigned long long number)
1763 const char *section,
1765 unsigned long long *
number)
1776 if (1 != sscanf (e->
val,
1787 const char *section,
1795 const locale_t cl = newlocale (LC_NUMERIC_MASK,
"C", (locale_t) 0);
1796 locale_t old_locale = uselocale (cl);
1801 uselocale (old_locale);
1812 const char *section,
1826 const locale_t cl = newlocale (LC_NUMERIC_MASK,
"C", (locale_t) 0);
1827 locale_t old_locale = uselocale (cl);
1828 if (1 != sscanf (e->
val,
1833 uselocale (old_locale);
1841 const char *section,
1860 _ (
"Not a valid relative time specification"));
1868 const char *section,
1870 unsigned long long *
size)
1898 const char *section,
1920 const char *section,
1932 for (i = 0; NULL !=
choices[i]; i++)
1938 _ (
"Configuration value '%s' for '%s'"
1939 " in section '%s' is not in set of legal choices\n"),
1952 const char *section,
1990 const char *section,
2041 "Recursive expansion suspected, aborting $-expansion for term `%s'\n",
2046 "Asked to $-expand %s\n",
2051 "Doesn't start with $ - not expanding\n");
2076 "Missing closing `}' in option `%s'\n",
2088 def = strchr (orig,
':');
2093 if ((
'-' == *def) || (
'=' == *def))
2105 while ( (orig[i] !=
'/') &&
2106 (orig[i] !=
'\\') &&
2107 (orig[i] !=
'\0') &&
2110 if (orig[i] ==
'\0')
2116 erased_char = orig[i];
2117 erased_pos = &orig[i];
2119 post = &orig[i + 1];
2123 "Split into `%s' and `%s' with default %s\n",
2145 *erased_pos = erased_char;
2147 "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n",
2157 if ((erased_pos) && (
'}' != erased_char))
2159 len = strlen (
prefix) + 1;
2161 prefix[len - 1] = erased_char;
2183 for (i = 0;
'\0' != orig[i]; i++)
2190 len = strlen (dup) + 1;
2202 const char *section,
2216 "Failed to retrieve filename\n");
2233 const char *section,
2236 static const char *yesno[] = {
2252 if (
val == yesno[0])
2261 const char *section,
2283 while (pos[0] ==
' ')
2285 if (strlen (pos) == 0)
2288 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
2296 memmove (
end, &
end[1], strlen (&
end[1]) + 1);
2311 if (strlen (pos) > 0)
2314 if ( (NULL != cb) &&
2345 memset (escaped, 0, strlen (
value) * 2 + 1);
2348 while (rpos[0] !=
'\0')
2379 const char *of = cls;
2381 return (0 == strcmp (of, fn))
2390 const char *section,
2411 if (strlen (old) > 0)
2413 strcat (nw, escaped);
2428 const char *section,
2448 while (pos[0] ==
' ')
2450 if (strlen (pos) == 0)
2453 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
2477 if (0 == strcmp (pos, match))
2482 strlen (&
end[1]) + 1);
2512 const char *defaults_d)
2525 qsort (files_context.
files,
2529 for (
unsigned int i = 0; i < files_context.
files_length; i++)
2536 if ((NULL == ext) || (0 != strcmp (ext,
".conf")))
2539 "Skipping file `%s'\n",
2552 for (
size_t i = 0; i < files_context.
files_length; i++)
2567 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
2612 const char *base_config_varname;
2629 if ((NULL != base_config_varname)
2630 && (NULL != (baseconfig =
getenv (base_config_varname))))
2665 "Failed to load base configuration from '%s'\n",
2679 "Failed to load configuration from file '%s'\n",
2686 "DEFAULTCONFIG"))) &&
2706 const char *section,
2743 const char *section,
2765 const char *section)
2778 const char *cfgfile,
2796 _ (
"Failed to load config file `%s'"),
2808 _ (
"The following sections are available:\n"));
2817 char *serialization;
2822 _ (
"%s, %s or %s argument is required\n"),
2835 else if ( (NULL != cs->
section) &&
2836 (NULL == cs->
value) )
2893 _ (
"--option argument required to set value\n"));
2906 char *cfg_fn = NULL;
2911 if (NULL == cfgfile)
2913 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
2936 _ (
"failed to load configuration defaults"));
struct GNUNET_MQ_Envelope * env
static bool do_skip(const char *sec, const char *key)
Should we skip this configuration entry when serializing?
static void print_filename_option(void *cls, const char *section, const char *option, const char *value)
Print each option in a given section as a filename.
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
static enum GNUNET_GenericReturnValue handle_inline(struct GNUNET_CONFIGURATION_Handle *cfg, const char *path_or_glob, bool path_is_glob, const char *restrict_section, const char *source_filename, unsigned int source_lineno)
Handle an inline directive.
static void print_section_name(void *cls, const char *section)
Print out given section name.
static char * escape_name(const char *value)
FIXME.
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...
static enum GNUNET_GenericReturnValue test_match(void *cls, const char *fn)
FIXME.
static struct ConfigSection * find_section(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Find a section entry from a configuration.
static int pstrcmp(const void *a, const void *b)
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...
static enum GNUNET_GenericReturnValue collect_files_cb(void *cls, const char *filename)
Function called with a filename.
static void copy_entry(void *cls, const char *section, const char *option, const char *value)
Copy a configuration value to the given target configuration.
static void print_option(void *cls, const char *section, const char *option, const char *value)
Print each option in a given section.
static void dump_os_ipk(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_Buffer *buf, enum GNUNET_OS_InstallationPathKind ipk)
Dump an os installation path to a buffer.
static void set_entry_hint(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *hint_filename, unsigned int hint_line)
Set a configuration hint.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int start
Set if we are to start default services (including ARM).
static int list
Set if we should print a list of currently running services.
static int ret
Final status code.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static int end
Set if we are to shutdown all services (including ARM).
static int prefix
If printing the value of PREFIX has been requested.
static char * line
Desired phone line (string to be converted to a hash).
struct GNUNET_HashCode key
The key used in the DHT.
static void cleanup(void *cls)
Disconnect and shutdown.
static struct GNUNET_FS_Handle * fs
Handle to FS service.
static OpusEncoder * enc
OPUS encoder.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
static size_t data_size
Number of bytes in data.
static int result
Global testing status.
static struct GNUNET_OS_Process * p
Helper process we started.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
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.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_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.
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.
void GNUNET_CONFIGURATION_remove_section(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Remove the given section and all options in it.
enum GNUNET_GenericReturnValue(* GNUNET_CONFIGURATION_Callback)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Signature of a function to be run with a configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls)
Iterate over all sections in the configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_CONFIGURATION_config_settings_free(struct GNUNET_CONFIGURATION_ConfigSettings *cs)
Free resources associated with cs.
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_remove_value_filename(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Remove a filename from a configuration value that represents a list of filenames.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse_and_run(const struct GNUNET_OS_ProjectData *pd, const char *filename, GNUNET_CONFIGURATION_Callback cb, void *cb_cls)
Parse a configuration file filename and run the function cb with the resulting configuration object.
void GNUNET_CONFIGURATION_config_tool_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main task to run to perform operations typical for gnunet-config as per the configuration settings gi...
void(* GNUNET_CONFIGURATION_SectionIterator)(void *cls, const char *section)
Function to iterate over section.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename)
De-serializes configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_size(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *size)
Get a configuration value that should be a size in bytes.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_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".
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
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.
char * GNUNET_CONFIGURATION_default_filename(const struct GNUNET_OS_ProjectData *pd)
Return the filename of the default configuration filename that is used when no explicit configuration...
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...
void GNUNET_CONFIGURATION_set_value_float(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float number)
Set a configuration value that should be a float.
const struct GNUNET_OS_ProjectData * GNUNET_CONFIGURATION_get_project_data(const struct GNUNET_CONFIGURATION_Handle *cfg)
Return the project data associated with this configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_get_diff(const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new)
Compute configuration with only entries that have been changed.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Parse a configuration file, add all of the options in the file to the configuration environment.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_float(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number)
Get a configuration value that should be a floating point number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load_from(struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
Load default configuration.
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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_choice(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *const *choices, const char **value)
Get a configuration value that should be in a set of predefined strings.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
void(* GNUNET_CONFIGURATION_Iterator)(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options.
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write_diffs(const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new, const char *filename)
Write only configuration entries that have been changed to configuration file.
char * GNUNET_CONFIGURATION_serialize_diagnostics(const struct GNUNET_CONFIGURATION_Handle *cfg)
Serializes the given configuration with diagnostics information.
void GNUNET_CONFIGURATION_enable_diagnostics(struct GNUNET_CONFIGURATION_Handle *cfg)
Enable extra diagnostics.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
int GNUNET_DISK_glob(const char *glob_pattern, GNUNET_FileNameCallback callback, void *callback_cls)
Find all files matching a glob pattern.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test_read(const char *fil)
Check that fil corresponds to a filename and the file has read permissions.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_GROUP_WRITE
Group can write.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
enum GNUNET_GenericReturnValue(* GNUNET_FileNameCallback)(void *cls, const char *filename)
Function called with a filename.
#define GNUNET_log(kind,...)
char * GNUNET_buffer_reap_str(struct GNUNET_Buffer *buf)
Clear the buffer and return the string it contained.
void GNUNET_buffer_write_fstr(struct GNUNET_Buffer *buf, const char *fmt,...) __attribute__((format(printf
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator.
void GNUNET_buffer_write_str(struct GNUNET_Buffer *buf, const char *str)
Write a 0-terminated string to a buffer, excluding the 0-terminator.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_OS_installation_get_path(const struct GNUNET_OS_ProjectData *pd, enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
GNUNET_OS_InstallationPathKind
Possible installation paths to request.
@ GNUNET_OS_IPK_SELF_PREFIX
Return the installation directory of this application, not the one of the overall GNUnet installation...
@ GNUNET_OS_IPK_ICONDIR
Return the prefix of the path with application icons (share/icons/).
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
@ GNUNET_OS_IPK_DOCDIR
Return the prefix of the path with documentation files, including the license (share/doc/gnunet/).
@ GNUNET_OS_IPK_LOCALEDIR
Return the directory where translations are installed (share/locale/)
@ GNUNET_OS_IPK_LIBDIR
Return the directory where libraries are installed.
@ GNUNET_OS_IPK_PREFIX
Return the "PREFIX" directory given to configure.
@ GNUNET_OS_IPK_BINDIR
Return the directory where the program binaries are installed.
@ GNUNET_OS_IPK_LIBEXECDIR
Return the directory where helper binaries are installed (lib/gnunet/libexec/)
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
static unsigned int size
Size of the "table".
Closure to collect_files_cb.
char ** files
Collected files from globbing.
unsigned int files_length
Size of the files array.
char * hint_filename
Diagnostics information for the filename.
struct ConfigEntry * next
This is a linked list.
char * key
key for this entry
unsigned int hint_lineno
Diagnostics information for the line number.
char * val
current, committed value
char * hint_restrict_section
Was this configuration file parsed via @inline-secret@?
char * source_filename
Source filename.
bool hint_inaccessible
Was this configuration file inaccessible?
unsigned int level
Level in the tree of loaded config files.
char * name
name of the section
char * hint_inlined_from_filename
For secret sections: Where was this inlined from?
struct ConfigEntry * entries
entries in the section
bool inaccessible
Is the configuration section marked as inaccessible?
struct ConfigSection * next
This is a linked list.
char * hint_secret_filename
Diagnostics hint for the secret file.
unsigned int hint_inlined_from_line
For secret sections: Where was this inlined from?
char * hint_secret_stat
Extra information regarding permissions of the secret file.
Used for diffing a configuration object against the default one.
const struct GNUNET_CONFIGURATION_Handle * cfg_default
struct GNUNET_CONFIGURATION_Handle * cfgDiff
Dynamically growing buffer.
Closure for GNUNET_CONFIGURATION_config_tool_run() with settings for what should be done with the con...
char * value
Value to set.
int full
Should the generated configuration file contain the whole configuration?
int global_ret
Return value from the operation, to be returned from 'main'.
int diagnostics
Should we give extra diagnostics?
int list_sections
Whether to show the sections.
int rewrite
Should we write out the configuration file, even if no value was changed?
char * option
Name of the option.
char * section
Name of the section.
int is_filename
Treat option as a filename.
struct ConfigFile * loaded_files_tail
Linked list of loaded files.
bool load_called
Was the configuration ever loaded via GNUNET_CONFIGURATION_load?
unsigned int current_nest_level
Current nesting level of file loading.
const struct GNUNET_OS_ProjectData * pd
Project data for this configuration object.
struct ConfigSection * sections
Configuration sections.
struct ConfigFile * loaded_files_head
Linked list of loaded files.
char * main_filename
Name of the entry point configuration file.
enum GNUNET_GenericReturnValue dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
bool diagnostics
Enable diagnostics.
const char * restrict_section
When parsing into this configuration, and this value is non-NULL, only parse sections of the same nam...
Handle used to access files (and pipes).
Project-specific data used to help the OS subsystem find installation paths.
const char * base_config_varname
Name of an environment variable that can be used to override the location from which default configur...
const char * project_dirname
Name of the project that is used in the "libexec" prefix, For example, "gnunet".
const char * user_config_file
Configuration file name to use (if $XDG_CONFIG_HOME is not set).
const char * config_file
Configuration file name (in $XDG_CONFIG_HOME) to use.
Time for relative time used by GNUnet, in microseconds.