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