aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_configuration_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_configuration_lib.h')
-rw-r--r--src/include/gnunet_configuration_lib.h158
1 files changed, 158 insertions, 0 deletions
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h
index 02e656196..46b745541 100644
--- a/src/include/gnunet_configuration_lib.h
+++ b/src/include/gnunet_configuration_lib.h
@@ -632,6 +632,164 @@ GNUNET_CONFIGURATION_append_value_filename (struct
632 const char *option, 632 const char *option,
633 const char *value); 633 const char *value);
634 634
635
636/**
637 * Closure for #GNUNET_CONFIGURATION_config_tool_run()
638 * with settings for what should be done with the
639 * configuration.
640 */
641struct GNUNET_CONFIGURATION_ConfigSettings
642{
643
644 /**
645 * Name of the section
646 */
647 char *section;
648
649 /**
650 * Name of the option
651 */
652 char *option;
653
654 /**
655 * Value to set
656 */
657 char *value;
658
659 /**
660 * Backend to check if the respective plugin is
661 * loadable. NULL if no check is to be performed.
662 * The value is the "basename" of the plugin to load.
663 */
664 char *backend_check;
665
666 /**
667 * Treat option as a filename.
668 */
669 int is_filename;
670
671 /**
672 * Whether to show the sections.
673 */
674 int list_sections;
675
676 /**
677 * Should we write out the configuration file, even if no value was changed?
678 */
679 int rewrite;
680
681 /**
682 * Should we give extra diagnostics?
683 */
684 int diagnostics;
685
686 /**
687 * Should the generated configuration file contain the whole configuration?
688 */
689 int full;
690
691
692 /**
693 * Return value from the operation, to be returned
694 * from 'main'.
695 */
696 int global_ret;
697
698};
699
700
701/**
702 * Macro that expands to a set of GNUNET-getopt directives
703 * to initialize a `struct GNUNET_CONFIGURATION_ConfigSettings`
704 * from the command line.
705 *
706 * @param cs configuration settings to initialize
707 */
708#define GNUNET_CONFIGURATION_CONFIG_OPTIONS(cs) \
709 GNUNET_GETOPT_option_exclusive ( \
710 GNUNET_GETOPT_option_string ( \
711 'b', \
712 "supported-backend", \
713 "BACKEND", \
714 gettext_noop ( \
715 "test if the current installation supports the specified BACKEND"), \
716 &(cs)->backend_check)), \
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
763/**
764 * Free resources assoicated with @a cs.
765 *
766 * @param[in] cs settings to free (actual memory
767 * of @a cs itself is not released)
768 */
769void
770GNUNET_CONFIGURATION_config_settings_free (
771 struct GNUNET_CONFIGURATION_ConfigSettings *cs);
772
773
774/**
775 * Main task to run to perform operations typical for
776 * gnunet-config as per the configuration settings
777 * given in @a cls.
778 *
779 * @param cls closure with the `struct GNUNET_CONFIGURATION_ConfigSettings`
780 * @param args remaining command-line arguments
781 * @param cfgfile name of the configuration file used (for saving,
782 * can be NULL!)
783 * @param cfg configuration
784 */
785void
786GNUNET_CONFIGURATION_config_tool_run (
787 void *cls,
788 char *const *args,
789 const char *cfgfile,
790 const struct GNUNET_CONFIGURATION_Handle *cfg);
791
792
635#if 0 /* keep Emacsens' auto-indent happy */ 793#if 0 /* keep Emacsens' auto-indent happy */
636{ 794{
637#endif 795#endif