GNUnet  0.17.6
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 #include "gnunet_time_lib.h"
39 
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #if 0 /* keep Emacsens' auto-indent happy */
44 }
45 #endif
46 #endif
47 
52 
59 
60 
69 
70 
76 void
78 
79 
91  const char *filename);
92 
93 
104  const char *defaults_d);
105 
106 
117 
118 
127 char *
129 
130 
141  const char *filename);
142 
143 
152 char *
154  size_t *size);
155 
156 
166 char *
168  const struct GNUNET_CONFIGURATION_Handle *cfg);
169 
182  const char *mem,
183  size_t size,
184  const char *source_filename);
185 
186 
196  const char *filename);
197 
198 
209  const struct GNUNET_CONFIGURATION_Handle *cfg_default,
210  const struct GNUNET_CONFIGURATION_Handle *cfg_new,
211  const char *filename);
212 
213 
223  const struct GNUNET_CONFIGURATION_Handle *cfg_default,
224  const struct GNUNET_CONFIGURATION_Handle *cfg_new);
225 
226 
236 
237 
245 typedef enum GNUNET_GenericReturnValue
246 (*GNUNET_CONFIGURATION_Callback)(void *cls,
247  const struct GNUNET_CONFIGURATION_Handle *cfg);
248 
249 
264  void *cb_cls);
265 
272 void
275 
276 
285 typedef void
286 (*GNUNET_CONFIGURATION_Iterator) (void *cls,
287  const char *section,
288  const char *option,
289  const char *value);
290 
291 
298 typedef void
300  const char *section);
301 
302 
310 void
313  void *iter_cls);
314 
315 
323 void
325  const struct GNUNET_CONFIGURATION_Handle *cfg,
327  void *iter_cls);
328 
329 
336 void
338  const char *section);
339 
340 
352  const struct GNUNET_CONFIGURATION_Handle *cfg,
353  const char *section,
354  const char *option,
355  unsigned long long *number);
356 
357 
369  const struct GNUNET_CONFIGURATION_Handle *cfg,
370  const char *section,
371  const char *option,
372  float *number);
373 
374 
386  const struct GNUNET_CONFIGURATION_Handle *cfg,
387  const char *section,
388  const char *option,
389  struct GNUNET_TIME_Relative *time);
390 
391 
403  const struct GNUNET_CONFIGURATION_Handle *cfg,
404  const char *section,
405  const char *option,
406  unsigned long long *size);
407 
408 
419  const char *section,
420  const char *option);
421 
422 
435  const struct GNUNET_CONFIGURATION_Handle *cfg,
436  const char *section,
437  const char *option,
438  char **value);
439 
440 
454  const struct GNUNET_CONFIGURATION_Handle *cfg,
455  const char *section,
456  const char *option,
457  char **value);
458 
459 
470 int
472  const struct GNUNET_CONFIGURATION_Handle *cfg,
473  const char *section,
474  const char *option,
476  void *cb_cls);
477 
478 
487 void
489  const struct GNUNET_CONFIGURATION_Handle *cfg,
490  const char *section,
492  void *iter_cls);
493 
494 
509  const struct GNUNET_CONFIGURATION_Handle *cfg,
510  const char *section,
511  const char *option,
512  const char *const *choices,
513  const char **value);
514 
515 
527  const struct GNUNET_CONFIGURATION_Handle *cfg,
528  const char *section,
529  const char *option);
530 
531 
546  const char *section,
547  const char *option,
548  void *buf,
549  size_t buf_size);
550 
551 
568 char *
570  const struct GNUNET_CONFIGURATION_Handle *cfg,
571  char *orig);
572 
573 
582 void
584  const char *section,
585  const char *option,
586  unsigned long long number);
587 
588 
597 void
599  const char *section,
600  const char *option,
601  const char *value);
602 
603 
618  const char *section,
619  const char *option,
620  const char *value);
621 
622 
637  const char *section,
638  const char *option,
639  const char *value);
640 
641 
648 {
649 
656  unsigned int api_version;
657 
661  char *section;
662 
666  char *option;
667 
671  char *value;
672 
677 
682 
686  int rewrite;
687 
692 
696  int full;
697 
698 
704 
705 };
706 
707 
715 #define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
716  GNUNET_GETOPT_option_flag ( \
717  'F', \
718  "full", \
719  gettext_noop ( \
720  "write the full configuration file, including default values"), \
721  &(cs)->full), \
722  GNUNET_GETOPT_option_flag ( \
723  'f', \
724  "filename", \
725  gettext_noop ("interpret option value as a filename (with $-expansion)"), \
726  &(cs)->is_filename), \
727  GNUNET_GETOPT_option_string ('o', \
728  "option", \
729  "OPTION", \
730  gettext_noop ("name of the option to access"), \
731  &(cs)->option), \
732  GNUNET_GETOPT_option_flag ( \
733  'r', \
734  "rewrite", \
735  gettext_noop ( \
736  "rewrite the configuration file, even if nothing changed"), \
737  &(cs)->rewrite), \
738  GNUNET_GETOPT_option_flag ( \
739  'd', \
740  "diagnostics", \
741  gettext_noop ( \
742  "output extra diagnostics"), \
743  &(cs)->diagnostics), \
744  GNUNET_GETOPT_option_flag ('S', \
745  "list-sections", \
746  gettext_noop ( \
747  "print available configuration sections"), \
748  &(cs)->list_sections), \
749  GNUNET_GETOPT_option_string ('s', \
750  "section", \
751  "SECTION", \
752  gettext_noop ( \
753  "name of the section to access"), \
754  &(cs)->section), \
755  GNUNET_GETOPT_option_string ('V', \
756  "value", \
757  "VALUE", \
758  gettext_noop ("value to set"), \
759  &(cs)->value)
760 
761 
768 void
771 
772 
784 void
786  void *cls,
787  char *const *args,
788  const char *cfgfile,
789  const struct GNUNET_CONFIGURATION_Handle *cfg);
790 
791 
792 #if 0 /* keep Emacsens' auto-indent happy */
793 {
794 #endif
795 #ifdef __cplusplus
796 }
797 #endif
798 
799 #endif
800  /* end of group configuration */
802  /* end of group addition */
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static char * filename
static char * value
Value of the record to add/remove.
static char buf[2048]
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.
char * GNUNET_CONFIGURATION_serialize_diagnostics(const struct GNUNET_CONFIGURATION_Handle *cfg)
Serializes the given configuration with diagnostics information.
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_default(void)
Return GNUnet's default configuration.
enum GNUNET_GenericReturnValue(* GNUNET_CONFIGURATION_Callback)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Signature of a function to be run with a configuration.
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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
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.
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_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...
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.
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_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
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.
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_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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
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.
Definition: gnunet_common.h:96
static unsigned int size
Size of the "table".
Definition: peer.c:67
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.