/*
- * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2008-2013 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
#include "para.h"
#include "ggo.h"
-__printf_1_2 void printf_or_die(const char *fmt, ...)
+/**
+ * Wrapper for printf() that exits on errors.
+ *
+ * \param fmt Usual format string.
+ */
+__printf_1_2 int printf_or_die(const char *fmt, ...)
{
va_list argp;
int ret;
ret = vprintf(fmt, argp);
va_end(argp);
if (ret >= 0)
- return;
- fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(errno));
+ return ret;
+ exit(EXIT_FAILURE);
}
+/**
+ * Print one of the two given help texts.
+ *
+ * \param help contains the help texts.
+ * \param detailed_help Whether to print the detailed help text.
+ */
void ggo_print_help(struct ggo_help *help, int detailed_help)
{
const char **p;
p = help->short_help;
if (!p)
return;
- p += 3; /* skip -h and -V */
for (; *p; p++)
printf_or_die("\t%s\n", *p);
}