]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - ggo.c
Improve help/man page of para_filter.
[paraslash.git] / ggo.c
diff --git a/ggo.c b/ggo.c
new file mode 100644 (file)
index 0000000..55f1043
--- /dev/null
+++ b/ggo.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
+ *
+ * Licensed under the GPL v2. For licencing details see COPYING.
+ */
+
+/** \file ggo.c Function for printing help. */
+
+
+#include "para.h"
+#include "ggo.h"
+
+__printf_1_2 void printf_or_die(const char *fmt, ...)
+{
+       va_list argp;
+       int ret;
+
+       va_start(argp, fmt);
+       ret = vprintf(fmt, argp);
+       va_end(argp);
+       if (ret >= 0)
+               return;
+       fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(errno));
+}
+
+void ggo_print_help(struct ggo_help *help, int detailed_help)
+{
+       const char **p;
+
+       if (!help)
+               return;
+       if (detailed_help)
+               p = help->detailed_help;
+       else
+               p = help->short_help;
+       if (!p)
+               return;
+       p += 3; /* skip -h and -V */
+       for (; *p; p++)
+               printf_or_die("\t%s\n", *p);
+}