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