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
379
393 const struct GNUNET_CONFIGURATION_Handle *cfg,
394 const char *section,
395 const char *option,
396 float *number);
397
398
412 const struct GNUNET_CONFIGURATION_Handle *cfg,
413 const char *section,
414 const char *option,
415 struct GNUNET_TIME_Relative *time);
416
417
431 const struct GNUNET_CONFIGURATION_Handle *cfg,
432 const char *section,
433 const char *option,
434 unsigned long long *size);
435
436
447 const char *section,
448 const char *option);
449
450
465 const struct GNUNET_CONFIGURATION_Handle *cfg,
466 const char *section,
467 const char *option,
468 char **value);
469
470
486 const struct GNUNET_CONFIGURATION_Handle *cfg,
487 const char *section,
488 const char *option,
489 char **value);
490
491
502int
504 const struct GNUNET_CONFIGURATION_Handle *cfg,
505 const char *section,
506 const char *option,
508 void *cb_cls);
509
510
519void
521 const struct GNUNET_CONFIGURATION_Handle *cfg,
522 const char *section,
524 void *iter_cls);
525
526
543 const struct GNUNET_CONFIGURATION_Handle *cfg,
544 const char *section,
545 const char *option,
546 const char *const *choices,
547 const char **value);
548
549
563 const struct GNUNET_CONFIGURATION_Handle *cfg,
564 const char *section,
565 const char *option);
566
567
582 const char *section,
583 const char *option,
584 void *buf,
585 size_t buf_size);
586
587
604char *
606 const struct GNUNET_CONFIGURATION_Handle *cfg,
607 char *orig);
608
609
618void
621 const char *section,
622 const char *option,
623 unsigned long long number);
624
625
634void
637 const char *section,
638 const char *option,
639 const char *value);
640
641
656 const char *section,
657 const char *option,
658 const char *value);
659
660
675 const char *section,
676 const char *option,
677 const char *value);
678
679
686{
687
692 unsigned int api_version;
693
697 char *section;
698
702 char *option;
703
707 char *value;
708
713
718
723
728
732 int full;
733
739
740};
741
742
750#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
751 GNUNET_GETOPT_option_flag ( \
752 'F', \
753 "full", \
754 gettext_noop ( \
755 "write the full configuration file, including default values"), \
756 &(cs)->full), \
757 GNUNET_GETOPT_option_flag ( \
758 'f', \
759 "filename", \
760 gettext_noop ( \
761 "interpret option value as a filename (with $-expansion)"), \
762 &(cs)->is_filename), \
763 GNUNET_GETOPT_option_string ('o', \
764 "option", \
765 "OPTION", \
766 gettext_noop ( \
767 "name of the option to access"), \
768 &(cs)->option), \
769 GNUNET_GETOPT_option_flag ( \
770 'r', \
771 "rewrite", \
772 gettext_noop ( \
773 "rewrite the configuration file, even if nothing changed"), \
774 &(cs)->rewrite), \
775 GNUNET_GETOPT_option_flag ( \
776 'd', \
777 "diagnostics", \
778 gettext_noop ( \
779 "output extra diagnostics"), \
780 &(cs)->diagnostics), \
781 GNUNET_GETOPT_option_flag ('S', \
782 "list-sections", \
783 gettext_noop ( \
784 "print available configuration sections"), \
785 &(cs)->list_sections), \
786 GNUNET_GETOPT_option_string ('s', \
787 "section", \
788 "SECTION", \
789 gettext_noop ( \
790 "name of the section to access"), \
791 &(cs)->section), \
792 GNUNET_GETOPT_option_string ('V', \
793 "value", \
794 "VALUE", \
795 gettext_noop ("value to set"), \
796 &(cs)->value)
797
798
805void
808
809
821void
823 void *cls,
824 char *const *args,
825 const char *cfgfile,
826 const struct GNUNET_CONFIGURATION_Handle *cfg);
827
828
829#if 0 /* keep Emacsens' auto-indent happy */
830{
831#endif
832#ifdef __cplusplus
833}
834#endif
835
836#endif
837 /* end of group configuration */
839 /* 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...
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.