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