+/**
+ * Report parsing failure, suggest `--help`, and abort the program with
+ * exit code 2.
+ **/
+void opt_failure(const char * mesg, ...) FORMAT_CHECK(printf,1,2) NONRET;
+
+void opt_help(const struct opt_section * sec);
+void opt_handle_help(struct opt_item * opt, const char * value, void * data);
+
+/***
+ * [[conf]]
+ * Cooperating with config file parser
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * Parsing of command-line options and configuration files are usually
+ * intertwined in a somewhat tricky way. We want to provide command-line
+ * options that control the name of the configuration file, or possibly to
+ * override configuration settings from the command line. On the other hand,
+ * regular command-line options can refer to values loaded from the
+ * program's configuration.
+ *
+ * To achieve this goal, the option parser is able to cooperate with the
+ * config file parser. This is enabled by listing the `OPT_CONF_OPTIONS`
+ * macro in the list of command-line options.
+ *
+ * The following options are defined for you:
+ *
+ * - `-C` (`--config`) to load a specific configuration file. This option
+ * suppresses loading of the default configuration, but it can be given
+ * multiple times to merge settings from several files.
+ *
+ * - `-S` (`--set`) to include a part of configuration inline. For example,
+ * you can use `-Ssection.item=value` to change a single configuration item.
+ *
+ * - `--dumpconfig` to dump the configuration to standard output and exit.
+ * (This is available only if the program is compiled with `CONFIG_UCW_DEBUG`.)
+ *
+ * The default configuration file (as specified by <<var_cf_def_file,`cf_def_file`>>) is loaded
+ * as soon as the first option different from `-C` is encountered, unless
+ * a different file has been already loaded. For this reason, `-C` must be
+ * the very first argument given to the program.
+ *
+ * This interface supersedes <<conf:getopt_h,`cf_getopt()`>>.
+ ***/
+
+#ifdef CONFIG_UCW_DEBUG
+#define OPT_CONF_OPTIONS OPT_CONF_CONFIG, OPT_CONF_SET, OPT_CONF_DUMPCONFIG, OPT_CONF_HOOK
+#else
+#define OPT_CONF_OPTIONS OPT_CONF_CONFIG, OPT_CONF_SET, OPT_CONF_HOOK
+#endif
+
+#define OPT_CONF_CONFIG OPT_CALL('C', "config", opt_handle_config, NULL, OPT_BEFORE_CONFIG | OPT_INTERNAL | OPT_REQUIRED_VALUE, "<file>\tOverride the default configuration file")
+#define OPT_CONF_SET OPT_CALL('S', "set", opt_handle_set, NULL, OPT_BEFORE_CONFIG | OPT_INTERNAL | OPT_REQUIRED_VALUE, "<item>\tManual setting of a configuration item")
+#define OPT_CONF_DUMPCONFIG OPT_CALL(0, "dumpconfig", opt_handle_dumpconfig, NULL, OPT_INTERNAL | OPT_NO_VALUE, "\tDump program configuration")
+#define OPT_CONF_HOOK OPT_HOOK(opt_conf_hook_internal, NULL, OPT_HOOK_BEFORE_VALUE | OPT_HOOK_FINAL | OPT_HOOK_INTERNAL)
+
+void opt_handle_config(struct opt_item * opt, const char * value, void * data);
+void opt_handle_set(struct opt_item * opt, const char * value, void * data);
+void opt_handle_dumpconfig(struct opt_item * opt, const char * value, void * data);
+void opt_conf_hook_internal(struct opt_item * opt, uns event, const char * value, void * data);
+
+// XXX: This is duplicated with <ucw/getopt.h>, but that one will hopefully go away one day.
+/**
+ * The name of the default configuration file (NULL if configuration has been
+ * already loaded). It is initialized to `CONFIG_UCW_DEFAULT_CONFIG`, but you
+ * usually want to replace it by your own config file.
+ */
+extern char *cf_def_file;
+/**
+ * Name of environment variable that can override what configuration is loaded.
+ * Defaults to the value of the `CONFIG_UCW_ENV_VAR_CONFIG` compile-time option.
+ **/
+extern char *cf_env_file;
+
+/***
+ * [[hooks]]
+ * Hooks
+ * -----
+ *
+ * You can supply hook functions, which will be called by the parser upon various
+ * events. Hooks are declared as option items of class `OPT_CL_HOOK`, whose @flags
+ * field specifies a mask of events the hook wants to receive.
+ *
+ * Please note that the hook interface is not considered stable yet,
+ * so it might change in future versions of libucw.
+ *
+ * The following events are defined:
+ ***/
+
+#define OPT_HOOK_BEFORE_ARG 0x1 /** Call before option parsing **/
+#define OPT_HOOK_BEFORE_VALUE 0x2 /** Call before value parsing **/
+#define OPT_HOOK_AFTER_VALUE 0x4 /** Call after value parsing **/
+#define OPT_HOOK_FINAL 0x8 /** Call just before opt_parse() returns **/
+#define OPT_HOOK_INTERNAL 0x4000 // Used internally to ask for passing of struct opt_context
+