Add mood methods {artist, title, album, comment}_matches.
[paraslash.git] / ggo.c
1 /*
2 * Copyright (C) 2008-2009 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file ggo.c Function for printing help. */
8
9
10 #include "para.h"
11 #include "ggo.h"
12
13 /**
14 * Wrapper for printf() that exits on errors.
15 *
16 * \param fmt Usual format string.
17 */
18 __printf_1_2 void printf_or_die(const char *fmt, ...)
19 {
20 va_list argp;
21 int ret;
22
23 va_start(argp, fmt);
24 ret = vprintf(fmt, argp);
25 va_end(argp);
26 if (ret >= 0)
27 return;
28 exit(EXIT_FAILURE);
29 }
30
31 /**
32 * Print one of the two given help texts.
33 *
34 * \param help contains the help texts.
35 * \param detailed_help Whether to print the detailed help text.
36 */
37 void ggo_print_help(struct ggo_help *help, int detailed_help)
38 {
39 const char **p;
40
41 if (!help)
42 return;
43 if (detailed_help)
44 p = help->detailed_help;
45 else
46 p = help->short_help;
47 if (!p)
48 return;
49 p += 3; /* skip -h and -V */
50 for (; *p; p++)
51 printf_or_die("\t%s\n", *p);
52 }