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