changes from H.G. Muller; version 4.3.2
[xboard.git] / common.h
index 4ea68ed..fc2b999 100644 (file)
--- a/common.h
+++ b/common.h
-/*
- * common.h -- Common definitions for X and Windows NT versions of XBoard
- * $Id: common.h,v 2.1 2003/10/27 19:21:00 mann Exp $
- *
- * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
- * Enhancements Copyright 1992-95 Free Software Foundation, Inc.
- *
- * The following terms apply to Digital Equipment Corporation's copyright
- * interest in XBoard:
- * ------------------------------------------------------------------------
- * All Rights Reserved
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of Digital not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- *
- * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * ------------------------------------------------------------------------
- *
- * The following terms apply to the enhanced version of XBoard distributed
- * by the Free Software Foundation:
- * ------------------------------------------------------------------------
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ------------------------------------------------------------------------
- */
-
-#ifndef _COMMON
-#define _COMMON
-
-/* Begin compatibility grunge  */
-
-#if defined(__STDC__) || defined(WIN32) || defined(_amigados)
-#define        P(args) args
-typedef void *VOIDSTAR;
-#else
-#define P(args)                ()
-typedef char *VOIDSTAR;
-#endif
-
-#ifdef WIN32
-typedef char Boolean;
-typedef char *String;
-#define popen _popen
-#define pclose _pclose
-
-#else
-#ifdef _amigados        /*  It is important, that these types have  */
-typedef int Boolean;    /*  a length of 4 bytes each, as we are     */
-typedef char *String;   /*  using ReadArgs() for argument parsing.  */
-#ifdef _DCC
-FILE *popen(const char *, const char *);
-int pclose(FILE *);
-#endif
-
-#else
-#include <X11/Intrinsic.h>
-#endif
-#endif
-
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#if !HAVE_RANDOM
-# if HAVE_RAND48
-#  define srandom srand48
-#  define random lrand48
-# else /* not HAVE_RAND48 */
-#  define srandom srand
-#  define random rand
-# endif /* not HAVE_RAND48 */
-#endif /* !HAVE_RANDOM */
-
-/* End compatibility grunge */
-
-#define PROTOVER                2       /* engine protocol version */
-
-#define BOARD_SIZE             8
-#define DROP_RANK               -3
-#define MAX_MOVES              1000
-#define MSG_SIZ                        512
-#define DIALOG_SIZE            256
-#define STAR_MATCH_N            16
-#define MOVE_LEN               32
-#define TIME_CONTROL           "5"     /* in minutes */
-#define TIME_DELAY_QUOTE       "1.0"   /* seconds between moves */
-#define TIME_DELAY              ((float) 1.0)
-#define MOVES_PER_SESSION      40      /* moves per TIME_CONTROL */
-#define TIME_INCREMENT          -1      /* if >= 0, MOVES_PER_SESSION unused */
-#define WhiteOnMove(move)      (((move) % 2) == 0)
-#define ICS_HOST                "chessclub.com"
-#define ICS_PORT               "5000"
-#define ICS_COMM_PORT           ""
-#define FIRST_HOST             "localhost"
-#define SECOND_HOST            "localhost"
-#define TELNET_PROGRAM          "telnet"
-#define MATCH_MODE             "False"
-#define INIT_STRING            "new\nrandom\n"
-#define WHITE_STRING           "white\ngo\n"
-#define BLACK_STRING           "black\ngo\n"
-#define COMPUTER_STRING         "computer\n"
-#define REUSE_CHESS_PROGRAMS    1
-#define WHITE_PIECE_COLOR      "#FFFFCC"
-#define BLACK_PIECE_COLOR      "#202020"
-#define LIGHT_SQUARE_COLOR     "#C8C365"
-#define DARK_SQUARE_COLOR      "#77A26D"
-#define JAIL_SQUARE_COLOR       "#808080"
-#define HIGHLIGHT_SQUARE_COLOR "#FFFF00"
-#define PREMOVE_HIGHLIGHT_COLOR        "#FF0000"
-#define BELLCHAR                '\007'
-#define NULLCHAR                '\000'
-#define FEATURE_TIMEOUT         10000 /*ms*/
-
-/* Zippy defaults */
-#define ZIPPY_TALK FALSE
-#define ZIPPY_PLAY FALSE
-#define ZIPPY_LINES "yow.lines"
-#define ZIPPY_PINHEAD ""
-#define ZIPPY_PASSWORD ""
-#define ZIPPY_PASSWORD2 ""
-#define ZIPPY_WRONG_PASSWORD ""
-#define ZIPPY_ACCEPT_ONLY ""
-#define ZIPPY_USE_I TRUE
-#define ZIPPY_BUGHOUSE 0
-#define ZIPPY_NOPLAY_CRAFTY FALSE
-#define ZIPPY_GAME_END "gameend\n"
-#define ZIPPY_GAME_START ""
-#define ZIPPY_ADJOURN FALSE
-#define ZIPPY_ABORT FALSE
-#define ZIPPY_VARIANTS "normal"
-#define ZIPPY_MAX_GAMES 0
-#define ZIPPY_REPLAY_TIMEOUT 120
-
-typedef enum {
-    BeginningOfGame, MachinePlaysWhite, MachinePlaysBlack,
-    AnalyzeMode, AnalyzeFile, TwoMachinesPlay,
-    EditGame, PlayFromGameFile, EndOfGame, EditPosition, Training,
-    IcsIdle, IcsPlayingWhite, IcsPlayingBlack, IcsObserving,
-    IcsExamining
-  } GameMode;
-
-typedef enum {
-    WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, WhiteQueen, WhiteKing,
-    BlackPawn, BlackKnight, BlackBishop, BlackRook, BlackQueen, BlackKing,
-    EmptySquare, 
-    ClearBoard, WhitePlay, BlackPlay /*for use on EditPosition menus*/
-  } ChessSquare;
-
-typedef ChessSquare Board[BOARD_SIZE][BOARD_SIZE];
-
-typedef enum {
-    WhiteKingSideCastle = 1, WhiteQueenSideCastle,
-    WhiteKingSideCastleWild, WhiteQueenSideCastleWild,
-    WhiteHSideCastleFR, WhiteASideCastleFR, 
-    BlackKingSideCastle, BlackQueenSideCastle,
-    BlackKingSideCastleWild, BlackQueenSideCastleWild,
-    BlackHSideCastleFR, BlackASideCastleFR, 
-    WhitePromotionKnight, WhitePromotionBishop,
-    WhitePromotionRook, WhitePromotionQueen, WhitePromotionKing,
-    BlackPromotionKnight, BlackPromotionBishop,
-    BlackPromotionRook, BlackPromotionQueen, BlackPromotionKing,
-    WhiteCapturesEnPassant, BlackCapturesEnPassant,
-    WhiteDrop, BlackDrop, 
-    NormalMove, AmbiguousMove, IllegalMove, ImpossibleMove,
-    WhiteWins, BlackWins, GameIsDrawn, GameUnfinished,
-    GNUChessGame, XBoardGame, MoveNumberOne, 
-    Comment, PositionDiagram, ElapsedTime, PGNTag, NAG
-  } ChessMove;
-
-typedef enum {
-    ColorShout, ColorSShout, ColorChannel1, ColorChannel, ColorKibitz,
-    ColorTell, ColorChallenge, ColorRequest, ColorSeek, ColorNormal,
-    ColorNone, NColorClasses
-} ColorClass;
-
-typedef enum {
-    SoundMove, SoundBell, SoundAlarm, SoundIcsWin, SoundIcsLoss,
-    SoundIcsDraw, SoundIcsUnfinished, NSoundClasses
-} SoundClass;
-
-/* Names for chess variants, not necessarily supported */
-typedef enum {
-    VariantNormal,       /* Normal chess */
-    VariantLoadable,     /* "loadgame" command allowed (not really a variant)*/
-    VariantWildCastle,   /* Shuffle chess where king can castle from d file */
-    VariantNoCastle,     /* Shuffle chess with no castling at all */
-    VariantFischeRandom, /* FischeRandom */
-    VariantBughouse,     /* Bughouse, ICC/FICS rules */
-    VariantCrazyhouse,   /* Crazyhouse, ICC/FICS rules */
-    VariantLosers,       /* Try to lose all pieces or get mated (ICC wild 17)*/
-    VariantSuicide,      /* Try to lose all pieces incl. king (FICS) */
-    VariantGiveaway,     /* Try to have no legal moves left (ICC wild 26) */
-    VariantTwoKings,     /* Weird ICC wild 9 */
-    VariantKriegspiel,   /* Kriegspiel; pawns can capture invisible pieces */
-    VariantAtomic,       /* Capturing piece explodes (ICC wild 27) */
-    Variant3Check,       /* Win by giving check 3 times (ICC wild 25) */
-    VariantShatranj,     /* Unsupported (ICC wild 28) */
-    Variant29,           /* Temporary name for possible future ICC wild 29 */
-    Variant30,           /* Temporary name for possible future ICC wild 30 */
-    Variant31,           /* Temporary name for possible future ICC wild 31 */
-    Variant32,           /* Temporary name for possible future ICC wild 32 */
-    Variant33,           /* Temporary name for possible future ICC wild 33 */
-    Variant34,           /* Temporary name for possible future ICC wild 34 */
-    Variant35,           /* Temporary name for possible future ICC wild 35 */
-    Variant36,           /* Temporary name for possible future ICC wild 36 */
-    VariantUnknown       /* Catchall for other unknown variants */
-} VariantClass;
-
-#define VARIANT_NAMES { \
-  "normal", \
-  "normal", \
-  "wildcastle", \
-  "nocastle", \
-  "fischerandom", \
-  "bughouse", \
-  "crazyhouse", \
-  "losers", \
-  "suicide", \
-  "giveaway", \
-  "twokings", \
-  "kriegspiel", \
-  "atomic", \
-  "3check", \
-  "shatranj", \
-  "wild29", \
-  "wild30", \
-  "wild31", \
-  "wild32", \
-  "wild33", \
-  "wild34", \
-  "wild35", \
-  "wild36", \
-  "unknown" \
-}
-
-typedef struct {
-#if !defined(_amigados)
-    char *whitePieceColor;
-    char *blackPieceColor;
-    char *lightSquareColor;
-    char *darkSquareColor;
-    char *jailSquareColor;
-    char *highlightSquareColor;
-    char *premoveHighlightColor;
-#else
-    int whitePieceColor;
-    int blackPieceColor;
-    int lightSquareColor;
-    int darkSquareColor;
-    int jailSquareColor;
-    int highlightSquareColor;
-    int premoveHighlightColor;
-#endif
-    int movesPerSession;
-    int timeIncrement;
-    char *initString;
-    char *secondInitString;
-    char *firstComputerString;
-    char *secondComputerString;
-    char *firstChessProgram;
-    char *secondChessProgram;
-    char *firstDirectory;
-    char *secondDirectory;
-    Boolean firstPlaysBlack;
-    Boolean noChessProgram;
-    char *firstHost;
-    char *secondHost;
-    char *bitmapDirectory;
-    char *remoteShell;
-    char *remoteUser;
-    float timeDelay;
-    char *timeControl;
-    Boolean icsActive;
-    char *icsHost;
-    char *icsPort;
-    char *icsCommPort;  /* if set, use serial port instead of tcp host/port */
-    char *icsLogon;     /* Hack to permit variable logon scripts. */
-    char *icsHelper;
-    Boolean icsInputBox;
-    Boolean useTelnet;
-    char *telnetProgram;
-    char *gateway;
-    char *loadGameFile;
-    int loadGameIndex;      /* game # within file */
-    char *saveGameFile;
-    Boolean autoSaveGames;
-    char *loadPositionFile;
-    int loadPositionIndex;  /* position # within file */
-    char *savePositionFile;
-    Boolean matchMode;
-    int matchGames;
-    Boolean monoMode;
-    Boolean debugMode;
-    Boolean clockMode;
-    char *boardSize;
-    Boolean Iconic;
-    char *searchTime;
-    int searchDepth;
-    Boolean showCoords;
-    char *clockFont;
-    char *messageFont; /* WinBoard only */
-    char *coordFont;
-    char *font; /* xboard only: all other fonts */
-    char *tagsFont; /* WinBoard only */
-    char *commentFont; /* WinBoard only */
-    char *icsFont; /* WinBoard only */
-    Boolean ringBellAfterMoves;
-    Boolean autoCallFlag;
-    Boolean flipView;
-    Boolean autoFlipView;
-    char *cmailGameName; /* xboard only */
-    Boolean alwaysPromoteToQueen;
-    Boolean oldSaveStyle;
-    Boolean quietPlay;
-    Boolean showThinking;
-    Boolean ponderNextMove;
-    Boolean periodicUpdates;
-    Boolean autoObserve;
-    Boolean autoComment;
-    Boolean getMoveList;
-    Boolean testLegality;
-    int borderXoffset; /* xboard only */
-    int borderYoffset; /* xboard only */
-    Boolean titleInWindow; /* xboard only */
-    Boolean localLineEditing; /* WinBoard only */
-    Boolean zippyTalk;
-    Boolean zippyPlay;
-    int flashCount; /* Number of times to flash (xboard only) */
-    int flashRate; /* Flashes per second (xboard only)  */
-    char *pixmapDirectory; /* Path to XPM/XIM files to use (xboard only) */
-    int msLoginDelay;  /* Delay per character (in msec) while sending
-                         ICS logon script (xboard only) */
-    Boolean colorize;  /* If True, use the following colors to color text */
-    /* Strings for colors, as "fg, bg, bold" (strings used in xboard only) */
-    char *colorShout;
-    char *colorSShout;
-    char *colorChannel1;
-    char *colorChannel;
-    char *colorKibitz;
-    char *colorTell;
-    char *colorChallenge;
-    char *colorRequest;
-    char *colorSeek;
-    char *colorNormal;
-    char *soundProgram; /* sound-playing program */
-    char *soundShout;
-    char *soundSShout;
-    char *soundChannel1;
-    char *soundChannel;
-    char *soundKibitz;
-    char *soundTell;
-    char *soundChallenge;
-    char *soundRequest;
-    char *soundSeek;
-    char *soundMove;
-    char *soundIcsWin;
-    char *soundIcsLoss;
-    char *soundIcsDraw;
-    char *soundIcsUnfinished;
-    char *soundIcsAlarm;
-    Boolean reuseFirst;
-    Boolean reuseSecond;
-    Boolean animateDragging; /* If True, animate mouse dragging of pieces */
-    Boolean animate;   /* If True, animate non-mouse moves */
-    int animSpeed;     /* Delay in milliseconds between animation frames */
-    Boolean popupMoveErrors;
-    Boolean popupExitMessage;
-    int showJail;
-    Boolean highlightLastMove;
-    Boolean highlightDragging;
-    Boolean blindfold;          /* if true, no pieces are drawn */
-    Boolean premove;           /* true if premove feature enabled */ 
-    Boolean premoveWhite;      /* true if premoving White first move  */ 
-    char *premoveWhiteText;    /* text of White premove 1 */ 
-    Boolean premoveBlack;      /* true if premoving Black first move */ 
-    char *premoveBlackText;    /* text of Black premove 1 */ 
-    Boolean icsAlarm;          /* true if sounding alarm at a certain time */  
-    int icsAlarmTime;          /* time to sound alarm, in milliseconds */
-    Boolean autoRaiseBoard;
-    int fontSizeTolerance; /* xboard only */
-    char *initialMode;
-    char *variant;
-    int firstProtocolVersion;
-    int secondProtocolVersion;
-    Boolean showButtonBar;
-
-    /* [AS] New properties (down to the "ZIPPY" part) */
-    Boolean firstScoreIsAbsolute;  /* If true, engine score is always from white side */
-    Boolean secondScoreIsAbsolute; /* If true, engine score is always from white side */
-    Boolean saveExtendedInfoInPGN; /* If true, saved PGN games contain extended info */
-    Boolean hideThinkingFromHuman; /* If true, program thinking is generated but not displayed in human/computer matches */
-    char * liteBackTextureFile; /* Name of texture bitmap for lite squares */
-    char * darkBackTextureFile; /* Name of texture bitmap for dark squares */
-    int liteBackTextureMode;
-    int darkBackTextureMode;
-    char * renderPiecesWithFont; /* Name of font for rendering chess pieces */
-    char * fontToPieceTable; /* Map to translate font character to chess pieces */
-    int fontBackColorWhite;
-    int fontForeColorWhite;
-    int fontBackColorBlack;
-    int fontForeColorBlack;
-    int fontPieceSize; /* Size of font relative to square (percentage) */
-    int overrideLineGap; /* If >= 0 overrides the lineGap value of the board size properties */
-    int adjudicateLossThreshold; /* Adjudicate a two-machine game if both engines agree the score is below this for 6 plies */
-    int delayBeforeQuit;
-    int delayAfterQuit;
-    char * nameOfDebugFile;
-    char * pgnEventHeader;
-    int defaultFrcPosition;
-    char * gameListTags;
-    Boolean saveOutOfBookInfo;
-    Boolean showEvalInMoveHistory;
-    int evalHistColorWhite;
-    int evalHistColorBlack;
-    Boolean highlightMoveWithArrow;
-    int highlightArrowColor;
-    Boolean useStickyWindows;
-    int adjudicateDrawMoves;
-    Boolean autoDisplayComment;
-    Boolean autoDisplayTags;
-    Boolean firstIsUCI;
-    Boolean secondIsUCI;
-    Boolean firstHasOwnBookUCI;
-    Boolean secondHasOwnBookUCI;
-    char * polyglotDir;
-    Boolean usePolyglotBook;
-    char * polyglotBook;
-    int defaultHashSize;
-    int defaultCacheSizeEGTB;
-    char * defaultPathEGTB;
-
-#if ZIPPY
-    char *zippyLines;
-    char *zippyPinhead;
-    char *zippyPassword;
-    char *zippyPassword2;
-    char *zippyWrongPassword;
-    char *zippyAcceptOnly;
-    int zippyUseI;
-    int zippyBughouse;
-    int zippyNoplayCrafty;
-    char *zippyGameEnd;
-    char *zippyGameStart;
-    int zippyAdjourn;
-    int zippyAbort;
-    char *zippyVariants;
-    int zippyMaxGames;
-    int zippyReplayTimeout; /*seconds*/
-#endif
-} AppData, *AppDataPtr;
-
-/* [AS] PGN tags (for showing in the game list) */
-#define GLT_EVENT           'e'
-#define GLT_SITE            's'
-#define GLT_DATE            'd'
-#define GLT_ROUND           'o'
-#define GLT_PLAYERS         'p'     /* I.e. white "-" black */
-#define GLT_RESULT          'r'
-#define GLT_WHITE_ELO       'w'
-#define GLT_BLACK_ELO       'b'
-#define GLT_TIME_CONTROL    't'
-#define GLT_VARIANT         'v'
-#define GLT_OUT_OF_BOOK     'a'
-
-#define GLT_DEFAULT_TAGS    "eprd"  /* Event, players, result, date */
-
-#define GLT_ALL_TAGS        "esdoprwbtva"
-
-#define PGN_OUT_OF_BOOK     "Annotator"
-
-extern AppData appData;
-
-typedef struct {
-    /* PGN 7-tag info */
-    char *event;
-    char *site;
-    char *date;
-    char *round;
-    char *white;
-    char *black;
-    ChessMove result;
-    /* Additional info */
-    char *fen;          /* NULL or FEN for starting position; input only */
-    char *resultDetails;
-    char *timeControl;
-    char *extraTags;    /* NULL or "[Tag \"Value\"]\n", etc. */
-    int whiteRating;    /* -1 if unknown */
-    int blackRating;    /* -1 if unknown */
-    VariantClass variant;
-    char *outOfBook;    /* [AS] Move and score when engine went out of book */
-} GameInfo;
-
-
-#endif
+/*\r
+ * common.h -- Common definitions for X and Windows NT versions of XBoard\r
+ * $Id: common.h,v 2.1 2003/10/27 19:21:00 mann Exp $\r
+ *\r
+ * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.\r
+ * Enhancements Copyright 1992-95 Free Software Foundation, Inc.\r
+ *\r
+ * The following terms apply to Digital Equipment Corporation's copyright\r
+ * interest in XBoard:\r
+ * ------------------------------------------------------------------------\r
+ * All Rights Reserved\r
+ *\r
+ * Permission to use, copy, modify, and distribute this software and its\r
+ * documentation for any purpose and without fee is hereby granted,\r
+ * provided that the above copyright notice appear in all copies and that\r
+ * both that copyright notice and this permission notice appear in\r
+ * supporting documentation, and that the name of Digital not be\r
+ * used in advertising or publicity pertaining to distribution of the\r
+ * software without specific, written prior permission.\r
+ *\r
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\r
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\r
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\r
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\r
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\r
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\r
+ * SOFTWARE.\r
+ * ------------------------------------------------------------------------\r
+ *\r
+ * The following terms apply to the enhanced version of XBoard distributed\r
+ * by the Free Software Foundation:\r
+ * ------------------------------------------------------------------------\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
+ * ------------------------------------------------------------------------\r
+ */\r
+\r
+#ifndef _COMMON\r
+#define _COMMON\r
+\r
+\r
+/* Begin compatibility grunge  */\r
+\r
+#if defined(__STDC__) || defined(WIN32) || defined(_amigados)\r
+#define        P(args) args\r
+typedef void *VOIDSTAR;\r
+#else\r
+#define P(args)                ()\r
+typedef char *VOIDSTAR;\r
+#endif\r
+\r
+#ifdef WIN32\r
+typedef char Boolean;\r
+typedef char *String;\r
+#define popen _popen\r
+#define pclose _pclose\r
+\r
+#else\r
+#ifdef _amigados        /*  It is important, that these types have  */\r
+typedef int Boolean;    /*  a length of 4 bytes each, as we are     */\r
+typedef char *String;   /*  using ReadArgs() for argument parsing.  */\r
+#ifdef _DCC\r
+FILE *popen(const char *, const char *);\r
+int pclose(FILE *);\r
+#endif\r
+\r
+#else\r
+#include <X11/Intrinsic.h>\r
+#endif\r
+#endif\r
+\r
+\r
+#ifndef TRUE\r
+#define TRUE 1\r
+#define FALSE 0\r
+#endif\r
+\r
+#if !HAVE_RANDOM\r
+# if HAVE_RAND48\r
+#  define srandom srand48\r
+#  define random lrand48\r
+# else /* not HAVE_RAND48 */\r
+#  define srandom srand\r
+#  define random rand\r
+# endif /* not HAVE_RAND48 */\r
+#endif /* !HAVE_RANDOM */\r
+\r
+/* End compatibility grunge */\r
+\r
+#define PROTOVER                2       /* engine protocol version */\r
+\r
+#define BOARD_SIZE              12                     /* [HGM] for in declarations */\r
+#define BOARD_WIDTH             (appData.NrFiles)      /* [HGM] made user adjustable */\r
+#define BOARD_HEIGHT            (appData.NrRanks)\r
+#define ONE                     ('1'-(BOARD_HEIGHT>9)) /* [HGM] foremost board rank */\r
+#define DROP_RANK               -3\r
+#define MAX_MOVES              1000\r
+#define MSG_SIZ                        512\r
+#define DIALOG_SIZE            256\r
+#define STAR_MATCH_N            16\r
+#define MOVE_LEN               32\r
+#define TIME_CONTROL           "5"     /* in minutes */\r
+#define TIME_DELAY_QUOTE       "1.0"   /* seconds between moves */\r
+#define TIME_DELAY              ((float) 1.0)\r
+#define MOVES_PER_SESSION      40      /* moves per TIME_CONTROL */\r
+#define TIME_INCREMENT          -1      /* if >= 0, MOVES_PER_SESSION unused */\r
+#define WhiteOnMove(move)      (((move) % 2) == 0)\r
+#define ICS_HOST                "chessclub.com"\r
+#define ICS_PORT               "5000"\r
+#define ICS_COMM_PORT           ""\r
+#define FIRST_HOST             "localhost"\r
+#define SECOND_HOST            "localhost"\r
+#define TELNET_PROGRAM          "telnet"\r
+#define MATCH_MODE             "False"\r
+#define INIT_STRING            "new\nrandom\n"\r
+#define WHITE_STRING           "white\ngo\n"\r
+#define BLACK_STRING           "black\ngo\n"\r
+#define COMPUTER_STRING         "computer\n"\r
+#define REUSE_CHESS_PROGRAMS    1\r
+#define WHITE_PIECE_COLOR      "#FFFFCC"\r
+#define BLACK_PIECE_COLOR      "#202020"\r
+#define LIGHT_SQUARE_COLOR     "#C8C365"\r
+#define DARK_SQUARE_COLOR      "#77A26D"\r
+#define JAIL_SQUARE_COLOR       "#808080"\r
+#define HIGHLIGHT_SQUARE_COLOR "#FFFF00"\r
+#define PREMOVE_HIGHLIGHT_COLOR        "#FF0000"\r
+#define BELLCHAR                '\007'\r
+#define NULLCHAR                '\000'\r
+#define FEATURE_TIMEOUT         10000 /*ms*/\r
+\r
+/* Zippy defaults */\r
+#define ZIPPY_TALK FALSE\r
+#define ZIPPY_PLAY FALSE\r
+#define ZIPPY_LINES "yow.lines"\r
+#define ZIPPY_PINHEAD ""\r
+#define ZIPPY_PASSWORD ""\r
+#define ZIPPY_PASSWORD2 ""\r
+#define ZIPPY_WRONG_PASSWORD ""\r
+#define ZIPPY_ACCEPT_ONLY ""\r
+#define ZIPPY_USE_I TRUE\r
+#define ZIPPY_BUGHOUSE 0\r
+#define ZIPPY_NOPLAY_CRAFTY FALSE\r
+#define ZIPPY_GAME_END "gameend\n"\r
+#define ZIPPY_GAME_START ""\r
+#define ZIPPY_ADJOURN FALSE\r
+#define ZIPPY_ABORT FALSE\r
+#define ZIPPY_VARIANTS "normal"\r
+#define ZIPPY_MAX_GAMES 0\r
+#define ZIPPY_REPLAY_TIMEOUT 120\r
+\r
+typedef enum {\r
+    BeginningOfGame, MachinePlaysWhite, MachinePlaysBlack,\r
+    AnalyzeMode, AnalyzeFile, TwoMachinesPlay,\r
+    EditGame, PlayFromGameFile, EndOfGame, EditPosition, Training,\r
+    IcsIdle, IcsPlayingWhite, IcsPlayingBlack, IcsObserving,\r
+    IcsExamining\r
+  } GameMode;\r
+\r
+typedef enum {\r
+    WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, \r
+#ifdef FAIRY\r
+    WhiteCardinal, WhiteMarshall, WhiteFairyPawn, WhiteFairyKnight,\r
+    WhiteFairyBishop, WhiteFairyRook, WhiteFairyCardinal, WhiteFairyMarshall,\r
+    WhiteFairyQueen, WhiteFairyKing,\r
+#endif\r
+    WhiteQueen, WhiteKing,\r
+    BlackPawn, BlackKnight, BlackBishop, BlackRook,\r
+#ifdef FAIRY\r
+    BlackCardinal, BlackMarshall, BlackFairyPawn, BlackFairyKnight,\r
+    BlackFairyBishop, BlackFairyRook, BlackFairyCardinal, BlackFairyMarshall,\r
+    BlackFairyQueen, BlackFairyKing,\r
+#endif\r
+    BlackQueen, BlackKing,\r
+    EmptySquare, \r
+    ClearBoard, WhitePlay, BlackPlay /*for use on EditPosition menus*/\r
+  } ChessSquare;\r
+\r
+typedef ChessSquare Board[BOARD_SIZE][BOARD_SIZE];\r
+\r
+typedef enum {\r
+    WhiteKingSideCastle = 1, WhiteQueenSideCastle,\r
+    WhiteKingSideCastleWild, WhiteQueenSideCastleWild,\r
+    WhiteHSideCastleFR, WhiteASideCastleFR, \r
+    BlackKingSideCastle, BlackQueenSideCastle,\r
+    BlackKingSideCastleWild, BlackQueenSideCastleWild,\r
+    BlackHSideCastleFR, BlackASideCastleFR, \r
+    WhitePromotionKnight, WhitePromotionBishop,\r
+    WhitePromotionRook, WhitePromotionQueen, WhitePromotionKing,\r
+#ifdef FAIRY\r
+    WhitePromotionChancellor, WhitePromotionArchbishop,\r
+#endif\r
+    BlackPromotionKnight, BlackPromotionBishop,\r
+    BlackPromotionRook, BlackPromotionQueen, BlackPromotionKing,\r
+#ifdef FAIRY\r
+    BlackPromotionChancellor, BlackPromotionArchbishop,\r
+#endif\r
+    WhiteCapturesEnPassant, BlackCapturesEnPassant,\r
+    WhiteDrop, BlackDrop, \r
+    NormalMove, AmbiguousMove, IllegalMove, ImpossibleMove,\r
+    WhiteWins, BlackWins, GameIsDrawn, GameUnfinished,\r
+    GNUChessGame, XBoardGame, MoveNumberOne, \r
+    Comment, PositionDiagram, ElapsedTime, PGNTag, NAG\r
+  } ChessMove;\r
+\r
+typedef enum {\r
+    ColorShout, ColorSShout, ColorChannel1, ColorChannel, ColorKibitz,\r
+    ColorTell, ColorChallenge, ColorRequest, ColorSeek, ColorNormal,\r
+    ColorNone, NColorClasses\r
+} ColorClass;\r
+\r
+typedef enum {\r
+    SoundMove, SoundBell, SoundAlarm, SoundIcsWin, SoundIcsLoss,\r
+    SoundIcsDraw, SoundIcsUnfinished, NSoundClasses\r
+} SoundClass;\r
+\r
+/* Names for chess variants, not necessarily supported */\r
+typedef enum {\r
+    VariantNormal,       /* Normal chess */\r
+    VariantLoadable,     /* "loadgame" command allowed (not really a variant)*/\r
+    VariantWildCastle,   /* Shuffle chess where king can castle from d file */\r
+    VariantNoCastle,     /* Shuffle chess with no castling at all */\r
+    VariantFischeRandom, /* FischeRandom */\r
+    VariantBughouse,     /* Bughouse, ICC/FICS rules */\r
+    VariantCrazyhouse,   /* Crazyhouse, ICC/FICS rules */\r
+    VariantLosers,       /* Try to lose all pieces or get mated (ICC wild 17)*/\r
+    VariantSuicide,      /* Try to lose all pieces incl. king (FICS) */\r
+    VariantGiveaway,     /* Try to have no legal moves left (ICC wild 26) */\r
+    VariantTwoKings,     /* Weird ICC wild 9 */\r
+    VariantKriegspiel,   /* Kriegspiel; pawns can capture invisible pieces */\r
+    VariantAtomic,       /* Capturing piece explodes (ICC wild 27) */\r
+    Variant3Check,       /* Win by giving check 3 times (ICC wild 25) */\r
+    VariantShatranj,     /* Unsupported (ICC wild 28) */\r
+    Variant29,           /* Temporary name for possible future ICC wild 29 */\r
+    Variant30,           /* Temporary name for possible future ICC wild 30 */\r
+#ifdef FAIRY\r
+    VariantShogi,        /* [HGM] To be supported in next version */\r
+    VariantXiangqi,\r
+    VariantCourier,\r
+    VariantGothic,\r
+    VariantCapablanca,\r
+    VariantFairy,        /* [HGM] allow more piece types */\r
+#else\r
+    Variant31,           /* Temporary name for possible future ICC wild 31 */\r
+    Variant32,           /* Temporary name for possible future ICC wild 32 */\r
+    Variant33,\r
+    Variant34,           /* Temporary name for possible future ICC wild 34 */\r
+    Variant35,           /* Temporary name for possible future ICC wild 35 */\r
+    Variant36,           /* Temporary name for possible future ICC wild 36 */\r
+#endif\r
+    VariantUnknown       /* Catchall for other unknown variants */\r
+} VariantClass;\r
+\r
+#ifdef FAIRY\r
+#define VARIANT_NAMES { \\r
+  "normal", \\r
+  "normal", \\r
+  "wildcastle", \\r
+  "nocastle", \\r
+  "fischerandom", \\r
+  "bughouse", \\r
+  "crazyhouse", \\r
+  "losers", \\r
+  "suicide", \\r
+  "giveaway", \\r
+  "twokings", \\r
+  "kriegspiel", \\r
+  "atomic", \\r
+  "3check", \\r
+  "shatranj", \\r
+  "wild29", \\r
+  "wild30", \\r
+  "shogi", \\r
+  "xiangqi", \\r
+  "courier", \\r
+  "gothic", \\r
+  "capablanca", \\r
+  "fairy", \\r
+  "unknown" \\r
+}\r
+#else\r
+#define VARIANT_NAMES { \\r
+  "normal", \\r
+  "normal", \\r
+  "wildcastle", \\r
+  "nocastle", \\r
+  "fischerandom", \\r
+  "bughouse", \\r
+  "crazyhouse", \\r
+  "losers", \\r
+  "suicide", \\r
+  "giveaway", \\r
+  "twokings", \\r
+  "kriegspiel", \\r
+  "atomic", \\r
+  "3check", \\r
+  "shatranj", \\r
+  "wild29", \\r
+  "wild30", \\r
+  "wild31", \\r
+  "wild32", \\r
+  "wild33", \\r
+  "wild34", \\r
+  "wild35", \\r
+  "wild36", \\r
+  "unknown" \\r
+}\r
+#endif\r
+\r
+typedef struct {\r
+#if !defined(_amigados)\r
+    char *whitePieceColor;\r
+    char *blackPieceColor;\r
+    char *lightSquareColor;\r
+    char *darkSquareColor;\r
+    char *jailSquareColor;\r
+    char *highlightSquareColor;\r
+    char *premoveHighlightColor;\r
+#else\r
+    int whitePieceColor;\r
+    int blackPieceColor;\r
+    int lightSquareColor;\r
+    int darkSquareColor;\r
+    int jailSquareColor;\r
+    int highlightSquareColor;\r
+    int premoveHighlightColor;\r
+#endif\r
+    int movesPerSession;\r
+    int timeIncrement;\r
+    char *initString;\r
+    char *secondInitString;\r
+    char *firstComputerString;\r
+    char *secondComputerString;\r
+    char *firstChessProgram;\r
+    char *secondChessProgram;\r
+    char *firstDirectory;\r
+    char *secondDirectory;\r
+    Boolean firstPlaysBlack;\r
+    Boolean noChessProgram;\r
+    char *firstHost;\r
+    char *secondHost;\r
+    char *bitmapDirectory;\r
+    char *remoteShell;\r
+    char *remoteUser;\r
+    float timeDelay;\r
+    char *timeControl;\r
+    Boolean icsActive;\r
+    char *icsHost;\r
+    char *icsPort;\r
+    char *icsCommPort;  /* if set, use serial port instead of tcp host/port */\r
+    char *icsLogon;     /* Hack to permit variable logon scripts. */\r
+    char *icsHelper;\r
+    Boolean icsInputBox;\r
+    Boolean useTelnet;\r
+    char *telnetProgram;\r
+    char *gateway;\r
+    char *loadGameFile;\r
+    int loadGameIndex;      /* game # within file */\r
+    char *saveGameFile;\r
+    Boolean autoSaveGames;\r
+    char *loadPositionFile;\r
+    int loadPositionIndex;  /* position # within file */\r
+    char *savePositionFile;\r
+    Boolean matchMode;\r
+    int matchGames;\r
+    Boolean monoMode;\r
+    Boolean debugMode;\r
+    Boolean clockMode;\r
+    char *boardSize;\r
+    Boolean Iconic;\r
+    char *searchTime;\r
+    int searchDepth;\r
+    Boolean showCoords;\r
+    char *clockFont;\r
+    char *messageFont; /* WinBoard only */\r
+    char *coordFont;\r
+    char *font; /* xboard only: all other fonts */\r
+    char *tagsFont; /* WinBoard only */\r
+    char *commentFont; /* WinBoard only */\r
+    char *icsFont; /* WinBoard only */\r
+    Boolean ringBellAfterMoves;\r
+    Boolean autoCallFlag;\r
+    Boolean flipView;\r
+    Boolean autoFlipView;\r
+    char *cmailGameName; /* xboard only */\r
+    Boolean alwaysPromoteToQueen;\r
+    Boolean oldSaveStyle;\r
+    Boolean quietPlay;\r
+    Boolean showThinking;\r
+    Boolean ponderNextMove;\r
+    Boolean periodicUpdates;\r
+    Boolean autoObserve;\r
+    Boolean autoComment;\r
+    Boolean getMoveList;\r
+    Boolean testLegality;\r
+    int borderXoffset; /* xboard only */\r
+    int borderYoffset; /* xboard only */\r
+    Boolean titleInWindow; /* xboard only */\r
+    Boolean localLineEditing; /* WinBoard only */\r
+    Boolean zippyTalk;\r
+    Boolean zippyPlay;\r
+    int flashCount; /* Number of times to flash (xboard only) */\r
+    int flashRate; /* Flashes per second (xboard only)  */\r
+    char *pixmapDirectory; /* Path to XPM/XIM files to use (xboard only) */\r
+    int msLoginDelay;  /* Delay per character (in msec) while sending\r
+                         ICS logon script (xboard only) */\r
+    Boolean colorize;  /* If True, use the following colors to color text */\r
+    /* Strings for colors, as "fg, bg, bold" (strings used in xboard only) */\r
+    char *colorShout;\r
+    char *colorSShout;\r
+    char *colorChannel1;\r
+    char *colorChannel;\r
+    char *colorKibitz;\r
+    char *colorTell;\r
+    char *colorChallenge;\r
+    char *colorRequest;\r
+    char *colorSeek;\r
+    char *colorNormal;\r
+    char *soundProgram; /* sound-playing program */\r
+    char *soundShout;\r
+    char *soundSShout;\r
+    char *soundChannel1;\r
+    char *soundChannel;\r
+    char *soundKibitz;\r
+    char *soundTell;\r
+    char *soundChallenge;\r
+    char *soundRequest;\r
+    char *soundSeek;\r
+    char *soundMove;\r
+    char *soundIcsWin;\r
+    char *soundIcsLoss;\r
+    char *soundIcsDraw;\r
+    char *soundIcsUnfinished;\r
+    char *soundIcsAlarm;\r
+    Boolean reuseFirst;\r
+    Boolean reuseSecond;\r
+    Boolean animateDragging; /* If True, animate mouse dragging of pieces */\r
+    Boolean animate;   /* If True, animate non-mouse moves */\r
+    int animSpeed;     /* Delay in milliseconds between animation frames */\r
+    Boolean popupMoveErrors;\r
+    Boolean popupExitMessage;\r
+    int showJail;\r
+    Boolean highlightLastMove;\r
+    Boolean highlightDragging;\r
+    Boolean blindfold;          /* if true, no pieces are drawn */\r
+    Boolean premove;           /* true if premove feature enabled */ \r
+    Boolean premoveWhite;      /* true if premoving White first move  */ \r
+    char *premoveWhiteText;    /* text of White premove 1 */ \r
+    Boolean premoveBlack;      /* true if premoving Black first move */ \r
+    char *premoveBlackText;    /* text of Black premove 1 */ \r
+    Boolean icsAlarm;          /* true if sounding alarm at a certain time */  \r
+    int icsAlarmTime;          /* time to sound alarm, in milliseconds */\r
+    Boolean autoRaiseBoard;\r
+    int fontSizeTolerance; /* xboard only */\r
+    char *initialMode;\r
+    char *variant;\r
+    int firstProtocolVersion;\r
+    int secondProtocolVersion;\r
+    Boolean showButtonBar;\r
+\r
+    /* [AS] New properties (down to the "ZIPPY" part) */\r
+    Boolean firstScoreIsAbsolute;  /* If true, engine score is always from white side */\r
+    Boolean secondScoreIsAbsolute; /* If true, engine score is always from white side */\r
+    Boolean saveExtendedInfoInPGN; /* If true, saved PGN games contain extended info */\r
+    Boolean hideThinkingFromHuman; /* If true, program thinking is generated but not displayed in human/computer matches */\r
+    char * liteBackTextureFile; /* Name of texture bitmap for lite squares */\r
+    char * darkBackTextureFile; /* Name of texture bitmap for dark squares */\r
+    int liteBackTextureMode;\r
+    int darkBackTextureMode;\r
+    char * renderPiecesWithFont; /* Name of font for rendering chess pieces */\r
+    char * fontToPieceTable; /* Map to translate font character to chess pieces */\r
+    int fontBackColorWhite;\r
+    int fontForeColorWhite;\r
+    int fontBackColorBlack;\r
+    int fontForeColorBlack;\r
+    int fontPieceSize; /* Size of font relative to square (percentage) */\r
+    int overrideLineGap; /* If >= 0 overrides the lineGap value of the board size properties */\r
+    int adjudicateLossThreshold; /* Adjudicate a two-machine game if both engines agree the score is below this for 6 plies */\r
+    int delayBeforeQuit;\r
+    int delayAfterQuit;\r
+    char * nameOfDebugFile;\r
+    char * pgnEventHeader;\r
+    int defaultFrcPosition;\r
+    char * gameListTags;\r
+    Boolean saveOutOfBookInfo;\r
+    Boolean showEvalInMoveHistory;\r
+    int evalHistColorWhite;\r
+    int evalHistColorBlack;\r
+    Boolean highlightMoveWithArrow;\r
+    int highlightArrowColor;\r
+    Boolean useStickyWindows;\r
+    int adjudicateDrawMoves;\r
+    Boolean autoDisplayComment;\r
+    Boolean autoDisplayTags;\r
+    Boolean firstIsUCI;\r
+    Boolean secondIsUCI;\r
+    Boolean firstHasOwnBookUCI;\r
+    Boolean secondHasOwnBookUCI;\r
+    char * polyglotDir;\r
+    Boolean usePolyglotBook;\r
+    char * polyglotBook;\r
+    int defaultHashSize;\r
+    int defaultCacheSizeEGTB;\r
+    char * defaultPathEGTB;\r
+\r
+    /* [HGM] Board size */\r
+    int NrFiles;\r
+    int NrRanks;\r
+    int matchPause;\r
+    Boolean testClaims;\r
+    int ruleMoves;\r
+    int drawRepeats;\r
+\r
+#if ZIPPY\r
+    char *zippyLines;\r
+    char *zippyPinhead;\r
+    char *zippyPassword;\r
+    char *zippyPassword2;\r
+    char *zippyWrongPassword;\r
+    char *zippyAcceptOnly;\r
+    int zippyUseI;\r
+    int zippyBughouse;\r
+    int zippyNoplayCrafty;\r
+    char *zippyGameEnd;\r
+    char *zippyGameStart;\r
+    int zippyAdjourn;\r
+    int zippyAbort;\r
+    char *zippyVariants;\r
+    int zippyMaxGames;\r
+    int zippyReplayTimeout; /*seconds*/\r
+#endif\r
+} AppData, *AppDataPtr;\r
+\r
+/* [AS] PGN tags (for showing in the game list) */\r
+#define GLT_EVENT           'e'\r
+#define GLT_SITE            's'\r
+#define GLT_DATE            'd'\r
+#define GLT_ROUND           'o'\r
+#define GLT_PLAYERS         'p'     /* I.e. white "-" black */\r
+#define GLT_RESULT          'r'\r
+#define GLT_WHITE_ELO       'w'\r
+#define GLT_BLACK_ELO       'b'\r
+#define GLT_TIME_CONTROL    't'\r
+#define GLT_VARIANT         'v'\r
+#define GLT_OUT_OF_BOOK     'a'\r
+\r
+#define GLT_DEFAULT_TAGS    "eprd"  /* Event, players, result, date */\r
+\r
+#define GLT_ALL_TAGS        "esdoprwbtva"\r
+\r
+#define PGN_OUT_OF_BOOK     "Annotator"\r
+\r
+extern AppData appData;\r
+\r
+typedef struct {\r
+    /* PGN 7-tag info */\r
+    char *event;\r
+    char *site;\r
+    char *date;\r
+    char *round;\r
+    char *white;\r
+    char *black;\r
+    ChessMove result;\r
+    /* Additional info */\r
+    char *fen;          /* NULL or FEN for starting position; input only */\r
+    char *resultDetails;\r
+    char *timeControl;\r
+    char *extraTags;    /* NULL or "[Tag \"Value\"]\n", etc. */\r
+    int whiteRating;    /* -1 if unknown */\r
+    int blackRating;    /* -1 if unknown */\r
+    VariantClass variant;\r
+    char *outOfBook;    /* [AS] Move and score when engine went out of book */\r
+} GameInfo;\r
+\r
+\r
+#endif\r