X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ggo.c;h=e3aa5794cee33815e7c04e1fd033a9a7c34bf244;hp=55f1043082e5c511231616ad6bc5bd6a43e1f6af;hb=533b0303c27fb9ba098bb72e30f41f0939b2dbd2;hpb=40de1dd2fdbb054444d585aa70e2d50166a66e07 diff --git a/ggo.c b/ggo.c index 55f10430..e3aa5794 100644 --- a/ggo.c +++ b/ggo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Andre Noll + * Copyright (C) 2008-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -10,7 +10,12 @@ #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; @@ -19,10 +24,16 @@ __printf_1_2 void printf_or_die(const char *fmt, ...) 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; @@ -35,7 +46,6 @@ void ggo_print_help(struct ggo_help *help, int detailed_help) p = help->short_help; if (!p) return; - p += 3; /* skip -h and -V */ for (; *p; p++) printf_or_die("\t%s\n", *p); }