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