diff options
-rw-r--r-- | man/xmessage.man | 13 | ||||
-rw-r--r-- | xmessage.c | 25 |
2 files changed, 34 insertions, 4 deletions
diff --git a/man/xmessage.man b/man/xmessage.man index 4b6dfdc..6499d0a 100644 --- a/man/xmessage.man +++ b/man/xmessage.man @@ -27,6 +27,13 @@ xmessage \- display a message or query in a window (X-based /bin/echo) ] .I message \&.\|.\|. +.br +.B xmessage +[ +.B \-help +| +.B \-version +] .SH DESCRIPTION The .I xmessage @@ -101,6 +108,12 @@ Equivalent to setting the \fBnearMouse\fP resource to TRUE. Exit with status 0 after \fIsecs\fP seconds if the user has not clicked on a button yet. The corresponding resource is \fBtimeout\fP. +.TP 8 +.B \-help +Print a usage message and exit. +.TP 8 +.B \-version +Print version info and exit. .SH "WIDGET HIERARCHY" Knowing the name and position in the hierarchy of each widget is useful when specifying resources for them. In the following chart, the @@ -29,6 +29,10 @@ from the X Consortium. */ /* $XFree86: xc/programs/xmessage/xmessage.c,v 1.4 2000/02/17 16:53:03 dawes Exp $ */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <assert.h> #include <X11/Intrinsic.h> #include <X11/StringDefs.h> @@ -307,6 +311,23 @@ 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(stdout); + exit(0); + } + if (strcmp (argn, "-version") == 0) { + puts (PACKAGE_STRING); + exit (0); + } + } + top = XtAppInitialize (&app_con, "Xmessage", optionList, XtNumber(optionList), &argc, argv, fallback_resources, NULL, 0); @@ -314,10 +335,6 @@ main (int argc, char *argv[]) XtGetApplicationResources (top, (XtPointer) &qres, resources, XtNumber(resources), NULL, 0); - if (argc > 1 && !strcmp(argv[1], "-help")) { - usage(stdout); - exit(0); - } if (argc == 1 && qres.file != NULL) { message_str = read_file (qres.file, &message_len); if (message_str == NULL) { |