From: H.G. Muller Date: Mon, 13 Jan 2014 15:21:59 +0000 (+0100) Subject: Add --show-config special option X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=27f670dbe352c1333448bb137a6aa008e4cdf3ad Add --show-config special option This prints a list of configure parameters, and then exits. If a second argument is given, it only prints the value of that config parameter, so that tricks like cp *.svg `xboard --show-config Datadir`/themes/chu can be used in install scripts of packages with piece images. --- diff --git a/gtk/xboard.c b/gtk/xboard.c index 20eeaff..6769a19 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -800,6 +800,23 @@ main (int argc, char **argv) } #endif + if(argc > 1 && !strcmp(argv[1], "--show-config")) { // [HGM] install: called to print config info + typedef struct {char *name, *value; } Config; + static Config configList[] = { + { "Datadir", DATADIR }, + { "Sysconfdir", SYSCONFDIR }, + { NULL } + }; + int i; + + for(i=0; configList[i].name; i++) { + if(argc > 2 && strcmp(argv[2], configList[i].name)) continue; + if(argc > 2) printf("%s", configList[i].value); + else printf("%-12s: %s\n", configList[i].name, configList[i].value); + } + exit(0); + } + /* set up keyboard accelerators group */ GtkAccelerators = gtk_accel_group_new(); diff --git a/xaw/xboard.c b/xaw/xboard.c index d3d6ba2..292f7c2 100644 --- a/xaw/xboard.c +++ b/xaw/xboard.c @@ -990,6 +990,23 @@ main (int argc, char **argv) exit(0); } + if(argc > 1 && !strcmp(argv[1], "--show-config")) { // [HGM] install: called to print config info + typedef struct {char *name, *value; } Config; + static Config configList[] = { + { "Datadir", DATADIR }, + { "Sysconfdir", SYSCONFDIR }, + { NULL } + }; + int i; + + for(i=0; configList[i].name; i++) { + if(argc > 2 && strcmp(argv[2], configList[i].name)) continue; + if(argc > 2) printf("%s", configList[i].value); + else printf("%-12s: %s\n", configList[i].name, configList[i].value); + } + exit(0); + } + programName = strrchr(argv[0], '/'); if (programName == NULL) programName = argv[0];