diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-13 12:38:19 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-13 12:38:19 -0800 |
commit | 250cdac0bcc73e1dee9094ded8612f500370640c (patch) | |
tree | 8f8fae048c8e17410307e1e6a16533bf4b540f2d | |
parent | c6f15b6d67f4c8df2af07848d6277593e24f6352 (diff) |
Add -version option
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | man/xstdcmap.man | 5 | ||||
-rw-r--r-- | xstdcmap.c | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/man/xstdcmap.man b/man/xstdcmap.man index 8c1118b..1685764 100644 --- a/man/xstdcmap.man +++ b/man/xstdcmap.man @@ -44,7 +44,7 @@ xstdcmap - X standard colormap utility .SH SYNOPSIS .B xstdcmap [-all] [-best] [-blue] [-default] [-delete \fImap\fP] [-display \fIdisplay\fP] -[-gray] [-green] [-help] [-red] [-verbose] +[-gray] [-green] [-help] [-red] [-verbose] [-version] .SH DESCRIPTION .PP The \fIxstdcmap\fP utility can be used to selectively define standard colormap @@ -100,6 +100,9 @@ This option indicates that the RGB_RED_MAP should be defined. This option indicates that \fIxstdcmap\fP should print logging information as it parses its input and defines the standard colormap properties. +.TP 8 +.B \-version +This option indicates that \fIxstdcmap\fP should print its version and exit. .SH ENVIRONMENT .PP .TP 8 @@ -28,6 +28,10 @@ in this Software without prior written authorization from The Open Group. */ /* $XFree86: xc/programs/xstdcmap/xstdcmap.c,v 1.8tsi Exp $ */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <stdio.h> #include <stdlib.h> #include <X11/Xos.h> @@ -47,6 +51,7 @@ static char *program_name = NULL; static Bool all = 0; static Bool help = 0; static Bool verbose = 0; +static Bool version = 0; static Display *dpy = NULL; typedef struct @@ -88,6 +93,7 @@ static char *usage_message[]= " -green make the RGB_GREEN_MAP", " -red make the RGB_RED_MAP", " -verbose turn on logging", +" -version print version info", "", NULL }; @@ -104,6 +110,7 @@ static XrmOptionDescRec optionTable[]= {"-help", ".help", XrmoptionNoArg, (caddr_t) "on"}, {"-red", ".red", XrmoptionNoArg, (caddr_t) "on"}, {"-verbose", ".verbose", XrmoptionNoArg, (caddr_t) "on"}, +{"-version", ".version", XrmoptionNoArg, (caddr_t) "on"}, }; #define NOPTIONS (sizeof optionTable / sizeof optionTable[0]) @@ -178,6 +185,10 @@ parse(int argc, char **argv) snprintf(option, sizeof(option), "%s%s", program_name, ".verbose"); if (XrmGetResource(database, option, (char *) NULL, &type, &value)) verbose++; + + snprintf(option, sizeof(option), "%s%s", program_name, ".version"); + if (XrmGetResource(database, option, (char *) NULL, &type, &value)) + version++; } static void _X_NORETURN @@ -343,6 +354,11 @@ main(int argc, char *argv[]) usage(0); } + if (version) { + printf("%s\n", PACKAGE_STRING); + exit(0); + } + if ((dpy = XOpenDisplay(display_name)) == NULL) { (void) fprintf(stderr, "%s: cannot open display \"%s\".\n", program_name, XDisplayName(display_name)); |