Implement --help option
[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   { "secondUCI", ArgTrue, (void *) &appData.secondIsUCI, FALSE, INVALID },
546   { "sUCI", ArgTrue, (void *) &appData.secondIsUCI, FALSE, INVALID },
547   { "fUCCI", ArgTwo, (void *) &appData.firstIsUCI, FALSE, INVALID },
548   { "sUCCI", ArgTwo, (void *) &appData.secondIsUCI, FALSE, INVALID },
549   { "fUSI", ArgTwo, (void *) &appData.firstIsUCI, FALSE, INVALID },
550   { "sUSI", ArgTwo, (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   { "commentX", ArgX,   (void *) &wpComment.x, TRUE, (ArgIniType) CW_USEDEFAULT },
737   { "commentY", ArgY,   (void *) &wpComment.y, TRUE, (ArgIniType) CW_USEDEFAULT },
738   { "commentW", ArgInt, (void *) &wpComment.width, TRUE, (ArgIniType) CW_USEDEFAULT },
739   { "commentH", ArgInt, (void *) &wpComment.height, TRUE, (ArgIniType) CW_USEDEFAULT },
740   { "tagsX", ArgX,   (void *) &wpTags.x, TRUE, (ArgIniType) CW_USEDEFAULT },
741   { "tagsY", ArgY,   (void *) &wpTags.y, TRUE, (ArgIniType) CW_USEDEFAULT },
742   { "tagsW", ArgInt, (void *) &wpTags.width, TRUE, (ArgIniType) CW_USEDEFAULT },
743   { "tagsH", ArgInt, (void *) &wpTags.height, TRUE, (ArgIniType) CW_USEDEFAULT },
744   { "gameListX", ArgX,   (void *) &wpGameList.x, TRUE, (ArgIniType) CW_USEDEFAULT },
745   { "gameListY", ArgY,   (void *) &wpGameList.y, TRUE, (ArgIniType) CW_USEDEFAULT },
746   { "gameListW", ArgInt, (void *) &wpGameList.width, TRUE, (ArgIniType) CW_USEDEFAULT },
747   { "gameListH", ArgInt, (void *) &wpGameList.height, TRUE, (ArgIniType) CW_USEDEFAULT },
748   /* [AS] Layout stuff */
749   { "moveHistoryUp", ArgBoolean, (void *) &wpMoveHistory.visible, TRUE, (ArgIniType) TRUE },
750   { "moveHistoryX", ArgX,   (void *) &wpMoveHistory.x, TRUE, (ArgIniType) CW_USEDEFAULT },
751   { "moveHistoryY", ArgY,   (void *) &wpMoveHistory.y, TRUE, (ArgIniType) CW_USEDEFAULT },
752   { "moveHistoryW", ArgInt, (void *) &wpMoveHistory.width, TRUE, (ArgIniType) CW_USEDEFAULT },
753   { "moveHistoryH", ArgInt, (void *) &wpMoveHistory.height, TRUE, (ArgIniType) CW_USEDEFAULT },
754
755   { "evalGraphUp", ArgBoolean, (void *) &wpEvalGraph.visible, TRUE, (ArgIniType) TRUE },
756   { "evalGraphX", ArgX,   (void *) &wpEvalGraph.x, TRUE, (ArgIniType) CW_USEDEFAULT },
757   { "evalGraphY", ArgY,   (void *) &wpEvalGraph.y, TRUE, (ArgIniType) CW_USEDEFAULT },
758   { "evalGraphW", ArgInt, (void *) &wpEvalGraph.width, TRUE, (ArgIniType) CW_USEDEFAULT },
759   { "evalGraphH", ArgInt, (void *) &wpEvalGraph.height, TRUE, (ArgIniType) CW_USEDEFAULT },
760
761   { "engineOutputUp", ArgBoolean, (void *) &wpEngineOutput.visible, TRUE, (ArgIniType) TRUE },
762   { "engineOutputX", ArgX,   (void *) &wpEngineOutput.x, TRUE, (ArgIniType) CW_USEDEFAULT },
763   { "engineOutputY", ArgY,   (void *) &wpEngineOutput.y, TRUE, (ArgIniType) CW_USEDEFAULT },
764   { "engineOutputW", ArgInt, (void *) &wpEngineOutput.width, TRUE, (ArgIniType) CW_USEDEFAULT },
765   { "engineOutputH", ArgInt, (void *) &wpEngineOutput.height, TRUE, (ArgIniType) CW_USEDEFAULT },
766
767   { NULL, ArgNone, NULL, FALSE, INVALID }
768 };
769
770
771 /* Kludge for indirection files on command line */
772 char* lastIndirectionFilename;
773 ArgDescriptor argDescriptorIndirection =
774 { "", ArgSettingsFilename, (void *) NULL, FALSE };
775
776 void
777 ExitArgError(char *msg, char *badArg, Boolean quit)
778 {
779   char buf[MSG_SIZ];
780   int len;
781
782   len = snprintf(buf, MSG_SIZ, msg, badArg);
783   if( (len >= MSG_SIZ) && appData.debugMode )
784     fprintf(debugFP, "ExitArgError: buffer truncated. Input: msg=%s badArg=%s\n", msg, badArg);
785
786   if(!quit) { printf(_("%s in settings file\n"), buf); return; } // DisplayError does not work yet at this stage...
787   DisplayFatalError(buf, 0, 2);
788   exit(2);
789 }
790
791 int
792 ValidateInt(char *s)
793 {
794   char *p = s;
795   if(*p == '-' || *p == '+') p++;
796   while(*p) if(!isdigit(*p++)) ExitArgError(_("Bad integer value %s"), s, TRUE);
797   return atoi(s);
798 }
799
800 char
801 StringGet(void *getClosure)
802 {
803   char **p = (char **) getClosure;
804   return *((*p)++);
805 }
806
807 char
808 FileGet(void *getClosure)
809 {
810   int c;
811   FILE* f = (FILE*) getClosure;
812
813   c = getc(f);
814   if (c == '\r') c = getc(f); // work around DOS format files by bypassing the '\r' completely
815   if (c == EOF)
816     return NULLCHAR;
817   else
818     return (char) c;
819 }
820
821 /* Parse settings file named "name". If file found, return the
822    full name in fullname and return TRUE; else return FALSE */
823 Boolean
824 ParseSettingsFile(char *name, char **addr)
825 {
826   FILE *f;
827   int ok,len;
828   char buf[MSG_SIZ], fullname[MSG_SIZ];
829
830
831   ok = MySearchPath(installDir, name, fullname);
832   if(!ok && strchr(name, '.') == NULL)
833     { // append default file-name extension '.ini' when needed
834       len = snprintf(buf,MSG_SIZ, "%s.ini", name);
835       if( (len >= MSG_SIZ) && appData.debugMode )
836         fprintf(debugFP, "ParseSettingsFile: buffer truncated. Input: name=%s \n",name);
837
838       ok = MySearchPath(installDir, buf, fullname);
839     }
840   if (ok) {
841     f = fopen(fullname, "r");
842     if (f != NULL) {
843       if (addr != NULL) {
844             ASSIGN(*addr, fullname);
845       }
846       ParseArgs(FileGet, f);
847       fclose(f);
848       return TRUE;
849     }
850   }
851   return FALSE;
852 }
853
854 void
855 ParseArgs(GetFunc get, void *cl)
856 {
857   char argName[MAX_ARG_LEN];
858   char argValue[MAX_ARG_LEN];
859   ArgDescriptor *ad;
860   char start;
861   char *q;
862   int i, octval;
863   char ch;
864   int posarg = 3; // default is game file
865
866   ch = get(cl);
867   for (;;) {
868     int posflag = 0;
869     while (ch == ' ' || ch == '\n' || ch == '\t') ch = get(cl);
870     if (ch == NULLCHAR) break;
871     if (ch == ';') {
872       /* Comment to end of line */
873       ch = get(cl);
874       while (ch != '\n' && ch != NULLCHAR) ch = get(cl);
875       continue;
876     } else if (ch == '/' || ch == '-') {
877       /* Switch */
878       q = argName;
879       while (ch != ' ' && ch != '=' && ch != ':' && ch != NULLCHAR &&
880              ch != '\n' && ch != '\t') {
881         *q++ = ch;
882         ch = get(cl);
883       }
884       *q = NULLCHAR;
885       for (ad = argDescriptors; ad->argName != NULL; ad++)
886         if (strcmp(ad->argName, argName + 1) == 0) break;
887       if (ad->argName == NULL) {
888         ExitArgError(_("Unrecognized argument %s"), argName, get != &FileGet); // [HGM] make unknown argument non-fatal
889         while (ch != '\n' && ch != NULLCHAR) ch = get(cl); // but skip rest of line it is on
890         continue; // so that when it is in a settings file, it is the only setting that will be purged from it
891       }
892     } else if (ch == '@') {
893       /* Indirection file */
894       ad = &argDescriptorIndirection;
895       ch = get(cl);
896     } else {
897       /* Positional argument */
898       ad = &argDescriptors[posarg++];
899       posflag++;
900       strncpy(argName, ad->argName,sizeof(argName)/sizeof(argName[0]));
901     }
902
903     if (ad->argType == ArgTwo) { // [HGM] kludgey arg type, not suitable for saving
904       *(Boolean *) ad->argLoc = 2;
905       continue;
906     }
907     if (ad->argType == ArgTrue) {
908       *(Boolean *) ad->argLoc = TRUE;
909       continue;
910     }
911     if (ad->argType == ArgFalse) {
912       *(Boolean *) ad->argLoc = FALSE;
913       continue;
914     }
915
916     while (ch == ' ' || ch == '=' || ch == ':' || ch == '\t') ch = get(cl);
917     if (ch == NULLCHAR || ch == '\n') {
918       ExitArgError(_("No value provided for argument %s"), argName, TRUE);
919     }
920     q = argValue;
921     if (ch == '{') {
922       // Quoting with { }.  No characters have to (or can) be escaped.
923       // Thus the string cannot contain a '}' character.
924       start = ch;
925       ch = get(cl);
926       while (start) {
927         switch (ch) {
928         case NULLCHAR:
929           start = NULLCHAR;
930           break;
931
932         case '}':
933           ch = get(cl);
934           start = NULLCHAR;
935           break;
936
937         default:
938           *q++ = ch;
939           ch = get(cl);
940           break;
941         }
942       }
943     } else if (ch == '\'' || ch == '"') {
944       // Quoting with ' ' or " ", with \ as escape character.
945       // Inconvenient for long strings that may contain Windows filenames.
946       start = ch;
947       ch = get(cl);
948       while (start) {
949         switch (ch) {
950         case NULLCHAR:
951           start = NULLCHAR;
952           break;
953
954         default:
955         not_special:
956           *q++ = ch;
957           ch = get(cl);
958           break;
959
960         case '\'':
961         case '\"':
962           if (ch == start) {
963             ch = get(cl);
964             start = NULLCHAR;
965             break;
966           } else {
967             goto not_special;
968           }
969
970         case '\\':
971           if (ad->argType == ArgFilename
972               || ad->argType == ArgSettingsFilename) {
973               goto not_special;
974           }
975           ch = get(cl);
976           switch (ch) {
977           case NULLCHAR:
978             ExitArgError(_("Incomplete \\ escape in value for %s"), argName, TRUE);
979             break;
980           case 'n':
981             *q++ = '\n';
982             ch = get(cl);
983             break;
984           case 'r':
985             *q++ = '\r';
986             ch = get(cl);
987             break;
988           case 't':
989             *q++ = '\t';
990             ch = get(cl);
991             break;
992           case 'b':
993             *q++ = '\b';
994             ch = get(cl);
995             break;
996           case 'f':
997             *q++ = '\f';
998             ch = get(cl);
999             break;
1000           default:
1001             octval = 0;
1002             for (i = 0; i < 3; i++) {
1003               if (ch >= '0' && ch <= '7') {
1004                 octval = octval*8 + (ch - '0');
1005                 ch = get(cl);
1006               } else {
1007                 break;
1008               }
1009             }
1010             if (i > 0) {
1011               *q++ = (char) octval;
1012             } else {
1013               *q++ = ch;
1014               ch = get(cl);
1015             }
1016             break;
1017           }
1018           break;
1019         }
1020       }
1021     } else {
1022       while ((ch != ' ' || posflag) && ch != NULLCHAR && ch != '\t' && ch != '\n') { // space allowed in positional arg
1023         *q++ = ch;
1024         ch = get(cl);
1025       }
1026     }
1027     *q = NULLCHAR;
1028
1029     if(posflag) { // positional argument: the argName was implied, and per default set as -lgf
1030       int len = strlen(argValue) - 4; // start of filename extension
1031       if(len < 0) len = 0;
1032       if(!strcasecmp(argValue + len, ".trn")) {
1033         ad = &argDescriptors[2]; // correct implied type to -tf
1034         appData.tourney = TRUE; // let it parse -tourneyOptions later
1035       } else if(!strcasecmp(argValue + len, ".fen") || !strcasecmp(argValue + len, ".epd")) {
1036         ad = &argDescriptors[1]; // correct implied type to -lpf
1037         appData.viewer = TRUE;
1038       } else if(!strcasecmp(argValue + len, ".ini") || !strcasecmp(argValue + len, ".xop")) {
1039         ad = &argDescriptors[0]; // correct implied type to -opt
1040       } else { // keep default -lgf, but let it imply viewer mode as well
1041         appData.viewer = TRUE;
1042       }
1043       strncpy(argName, ad->argName,sizeof(argName)/sizeof(argName[0]));
1044     }
1045
1046     switch (ad->argType) {
1047     case ArgInt:
1048       *(int *) ad->argLoc = ValidateInt(argValue);
1049       break;
1050
1051     case ArgX:
1052       *(int *) ad->argLoc = ValidateInt(argValue) + wpMain.x; // [HGM] placement: translate stored relative to absolute
1053       break;
1054
1055     case ArgY:
1056       *(int *) ad->argLoc = ValidateInt(argValue) + wpMain.y; // (this is really kludgey, it should be done where used...)
1057       break;
1058
1059     case ArgZ:
1060       *(int *) ad->argLoc = ValidateInt(argValue);
1061       EnsureOnScreen(&wpMain.x, &wpMain.y, minX, minY);
1062       break;
1063
1064     case ArgFloat:
1065       *(float *) ad->argLoc = (float) atof(argValue);
1066       break;
1067
1068     case ArgString:
1069     case ArgFilename:
1070       ASSIGN(*(char **) ad->argLoc, argValue);
1071       break;
1072
1073     case ArgSettingsFilename:
1074       {
1075         if (ParseSettingsFile(argValue, (char**)ad->argLoc)) {
1076         } else {
1077           if (ad->argLoc != NULL) {
1078           } else {
1079             ExitArgError(_("Failed to open indirection file %s"), argValue, TRUE);
1080           }
1081         }
1082       }
1083       break;
1084
1085     case ArgBoolean:
1086       switch (argValue[0]) {
1087       case 't':
1088       case 'T':
1089         *(Boolean *) ad->argLoc = TRUE;
1090         break;
1091       case 'f':
1092       case 'F':
1093         *(Boolean *) ad->argLoc = FALSE;
1094         break;
1095       default:
1096         ExitArgError(_("Unrecognized boolean argument value %s"), argValue, TRUE);
1097         break;
1098       }
1099       break;
1100
1101     case ArgColor:
1102       ParseColor((int)(intptr_t)ad->argLoc, argValue);
1103       break;
1104
1105     case ArgAttribs: {
1106       ColorClass cc = (ColorClass)ad->argLoc;
1107         ParseTextAttribs(cc, argValue); // [HGM] wrapper for platform independency
1108       }
1109       break;
1110
1111     case ArgBoardSize:
1112       ParseBoardSize(ad->argLoc, argValue);
1113       break;
1114
1115     case ArgFont:
1116       ParseFont(argValue, (int)(intptr_t)ad->argLoc);
1117       break;
1118
1119     case ArgCommSettings:
1120       ParseCommPortSettings(argValue);
1121       break;
1122
1123     case ArgNone:
1124       ExitArgError(_("Unrecognized argument %s"), argValue, TRUE);
1125       break;
1126     case ArgTwo:
1127     case ArgTrue:
1128     case ArgFalse: ;
1129     }
1130   }
1131 }
1132
1133 void
1134 ParseArgsFromString(char *p)
1135 {
1136     ParseArgs(StringGet, &p);
1137 }
1138
1139 void
1140 ParseArgsFromFile(FILE *f)
1141 {
1142     ParseArgs(FileGet, f);
1143 }
1144
1145 void
1146 ParseIcsTextMenu(char *icsTextMenuString)
1147 {
1148 //  int flags = 0;
1149   IcsTextMenuEntry *e = icsTextMenuEntry;
1150   char *p = icsTextMenuString;
1151   while (e->item != NULL && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) {
1152     free(e->item);
1153     e->item = NULL;
1154     if (e->command != NULL) {
1155       free(e->command);
1156       e->command = NULL;
1157     }
1158     e++;
1159   }
1160   e = icsTextMenuEntry;
1161   while (*p && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) {
1162     if (*p == ';' || *p == '\n') {
1163       e->item = strdup("-");
1164       e->command = NULL;
1165       p++;
1166     } else if (*p == '-') {
1167       e->item = strdup("-");
1168       e->command = NULL;
1169       p++;
1170       if (*p) p++;
1171     } else {
1172       char *q, *r, *s, *t;
1173       char c;
1174       q = strchr(p, ',');
1175       if (q == NULL) break;
1176       *q = NULLCHAR;
1177       r = strchr(q + 1, ',');
1178       if (r == NULL) break;
1179       *r = NULLCHAR;
1180       s = strchr(r + 1, ',');
1181       if (s == NULL) break;
1182       *s = NULLCHAR;
1183       c = ';';
1184       t = strchr(s + 1, c);
1185       if (t == NULL) {
1186         c = '\n';
1187         t = strchr(s + 1, c);
1188       }
1189       if (t != NULL) *t = NULLCHAR;
1190       e->item = strdup(p);
1191       e->command = strdup(q + 1);
1192       e->getname = *(r + 1) != '0';
1193       e->immediate = *(s + 1) != '0';
1194       *q = ',';
1195       *r = ',';
1196       *s = ',';
1197       if (t == NULL) break;
1198       *t = c;
1199       p = t + 1;
1200     }
1201     e++;
1202   }
1203 }
1204
1205 void
1206 SetDefaultTextAttribs()
1207 {
1208   ColorClass cc;
1209   for (cc = (ColorClass)0; cc < ColorNone; cc++) {
1210     ParseTextAttribs(cc, defaultTextAttribs[cc]);
1211   }
1212 }
1213
1214 void
1215 SetDefaultsFromList()
1216 { // [HGM] ini: take defaults from argDescriptor list
1217   int i;
1218
1219   for(i=0; argDescriptors[i].argName != NULL; i++) {
1220     if(argDescriptors[i].defaultValue != INVALID)
1221       switch(argDescriptors[i].argType) {
1222         case ArgBoolean:
1223         case ArgTwo:
1224         case ArgTrue:
1225         case ArgFalse:
1226           *(Boolean *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1227           break;
1228         case ArgInt:
1229         case ArgX:
1230         case ArgY:
1231         case ArgZ:
1232           *(int *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1233           break;
1234         case ArgString:
1235         case ArgFilename:
1236         case ArgSettingsFilename:
1237           if((char *)argDescriptors[i].defaultValue)
1238           *(char **) argDescriptors[i].argLoc = strdup((char *)argDescriptors[i].defaultValue);
1239           break;
1240         case ArgBoardSize:
1241           *(int *) argDescriptors[i].argLoc = (int)(intptr_t)argDescriptors[i].defaultValue;
1242           break;
1243         case ArgColor:
1244           ParseColor((int)(intptr_t)argDescriptors[i].argLoc, (char*)argDescriptors[i].defaultValue);
1245           break;
1246         case ArgFloat: // floats cannot be casted to int without precision loss
1247         default: ; // some arg types cannot be initialized through table
1248     }
1249   }
1250 }
1251
1252 void
1253 InitAppData(char *lpCmdLine)
1254 {
1255   int i;
1256   char buf[MAX_ARG_LEN], currDir[MSG_SIZ];
1257   char *p;
1258
1259   /* Initialize to defaults */
1260   SetDefaultsFromList(); // this sets most defaults
1261
1262   // some parameters for which there are no options!
1263   appData.Iconic = FALSE; /*unused*/
1264   appData.icsEngineAnalyze = FALSE;
1265
1266   // float: casting to int is not harmless, so default cannot be contained in table
1267   appData.timeDelay = TIME_DELAY;
1268   appData.timeIncrement = TIME_INCREMENT;
1269
1270   // some complex, platform-dependent stuff that could not be handled from table
1271   SetDefaultTextAttribs();
1272   SetFontDefaults();
1273   SetCommPortDefaults();
1274
1275   /* Parse default settings file if any */
1276   ParseSettingsFile(settingsFileName, &settingsFileName);
1277
1278   /* Parse command line */
1279   ParseArgs(StringGet, &lpCmdLine);
1280
1281   if(appData.viewer && appData.viewerOptions[0]) ParseArgsFromString(appData.viewerOptions);
1282   if(appData.tourney && appData.tourneyOptions[0]) ParseArgsFromString(appData.tourneyOptions);
1283
1284   /* [HGM] make sure board size is acceptable */
1285   if(appData.NrFiles > BOARD_FILES ||
1286      appData.NrRanks > BOARD_RANKS   )
1287       DisplayFatalError("Recompile with BOARD_RANKS or BOARD_FILES, to support this size", 0, 2);
1288
1289   /* [HGM] After parsing the options from the .ini file, and overruling them
1290    * with options from the command line, we now make an even higher priority
1291    * overrule by WB options attached to the engine command line. This so that
1292    * tournament managers can use WB options (such as /timeOdds) that follow
1293    * the engines.
1294    */
1295   if(appData.firstChessProgram != NULL) {
1296       char *p = StrStr(appData.firstChessProgram, "WBopt");
1297       static char *f = "first";
1298       char buf[MSG_SIZ], *q = buf;
1299       int len;
1300
1301       if(p != NULL)
1302         { // engine command line contains WinBoard options
1303           len = snprintf(buf, MSG_SIZ, p+6, f, f, f, f, f, f, f, f, f, f); // replace %s in them by "first"
1304           if( (len >= MSG_SIZ) && appData.debugMode )
1305             fprintf(debugFP, "InitAppData: buffer truncated.\n");
1306
1307           ParseArgs(StringGet, &q);
1308           p[-1] = 0; // cut them offengine command line
1309         }
1310   }
1311   // now do same for second chess program
1312   if(appData.secondChessProgram != NULL) {
1313       char *p = StrStr(appData.secondChessProgram, "WBopt");
1314       static char *s = "second";
1315       char buf[MSG_SIZ], *q = buf;
1316       int len;
1317
1318       if(p != NULL)
1319         { // engine command line contains WinBoard options
1320           len = snprintf(buf,MSG_SIZ, p+6, s, s, s, s, s, s, s, s, s, s); // replace %s in them by "first"
1321           if( (len >= MSG_SIZ) && appData.debugMode )
1322             fprintf(debugFP, "InitAppData: buffer truncated.\n");
1323
1324           ParseArgs(StringGet, &q);
1325           p[-1] = 0; // cut them offengine command line
1326         }
1327   }
1328
1329   /* Propagate options that affect others */
1330   if (appData.matchMode || appData.matchGames) chessProgram = TRUE;
1331   if (appData.icsActive || appData.noChessProgram) {
1332      chessProgram = FALSE;  /* not local chess program mode */
1333   }
1334
1335   /* Open startup dialog if needed */
1336   if ((!appData.noChessProgram && !chessProgram && !appData.icsActive) ||
1337       (appData.icsActive && *appData.icsHost == NULLCHAR) ||
1338       (chessProgram && (*appData.firstChessProgram == NULLCHAR ||
1339                         *appData.secondChessProgram == NULLCHAR)))
1340                 PopUpStartupDialog();
1341
1342   /* Make sure save files land in the right (?) directory */
1343   if (MyGetFullPathName(appData.saveGameFile, buf)) {
1344     appData.saveGameFile = strdup(buf);
1345   }
1346   if (MyGetFullPathName(appData.savePositionFile, buf)) {
1347     appData.savePositionFile = strdup(buf);
1348   }
1349
1350   /* Finish initialization for fonts and sounds */
1351   CreateFonts();
1352
1353   GetCurrentDirectory(MSG_SIZ, currDir);
1354   SetCurrentDirectory(installDir);
1355   LoadAllSounds();
1356   SetCurrentDirectory(currDir);
1357
1358   p = icsTextMenuString;
1359   if (p[0] == '@') {
1360     FILE* f = fopen(p + 1, "r");
1361     if (f == NULL) {
1362       DisplayFatalError(p + 1, errno, 2);
1363       return;
1364     }
1365     i = fread(buf, 1, sizeof(buf)-1, f);
1366     fclose(f);
1367     buf[i] = NULLCHAR;
1368     p = buf;
1369   }
1370   ParseIcsTextMenu(strdup(p));
1371 }
1372
1373 void
1374 SaveSettings(char* name)
1375 {
1376   FILE *f;
1377   ArgDescriptor *ad;
1378   char dir[MSG_SIZ], buf[MSG_SIZ];
1379
1380   if (!MainWindowUp()) return;
1381
1382   GetCurrentDirectory(MSG_SIZ, dir);
1383   if(MySearchPath(installDir, name, buf)) {
1384     f = fopen(buf, "w");
1385   } else {
1386     SetCurrentDirectory(installDir);
1387     f = fopen(name, "w");
1388     SetCurrentDirectory(dir);
1389   }
1390   if (f == NULL) {
1391     DisplayError(name, errno);
1392     return;
1393   }
1394
1395   fprintf(f, ";\n");
1396   fprintf(f, "; %s Save Settings file\n", PACKAGE_STRING);
1397   fprintf(f, ";\n");
1398   fprintf(f, "; You can edit the values of options that are already set in this file,\n");
1399   fprintf(f, "; but if you add other options, the next Save Settings will not save them.\n");
1400   fprintf(f, "; Use a shortcut, an @indirection file, or a .bat file instead.\n");
1401   fprintf(f, ";\n");
1402
1403   GetWindowCoords();
1404
1405   /* [AS] Move history */
1406   wpMoveHistory.visible = MoveHistoryIsUp();
1407
1408   /* [AS] Eval graph */
1409   wpEvalGraph.visible = EvalGraphIsUp();
1410
1411   /* [AS] Engine output */
1412   wpEngineOutput.visible = EngineOutputIsUp();
1413
1414   // [HGM] in WB we have to copy sound names to appData first
1415   ExportSounds();
1416
1417   for (ad = argDescriptors; ad->argName != NULL; ad++) {
1418     if (!ad->save) continue;
1419     switch (ad->argType) {
1420     case ArgString:
1421       {
1422         char *p = *(char **)ad->argLoc;
1423         if(p == NULL) break; // just in case
1424         if ((strchr(p, '\\') || strchr(p, '\n')) && !strchr(p, '}')) {
1425           /* Quote multiline values or \-containing values
1426              with { } if possible */
1427           fprintf(f, OPTCHAR "%s" SEPCHAR "{%s}\n", ad->argName, p);
1428         } else {
1429           /* Else quote with " " */
1430           fprintf(f, OPTCHAR "%s" SEPCHAR "\"", ad->argName);
1431           while (*p) {
1432             if (*p == '\n') fprintf(f, "\n");
1433             else if (*p == '\r') fprintf(f, "\\r");
1434             else if (*p == '\t') fprintf(f, "\\t");
1435             else if (*p == '\b') fprintf(f, "\\b");
1436             else if (*p == '\f') fprintf(f, "\\f");
1437             else if (*p < ' ') fprintf(f, "\\%03o", *p);
1438             else if (*p == '\"') fprintf(f, "\\\"");
1439             else if (*p == '\\') fprintf(f, "\\\\");
1440             else putc(*p, f);
1441             p++;
1442           }
1443           fprintf(f, "\"\n");
1444         }
1445       }
1446       break;
1447     case ArgInt:
1448     case ArgZ:
1449       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc);
1450       break;
1451     case ArgX:
1452       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.x); // [HGM] placement: store relative value
1453       break;
1454     case ArgY:
1455       fprintf(f, OPTCHAR "%s" SEPCHAR "%d\n", ad->argName, *(int *)ad->argLoc - wpMain.y);
1456       break;
1457     case ArgFloat:
1458       fprintf(f, OPTCHAR "%s" SEPCHAR "%g\n", ad->argName, *(float *)ad->argLoc);
1459       break;
1460     case ArgBoolean:
1461       fprintf(f, OPTCHAR "%s" SEPCHAR "%s\n", ad->argName,
1462         (*(Boolean *)ad->argLoc) ? "true" : "false");
1463       break;
1464     case ArgTrue:
1465       if (*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName);
1466       break;
1467     case ArgFalse:
1468       if (!*(Boolean *)ad->argLoc) fprintf(f, OPTCHAR "%s\n", ad->argName);
1469       break;
1470     case ArgColor:
1471       SaveColor(f, ad);
1472       break;
1473     case ArgAttribs:
1474       SaveAttribsArg(f, ad);
1475       break;
1476     case ArgFilename:
1477       if(*(char**)ad->argLoc == NULL) break; // just in case
1478       if (strchr(*(char **)ad->argLoc, '\"')) {
1479         fprintf(f, OPTCHAR "%s" SEPCHAR "'%s'\n", ad->argName, *(char **)ad->argLoc);
1480       } else {
1481         fprintf(f, OPTCHAR "%s" SEPCHAR "\"%s\"\n", ad->argName, *(char **)ad->argLoc);
1482       }
1483       break;
1484     case ArgBoardSize:
1485       SaveBoardSize(f, ad->argName, ad->argLoc);
1486       break;
1487     case ArgFont:
1488       SaveFontArg(f, ad);
1489       break;
1490     case ArgCommSettings:
1491       PrintCommPortSettings(f, ad->argName);
1492     case ArgTwo:
1493     case ArgNone:
1494     case ArgSettingsFilename: ;
1495     }
1496   }
1497   fclose(f);
1498 }
1499
1500 Boolean
1501 GetArgValue(char *name)
1502 { // retrieve (as text) current value of string or int argument given by name
1503   // (this is used for maing the values available in the adapter command)
1504   ArgDescriptor *ad;
1505   int len;
1506
1507   for (ad = argDescriptors; ad->argName != NULL; ad++)
1508     if (strcmp(ad->argName, name) == 0) break;
1509
1510   if (ad->argName == NULL) return FALSE;
1511
1512   switch(ad->argType) {
1513     case ArgString:
1514     case ArgFilename:
1515       strncpy(name, *(char**) ad->argLoc, MSG_SIZ);
1516
1517       return TRUE;
1518     case ArgInt:
1519       len = snprintf(name, MSG_SIZ, "%d", *(int*) ad->argLoc);
1520       if( (len >= MSG_SIZ) && appData.debugMode )
1521         fprintf(debugFP, "GetArgValue: buffer truncated.\n");
1522
1523       return TRUE;
1524     case ArgBoolean:
1525       len = snprintf(name, MSG_SIZ, "%s", *(Boolean*) ad->argLoc ? "true" : "false");
1526       if( (len >= MSG_SIZ) && appData.debugMode )
1527         fprintf(debugFP, "GetArgValue: buffer truncated.\n");
1528
1529       return TRUE;
1530     default: ;
1531   }
1532
1533   return FALSE;
1534 }