gnunet-android

GNUnet for Android
Log | Files | Refs | README

gnunet_configuration_lib.h (24162B)


      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 
     21 /**
     22  * @addtogroup libgnunetutil
     23  * Multi-function utilities library for GNUnet programs
     24  * @{
     25  *
     26  * @author Christian Grothoff
     27  *
     28  * @file
     29  * Configuration API
     30  *
     31  * @defgroup configuration  Configuration library
     32  * Configuration management
     33  * @{
     34  */
     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
     42 extern "C"
     43 {
     44 #if 0                           /* keep Emacsens' auto-indent happy */
     45 }
     46 #endif
     47 #endif
     48 
     49 /**
     50  * A configuration object.
     51  */
     52 struct GNUNET_CONFIGURATION_Handle;
     53 
     54 /**
     55  * Create a new configuration object.
     56  *
     57  * @param pd project data to use to determine paths
     58  * @return fresh configuration object
     59  */
     60 struct GNUNET_CONFIGURATION_Handle *
     61 GNUNET_CONFIGURATION_create (const struct GNUNET_OS_ProjectData *pd);
     62 
     63 
     64 /**
     65  * Duplicate an existing configuration object.
     66  *
     67  * @param cfg configuration to duplicate
     68  * @return duplicate configuration
     69  */
     70 struct GNUNET_CONFIGURATION_Handle *
     71 GNUNET_CONFIGURATION_dup (
     72   const struct GNUNET_CONFIGURATION_Handle *cfg);
     73 
     74 
     75 /**
     76  * Destroy configuration object.
     77  *
     78  * @param cfg configuration to destroy
     79  */
     80 void
     81 GNUNET_CONFIGURATION_destroy (
     82   struct GNUNET_CONFIGURATION_Handle *cfg);
     83 
     84 
     85 /**
     86  * Load configuration.  This function will first parse the
     87  * defaults and then parse the specific configuration file
     88  * to overwrite the defaults.
     89  *
     90  * @param[in,out] cfg configuration to update
     91  * @param filename name of the configuration file, NULL to load defaults
     92  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
     93  */
     94 enum GNUNET_GenericReturnValue
     95 GNUNET_CONFIGURATION_load (
     96   struct GNUNET_CONFIGURATION_Handle *cfg,
     97   const char *filename);
     98 
     99 
    100 /**
    101  * Load default configuration.  This function will parse the
    102  * defaults from the given @a defaults_d directory.
    103  *
    104  * @param cfg configuration to update
    105  * @param defaults_d directory with the defaults
    106  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    107  */
    108 enum GNUNET_GenericReturnValue
    109 GNUNET_CONFIGURATION_load_from (
    110   struct GNUNET_CONFIGURATION_Handle *cfg,
    111   const char *defaults_d);
    112 
    113 
    114 /**
    115  * Return the filename of the default configuration filename
    116  * that is used when no explicit configuration entry point
    117  * has been specified.
    118  *
    119  * @param pd project data to use to determine paths
    120  * @returns NULL if no default configuration file can be located,
    121  *          a newly allocated string otherwise
    122  */
    123 char *
    124 GNUNET_CONFIGURATION_default_filename (
    125   const struct GNUNET_OS_ProjectData *pd);
    126 
    127 
    128 /**
    129  * Parse a configuration file, add all of the options in the
    130  * file to the configuration environment.
    131  *
    132  * @param cfg configuration to update
    133  * @param filename name of the configuration file
    134  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    135  */
    136 enum GNUNET_GenericReturnValue
    137 GNUNET_CONFIGURATION_parse (
    138   struct GNUNET_CONFIGURATION_Handle *cfg,
    139   const char *filename);
    140 
    141 
    142 /**
    143  * Serializes the given configuration.
    144  *
    145  * @param cfg configuration to serialize
    146  * @param size will be set to the size of the serialized memory block
    147  * @return the memory block where the serialized configuration is
    148  *           present. This memory should be freed by the caller
    149  */
    150 char *
    151 GNUNET_CONFIGURATION_serialize (
    152   const struct GNUNET_CONFIGURATION_Handle *cfg,
    153   size_t *size);
    154 
    155 
    156 /**
    157  * Serializes the given configuration with diagnostics information.
    158  * Diagnostics information will only be available if diagnostics
    159  * have been enabled before parsing.
    160  *
    161  * @param cfg configuration to serialize
    162  * @return the memory block where the serialized configuration is
    163  *           present. This memory should be freed by the caller
    164  */
    165 char *
    166 GNUNET_CONFIGURATION_serialize_diagnostics (
    167   const struct GNUNET_CONFIGURATION_Handle *cfg);
    168 
    169 
    170 /**
    171  * De-serializes configuration
    172  *
    173  * @param cfg configuration to update
    174  * @param mem the memory block of serialized configuration
    175  * @param size the size of the memory block
    176  * @param source_filename source filename, will be used
    177  *        to resolve relative \@INLINE\@ statements
    178  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    179  */
    180 enum GNUNET_GenericReturnValue
    181 GNUNET_CONFIGURATION_deserialize (
    182   struct GNUNET_CONFIGURATION_Handle *cfg,
    183   const char *mem,
    184   size_t size,
    185   const char *source_filename);
    186 
    187 
    188 /**
    189  * Write configuration file.
    190  *
    191  * @param cfg configuration to write
    192  * @param filename where to write the configuration
    193  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    194  */
    195 enum GNUNET_GenericReturnValue
    196 GNUNET_CONFIGURATION_write (
    197   struct GNUNET_CONFIGURATION_Handle *cfg,
    198   const char *filename);
    199 
    200 
    201 /**
    202  * Write only configuration entries that have been changed to configuration file
    203  *
    204  * @param cfg_default default configuration
    205  * @param cfg_new new configuration
    206  * @param filename where to write the configuration diff between default and new
    207  * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
    208  */
    209 enum GNUNET_GenericReturnValue
    210 GNUNET_CONFIGURATION_write_diffs (
    211   const struct GNUNET_CONFIGURATION_Handle *cfg_default,
    212   const struct GNUNET_CONFIGURATION_Handle *cfg_new,
    213   const char *filename);
    214 
    215 
    216 /**
    217  * Compute configuration with only entries that have been changed
    218  *
    219  * @param cfg_default original configuration
    220  * @param cfg_new new configuration
    221  * @return configuration with only the differences, never NULL
    222  */
    223 struct GNUNET_CONFIGURATION_Handle *
    224 GNUNET_CONFIGURATION_get_diff (
    225   const struct GNUNET_CONFIGURATION_Handle *cfg_default,
    226   const struct GNUNET_CONFIGURATION_Handle *cfg_new);
    227 
    228 
    229 /**
    230  * Test if there are configuration options that were
    231  * changed since the last save.
    232  *
    233  * @param cfg configuration to inspect
    234  * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on error (i.e. last save failed)
    235  */
    236 enum GNUNET_GenericReturnValue
    237 GNUNET_CONFIGURATION_is_dirty (
    238   const struct GNUNET_CONFIGURATION_Handle *cfg);
    239 
    240 
    241 /**
    242  * Signature of a function to be run with a configuration.
    243  *
    244  * @param cls closure
    245  * @param cfg the configuration
    246  * @return status code
    247  */
    248 typedef enum GNUNET_GenericReturnValue
    249 (*GNUNET_CONFIGURATION_Callback)(
    250   void *cls,
    251   const struct GNUNET_CONFIGURATION_Handle *cfg);
    252 
    253 
    254 /**
    255  * Parse a configuration file @a filename and run the function
    256  * @a cb with the resulting configuration object. Then free the
    257  * configuration object and return the status value from @a cb.
    258  *
    259  * @param pd project data to use to determine paths
    260  * @param filename configuration to parse, NULL for "default"
    261  * @param cb function to run
    262  * @param cb_cls closure for @a cb
    263  * @return #GNUNET_SYSERR if parsing the configuration failed,
    264  *   otherwise return value from @a cb.
    265  */
    266 enum GNUNET_GenericReturnValue
    267 GNUNET_CONFIGURATION_parse_and_run (
    268   const struct GNUNET_OS_ProjectData *pd,
    269   const char *filename,
    270   GNUNET_CONFIGURATION_Callback cb,
    271   void *cb_cls);
    272 
    273 /**
    274  * Enable extra diagnostics.  Will produce more log output
    275  * and allocate more memory.
    276  *
    277  * @param cfg configuration handle
    278  */
    279 void
    280 GNUNET_CONFIGURATION_enable_diagnostics (
    281   struct GNUNET_CONFIGURATION_Handle *cfg);
    282 
    283 
    284 /**
    285  * Return the project data associated with this configuration.
    286  *
    287  * @param cfg a configuration
    288  * @return associated project data, never NULL
    289  */
    290 const struct GNUNET_OS_ProjectData *
    291 GNUNET_CONFIGURATION_get_project_data (
    292   const struct GNUNET_CONFIGURATION_Handle *cfg);
    293 
    294 
    295 /**
    296  * Function to iterate over options.
    297  *
    298  * @param cls closure
    299  * @param section name of the section
    300  * @param option name of the option
    301  * @param value value of the option
    302  */
    303 typedef void
    304 (*GNUNET_CONFIGURATION_Iterator) (void *cls,
    305                                   const char *section,
    306                                   const char *option,
    307                                   const char *value);
    308 
    309 
    310 /**
    311  * Function to iterate over section.
    312  *
    313  * @param cls closure
    314  * @param section name of the section
    315  */
    316 typedef void
    317 (*GNUNET_CONFIGURATION_SectionIterator) (void *cls,
    318                                          const char *section);
    319 
    320 
    321 /**
    322  * Iterate over all options in the configuration.
    323  *
    324  * @param cfg configuration to inspect
    325  * @param iter function to call on each option
    326  * @param iter_cls closure for @a iter
    327  */
    328 void
    329 GNUNET_CONFIGURATION_iterate (
    330   const struct GNUNET_CONFIGURATION_Handle *cfg,
    331   GNUNET_CONFIGURATION_Iterator iter,
    332   void *iter_cls);
    333 
    334 
    335 /**
    336  * Iterate over all sections in the configuration.
    337  *
    338  * @param cfg configuration to inspect
    339  * @param iter function to call on each section
    340  * @param iter_cls closure for @a iter
    341  */
    342 void
    343 GNUNET_CONFIGURATION_iterate_sections (
    344   const struct GNUNET_CONFIGURATION_Handle *cfg,
    345   GNUNET_CONFIGURATION_SectionIterator iter,
    346   void *iter_cls);
    347 
    348 
    349 /**
    350  * Remove the given section and all options in it.
    351  *
    352  * @param cfg configuration to inspect
    353  * @param section name of the section to remove
    354  */
    355 void
    356 GNUNET_CONFIGURATION_remove_section (
    357   struct GNUNET_CONFIGURATION_Handle *cfg,
    358   const char *section);
    359 
    360 
    361 /**
    362  * Get a configuration value that should be a number.
    363  *
    364  * @param cfg configuration to inspect
    365  * @param section section of interest
    366  * @param option option of interest
    367  * @param number where to store the numeric value of the option
    368  * @return #GNUNET_OK on success,
    369  *         #GNUNET_NO if option is not set
    370  *         #GNUNET_SYSERR on error (value is malformed)
    371  */
    372 enum GNUNET_GenericReturnValue
    373 GNUNET_CONFIGURATION_get_value_number (
    374   const struct GNUNET_CONFIGURATION_Handle *cfg,
    375   const char *section,
    376   const char *option,
    377   unsigned long long *number);
    378 
    379 /**
    380  * Set a configuration value that should be a float.
    381  * Note that this possibly truncates your float value.
    382  *
    383  * @param cfg configuration to update
    384  * @param section section of interest
    385  * @param option option of interest
    386  * @param number value to set
    387  */
    388 void
    389 GNUNET_CONFIGURATION_set_value_float (struct GNUNET_CONFIGURATION_Handle *cfg,
    390                                        const char *section,
    391                                        const char *option,
    392                                        float number);
    393 
    394 /**
    395  * Get a configuration value that should be a floating point number.
    396  *
    397  * @param cfg configuration to inspect
    398  * @param section section of interest
    399  * @param option option of interest
    400  * @param number where to store the floating value of the option
    401  * @return #GNUNET_OK on success,
    402  *         #GNUNET_NO if option is not set
    403  *         #GNUNET_SYSERR on error (value is malformed)
    404  */
    405 enum GNUNET_GenericReturnValue
    406 GNUNET_CONFIGURATION_get_value_float (
    407   const struct GNUNET_CONFIGURATION_Handle *cfg,
    408   const char *section,
    409   const char *option,
    410   float *number);
    411 
    412 
    413 /**
    414  * Get a configuration value that should be a relative time.
    415  *
    416  * @param cfg configuration to inspect
    417  * @param section section of interest
    418  * @param option option of interest
    419  * @param time set to the time value stored in the configuration
    420  * @return #GNUNET_OK on success,
    421  *         #GNUNET_NO if option is not set
    422  *         #GNUNET_SYSERR on error (value is malformed)
    423  */
    424 enum GNUNET_GenericReturnValue
    425 GNUNET_CONFIGURATION_get_value_time (
    426   const struct GNUNET_CONFIGURATION_Handle *cfg,
    427   const char *section,
    428   const char *option,
    429   struct GNUNET_TIME_Relative *time);
    430 
    431 
    432 /**
    433  * Get a configuration value that should be a size in bytes.
    434  *
    435  * @param cfg configuration to inspect
    436  * @param section section of interest
    437  * @param option option of interest
    438  * @param size set to the size in bytes as stored in the configuration
    439  * @return #GNUNET_OK on success,
    440  *         #GNUNET_NO if option is not set
    441  *         #GNUNET_SYSERR on error (value is malformed)
    442  */
    443 enum GNUNET_GenericReturnValue
    444 GNUNET_CONFIGURATION_get_value_size (
    445   const struct GNUNET_CONFIGURATION_Handle *cfg,
    446   const char *section,
    447   const char *option,
    448   unsigned long long *size);
    449 
    450 
    451 /**
    452  * Test if we have a value for a particular option
    453  *
    454  * @param cfg configuration to inspect
    455  * @param section section of interest
    456  * @param option option of interest
    457  * @return #GNUNET_YES if so, #GNUNET_NO if not.
    458  */
    459 enum GNUNET_GenericReturnValue
    460 GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg,
    461                                  const char *section,
    462                                  const char *option);
    463 
    464 
    465 /**
    466  * Get a configuration value that should be a string.
    467  *
    468  * @param cfg configuration to inspect
    469  * @param section section of interest
    470  * @param option option of interest
    471  * @param value will be set to a freshly allocated configuration
    472  *        value, or NULL if option is not specified
    473  * @return #GNUNET_OK on success,
    474  *         #GNUNET_NO if option is not set
    475  *         #GNUNET_SYSERR on error (value is malformed)
    476  */
    477 enum GNUNET_GenericReturnValue
    478 GNUNET_CONFIGURATION_get_value_string (
    479   const struct GNUNET_CONFIGURATION_Handle *cfg,
    480   const char *section,
    481   const char *option,
    482   char **value);
    483 
    484 
    485 /**
    486  * Get a configuration value that should be the name of a file
    487  * or directory.
    488  *
    489  * @param cfg configuration to inspect
    490  * @param section section of interest
    491  * @param option option of interest
    492  * @param value will be set to a freshly allocated configuration
    493  *        value, or NULL if option is not specified
    494  * @return #GNUNET_OK on success,
    495  *         #GNUNET_NO if option is not set
    496  *         #GNUNET_SYSERR on error (value is malformed)
    497  */
    498 enum GNUNET_GenericReturnValue
    499 GNUNET_CONFIGURATION_get_value_filename (
    500   const struct GNUNET_CONFIGURATION_Handle *cfg,
    501   const char *section,
    502   const char *option,
    503   char **value);
    504 
    505 
    506 /**
    507  * Iterate over the set of filenames stored in a configuration value.
    508  *
    509  * @param cfg configuration to inspect
    510  * @param section section of interest
    511  * @param option option of interest
    512  * @param cb function to call on each filename
    513  * @param cb_cls closure for @a cb
    514  * @return number of filenames iterated over, -1 on error
    515  */
    516 int
    517 GNUNET_CONFIGURATION_iterate_value_filenames (
    518   const struct GNUNET_CONFIGURATION_Handle *cfg,
    519   const char *section,
    520   const char *option,
    521   GNUNET_FileNameCallback cb,
    522   void *cb_cls);
    523 
    524 
    525 /**
    526  * Iterate over values of a section in the configuration.
    527  *
    528  * @param cfg configuration to inspect
    529  * @param section the section
    530  * @param iter function to call on each option
    531  * @param iter_cls closure for @a iter
    532  */
    533 void
    534 GNUNET_CONFIGURATION_iterate_section_values (
    535   const struct GNUNET_CONFIGURATION_Handle *cfg,
    536   const char *section,
    537   GNUNET_CONFIGURATION_Iterator iter,
    538   void *iter_cls);
    539 
    540 
    541 /**
    542  * Get a configuration value that should be in a set of
    543  * predefined strings
    544  *
    545  * @param cfg configuration to inspect
    546  * @param section section of interest
    547  * @param option option of interest
    548  * @param choices NULL-terminated list of legal values
    549  * @param value will be set to an entry in the legal list,
    550  *        or NULL if option is not specified and no default given
    551  * @return #GNUNET_OK on success,
    552  *         #GNUNET_NO if option is not set
    553  *         #GNUNET_SYSERR on error (value not in @a choices)
    554  */
    555 enum GNUNET_GenericReturnValue
    556 GNUNET_CONFIGURATION_get_value_choice (
    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 
    564 /**
    565  * Get a configuration value that should be in a set of
    566  * "YES" or "NO".
    567  *
    568  * @param cfg configuration to inspect
    569  * @param section section of interest
    570  * @param option option of interest
    571  * @return #GNUNET_OK if option is set to "YES"
    572  *         #GNUNET_NO if option is not set or "NO"
    573  *         #GNUNET_SYSERR on error (neither YES nor NO)
    574  */
    575 enum GNUNET_GenericReturnValue
    576 GNUNET_CONFIGURATION_get_value_yesno (
    577   const struct GNUNET_CONFIGURATION_Handle *cfg,
    578   const char *section,
    579   const char *option);
    580 
    581 
    582 /**
    583  * Get Crockford32-encoded fixed-size binary data from a configuration.
    584  *
    585  * @param cfg configuration to access
    586  * @param section section to access
    587  * @param option option to access
    588  * @param buf where to store the decoded binary result
    589  * @param buf_size exact number of bytes to store in @a buf
    590  * @return #GNUNET_OK on success
    591  *         #GNUNET_NO is the value does not exist
    592  *         #GNUNET_SYSERR on decoding error
    593  */
    594 enum GNUNET_GenericReturnValue
    595 GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
    596                                const char *section,
    597                                const char *option,
    598                                void *buf,
    599                                size_t buf_size);
    600 
    601 
    602 /**
    603  * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
    604  * where either in the "PATHS" section or the environment "FOO" is
    605  * set to "DIRECTORY".  We also support default expansion,
    606  * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is
    607  * set in PATHS or the environment, and otherwise to "default".  Note
    608  * that "default" itself can also be a $-expression, thus
    609  * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined
    610  * to VAR2.
    611  *
    612  * @param cfg configuration to use for path expansion
    613  * @param orig string to $-expand (will be freed!)  Note that multiple
    614  *          $-expressions can be present in this string.  They will all be
    615  *          $-expanded.
    616  * @return $-expanded string
    617  */
    618 char *
    619 GNUNET_CONFIGURATION_expand_dollar (
    620   const struct GNUNET_CONFIGURATION_Handle *cfg,
    621   char *orig);
    622 
    623 
    624 /**
    625  * Set a configuration value that should be a number.
    626  *
    627  * @param cfg configuration to update
    628  * @param section section of interest
    629  * @param option option of interest
    630  * @param number value to set
    631  */
    632 void
    633 GNUNET_CONFIGURATION_set_value_number (
    634   struct GNUNET_CONFIGURATION_Handle *cfg,
    635   const char *section,
    636   const char *option,
    637   unsigned long long number);
    638 
    639 
    640 /**
    641  * Set a configuration value that should be a string.
    642  *
    643  * @param cfg configuration to update
    644  * @param section section of interest
    645  * @param option option of interest
    646  * @param value value to set
    647  */
    648 void
    649 GNUNET_CONFIGURATION_set_value_string (
    650   struct GNUNET_CONFIGURATION_Handle *cfg,
    651   const char *section,
    652   const char *option,
    653   const char *value);
    654 
    655 
    656 /**
    657  * Remove a filename from a configuration value that
    658  * represents a list of filenames
    659  *
    660  * @param cfg configuration to update
    661  * @param section section of interest
    662  * @param option option of interest
    663  * @param value filename to remove
    664  * @return #GNUNET_OK on success,
    665  *         #GNUNET_SYSERR if the filename is not in the list
    666  */
    667 enum GNUNET_GenericReturnValue
    668 GNUNET_CONFIGURATION_remove_value_filename (
    669   struct GNUNET_CONFIGURATION_Handle *cfg,
    670   const char *section,
    671   const char *option,
    672   const char *value);
    673 
    674 
    675 /**
    676  * Append a filename to a configuration value that
    677  * represents a list of filenames
    678  *
    679  * @param cfg configuration to update
    680  * @param section section of interest
    681  * @param option option of interest
    682  * @param value filename to append
    683  * @return #GNUNET_OK on success,
    684  *         #GNUNET_SYSERR if the filename already in the list
    685  */
    686 enum GNUNET_GenericReturnValue
    687 GNUNET_CONFIGURATION_append_value_filename (
    688   struct GNUNET_CONFIGURATION_Handle *cfg,
    689   const char *section,
    690   const char *option,
    691   const char *value);
    692 
    693 
    694 /**
    695  * Closure for #GNUNET_CONFIGURATION_config_tool_run()
    696  * with settings for what should be done with the
    697  * configuration.
    698  */
    699 struct GNUNET_CONFIGURATION_ConfigSettings
    700 {
    701 
    702   /**
    703    * Must be set to the API version, i.e.  #GNUNET_UTIL_VERSION. Used to
    704    * detect which version of the struct the client is using.
    705    */
    706   unsigned int api_version;
    707 
    708   /**
    709    * Name of the section
    710    */
    711   char *section;
    712 
    713   /**
    714    * Name of the option
    715    */
    716   char *option;
    717 
    718   /**
    719    * Value to set
    720    */
    721   char *value;
    722 
    723   /**
    724    * Treat option as a filename.
    725    */
    726   int is_filename;
    727 
    728   /**
    729    * Whether to show the sections.
    730    */
    731   int list_sections;
    732 
    733   /**
    734    * Should we write out the configuration file, even if no value was changed?
    735    */
    736   int rewrite;
    737 
    738   /**
    739    * Should we give extra diagnostics?
    740    */
    741   int diagnostics;
    742 
    743   /**
    744    * Should the generated configuration file contain the whole configuration?
    745    */
    746   int full;
    747 
    748   /**
    749    * Return value from the operation, to be returned
    750    * from 'main'.
    751    */
    752   int global_ret;
    753 
    754 };
    755 
    756 
    757 /**
    758  * Macro that expands to a set of GNUNET-getopt directives
    759  * to initialize a `struct GNUNET_CONFIGURATION_ConfigSettings`
    760  * from the command line.
    761  *
    762  * @param cs configuration settings to initialize
    763  */
    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 
    813 /**
    814  * Free resources associated with @a cs.
    815  *
    816  * @param[in] cs settings to free (actual memory
    817  *     of @a cs itself is not released)
    818  */
    819 void
    820 GNUNET_CONFIGURATION_config_settings_free (
    821   struct GNUNET_CONFIGURATION_ConfigSettings *cs);
    822 
    823 
    824 /**
    825  * Main task to run to perform operations typical for
    826  * gnunet-config as per the configuration settings
    827  * given in @a cls.
    828  *
    829  * @param cls closure with the `struct GNUNET_CONFIGURATION_ConfigSettings`
    830  * @param args remaining command-line arguments
    831  * @param cfgfile name of the configuration file used (for saving,
    832  *                                                     can be NULL!)
    833  * @param cfg configuration
    834  */
    835 void
    836 GNUNET_CONFIGURATION_config_tool_run (
    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 
    852 /** @} */ /* end of group configuration */
    853 
    854 /** @} */ /* end of group addition */