Don't add PV moves on board clicking in AnalyzeMode
[xboard.git] / args.h
1 /*
2  * args.c -- Option parsing and saving for X and Windows versions of XBoard
3  *
4  * Copyright 1991 by Digital Equipment Corporation, Maynard,
5  * Massachusetts.
6  *
7  * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
8  * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
9  *
10  * Enhancements Copyright 2005 Alessandro Scotti
11  *
12  * The following terms apply to Digital Equipment Corporation's copyright
13  * interest in XBoard:
14  * ------------------------------------------------------------------------
15  * All Rights Reserved
16  *
17  * Permission to use, copy, modify, and distribute this software and its
18  * documentation for any purpose and without fee is hereby granted,
19  * provided that the above copyright notice appear in all copies and that
20  * both that copyright notice and this permission notice appear in
21  * supporting documentation, and that the name of Digital not be
22  * used in advertising or publicity pertaining to distribution of the
23  * software without specific, written prior permission.
24  *
25  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
26  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
27  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
28  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
30  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
31  * SOFTWARE.
32  * ------------------------------------------------------------------------
33  *
34  * The following terms apply to the enhanced version of XBoard
35  * distributed by the Free Software Foundation:
36  * ------------------------------------------------------------------------
37  *
38  * GNU XBoard is free software: you can redistribute it and/or modify
39  * it under the terms of the GNU General Public License as published by
40  * the Free Software Foundation, either version 3 of the License, or (at
41  * your option) any later version.
42  *
43  * GNU XBoard is distributed in the hope that it will be useful, but
44  * WITHOUT ANY WARRANTY; without even the implied warranty of
45  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
46  * General Public License for more details.
47  *
48  * You should have received a copy of the GNU General Public License
49  * along with this program. If not, see http://www.gnu.org/licenses/.  *
50  *
51  *------------------------------------------------------------------------
52  ** See the file ChangeLog for a revision history.
53 */
54
55 // Note: this file is not a normal header, but contains executable code
56 // for #inclusion in winboard.c and xboard.c, rather than separate compilation,
57 // so that it can make use of the proper context of #defined symbols and
58 // declarations in those files.
59
60 typedef enum {
61   ArgString, ArgInt, ArgFloat, ArgBoolean, ArgTrue, ArgFalse, ArgNone,
62   ArgColor, ArgAttribs, ArgFilename, ArgBoardSize, ArgFont, ArgCommSettings,
63   ArgSettingsFilename, ArgTwo,
64   ArgX, ArgY, ArgZ // [HGM] placement: for window-placement options stored relative to main window
65 } ArgType;
66
67 typedef void *ArgIniType;
68
69 #define INVALID (ArgIniType) 6915 /* Some number unlikely to be needed as default for anything */
70 #define MAX_ARG_LEN 128*1024 /* [AS] For Roger Brown's very long list! */
71
72 typedef struct {
73   char *argName;
74   ArgType argType;
75   /***
76   union {
77     String *pString;       // ArgString
78     int *pInt;             // ArgInt
79     float *pFloat;         // ArgFloat
80     Boolean *pBoolean;     // ArgBoolean
81     COLORREF *pColor;      // ArgColor
82     ColorClass cc;         // ArgAttribs
83     String *pFilename;     // ArgFilename
84     BoardSize *pBoardSize; // ArgBoardSize
85     int whichFont;         // ArgFont
86     DCB *pDCB;             // ArgCommSettings
87     String *pFilename;     // ArgSettingsFilename
88   } argLoc;
89   ***/
90   void *argLoc;
91   Boolean save;
92   ArgIniType defaultValue;
93 } ArgDescriptor;
94
95 typedef struct {
96   char *item;
97   char *command;
98   Boolean getname;
99   Boolean immediate;
100 } IcsTextMenuEntry;
101
102 IcsTextMenuEntry icsTextMenuEntry[ICS_TEXT_MENU_SIZE];
103
104 int junk;
105 Boolean singleList;
106 char *homeDir;
107 char *firstEngineLine;
108 char *secondEngineLine;
109 char *icsNick;
110 char *theme;
111
112 void EnsureOnScreen(int *x, int *y, int minX, int minY);
113 char StringGet(void *getClosure);
114 void ParseFont(char *name, int number);
115 void SetFontDefaults();
116 void CreateFonts();
117 void ParseColor(int n, char *name);
118 void ParseTextAttribs(ColorClass cc, char *s);
119 void ParseBoardSize(void * addr, char *name);
120 void ParseCommPortSettings(char *name);
121 void LoadAllSounds();
122 void SetCommPortDefaults();
123 void SaveFontArg(FILE *f, ArgDescriptor *ad);
124 void ExportSounds();
125 void SaveAttribsArg(FILE *f, ArgDescriptor *ad);
126 void SaveColor(FILE *f, ArgDescriptor *ad);
127 void SaveBoardSize(FILE *f, char *name, void *addr);
128 void PrintCommPortSettings(FILE *f, char *name);
129 void GetWindowCoords();
130 int  MainWindowUp();
131 void PopUpStartupDialog();
132 typedef char GetFunc(void *getClosure);
133 void ParseArgs(GetFunc get, void *cl);
134
135 // [HGM] this is an exact duplicate of something in winboard.c. Move to backend.c?
136 char *defaultTextAttribs[] =
137 {
138   COLOR_SHOUT, COLOR_SSHOUT, COLOR_CHANNEL1, COLOR_CHANNEL, COLOR_KIBITZ,
139   COLOR_TELL, COLOR_CHALLENGE, COLOR_REQUEST, COLOR_SEEK, COLOR_NORMAL,
140   "#000000"
141 };
142
143 ArgDescriptor argDescriptors[] = {
144   /* positional arguments */
145   { "opt", ArgSettingsFilename, (void *) NULL, FALSE, INVALID },
146   { "loadPositionFile", ArgFilename, (void *) &appData.loadPositionFile, FALSE, INVALID },
147   { "tourneyFile", ArgFilename, (void *) &appData.tourneyFile, FALSE, INVALID },
148   { "is", ArgString, (void *) &icsNick, FALSE, INVALID },
149   { "loadGameFile", ArgFilename, (void *) &appData.loadGameFile, FALSE, INVALID },
150   { "", ArgNone, NULL, FALSE, INVALID },
151   /* keyword arguments */
152   JAWS_ARGS
153   { "whitePieceColor", ArgColor, (void *) 0, TRUE, (ArgIniType) WHITE_PIECE_COLOR },
154   { "wpc", ArgColor, (void *) 0, FALSE, INVALID },
155   { "blackPieceColor", ArgColor, (void *) 1, TRUE, (ArgIniType) BLACK_PIECE_COLOR },
156   { "bpc", ArgColor, (void *) 1, FALSE, INVALID },
157   { "lightSquareColor", ArgColor, (void *) 2, TRUE, (ArgIniType) LIGHT_SQUARE_COLOR },
158   { "lsc", ArgColor, (void *) 2, FALSE, INVALID },
159   { "darkSquareColor", ArgColor, (void *) 3, TRUE, (ArgIniType) DARK_SQUARE_COLOR },
160   { "dsc", ArgColor, (void *) 3, FALSE, INVALID },
161   { "highlightSquareColor", ArgColor, (void *) 4, TRUE, (ArgIniType) HIGHLIGHT_SQUARE_COLOR },
162   { "hsc", ArgColor, (void *) 4, FALSE, INVALID },
163   { "premoveHighlightColor", ArgColor, (void *) 5, TRUE, (ArgIniType) PREMOVE_HIGHLIGHT_COLOR },
164   { "phc", ArgColor, (void *) 5, FALSE, INVALID },
165   { "movesPerSession", ArgInt, (void *) &appData.movesPerSession, TRUE, (ArgIniType) MOVES_PER_SESSION },
166   { "mps", ArgInt, (void *) &appData.movesPerSession, FALSE, INVALID },
167   { "initString", ArgString, (void *) &appData.firstInitString, FALSE, INVALID },
168   { "firstInitString", ArgString, (void *) &appData.firstInitString, FALSE, (ArgIniType) INIT_STRING },
169   { "secondInitString", ArgString, (void *) &appData.secondInitString, FALSE, (ArgIniType) INIT_STRING },
170   { "firstComputerString", ArgString, (void *) &appData.firstComputerString,
171     FALSE, (ArgIniType) COMPUTER_STRING },
172   { "secondComputerString", ArgString, (void *) &appData.secondComputerString,
173     FALSE, (ArgIniType) COMPUTER_STRING },
174   { "firstChessProgram", ArgFilename, (void *) &appData.firstChessProgram,
175     FALSE, (ArgIniType) FIRST_CHESS_PROGRAM },
176   { "fcp", ArgFilename, (void *) &appData.firstChessProgram, FALSE, INVALID },
177   { "secondChessProgram", ArgFilename, (void *) &appData.secondChessProgram,
178     FALSE, (ArgIniType) SECOND_CHESS_PROGRAM },
179   { "scp", ArgFilename, (void *) &appData.secondChessProgram, FALSE, INVALID },
180   { "fe", ArgString, (void *) &firstEngineLine, FALSE, "" },
181   { "se", ArgString, (void *) &secondEngineLine, FALSE, "" },
182   { "firstPlaysBlack", ArgBoolean, (void *) &appData.firstPlaysBlack, FALSE, FALSE },
183   { "fb", ArgTrue, (void *) &appData.firstPlaysBlack, FALSE, FALSE },
184   { "xfb", ArgFalse, (void *) &appData.firstPlaysBlack, FALSE, INVALID },
185   { "-fb", ArgFalse, (void *) &appData.firstPlaysBlack, FALSE, INVALID },
186   { "noChessProgram", ArgBoolean, (void *) &appData.noChessProgram, FALSE, FALSE },
187   { "ncp", ArgTrue, (void *) &appData.noChessProgram, FALSE, INVALID },
188   { "xncp", ArgFalse, (void *) &appData.noChessProgram, FALSE, INVALID },
189   { "-ncp", ArgFalse, (void *) &appData.noChessProgram, FALSE, INVALID },
190   { "firstHost", ArgString, (void *) &appData.firstHost, FALSE, (ArgIniType) FIRST_HOST },
191   { "fh", ArgString, (void *) &appData.firstHost, FALSE, INVALID },
192   { "secondHost", ArgString, (void *) &appData.secondHost, FALSE, (ArgIniType) SECOND_HOST },
193   { "sh", ArgString, (void *) &appData.secondHost, FALSE, INVALID },
194   { "firstDirectory", ArgFilename, (void *) &appData.firstDirectory, FALSE, (ArgIniType) FIRST_DIRECTORY },
195   { "fd", ArgFilename, (void *) &appData.firstDirectory, FALSE, INVALID },
196   { "secondDirectory", ArgFilename, (void *) &appData.secondDirectory, FALSE, (ArgIniType) SECOND_DIRECTORY },
197   { "sd", ArgFilename, (void *) &appData.secondDirectory, FALSE, INVALID },
198   { "variations", ArgBoolean, (void *) &appData.variations, TRUE, (ArgIniType) FALSE },
199   { "appendPV", ArgBoolean, (void *) &appData.autoExtend, TRUE, (ArgIniType) FALSE },
200   { "theme", ArgString, (void *) &theme, FALSE, (ArgIniType) "" },
201
202   /* some options only used by the XBoard front end, and ignored in WinBoard         */
203   /* Their saving is controlled by XBOARD, which in WinBoard is defined as FALSE */
204   { "internetChessServerInputBox", ArgBoolean, (void *) &appData.icsInputBox, XBOARD, (ArgIniType) FALSE },
205   { "icsinput", ArgTrue, (void *) &appData.icsInputBox, FALSE, INVALID },
206   { "xicsinput", ArgFalse, (void *) &appData.icsInputBox, FALSE, INVALID },
207   { "cmail", ArgString, (void *) &appData.cmailGameName, FALSE, (ArgIniType) "" },
208   { "soundProgram", ArgFilename, (void *) &appData.soundProgram, XBOARD, (ArgIniType) "play" },
209   { "fontSizeTolerance", ArgInt, (void *) &appData.fontSizeTolerance, XBOARD, (ArgIniType) 4 },
210   { "lowTimeWarningColor", ArgColor, (void *) 6, XBOARD, (ArgIniType) LOWTIMEWARNING_COLOR },
211   { "lowTimeWarning", ArgBoolean, (void *) &appData.lowTimeWarning, XBOARD, (ArgIniType) FALSE },
212   { "titleInWindow", ArgBoolean, (void *) &appData.titleInWindow, XBOARD, (ArgIniType) FALSE },
213   { "title", ArgTrue, (void *) &appData.titleInWindow, FALSE, INVALID },
214   { "xtitle", ArgFalse, (void *) &appData.titleInWindow, FALSE, INVALID },
215   { "flashCount", ArgInt, (void *) &appData.flashCount, XBOARD, INVALID }, // let X handle this
216   { "flashRate", ArgInt, (void *) &appData.flashRate, XBOARD, (ArgIniType) FLASH_RATE },
217   { "pieceImageDirectory", ArgFilename, (void *) &appData.pieceDirectory, TRUE, (ArgIniType) "" },
218   { "pid", ArgFilename, (void *) &appData.pieceDirectory, FALSE, INVALID },
219   { "trueColors", ArgBoolean, (void *) &appData.trueColors, TRUE, (ArgIniType) FALSE },
220   { "soundDirectory", ArgFilename, (void *) &appData.soundDirectory, XBOARD, (ArgIniType) "" },
221   { "msLoginDelay", ArgInt, (void *) &appData.msLoginDelay, XBOARD, (ArgIniType) MS_LOGIN_DELAY },
222   { "pasteSelection", ArgBoolean, (void *) &appData.pasteSelection, XBOARD, (ArgIniType) FALSE },
223
224   { "dropMenu", ArgBoolean, (void *) &appData.dropMenu, TRUE, (ArgIniType) FALSE },
225   { "pieceMenu", ArgBoolean, (void *) &appData.pieceMenu, TRUE, (ArgIniType) TRUE },
226   { "sweepPromotions", ArgBoolean, (void *) &appData.sweepSelect, TRUE, (ArgIniType) FALSE },
227   { "remoteShell", ArgFilename, (void *) &appData.remoteShell, FALSE, (ArgIniType) REMOTE_SHELL },
228   { "rsh", ArgFilename, (void *) &appData.remoteShell, FALSE, INVALID },
229   { "remoteUser", ArgString, (void *) &appData.remoteUser, FALSE, (ArgIniType) "" },
230   { "ruser", ArgString, (void *) &appData.remoteUser, FALSE, INVALID },
231   { "timeDelay", ArgFloat, (void *) &appData.timeDelay, TRUE, INVALID },
232   { "td", ArgFloat, (void *) &appData.timeDelay, FALSE, INVALID },
233   { "timeControl", ArgString, (void *) &appData.timeControl, TRUE, (ArgIniType) TIME_CONTROL },
234   { "tc", ArgString, (void *) &appData.timeControl, FALSE, INVALID },
235   { "timeIncrement", ArgFloat, (void *) &appData.timeIncrement, FALSE, INVALID },
236   { "inc", ArgFloat, (void *) &appData.timeIncrement, FALSE, INVALID },
237   { "internetChessServerMode", ArgBoolean, (void *) &appData.icsActive, FALSE, INVALID },
238   { "ics", ArgTrue, (void *) &appData.icsActive, FALSE, (ArgIniType) FALSE },
239   { "xics", ArgFalse, (void *) &appData.icsActive, FALSE, INVALID },
240   { "-ics", ArgFalse, (void *) &appData.icsActive, FALSE, INVALID },
241   { "is", ArgString, (void *) &icsNick, FALSE, "" },
242   { "internetChessServerHost", ArgString, (void *) &appData.icsHost, FALSE, (ArgIniType) "" },
243   { "icshost", ArgString, (void *) &appData.icsHost, FALSE, INVALID },
244   { "internetChessServerPort", ArgString, (void *) &appData.icsPort, FALSE, (ArgIniType) ICS_PORT },
245   { "icsport", ArgString, (void *) &appData.icsPort, FALSE, INVALID },
246   { "internetChessServerCommPort", ArgString, (void *) &appData.icsCommPort, FALSE, (ArgIniType) ICS_COMM_PORT },
247   { "icscomm", ArgString, (void *) &appData.icsCommPort, FALSE, INVALID },
248   { "internetChessServerComPort", ArgString, (void *) &appData.icsCommPort, FALSE, INVALID },
249   { "icscom", ArgString, (void *) &appData.icsCommPort, FALSE, INVALID },
250   { "internetChessServerLogonScript", ArgFilename, (void *) &appData.icsLogon, FALSE, (ArgIniType) ICS_LOGON },
251   { "icslogon", ArgFilename, (void *) &appData.icsLogon, FALSE, INVALID },
252   { "useTelnet", ArgBoolean, (void *) &appData.useTelnet, FALSE, INVALID },
253   { "telnet", ArgTrue, (void *) &appData.useTelnet, FALSE, INVALID },
254   { "xtelnet", ArgFalse, (void *) &appData.useTelnet, FALSE, INVALID },
255   { "-telnet", ArgFalse, (void *) &appData.useTelnet, FALSE, INVALID },
256   { "telnetProgram", ArgFilename, (void *) &appData.telnetProgram, FALSE, (ArgIniType) TELNET_PROGRAM },
257   { "internetChessserverHelper", ArgFilename, (void *) &appData.icsHelper,
258         FALSE, INVALID }, // for XB
259   { "icshelper", ArgFilename, (void *) &appData.icsHelper, FALSE, (ArgIniType) "" },
260   { "seekGraph", ArgBoolean, (void *) &appData.seekGraph, TRUE, (ArgIniType) FALSE },
261   { "sg", ArgTrue, (void *) &appData.seekGraph, FALSE, INVALID },
262   { "autoRefresh", ArgBoolean, (void *) &appData.autoRefresh, TRUE, (ArgIniType) FALSE },
263   { "autoBox", ArgBoolean, (void *) &appData.autoBox, XBOARD, (ArgIniType) TRUE },
264   { "gateway", ArgString, (void *) &appData.gateway, FALSE, (ArgIniType) "" },
265   { "loadGameFile", ArgFilename, (void *) &appData.loadGameFile, FALSE, (ArgIniType) "" },
266   { "lgf", ArgFilename, (void *) &appData.loadGameFile, FALSE, INVALID },
267   { "loadGameIndex", ArgInt, (void *) &appData.loadGameIndex, FALSE, (ArgIniType) 0 },
268   { "lgi", ArgInt, (void *) &appData.loadGameIndex, FALSE, INVALID },
269   { "saveGameFile", ArgFilename, (void *) &appData.saveGameFile, TRUE, (ArgIniType) "" },
270   { "sgf", ArgFilename, (void *) &appData.saveGameFile, FALSE, INVALID },
271   { "autoSaveGames", ArgBoolean, (void *) &appData.autoSaveGames, TRUE, (ArgIniType) FALSE },
272   { "autosave", ArgTrue, (void *) &appData.autoSaveGames, FALSE, INVALID },
273   { "xautosave", ArgFalse, (void *) &appData.autoSaveGames, FALSE, INVALID },
274   { "-autosave", ArgFalse, (void *) &appData.autoSaveGames, FALSE, INVALID },
275   { "loadPositionFile", ArgFilename, (void *) &appData.loadPositionFile, FALSE, (ArgIniType) "" },
276   { "lpf", ArgFilename, (void *) &appData.loadPositionFile, FALSE, INVALID },
277   { "loadPositionIndex", ArgInt, (void *) &appData.loadPositionIndex, FALSE, (ArgIniType) 1 },
278   { "lpi", ArgInt, (void *) &appData.loadPositionIndex, FALSE, INVALID },
279   { "savePositionFile", ArgFilename, (void *) &appData.savePositionFile, FALSE, (ArgIniType) "" },
280   { "spf", ArgFilename, (void *) &appData.savePositionFile, FALSE, INVALID },
281   { "matchMode", ArgBoolean, (void *) &appData.matchMode, FALSE, (ArgIniType) FALSE },
282   { "mm", ArgTrue, (void *) &appData.matchMode, FALSE, INVALID },
283   { "xmm", ArgFalse, (void *) &appData.matchMode, FALSE, INVALID },
284   { "-mm", ArgFalse, (void *) &appData.matchMode, FALSE, INVALID },
285   { "matchGames", ArgInt, (void *) &appData.matchGames, FALSE, (ArgIniType) 0 },
286   { "mg", ArgInt, (void *) &appData.matchGames, FALSE, INVALID },
287   { "monoMode", ArgBoolean, (void *) &appData.monoMode, TRUE, (ArgIniType) FALSE },
288   { "mono", ArgTrue, (void *) &appData.monoMode, FALSE, INVALID },
289   { "xmono", ArgFalse, (void *) &appData.monoMode, FALSE, INVALID },
290   { "-mono", ArgFalse, (void *) &appData.monoMode, FALSE, INVALID },
291   { "debugMode", ArgBoolean, (void *) &appData.debugMode, FALSE, (ArgIniType) FALSE },
292   { "debug", ArgTrue, (void *) &appData.debugMode, FALSE, INVALID },
293   { "xdebug", ArgFalse, (void *) &appData.debugMode, FALSE, INVALID },
294   { "-debug", ArgFalse, (void *) &appData.debugMode, FALSE, INVALID },
295   { "clockMode", ArgBoolean, (void *) &appData.clockMode, FALSE, (ArgIniType) TRUE },
296   { "clock", ArgTrue, (void *) &appData.clockMode, FALSE, INVALID },
297   { "xclock", ArgFalse, (void *) &appData.clockMode, FALSE, INVALID },
298   { "-clock", ArgFalse, (void *) &appData.clockMode, FALSE, INVALID },
299   { "searchTime", ArgString, (void *) &appData.searchTime, FALSE, (ArgIniType) "" },
300   { "st", ArgString, (void *) &appData.searchTime, FALSE, INVALID },
301   { "searchDepth", ArgInt, (void *) &appData.searchDepth, FALSE, (ArgIniType) 0 },
302   { "depth", ArgInt, (void *) &appData.searchDepth, FALSE, INVALID },
303   { "showCoords", ArgBoolean, (void *) &appData.showCoords, TRUE, (ArgIniType) FALSE },
304   { "coords", ArgTrue, (void *) &appData.showCoords, FALSE, INVALID },
305   { "xcoords", ArgFalse, (void *) &appData.showCoords, FALSE, INVALID },
306   { "-coords", ArgFalse, (void *) &appData.showCoords, FALSE, INVALID },
307   { "showThinking", ArgBoolean, (void *) &appData.showThinking, TRUE, (ArgIniType) FALSE },
308   { "thinking", ArgTrue, (void *) &appData.showThinking, FALSE, INVALID },
309   { "xthinking", ArgFalse, (void *) &appData.showThinking, FALSE, INVALID },
310   { "-thinking", ArgFalse, (void *) &appData.showThinking, FALSE, INVALID },
311   { "ponderNextMove", ArgBoolean, (void *) &appData.ponderNextMove, TRUE, (ArgIniType) TRUE },
312   { "ponder", ArgTrue, (void *) &appData.ponderNextMove, FALSE, INVALID },
313   { "xponder", ArgFalse, (void *) &appData.ponderNextMove, FALSE, INVALID },
314   { "-ponder", ArgFalse, (void *) &appData.ponderNextMove, FALSE, INVALID },
315   { "periodicUpdates", ArgBoolean, (void *) &appData.periodicUpdates, TRUE, (ArgIniType) TRUE },
316   { "periodic", ArgTrue, (void *) &appData.periodicUpdates, FALSE, INVALID },
317   { "xperiodic", ArgFalse, (void *) &appData.periodicUpdates, FALSE, INVALID },
318   { "-periodic", ArgFalse, (void *) &appData.periodicUpdates, FALSE, INVALID },
319   { "popupExitMessage", ArgBoolean, (void *) &appData.popupExitMessage, TRUE, (ArgIniType) TRUE },
320   { "exit", ArgTrue, (void *) &appData.popupExitMessage, FALSE, INVALID },
321   { "xexit", ArgFalse, (void *) &appData.popupExitMessage, FALSE, INVALID },
322   { "-exit", ArgFalse, (void *) &appData.popupExitMessage, FALSE, INVALID },
323   { "popupMoveErrors", ArgBoolean, (void *) &appData.popupMoveErrors, TRUE, (ArgIniType) FALSE },
324   { "popup", ArgTrue, (void *) &appData.popupMoveErrors, FALSE, INVALID },
325   { "xpopup", ArgFalse, (void *) &appData.popupMoveErrors, FALSE, INVALID },
326   { "-popup", ArgFalse, (void *) &appData.popupMoveErrors, FALSE, INVALID },
327   { "popUpErrors", ArgBoolean, (void *) &appData.popupMoveErrors,
328     FALSE, INVALID }, /* only so that old WinBoard.ini files from betas can be read */
329   { "clockFont", ArgFont, (void *) CLOCK_FONT, TRUE, INVALID },
330   { "messageFont", ArgFont, (void *) MESSAGE_FONT, TRUE, INVALID },
331   { "font", ArgFont, (void *) MESSAGE_FONT, FALSE, INVALID }, /* only so that old .xboardrc files will parse. -font does not work from the command line because it is captured by the X libraries. */
332   { "coordFont", ArgFont, (void *) COORD_FONT, TRUE, INVALID },
333   { "tagsFont", ArgFont, (void *) EDITTAGS_FONT, TRUE, INVALID },
334   { "commentFont", ArgFont, (void *) COMMENT_FONT, TRUE, INVALID },
335   { "icsFont", ArgFont, (void *) CONSOLE_FONT, TRUE, INVALID },
336   { "moveHistoryFont", ArgFont, (void *) MOVEHISTORY_FONT, TRUE, INVALID }, /* [AS] */
337   { "gameListFont", ArgFont, (void *) GAMELIST_FONT, TRUE, INVALID }, /* [HGM] */
338   { "boardSize", ArgBoardSize, (void *) &boardSize,
339     TRUE, (ArgIniType) -1 }, /* must come after all fonts */
340   { "size", ArgBoardSize, (void *) &boardSize, FALSE, INVALID },
341   { "ringBellAfterMoves", ArgBoolean, (void *) &appData.ringBellAfterMoves,
342     FALSE, (ArgIniType) TRUE }, /* historical; kept only so old winboard.ini files will parse */
343   { "bell", ArgTrue, (void *) &appData.ringBellAfterMoves, FALSE, INVALID }, // for XB
344   { "xbell", ArgFalse, (void *) &appData.ringBellAfterMoves, FALSE, INVALID }, // for XB
345   { "movesound", ArgTrue, (void *) &appData.ringBellAfterMoves, FALSE, INVALID }, // for XB
346   { "xmovesound", ArgFalse, (void *) &appData.ringBellAfterMoves, FALSE, INVALID }, // for XB
347   { "alwaysOnTop", ArgBoolean, (void *) &alwaysOnTop, TRUE, INVALID },
348   { "top", ArgTrue, (void *) &alwaysOnTop, FALSE, INVALID },
349   { "xtop", ArgFalse, (void *) &alwaysOnTop, FALSE, INVALID },
350   { "-top", ArgFalse, (void *) &alwaysOnTop, FALSE, INVALID },
351   { "autoCallFlag", ArgBoolean, (void *) &appData.autoCallFlag, TRUE, (ArgIniType) FALSE },
352   { "autoflag", ArgTrue, (void *) &appData.autoCallFlag, FALSE, INVALID },
353   { "xautoflag", ArgFalse, (void *) &appData.autoCallFlag, FALSE, INVALID },
354   { "-autoflag", ArgFalse, (void *) &appData.autoCallFlag, FALSE, INVALID },
355   { "autoComment", ArgBoolean, (void *) &appData.autoComment, TRUE, (ArgIniType) FALSE },
356   { "autocomm", ArgTrue, (void *) &appData.autoComment, FALSE, INVALID },
357   { "xautocomm", ArgFalse, (void *) &appData.autoComment, FALSE, INVALID },
358   { "-autocomm", ArgFalse, (void *) &appData.autoComment, FALSE, INVALID },
359   { "autoCreateLogon", ArgBoolean, (void *) &appData.autoCreateLogon, TRUE, (ArgIniType) FALSE },
360   { "autoObserve", ArgBoolean, (void *) &appData.autoObserve, TRUE, (ArgIniType) FALSE },
361   { "autobs", ArgTrue, (void *) &appData.autoObserve, FALSE, INVALID },
362   { "xautobs", ArgFalse, (void *) &appData.autoObserve, FALSE, INVALID },
363   { "-autobs", ArgFalse, (void *) &appData.autoObserve, FALSE, INVALID },
364   { "flipView", ArgBoolean, (void *) &appData.flipView, FALSE, (ArgIniType) FALSE },
365   { "flip", ArgTrue, (void *) &appData.flipView, FALSE, INVALID },
366   { "xflip", ArgFalse, (void *) &appData.flipView, FALSE, INVALID },
367   { "-flip", ArgFalse, (void *) &appData.flipView, FALSE, INVALID },
368   { "autoFlipView", ArgBoolean, (void *) &appData.autoFlipView, TRUE, (ArgIniType) TRUE },
369   { "autoflip", ArgTrue, (void *) &appData.autoFlipView, FALSE, INVALID },
370   { "xautoflip", ArgFalse, (void *) &appData.autoFlipView, FALSE, INVALID },
371   { "-autoflip", ArgFalse, (void *) &appData.autoFlipView, FALSE, INVALID },
372   { "autoRaiseBoard", ArgBoolean, (void *) &appData.autoRaiseBoard, TRUE, (ArgIniType) TRUE },
373   { "autoraise", ArgTrue, (void *) &appData.autoRaiseBoard, FALSE, INVALID },
374   { "xautoraise", ArgFalse, (void *) &appData.autoRaiseBoard, FALSE, INVALID },
375   { "-autoraise", ArgFalse, (void *) &appData.autoRaiseBoard, FALSE, INVALID },
376   { "alwaysPromoteToQueen", ArgBoolean, (void *) &appData.alwaysPromoteToQueen, TRUE, (ArgIniType) FALSE },
377   { "queen", ArgTrue, (void *) &appData.alwaysPromoteToQueen, FALSE, INVALID },
378   { "xqueen", ArgFalse, (void *) &appData.alwaysPromoteToQueen, FALSE, INVALID },
379   { "-queen", ArgFalse, (void *) &appData.alwaysPromoteToQueen, FALSE, INVALID },
380   { "oldSaveStyle", ArgBoolean, (void *) &appData.oldSaveStyle, TRUE, (ArgIniType) FALSE },
381   { "oldsave", ArgTrue, (void *) &appData.oldSaveStyle, FALSE, INVALID },
382   { "xoldsave", ArgFalse, (void *) &appData.oldSaveStyle, FALSE, INVALID },
383   { "-oldsave", ArgFalse, (void *) &appData.oldSaveStyle, FALSE, INVALID },
384   { "quietPlay", ArgBoolean, (void *) &appData.quietPlay, TRUE, (ArgIniType) FALSE },
385   { "quiet", ArgTrue, (void *) &appData.quietPlay, FALSE, INVALID },
386   { "xquiet", ArgFalse, (void *) &appData.quietPlay, FALSE, INVALID },
387   { "-quiet", ArgFalse, (void *) &appData.quietPlay, FALSE, INVALID },
388   { "getMoveList", ArgBoolean, (void *) &appData.getMoveList, TRUE, (ArgIniType) TRUE },
389   { "moves", ArgTrue, (void *) &appData.getMoveList, FALSE, INVALID },
390   { "xmoves", ArgFalse, (void *) &appData.getMoveList, FALSE, INVALID },
391   { "-moves", ArgFalse, (void *) &appData.getMoveList, FALSE, INVALID },
392   { "testLegality", ArgBoolean, (void *) &appData.testLegality, TRUE, (ArgIniType) TRUE },
393   { "legal", ArgTrue, (void *) &appData.testLegality, FALSE, INVALID },
394   { "xlegal", ArgFalse, (void *) &appData.testLegality, FALSE, INVALID },
395   { "-legal", ArgFalse, (void *) &appData.testLegality, FALSE, INVALID },
396   { "premove", ArgBoolean, (void *) &appData.premove, TRUE, (ArgIniType) TRUE },
397   { "pre", ArgTrue, (void *) &appData.premove, FALSE, INVALID },
398   { "xpre", ArgFalse, (void *) &appData.premove, FALSE, INVALID },
399   { "-pre", ArgFalse, (void *) &appData.premove, FALSE, INVALID },
400   { "premoveWhite", ArgBoolean, (void *) &appData.premoveWhite, TRUE, (ArgIniType) FALSE },
401   { "prewhite", ArgTrue, (void *) &appData.premoveWhite, FALSE, INVALID },
402   { "xprewhite", ArgFalse, (void *) &appData.premoveWhite, FALSE, INVALID },
403   { "-prewhite", ArgFalse, (void *) &appData.premoveWhite, FALSE, INVALID },
404   { "premoveWhiteText", ArgString, (void *) &appData.premoveWhiteText, TRUE, (ArgIniType) "" },
405   { "premoveBlack", ArgBoolean, (void *) &appData.premoveBlack, TRUE, (ArgIniType) FALSE },
406   { "preblack", ArgTrue, (void *) &appData.premoveBlack, FALSE, INVALID },
407   { "xpreblack", ArgFalse, (void *) &appData.premoveBlack, FALSE, INVALID },
408   { "-preblack", ArgFalse, (void *) &appData.premoveBlack, FALSE, INVALID },
409   { "premoveBlackText", ArgString, (void *) &appData.premoveBlackText, TRUE, (ArgIniType) "" },
410   { "icsAlarm", ArgBoolean, (void *) &appData.icsAlarm, TRUE, (ArgIniType) TRUE},
411   { "alarm", ArgTrue, (void *) &appData.icsAlarm, FALSE},
412   { "xalarm", ArgFalse, (void *) &appData.icsAlarm, FALSE},
413   { "-alarm", ArgFalse, (void *) &appData.icsAlarm, FALSE},
414   { "icsAlarmTime", ArgInt, (void *) &appData.icsAlarmTime, TRUE, (ArgIniType) 5000},
415   { "localLineEditing", ArgBoolean, (void *) &appData.localLineEditing, FALSE, (ArgIniType) TRUE},
416   { "edit", ArgTrue, (void *) &appData.localLineEditing, FALSE, INVALID },
417   { "xedit", ArgFalse, (void *) &appData.localLineEditing, FALSE, INVALID },
418   { "-edit", ArgFalse, (void *) &appData.localLineEditing, FALSE, INVALID },
419   { "animateMoving", ArgBoolean, (void *) &appData.animate, TRUE, (ArgIniType) TRUE },
420   { "animate", ArgTrue, (void *) &appData.animate, FALSE, INVALID },
421   { "xanimate", ArgFalse, (void *) &appData.animate, FALSE, INVALID },
422   { "-animate", ArgFalse, (void *) &appData.animate, FALSE, INVALID },
423   { "animateSpeed", ArgInt, (void *) &appData.animSpeed, TRUE, (ArgIniType) 10 },
424   { "animateDragging", ArgBoolean, (void *) &appData.animateDragging, TRUE, (ArgIniType) TRUE },
425   { "drag", ArgTrue, (void *) &appData.animateDragging, FALSE, INVALID },
426   { "xdrag", ArgFalse, (void *) &appData.animateDragging, FALSE, INVALID },
427   { "-drag", ArgFalse, (void *) &appData.animateDragging, FALSE, INVALID },
428   { "blindfold", ArgBoolean, (void *) &appData.blindfold, TRUE, (ArgIniType) FALSE },
429   { "blind", ArgTrue, (void *) &appData.blindfold, FALSE, INVALID },
430   { "xblind", ArgFalse, (void *) &appData.blindfold, FALSE, INVALID },
431   { "-blind", ArgFalse, (void *) &appData.blindfold, FALSE, INVALID },
432   { "highlightLastMove", ArgBoolean,
433     (void *) &appData.highlightLastMove, TRUE, (ArgIniType) TRUE },
434   { "highlight", ArgTrue, (void *) &appData.highlightLastMove, FALSE, INVALID },
435   { "xhighlight", ArgFalse, (void *) &appData.highlightLastMove, FALSE, INVALID },
436   { "-highlight", ArgFalse, (void *) &appData.highlightLastMove, FALSE, INVALID },
437   { "highlightDragging", ArgBoolean,
438     (void *) &appData.highlightDragging, !XBOARD, (ArgIniType) TRUE },
439   { "highdrag", ArgTrue, (void *) &appData.highlightDragging, FALSE, INVALID },
440   { "xhighdrag", ArgFalse, (void *) &appData.highlightDragging, FALSE, INVALID },
441   { "-highdrag", ArgFalse, (void *) &appData.highlightDragging, FALSE, INVALID },
442   { "colorizeMessages", ArgBoolean, (void *) &appData.colorize, TRUE, (ArgIniType) TRUE },
443   { "colorize", ArgTrue, (void *) &appData.colorize, FALSE, INVALID },
444   { "xcolorize", ArgFalse, (void *) &appData.colorize, FALSE, INVALID },
445   { "-colorize", ArgFalse, (void *) &appData.colorize, FALSE, INVALID },
446   { "colorShout", ArgAttribs, (void *) ColorShout, TRUE, INVALID },
447   { "colorSShout", ArgAttribs, (void *) ColorSShout, TRUE, INVALID },
448   { "colorCShout", ArgAttribs, (void *) ColorSShout, FALSE, INVALID }, // for XB
449   { "colorChannel1", ArgAttribs, (void *) ColorChannel1, TRUE, INVALID },
450   { "colorChannel", ArgAttribs, (void *) ColorChannel, TRUE, INVALID },
451   { "colorKibitz", ArgAttribs, (void *) ColorKibitz, TRUE, INVALID },
452   { "colorTell", ArgAttribs, (void *) ColorTell, TRUE, INVALID },
453   { "colorChallenge", ArgAttribs, (void *) ColorChallenge, TRUE, INVALID },
454   { "colorRequest", ArgAttribs, (void *) ColorRequest, TRUE, INVALID },
455   { "colorSeek", ArgAttribs, (void *) ColorSeek, TRUE, INVALID },
456   { "colorNormal", ArgAttribs, (void *) ColorNormal, TRUE, INVALID },
457   { "colorBackground", ArgColor, (void *) 7, TRUE, COLOR_BKGD },
458   { "soundShout", ArgFilename, (void *) &appData.soundShout, TRUE, (ArgIniType) "" },
459   { "soundSShout", ArgFilename, (void *) &appData.soundSShout, TRUE, (ArgIniType) "" },
460   { "soundCShout", ArgFilename, (void *) &appData.soundSShout, FALSE, (ArgIniType) "" }, // for XB
461   { "soundChannel1", ArgFilename, (void *) &appData.soundChannel1, TRUE, (ArgIniType) "" },
462   { "soundChannel", ArgFilename, (void *) &appData.soundChannel, TRUE, (ArgIniType) "" },
463   { "soundKibitz", ArgFilename, (void *) &appData.soundKibitz, TRUE, (ArgIniType) "" },
464   { "soundTell", ArgFilename, (void *) &appData.soundTell, TRUE, (ArgIniType) "" },
465   { "soundChallenge", ArgFilename, (void *) &appData.soundChallenge, TRUE, (ArgIniType) "" },
466   { "soundRequest", ArgFilename, (void *) &appData.soundRequest, TRUE, (ArgIniType) "" },
467   { "soundSeek", ArgFilename, (void *) &appData.soundSeek, TRUE, (ArgIniType) "" },
468   { "soundMove", ArgFilename, (void *) &appData.soundMove, TRUE, (ArgIniType) "" },
469   { "soundBell", ArgFilename, (void *) &appData.soundBell, TRUE, (ArgIniType) SOUND_BELL },
470   { "soundIcsWin", ArgFilename, (void *) &appData.soundIcsWin, TRUE, (ArgIniType) "" },
471   { "soundIcsLoss", ArgFilename, (void *) &appData.soundIcsLoss, TRUE, (ArgIniType) "" },
472   { "soundIcsDraw", ArgFilename, (void *) &appData.soundIcsDraw, TRUE, (ArgIniType) "" },
473   { "soundIcsUnfinished", ArgFilename, (void *) &appData.soundIcsUnfinished, TRUE, (ArgIniType) "" },
474   { "soundIcsAlarm", ArgFilename, (void *) &appData.soundIcsAlarm, TRUE, (ArgIniType) "" },
475   { "disguisePromotedPieces", ArgBoolean, (void *) &appData.disguise, TRUE, (ArgIniType) TRUE },
476   { "reuseFirst", ArgBoolean, (void *) &appData.reuseFirst, FALSE, (ArgIniType) TRUE },
477   { "reuse", ArgTrue, (void *) &appData.reuseFirst, FALSE, INVALID },
478   { "xreuse", ArgFalse, (void *) &appData.reuseFirst, FALSE, INVALID },
479   { "-reuse", ArgFalse, (void *) &appData.reuseFirst, FALSE, INVALID },
480   { "reuseChessPrograms", ArgBoolean,
481     (void *) &appData.reuseFirst, FALSE, INVALID }, /* backward compat only */
482   { "reuseSecond", ArgBoolean, (void *) &appData.reuseSecond, FALSE, (ArgIniType) TRUE },
483   { "reuse2", ArgTrue, (void *) &appData.reuseSecond, FALSE, INVALID },
484   { "xreuse2", ArgFalse, (void *) &appData.reuseSecond, FALSE, INVALID },
485   { "-reuse2", ArgFalse, (void *) &appData.reuseSecond, FALSE, INVALID },
486   { "comPortSettings", ArgCommSettings, (void *) /*&dcb*/ 0, TRUE, INVALID },
487   { "settingsFile", ArgSettingsFilename, (void *) &settingsFileName, FALSE, (ArgIniType) SETTINGS_FILE },
488   { "ini", ArgSettingsFilename, (void *) &settingsFileName, FALSE, INVALID },
489   { "at", ArgSettingsFilename, (void *) NULL, FALSE, INVALID },
490   { "opt", ArgSettingsFilename, (void *) NULL, FALSE, INVALID },
491   { "saveSettingsFile", ArgFilename, (void *) &settingsFileName, FALSE, INVALID },
492   { "saveSettingsOnExit", ArgBoolean, (void *) &saveSettingsOnExit, TRUE, (ArgIniType) TRUE },
493   { "chessProgram", ArgBoolean, (void *) &chessProgram, FALSE, (ArgIniType) FALSE },
494   { "cp", ArgTrue, (void *) &chessProgram, FALSE, INVALID },
495   { "xcp", ArgFalse, (void *) &chessProgram, FALSE, INVALID },
496   { "-cp", ArgFalse, (void *) &chessProgram, FALSE, INVALID },
497   { "icsMenu", ArgString, (void *) &icsTextMenuString, TRUE, (ArgIniType) ICS_TEXT_MENU_DEFAULT },
498   { "icsNames", ArgString, (void *) &icsNames, TRUE, (ArgIniType) ICS_NAMES },
499   { "singleEngineList", ArgBoolean, (void *) &singleList, !XBOARD, (ArgIniType) FALSE },
500   { "recentEngines", ArgInt, (void *) &appData.recentEngines, TRUE, (ArgIniType) 6 },
501   { "recentEngineList", ArgString, (void *) &appData.recentEngineList, TRUE, (ArgIniType) "" },
502   { "firstChessProgramNames", ArgString, (void *) &firstChessProgramNames,
503     TRUE, (ArgIniType) FCP_NAMES },
504   { "secondChessProgramNames", ArgString, (void *) &secondChessProgramNames,
505     !XBOARD, (ArgIniType) SCP_NAMES },
506   { "themeNames", ArgString, (void *) &appData.themeNames, !XBOARD, (ArgIniType) "native -upf false -ub false -ubt false -pid \"\"\n" },
507   { "initialMode", ArgString, (void *) &appData.initialMode, FALSE, (ArgIniType) "" },
508   { "mode", ArgString, (void *) &appData.initialMode, FALSE, INVALID },
509   { "variant", ArgString, (void *) &appData.variant, FALSE, (ArgIniType) "normal" },
510   { "firstProtocolVersion", ArgInt, (void *) &appData.firstProtocolVersion, FALSE, (ArgIniType) PROTOVER },
511   { "secondProtocolVersion", ArgInt, (void *) &appData.secondProtocolVersion,FALSE, (ArgIniType) PROTOVER },
512   { "showButtonBar", ArgBoolean, (void *) &appData.showButtonBar, TRUE, (ArgIniType) TRUE },
513   { "buttons", ArgTrue, (void *) &appData.showButtonBar, FALSE, INVALID },
514   { "xbuttons", ArgFalse, (void *) &appData.showButtonBar, FALSE, INVALID },
515   { "-buttons", ArgFalse, (void *) &appData.showButtonBar, FALSE, INVALID },
516
517   /* [AS] New features */
518   { "firstScoreAbs", ArgBoolean, (void *) &appData.firstScoreIsAbsolute, FALSE, (ArgIniType) FALSE },
519   { "secondScoreAbs", ArgBoolean, (void *) &appData.secondScoreIsAbsolute, FALSE, (ArgIniType) FALSE },
520   { "pgnExtendedInfo", ArgBoolean, (void *) &appData.saveExtendedInfoInPGN, TRUE, (ArgIniType) FALSE },
521   { "hideThinkingFromHuman", ArgBoolean, (void *) &appData.hideThinkingFromHuman, TRUE, (ArgIniType) FALSE },
522   { "liteBackTextureFile", ArgFilename, (void *) &appData.liteBackTextureFile, TRUE, (ArgIniType) "" },
523   { "lbtf", ArgFilename, (void *) &appData.liteBackTextureFile, FALSE, INVALID },
524   { "darkBackTextureFile", ArgFilename, (void *) &appData.darkBackTextureFile, TRUE, (ArgIniType) "" },
525   { "dbtf", ArgFilename, (void *) &appData.darkBackTextureFile, FALSE, INVALID },
526   { "liteBackTextureMode", ArgInt, (void *) &appData.liteBackTextureMode, TRUE, (ArgIniType) BACK_TEXTURE_MODE_PLAIN },
527   { "lbtm", ArgInt, (void *) &appData.liteBackTextureMode, FALSE, INVALID },
528   { "darkBackTextureMode", ArgInt, (void *) &appData.darkBackTextureMode, TRUE, (ArgIniType) BACK_TEXTURE_MODE_PLAIN },
529   { "dbtm", ArgInt, (void *) &appData.darkBackTextureMode, FALSE, INVALID },
530   { "renderPiecesWithFont", ArgString, (void *) &appData.renderPiecesWithFont, TRUE, (ArgIniType) "" },
531   { "pf", ArgString, (void *) &appData.renderPiecesWithFont, FALSE, INVALID },
532   { "fontPieceToCharTable", ArgString, (void *) &appData.fontToPieceTable, TRUE, (ArgIniType) "" },
533   { "fptc", ArgString, (void *) &appData.fontToPieceTable, FALSE, INVALID },
534   { "fontPieceBackColorWhite", ArgColor, (void *) 8, TRUE, (ArgIniType) WHITE_PIECE_COLOR },
535   { "fontPieceForeColorWhite", ArgColor, (void *) 9, TRUE, (ArgIniType) WHITE_PIECE_COLOR },
536   { "fontPieceBackColorBlack", ArgColor, (void *) 10, TRUE, (ArgIniType) BLACK_PIECE_COLOR },
537   { "fontPieceForeColorBlack", ArgColor, (void *) 11, TRUE, (ArgIniType) BLACK_PIECE_COLOR },
538   { "fpfcw", ArgColor, (void *) 9, FALSE, INVALID },
539   { "fpbcb", ArgColor, (void *) 10, FALSE, INVALID },
540   { "fontPieceSize", ArgInt, (void *) &appData.fontPieceSize, TRUE, (ArgIniType) 80 },
541   { "overrideLineGap", ArgInt, (void *) &appData.overrideLineGap, TRUE, (ArgIniType) 1 },
542   { "adjudicateLossThreshold", ArgInt, (void *) &appData.adjudicateLossThreshold, TRUE, (ArgIniType) 0 },
543   { "delayBeforeQuit", ArgInt, (void *) &appData.delayBeforeQuit, TRUE, (ArgIniType) 0 },
544   { "delayAfterQuit", ArgInt, (void *) &appData.delayAfterQuit, TRUE, (ArgIniType) 0 },
545   { "nameOfDebugFile", ArgFilename, (void *) &appData.nameOfDebugFile, FALSE, (ArgIniType) DEBUG_FILE },
546   { "debugfile", ArgFilename, (void *) &appData.nameOfDebugFile, FALSE, INVALID },
547   { "pgnEventHeader", ArgString, (void *) &appData.pgnEventHeader, TRUE, (ArgIniType) "Computer Chess Game" },
548   { "defaultFrcPosition", ArgInt, (void *) &appData.defaultFrcPosition, TRUE, (ArgIniType) -1 },
549   { "shuffleOpenings", ArgTrue, (void *) &shuffleOpenings, FALSE, INVALID },
550   { "gameListTags", ArgString, (void *) &appData.gameListTags, TRUE, (ArgIniType) GLT_DEFAULT_TAGS },
551   { "saveOutOfBookInfo", ArgBoolean, (void *) &appData.saveOutOfBookInfo, TRUE, (ArgIniType) TRUE },
552   { "showEvalInMoveHistory", ArgBoolean, (void *) &appData.showEvalInMoveHistory, TRUE, (ArgIniType) TRUE },
553   { "evalHistColorWhite", ArgColor, (void *) 12, TRUE, (ArgIniType) "#FFFFB0" },
554   { "evalHistColorBlack", ArgColor, (void *) 13, TRUE, (ArgIniType) "#AD5D3D" },
555   { "highlightMoveWithArrow", ArgBoolean, (void *) &appData.highlightMoveWithArrow, TRUE, (ArgIniType) FALSE },
556   { "highlightArrowColor", ArgColor, (void *) 14, TRUE, (ArgIniType) "#FFFF80" },
557   { "stickyWindows", ArgBoolean, (void *) &appData.useStickyWindows, TRUE, (ArgIniType) TRUE },
558   { "adjudicateDrawMoves", ArgInt, (void *) &appData.adjudicateDrawMoves, TRUE, (ArgIniType) 0 },
559   { "autoDisplayComment", ArgBoolean, (void *) &appData.autoDisplayComment, TRUE, (ArgIniType) TRUE },
560   { "autoDisplayTags", ArgBoolean, (void *) &appData.autoDisplayTags, TRUE, (ArgIniType) TRUE },
561   { "firstIsUCI", ArgBoolean, (void *) &appData.firstIsUCI, FALSE, (ArgIniType) FALSE },
562   { "fUCI", ArgTrue, (void *) &appData.firstIsUCI, FALSE, INVALID },
563   { "firstUCI", ArgTrue, (void *) &appData.firstIsUCI, FALSE, INVALID },
564   { "secondIsUCI", ArgBoolean, (void *) &appData.secondIsUCI, FALSE, (ArgIniType) FALSE },
565   { "secondUCI", ArgTrue, (void *) &appData.secondIsUCI, FALSE, INVALID },
566   { "sUCI", ArgTrue, (void *) &appData.secondIsUCI, FALSE, INVALID },
567   { "fUCCI", ArgTwo, (void *) &appData.firstIsUCI, FALSE, INVALID },
568   { "sUCCI", ArgTwo, (void *) &appData.secondIsUCI, FALSE, INVALID },
569   { "fUSI", ArgTwo, (void *) &appData.firstIsUCI, FALSE, INVALID },
570   { "sUSI", ArgTwo, (void *) &appData.secondIsUCI, FALSE, INVALID },
571   { "firstHasOwnBookUCI", ArgBoolean, (void *) &appData.firstHasOwnBookUCI, FALSE, (ArgIniType) TRUE },
572   { "fNoOwnBookUCI", ArgFalse, (void *) &appData.firstHasOwnBookUCI, FALSE, INVALID },
573   { "firstXBook", ArgFalse, (void *) &appData.firstHasOwnBookUCI, FALSE, INVALID },
574   { "secondHasOwnBookUCI", ArgBoolean, (void *) &appData.secondHasOwnBookUCI, FALSE, (ArgIniType) TRUE },
575   { "sNoOwnBookUCI", ArgFalse, (void *) &appData.secondHasOwnBookUCI, FALSE, INVALID },
576   { "secondXBook", ArgFalse, (void *) &appData.secondHasOwnBookUCI, FALSE, INVALID },
577   { "adapterCommand", ArgFilename, (void *) &appData.adapterCommand, TRUE, (ArgIniType) "polyglot -noini -ec \"%fcp\" -ed \"%fd\"" },
578   { "uxiAdapter", ArgFilename, (void *) &appData.ucciAdapter, TRUE, (ArgIniType) "" },
579   { "polyglotDir", ArgFilename, (void *) &appData.polyglotDir, TRUE, (ArgIniType) "" },
580   { "usePolyglotBook", ArgBoolean, (void *) &appData.usePolyglotBook, TRUE, (ArgIniType) FALSE },
581   { "polyglotBook", ArgFilename, (void *) &appData.polyglotBook, TRUE, (ArgIniType) "" },
582   { "bookDepth", ArgInt, (void *) &appData.bookDepth, TRUE, (ArgIniType) 12 },
583   { "bookVariation", ArgInt, (void *) &appData.bookStrength, TRUE, (ArgIniType) 50 },
584   { "discourageOwnBooks", ArgBoolean, (void *) &appData.defNoBook, TRUE, (ArgIniType) FALSE },
585   { "mcBookMode", ArgTrue, (void *) &mcMode, FALSE, (ArgIniType) FALSE },
586   { "defaultHashSize", ArgInt, (void *) &appData.defaultHashSize, TRUE, (ArgIniType) 64 },
587   { "defaultCacheSizeEGTB", ArgInt, (void *) &appData.defaultCacheSizeEGTB, TRUE, (ArgIniType) 4 },
588   { "defaultPathEGTB", ArgFilename, (void *) &appData.defaultPathEGTB, TRUE, (ArgIniType) "c:\\egtb" },
589   { "language", ArgFilename, (void *) &appData.language, TRUE, (ArgIniType) "" },
590   { "userFileDirectory", ArgFilename, (void *) &homeDir, FALSE, (ArgIniType) installDir },
591   { "usePieceFont", ArgBoolean, (void *) &appData.useFont, TRUE, (ArgIniType) FALSE },
592   { "upf", ArgBoolean, (void *) &appData.useFont, FALSE, INVALID },
593   { "useBoardTexture", ArgBoolean, (void *) &appData.useBitmaps, TRUE, (ArgIniType) FALSE },
594   { "ubt", ArgBoolean, (void *) &appData.useBitmaps, FALSE, INVALID },
595   { "useBorder", ArgBoolean, (void *) &appData.useBorder, TRUE, (ArgIniType) FALSE },
596   { "ub", ArgBoolean, (void *) &appData.useBorder, FALSE, INVALID },
597   { "border", ArgFilename, (void *) &appData.border, TRUE, (ArgIniType) "" },
598
599   // [HGM] tournament options
600   { "tourneyFile", ArgFilename, (void *) &appData.tourneyFile, FALSE, (ArgIniType) "" },
601   { "tf", ArgFilename, (void *) &appData.tourneyFile, FALSE, INVALID },
602   { "participants", ArgString, (void *) &appData.participants, FALSE, (ArgIniType) "" },
603   { "tourneyType", ArgInt, (void *) &appData.tourneyType, FALSE, (ArgIniType) 0 },
604   { "tt", ArgInt, (void *) &appData.tourneyType, FALSE, INVALID },
605   { "tourneyCycles", ArgInt, (void *) &appData.tourneyCycles, FALSE, (ArgIniType) 1 },
606   { "cy", ArgInt, (void *) &appData.tourneyCycles, FALSE, INVALID },
607   { "results", ArgString, (void *) &appData.results, FALSE, (ArgIniType) "" },
608   { "syncAfterRound", ArgBoolean, (void *) &appData.roundSync, FALSE, (ArgIniType) FALSE },
609   { "syncAfterCycle", ArgBoolean, (void *) &appData.cycleSync, FALSE, (ArgIniType) TRUE },
610   { "seedBase", ArgInt, (void *) &appData.seedBase, FALSE, (ArgIniType) 1 },
611   { "pgnNumberTag", ArgBoolean, (void *) &appData.numberTag, TRUE, (ArgIniType) FALSE },
612   { "afterGame", ArgString, (void *) &appData.afterGame, FALSE, INVALID },
613   { "afterTourney", ArgString, (void *) &appData.afterTourney, FALSE, INVALID },
614
615   /* [HGM] board-size, adjudication and misc. options */
616   { "oneClickMove", ArgBoolean, (void *) &appData.oneClick, TRUE, (ArgIniType) FALSE },
617   { "boardWidth", ArgInt, (void *) &appData.NrFiles, FALSE, (ArgIniType) -1 },
618   { "boardHeight", ArgInt, (void *) &appData.NrRanks, FALSE, (ArgIniType) -1 },
619   { "holdingsSize", ArgInt, (void *) &appData.holdingsSize, FALSE, (ArgIniType) -1 },
620   { "defaultMatchGames", ArgInt, (void *) &appData.defaultMatchGames, TRUE, (ArgIniType) 10 },
621   { "matchPause", ArgInt, (void *) &appData.matchPause, TRUE, (ArgIniType) 10000 },
622   { "pieceToCharTable", ArgString, (void *) &appData.pieceToCharTable, FALSE, INVALID },
623   { "pieceNickNames", ArgString, (void *) &appData.pieceNickNames, FALSE, INVALID },
624   { "colorNickNames", ArgString, (void *) &appData.colorNickNames, FALSE, INVALID },
625   { "flipBlack", ArgBoolean, (void *) &appData.upsideDown, FALSE, (ArgIniType) FALSE },
626   { "allWhite", ArgBoolean, (void *) &appData.allWhite, FALSE, (ArgIniType) FALSE },
627   { "alphaRank", ArgBoolean, (void *) &appData.alphaRank, FALSE, (ArgIniType) FALSE },
628   { "firstAlphaRank", ArgBoolean, (void *) &first.alphaRank, FALSE, (ArgIniType) FALSE },
629   { "secondAlphaRank", ArgBoolean, (void *) &second.alphaRank, FALSE, (ArgIniType) FALSE },
630   { "testClaims", ArgBoolean, (void *) &appData.testClaims, TRUE, (ArgIniType) FALSE },
631   { "checkMates", ArgBoolean, (void *) &appData.checkMates, TRUE, (ArgIniType) FALSE },
632   { "materialDraws", ArgBoolean, (void *) &appData.materialDraws, TRUE, (ArgIniType) FALSE },
633   { "trivialDraws", ArgBoolean, (void *) &appData.trivialDraws, TRUE, (ArgIniType) FALSE },
634   { "ruleMoves", ArgInt, (void *) &appData.ruleMoves, TRUE, (ArgIniType) 51 },
635   { "repeatsToDraw", ArgInt, (void *) &appData.drawRepeats, TRUE, (ArgIniType) 6 },
636   { "backgroundObserve", ArgBoolean, (void *) &appData.bgObserve, TRUE, (ArgIniType) FALSE },
637   { "dualBoard", ArgBoolean, (void *) &appData.dualBoard, TRUE, (ArgIniType) FALSE },
638   { "autoKibitz", ArgTrue, (void *) &appData.autoKibitz, FALSE, INVALID },
639   { "engineDebugOutput", ArgInt, (void *) &appData.engineComments, FALSE, (ArgIniType) 1 },
640   { "userName", ArgString, (void *) &appData.userName, FALSE, INVALID },
641   { "rewindIndex", ArgInt, (void *) &appData.rewindIndex, FALSE, INVALID },
642   { "sameColorGames", ArgInt, (void *) &appData.sameColorGames, FALSE, INVALID },
643   { "smpCores", ArgInt, (void *) &appData.smpCores, TRUE, (ArgIniType) 1 },
644   { "egtFormats", ArgString, (void *) &appData.egtFormats, TRUE, (ArgIniType) "" },
645   { "niceEngines", ArgInt, (void *) &appData.niceEngines, TRUE, INVALID },
646   { "logoSize", ArgInt, (void *) &appData.logoSize, XBOARD, INVALID },
647   { "logoDir", ArgFilename, (void *) &appData.logoDir, XBOARD, (ArgIniType) "." },
648   { "firstLogo", ArgFilename, (void *) &appData.firstLogo, FALSE, (ArgIniType) "" },
649   { "secondLogo", ArgFilename, (void *) &appData.secondLogo, FALSE, (ArgIniType) "" },
650   { "autoLogo", ArgBoolean, (void *) &appData.autoLogo, TRUE, INVALID },
651   { "firstOptions", ArgString, (void *) &appData.firstOptions, FALSE, (ArgIniType) "" },
652   { "secondOptions", ArgString, (void *) &appData.secondOptions, FALSE, (ArgIniType) "" },
653   { "firstFeatures", ArgString, (void *) &appData.features[0], FALSE, (ArgIniType) "" },
654   { "secondFeatures", ArgString, (void *) &appData.features[1], FALSE, (ArgIniType) "" },
655   { "featureDefaults", ArgString, (void *) &appData.featureDefaults, TRUE, (ArgIniType) "" },
656   { "firstNeedsNoncompliantFEN", ArgString, (void *) &appData.fenOverride1, FALSE, (ArgIniType) NULL },
657   { "secondNeedsNoncompliantFEN", ArgString, (void *) &appData.fenOverride2, FALSE, (ArgIniType) NULL },
658   { "keepAlive", ArgInt, (void *) &appData.keepAlive, FALSE, INVALID },
659   { "icstype", ArgInt, (void *) &ics_type, FALSE, INVALID },
660   { "forceIllegalMoves", ArgTrue, (void *) &appData.forceIllegal, FALSE, INVALID },
661   { "showTargetSquares", ArgBoolean, (void *) &appData.markers, TRUE, (ArgIniType) FALSE },
662   { "firstPgnName", ArgString, (void *) &appData.pgnName[0], FALSE, (ArgIniType) "" },
663   { "fn", ArgString, (void *) &appData.pgnName[0], FALSE, INVALID },
664   { "secondPgnName", ArgString, (void *) &appData.pgnName[1], FALSE, (ArgIniType) "" },
665   { "sn", ArgString, (void *) &appData.pgnName[1], FALSE, INVALID },
666   { "absoluteAnalysisScores", ArgBoolean, (void *) &appData.whitePOV, TRUE, FALSE },
667   { "scoreWhite", ArgBoolean, (void *) &appData.scoreWhite, TRUE, FALSE },
668   { "evalZoom", ArgInt, (void *) &appData.zoom, TRUE, (ArgIniType) 1 },
669   { "evalThreshold", ArgInt, (void *) &appData.evalThreshold, TRUE, (ArgIniType) 25 },
670   { "fSAN", ArgTrue, (void *) &appData.pvSAN[0], FALSE, FALSE },
671   { "sSAN", ArgTrue, (void *) &appData.pvSAN[1], FALSE, FALSE },
672   { "pairingEngine", ArgFilename, (void *) &appData.pairingEngine, TRUE, "" },
673   { "defaultTourneyName", ArgFilename, (void *) &appData.defName, TRUE, "" },
674   { "eloThresholdAny", ArgInt, (void *) &appData.eloThreshold1, FALSE, (ArgIniType) 0 },
675   { "eloThresholdBoth", ArgInt, (void *) &appData.eloThreshold2, FALSE, (ArgIniType) 0 },
676   { "dateThreshold", ArgInt, (void *) &appData.dateThreshold, FALSE, (ArgIniType) 0 },
677   { "searchMode", ArgInt, (void *) &appData.searchMode, FALSE, (ArgIniType) 1 },
678   { "stretch", ArgInt, (void *) &appData.stretch, FALSE, (ArgIniType) 1 },
679   { "ignoreColors", ArgBoolean, (void *) &appData.ignoreColors, FALSE, FALSE },
680   { "findMirrorImage", ArgBoolean, (void *) &appData.findMirror, FALSE, FALSE },
681   { "viewer", ArgTrue, (void *) &appData.viewer, FALSE, FALSE },
682   { "viewerOptions", ArgString, (void *) &appData.viewerOptions, TRUE, (ArgIniType) "-ncp -engineOutputUp false -saveSettingsOnExit false" },
683   { "tourneyOptions", ArgString, (void *) &appData.tourneyOptions, TRUE, (ArgIniType) "-ncp -mm -saveSettingsOnExit false" },
684   { "autoCopyPV", ArgBoolean, (void *) &appData.autoCopyPV, TRUE, FALSE },
685   { "topLevel", ArgBoolean, (void *) &appData.topLevel, XBOARD, (ArgIniType) TOPLEVEL },
686   { "dialogColor", ArgString, (void *) &appData.dialogColor, XBOARD, (ArgIniType) "" },
687   { "buttonColor", ArgString, (void *) &appData.buttonColor, XBOARD, (ArgIniType) "" },
688
689 #if ZIPPY
690   { "zippyTalk", ArgBoolean, (void *) &appData.zippyTalk, FALSE, (ArgIniType) ZIPPY_TALK },
691   { "zt", ArgTrue, (void *) &appData.zippyTalk, FALSE, INVALID },
692   { "xzt", ArgFalse, (void *) &appData.zippyTalk, FALSE, INVALID },
693   { "-zt", ArgFalse, (void *) &appData.zippyTalk, FALSE, INVALID },
694   { "zippyPlay", ArgBoolean, (void *) &appData.zippyPlay, FALSE, (ArgIniType) ZIPPY_PLAY },
695   { "zp", ArgTrue, (void *) &appData.zippyPlay, FALSE, INVALID },
696   { "xzp", ArgFalse, (void *) &appData.zippyPlay, FALSE, INVALID },
697   { "-zp", ArgFalse, (void *) &appData.zippyPlay, FALSE, INVALID },
698   { "zippyLines", ArgFilename, (void *) &appData.zippyLines, FALSE, (ArgIniType) ZIPPY_LINES },
699   { "zippyPinhead", ArgString, (void *) &appData.zippyPinhead, FALSE, (ArgIniType) ZIPPY_PINHEAD },
700   { "zippyPassword", ArgString, (void *) &appData.zippyPassword, FALSE, (ArgIniType) ZIPPY_PASSWORD },
701   { "zippyPassword2", ArgString, (void *) &appData.zippyPassword2, FALSE, (ArgIniType) ZIPPY_PASSWORD2 },
702   { "zippyWrongPassword", ArgString, (void *) &appData.zippyWrongPassword,
703     FALSE, (ArgIniType) ZIPPY_WRONG_PASSWORD },
704   { "zippyAcceptOnly", ArgString, (void *) &appData.zippyAcceptOnly, FALSE, (ArgIniType) ZIPPY_ACCEPT_ONLY },
705   { "zippyUseI", ArgBoolean, (void *) &appData.zippyUseI, FALSE, (ArgIniType) ZIPPY_USE_I },
706   { "zui", ArgTrue, (void *) &appData.zippyUseI, FALSE, INVALID },
707   { "xzui", ArgFalse, (void *) &appData.zippyUseI, FALSE, INVALID },
708   { "-zui", ArgFalse, (void *) &appData.zippyUseI, FALSE, INVALID },
709   { "zippyBughouse", ArgInt, (void *) &appData.zippyBughouse, FALSE, (ArgIniType) ZIPPY_BUGHOUSE },
710   { "zippyNoplayCrafty", ArgBoolean, (void *) &appData.zippyNoplayCrafty,
711     FALSE, (ArgIniType) ZIPPY_NOPLAY_CRAFTY },
712   { "znc", ArgTrue, (void *) &appData.zippyNoplayCrafty, FALSE, INVALID },
713   { "xznc", ArgFalse, (void *) &appData.zippyNoplayCrafty, FALSE, INVALID },
714   { "-znc", ArgFalse, (void *) &appData.zippyNoplayCrafty, FALSE, INVALID },
715   { "zippyGameEnd", ArgString, (void *) &appData.zippyGameEnd, FALSE, (ArgIniType) ZIPPY_GAME_END },
716   { "zippyGameStart", ArgString, (void *) &appData.zippyGameStart, FALSE, (ArgIniType) ZIPPY_GAME_START },
717   { "zippyAdjourn", ArgBoolean, (void *) &appData.zippyAdjourn, FALSE, (ArgIniType) ZIPPY_ADJOURN },
718   { "zadj", ArgTrue, (void *) &appData.zippyAdjourn, FALSE, INVALID },
719   { "xzadj", ArgFalse, (void *) &appData.zippyAdjourn, FALSE, INVALID },
720   { "-zadj", ArgFalse, (void *) &appData.zippyAdjourn, FALSE, INVALID },
721   { "zippyAbort", ArgBoolean, (void *) &appData.zippyAbort, FALSE, (ArgIniType) ZIPPY_ABORT },
722   { "zab", ArgTrue, (void *) &appData.zippyAbort, FALSE, INVALID },
723   { "xzab", ArgFalse, (void *) &appData.zippyAbort, FALSE, INVALID },
724   { "-zab", ArgFalse, (void *) &appData.zippyAbort, FALSE, INVALID },
725   { "zippyVariants", ArgString, (void *) &appData.zippyVariants, FALSE, (ArgIniType) ZIPPY_VARIANTS },
726   { "zippyMaxGames", ArgInt, (void *)&appData.zippyMaxGames, FALSE, (ArgIniType) ZIPPY_MAX_GAMES},
727   { "zippyReplayTimeout", ArgInt, (void *)&appData.zippyReplayTimeout, FALSE, (ArgIniType) ZIPPY_REPLAY_TIMEOUT },
728   { "zippyShortGame", ArgInt, (void *)&appData.zippyShortGame, FALSE, INVALID },
729   /* Kludge to allow winboard.ini files from buggy 4.0.4 to be read: */
730   { "zippyReplyTimeout", ArgInt, (void *)&junk, FALSE, INVALID },
731 #endif
732   /* [HGM] options for broadcasting and time odds */
733   { "chatBoxes", ArgString, (void *) &appData.chatBoxes, !XBOARD, (ArgIniType) NULL },
734   { "serverMoves", ArgString, (void *) &appData.serverMovesName, FALSE, (ArgIniType) NULL },
735   { "serverFile", ArgString, (void *) &appData.serverFileName, FALSE, (ArgIniType) NULL },
736   { "suppressLoadMoves", ArgBoolean, (void *) &appData.suppressLoadMoves, FALSE, (ArgIniType) FALSE },
737   { "serverPause", ArgInt, (void *) &appData.serverPause, FALSE, (ArgIniType) 15 },
738   { "firstTimeOdds", ArgInt, (void *) &appData.firstTimeOdds, FALSE, (ArgIniType) 1 },
739   { "secondTimeOdds", ArgInt, (void *) &appData.secondTimeOdds, FALSE, (ArgIniType) 1 },
740   { "timeOddsMode", ArgInt, (void *) &appData.timeOddsMode, TRUE, INVALID },
741   { "firstAccumulateTC", ArgInt, (void *) &appData.firstAccumulateTC, FALSE, (ArgIniType) 1 },
742   { "secondAccumulateTC", ArgInt, (void *) &appData.secondAccumulateTC, FALSE, (ArgIniType) 1 },
743   { "firstNPS", ArgInt, (void *) &appData.firstNPS, FALSE, (ArgIniType) -1 },
744   { "secondNPS", ArgInt, (void *) &appData.secondNPS, FALSE, (ArgIniType) -1 },
745   { "noGUI", ArgTrue, (void *) &appData.noGUI, FALSE, INVALID },
746   { "keepLineBreaksICS", ArgBoolean, (void *) &appData.noJoin, TRUE, INVALID },
747   { "wrapContinuationSequence", ArgString, (void *) &appData.wrapContSeq, FALSE, INVALID },
748   { "useInternalWrap", ArgTrue, (void *) &appData.useInternalWrap, FALSE, INVALID }, /* noJoin usurps this if set */
749   { "openCommand", ArgString, (void *) &appData.sysOpen, FALSE, "xdg-open" },
750
751   // [HGM] placement: put all window layouts last in ini file, but man X,Y before all others
752   { "minX", ArgZ, (void *) &minX, FALSE, INVALID }, // [HGM] placement: to make sure auxiliary windows can be placed
753   { "minY", ArgZ, (void *) &minY, FALSE, INVALID },
754   { "winWidth",  ArgInt, (void *) &wpMain.width,  TRUE, INVALID }, // [HGM] placement: dummies to remember right & bottom
755   { "winHeight", ArgInt, (void *) &wpMain.height, TRUE, INVALID }, //       for attaching auxiliary windows to them
756   { "x", ArgInt, (void *) &wpMain.x, TRUE, (ArgIniType) CW_USEDEFAULT },
757   { "y", ArgInt, (void *) &wpMain.y, TRUE, (ArgIniType) CW_USEDEFAULT },
758   { "icsX", ArgX,   (void *) &wpConsole.x, TRUE, (ArgIniType) CW_USEDEFAULT },
759   { "icsY", ArgY,   (void *) &wpConsole.y, TRUE, (ArgIniType) CW_USEDEFAULT },
760   { "icsW", ArgInt, (void *) &wpConsole.width, TRUE, (ArgIniType) CW_USEDEFAULT },
761   { "icsH", ArgInt, (void *) &wpConsole.height, TRUE, (ArgIniType) CW_USEDEFAULT },
762   { "commentX", ArgX,   (void *) &wpComment.x, TRUE, (ArgIniType) CW_USEDEFAULT },
763   { "commentY", ArgY,   (void *) &wpComment.y, TRUE, (ArgIniType) CW_USEDEFAULT },
764   { "commentW", ArgInt, (void *) &wpComment.width, TRUE, (ArgIniType) CW_USEDEFAULT },
765   { "commentH", ArgInt, (void *) &wpComment.height, TRUE, (ArgIniType) CW_USEDEFAULT },
766   { "tagsX", ArgX,   (void *) &wpTags.x, TRUE, (ArgIniType) CW_USEDEFAULT },
767   { "tagsY", ArgY,   (void *) &wpTags.y, TRUE, (ArgIniType) CW_USEDEFAULT },
768   { "tagsW", ArgInt, (void *) &wpTags.width, TRUE, (ArgIniType) CW_USEDEFAULT },
769   { "tagsH", ArgInt, (void *) &wpTags.height, TRUE, (ArgIniType) CW_USEDEFAULT },
770   { "gameListX", ArgX,   (void *) &wpGameList.x, TRUE, (ArgIniType) CW_USEDEFAULT },
771   { "gameListY", ArgY,   (void *) &wpGameList.y, TRUE, (ArgIniType) CW_USEDEFAULT },
772   { "gameListW", ArgInt, (void *) &wpGameList.width, TRUE, (ArgIniType) CW_USEDEFAULT },
773   { "gameListH", ArgInt, (void *) &wpGameList.height, TRUE, (ArgIniType) CW_USEDEFAULT },
774   /* [AS] Layout stuff */
775   { "moveHistoryUp", ArgBoolean, (void *) &wpMoveHistory.visible, TRUE, (ArgIniType) TRUE },
776   { "moveHistoryX", ArgX,   (void *) &wpMoveHistory.x, TRUE, (ArgIniType) CW_USEDEFAULT },
777   { "moveHistoryY", ArgY,   (void *) &wpMoveHistory.y, TRUE, (ArgIniType) CW_USEDEFAULT },
778   { "moveHistoryW", ArgInt, (void *) &wpMoveHistory.width, TRUE, (ArgIniType) CW_USEDEFAULT },
779   { "moveHistoryH", ArgInt, (void *) &wpMoveHistory.height, TRUE, (ArgIniType) CW_USEDEFAULT },
780
781   { "evalGraphUp", ArgBoolean, (void *) &wpEvalGraph.visible, TRUE, (ArgIniType) TRUE },
782   { "evalGraphX", ArgX,   (void *) &wpEvalGraph.x, TRUE, (ArgIniType) CW_USEDEFAULT },
783   { "evalGraphY", ArgY,   (void *) &wpEvalGraph.y, TRUE, (ArgIniType) CW_USEDEFAULT },
784   { "evalGraphW", ArgInt, (void *) &wpEvalGraph.width, TRUE, (ArgIniType) CW_USEDEFAULT },
785   { "evalGraphH", ArgInt, (void *) &wpEvalGraph.height, TRUE, (ArgIniType) CW_USEDEFAULT },
786
787   { "engineOutputUp", ArgBoolean, (void *) &wpEngineOutput.visible, TRUE, (ArgIniType) TRUE },
788   { "engineOutputX", ArgX,   (void *) &wpEngineOutput.x, TRUE, (ArgIniType) CW_USEDEFAULT },
789   { "engineOutputY", ArgY,   (void *) &wpEngineOutput.y, TRUE, (ArgIniType) CW_USEDEFAULT },
790   { "engineOutputW", ArgInt, (void *) &wpEngineOutput.width, TRUE, (ArgIniType) CW_USEDEFAULT },
791   { "engineOutputH", ArgInt, (void *) &wpEngineOutput.height, TRUE, (ArgIniType) CW_USEDEFAULT },
792
793   { NULL, ArgNone, NULL, FALSE, INVALID }
794 };
795
796
797 /* Kludge for indirection files on command line */
798 char* lastIndirectionFilename;
799 ArgDescriptor argDescriptorIndirection =
800 { "", ArgSettingsFilename, (void *) NULL, FALSE };
801
802 void
803 ExitArgError(char *msg, char *badArg, Boolean quit)
804 {
805   char buf[MSG_SIZ];
806   int len;
807
808   len = snprintf(buf, MSG_SIZ, msg, badArg);
809   if( (len >= MSG_SIZ) && appData.debugMode )
810     fprintf(debugFP, "ExitArgError: buffer truncated. Input: msg=%s badArg=%s\n", msg, badArg);
811
812   if(!quit) { printf(_("%s in settings file\n"), buf); return; } // DisplayError does not work yet at this stage...
813   DisplayFatalError(buf, 0, 2);
814   exit(2);
815 }
816
817 int
818 ValidateInt(char *s)
819 {
820   char *p = s;
821   if(*p == '-' || *p == '+') p++;
822   while(*p) if(!isdigit(*p++)) ExitArgError(_("Bad integer value %s"), s, TRUE);
823   return atoi(s);
824 }
825
826 char
827 StringGet(void *getClosure)
828 {
829   char **p = (char **) getClosure;
830   return *((*p)++);
831 }
832
833 char
834 FileGet(void *getClosure)
835 {
836   int c;
837   FILE* f = (FILE*) getClosure;
838
839   c = getc(f);
840   if (c == '\r') c = getc(f); // work around DOS format files by bypassing the '\r' completely
841   if (c == EOF)
842     return NULLCHAR;
843   else
844     return (char) c;
845 }
846
847 /* Parse settings file named "name". If file found, return the
848    full name in fullname and return TRUE; else return FALSE */
849 Boolean
850 ParseSettingsFile(char *name, char **addr)
851 {
852   FILE *f;
853   int ok,len;
854   char buf[MSG_SIZ], fullname[MSG_SIZ];
855
856
857   ok = MySearchPath(installDir, name, fullname);
858   if(!ok && strchr(name, '.') == NULL)
859     { // append default file-name extension '.ini' when needed
860       len = snprintf(buf,MSG_SIZ, "%s.ini", name);
861       if( (len >= MSG_SIZ) && appData.debugMode )
862         fprintf(debugFP, "ParseSettingsFile: buffer truncated. Input: name=%s \n",name);
863
864       ok = MySearchPath(installDir, buf, fullname);
865     }
866   if (ok) {
867     f = fopen(fullname, "r");
868     if (f != NULL) {
869       if (addr != NULL) {
870             ASSIGN(*addr, fullname);
871       }
872       ParseArgs(FileGet, f);
873       fclose(f);
874       return TRUE;
875     }
876   }
877   return FALSE;
878 }
879
880 void
881 ParseArgs(GetFunc get, void *cl)
882 {
883   char argName[MAX_ARG_LEN];
884   char argValue[MAX_ARG_LEN];
885   ArgDescriptor *ad;
886   char start;
887   char *q;
888   int i, octval;
889   char ch;
890   int posarg = 4; // default is game file
891
892   ch = get(cl);
893   for (;;) {
894     int posflag = 0;
895     while (ch == ' ' || ch == '\n' || ch == '\t') ch = get(cl);
896     if (ch == NULLCHAR) break;
897     if (ch == ';') {
898       /* Comment to end of line */
899       ch = get(cl);
900       while (ch != '\n' && ch != NULLCHAR) ch = get(cl);
901       continue;
902     } else if (ch == '/' || ch == '-') {
903       /* Switch */
904       q = argName;
905       while (ch != ' ' && ch != '=' && ch != ':' && ch != NULLCHAR &&
906              ch != '\n' && ch != '\t') {
907         *q++ = ch;
908         ch = get(cl);
909       }
910       *q = NULLCHAR;
911       for (ad = argDescriptors; ad->argName != NULL; ad++)
912         if (strcmp(ad->argName, argName + 1) == 0) break;
913       if (ad->argName == NULL) {
914         ExitArgError(_("Unrecognized argument %s"), argName, get != &FileGet); // [HGM] make unknown argument non-fatal
915         while (ch != '\n' && ch != NULLCHAR) ch = get(cl); // but skip rest of line it is on
916         continue; // so that when it is in a settings file, it is the only setting that will be purged from it
917       }
918     } else if (ch == '@') {
919       /* Indirection file */
920       ad = &argDescriptorIndirection;
921       ch = get(cl);
922     } else {
923       /* Positional argument */
924       ad = &argDescriptors[posarg++];
925       posflag++;
926       strncpy(argName, ad->argName,sizeof(argName)/sizeof(argName[0]));
927     }
928
929     if (ad->argType == ArgTwo) { // [HGM] kludgey arg type, not suitable for saving
930       *(Boolean *) ad->argLoc = 2;
931       continue;
932     }
933     if (ad->argType == ArgTrue) {
934       *(Boolean *) ad->argLoc = TRUE;
935       continue;
936     }
937     if (ad->argType == ArgFalse) {
938       *(Boolean *) ad->argLoc = FALSE;
939       continue;
940     }
941
942     while (ch == ' ' || ch == '=' || ch == ':' || ch == '\t') ch = get(cl);
943     if (ch == NULLCHAR || ch == '\n') {
944       ExitArgError(_("No value provided for argument %s"), argName, TRUE);
945     }
946     q = argValue;
947     if (ch == '{') {
948       // Quoting with { }.  No characters have to (or can) be escaped.
949       // Thus the string cannot contain a '}' character.
950       start = ch;
951       ch = get(cl);
952       while (start) {
953         switch (ch) {
954         case NULLCHAR:
955           start = NULLCHAR;
956           break;
957
958         case '}':
959           ch = get(cl);
960           start = NULLCHAR;
961           break;
962
963         default:
964           *q++ = ch;
965           ch = get(cl);
966           break;
967         }
968       }
969     } else if (ch == '\'' || ch == '"') {
970       // Quoting with ' ' or " ", with \ as escape character.
971       // Inconvenient for long strings that may contain Windows filenames.
972       start = ch;
973       ch = get(cl);
974       while (start) {
975         switch (ch) {
976         case NULLCHAR:
977           start = NULLCHAR;
978           break;
979
980         default:
981         not_special:
982           *q++ = ch;
983           ch = get(cl);
984           break;
985
986         case '\'':
987         case '\"':
988           if (ch == start) {
989             ch = get(cl);
990             start = NULLCHAR;
991             break;
992           } else {
993             goto not_special;
994           }
995
996         case '\\':
997           if (ad->argType == ArgFilename
998               || ad->argType == ArgSettingsFilename) {
999               goto not_special;
1000           }
1001           ch = get(cl);
1002           switch (ch) {
1003           case NULLCHAR:
1004             ExitArgError(_("Incomplete \\ escape in value for %s"), argName, TRUE);
1005             break;
1006           case 'n':
1007             *q++ = '\n';
1008             ch = get(cl);
1009             break;
1010           case 'r':
1011             *q++ = '\r';
1012             ch = get(cl);
1013             break;
1014           case 't':
1015             *q++ = '\t';
1016             ch = get(cl);
1017             break;
1018           case 'b':
1019             *q++ = '\b';
1020             ch = get(cl);
1021             break;
1022           case 'f':
1023             *q++ = '\f';
1024             ch = get(cl);
1025             break;
1026           default:
1027             octval = 0;
1028             for (i = 0; i < 3; i++) {
1029               if (ch >= '0' && ch <= '7') {
1030                 octval = octval*8 + (ch - '0');
1031                 ch = get(cl);
1032               } else {
1033                 break;
1034               }
1035             }
1036             if (i > 0) {
1037               *q++ = (char) octval;
1038             } else {
1039               *q++ = ch;
1040               ch = get(cl);
1041             }
1042             break;
1043           }
1044           break;
1045         }
1046       }
1047     } else {
1048       while ((ch != ' ' || posflag) && ch != NULLCHAR && ch != '\t' && ch != '\n') { // space allowed in positional arg
1049         *q++ = ch;
1050         ch = get(cl);
1051       }
1052     }
1053     *q = NULLCHAR;
1054
1055     if(posflag) { // positional argument: the argName was implied, and per default set as -lgf
1056       int len = strlen(argValue) - 4; // start of filename extension
1057       if(len < 0) len = 0;
1058       if(!strcasecmp(argValue + len, ".trn")) {
1059         ad = &argDescriptors[2]; // correct implied type to -tf
1060         appData.tourney = TRUE; // let it parse -tourneyOptions later
1061       } else if(!strcasecmp(argValue + len, ".fen") || !strcasecmp(argValue + len, ".epd")) {
1062         ad = &argDescriptors[1]; // correct implied type to -lpf
1063         appData.viewer = TRUE;
1064       } else if(!strcasecmp(argValue + len, ".ini") || !strcasecmp(argValue + len, ".xop")) {
1065         ad = &argDescriptors[0]; // correct implied type to -opt
1066       } else if(GetEngineLine(argValue, 11)) {
1067         ad = &argDescriptors[3]; // correct implied type to -is
1068       } else { // keep default -lgf, but let it imply viewer mode as well
1069         appData.viewer = TRUE;
1070       }
1071       strncpy(argName, ad->argName,sizeof(argName)/sizeof(argName[0]));
1072     }
1073
1074     switch (ad->argType) {
1075     case ArgInt:
1076       *(int *) ad->argLoc = ValidateInt(argValue);
1077       break;
1078
1079     case ArgX:
1080       *(int *) ad->argLoc = ValidateInt(argValue) + wpMain.x; // [HGM] placement: translate stored relative to absolute
1081       break;
1082
1083     case ArgY:
1084       *(int *) ad->argLoc = ValidateInt(argValue) + wpMain.y; // (this is really kludgey, it should be done where used...)
1085       break;
1086
1087     case ArgZ:
1088       *(int *) ad->argLoc = ValidateInt(argValue);
1089       EnsureOnScreen(&wpMain.x, &wpMain.y, minX, minY);
1090       break;
1091
1092     case ArgFloat:
1093       *(float *) ad->argLoc = (float) atof(argValue);
1094       break;
1095
1096     case ArgString:
1097     case ArgFilename:
1098       ASSIGN(*(char **) ad->argLoc, argValue);
1099       break;
1100
1101     case ArgSettingsFilename:
1102       {
1103         if (ParseSettingsFile(argValue, (char**)ad->argLoc)) {
1104         } else {
1105           if (ad->argLoc != NULL) {
1106           } else {
1107             ExitArgError(_("Failed to open indirection file %s"), argValue, TRUE);
1108           }
1109         }
1110       }
1111       break;
1112
1113     case ArgBoolean:
1114       switch (argValue[0]) {
1115       case 't':
1116       case 'T':
1117         *(Boolean *) ad->argLoc = TRUE;
1118         break;
1119       case 'f':
1120       case 'F':
1121         *(Boolean *) ad->argLoc = FALSE;
1122         break;
1123       default:
1124         ExitArgError(_("Unrecognized boolean argument value %s"), argValue, TRUE);
1125         break;
1126       }
1127       break;
1128
1129     case ArgColor:
1130       ParseColor((int)(intptr_t)ad->argLoc, argValue);
1131       break;
1132
1133     case ArgAttribs: {
1134       ColorClass cc = (ColorClass)ad->argLoc;
1135         ParseTextAttribs(cc, argValue); // [HGM] wrapper for platform independency
1136       }
1137       break;
1138
1139     case ArgBoardSize:
1140       ParseBoardSize(ad->argLoc, argValue);
1141       break;
1142
1143     case ArgFont:
1144       ParseFont(argValue, (int)(intptr_t)ad->argLoc);
1145       break;
1146
1147     case ArgCommSettings:
1148       ParseCommPortSettings(argValue);
1149       break;
1150
1151     case ArgNone:
1152       ExitArgError(_("Unrecognized argument %s"), argValue, TRUE);
1153       break;
1154     case ArgTwo:
1155     case ArgTrue:
1156     case ArgFalse: ;
1157     }
1158   }
1159 }
1160
1161 void
1162 ParseArgsFromString(char *p)
1163 {
1164     ParseArgs(StringGet, &p);
1165 }
1166
1167 void
1168 ParseArgsFromFile(FILE *f)
1169 {
1170     ParseArgs(FileGet, f);
1171 }
1172
1173 void
1174 ParseIcsTextMenu(char *icsTextMenuString)
1175 {
1176 //  int flags = 0;
1177   IcsTextMenuEntry *e = icsTextMenuEntry;
1178   char *p = icsTextMenuString;
1179   while (e->item != NULL && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) {
1180     free(e->item);
1181     e->item = NULL;
1182     if (e->command != NULL) {
1183       free(e->command);
1184       e->command = NULL;
1185     }
1186     e++;
1187   }
1188   e = icsTextMenuEntry;
1189   while (*p && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) {
1190     if (*p == ';' || *p == '\n') {
1191       e->item = strdup("-");
1192       e->command = NULL;
1193       p++;
1194     } else if (*p == '-') {
1195       e->item = strdup("-");
1196       e->command = NULL;
1197       p++;
1198       if (*p) p++;
1199     } else {
1200       char *q, *r, *s, *t;
1201       char c;
1202       q = strchr(p, ',');
1203       if (q == NULL) break;
1204       *q = NULLCHAR;
1205       r = strchr(q + 1, ',');
1206       if (r == NULL) break;
1207       *r = NULLCHAR;
1208       s = strchr(r + 1, ',');
1209       if (s == NULL) break;
1210       *s = NULLCHAR;
1211       c = ';';
1212       t = strchr(s + 1, c);
1213       if (t == NULL) {
1214         c = '\n';
1215         t = strchr(s + 1, c);
1216       }
1217       if (t != NULL) *t = NULLCHAR;
1218       e->item = strdup(p);
1219       e->command = strdup(q + 1);
1220       e->getname = *(r + 1) != '0';
1221       e->immediate = *(s + 1) != '0';
1222       *q = ',';
1223       *r = ',';
1224       *s = ',';
1225       if (t == NULL) break;
1226       *t = c;
1227       p = t + 1;
1228     }
1229     e++;
1230   }
1231 }
1232
1233 void
1234 SetDefaultTextAttribs()
1235 {
1236   ColorClass cc;
1237   for (cc = (ColorClass)0; cc < ColorNone; cc++) {
1238     ParseTextAttribs(cc, defaultTextAttribs[cc]);
1239   }
1240 }
1241
1242 void
1243 SetDefaultsFromList()
1244 { // [HGM] ini: take defaults from argDescriptor list
1245   int i;
1246
1247   for(i=0; argDescriptors[i].argName != NULL; i++) {
1248     if(argDescriptors[i].defaultValue != INVALID)
1249       switch(argDescriptors[i].argType) {
1250         case ArgBoolean:
1251         case ArgTwo:
1252         case ArgTrue:
1253         case ArgFalse:
1254           *(Boolean *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1255           break;
1256         case ArgInt:
1257         case ArgX:
1258         case ArgY:
1259         case ArgZ:
1260           *(int *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1261           break;
1262         case ArgString:
1263         case ArgFilename:
1264         case ArgSettingsFilename:
1265           if((char *)argDescriptors[i].defaultValue)
1266           *(char **) argDescriptors[i].argLoc = strdup((char *)argDescriptors[i].defaultValue);
1267           break;
1268         case ArgBoardSize:
1269           *(int *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1270           break;
1271         case ArgColor:
1272           ParseColor((int)(intptr_t)argDescriptors[i].argLoc, (char*)argDescriptors[i].defaultValue);
1273           break;
1274         case ArgFloat: // floats cannot be casted to int without precision loss
1275         default: ; // some arg types cannot be initialized through table
1276     }
1277   }
1278 }
1279
1280 void
1281 InitAppData(char *lpCmdLine)
1282 {
1283   int i;
1284   char buf[MAX_ARG_LEN], currDir[MSG_SIZ];
1285   char *p;
1286
1287   /* Initialize to defaults */
1288   SetDefaultsFromList(); // this sets most defaults
1289
1290   // some parameters for which there are no options!
1291   appData.Iconic = FALSE; /*unused*/
1292   appData.icsEngineAnalyze = FALSE;
1293
1294   // float: casting to int is not harmless, so default cannot be contained in table
1295   appData.timeDelay = TIME_DELAY;
1296   appData.timeIncrement = -314159;
1297
1298   // some complex, platform-dependent stuff that could not be handled from table
1299   SetDefaultTextAttribs();
1300   SetFontDefaults();
1301   SetCommPortDefaults();
1302
1303   /* Parse default settings file if any */
1304   ParseSettingsFile(settingsFileName, &settingsFileName);
1305
1306   /* Parse command line */
1307   ParseArgs(StringGet, &lpCmdLine);
1308
1309   if(appData.viewer && appData.viewerOptions[0]) ParseArgsFromString(appData.viewerOptions);
1310   if(appData.tourney && appData.tourneyOptions[0]) ParseArgsFromString(appData.tourneyOptions);
1311   chessProgram |= GetEngineLine(firstEngineLine, 0) || GetEngineLine(secondEngineLine, 1);
1312   appData.icsActive |= GetEngineLine(icsNick, 10);
1313
1314   /* [HGM] make sure board size is acceptable */
1315   if(appData.NrFiles > BOARD_FILES ||
1316      appData.NrRanks > BOARD_RANKS   )
1317       DisplayFatalError("Recompile with BOARD_RANKS or BOARD_FILES, to support this size", 0, 2);
1318
1319   /* [HGM] After parsing the options from the .ini file, and overruling them
1320    * with options from the command line, we now make an even higher priority
1321    * overrule by WB options attached to the engine command line. This so that
1322    * tournament managers can use WB options (such as /timeOdds) that follow
1323    * the engines.
1324    */
1325   if(appData.firstChessProgram != NULL) {
1326       char *p = StrStr(appData.firstChessProgram, "WBopt");
1327       static char *f = "first";
1328       char buf[MSG_SIZ], *q = buf;
1329       int len;
1330
1331       if(p != NULL)
1332         { // engine command line contains WinBoard options
1333           len = snprintf(buf, MSG_SIZ, p+6, f, f, f, f, f, f, f, f, f, f); // replace %s in them by "first"
1334           if( (len >= MSG_SIZ) && appData.debugMode )
1335             fprintf(debugFP, "InitAppData: buffer truncated.\n");
1336
1337           ParseArgs(StringGet, &q);
1338           p[-1] = 0; // cut them offengine command line
1339         }
1340   }
1341   // now do same for second chess program
1342   if(appData.secondChessProgram != NULL) {
1343       char *p = StrStr(appData.secondChessProgram, "WBopt");
1344       static char *s = "second";
1345       char buf[MSG_SIZ], *q = buf;
1346       int len;
1347
1348       if(p != NULL)
1349         { // engine command line contains WinBoard options
1350           len = snprintf(buf,MSG_SIZ, p+6, s, s, s, s, s, s, s, s, s, s); // replace %s in them by "first"
1351           if( (len >= MSG_SIZ) && appData.debugMode )
1352             fprintf(debugFP, "InitAppData: buffer truncated.\n");
1353
1354           ParseArgs(StringGet, &q);
1355           p[-1] = 0; // cut them offengine command line
1356         }
1357   }
1358
1359   /* Propagate options that affect others */
1360   if (appData.matchMode || appData.matchGames) chessProgram = TRUE;
1361   if (appData.icsActive || appData.noChessProgram) {
1362      chessProgram = FALSE;  /* not local chess program mode */
1363   }
1364   if(appData.timeIncrement == -314159) { // new storage mechanism of (mps,inc) in use and no -inc on command line
1365     if(appData.movesPerSession <= 0) { // new encoding of incremental mode
1366       appData.timeIncrement = -appData.movesPerSession/1000.;
1367     } else appData.timeIncrement = -1;
1368   }
1369   if(appData.movesPerSession <= 0) appData.movesPerSession = MOVES_PER_SESSION; // mps <= 0 is invalid in any case
1370
1371   /* Open startup dialog if needed */
1372   if ((!appData.noChessProgram && !chessProgram && !appData.icsActive) ||
1373       (appData.icsActive && *appData.icsHost == NULLCHAR) ||
1374       (chessProgram && (*appData.firstChessProgram == NULLCHAR ||
1375                         *appData.secondChessProgram == NULLCHAR)))
1376                 PopUpStartupDialog();
1377
1378   /* Make sure save files land in the right (?) directory */
1379   if (MyGetFullPathName(appData.saveGameFile, buf)) {
1380     appData.saveGameFile = strdup(buf);
1381   }
1382   if (MyGetFullPathName(appData.savePositionFile, buf)) {
1383     appData.savePositionFile = strdup(buf);
1384   }
1385
1386   /* Finish initialization for fonts and sounds */
1387   CreateFonts();
1388
1389   GetCurrentDirectory(MSG_SIZ, currDir);
1390   SetCurrentDirectory(installDir);
1391   LoadAllSounds();
1392   SetCurrentDirectory(currDir);
1393
1394   p = icsTextMenuString;
1395   if (p[0] == '@') {
1396     FILE* f = fopen(p + 1, "r");
1397     if (f == NULL) {
1398       DisplayFatalError(p + 1, errno, 2);
1399       return;
1400     }
1401     i = fread(buf, 1, sizeof(buf)-1, f);
1402     fclose(f);
1403     buf[i] = NULLCHAR;
1404     p = buf;
1405   }
1406   ParseIcsTextMenu(strdup(p));
1407 }
1408
1409 void
1410 SaveSettings(char* name)
1411 {
1412   FILE *f;
1413   ArgDescriptor *ad;
1414   char dir[MSG_SIZ], buf[MSG_SIZ];
1415   int mps = appData.movesPerSession;
1416
1417   if (!MainWindowUp()) return;
1418
1419   GetCurrentDirectory(MSG_SIZ, dir);
1420   if(MySearchPath(installDir, name, buf)) {
1421     f = fopen(buf, "w");
1422   } else {
1423     SetCurrentDirectory(installDir);
1424     f = fopen(name, "w");
1425     SetCurrentDirectory(dir);
1426   }
1427   if (f == NULL) {
1428     DisplayError(name, errno);
1429     return;
1430   }
1431
1432   fprintf(f, ";\n");
1433   fprintf(f, "; %s Save Settings file\n", PACKAGE_STRING);
1434   fprintf(f, ";\n");
1435   fprintf(f, "; You can edit the values of options that are already set in this file,\n");
1436   fprintf(f, "; but if you add other options, the next Save Settings will not save them.\n");
1437   fprintf(f, "; Use a shortcut, an @indirection file, or a .bat file instead.\n");
1438   fprintf(f, ";\n");
1439
1440   GetWindowCoords();
1441
1442   /* [AS] Move history */
1443   wpMoveHistory.visible = MoveHistoryIsUp();
1444
1445   /* [AS] Eval graph */
1446   wpEvalGraph.visible = EvalGraphIsUp();
1447
1448   /* [AS] Engine output */
1449   wpEngineOutput.visible = EngineOutputIsUp();
1450
1451   // [HGM] in WB we have to copy sound names to appData first
1452   ExportSounds();
1453
1454   if(appData.timeIncrement >= 0) appData.movesPerSession = -1000*appData.timeIncrement; // kludge to store mps & inc as one
1455
1456   for (ad = argDescriptors; ad->argName != NULL; ad++) {
1457     if (!ad->save) continue;
1458     switch (ad->argType) {
1459     case ArgString:
1460       {
1461         char *p = *(char **)ad->argLoc;
1462         if(p == NULL) break; // just in case
1463         if ((strchr(p, '\\') || strchr(p, '\n')) && !strchr(p, '}')) {
1464           /* Quote multiline values or \-containing values
1465              with { } if possible */
1466           fprintf(f, OPTCHAR "%s" SEPCHAR "{%s}\n", ad->argName, p);
1467         } else {
1468           /* Else quote with " " */
1469           fprintf(f, OPTCHAR "%s" SEPCHAR "\"", ad->argName);
1470           while (*p) {
1471             if (*p == '\n') fprintf(f, "\n");
1472             else if (*p == '\r') fprintf(f, "\\r");
1473             else if (*p == '\t') fprintf(f, "\\t");
1474             else if (*p == '\b') fprintf(f, "\\b");
1475             else if (*p == '\f') fprintf(f, "\\f");
1476             else if (*p < ' ') fprintf(f, "\\%03o", *p);
1477             else if (*p == '\"') fprintf(f, "\\\"");
1478             else if (*p == '\\') fprintf(f, "\\\\");
1479             else putc(*p, f);
1480             p++;
1481           }
1482           fprintf(f, "\"\n");
1483         }
1484       }
1485       break;
1486     case ArgInt:
1487     case ArgZ:
1488       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc);
1489       break;
1490     case ArgX:
1491       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.x); // [HGM] placement: store relative value
1492       break;
1493     case ArgY:
1494       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.y);
1495       break;
1496     case ArgFloat:
1497       fprintf(f, OPTCHAR "%s" SEPCHAR "%g\n", ad->argName, *(float *)ad->argLoc);
1498       break;
1499     case ArgBoolean:
1500       fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName,
1501         (*(Boolean *)ad->argLoc) ? "true" : "false");
1502       break;
1503     case ArgTrue:
1504       if (*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName);
1505       break;
1506     case ArgFalse:
1507       if (!*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName);
1508       break;
1509     case ArgColor:
1510       SaveColor(f, ad);
1511       break;
1512     case ArgAttribs:
1513       SaveAttribsArg(f, ad);
1514       break;
1515     case ArgFilename:
1516       if(*(char**)ad->argLoc == NULL) break; // just in case
1517       if (strchr(*(char **)ad->argLoc, '\"')) {
1518         fprintf(f, OPTCHAR "%s" SEPCHAR "'%s'\n", ad->argName, *(char **)ad->argLoc);
1519       } else {
1520         fprintf(f, OPTCHAR "%s" SEPCHAR "\"%s\"\n", ad->argName, *(char **)ad->argLoc);
1521       }
1522       break;
1523     case ArgBoardSize:
1524       SaveBoardSize(f, ad->argName, ad->argLoc);
1525       break;
1526     case ArgFont:
1527       SaveFontArg(f, ad);
1528       break;
1529     case ArgCommSettings:
1530       PrintCommPortSettings(f, ad->argName);
1531     case ArgTwo:
1532     case ArgNone:
1533     case ArgSettingsFilename: ;
1534     }
1535   }
1536   fclose(f);
1537   appData.movesPerSession = mps;
1538 }
1539
1540 Boolean
1541 GetArgValue(char *name)
1542 { // retrieve (as text) current value of string or int argument given by name
1543   // (this is used for maing the values available in the adapter command)
1544   ArgDescriptor *ad;
1545   int len;
1546
1547   for (ad = argDescriptors; ad->argName != NULL; ad++)
1548     if (strcmp(ad->argName, name) == 0) break;
1549
1550   if (ad->argName == NULL) return FALSE;
1551
1552   switch(ad->argType) {
1553     case ArgString:
1554     case ArgFilename:
1555       strncpy(name, *(char**) ad->argLoc, MSG_SIZ);
1556
1557       return TRUE;
1558     case ArgInt:
1559       len = snprintf(name, MSG_SIZ, "%d", *(int*) ad->argLoc);
1560       if( (len >= MSG_SIZ) && appData.debugMode )
1561         fprintf(debugFP, "GetArgValue: buffer truncated.\n");
1562
1563       return TRUE;
1564     case ArgBoolean:
1565       len = snprintf(name, MSG_SIZ, "%s", *(Boolean*) ad->argLoc ? "true" : "false");
1566       if( (len >= MSG_SIZ) && appData.debugMode )
1567         fprintf(debugFP, "GetArgValue: buffer truncated.\n");
1568
1569       return TRUE;
1570     default: ;
1571   }
1572
1573   return FALSE;
1574 }