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;
876 if (strlen (line_orig) != line_size)
879 "NUL byte in line %u\n",
886 for (
size_t i = 0; i < line_size; i++)
900 for (
size_t i = line_size - 1;
901 (i >= 1) && (isspace ((
unsigned char)
line[i]));
906 for (;
line[0] !=
'\0' && (isspace ((
unsigned char)
line[0]));
line++)
908 line_size = strlen (
line);
911 if ( (
'#' ==
line[0]) ||
918 char *
end = strchr (
line + 1,
'@');
925 "Illegal directive in line %u (parsing restricted section %s)\n",
935 "Bad directive in line %u\n",
941 directive =
line + 1;
943 if (0 == strcasecmp (directive,
946 const char *path =
end + 1;
949 for (; isspace (*path); path++)
959 else if (0 == strcasecmp (directive,
962 const char *path =
end + 1;
965 for (; isspace (*path); path++)
975 else if (0 == strcasecmp (directive,
978 char *secname =
end + 1;
983 for (; isspace (*secname); secname++)
986 secname_end = strchr (secname,
' ');
988 if (NULL == secname_end)
991 "Bad inline-secret directive in line %u\n",
997 path = secname_end + 1;
1000 for (; isspace (*path); path++)
1013 "Unknown or malformed directive '%s' in line %u\n",
1021 ret = directive_ret;
1026 if ( (
'[' ==
line[0]) &&
1027 (
']' ==
line[line_size - 1]) )
1030 line[line_size - 1] =
'\0';
1036 if (NULL != (eq = strchr (
line,
'=')))
1039 if (NULL == section)
1042 "Syntax error while deserializing in line %u (option without section)\n",
1051 for (
int i = strlen (tag) - 1;
1052 (i >= 1) && (isspace ((
unsigned char) tag[i]));
1058 while (isspace ((
unsigned char)
value[0]))
1060 for (
int i = strlen (
value) - 1;
1061 (i >= 1) && (isspace ((
unsigned char)
value[i]));
1066 if ( (
'"' ==
value[0]) &&
1092 "Syntax error while deserializing in line %u\n",
1100 (r_bytes ==
size) );
1120 "Asked to parse config file `%s'\n",
1133 for (; NULL != cf; parent = cf, cf = cf->
prev)
1136 if (cf->
level >= lvl)
1148 "Forbidden direct cyclic configuration import (%s -> %s)\n",
1154 "Forbidden indirect cyclic configuration import (%s -> ... -> %s -> %s)\n",
1186 "Error while determining the file size of `%s'\n",
1202 if ((sret < 0) || (
fs != (
size_t) sret))
1205 "Error while reading file `%s'\n",
1218 "Deserializing contents of file `%s'\n",
1227 _ (
"Failed to parse configuration file `%s'\n"),
1261 if (0 != strcasecmp (
"PATHS",
1264 return ( (0 == strcasecmp (
"DATADIR",
1266 (0 == strcasecmp (
"LIBDIR",
1268 (0 == strcasecmp (
"BINDIR",
1270 (0 == strcasecmp (
"PREFIX",
1272 (0 == strcasecmp (
"LOCALEDIR",
1274 (0 == strcasecmp (
"ICONDIR",
1276 (0 == strcasecmp (
"DOCDIR",
1278 (0 == strcasecmp (
"DEFAULTCONFIG",
1280 (0 == strcasecmp (
"LIBEXECDIR",
1302 if (sec->inaccessible && (NULL == sec->entries))
1305 m_size += strlen (sec->name) + 3;
1313 if (NULL != ent->val)
1317 while (NULL != (pos = strstr (pos,
"\n")))
1324 m_size += strlen (ent->key) + strlen (ent->val) + 4;
1342 if (sec->inaccessible && (NULL == sec->entries))
1360 if (NULL != ent->val)
1363 strcpy (val, ent->val);
1364 while (NULL != (pos = strstr (val,
"\n")))
1366 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1402 const char *ipkname;
1406 ipkname =
"IPK_DATADIR";
1409 ipkname =
"IPK_BINDIR";
1412 ipkname =
"IPK_LIBDIR";
1415 ipkname =
"IPK_PREFIX";
1417 ipkname =
"IPK_LOCALEDIR";
1420 ipkname =
"IPK_ICONDIR";
1422 ipkname =
"IPK_DOCDIR";
1425 ipkname =
"IPK_LIBEXECDIR";
1428 ipkname =
"IPK_SELF_PREFIX";
1456 "#\n# Configuration file diagnostics\n#\n");
1458 "# Entry point: %s\n",
1462 "#\n# Files Loaded:\n");
1470 for (
unsigned int i = 0; i < cfil->level; i++)
1473 if (0 != cfil->level)
1479 cfil->source_filename);
1481 if (NULL != cfil->hint_restrict_section)
1483 " (%s secret section %s)",
1484 cfil->hint_inaccessible
1487 cfil->hint_restrict_section);
1494 "#\n# Installation paths:\n");
1514 if (sec->hint_secret_filename)
1516 "# secret section from %s\n# secret file stat %s\n",
1517 sec->hint_secret_filename,
1518 sec->hint_secret_stat);
1519 if (sec->hint_inlined_from_filename)
1522 "# inlined from %s:%u\n",
1523 sec->hint_inlined_from_filename,
1524 sec->hint_inlined_from_line);
1529 if (sec->inaccessible && (NULL == sec->entries))
1532 "# <section contents inaccessible>\n\n\n");
1542 if (NULL != ent->val)
1546 strcpy (val, ent->val);
1547 while (NULL != (pos = strstr (val,
"\n")))
1549 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1553 if (NULL != ent->sources)
1556 (NULL != ent->sources->next))
1560 "# duplicate definitions (highest precedence first):\n");
1567 if (
source == ent->sources)
1569 else if (0 == strcmp (
source->value,
1573 status =
"different value";
1586 ent->sources->filename,
1587 ent->sources->lineno);
1598 if (sec->inaccessible)
1601 "# <additional section contents inaccessible>\n\n\n");
1644 *
size = (size_t) fs64;
1698 const char *contents,
1716 char *rfn = realpath (fn,
1735 (
unsigned int) getpid ());
1753 if (((ssize_t)
size) !=
1762 (void) unlink (tfn);
1775 (void) unlink (tfn);
1785 (void) unlink (tfn);
1796 if ( (0 == stat (fn,
1799 sbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO))) )
1804 if ( (NULL != expected_hash) &&
1809 "Configuration file `%s' changed while it was being cleaned\n",
1811 (void) unlink (tfn);
1816 if (0 != rename (tfn,
1822 (void) unlink (tfn);
1871 unsigned int lines_length,
1874 for (
unsigned int i = 0; i < lines_length; i++)
1888 unsigned int lines_length)
1892 if (0 != strcmp (
source->filename,
1898 return (NULL !=
line) &&
line->remove;
1926 unsigned int *removed)
1929 unsigned int lines_length = 0;
1932 char *contents = NULL;
1933 char *cleaned = NULL;
1935 size_t cleaned_size = 0;
1938 if (NULL != removed)
1953 if (! cf->have_content_hash)
1962 if (NULL == parsed_file)
1965 "Configuration file `%s' was not parsed with diagnostics enabled\n",
1974 "Configuration file `%s' changed since it was parsed\n",
1988 "Configuration file `%s' changed since it was parsed\n",
1999 for (
const struct ConfigEntry *ent = sec->entries;
2006 bool duplicate =
false;
2009 if (0 != strcmp (
source->filename,
2014 other = other->next)
2016 if ( (0 == strcmp (
source->value,
2018 ( (
source->lineno != other->lineno) ||
2019 (0 != strcmp (
source->filename,
2020 other->filename)) ) )
2026 if ( (! duplicate) ||
2032 line.option = ent->key;
2045 for (
const struct ConfigEntry *ent = sec->entries;
2062 if ( (NULL != survivor) &&
2063 (0 == strcmp (survivor->
value,
2072 if ( (0 != strcmp (
source->filename,
2074 (0 != strcmp (
source->value,
2080 if ( (NULL !=
line) &&
line->remove)
2082 line->remove =
false;
2088 if (lines_length > 1)
2094 unsigned int remove_count = 0;
2096 for (
unsigned int i = 0; i < lines_length; i++)
2099 if (0 == remove_count)
2101 if (NULL != removed)
2108 for (
size_t offset = 0, line_number = 1; offset <
size; line_number++)
2110 size_t end = offset;
2113 while ( (
end <
size) && (
'\n' != contents[
end]) )
2119 (
unsigned int) line_number);
2120 if ( (NULL ==
line) || (!
line->remove) )
2125 cleaned_size +=
end - offset;
2135 if (NULL != removed)
2136 *removed = remove_count;
2138 for (
unsigned int i = 0; i < lines_length; i++)
2170 if (NULL != epos->val)
2188 while ((spos != NULL) && (0 != strcasecmp (spos->
name, section)))
2195 if (NULL != epos->val)
2203 "Section '%s' is marked as inaccessible, because a configuration "
2204 "file that contains the section can't be read.\n",
2221 while (NULL !=
next)
2235 const char *section)
2243 while (NULL != spos)
2245 if (0 == strcasecmp (section,
2252 while (NULL != (ent = spos->
entries))
2293 const char *section,
2332 const char *section,
2340 if ((NULL != entNew) && (NULL != entNew->
val) &&
2341 (0 == strcmp (entNew->
val,
value)))
2386 const char *section,
2428 const char *section,
2430 unsigned long long number)
2448 const char *section,
2450 unsigned long long *
number)
2461 if (1 != sscanf (e->
val,
2472 const char *section,
2479 const locale_t cl = newlocale (LC_NUMERIC_MASK,
2482 locale_t old_locale;
2485 old_locale = uselocale (cl);
2490 uselocale (old_locale);
2502 const char *section,
2517 const locale_t cl = newlocale (LC_NUMERIC_MASK,
2520 locale_t old_locale;
2524 old_locale = uselocale (cl);
2529 uselocale (old_locale);
2541 const char *section,
2560 _ (
"Not a valid relative time specification"));
2568 const char *section,
2570 unsigned long long *
size)
2598 const char *section,
2620 const char *section,
2622 const char *
const *choices,
2632 for (i = 0; NULL != choices[i]; i++)
2633 if (0 == strcasecmp (choices[i], e->
val))
2635 if (NULL == choices[i])
2638 _ (
"Configuration value '%s' for '%s'"
2639 " in section '%s' is not in set of legal choices\n"),
2645 *
value = choices[i];
2652 const char *section,
2690 const char *section,
2767 bool recursive =
false;
2776 "Recursive expansion suspected, aborting $-expansion for term `%s'\n",
2781 "Asked to $-expand %s\n",
2786 "Doesn't start with $ - not expanding\n");
2811 "Missing closing `}' in option `%s'\n",
2823 def = strchr (orig,
':');
2828 if ((
'-' == *def) || (
'=' == *def))
2840 while ( (orig[i] !=
'/') &&
2841 (orig[i] !=
'\\') &&
2842 (orig[i] !=
'\0') &&
2845 if (orig[i] ==
'\0')
2851 erased_char = orig[i];
2852 erased_pos = &orig[i];
2854 post = &orig[i + 1];
2858 "Split into `%s' and `%s' with default %s\n",
2866 if (0 == strcmp (pos->name,
2870 "The definition of `%s' refers to itself, not expanding it\n",
2898 *erased_pos = erased_char;
2900 "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n",
2913 if ((erased_pos) && (
'}' != erased_char))
2915 len = strlen (
prefix) + 1;
2917 prefix[len - 1] = erased_char;
2950 while (
'\0' != orig[i])
2960 len = strlen (dup) + 1;
2986 const char *section,
3000 "Failed to retrieve filename\n");
3017 const char *section,
3020 static const char *yesno[] = {
3036 if (val == yesno[0])
3045 const char *section,
3067 while (pos[0] ==
' ')
3069 if (strlen (pos) == 0)
3072 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
3080 memmove (
end, &
end[1], strlen (&
end[1]) + 1);
3095 if (strlen (pos) > 0)
3098 if ( (NULL != cb) &&
3129 memset (escaped, 0, strlen (
value) * 2 + 1);
3132 while (rpos[0] !=
'\0')
3164 const char *of = cls;
3166 return (0 == strcmp (of, fn))
3175 const char *section,
3196 if (strlen (old) > 0)
3198 strcat (nw, escaped);
3213 const char *section,
3233 while (pos[0] ==
' ')
3235 if (strlen (pos) == 0)
3238 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
3262 if (0 == strcmp (pos, match))
3267 strlen (&
end[1]) + 1);
3297 const char *defaults_d)
3310 qsort (files_context.
files,
3314 for (
unsigned int i = 0; i < files_context.
files_length; i++)
3321 if ( (NULL == ext) ||
3326 "Skipping file `%s'\n",
3338 for (
size_t i = 0; i < files_context.
files_length; i++)
3353 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
3398 const char *base_config_varname;
3415 if ((NULL != base_config_varname)
3416 && (NULL != (baseconfig =
getenv (base_config_varname))))
3451 "Failed to load base configuration from '%s'\n",
3465 "Failed to load configuration from file '%s'\n",
3472 "DEFAULTCONFIG"))) &&
3492 const char *section,
3529 const char *section,
3551 const char *section)
3564 const char *cfgfile,
3583 _ (
"Failed to load config file `%s'"),
3595 _ (
"The following sections are available:\n"));
3604 char *serialization;
3609 _ (
"%s, %s or %s argument is required\n"),
3624 else if ( (NULL != cs->
section) &&
3625 (NULL == cs->
value) )
3682 _ (
"--option argument required to set value\n"));
3695 char *cfg_fn = NULL;
3700 if (NULL == cfgfile)
3702 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
3725 _ (
"failed to load configuration defaults"));
3778 const char *progname)
3781 char *binary = NULL;
3800 if ( (NULL == path) ||
3801 (0 == strlen (path)) )
3809 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 char * expand_dollar(const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig, unsigned int depth, const struct ExpansionFrame *frame, size_t *skip)
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or...
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 char * expand_all(const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig, const struct ExpansionFrame *frame)
$-expand all terms in a string.
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 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
A [PATHS] option or environment variable whose value is being $-expanded, used to detect definitions ...
const struct ExpansionFrame * parent
The expansion this one is part of, or NULL.
const char * name
Name of the variable whose value is being expanded.
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.