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