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