summaryrefslogtreecommitdiff
path: root/xvidtune.c
diff options
context:
space:
mode:
Diffstat (limited to 'xvidtune.c')
-rw-r--r--xvidtune.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/xvidtune.c b/xvidtune.c
index 2f73bf1..85cd9ce 100644
--- a/xvidtune.c
+++ b/xvidtune.c
@@ -30,6 +30,10 @@ from Kaleb S. KEITHLEY.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
@@ -1477,16 +1481,21 @@ PrevModeAction(Widget w, XEvent* e, String* vector, Cardinal* count)
static void
-usage(void)
+usage(int exitval)
{
- fprintf(stderr, "Usage: %s [-show|-prev|-next|-unlock|-timeout <sec>] [-toolkitoption...]\n", progname);
- fprintf(stderr, " where option is one of:\n");
- fprintf(stderr, " -show Print current modeline to stdout\n");
- fprintf(stderr, " -next Switch to next video mode\n");
- fprintf(stderr, " -prev Switch to previous video mode\n");
- fprintf(stderr, " -unlock Enable mode switch hot-keys\n");
- fprintf(stderr, " -timeout <sec> Set testmode timeout in seconds\n");
- exit(1);
+ FILE *out = (exitval == 0) ? stdout : stderr;
+
+ fprintf(out, "Usage: %s [option] [-toolkitoption...]\n", progname);
+ fprintf(out, " where option is one of:\n"
+ " -show Print current modeline to stdout\n"
+ " -next Switch to next video mode\n"
+ " -prev Switch to previous video mode\n"
+ " -unlock Enable mode switch hot-keys\n"
+ " -timeout <sec> Set testmode timeout in seconds\n"
+ " -help Print this message\n"
+ " -version Print version info\n"
+ );
+ exit(exitval);
}
@@ -1499,6 +1508,22 @@ main (int argc, char** argv)
Bool modeSettable = TRUE;
progname = argv[0];
+
+ /* 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);
+ }
+ }
static XtActionsRec actions[] = { { "xvidtune-quit", QuitAction },
{ "xvidtune-restore", RestoreAction },
@@ -1555,14 +1580,14 @@ main (int argc, char** argv)
TestTimeout = ((unsigned long) atol( argv[2] )) * 1000L;
}
else
- usage();
+ usage(1);
}
if (argc > 1) {
int i = 0;
if (argc != 2)
- usage();
+ usage(1);
if (!strcmp(argv[1], "-show")) {
if (!GetModeLine(XtDisplay (top), DefaultScreen (XtDisplay (top)))) {
fprintf(stderr, "Unable to get mode info\n");
@@ -1580,7 +1605,7 @@ main (int argc, char** argv)
XSync(XtDisplay (top), True);
return 0;
} else
- usage();
+ usage(1);
if (i != 0) {
XF86VidModeSwitchMode(XtDisplay (top),
DefaultScreen (XtDisplay (top)), i);