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