diff options
-rw-r--r-- | man/xmag.man | 13 | ||||
-rw-r--r-- | xmag.c | 31 |
2 files changed, 40 insertions, 4 deletions
diff --git a/man/xmag.man b/man/xmag.man index b6f850f..e608491 100644 --- a/man/xmag.man +++ b/man/xmag.man @@ -37,6 +37,13 @@ xmag \- magnify parts of the screen ] [ .I \-toolkitoption \&.\|.\|. ] +.br +.B xmag +[ +.B \-help +| +.B \-version +] .SH DESCRIPTION The \fIxmag\fP program allows you to magnify portions of an X screen. If no explicit region is specified, a square with the pointer in the upper left @@ -95,5 +102,11 @@ an area of the screen. .TP 15 .B \-mag\fI integer\fP This option indicates the magnification to be used. 5 is the default. +.TP 15 +.B \-help +This option indicates that \fIxmag\fP should print a usage message and exit. +.TP 15 +.B \-version +This option indicates that \fIxmag\fP should print version info and exit. .SH AUTHORS Dave Sternlicht and Davor Matic, MIT X Consortium. @@ -1105,15 +1105,40 @@ ParseSourceGeom(void) +static void +usage(const char *progname, int exitval) +{ + fprintf (stderr, + "usage: %s [-source geom] [-mag magfactor] [-toolkitoption]\n" + " %s [-help|-version]\n", + progname, progname); + exit (exitval); +} + /* * Main program. */ int main(int argc, char *argv[]) { + /* 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(argv[0], 0); + } + if (strcmp(argn, "-version") == 0) { + puts(PACKAGE_STRING); + exit(0); + } + } + XSetErrorHandler(Error); - /* SUPPRESS 594 */ toplevel = XtAppInitialize(&app, "Xmag", optionDesc, XtNumber(optionDesc), &argc, argv, NULL, NULL, 0); @@ -1128,9 +1153,7 @@ main(int argc, char *argv[]) fprintf(stderr, " %s", argv[n]); } fputs("\n\n", stderr); - fprintf (stderr, - "usage: xmag [-source geom] [-mag magfactor] [-toolkitoption]\n"); - exit(1); + usage(argv[0], 1); } |