aboutsummaryrefslogtreecommitdiff
path: root/src/_usage.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-04-17 12:44:32 +0000
committerMike Frysinger <vapier@gentoo.org>2007-04-17 12:44:32 +0000
commit9d50d4cb258ad0e63ca85467817bccf9765d8326 (patch)
tree437f66d62899212562a74879c52bfd842bacfe2b /src/_usage.c
parentf5e65274f0f150d6db9f53f87e87eb6d984f8e94 (diff)
start unifying help handling
Diffstat (limited to 'src/_usage.c')
-rw-r--r--src/_usage.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/_usage.c b/src/_usage.c
new file mode 100644
index 00000000..89258185
--- /dev/null
+++ b/src/_usage.c
@@ -0,0 +1,26 @@
+/*
+ * @file _usage.c
+ * @brief standardize help/usage output across all our programs
+ * @internal
+ *
+ * Copyright 2007 Gentoo Foundation
+ * Released under the GPLv2
+ */
+
+#ifndef APPLET
+# error you forgot to define APPLET
+#endif
+
+static void usage (int exit_status)
+{
+ int i;
+ printf ("Usage: " APPLET " [options]\n\n");
+ printf ("Options: [" getoptstring "]\n");
+ for (i = 0; longopts[i].name; ++i)
+ printf (" -%c, --%s\n", longopts[i].val, longopts[i].name);
+ exit (exit_status);
+}
+
+#define case_RC_COMMON_GETOPT \
+ case 'h': usage (EXIT_SUCCESS); \
+ default: usage (EXIT_FAILURE);