para_afh: Accept more than one input file in info mode.
[paraslash.git] / ggo.c
1 /*
2  * Copyright (C) 2008 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 __printf_1_2 void printf_or_die(const char *fmt, ...)
14 {
15         va_list argp;
16         int ret;
17
18         va_start(argp, fmt);
19         ret = vprintf(fmt, argp);
20         va_end(argp);
21         if (ret >= 0)
22                 return;
23         fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(errno));
24 }
25
26 void ggo_print_help(struct ggo_help *help, int detailed_help)
27 {
28         const char **p;
29
30         if (!help)
31                 return;
32         if (detailed_help)
33                 p = help->detailed_help;
34         else
35                 p = help->short_help;
36         if (!p)
37                 return;
38         p += 3; /* skip -h and -V */
39         for (; *p; p++)
40                 printf_or_die("\t%s\n", *p);
41 }