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
71
77void
79
80
92 const char *filename);
93
94
105 const char *defaults_d);
106
107
118
119
128char *
130
131
142 const char *filename);
143
144
153char *
155 size_t *size);
156
157
167char *
169 const struct GNUNET_CONFIGURATION_Handle *cfg);
170
183 const char *mem,
184 size_t size,
185 const char *source_filename);
186
187
197 const char *filename);
198
199
210 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
211 const struct GNUNET_CONFIGURATION_Handle *cfg_new,
212 const char *filename);
213
214
224 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
225 const struct GNUNET_CONFIGURATION_Handle *cfg_new);
226
227
237
238
246typedef enum GNUNET_GenericReturnValue
248 const struct GNUNET_CONFIGURATION_Handle *cfg);
249
250
265 void *cb_cls);
266
273void
276
277
286typedef void
288 const char *section,
289 const char *option,
290 const char *value);
291
292
299typedef void
301 const char *section);
302
303
311void
314 void *iter_cls);
315
316
324void
326 const struct GNUNET_CONFIGURATION_Handle *cfg,
328 void *iter_cls);
329
330
337void
339 const char *section);
340
341
353 const struct GNUNET_CONFIGURATION_Handle *cfg,
354 const char *section,
355 const char *option,
356 unsigned long long *number);
357
358
370 const struct GNUNET_CONFIGURATION_Handle *cfg,
371 const char *section,
372 const char *option,
373 float *number);
374
375
387 const struct GNUNET_CONFIGURATION_Handle *cfg,
388 const char *section,
389 const char *option,
390 struct GNUNET_TIME_Relative *time);
391
392
404 const struct GNUNET_CONFIGURATION_Handle *cfg,
405 const char *section,
406 const char *option,
407 unsigned long long *size);
408
409
420 const char *section,
421 const char *option);
422
423
436 const struct GNUNET_CONFIGURATION_Handle *cfg,
437 const char *section,
438 const char *option,
439 char **value);
440
441
455 const struct GNUNET_CONFIGURATION_Handle *cfg,
456 const char *section,
457 const char *option,
458 char **value);
459
460
471int
473 const struct GNUNET_CONFIGURATION_Handle *cfg,
474 const char *section,
475 const char *option,
477 void *cb_cls);
478
479
488void
490 const struct GNUNET_CONFIGURATION_Handle *cfg,
491 const char *section,
493 void *iter_cls);
494
495
510 const struct GNUNET_CONFIGURATION_Handle *cfg,
511 const char *section,
512 const char *option,
513 const char *const *choices,
514 const char **value);
515
516
528 const struct GNUNET_CONFIGURATION_Handle *cfg,
529 const char *section,
530 const char *option);
531
532
547 const char *section,
548 const char *option,
549 void *buf,
550 size_t buf_size);
551
552
569char *
571 const struct GNUNET_CONFIGURATION_Handle *cfg,
572 char *orig);
573
574
583void
585 const char *section,
586 const char *option,
587 unsigned long long number);
588
589
598void
600 const char *section,
601 const char *option,
602 const char *value);
603
604
619 const char *section,
620 const char *option,
621 const char *value);
622
623
638 const char *section,
639 const char *option,
640 const char *value);
641
642
649{
650
657 unsigned int api_version;
658
662 char *section;
663
667 char *option;
668
672 char *value;
673
678
683
688
693
697 int full;
698
699
705
706};
707
708
716#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
717 GNUNET_GETOPT_option_flag ( \
718 'F', \
719 "full", \
720 gettext_noop ( \
721 "write the full configuration file, including default values"), \
722 &(cs)->full), \
723 GNUNET_GETOPT_option_flag ( \
724 'f', \
725 "filename", \
726 gettext_noop ("interpret option value as a filename (with $-expansion)"), \
727 &(cs)->is_filename), \
728 GNUNET_GETOPT_option_string ('o', \
729 "option", \
730 "OPTION", \
731 gettext_noop ("name of the option to access"), \
732 &(cs)->option), \
733 GNUNET_GETOPT_option_flag ( \
734 'r', \
735 "rewrite", \
736 gettext_noop ( \
737 "rewrite the configuration file, even if nothing changed"), \
738 &(cs)->rewrite), \
739 GNUNET_GETOPT_option_flag ( \
740 'd', \
741 "diagnostics", \
742 gettext_noop ( \
743 "output extra diagnostics"), \
744 &(cs)->diagnostics), \
745 GNUNET_GETOPT_option_flag ('S', \
746 "list-sections", \
747 gettext_noop ( \
748 "print available configuration sections"), \
749 &(cs)->list_sections), \
750 GNUNET_GETOPT_option_string ('s', \
751 "section", \
752 "SECTION", \
753 gettext_noop ( \
754 "name of the section to access"), \
755 &(cs)->section), \
756 GNUNET_GETOPT_option_string ('V', \
757 "value", \
758 "VALUE", \
759 gettext_noop ("value to set"), \
760 &(cs)->value)
761
762
769void
772
773
785void
787 void *cls,
788 char *const *args,
789 const char *cfgfile,
790 const struct GNUNET_CONFIGURATION_Handle *cfg);
791
792
793#if 0 /* keep Emacsens' auto-indent happy */
794{
795#endif
796#ifdef __cplusplus
797}
798#endif
799
800#endif
801 /* end of group configuration */
803 /* 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.