summaryrefslogtreecommitdiff
path: root/viewres.c
diff options
context:
space:
mode:
Diffstat (limited to 'viewres.c')
-rw-r--r--viewres.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/viewres.c b/viewres.c
index 56ba828..4ef84d2 100644
--- a/viewres.c
+++ b/viewres.c
@@ -29,6 +29,10 @@ in this Software without prior written authorization from the X Consortium.
*/
/* $XFree86: xc/programs/viewres/viewres.c,v 1.6 2003/05/27 22:26:58 tsi Exp $ */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <X11/StringDefs.h>
@@ -100,6 +104,8 @@ static const char *help_message[] = {
"-top name object to be top of tree",
"-variable show variable name instead of class name",
"-vertical list the tree vertically",
+ "-help print this message",
+ "-version print version info",
NULL
};
@@ -229,7 +235,7 @@ static Arg true_args[1] = {{ XtNstate, (XtArgVal) TRUE }};
* routines
*/
static void
-usage(void)
+usage(int exitval)
{
fprintf(stderr, "usage: %s [-options...]\n", ProgramName);
fprintf(stderr, "\nwhere options include:\n");
@@ -237,7 +243,7 @@ usage(void)
fprintf(stderr, " %s\n", *cpp);
}
fprintf(stderr, "\n");
- exit(1);
+ exit(exitval);
}
static XmuWidgetNode *
@@ -891,6 +897,22 @@ main(int argc, char *argv[])
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
+ /* Handle args that don't require opening a display */
+ for (int n = 1; n < argc; n++) {
+ const char *argn = argv[n];
+ /* accept single or double dash for -help & -version */
+ if (argn[0] == '-' && argn[1] == '-') {
+ argn++;
+ }
+ if (strcmp(argn, "-help") == 0) {
+ usage(0);
+ }
+ if (strcmp(argn, "-version") == 0) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ }
+
toplevel = XtAppInitialize(&app_con, "Viewres",
Options, XtNumber(Options),
&argc, argv, (String *) fallback_resources,
@@ -901,7 +923,7 @@ main(int argc, char *argv[])
fprintf(stderr, " %s", argv[n]);
}
fputs("\n\n", stderr);
- usage();
+ usage(1);
}
initialize_widgetnode_list(&selected_list.elements,