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 /xstdcmap.c | |
parent | c6f15b6d67f4c8df2af07848d6277593e24f6352 (diff) |
Add -version option
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xstdcmap.c')
-rw-r--r-- | xstdcmap.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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)); |