2 * Copyright (C) 2008 Andre Noll <maan@tuebingen.mpg.de>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file ggo.c Function for printing help. */
15 * Wrapper for printf() that exits on errors.
17 * \param fmt Usual format string.
19 * \return The return value of the underlying (successful) call to vprintf(3),
20 * i.e. the number of characters printed, excluding the terminating null byte.
22 __printf_1_2
int printf_or_die(const char *fmt
, ...)
28 ret
= vprintf(fmt
, argp
);
36 * Print one of the two given help texts.
38 * \param help contains the help texts.
39 * \param flags What to print, see \ref ggo_print_help_flags.
41 void ggo_print_help(struct ggo_help
*help
, unsigned flags
)
45 if (help
->purpose
&& (flags
& GPH_PRINT_NAME_PURPOSE
))
46 printf_or_die("para_%s - %s\n", help
->prefix
, help
->purpose
);
47 if (help
->usage
&& (flags
& GPH_PRINT_USAGE
))
48 printf_or_die("\n%s\n", help
->usage
);
49 if (help
->description
&& (flags
& GPH_PRINT_DESCRIPTION
))
50 printf_or_die("\n%s\n", help
->description
);
52 if (flags
& GPH_DETAILED
)
53 p
= help
->detailed_help
;
59 printf_or_die("%s\n", *p
);