From c34e0dfd20c024ddf8f5cbc6bef0b1386dcb6e72 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 25 Oct 2013 22:24:43 +0200 Subject: [PATCH] Implement -installEngine option This volatile string option conditionally adds its argument as a line to the engine list (-firstChessProgramNames). The condition is that the line is not yet already there, and either that the -versionNumber option read from settings files or command line has a value different from the version of the binary, or that -autoClose is set. It can be used for two purposes: to install engines from the master settings file (so that it only works first time after upgrades, when the stored versionNumber is obsolete), or from engine install scripts (calling XBoard with -autoClose). --- args.h | 14 +++++++++++++- xaw/xboard.c | 1 + 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/args.h b/args.h index 827952e..2d2fc1d 100644 --- a/args.h +++ b/args.h @@ -60,7 +60,7 @@ typedef enum { ArgString, ArgInt, ArgFloat, ArgBoolean, ArgTrue, ArgFalse, ArgNone, ArgColor, ArgAttribs, ArgFilename, ArgBoardSize, ArgFont, ArgCommSettings, - ArgSettingsFilename, ArgBackupSettingsFile, ArgTwo, + ArgSettingsFilename, ArgBackupSettingsFile, ArgTwo, ArgInstall, ArgX, ArgY, ArgZ // [HGM] placement: for window-placement options stored relative to main window } ArgType; @@ -507,6 +507,7 @@ ArgDescriptor argDescriptors[] = { { "secondChessProgramNames", ArgString, (void *) &secondChessProgramNames, !XBOARD, (ArgIniType) SCP_NAMES }, { "themeNames", ArgString, (void *) &appData.themeNames, !XBOARD, (ArgIniType) "native -upf false -ub false -ubt false -pid \"\"\n" }, + { "installEngine", ArgInstall, (void *) &firstChessProgramNames, FALSE, (ArgIniType) "" }, { "initialMode", ArgString, (void *) &appData.initialMode, FALSE, (ArgIniType) "" }, { "mode", ArgString, (void *) &appData.initialMode, FALSE, INVALID }, { "variant", ArgString, (void *) &appData.variant, FALSE, (ArgIniType) "normal" }, @@ -1176,6 +1177,16 @@ ParseArgs(GetFunc get, void *cl) ParseCommPortSettings(argValue); break; + case ArgInstall: + q = *(char **) ad->argLoc; + if((strcmp(version, VERSION) || autoClose) && !strstr(q, argValue) ) { + int l = strlen(q) + strlen(argValue); + *(char **) ad->argLoc = malloc(l+2); + snprintf(*(char **) ad->argLoc, l+2, "%s%s\n", q, argValue); + free(q); + } + break; + case ArgNone: ExitArgError(_("Unrecognized argument %s"), argValue, TRUE); break; @@ -1560,6 +1571,7 @@ SaveSettings(char* name) case ArgNone: case ArgBackupSettingsFile: case ArgSettingsFilename: ; + case ArgInstall: ; } } fclose(f); diff --git a/xaw/xboard.c b/xaw/xboard.c index 5b6501d..b88c445 100644 --- a/xaw/xboard.c +++ b/xaw/xboard.c @@ -819,6 +819,7 @@ PrintArg (ArgType t) case ArgTwo: case ArgNone: case ArgCommSettings: + case ArgInstall: break; } return p; -- 1.7.0.4