GNUnet 0.29.1-dev.1-3-g346358e26
 
Loading...
Searching...
No Matches
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
179char *
181 const struct GNUNET_CONFIGURATION_Handle *cfg);
182
183
193typedef void
195 const char *section,
196 const char *option,
197 unsigned int line);
198
199
216 const struct GNUNET_CONFIGURATION_Handle *cfg,
217 const char *filename,
219 void *cb_cls,
220 unsigned int *removed);
221
222
236 const char *mem,
237 size_t size,
238 const char *source_filename);
239
240
251 const char *filename);
252
253
264 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
265 const struct GNUNET_CONFIGURATION_Handle *cfg_new,
266 const char *filename);
267
268
278 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
279 const struct GNUNET_CONFIGURATION_Handle *cfg_new);
280
281
291 const struct GNUNET_CONFIGURATION_Handle *cfg);
292
293
301typedef enum GNUNET_GenericReturnValue
303 void *cls,
304 const struct GNUNET_CONFIGURATION_Handle *cfg);
305
306
321 const struct GNUNET_OS_ProjectData *pd,
322 const char *filename,
324 void *cb_cls);
325
332void
335
336
343const struct GNUNET_OS_ProjectData *
345 const struct GNUNET_CONFIGURATION_Handle *cfg);
346
347
356typedef void
358 const char *section,
359 const char *option,
360 const char *value);
361
362
369typedef void
371 const char *section);
372
373
381void
383 const struct GNUNET_CONFIGURATION_Handle *cfg,
385 void *iter_cls);
386
387
395void
397 const struct GNUNET_CONFIGURATION_Handle *cfg,
399 void *iter_cls);
400
401
408void
411 const char *section);
412
413
427 const struct GNUNET_CONFIGURATION_Handle *cfg,
428 const char *section,
429 const char *option,
430 unsigned long long *number);
431
441void
443 const char *section,
444 const char *option,
445 float number);
446
460 const struct GNUNET_CONFIGURATION_Handle *cfg,
461 const char *section,
462 const char *option,
463 float *number);
464
465
479 const struct GNUNET_CONFIGURATION_Handle *cfg,
480 const char *section,
481 const char *option,
482 struct GNUNET_TIME_Relative *time);
483
484
498 const struct GNUNET_CONFIGURATION_Handle *cfg,
499 const char *section,
500 const char *option,
501 unsigned long long *size);
502
503
514 const char *section,
515 const char *option);
516
517
532 const struct GNUNET_CONFIGURATION_Handle *cfg,
533 const char *section,
534 const char *option,
535 char **value);
536
537
553 const struct GNUNET_CONFIGURATION_Handle *cfg,
554 const char *section,
555 const char *option,
556 char **value);
557
558
569int
571 const struct GNUNET_CONFIGURATION_Handle *cfg,
572 const char *section,
573 const char *option,
575 void *cb_cls);
576
577
586void
588 const struct GNUNET_CONFIGURATION_Handle *cfg,
589 const char *section,
591 void *iter_cls);
592
593
610 const struct GNUNET_CONFIGURATION_Handle *cfg,
611 const char *section,
612 const char *option,
613 const char *const *choices,
614 const char **value);
615
616
630 const struct GNUNET_CONFIGURATION_Handle *cfg,
631 const char *section,
632 const char *option);
633
634
649 const char *section,
650 const char *option,
651 void *buf,
652 size_t buf_size);
653
654
671char *
673 const struct GNUNET_CONFIGURATION_Handle *cfg,
674 char *orig);
675
676
685void
688 const char *section,
689 const char *option,
690 unsigned long long number);
691
692
701void
704 const char *section,
705 const char *option,
706 const char *value);
707
708
723 const char *section,
724 const char *option,
725 const char *value);
726
727
742 const char *section,
743 const char *option,
744 const char *value);
745
746
753{
754
759 unsigned int api_version;
760
764 char *section;
765
769 char *option;
770
774 char *value;
775
780
785
790
795 unsigned int diagnostics;
796
800 int full;
801
807
808};
809
810
818#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
819 GNUNET_GETOPT_option_flag ( \
820 'F', \
821 "full", \
822 gettext_noop ( \
823 "write the full configuration file, including default values"), \
824 &(cs)->full), \
825 GNUNET_GETOPT_option_flag ( \
826 'f', \
827 "filename", \
828 gettext_noop ( \
829 "interpret option value as a filename (with $-expansion)"), \
830 &(cs)->is_filename), \
831 GNUNET_GETOPT_option_string ('o', \
832 "option", \
833 "OPTION", \
834 gettext_noop ( \
835 "name of the option to access"), \
836 &(cs)->option), \
837 GNUNET_GETOPT_option_flag ( \
838 'r', \
839 "rewrite", \
840 gettext_noop ( \
841 "rewrite the configuration file, even if nothing changed"), \
842 &(cs)->rewrite), \
843 GNUNET_GETOPT_option_increment_uint ( \
844 'd', \
845 "diagnostics", \
846 gettext_noop ( \
847 "output extra diagnostics; repeat to show all definitions"), \
848 &(cs)->diagnostics), \
849 GNUNET_GETOPT_option_flag ('S', \
850 "list-sections", \
851 gettext_noop ( \
852 "print available configuration sections"), \
853 &(cs)->list_sections), \
854 GNUNET_GETOPT_option_string ('s', \
855 "section", \
856 "SECTION", \
857 gettext_noop ( \
858 "name of the section to access"), \
859 &(cs)->section), \
860 GNUNET_GETOPT_option_string ('V', \
861 "value", \
862 "VALUE", \
863 gettext_noop ("value to set"), \
864 &(cs)->value)
865
866
873void
876
877
889void
891 void *cls,
892 char *const *args,
893 const char *cfgfile,
894 const struct GNUNET_CONFIGURATION_Handle *cfg);
895
896
910char *
912 pd,
913 const struct
915 const char *progname);
916
917
918#if 0 /* keep Emacsens' auto-indent happy */
919{
920#endif
921#ifdef __cplusplus
922}
923#endif
924
925#endif
926
/* end of group configuration */
928
/* end of group addition */
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static char * line
Desired phone line (string to be converted to a hash).
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.
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.
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 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 diagnostics
Diagnostics verbosity.
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.