X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gtk%2Fxboard.c;h=4c66bdc6dc4295542bb2362992b49b7699e68abf;hb=e4c23f9f78695a7bbb432929a8412c9c93477dd6;hp=fa13d748d3f5d348952d208bdde8dccbd047f012;hpb=5069483bf5f0fc22d9daf3a8a59d2e73251330cf;p=xboard.git diff --git a/gtk/xboard.c b/gtk/xboard.c index fa13d74..4c66bdc 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -174,14 +174,15 @@ extern char *getenv(); # define SLASH '-' // redefine some defaults # undef ICS_LOGON -# undef SYSCONFDIR +# undef DATADIR +# undef SETTINGS_FILE # define ICS_LOGON "Library/Preferences/XboardICS.conf" -# define SYSCONFDIR "../etc" # define DATADIR dataDir - char *dataDir; // for expanding ~~ +# define SETTINGS_FILE masterSettings + char dataDir[MSG_SIZ]; // for expanding ~~ + char masterSettings[MSG_SIZ]; #else # define SLASH '/' -# define DATADIR "~~" #endif #ifdef __EMX__ @@ -679,6 +680,7 @@ PrintArg (ArgType t) case ArgTwo: case ArgNone: case ArgCommSettings: + default: break; } return p; @@ -761,7 +763,7 @@ main (int argc, char **argv) debugFP = stderr; if(argc > 1 && (!strcmp(argv[1], "-v" ) || !strcmp(argv[1], "--version" ))) { - printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); + printf("%s version %s\n\n configure options: %s\n", PACKAGE_NAME, PACKAGE_VERSION, CONFIGURE_OPTIONS); exit(0); } @@ -775,7 +777,9 @@ main (int argc, char **argv) #ifdef __APPLE__ { // prepare to catch OX OpenFile signal, which will tell us the clicked file GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL); - dataDir = gtkosx_application_get_bundle_path(); + char *path = gtkosx_application_get_bundle_path(); + strncpy(dataDir, path, MSG_SIZ); + snprintf(masterSettings, MSG_SIZ, "%s/Contents/Resources/etc/xboard.conf", path); g_signal_connect(theApp, "NSApplicationOpenFile", G_CALLBACK(StartNewXBoard), NULL); // we must call application ready before we can get the signal, // and supply a (dummy) menu bar before that, to avoid problems with dual apples in it @@ -796,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(); @@ -827,6 +848,8 @@ main (int argc, char **argv) { // [HGM] initstring: kludge to fix bad bug. expand '\n' characters in init string and computer string. static char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, appData.sysOpen, DATADIR); + ASSIGN(appData.sysOpen, buf); // expand %s in -openCommand to DATADIR (usefull for OS X configuring) EscapeExpand(buf, appData.firstInitString); appData.firstInitString = strdup(buf); EscapeExpand(buf, appData.secondInitString); @@ -1786,7 +1809,9 @@ void ManProc () { // called from menu #ifdef __APPLE__ - system("%s ./man.command", appData.sysOpen); + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, "%s ./man.command", appData.sysOpen); + system(buf); #else system("xterm -e man xboard &"); #endif