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)
454 while ( (NULL != pos) &&
455 (0 != strcasecmp (section,
466 return strcmp (*((
const char **) a),
467 *((
const char **) b));
484 const char *path_or_glob,
486 const char *restrict_section,
487 const char *source_filename,
488 unsigned int source_lineno)
490 char *inline_path = NULL;
500 GNUNET_assert (! (path_is_glob && (NULL != restrict_section)));
502 if (NULL == source_filename)
505 "Refusing to parse inline configurations, "
506 "not allowed without source filename!\n");
511 if (
'/' == *path_or_glob)
518 char *source_realpath;
521 source_realpath = realpath (source_filename,
523 if (NULL == source_realpath)
531 endsep = strrchr (source_realpath,
'/');
538 free (source_realpath);
546 "processing config glob '%s'\n",
562 for (
int i = 0; i < nret; i++)
574 else if (NULL != restrict_section)
600 if (0 == stat (sfn, &istat))
602 struct passwd *pw = getpwuid (istat.st_uid);
603 struct group *gr = getgrgid (istat.st_gid);
604 pwname = (NULL == pw) ?
"<unknown>" : pw->pw_name;
605 grname = (NULL == gr) ?
"<unknown>" : gr->gr_name;
663 "Configuration file '%s' loaded with @inline-secret@ "
664 "does not contain section '%s'.\n",
694 if (NULL != other_cfg)
728 if (0 == strcasecmp (
key,
734 "Section '%s' is marked as inaccessible, because the configuration "
735 "file that contains the section can't be read. Attempts to use "
736 "option '%s' will fail.\n",
818 copy->
lineno = pos->lineno;
834 const char *source_filename)
845 char *line_orig = NULL;
851 while (r_bytes <
size)
859 to_read =
size - r_bytes;
860 pos = memchr (&mem[r_bytes],
'\n', to_read);
864 line_size = to_read);
865 r_bytes += line_size;
870 line_size = (pos - &mem[r_bytes]));
871 r_bytes += line_size + 1;
878 for (
size_t i = 0; i < line_size; i++)
892 for (
size_t i = line_size - 1;
893 (i >= 1) && (isspace ((
unsigned char)
line[i]));
898 for (;
line[0] !=
'\0' && (isspace ((
unsigned char)
line[0]));
line++)
902 if ( (
'#' ==
line[0]) ||
909 char *
end = strchr (
line + 1,
'@');
916 "Illegal directive in line %u (parsing restricted section %s)\n",
926 "Bad directive in line %u\n",
932 directive =
line + 1;
934 if (0 == strcasecmp (directive,
937 const char *path =
end + 1;
940 for (; isspace (*path); path++)
950 else if (0 == strcasecmp (directive,
953 const char *path =
end + 1;
956 for (; isspace (*path); path++)
966 else if (0 == strcasecmp (directive,
969 char *secname =
end + 1;
974 for (; isspace (*secname); secname++)
977 secname_end = strchr (secname,
' ');
979 if (NULL == secname_end)
982 "Bad inline-secret directive in line %u\n",
988 path = secname_end + 1;
991 for (; isspace (*path); path++)
1004 "Unknown or malformed directive '%s' in line %u\n",
1012 ret = directive_ret;
1017 if ( (
'[' ==
line[0]) &&
1018 (
']' ==
line[line_size - 1]) )
1021 line[line_size - 1] =
'\0';
1027 if (NULL != (eq = strchr (
line,
'=')))
1030 if (NULL == section)
1033 "Syntax error while deserializing in line %u (option without section)\n",
1042 for (
int i = strlen (tag) - 1;
1043 (i >= 1) && (isspace ((
unsigned char) tag[i]));
1049 while (isspace ((
unsigned char)
value[0]))
1051 for (
int i = strlen (
value) - 1;
1052 (i >= 1) && (isspace ((
unsigned char)
value[i]));
1057 if ( (
'"' ==
value[0]) &&
1083 "Syntax error while deserializing in line %u\n",
1091 (r_bytes ==
size) );
1111 "Asked to parse config file `%s'\n",
1124 for (; NULL != cf; parent = cf, cf = cf->
prev)
1127 if (cf->
level >= lvl)
1139 "Forbidden direct cyclic configuration import (%s -> %s)\n",
1145 "Forbidden indirect cyclic configuration import (%s -> ... -> %s -> %s)\n",
1177 "Error while determining the file size of `%s'\n",
1193 if ((sret < 0) || (
fs != (
size_t) sret))
1196 "Error while reading file `%s'\n",
1209 "Deserializing contents of file `%s'\n",
1218 _ (
"Failed to parse configuration file `%s'\n"),
1252 if (0 != strcasecmp (
"PATHS",
1255 return ( (0 == strcasecmp (
"DATADIR",
1257 (0 == strcasecmp (
"LIBDIR",
1259 (0 == strcasecmp (
"BINDIR",
1261 (0 == strcasecmp (
"PREFIX",
1263 (0 == strcasecmp (
"LOCALEDIR",
1265 (0 == strcasecmp (
"ICONDIR",
1267 (0 == strcasecmp (
"DOCDIR",
1269 (0 == strcasecmp (
"DEFAULTCONFIG",
1271 (0 == strcasecmp (
"LIBEXECDIR",
1293 if (sec->inaccessible && (NULL == sec->entries))
1296 m_size += strlen (sec->name) + 3;
1304 if (NULL != ent->val)
1308 while (NULL != (pos = strstr (pos,
"\n")))
1315 m_size += strlen (ent->key) + strlen (ent->val) + 4;
1348 if (NULL != ent->val)
1351 strcpy (val, ent->val);
1352 while (NULL != (pos = strstr (val,
"\n")))
1354 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1390 const char *ipkname;
1394 ipkname =
"IPK_DATADIR";
1397 ipkname =
"IPK_BINDIR";
1400 ipkname =
"IPK_LIBDIR";
1403 ipkname =
"IPK_PREFIX";
1405 ipkname =
"IPK_LOCALEDIR";
1408 ipkname =
"IPK_ICONDIR";
1410 ipkname =
"IPK_DOCDIR";
1413 ipkname =
"IPK_LIBEXECDIR";
1416 ipkname =
"IPK_SELF_PREFIX";
1444 "#\n# Configuration file diagnostics\n#\n");
1446 "# Entry point: %s\n",
1450 "#\n# Files Loaded:\n");
1458 for (
unsigned int i = 0; i < cfil->level; i++)
1461 if (0 != cfil->level)
1467 cfil->source_filename);
1469 if (NULL != cfil->hint_restrict_section)
1471 " (%s secret section %s)",
1472 cfil->hint_inaccessible
1475 cfil->hint_restrict_section);
1482 "#\n# Installation paths:\n");
1502 if (sec->hint_secret_filename)
1504 "# secret section from %s\n# secret file stat %s\n",
1505 sec->hint_secret_filename,
1506 sec->hint_secret_stat);
1507 if (sec->hint_inlined_from_filename)
1510 "# inlined from %s:%u\n",
1511 sec->hint_inlined_from_filename,
1512 sec->hint_inlined_from_line);
1517 if (sec->inaccessible && (NULL == sec->entries))
1520 "# <section contents inaccessible>\n\n\n");
1530 if (NULL != ent->val)
1534 strcpy (val, ent->val);
1535 while (NULL != (pos = strstr (val,
"\n")))
1537 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1541 if (NULL != ent->sources)
1544 (NULL != ent->sources->next))
1548 "# duplicate definitions (highest precedence first):\n");
1555 if (
source == ent->sources)
1557 else if (0 == strcmp (
source->value,
1561 status =
"different value";
1574 ent->sources->filename,
1575 ent->sources->lineno);
1586 if (sec->inaccessible)
1589 "# <additional section contents inaccessible>\n\n\n");
1632 *
size = (size_t) fs64;
1686 const char *contents,
1704 char *rfn = realpath (fn,
1723 (
unsigned int) getpid ());
1741 if (((ssize_t)
size) !=
1750 (void) unlink (tfn);
1763 (void) unlink (tfn);
1773 (void) unlink (tfn);
1784 if ( (0 == stat (fn,
1787 sbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) )
1792 if ( (NULL != expected_hash) &&
1797 "Configuration file `%s' changed while it was being cleaned\n",
1799 (void) unlink (tfn);
1804 if (0 != rename (tfn,
1810 (void) unlink (tfn);
1859 unsigned int lines_length,
1862 for (
unsigned int i = 0; i < lines_length; i++)
1876 unsigned int lines_length)
1880 if (0 != strcmp (
source->filename,
1886 return (NULL !=
line) &&
line->remove;
1914 unsigned int *removed)
1917 unsigned int lines_length = 0;
1920 char *contents = NULL;
1921 char *cleaned = NULL;
1923 size_t cleaned_size = 0;
1926 if (NULL != removed)
1941 if (! cf->have_content_hash)
1950 if (NULL == parsed_file)
1953 "Configuration file `%s' was not parsed with diagnostics enabled\n",
1962 "Configuration file `%s' changed since it was parsed\n",
1976 "Configuration file `%s' changed since it was parsed\n",
1987 for (
const struct ConfigEntry *ent = sec->entries;
1994 bool duplicate =
false;
1997 if (0 != strcmp (
source->filename,
2002 other = other->next)
2004 if ( (0 == strcmp (
source->value,
2006 ( (
source->lineno != other->lineno) ||
2007 (0 != strcmp (
source->filename,
2008 other->filename)) ) )
2014 if ( (! duplicate) ||
2020 line.option = ent->key;
2033 for (
const struct ConfigEntry *ent = sec->entries;
2050 if ( (NULL != survivor) &&
2051 (0 == strcmp (survivor->
value,
2060 if ( (0 != strcmp (
source->filename,
2062 (0 != strcmp (
source->value,
2068 if ( (NULL !=
line) &&
line->remove)
2070 line->remove =
false;
2076 if (lines_length > 1)
2082 unsigned int remove_count = 0;
2084 for (
unsigned int i = 0; i < lines_length; i++)
2087 if (0 == remove_count)
2089 if (NULL != removed)
2096 for (
size_t offset = 0, line_number = 1; offset <
size; line_number++)
2098 size_t end = offset;
2101 while ( (
end <
size) && (
'\n' != contents[
end]) )
2107 (
unsigned int) line_number);
2108 if ( (NULL ==
line) || (!
line->remove) )
2113 cleaned_size +=
end - offset;
2123 if (NULL != removed)
2124 *removed = remove_count;
2126 for (
unsigned int i = 0; i < lines_length; i++)
2158 if (NULL != epos->val)
2176 while ((spos != NULL) && (0 != strcasecmp (spos->
name, section)))
2183 if (NULL != epos->val)
2191 "Section '%s' is marked as inaccessible, because a configuration "
2192 "file that contains the section can't be read.\n",
2209 while (NULL !=
next)
2223 const char *section)
2231 while (NULL != spos)
2233 if (0 == strcasecmp (section,
2240 while (NULL != (ent = spos->
entries))
2281 const char *section,
2320 const char *section,
2328 if ((NULL != entNew) && (NULL != entNew->
val) &&
2329 (0 == strcmp (entNew->
val,
value)))
2374 const char *section,
2416 const char *section,
2418 unsigned long long number)
2436 const char *section,
2438 unsigned long long *
number)
2449 if (1 != sscanf (e->
val,
2460 const char *section,
2467 const locale_t cl = newlocale (LC_NUMERIC_MASK,
2470 locale_t old_locale = uselocale (cl);
2475 uselocale (old_locale);
2486 const char *section,
2501 const locale_t cl = newlocale (LC_NUMERIC_MASK,
2504 locale_t old_locale = uselocale (cl);
2506 if (1 != sscanf (e->
val,
2511 uselocale (old_locale);
2520 const char *section,
2539 _ (
"Not a valid relative time specification"));
2547 const char *section,
2549 unsigned long long *
size)
2577 const char *section,
2599 const char *section,
2601 const char *
const *choices,
2611 for (i = 0; NULL != choices[i]; i++)
2612 if (0 == strcasecmp (choices[i], e->
val))
2614 if (NULL == choices[i])
2617 _ (
"Configuration value '%s' for '%s'"
2618 " in section '%s' is not in set of legal choices\n"),
2624 *
value = choices[i];
2631 const char *section,
2669 const char *section,
2720 "Recursive expansion suspected, aborting $-expansion for term `%s'\n",
2725 "Asked to $-expand %s\n",
2730 "Doesn't start with $ - not expanding\n");
2755 "Missing closing `}' in option `%s'\n",
2767 def = strchr (orig,
':');
2772 if ((
'-' == *def) || (
'=' == *def))
2784 while ( (orig[i] !=
'/') &&
2785 (orig[i] !=
'\\') &&
2786 (orig[i] !=
'\0') &&
2789 if (orig[i] ==
'\0')
2795 erased_char = orig[i];
2796 erased_pos = &orig[i];
2798 post = &orig[i + 1];
2802 "Split into `%s' and `%s' with default %s\n",
2824 *erased_pos = erased_char;
2826 "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n",
2836 if ((erased_pos) && (
'}' != erased_char))
2838 len = strlen (
prefix) + 1;
2840 prefix[len - 1] = erased_char;
2862 for (i = 0;
'\0' != orig[i]; i++)
2869 len = strlen (dup) + 1;
2881 const char *section,
2895 "Failed to retrieve filename\n");
2912 const char *section,
2915 static const char *yesno[] = {
2931 if (
val == yesno[0])
2940 const char *section,
2962 while (pos[0] ==
' ')
2964 if (strlen (pos) == 0)
2967 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
2975 memmove (
end, &
end[1], strlen (&
end[1]) + 1);
2990 if (strlen (pos) > 0)
2993 if ( (NULL != cb) &&
3024 memset (escaped, 0, strlen (
value) * 2 + 1);
3027 while (rpos[0] !=
'\0')
3059 const char *of = cls;
3061 return (0 == strcmp (of, fn))
3070 const char *section,
3091 if (strlen (old) > 0)
3093 strcat (nw, escaped);
3108 const char *section,
3128 while (pos[0] ==
' ')
3130 if (strlen (pos) == 0)
3133 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
3157 if (0 == strcmp (pos, match))
3162 strlen (&
end[1]) + 1);
3192 const char *defaults_d)
3205 qsort (files_context.
files,
3209 for (
unsigned int i = 0; i < files_context.
files_length; i++)
3216 if ( (NULL == ext) ||
3221 "Skipping file `%s'\n",
3233 for (
size_t i = 0; i < files_context.
files_length; i++)
3248 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
3293 const char *base_config_varname;
3310 if ((NULL != base_config_varname)
3311 && (NULL != (baseconfig =
getenv (base_config_varname))))
3346 "Failed to load base configuration from '%s'\n",
3360 "Failed to load configuration from file '%s'\n",
3367 "DEFAULTCONFIG"))) &&
3387 const char *section,
3424 const char *section,
3446 const char *section)
3459 const char *cfgfile,
3478 _ (
"Failed to load config file `%s'"),
3490 _ (
"The following sections are available:\n"));
3499 char *serialization;
3504 _ (
"%s, %s or %s argument is required\n"),
3519 else if ( (NULL != cs->
section) &&
3520 (NULL == cs->
value) )
3577 _ (
"--option argument required to set value\n"));
3590 char *cfg_fn = NULL;
3595 if (NULL == cfgfile)
3597 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
3620 _ (
"failed to load configuration defaults"));
3673 const char *progname)
3676 char *binary = NULL;
3695 if ( (NULL == path) ||
3696 (0 == strlen (path)) )
3704 path_len = strlen (path);
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 bool source_is_removed(const struct ConfigSource *source, const char *target, struct CleanLine *lines, unsigned int lines_length)
Return whether a source is a target line currently marked for removal.
static struct CleanLine * find_clean_line(struct CleanLine *lines, unsigned int lines_length, unsigned int line)
Find a cleanup record for a physical line.
static int clean_line_cmp(const void *a, const void *b)
Sort cleanup records by source line.
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 enum GNUNET_GenericReturnValue read_file(const char *filename, char **contents, size_t *size)
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 void add_entry_source(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value, const char *filename, unsigned int line)
Record the source of a configuration value.
static char * serialize_diagnostics(const struct GNUNET_CONFIGURATION_Handle *cfg, bool verbose)
Serialize configuration diagnostics.
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 enum GNUNET_GenericReturnValue write_buffer_atomic(const char *filename, const char *contents, size_t size, const struct GNUNET_HashCode *expected_hash)
Atomically replace a file with the given bytes.
static void copy_entry_with_sources(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const struct ConfigEntry *entry)
Copy an entry parsed through an @inline-secret@ directive, including all diagnostic source informatio...
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 bool file_hash_matches(const char *filename, const struct GNUNET_HashCode *expected)
Check that a file still has the expected contents.
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 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).
static unsigned int verbose
Be verbose.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * fs
Handle to FS service.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
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 status
The program status; 0 for success.
static int result
Global testing status.
static void cleanup()
Cleanup task.
static struct GNUNET_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.
char * GNUNET_CONFIGURATION_get_suid_binary_path(const struct GNUNET_OS_ProjectData *pd, const struct GNUNET_CONFIGURATION_Handle *cfg, const char *progname)
Given the name of a helper, service or daemon binary construct the full path to the binary using the ...
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 all configuration sections.
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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_clean_file(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename, GNUNET_CONFIGURATION_CleanCallback cb, void *cb_cls, unsigned int *removed)
Remove redundant option definitions from a parsed configuration file.
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.
char * GNUNET_CONFIGURATION_serialize_diagnostics_verbose(const struct GNUNET_CONFIGURATION_Handle *cfg)
Serializes the given configuration with verbose diagnostics information, including all source definit...
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.
void(* GNUNET_CONFIGURATION_CleanCallback)(void *cls, const char *section, const char *option, unsigned int line)
Function called for each duplicate definition removed by GNUNET_CONFIGURATION_clean_file().
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_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
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.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
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.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
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.
char * GNUNET_OS_get_libexec_binary_path(const struct GNUNET_OS_ProjectData *pd, const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
@ 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_path_is_absolute(const char *filename, int can_be_uri, int *r_is_uri, char **r_uri_scheme)
Check whether filename is absolute or not, and if it's an URI.
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".
One physical assignment line considered for removal.
Closure to collect_files_cb.
char ** files
Collected files from globbing.
unsigned int files_length
Size of the files array.
struct ConfigEntry * next
This is a linked list.
char * key
key for this entry
struct ConfigSource * sources
Source definitions retained for diagnostics.
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?
bool have_content_hash
Whether content_hash is available.
unsigned int level
Level in the tree of loaded config files.
struct GNUNET_HashCode content_hash
Hash of the file contents seen while parsing.
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.
source location of a configuration value
char * value
Value as normalized by the configuration parser.
unsigned int lineno
Line containing the definition.
char * filename
Filename containing the definition.
struct ConfigSource * next
Sources are ordered from highest to lowest precedence.
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 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.
unsigned int diagnostics
Diagnostics verbosity.
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.