Move dataDir definition to args.h so WB can also use it
[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, manDir[MSG_SIZ] = MANDIR;
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
716 #if ZIPPY
717   { "zippyTalk", ArgBoolean, (void *) &appData.zippyTalk, FALSE, (ArgIniType) ZIPPY_TALK },
718   { "zt", ArgTrue, (void *) &appData.zippyTalk, FALSE, INVALID },
719   { "xzt", ArgFalse, (void *) &appData.zippyTalk, FALSE, INVALID },
720   { "-zt", ArgFalse, (void *) &appData.zippyTalk, FALSE, INVALID },
721   { "zippyPlay", ArgBoolean, (void *) &appData.zippyPlay, FALSE, (ArgIniType) ZIPPY_PLAY },
722   { "zp", ArgTrue, (void *) &appData.zippyPlay, FALSE, INVALID },
723   { "xzp", ArgFalse, (void *) &appData.zippyPlay, FALSE, INVALID },
724   { "-zp", ArgFalse, (void *) &appData.zippyPlay, FALSE, INVALID },
725   { "zippyLines", ArgFilename, (void *) &appData.zippyLines, FALSE, (ArgIniType) ZIPPY_LINES },
726   { "zippyPinhead", ArgString, (void *) &appData.zippyPinhead, FALSE, (ArgIniType) ZIPPY_PINHEAD },
727   { "zippyPassword", ArgString, (void *) &appData.zippyPassword, FALSE, (ArgIniType) ZIPPY_PASSWORD },
728   { "zippyPassword2", ArgString, (void *) &appData.zippyPassword2, FALSE, (ArgIniType) ZIPPY_PASSWORD2 },
729   { "zippyWrongPassword", ArgString, (void *) &appData.zippyWrongPassword,
730     FALSE, (ArgIniType) ZIPPY_WRONG_PASSWORD },
731   { "zippyAcceptOnly", ArgString, (void *) &appData.zippyAcceptOnly, FALSE, (ArgIniType) ZIPPY_ACCEPT_ONLY },
732   { "zippyUseI", ArgBoolean, (void *) &appData.zippyUseI, FALSE, (ArgIniType) ZIPPY_USE_I },
733   { "zui", ArgTrue, (void *) &appData.zippyUseI, FALSE, INVALID },
734   { "xzui", ArgFalse, (void *) &appData.zippyUseI, FALSE, INVALID },
735   { "-zui", ArgFalse, (void *) &appData.zippyUseI, FALSE, INVALID },
736   { "zippyBughouse", ArgInt, (void *) &appData.zippyBughouse, FALSE, (ArgIniType) ZIPPY_BUGHOUSE },
737   { "zippyNoplayCrafty", ArgBoolean, (void *) &appData.zippyNoplayCrafty,
738     FALSE, (ArgIniType) ZIPPY_NOPLAY_CRAFTY },
739   { "znc", ArgTrue, (void *) &appData.zippyNoplayCrafty, FALSE, INVALID },
740   { "xznc", ArgFalse, (void *) &appData.zippyNoplayCrafty, FALSE, INVALID },
741   { "-znc", ArgFalse, (void *) &appData.zippyNoplayCrafty, FALSE, INVALID },
742   { "zippyGameEnd", ArgString, (void *) &appData.zippyGameEnd, FALSE, (ArgIniType) ZIPPY_GAME_END },
743   { "zippyGameStart", ArgString, (void *) &appData.zippyGameStart, FALSE, (ArgIniType) ZIPPY_GAME_START },
744   { "zippyAdjourn", ArgBoolean, (void *) &appData.zippyAdjourn, FALSE, (ArgIniType) ZIPPY_ADJOURN },
745   { "zadj", ArgTrue, (void *) &appData.zippyAdjourn, FALSE, INVALID },
746   { "xzadj", ArgFalse, (void *) &appData.zippyAdjourn, FALSE, INVALID },
747   { "-zadj", ArgFalse, (void *) &appData.zippyAdjourn, FALSE, INVALID },
748   { "zippyAbort", ArgBoolean, (void *) &appData.zippyAbort, FALSE, (ArgIniType) ZIPPY_ABORT },
749   { "zab", ArgTrue, (void *) &appData.zippyAbort, FALSE, INVALID },
750   { "xzab", ArgFalse, (void *) &appData.zippyAbort, FALSE, INVALID },
751   { "-zab", ArgFalse, (void *) &appData.zippyAbort, FALSE, INVALID },
752   { "zippyVariants", ArgString, (void *) &appData.zippyVariants, FALSE, (ArgIniType) ZIPPY_VARIANTS },
753   { "zippyMaxGames", ArgInt, (void *)&appData.zippyMaxGames, FALSE, (ArgIniType) ZIPPY_MAX_GAMES},
754   { "zippyReplayTimeout", ArgInt, (void *)&appData.zippyReplayTimeout, FALSE, (ArgIniType) ZIPPY_REPLAY_TIMEOUT },
755   { "zippyShortGame", ArgInt, (void *)&appData.zippyShortGame, FALSE, INVALID },
756   /* Kludge to allow winboard.ini files from buggy 4.0.4 to be read: */
757   { "zippyReplyTimeout", ArgInt, (void *)&junk, FALSE, INVALID },
758 #endif
759   /* [HGM] options for broadcasting and time odds */
760   { "chatBoxes", ArgString, (void *) &appData.chatBoxes, !XBOARD, (ArgIniType) NULL },
761   { "serverMoves", ArgString, (void *) &appData.serverMovesName, FALSE, (ArgIniType) NULL },
762   { "serverFile", ArgString, (void *) &appData.serverFileName, FALSE, (ArgIniType) NULL },
763   { "suppressLoadMoves", ArgBoolean, (void *) &appData.suppressLoadMoves, FALSE, (ArgIniType) FALSE },
764   { "serverPause", ArgInt, (void *) &appData.serverPause, FALSE, (ArgIniType) 15 },
765   { "firstTimeOdds", ArgInt, (void *) &appData.firstTimeOdds, FALSE, (ArgIniType) 1 },
766   { "secondTimeOdds", ArgInt, (void *) &appData.secondTimeOdds, FALSE, (ArgIniType) 1 },
767   { "timeOddsMode", ArgInt, (void *) &appData.timeOddsMode, TRUE, INVALID },
768   { "firstAccumulateTC", ArgInt, (void *) &appData.firstAccumulateTC, FALSE, (ArgIniType) 1 },
769   { "secondAccumulateTC", ArgInt, (void *) &appData.secondAccumulateTC, FALSE, (ArgIniType) 1 },
770   { "firstNPS", ArgInt, (void *) &appData.firstNPS, FALSE, (ArgIniType) -1 },
771   { "secondNPS", ArgInt, (void *) &appData.secondNPS, FALSE, (ArgIniType) -1 },
772   { "noGUI", ArgTrue, (void *) &appData.noGUI, FALSE, INVALID },
773   { "keepLineBreaksICS", ArgBoolean, (void *) &appData.noJoin, TRUE, INVALID },
774   { "wrapContinuationSequence", ArgString, (void *) &appData.wrapContSeq, FALSE, INVALID },
775   { "useInternalWrap", ArgTrue, (void *) &appData.useInternalWrap, FALSE, INVALID }, /* noJoin usurps this if set */
776   { "openCommand", ArgString, (void *) &appData.sysOpen, FALSE, "xdg-open" },
777
778   // [HGM] placement: put all window layouts last in ini file, but man X,Y before all others
779   { "minX", ArgZ, (void *) &minX, FALSE, INVALID }, // [HGM] placement: to make sure auxiliary windows can be placed
780   { "minY", ArgZ, (void *) &minY, FALSE, INVALID },
781   { "winWidth",  ArgInt, (void *) &wpMain.width,  TRUE, INVALID }, // [HGM] placement: dummies to remember right & bottom
782   { "winHeight", ArgInt, (void *) &wpMain.height, TRUE, INVALID }, //       for attaching auxiliary windows to them
783   { "x", ArgInt, (void *) &wpMain.x, TRUE, (ArgIniType) CW_USEDEFAULT },
784   { "y", ArgInt, (void *) &wpMain.y, TRUE, (ArgIniType) CW_USEDEFAULT },
785   { "icsUp", ArgBoolean, (void *) &wpConsole.visible, XBOARD, (ArgIniType) FALSE },
786   { "icsX", ArgX,   (void *) &wpConsole.x, TRUE, (ArgIniType) CW_USEDEFAULT },
787   { "icsY", ArgY,   (void *) &wpConsole.y, TRUE, (ArgIniType) CW_USEDEFAULT },
788   { "icsW", ArgInt, (void *) &wpConsole.width, TRUE, (ArgIniType) CW_USEDEFAULT },
789   { "icsH", ArgInt, (void *) &wpConsole.height, TRUE, (ArgIniType) CW_USEDEFAULT },
790   { "commentX", ArgX,   (void *) &wpComment.x, TRUE, (ArgIniType) CW_USEDEFAULT },
791   { "commentY", ArgY,   (void *) &wpComment.y, TRUE, (ArgIniType) CW_USEDEFAULT },
792   { "commentW", ArgInt, (void *) &wpComment.width, TRUE, (ArgIniType) CW_USEDEFAULT },
793   { "commentH", ArgInt, (void *) &wpComment.height, TRUE, (ArgIniType) CW_USEDEFAULT },
794   { "tagsX", ArgX,   (void *) &wpTags.x, TRUE, (ArgIniType) CW_USEDEFAULT },
795   { "tagsY", ArgY,   (void *) &wpTags.y, TRUE, (ArgIniType) CW_USEDEFAULT },
796   { "tagsW", ArgInt, (void *) &wpTags.width, TRUE, (ArgIniType) CW_USEDEFAULT },
797   { "tagsH", ArgInt, (void *) &wpTags.height, TRUE, (ArgIniType) CW_USEDEFAULT },
798   { "gameListX", ArgX,   (void *) &wpGameList.x, TRUE, (ArgIniType) CW_USEDEFAULT },
799   { "gameListY", ArgY,   (void *) &wpGameList.y, TRUE, (ArgIniType) CW_USEDEFAULT },
800   { "gameListW", ArgInt, (void *) &wpGameList.width, TRUE, (ArgIniType) CW_USEDEFAULT },
801   { "gameListH", ArgInt, (void *) &wpGameList.height, TRUE, (ArgIniType) CW_USEDEFAULT },
802 #if XBOARD
803   { "slaveX", ArgX,   (void *) &wpDualBoard.x, TRUE, (ArgIniType) CW_USEDEFAULT },
804   { "slaveY", ArgY,   (void *) &wpDualBoard.y, TRUE, (ArgIniType) CW_USEDEFAULT },
805   { "slaveW", ArgInt, (void *) &wpDualBoard.width, FALSE, (ArgIniType) CW_USEDEFAULT },
806   { "slaveH", ArgInt, (void *) &wpDualBoard.height, FALSE, (ArgIniType) CW_USEDEFAULT },
807 #endif
808   /* [AS] Layout stuff */
809   { "moveHistoryUp", ArgBoolean, (void *) &wpMoveHistory.visible, TRUE, (ArgIniType) TRUE },
810   { "moveHistoryX", ArgX,   (void *) &wpMoveHistory.x, TRUE, (ArgIniType) CW_USEDEFAULT },
811   { "moveHistoryY", ArgY,   (void *) &wpMoveHistory.y, TRUE, (ArgIniType) CW_USEDEFAULT },
812   { "moveHistoryW", ArgInt, (void *) &wpMoveHistory.width, TRUE, (ArgIniType) CW_USEDEFAULT },
813   { "moveHistoryH", ArgInt, (void *) &wpMoveHistory.height, TRUE, (ArgIniType) CW_USEDEFAULT },
814
815   { "evalGraphUp", ArgBoolean, (void *) &wpEvalGraph.visible, TRUE, (ArgIniType) TRUE },
816   { "evalGraphX", ArgX,   (void *) &wpEvalGraph.x, TRUE, (ArgIniType) CW_USEDEFAULT },
817   { "evalGraphY", ArgY,   (void *) &wpEvalGraph.y, TRUE, (ArgIniType) CW_USEDEFAULT },
818   { "evalGraphW", ArgInt, (void *) &wpEvalGraph.width, TRUE, (ArgIniType) CW_USEDEFAULT },
819   { "evalGraphH", ArgInt, (void *) &wpEvalGraph.height, TRUE, (ArgIniType) CW_USEDEFAULT },
820
821   { "engineOutputUp", ArgBoolean, (void *) &wpEngineOutput.visible, TRUE, (ArgIniType) TRUE },
822   { "engineOutputX", ArgX,   (void *) &wpEngineOutput.x, TRUE, (ArgIniType) CW_USEDEFAULT },
823   { "engineOutputY", ArgY,   (void *) &wpEngineOutput.y, TRUE, (ArgIniType) CW_USEDEFAULT },
824   { "engineOutputW", ArgInt, (void *) &wpEngineOutput.width, TRUE, (ArgIniType) CW_USEDEFAULT },
825   { "engineOutputH", ArgInt, (void *) &wpEngineOutput.height, TRUE, (ArgIniType) CW_USEDEFAULT },
826
827   { NULL, ArgNone, NULL, FALSE, INVALID }
828 };
829
830
831 /* Kludge for indirection files on command line */
832 char* lastIndirectionFilename;
833 ArgDescriptor argDescriptorIndirection =
834 { "", ArgSettingsFilename, (void *) NULL, FALSE };
835
836 void
837 ExitArgError(char *msg, char *badArg, Boolean quit)
838 {
839   char buf[MSG_SIZ];
840   int len;
841
842   len = snprintf(buf, MSG_SIZ, msg, badArg);
843   if( (len >= MSG_SIZ) && appData.debugMode )
844     fprintf(debugFP, "ExitArgError: buffer truncated. Input: msg=%s badArg=%s\n", msg, badArg);
845
846   if(!quit) { printf(_("%s in settings file\n"), buf); return; } // DisplayError does not work yet at this stage...
847   DisplayFatalError(buf, 0, 2);
848   exit(2);
849 }
850
851 void
852 AppendToSettingsFile (char *line)
853 {
854   char buf[MSG_SIZ];
855   FILE *f;
856   int c;
857   if(f = fopen(SETTINGS_FILE, "r")) {
858     do {
859       int i = 0;
860       while((buf[i] = c = fgetc(f)) != '\n' && c != EOF) if(i < MSG_SIZ-1) i++;
861       buf[i] = NULLCHAR;
862       if(!strcmp(line, buf)) return; // line occurs
863     } while(c != EOF);
864     // line did not occur; add it
865     fclose(f);
866     if(f = fopen(SETTINGS_FILE, "a")) {
867       TimeMark now;
868       GetTimeMark(&now);
869       fprintf(f, "-date %10lu\n%s\n", now.sec, line);
870       fclose(f);
871     }
872   }
873 }
874
875 int
876 ValidateInt(char *s)
877 {
878   char *p = s;
879   if(*p == '-' || *p == '+') p++;
880   while(*p) if(!isdigit(*p++)) ExitArgError(_("Bad integer value %s"), s, TRUE);
881   return atoi(s);
882 }
883
884 char
885 StringGet(void *getClosure)
886 {
887   char **p = (char **) getClosure;
888   return *((*p)++);
889 }
890
891 char
892 FileGet(void *getClosure)
893 {
894   int c;
895   FILE* f = (FILE*) getClosure;
896
897   c = getc(f);
898   if (c == '\r') c = getc(f); // work around DOS format files by bypassing the '\r' completely
899   if (c == EOF)
900     return NULLCHAR;
901   else
902     return (char) c;
903 }
904
905 /* Parse settings file named "name". If file found, return the
906    full name in fullname and return TRUE; else return FALSE */
907 Boolean
908 ParseSettingsFile(char *name, char **addr)
909 {
910   FILE *f;
911   int ok,len;
912   char buf[MSG_SIZ], fullname[MSG_SIZ];
913
914
915   ok = MySearchPath(installDir, name, fullname);
916   if(!ok && strchr(name, '.') == NULL)
917     { // append default file-name extension '.ini' when needed
918       len = snprintf(buf,MSG_SIZ, "%s.ini", name);
919       if( (len >= MSG_SIZ) && appData.debugMode )
920         fprintf(debugFP, "ParseSettingsFile: buffer truncated. Input: name=%s \n",name);
921
922       ok = MySearchPath(installDir, buf, fullname);
923     }
924   if (ok) {
925     f = fopen(fullname, "r");
926 #ifdef DATADIR
927     if(f == NULL && *fullname != '/' && !addr) {         // when a relative name did not work
928         char buf[MSG_SIZ];
929         snprintf(buf, MSG_SIZ, "~/.xboard/themes/conf/%s", name);
930         MySearchPath(installDir, buf, fullname); // first look in user's own files
931         f = fopen(fullname, "r");
932         if(f == NULL) {
933             snprintf(buf, MSG_SIZ, "%s/themes/conf", dataDir);
934             MySearchPath(buf, name, fullname); // also look in standard place
935             f = fopen(fullname, "r");
936         }
937     }
938 #endif
939     if (f != NULL) {
940       if (addr != NULL) {
941             ASSIGN(*addr, fullname);
942       }
943       ParseArgs(FileGet, f);
944       fclose(f);
945       return TRUE;
946     }
947   }
948   return FALSE;
949 }
950
951 void
952 ParseArgs(GetFunc get, void *cl)
953 {
954   char argName[MAX_ARG_LEN];
955   char argValue[MAX_ARG_LEN];
956   ArgDescriptor *ad;
957   char start;
958   char *q;
959   int i, octval;
960   char ch;
961   int posarg = 4; // default is game file
962
963   ch = get(cl);
964   for (;;) {
965     int posflag = 0;
966     while (ch == ' ' || ch == '\n' || ch == '\t') ch = get(cl);
967     if (ch == NULLCHAR) break;
968     if (ch == ';') {
969       /* Comment to end of line */
970       ch = get(cl);
971       while (ch != '\n' && ch != NULLCHAR) ch = get(cl);
972       continue;
973     } else if (ch == SLASH || ch == '-') {
974       /* Switch */
975       q = argName;
976       while (ch != ' ' && ch != '=' && ch != ':' && ch != NULLCHAR &&
977              ch != '\n' && ch != '\t') {
978         *q++ = ch;
979         ch = get(cl);
980       }
981       *q = NULLCHAR;
982       for (ad = argDescriptors; ad->argName != NULL; ad++)
983         if (strcmp(ad->argName, argName + 1) == 0) break;
984       if (ad->argName == NULL) {
985         char endChar = (ch && ch != '\n' && (ch = get(cl)) == '{' ? '}' : '\n');
986         ExitArgError(_("Unrecognized argument %s"), argName, get != &FileGet); // [HGM] make unknown argument non-fatal
987         while (ch != endChar && ch != NULLCHAR) ch = get(cl); // but skip rest of line it is on (or until closing '}' )
988         if(ch == '}') ch = get(cl);
989         continue; // so that when it is in a settings file, it is the only setting that will be purged from it
990       }
991     } else if (ch == '@') {
992       /* Indirection file */
993       ad = &argDescriptorIndirection;
994       ch = get(cl);
995     } else {
996       /* Positional argument */
997       ad = &argDescriptors[posarg++];
998       posflag++;
999       strncpy(argName, ad->argName,sizeof(argName)/sizeof(argName[0]));
1000     }
1001
1002     if (ad->argType == ArgTwo) { // [HGM] kludgey arg type, not suitable for saving
1003       *(Boolean *) ad->argLoc = 2;
1004       continue;
1005     }
1006     if (ad->argType == ArgTrue) {
1007       *(Boolean *) ad->argLoc = TRUE;
1008       continue;
1009     }
1010     if (ad->argType == ArgFalse) {
1011       *(Boolean *) ad->argLoc = FALSE;
1012       continue;
1013     }
1014
1015     while (ch == ' ' || ch == '=' || ch == ':' || ch == '\t') ch = get(cl);
1016     if (ch == NULLCHAR || ch == '\n') {
1017       ExitArgError(_("No value provided for argument %s"), argName, TRUE);
1018     }
1019     q = argValue;
1020     if (ch == '{') {
1021       // Quoting with { }.  No characters have to (or can) be escaped.
1022       // Thus the string cannot contain a '}' character.
1023       start = ch;
1024       ch = get(cl);
1025       while (start) {
1026         switch (ch) {
1027         case NULLCHAR:
1028           start = NULLCHAR;
1029           break;
1030
1031         case '}':
1032           ch = get(cl);
1033           start = NULLCHAR;
1034           break;
1035
1036         default:
1037           *q++ = ch;
1038           ch = get(cl);
1039           break;
1040         }
1041       }
1042     } else if (ch == '\'' || ch == '"') {
1043       // Quoting with ' ' or " ", with \ as escape character.
1044       // Inconvenient for long strings that may contain Windows filenames.
1045       start = ch;
1046       ch = get(cl);
1047       while (start) {
1048         switch (ch) {
1049         case NULLCHAR:
1050           start = NULLCHAR;
1051           break;
1052
1053         default:
1054         not_special:
1055           *q++ = ch;
1056           ch = get(cl);
1057           break;
1058
1059         case '\'':
1060         case '\"':
1061           if (ch == start) {
1062             ch = get(cl);
1063             start = NULLCHAR;
1064             break;
1065           } else {
1066             goto not_special;
1067           }
1068
1069         case '\\':
1070           if (ad->argType == ArgFilename
1071               || ad->argType == ArgSettingsFilename) {
1072               goto not_special;
1073           }
1074           ch = get(cl);
1075           switch (ch) {
1076           case NULLCHAR:
1077             ExitArgError(_("Incomplete \\ escape in value for %s"), argName, TRUE);
1078             break;
1079           case 'n':
1080             *q++ = '\n';
1081             ch = get(cl);
1082             break;
1083           case 'r':
1084             *q++ = '\r';
1085             ch = get(cl);
1086             break;
1087           case 't':
1088             *q++ = '\t';
1089             ch = get(cl);
1090             break;
1091           case 'b':
1092             *q++ = '\b';
1093             ch = get(cl);
1094             break;
1095           case 'f':
1096             *q++ = '\f';
1097             ch = get(cl);
1098             break;
1099           default:
1100             octval = 0;
1101             for (i = 0; i < 3; i++) {
1102               if (ch >= '0' && ch <= '7') {
1103                 octval = octval*8 + (ch - '0');
1104                 ch = get(cl);
1105               } else {
1106                 break;
1107               }
1108             }
1109             if (i > 0) {
1110               *q++ = (char) octval;
1111             } else {
1112               *q++ = ch;
1113               ch = get(cl);
1114             }
1115             break;
1116           }
1117           break;
1118         }
1119       }
1120     } else {
1121       while ((ch != ' ' || posflag) && ch != NULLCHAR && ch != '\t' && ch != '\n') { // space allowed in positional arg
1122         *q++ = ch;
1123         ch = get(cl);
1124       }
1125     }
1126     *q = NULLCHAR;
1127
1128     if(posflag) { // positional argument: the argName was implied, and per default set as -lgf
1129       int len = strlen(argValue) - 4; // start of filename extension
1130       if(len < 0) len = 0;
1131       if(!StrCaseCmp(argValue + len, ".trn")) {
1132         ad = &argDescriptors[2]; // correct implied type to -tf
1133         appData.tourney = TRUE; // let it parse -tourneyOptions later
1134       } else if(!StrCaseCmp(argValue + len, ".fen") || !StrCaseCmp(argValue + len, ".epd")) {
1135         ad = &argDescriptors[1]; // correct implied type to -lpf
1136         appData.viewer = TRUE;
1137       } else if(!StrCaseCmp(argValue + len, ".ini") || !StrCaseCmp(argValue + len, ".xop")) {
1138         ad = &argDescriptors[0]; // correct implied type to -opt
1139       } else if(GetEngineLine(argValue, 11)) {
1140         ad = &argDescriptors[3]; // correct implied type to -is
1141       } else { // keep default -lgf, but let it imply viewer mode as well
1142         appData.viewer = TRUE;
1143       }
1144       strncpy(argName, ad->argName,sizeof(argName)/sizeof(argName[0]));
1145     }
1146
1147     switch (ad->argType) {
1148     case ArgInt:
1149       *(int *) ad->argLoc = ValidateInt(argValue);
1150       break;
1151
1152     case ArgX:
1153       *(int *) ad->argLoc = ValidateInt(argValue) + wpMain.x; // [HGM] placement: translate stored relative to absolute
1154       break;
1155
1156     case ArgY:
1157       *(int *) ad->argLoc = ValidateInt(argValue) + wpMain.y; // (this is really kludgey, it should be done where used...)
1158       break;
1159
1160     case ArgZ:
1161       *(int *) ad->argLoc = ValidateInt(argValue);
1162       EnsureOnScreen(&wpMain.x, &wpMain.y, minX, minY);
1163       break;
1164
1165     case ArgFloat:
1166       *(float *) ad->argLoc = (float) atof(argValue);
1167       break;
1168
1169     case ArgString:
1170     case ArgFilename:
1171       if(argValue[0] == '~' && argValue[1] == '~') {
1172         char buf[4*MSG_SIZ]; // expand ~~
1173         snprintf(buf, 4*MSG_SIZ, "%s%s", dataDir, argValue+2);
1174         ASSIGN(*(char **) ad->argLoc, buf);
1175         break;
1176       }
1177       ASSIGN(*(char **) ad->argLoc, argValue);
1178       break;
1179
1180     case ArgBackupSettingsFile: // no-op if non-default settings-file already successfully read
1181         if(strcmp(*(char**)ad->argLoc, SETTINGS_FILE)) break;
1182     case ArgSettingsFilename:
1183       {
1184         if (ParseSettingsFile(argValue, (char**)ad->argLoc)) {
1185         } else {
1186           if (ad->argLoc != NULL) {
1187           } else {
1188             ExitArgError(_("Failed to open indirection file %s"), argValue, TRUE);
1189           }
1190         }
1191       }
1192       break;
1193
1194     case ArgBoolean:
1195       switch (argValue[0]) {
1196       case 't':
1197       case 'T':
1198         *(Boolean *) ad->argLoc = TRUE;
1199         break;
1200       case 'f':
1201       case 'F':
1202         *(Boolean *) ad->argLoc = FALSE;
1203         break;
1204       default:
1205         ExitArgError(_("Unrecognized boolean argument value %s"), argValue, TRUE);
1206         break;
1207       }
1208       break;
1209
1210     case ArgColor:
1211       ParseColor((int)(intptr_t)ad->argLoc, argValue);
1212       break;
1213
1214     case ArgAttribs: {
1215       ColorClass cc = (ColorClass)ad->argLoc;
1216         ParseTextAttribs(cc, argValue); // [HGM] wrapper for platform independency
1217       }
1218       break;
1219
1220     case ArgBoardSize:
1221       ParseBoardSize(ad->argLoc, argValue);
1222       break;
1223
1224     case ArgFont:
1225       ParseFont(argValue, (int)(intptr_t)ad->argLoc);
1226       break;
1227
1228     case ArgCommSettings:
1229       ParseCommPortSettings(argValue);
1230       break;
1231
1232     case ArgMaster:
1233       AppendToSettingsFile(argValue);
1234       break;
1235
1236     case ArgInstall:
1237       q = *(char **) ad->argLoc;
1238       if((saveDate == 0 || saveDate - dateStamp < 0) && !strstr(q, argValue) ) {
1239         int l = strlen(q) + strlen(argValue);
1240         *(char **) ad->argLoc = malloc(l+2);
1241         snprintf(*(char **) ad->argLoc, l+2, "%s%s\n", q, argValue);
1242         free(q);
1243       }
1244       break;
1245
1246     case ArgNone:
1247       ExitArgError(_("Unrecognized argument %s"), argValue, TRUE);
1248       break;
1249     case ArgTwo:
1250     case ArgTrue:
1251     case ArgFalse: ;
1252     }
1253   }
1254 }
1255
1256 void
1257 ParseArgsFromString(char *p)
1258 {
1259     ParseArgs(StringGet, &p);
1260 }
1261
1262 void
1263 ParseArgsFromFile(FILE *f)
1264 {
1265     ParseArgs(FileGet, f);
1266 }
1267
1268 void
1269 ParseIcsTextMenu(char *icsTextMenuString)
1270 {
1271 //  int flags = 0;
1272   IcsTextMenuEntry *e = icsTextMenuEntry;
1273   char *p = icsTextMenuString;
1274   while (e->item != NULL && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) {
1275     free(e->item);
1276     e->item = NULL;
1277     if (e->command != NULL) {
1278       free(e->command);
1279       e->command = NULL;
1280     }
1281     e++;
1282   }
1283   e = icsTextMenuEntry;
1284   while (*p && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) {
1285     if (*p == ';' || *p == '\n') {
1286       e->item = strdup("-");
1287       e->command = NULL;
1288       p++;
1289     } else if (*p == '-') {
1290       e->item = strdup("-");
1291       e->command = NULL;
1292       p++;
1293       if (*p) p++;
1294     } else {
1295       char *q, *r, *s, *t;
1296       char c;
1297       q = strchr(p, ',');
1298       if (q == NULL) break;
1299       *q = NULLCHAR;
1300       r = strchr(q + 1, ',');
1301       if (r == NULL) break;
1302       *r = NULLCHAR;
1303       s = strchr(r + 1, ',');
1304       if (s == NULL) break;
1305       *s = NULLCHAR;
1306       c = ';';
1307       t = strchr(s + 1, c);
1308       if (t == NULL) {
1309         c = '\n';
1310         t = strchr(s + 1, c);
1311       }
1312       if (t != NULL) *t = NULLCHAR;
1313       e->item = strdup(p);
1314       e->command = strdup(q + 1);
1315       e->getname = *(r + 1) != '0';
1316       e->immediate = *(s + 1) != '0';
1317       *q = ',';
1318       *r = ',';
1319       *s = ',';
1320       if (t == NULL) break;
1321       *t = c;
1322       p = t + 1;
1323     }
1324     e++;
1325   }
1326 }
1327
1328 void
1329 SetDefaultTextAttribs()
1330 {
1331   ColorClass cc;
1332   for (cc = (ColorClass)0; cc < ColorNone; cc++) {
1333     ParseTextAttribs(cc, defaultTextAttribs[cc]);
1334   }
1335 }
1336
1337 void
1338 SetDefaultsFromList()
1339 { // [HGM] ini: take defaults from argDescriptor list
1340   int i;
1341
1342   for(i=0; argDescriptors[i].argName != NULL; i++) {
1343     if(argDescriptors[i].defaultValue != INVALID)
1344       switch(argDescriptors[i].argType) {
1345         case ArgBoolean:
1346         case ArgTwo:
1347         case ArgTrue:
1348         case ArgFalse:
1349           *(Boolean *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1350           break;
1351         case ArgInt:
1352         case ArgX:
1353         case ArgY:
1354         case ArgZ:
1355           *(int *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1356           break;
1357         case ArgString:
1358         case ArgFilename:
1359         case ArgSettingsFilename:
1360           if((char *)argDescriptors[i].defaultValue)
1361           *(char **) argDescriptors[i].argLoc = strdup((char *)argDescriptors[i].defaultValue);
1362           break;
1363         case ArgBoardSize:
1364           *(int *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1365           break;
1366         case ArgColor:
1367           ParseColor((int)(intptr_t)argDescriptors[i].argLoc, (char*)argDescriptors[i].defaultValue);
1368           break;
1369         case ArgFloat: // floats cannot be casted to int without precision loss
1370         default: ; // some arg types cannot be initialized through table
1371     }
1372   }
1373 }
1374
1375 void
1376 InitAppData(char *lpCmdLine)
1377 {
1378   int i;
1379   char buf[MAX_ARG_LEN], currDir[MSG_SIZ];
1380   char *p;
1381
1382   /* Initialize to defaults */
1383   SetDefaultsFromList(); // this sets most defaults
1384
1385   // some parameters for which there are no options!
1386   appData.Iconic = FALSE; /*unused*/
1387   appData.icsEngineAnalyze = FALSE;
1388
1389   // float: casting to int is not harmless, so default cannot be contained in table
1390   appData.timeDelay = TIME_DELAY;
1391   appData.timeIncrement = -314159;
1392
1393   // some complex, platform-dependent stuff that could not be handled from table
1394   SetDefaultTextAttribs();
1395   SetFontDefaults();
1396   SetCommPortDefaults();
1397
1398   /* Parse default settings file if any */
1399   ParseSettingsFile(settingsFileName, &settingsFileName);
1400
1401   /* Parse command line */
1402   ParseArgs(StringGet, &lpCmdLine);
1403
1404   if(appData.viewer && appData.viewerOptions[0]) ParseArgsFromString(appData.viewerOptions);
1405   if(appData.tourney && appData.tourneyOptions[0]) ParseArgsFromString(appData.tourneyOptions);
1406   chessProgram |= GetEngineLine(firstEngineLine, 0) || GetEngineLine(secondEngineLine, 1);
1407   appData.icsActive |= GetEngineLine(icsNick, 10);
1408
1409   /* [HGM] make sure board size is acceptable */
1410   if(appData.NrFiles > BOARD_FILES ||
1411      appData.NrRanks > BOARD_RANKS   )
1412       DisplayFatalError("Recompile with BOARD_RANKS or BOARD_FILES, to support this size", 0, 2);
1413
1414   if(!*appData.secondChessProgram) { ASSIGN(appData.secondChessProgram, appData.firstChessProgram); } // [HGM] scp defaults to fcp
1415
1416   /* [HGM] After parsing the options from the .ini file, and overruling them
1417    * with options from the command line, we now make an even higher priority
1418    * overrule by WB options attached to the engine command line. This so that
1419    * tournament managers can use WB options (such as /timeOdds) that follow
1420    * the engines.
1421    */
1422   if(appData.firstChessProgram != NULL) {
1423       char *p = StrStr(appData.firstChessProgram, "WBopt");
1424       static char *f = "first";
1425       char buf[MSG_SIZ], *q = buf;
1426       int len;
1427
1428       if(p != NULL)
1429         { // engine command line contains WinBoard options
1430           len = snprintf(buf, MSG_SIZ, p+6, f, f, f, f, f, f, f, f, f, f); // replace %s in them by "first"
1431           if( (len >= MSG_SIZ) && appData.debugMode )
1432             fprintf(debugFP, "InitAppData: buffer truncated.\n");
1433
1434           ParseArgs(StringGet, &q);
1435           p[-1] = 0; // cut them offengine command line
1436         }
1437   }
1438   // now do same for second chess program
1439   if(appData.secondChessProgram != NULL) {
1440       char *p = StrStr(appData.secondChessProgram, "WBopt");
1441       static char *s = "second";
1442       char buf[MSG_SIZ], *q = buf;
1443       int len;
1444
1445       if(p != NULL)
1446         { // engine command line contains WinBoard options
1447           len = snprintf(buf,MSG_SIZ, p+6, s, s, s, s, s, s, s, s, s, s); // replace %s in them by "first"
1448           if( (len >= MSG_SIZ) && appData.debugMode )
1449             fprintf(debugFP, "InitAppData: buffer truncated.\n");
1450
1451           ParseArgs(StringGet, &q);
1452           p[-1] = 0; // cut them offengine command line
1453         }
1454   }
1455
1456   /* Propagate options that affect others */
1457   if (appData.matchMode || appData.matchGames) chessProgram = TRUE;
1458   if (appData.icsActive || appData.noChessProgram) {
1459      chessProgram = FALSE;  /* not local chess program mode */
1460   }
1461   if(appData.timeIncrement == -314159) { // new storage mechanism of (mps,inc) in use and no -inc on command line
1462     if(appData.movesPerSession <= 0) { // new encoding of incremental mode
1463       appData.timeIncrement = -appData.movesPerSession/1000.;
1464     } else appData.timeIncrement = -1;
1465   }
1466   if(appData.movesPerSession <= 0) appData.movesPerSession = MOVES_PER_SESSION; // mps <= 0 is invalid in any case
1467   if(*appData.defaultPathEGTB) { // append value of deprecated -defaultPathEGTB to -egtFormats
1468     snprintf(buf, MAX_ARG_LEN, "%s%snalimov:%s", appData.egtFormats, (*appData.egtFormats ?"," : ""), appData.defaultPathEGTB);
1469     ASSIGN(appData.egtFormats, buf);
1470     ASSIGN(appData.defaultPathEGTB, "");
1471   }
1472
1473   /* Open startup dialog if needed */
1474   if ((!appData.noChessProgram && !chessProgram && !appData.icsActive) ||
1475       (appData.icsActive && *appData.icsHost == NULLCHAR) ||
1476       (chessProgram && (*appData.firstChessProgram == NULLCHAR ||
1477                         *appData.secondChessProgram == NULLCHAR)))
1478                 PopUpStartupDialog();
1479
1480   /* Make sure save files land in the right (?) directory */
1481   if (MyGetFullPathName(appData.saveGameFile, buf)) {
1482     appData.saveGameFile = strdup(buf);
1483   }
1484   if (MyGetFullPathName(appData.savePositionFile, buf)) {
1485     appData.savePositionFile = strdup(buf);
1486   }
1487
1488   if(autoClose) { // was called for updating settingsfile only
1489     if(saveSettingsOnExit) SaveSettings(settingsFileName);
1490     exit(0);
1491   }
1492
1493   /* Finish initialization for fonts and sounds */
1494   CreateFonts();
1495
1496   GetCurrentDirectory(MSG_SIZ, currDir);
1497   SetCurrentDirectory(installDir);
1498   LoadAllSounds();
1499   SetCurrentDirectory(currDir);
1500
1501   p = icsTextMenuString;
1502   if (p[0] == '@') {
1503     FILE* f = fopen(p + 1, "r");
1504     if (f == NULL) {
1505       DisplayFatalError(p + 1, errno, 2);
1506       return;
1507     }
1508     i = fread(buf, 1, sizeof(buf)-1, f);
1509     fclose(f);
1510     buf[i] = NULLCHAR;
1511     p = buf;
1512   }
1513   ParseIcsTextMenu(strdup(p));
1514 }
1515
1516 void
1517 SaveSettings(char* name)
1518 {
1519   FILE *f;
1520   ArgDescriptor *ad;
1521   char dir[MSG_SIZ], buf[MSG_SIZ];
1522   int mps = appData.movesPerSession;
1523   TimeMark now;
1524
1525   if (!MainWindowUp() && !autoClose) return;
1526
1527   GetTimeMark(&now); saveDate = now.sec;
1528
1529   GetCurrentDirectory(MSG_SIZ, dir);
1530   if(MySearchPath(installDir, name, buf)) {
1531     f = fopen(buf, "w");
1532   } else {
1533     SetCurrentDirectory(installDir);
1534     f = fopen(name, "w");
1535     SetCurrentDirectory(dir);
1536   }
1537   if (f == NULL) {
1538     DisplayError(name, errno);
1539     return;
1540   }
1541
1542   fprintf(f, ";\n");
1543   fprintf(f, "; %s Save Settings file\n", PACKAGE_STRING);
1544   fprintf(f, ";\n");
1545   fprintf(f, "; You can edit the values of options that are already set in this file,\n");
1546   fprintf(f, "; but if you add other options, the next Save Settings will not save them.\n");
1547   fprintf(f, "; Use a shortcut, an @indirection file, or a .bat file instead.\n");
1548   fprintf(f, ";\n");
1549
1550   GetWindowCoords();
1551
1552   /* [AS] Move history */
1553   wpMoveHistory.visible = MoveHistoryIsUp();
1554
1555   /* [AS] Eval graph */
1556   wpEvalGraph.visible = EvalGraphIsUp();
1557
1558   /* [AS] Engine output */
1559   wpEngineOutput.visible = EngineOutputIsUp();
1560
1561   // [HGM] in WB we have to copy sound names to appData first
1562   ExportSounds();
1563
1564   if(appData.timeIncrement >= 0) appData.movesPerSession = -1000*appData.timeIncrement; // kludge to store mps & inc as one
1565
1566   for (ad = argDescriptors; ad->argName != NULL; ad++) {
1567     if (!ad->save) continue;
1568     switch (ad->argType) {
1569     case ArgString:
1570       {
1571         char *p = *(char **)ad->argLoc;
1572         if(p == NULL) break; // just in case
1573         if ((strchr(p, '\\') || strchr(p, '\n')) && !strchr(p, '}')) {
1574           /* Quote multiline values or \-containing values
1575              with { } if possible */
1576           fprintf(f, OPTCHAR "%s" SEPCHAR "{%s}\n", ad->argName, p);
1577         } else {
1578           /* Else quote with " " */
1579           fprintf(f, OPTCHAR "%s" SEPCHAR "\"", ad->argName);
1580           while (*p) {
1581             if (*p == '\n') fprintf(f, "\n");
1582             else if (*p == '\r') fprintf(f, "\\r");
1583             else if (*p == '\t') fprintf(f, "\\t");
1584             else if (*p == '\b') fprintf(f, "\\b");
1585             else if (*p == '\f') fprintf(f, "\\f");
1586             else if (*p < ' ') fprintf(f, "\\%03o", *p);
1587             else if (*p == '\"') fprintf(f, "\\\"");
1588             else if (*p == '\\') fprintf(f, "\\\\");
1589             else putc(*p, f);
1590             p++;
1591           }
1592           fprintf(f, "\"\n");
1593         }
1594       }
1595       break;
1596     case ArgInt:
1597     case ArgZ:
1598       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc);
1599       break;
1600     case ArgX:
1601       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.x); // [HGM] placement: store relative value
1602       break;
1603     case ArgY:
1604       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.y);
1605       break;
1606     case ArgFloat:
1607       fprintf(f, OPTCHAR "%s" SEPCHAR "%g\n", ad->argName, *(float *)ad->argLoc);
1608       break;
1609     case ArgBoolean:
1610       fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName,
1611         (*(Boolean *)ad->argLoc) ? "true" : "false");
1612       break;
1613     case ArgTrue:
1614       if (*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName);
1615       break;
1616     case ArgFalse:
1617       if (!*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName);
1618       break;
1619     case ArgColor:
1620       SaveColor(f, ad);
1621       break;
1622     case ArgAttribs:
1623       SaveAttribsArg(f, ad);
1624       break;
1625     case ArgFilename:
1626       if(*(char**)ad->argLoc == NULL) break; // just in case
1627       { char buf[MSG_SIZ];
1628         snprintf(buf, MSG_SIZ, "%s", *(char**)ad->argLoc);
1629 #ifdef OSXAPP
1630         if(strstr(buf, dataDir) == buf)
1631           snprintf(buf, MSG_SIZ, "~~%s", *(char**)ad->argLoc + strlen(dataDir));
1632 #endif
1633         if (strchr(buf, '\"')) {
1634           fprintf(f, OPTCHAR "%s" SEPCHAR "'%s'\n", ad->argName, buf);
1635         } else {
1636           fprintf(f, OPTCHAR "%s" SEPCHAR "\"%s\"\n", ad->argName, buf);
1637         }
1638       }
1639       break;
1640     case ArgBoardSize:
1641       SaveBoardSize(f, ad->argName, ad->argLoc);
1642       break;
1643     case ArgFont:
1644       SaveFontArg(f, ad);
1645       break;
1646     case ArgCommSettings:
1647       PrintCommPortSettings(f, ad->argName);
1648     case ArgTwo:
1649     case ArgNone:
1650     case ArgBackupSettingsFile:
1651     case ArgSettingsFilename: ;
1652     case ArgMaster: ;
1653     case ArgInstall: ;
1654     }
1655   }
1656   fclose(f);
1657   appData.movesPerSession = mps;
1658 }
1659
1660 Boolean
1661 GetArgValue(char *name)
1662 { // retrieve (as text) current value of string or int argument given by name
1663   // (this is used for maing the values available in the adapter command)
1664   ArgDescriptor *ad;
1665   int len;
1666
1667   for (ad = argDescriptors; ad->argName != NULL; ad++)
1668     if (strcmp(ad->argName, name) == 0) break;
1669
1670   if (ad->argName == NULL) return FALSE;
1671
1672   switch(ad->argType) {
1673     case ArgString:
1674     case ArgFilename:
1675       strncpy(name, *(char**) ad->argLoc, MSG_SIZ);
1676
1677       return TRUE;
1678     case ArgInt:
1679       len = snprintf(name, MSG_SIZ, "%d", *(int*) ad->argLoc);
1680       if( (len >= MSG_SIZ) && appData.debugMode )
1681         fprintf(debugFP, "GetArgValue: buffer truncated.\n");
1682
1683       return TRUE;
1684     case ArgBoolean:
1685       len = snprintf(name, MSG_SIZ, "%s", *(Boolean*) ad->argLoc ? "true" : "false");
1686       if( (len >= MSG_SIZ) && appData.debugMode )
1687         fprintf(debugFP, "GetArgValue: buffer truncated.\n");
1688
1689       return TRUE;
1690     default: ;
1691   }
1692
1693   return FALSE;
1694 }