GNUnet 0.21.1
gnunet_configuration_lib.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2006, 2008, 2009, 2018 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
35#ifndef GNUNET_CONFIGURATION_LIB_H
36#define GNUNET_CONFIGURATION_LIB_H
37
38
39#include "gnunet_time_lib.h"
40
41#ifdef __cplusplus
42extern "C"
43{
44#if 0 /* keep Emacsens' auto-indent happy */
45}
46#endif
47#endif
48
53
60
61
70 const struct GNUNET_CONFIGURATION_Handle *cfg);
71
72
78void
81
82
95 const char *filename);
96
97
109 const char *defaults_d);
110
111
122
123
132char *
134
135
147 const char *filename);
148
149
158char *
160 const struct GNUNET_CONFIGURATION_Handle *cfg,
161 size_t *size);
162
163
173char *
175 const struct GNUNET_CONFIGURATION_Handle *cfg);
176
177
191 const char *mem,
192 size_t size,
193 const char *source_filename);
194
195
206 const char *filename);
207
208
219 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
220 const struct GNUNET_CONFIGURATION_Handle *cfg_new,
221 const char *filename);
222
223
233 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
234 const struct GNUNET_CONFIGURATION_Handle *cfg_new);
235
236
246 const struct GNUNET_CONFIGURATION_Handle *cfg);
247
248
256typedef enum GNUNET_GenericReturnValue
258 void *cls,
259 const struct GNUNET_CONFIGURATION_Handle *cfg);
260
261
275 const char *filename,
277 void *cb_cls);
278
285void
288
289
298typedef void
300 const char *section,
301 const char *option,
302 const char *value);
303
304
311typedef void
313 const char *section);
314
315
323void
325 const struct GNUNET_CONFIGURATION_Handle *cfg,
327 void *iter_cls);
328
329
337void
339 const struct GNUNET_CONFIGURATION_Handle *cfg,
341 void *iter_cls);
342
343
350void
353 const char *section);
354
355
367 const struct GNUNET_CONFIGURATION_Handle *cfg,
368 const char *section,
369 const char *option,
370 unsigned long long *number);
371
372
384 const struct GNUNET_CONFIGURATION_Handle *cfg,
385 const char *section,
386 const char *option,
387 float *number);
388
389
401 const struct GNUNET_CONFIGURATION_Handle *cfg,
402 const char *section,
403 const char *option,
404 struct GNUNET_TIME_Relative *time);
405
406
418 const struct GNUNET_CONFIGURATION_Handle *cfg,
419 const char *section,
420 const char *option,
421 unsigned long long *size);
422
423
434 const char *section,
435 const char *option);
436
437
450 const struct GNUNET_CONFIGURATION_Handle *cfg,
451 const char *section,
452 const char *option,
453 char **value);
454
455
469 const struct GNUNET_CONFIGURATION_Handle *cfg,
470 const char *section,
471 const char *option,
472 char **value);
473
474
485int
487 const struct GNUNET_CONFIGURATION_Handle *cfg,
488 const char *section,
489 const char *option,
491 void *cb_cls);
492
493
502void
504 const struct GNUNET_CONFIGURATION_Handle *cfg,
505 const char *section,
507 void *iter_cls);
508
509
524 const struct GNUNET_CONFIGURATION_Handle *cfg,
525 const char *section,
526 const char *option,
527 const char *const *choices,
528 const char **value);
529
530
542 const struct GNUNET_CONFIGURATION_Handle *cfg,
543 const char *section,
544 const char *option);
545
546
561 const char *section,
562 const char *option,
563 void *buf,
564 size_t buf_size);
565
566
583char *
585 const struct GNUNET_CONFIGURATION_Handle *cfg,
586 char *orig);
587
588
597void
599 const char *section,
600 const char *option,
601 unsigned long long number);
602
603
612void
615 const char *section,
616 const char *option,
617 const char *value);
618
619
634 const char *section,
635 const char *option,
636 const char *value);
637
638
653 const char *section,
654 const char *option,
655 const char *value);
656
657
664{
665
670 unsigned int api_version;
671
675 char *section;
676
680 char *option;
681
685 char *value;
686
691
696
701
706
710 int full;
711
717
718};
719
720
728#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
729 GNUNET_GETOPT_option_flag ( \
730 'F', \
731 "full", \
732 gettext_noop ( \
733 "write the full configuration file, including default values"), \
734 &(cs)->full), \
735 GNUNET_GETOPT_option_flag ( \
736 'f', \
737 "filename", \
738 gettext_noop ( \
739 "interpret option value as a filename (with $-expansion)"), \
740 &(cs)->is_filename), \
741 GNUNET_GETOPT_option_string ('o', \
742 "option", \
743 "OPTION", \
744 gettext_noop ( \
745 "name of the option to access"), \
746 &(cs)->option), \
747 GNUNET_GETOPT_option_flag ( \
748 'r', \
749 "rewrite", \
750 gettext_noop ( \
751 "rewrite the configuration file, even if nothing changed"), \
752 &(cs)->rewrite), \
753 GNUNET_GETOPT_option_flag ( \
754 'd', \
755 "diagnostics", \
756 gettext_noop ( \
757 "output extra diagnostics"), \
758 &(cs)->diagnostics), \
759 GNUNET_GETOPT_option_flag ('S', \
760 "list-sections", \
761 gettext_noop ( \
762 "print available configuration sections"), \
763 &(cs)->list_sections), \
764 GNUNET_GETOPT_option_string ('s', \
765 "section", \
766 "SECTION", \
767 gettext_noop ( \
768 "name of the section to access"), \
769 &(cs)->section), \
770 GNUNET_GETOPT_option_string ('V', \
771 "value", \
772 "VALUE", \
773 gettext_noop ("value to set"), \
774 &(cs)->value)
775
776
783void
786
787
799void
801 void *cls,
802 char *const *args,
803 const char *cfgfile,
804 const struct GNUNET_CONFIGURATION_Handle *cfg);
805
806
807#if 0 /* keep Emacsens' auto-indent happy */
808{
809#endif
810#ifdef __cplusplus
811}
812#endif
813
814#endif
815 /* end of group configuration */
817 /* end of group addition */
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static char * filename
static char * value
Value of the record to add/remove.
Functions related to time.
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.
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.
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.
char * GNUNET_CONFIGURATION_default_filename(void)
Return the filename of the default configuration filename that is used when no explicit configuration...
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_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...
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_default(void)
Return GNUnet's default 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_parse_and_run(const char *filename, GNUNET_CONFIGURATION_Callback cb, void *cb_cls)
Parse a configuration file filename and run the function cb with the resulting configuration object.
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.
enum GNUNET_GenericReturnValue(* GNUNET_FileNameCallback)(void *cls, const char *filename)
Function called with a filename.
GNUNET_GenericReturnValue
Named constants for return values.
static unsigned int size
Size of the "table".
Definition: peer.c:68
uint32_t number
Closure for GNUNET_CONFIGURATION_config_tool_run() with settings for what should be done with the con...
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?
int is_filename
Treat option as a filename.
unsigned int api_version
Must be set to the API version, i.e.
Time for relative time used by GNUnet, in microseconds.