From: H.G. Muller Date: Sat, 29 Sep 2012 20:58:12 +0000 (+0200) Subject: Allow ICS nickname as positional argument X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=395642a0ccce8adbc55d4c8ff58780ab07c12813 Allow ICS nickname as positional argument If an argument is encountered that is not preceded by an option name, it is now first checked if it corresponds to the nickname of an ICS in -icsNames. If so, it is assumed to be the value of an -is option, selecting -ics mode with that ICS and all the options installed with it. --- diff --git a/args.h b/args.h index d9df08c..6e3c3ac 100644 --- a/args.h +++ b/args.h @@ -144,6 +144,7 @@ ArgDescriptor argDescriptors[] = { { "opt", ArgSettingsFilename, (void *) NULL, FALSE, INVALID }, { "loadPositionFile", ArgFilename, (void *) &appData.loadPositionFile, FALSE, INVALID }, { "tourneyFile", ArgFilename, (void *) &appData.tourneyFile, FALSE, INVALID }, + { "is", ArgString, (void *) &icsNick, FALSE, INVALID }, { "loadGameFile", ArgFilename, (void *) &appData.loadGameFile, FALSE, INVALID }, { "", ArgNone, NULL, FALSE, INVALID }, /* keyword arguments */ @@ -867,7 +868,7 @@ ParseArgs(GetFunc get, void *cl) char *q; int i, octval; char ch; - int posarg = 3; // default is game file + int posarg = 4; // default is game file ch = get(cl); for (;;) { @@ -1043,6 +1044,8 @@ ParseArgs(GetFunc get, void *cl) appData.viewer = TRUE; } else if(!strcasecmp(argValue + len, ".ini") || !strcasecmp(argValue + len, ".xop")) { ad = &argDescriptors[0]; // correct implied type to -opt + } else if(GetEngineLine(argValue, 11)) { + ad = &argDescriptors[3]; // correct implied type to -is } else { // keep default -lgf, but let it imply viewer mode as well appData.viewer = TRUE; } diff --git a/backend.c b/backend.c index 52fb515..6977595 100644 --- a/backend.c +++ b/backend.c @@ -10203,9 +10203,10 @@ GetEngineLine (char *s, int n) char buf[MSG_SIZ]; extern char *icsNames; if(!s || !*s) return 0; - NamesToList(n == 10 ? icsNames : firstChessProgramNames, command, mnemonic, "all"); + NamesToList(n >= 10 ? icsNames : firstChessProgramNames, command, mnemonic, "all"); for(i=1; mnemonic[i]; i++) if(!strcmp(s, mnemonic[i])) break; if(!mnemonic[i]) return 0; + if(n == 11) return 1; // just testing if there was a match snprintf(buf, MSG_SIZ, "-%s %s", n == 10 ? "icshost" : "fcp", command[i]); if(n == 1) SwapEngines(n); ParseArgsFromString(buf);