2 * UCI support thru Polyglot
4 * Author: Alessandro Scotti (Jan 2006)
6 * Copyright 2006 Alessandro Scotti
8 * ------------------------------------------------------------------------
10 * GNU XBoard is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or (at
13 * your option) any later version.
15 * GNU XBoard is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see http://www.gnu.org/licenses/.
23 * ------------------------------------------------------------------------
35 Boolean GetArgValue(char *a);
37 void InitEngineUCI( const char * iniDir, ChessProgramState * cps )
38 { // replace engine command line by adapter command with expanded meta-symbols
41 char polyglotCommand[MSG_SIZ];
43 p = appData.adapterCommand;
46 if(*p == '\\') p++; else
47 if(*p == '%') { // substitute marker
48 char argName[MSG_SIZ], buf[MSG_SIZ], *s = buf;
49 if(*++p == '%') { // second %, expand as f or s in option name (e.g. %%cp -> fcp)
50 *s++ = cps == &first ? 'f' : 's';
53 while(*p >= '0' && *p) *s++ = *p++; // copy option name
55 if(cps == &second) { // change options for first into those for second engine
56 if(strstr(buf, "first") == buf) sprintf(argName, "second%s", buf+5); else
57 if(buf[0] == 'f') sprintf(argName, "s%s", buf+1); else
59 } else strcpy(argName, buf);
60 if(GetArgValue(argName)) { // look up value of option with this name
62 while(*s) *q++ = *s++;
63 } else DisplayFatalError("Bad adapter command", 0, 1);
69 cps->program = StrSave(polyglotCommand);
70 cps->dir = appData.polyglotDir;