2 * Copyright (C) 2008-2014 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file ggo.h Functions and structures for help text handling. */
10 * Information extracted from the .cmdline.h header files.
13 /** Program or module (receiver, filter, writer) name. */
15 /** Generated by gengetopt from the options in the .ggo file. */
16 const char **short_help;
17 /** Like \a short_help, plus the \a details section. */
18 const char **detailed_help;
19 /** The purpose text as specified in the ggo file. */
21 /** Generated by gengetopt and exported via the *.cmdline.h file. */
23 /** The description text given in the .ggo file. */
24 const char *description;
28 * Control the output of \ref ggo_print_help().
30 * Any combination of these flags may be passed to ggo_print_help().
31 * Note that the list of supported options is always printed.
33 enum ggo_print_help_flags {
34 /** Whether to print the short help or the detailed help. */
35 GPH_DETAILED = 1 << 0,
36 /** Print the program or module name and the purpose text. */
37 GPH_PRINT_NAME_PURPOSE = 1 << 1,
38 /** Print the synopsis. */
39 GPH_PRINT_USAGE = 1 << 2,
40 /** Print the description text. */
41 GPH_PRINT_DESCRIPTION = 1 << 3,
44 /** Used to print the normal help of programs (--help) */
45 #define GPH_STANDARD_FLAGS \
46 (GPH_PRINT_NAME_PURPOSE | GPH_PRINT_USAGE)
48 /** Additional information for --detailed-help. */
49 #define GPH_STANDARD_FLAGS_DETAILED \
50 (GPH_STANDARD_FLAGS | GPH_DETAILED | GPH_PRINT_DESCRIPTION)
52 /** For module help embedded in a program help. */
53 #define GPH_MODULE_FLAGS 0
55 /** Modules help with detailed descriptions. */
56 #define GPH_MODULE_FLAGS_DETAILED GPH_DETAILED | GPH_PRINT_DESCRIPTION
58 /** Make a ggo_help structure using information from the .cmdline.h file. */
59 #define DEFINE_GGO_HELP(_prefix) \
62 .short_help = _prefix ## _args_info_help, \
63 .detailed_help = _prefix ## _args_info_detailed_help, \
64 .purpose = _prefix ## _args_info_purpose, \
65 .usage = _prefix ## _args_info_usage, \
66 .description = _prefix ## _args_info_description, \
69 void ggo_print_help(struct ggo_help *help, unsigned flags);
70 __printf_1_2 int printf_or_die(const char *fmt, ...);