build: ldflags conversion: alsa.
[paraslash.git] / ggo.h
1 /*
2  * Copyright (C) 2008-2013 Andre Noll <maan@systemlinux.org>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** \file ggo.h Functions and structures for help text handling. */
8
9 /**
10  * Information extracted from the .cmdline.h header files.
11  */
12 struct ggo_help {
13         /** Program or module (receiver, filter, writer) name. */
14         const char *prefix;
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. */
20         const char *purpose;
21         /** Generated by gengetopt and exported via the *.cmdline.h file. */
22         const char *usage;
23         /** The description text given in the .ggo file. */
24         const char *description;
25 };
26
27 /**
28  * Control the output of \ref ggo_print_help().
29  *
30  * Any combination of these flags may be passed to ggo_print_help().
31  * Note that the list of supported options is always printed.
32  */
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,
42 };
43
44 /** Used to print the normal help of programs (--help) */
45 #define GPH_STANDARD_FLAGS \
46         (GPH_PRINT_NAME_PURPOSE | GPH_PRINT_USAGE)
47
48 /** Additional information for --detailed-help. */
49 #define GPH_STANDARD_FLAGS_DETAILED \
50         (GPH_STANDARD_FLAGS | GPH_DETAILED | GPH_PRINT_DESCRIPTION)
51
52 /** For module help embedded in a program help. */
53 #define GPH_MODULE_FLAGS 0
54
55 /** Modules help with detailed descriptions. */
56 #define GPH_MODULE_FLAGS_DETAILED GPH_DETAILED | GPH_PRINT_DESCRIPTION
57
58 /** Make a ggo_help structure using information from the .cmdline.h file. */
59 #define DEFINE_GGO_HELP(_prefix) \
60         { \
61                 .prefix = #_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, \
67         }
68
69 void ggo_print_help(struct ggo_help *help, unsigned flags);
70 __printf_1_2 int printf_or_die(const char *fmt, ...);