GNUnet 0.22.2
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, 2024 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#include "gnunet_os_lib.h"
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
62
63
72 const struct GNUNET_CONFIGURATION_Handle *cfg);
73
74
80void
83
84
97 const char *filename);
98
99
111 const char *defaults_d);
112
113
123char *
125 const struct GNUNET_OS_ProjectData *pd);
126
127
139 const char *filename);
140
141
150char *
152 const struct GNUNET_CONFIGURATION_Handle *cfg,
153 size_t *size);
154
155
165char *
167 const struct GNUNET_CONFIGURATION_Handle *cfg);
168
169
183 const char *mem,
184 size_t size,
185 const char *source_filename);
186
187
198 const char *filename);
199
200
211 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
212 const struct GNUNET_CONFIGURATION_Handle *cfg_new,
213 const char *filename);
214
215
225 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
226 const struct GNUNET_CONFIGURATION_Handle *cfg_new);
227
228
238 const struct GNUNET_CONFIGURATION_Handle *cfg);
239
240
248typedef enum GNUNET_GenericReturnValue
250 void *cls,
251 const struct GNUNET_CONFIGURATION_Handle *cfg);
252
253
268 const struct GNUNET_OS_ProjectData *pd,
269 const char *filename,
271 void *cb_cls);
272
279void
282
283
290const struct GNUNET_OS_ProjectData *
292 const struct GNUNET_CONFIGURATION_Handle *cfg);
293
294
303typedef void
305 const char *section,
306 const char *option,
307 const char *value);
308
309
316typedef void
318 const char *section);
319
320
328void
330 const struct GNUNET_CONFIGURATION_Handle *cfg,
332 void *iter_cls);
333
334
342void
344 const struct GNUNET_CONFIGURATION_Handle *cfg,
346 void *iter_cls);
347
348
355void
358 const char *section);
359
360
374 const struct GNUNET_CONFIGURATION_Handle *cfg,
375 const char *section,
376 const char *option,
377 unsigned long long *number);
378
388void
390 const char *section,
391 const char *option,
392 float number);
393
407 const struct GNUNET_CONFIGURATION_Handle *cfg,
408 const char *section,
409 const char *option,
410 float *number);
411
412
426 const struct GNUNET_CONFIGURATION_Handle *cfg,
427 const char *section,
428 const char *option,
429 struct GNUNET_TIME_Relative *time);
430
431
445 const struct GNUNET_CONFIGURATION_Handle *cfg,
446 const char *section,
447 const char *option,
448 unsigned long long *size);
449
450
461 const char *section,
462 const char *option);
463
464
479 const struct GNUNET_CONFIGURATION_Handle *cfg,
480 const char *section,
481 const char *option,
482 char **value);
483
484
500 const struct GNUNET_CONFIGURATION_Handle *cfg,
501 const char *section,
502 const char *option,
503 char **value);
504
505
516int
518 const struct GNUNET_CONFIGURATION_Handle *cfg,
519 const char *section,
520 const char *option,
522 void *cb_cls);
523
524
533void
535 const struct GNUNET_CONFIGURATION_Handle *cfg,
536 const char *section,
538 void *iter_cls);
539
540
557 const struct GNUNET_CONFIGURATION_Handle *cfg,
558 const char *section,
559 const char *option,
560 const char *const *choices,
561 const char **value);
562
563
577 const struct GNUNET_CONFIGURATION_Handle *cfg,
578 const char *section,
579 const char *option);
580
581
596 const char *section,
597 const char *option,
598 void *buf,
599 size_t buf_size);
600
601
618char *
620 const struct GNUNET_CONFIGURATION_Handle *cfg,
621 char *orig);
622
623
632void
635 const char *section,
636 const char *option,
637 unsigned long long number);
638
639
648void
651 const char *section,
652 const char *option,
653 const char *value);
654
655
670 const char *section,
671 const char *option,
672 const char *value);
673
674
689 const char *section,
690 const char *option,
691 const char *value);
692
693
700{
701
706 unsigned int api_version;
707
711 char *section;
712
716 char *option;
717
721 char *value;
722
727
732
737
742
746 int full;
747
753
754};
755
756
764#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
765 GNUNET_GETOPT_option_flag ( \
766 'F', \
767 "full", \
768 gettext_noop ( \
769 "write the full configuration file, including default values"), \
770 &(cs)->full), \
771 GNUNET_GETOPT_option_flag ( \
772 'f', \
773 "filename", \
774 gettext_noop ( \
775 "interpret option value as a filename (with $-expansion)"), \
776 &(cs)->is_filename), \
777 GNUNET_GETOPT_option_string ('o', \
778 "option", \
779 "OPTION", \
780 gettext_noop ( \
781 "name of the option to access"), \
782 &(cs)->option), \
783 GNUNET_GETOPT_option_flag ( \
784 'r', \
785 "rewrite", \
786 gettext_noop ( \
787 "rewrite the configuration file, even if nothing changed"), \
788 &(cs)->rewrite), \
789 GNUNET_GETOPT_option_flag ( \
790 'd', \
791 "diagnostics", \
792 gettext_noop ( \
793 "output extra diagnostics"), \
794 &(cs)->diagnostics), \
795 GNUNET_GETOPT_option_flag ('S', \
796 "list-sections", \
797 gettext_noop ( \
798 "print available configuration sections"), \
799 &(cs)->list_sections), \
800 GNUNET_GETOPT_option_string ('s', \
801 "section", \
802 "SECTION", \
803 gettext_noop ( \
804 "name of the section to access"), \
805 &(cs)->section), \
806 GNUNET_GETOPT_option_string ('V', \
807 "value", \
808 "VALUE", \
809 gettext_noop ("value to set"), \
810 &(cs)->value)
811
812
819void
822
823
835void
837 void *cls,
838 char *const *args,
839 const char *cfgfile,
840 const struct GNUNET_CONFIGURATION_Handle *cfg);
841
842
843#if 0 /* keep Emacsens' auto-indent happy */
844{
845#endif
846#ifdef __cplusplus
847}
848#endif
849
850#endif
851 /* end of group configuration */
853 /* end of group addition */
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static char * filename
static char * value
Value of the record to add/remove.
Low level process routines.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_is_dirty(const struct GNUNET_CONFIGURATION_Handle *cfg)
Test if there are configuration options that were changed since the last save.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_append_value_filename(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Append a filename to a configuration value that represents a list of filenames.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
void GNUNET_CONFIGURATION_remove_section(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Remove the given section and all options in it.
enum GNUNET_GenericReturnValue(* GNUNET_CONFIGURATION_Callback)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Signature of a function to be run with a configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls)
Iterate over all sections in the configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_CONFIGURATION_config_settings_free(struct GNUNET_CONFIGURATION_ConfigSettings *cs)
Free resources associated with cs.
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_remove_value_filename(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Remove a filename from a configuration value that represents a list of filenames.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse_and_run(const struct GNUNET_OS_ProjectData *pd, const char *filename, GNUNET_CONFIGURATION_Callback cb, void *cb_cls)
Parse a configuration file filename and run the function cb with the resulting configuration object.
void GNUNET_CONFIGURATION_config_tool_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main task to run to perform operations typical for gnunet-config as per the configuration settings gi...
void(* GNUNET_CONFIGURATION_SectionIterator)(void *cls, const char *section)
Function to iterate over section.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename)
De-serializes configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_size(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *size)
Get a configuration value that should be a size in bytes.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
char * GNUNET_CONFIGURATION_default_filename(const struct GNUNET_OS_ProjectData *pd)
Return the filename of the default configuration filename that is used when no explicit configuration...
char * GNUNET_CONFIGURATION_expand_dollar(const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig)
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or...
void GNUNET_CONFIGURATION_set_value_float(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float number)
Set a configuration value that should be a float.
const struct GNUNET_OS_ProjectData * GNUNET_CONFIGURATION_get_project_data(const struct GNUNET_CONFIGURATION_Handle *cfg)
Return the project data associated with this configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_get_diff(const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new)
Compute configuration with only entries that have been changed.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Parse a configuration file, add all of the options in the file to the configuration environment.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_float(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number)
Get a configuration value that should be a floating point number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load_from(struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
Load default configuration.
int GNUNET_CONFIGURATION_iterate_value_filenames(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, GNUNET_FileNameCallback cb, void *cb_cls)
Iterate over the set of filenames stored in a configuration value.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_choice(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *const *choices, const char **value)
Get a configuration value that should be in a set of predefined strings.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
void(* GNUNET_CONFIGURATION_Iterator)(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options.
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write_diffs(const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new, const char *filename)
Write only configuration entries that have been changed to configuration file.
char * GNUNET_CONFIGURATION_serialize_diagnostics(const struct GNUNET_CONFIGURATION_Handle *cfg)
Serializes the given configuration with diagnostics information.
void GNUNET_CONFIGURATION_enable_diagnostics(struct GNUNET_CONFIGURATION_Handle *cfg)
Enable extra diagnostics.
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.
const struct GNUNET_OS_ProjectData * pd
Project data for this configuration object.
Project-specific data used to help the OS subsystem find installation paths.
Time for relative time used by GNUnet, in microseconds.