HGM fixed cygwin compile for winboard
[xboard.git] / common.h
1 /*
2  * common.h -- Common definitions for X and Windows NT versions of XBoard
3  * $Id$
4  *
5  * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
6  * Enhancements Copyright 1992-95 Free Software Foundation, Inc.
7  *
8  * The following terms apply to Digital Equipment Corporation's copyright
9  * interest in XBoard:
10  * ------------------------------------------------------------------------
11  * All Rights Reserved
12  *
13  * Permission to use, copy, modify, and distribute this software and its
14  * documentation for any purpose and without fee is hereby granted,
15  * provided that the above copyright notice appear in all copies and that
16  * both that copyright notice and this permission notice appear in
17  * supporting documentation, and that the name of Digital not be
18  * used in advertising or publicity pertaining to distribution of the
19  * software without specific, written prior permission.
20  *
21  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
22  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
23  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
24  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
25  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27  * SOFTWARE.
28  * ------------------------------------------------------------------------
29  *
30  * The following terms apply to the enhanced version of XBoard distributed
31  * by the Free Software Foundation:
32  * ------------------------------------------------------------------------
33  * This program is free software; you can redistribute it and/or modify
34  * it under the terms of the GNU General Public License as published by
35  * the Free Software Foundation; either version 2 of the License, or
36  * (at your option) any later version.
37  *
38  * This program is distributed in the hope that it will be useful,
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41  * GNU General Public License for more details.
42  *
43  * You should have received a copy of the GNU General Public License
44  * along with this program; if not, write to the Free Software
45  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
46  * ------------------------------------------------------------------------
47  */
48
49 #ifndef _COMMON
50 #define _COMMON
51
52 /* Begin compatibility grunge  */
53
54 #if defined(__STDC__) || defined(WIN32) || defined(_amigados)
55 #define P(args) args
56 typedef void *VOIDSTAR;
57 #else
58 #define P(args)         ()
59 typedef char *VOIDSTAR;
60 #endif
61
62 #ifdef WIN32
63 typedef char Boolean;
64 typedef char *String;
65 #define popen _popen
66 #define pclose _pclose
67
68 #else
69 #ifdef _amigados        /*  It is important, that these types have  */
70 typedef int Boolean;    /*  a length of 4 bytes each, as we are     */
71 typedef char *String;   /*  using ReadArgs() for argument parsing.  */
72 #ifdef _DCC
73 FILE *popen(const char *, const char *);
74 int pclose(FILE *);
75 #endif
76
77 #else
78 #include <X11/Intrinsic.h>
79 #endif
80 #endif
81
82
83 #ifndef TRUE
84 #define TRUE 1
85 #define FALSE 0
86 #endif
87
88 #if !HAVE_RANDOM
89 # if HAVE_RAND48
90 #  define srandom srand48
91 #  define random lrand48
92 # else /* not HAVE_RAND48 */
93 #  define srandom srand
94 #  define random rand
95 # endif /* not HAVE_RAND48 */
96 #endif /* !HAVE_RANDOM */
97
98 /* End compatibility grunge */
99
100 #define PROTOVER                2       /* engine protocol version */
101
102 #define BOARD_SIZE              8
103 #define DROP_RANK               -3
104 #define MAX_MOVES               1000
105 #define MSG_SIZ                 512
106 #define DIALOG_SIZE             256
107 #define STAR_MATCH_N            16
108 #define MOVE_LEN                32
109 #define TIME_CONTROL            "5"     /* in minutes */
110 #define TIME_DELAY_QUOTE        "1.0"   /* seconds between moves */
111 #define TIME_DELAY              ((float) 1.0)
112 #define MOVES_PER_SESSION       40      /* moves per TIME_CONTROL */
113 #define TIME_INCREMENT          -1      /* if >= 0, MOVES_PER_SESSION unused */
114 #define WhiteOnMove(move)       (((move) % 2) == 0)
115 #define ICS_HOST                "chessclub.com"
116 #define ICS_PORT                "5000"
117 #define ICS_COMM_PORT           ""
118 #define FIRST_HOST              "localhost"
119 #define SECOND_HOST             "localhost"
120 #define TELNET_PROGRAM          "telnet"
121 #define MATCH_MODE              "False"
122 #define INIT_STRING             "new\nrandom\n"
123 #define WHITE_STRING            "white\ngo\n"
124 #define BLACK_STRING            "black\ngo\n"
125 #define COMPUTER_STRING         "computer\n"
126 #define REUSE_CHESS_PROGRAMS    1
127 #define WHITE_PIECE_COLOR       "#FFFFCC"
128 #define BLACK_PIECE_COLOR       "#202020"
129 #define LIGHT_SQUARE_COLOR      "#C8C365"
130 #define DARK_SQUARE_COLOR       "#77A26D"
131 #define JAIL_SQUARE_COLOR       "#808080"
132 #define HIGHLIGHT_SQUARE_COLOR  "#FFFF00"
133 #define PREMOVE_HIGHLIGHT_COLOR "#FF0000"
134 #define BELLCHAR                '\007'
135 #define NULLCHAR                '\000'
136 #define FEATURE_TIMEOUT         10000 /*ms*/
137
138 /* Zippy defaults */
139 #define ZIPPY_TALK FALSE
140 #define ZIPPY_PLAY FALSE
141 #define ZIPPY_LINES "yow.lines"
142 #define ZIPPY_PINHEAD ""
143 #define ZIPPY_PASSWORD ""
144 #define ZIPPY_PASSWORD2 ""
145 #define ZIPPY_WRONG_PASSWORD ""
146 #define ZIPPY_ACCEPT_ONLY ""
147 #define ZIPPY_USE_I TRUE
148 #define ZIPPY_BUGHOUSE 0
149 #define ZIPPY_NOPLAY_CRAFTY FALSE
150 #define ZIPPY_GAME_END "gameend\n"
151 #define ZIPPY_GAME_START ""
152 #define ZIPPY_ADJOURN FALSE
153 #define ZIPPY_ABORT FALSE
154 #define ZIPPY_VARIANTS "normal"
155 #define ZIPPY_MAX_GAMES 0
156 #define ZIPPY_REPLAY_TIMEOUT 120
157
158 typedef enum {
159     BeginningOfGame, MachinePlaysWhite, MachinePlaysBlack,
160     AnalyzeMode, AnalyzeFile, TwoMachinesPlay,
161     EditGame, PlayFromGameFile, EndOfGame, EditPosition, Training,
162     IcsIdle, IcsPlayingWhite, IcsPlayingBlack, IcsObserving,
163     IcsExamining
164   } GameMode;
165
166 typedef enum {
167     WhitePawn, WhiteKnight, WhiteBishop, WhiteRook, WhiteQueen, WhiteKing,
168     BlackPawn, BlackKnight, BlackBishop, BlackRook, BlackQueen, BlackKing,
169     EmptySquare, 
170     ClearBoard, WhitePlay, BlackPlay /*for use on EditPosition menus*/
171   } ChessSquare;
172
173 typedef ChessSquare Board[BOARD_SIZE][BOARD_SIZE];
174
175 typedef enum {
176     WhiteKingSideCastle = 1, WhiteQueenSideCastle,
177     WhiteKingSideCastleWild, WhiteQueenSideCastleWild,
178     WhiteHSideCastleFR, WhiteASideCastleFR, 
179     BlackKingSideCastle, BlackQueenSideCastle,
180     BlackKingSideCastleWild, BlackQueenSideCastleWild,
181     BlackHSideCastleFR, BlackASideCastleFR, 
182     WhitePromotionKnight, WhitePromotionBishop,
183     WhitePromotionRook, WhitePromotionQueen, WhitePromotionKing,
184     BlackPromotionKnight, BlackPromotionBishop,
185     BlackPromotionRook, BlackPromotionQueen, BlackPromotionKing,
186     WhiteCapturesEnPassant, BlackCapturesEnPassant,
187     WhiteDrop, BlackDrop, 
188     NormalMove, AmbiguousMove, IllegalMove, ImpossibleMove,
189     WhiteWins, BlackWins, GameIsDrawn, GameUnfinished,
190     GNUChessGame, XBoardGame, MoveNumberOne, 
191     Comment, PositionDiagram, ElapsedTime, PGNTag, NAG
192   } ChessMove;
193
194 typedef enum {
195     ColorShout, ColorSShout, ColorChannel1, ColorChannel, ColorKibitz,
196     ColorTell, ColorChallenge, ColorRequest, ColorSeek, ColorNormal,
197     ColorNone, NColorClasses
198 } ColorClass;
199
200 typedef enum {
201     SoundMove, SoundBell, SoundAlarm, SoundIcsWin, SoundIcsLoss,
202     SoundIcsDraw, SoundIcsUnfinished, NSoundClasses
203 } SoundClass;
204
205 /* Names for chess variants, not necessarily supported */
206 typedef enum {
207     VariantNormal,       /* Normal chess */
208     VariantLoadable,     /* "loadgame" command allowed (not really a variant)*/
209     VariantWildCastle,   /* Shuffle chess where king can castle from d file */
210     VariantNoCastle,     /* Shuffle chess with no castling at all */
211     VariantFischeRandom, /* FischeRandom */
212     VariantBughouse,     /* Bughouse, ICC/FICS rules */
213     VariantCrazyhouse,   /* Crazyhouse, ICC/FICS rules */
214     VariantLosers,       /* Try to lose all pieces or get mated (ICC wild 17)*/
215     VariantSuicide,      /* Try to lose all pieces incl. king (FICS) */
216     VariantGiveaway,     /* Try to have no legal moves left (ICC wild 26) */
217     VariantTwoKings,     /* Weird ICC wild 9 */
218     VariantKriegspiel,   /* Kriegspiel; pawns can capture invisible pieces */
219     VariantAtomic,       /* Capturing piece explodes (ICC wild 27) */
220     Variant3Check,       /* Win by giving check 3 times (ICC wild 25) */
221     VariantShatranj,     /* Unsupported (ICC wild 28) */
222     Variant29,           /* Temporary name for possible future ICC wild 29 */
223     Variant30,           /* Temporary name for possible future ICC wild 30 */
224     Variant31,           /* Temporary name for possible future ICC wild 31 */
225     Variant32,           /* Temporary name for possible future ICC wild 32 */
226     Variant33,           /* Temporary name for possible future ICC wild 33 */
227     Variant34,           /* Temporary name for possible future ICC wild 34 */
228     Variant35,           /* Temporary name for possible future ICC wild 35 */
229     Variant36,           /* Temporary name for possible future ICC wild 36 */
230     VariantUnknown       /* Catchall for other unknown variants */
231 } VariantClass;
232
233 #define VARIANT_NAMES { \
234   "normal", \
235   "normal", \
236   "wildcastle", \
237   "nocastle", \
238   "fischerandom", \
239   "bughouse", \
240   "crazyhouse", \
241   "losers", \
242   "suicide", \
243   "giveaway", \
244   "twokings", \
245   "kriegspiel", \
246   "atomic", \
247   "3check", \
248   "shatranj", \
249   "wild29", \
250   "wild30", \
251   "wild31", \
252   "wild32", \
253   "wild33", \
254   "wild34", \
255   "wild35", \
256   "wild36", \
257   "unknown" \
258 }
259
260 typedef struct {
261 #if !defined(_amigados)
262     char *whitePieceColor;
263     char *blackPieceColor;
264     char *lightSquareColor;
265     char *darkSquareColor;
266     char *jailSquareColor;
267     char *highlightSquareColor;
268     char *premoveHighlightColor;
269 #else
270     int whitePieceColor;
271     int blackPieceColor;
272     int lightSquareColor;
273     int darkSquareColor;
274     int jailSquareColor;
275     int highlightSquareColor;
276     int premoveHighlightColor;
277 #endif
278     int movesPerSession;
279     int timeIncrement;
280     char *initString;
281     char *secondInitString;
282     char *firstComputerString;
283     char *secondComputerString;
284     char *firstChessProgram;
285     char *secondChessProgram;
286     char *firstDirectory;
287     char *secondDirectory;
288     Boolean firstPlaysBlack;
289     Boolean noChessProgram;
290     char *firstHost;
291     char *secondHost;
292     char *bitmapDirectory;
293     char *remoteShell;
294     char *remoteUser;
295     float timeDelay;
296     char *timeControl;
297     Boolean icsActive;
298     char *icsHost;
299     char *icsPort;
300     char *icsCommPort;  /* if set, use serial port instead of tcp host/port */
301     char *icsLogon;     /* Hack to permit variable logon scripts. */
302     char *icsHelper;
303     Boolean icsInputBox;
304     Boolean useTelnet;
305     char *telnetProgram;
306     char *gateway;
307     char *loadGameFile;
308     int loadGameIndex;      /* game # within file */
309     char *saveGameFile;
310     Boolean autoSaveGames;
311     char *loadPositionFile;
312     int loadPositionIndex;  /* position # within file */
313     char *savePositionFile;
314     Boolean matchMode;
315     int matchGames;
316     Boolean monoMode;
317     Boolean debugMode;
318     Boolean clockMode;
319     char *boardSize;
320     Boolean Iconic;
321     char *searchTime;
322     int searchDepth;
323     Boolean showCoords;
324     char *clockFont;
325     char *messageFont; /* WinBoard only */
326     char *coordFont;
327     char *font; /* xboard only: all other fonts */
328     char *tagsFont; /* WinBoard only */
329     char *commentFont; /* WinBoard only */
330     char *icsFont; /* WinBoard only */
331     Boolean ringBellAfterMoves;
332     Boolean autoCallFlag;
333     Boolean flipView;
334     Boolean autoFlipView;
335     char *cmailGameName; /* xboard only */
336     Boolean alwaysPromoteToQueen;
337     Boolean oldSaveStyle;
338     Boolean quietPlay;
339     Boolean showThinking;
340     Boolean ponderNextMove;
341     Boolean periodicUpdates;
342     Boolean autoObserve;
343     Boolean autoComment;
344     Boolean getMoveList;
345     Boolean testLegality;
346     int borderXoffset; /* xboard only */
347     int borderYoffset; /* xboard only */
348     Boolean titleInWindow; /* xboard only */
349     Boolean localLineEditing; /* WinBoard only */
350     Boolean zippyTalk;
351     Boolean zippyPlay;
352     int flashCount; /* Number of times to flash (xboard only) */
353     int flashRate; /* Flashes per second (xboard only)  */
354     char *pixmapDirectory; /* Path to XPM/XIM files to use (xboard only) */
355     int msLoginDelay;  /* Delay per character (in msec) while sending
356                           ICS logon script (xboard only) */
357     Boolean colorize;   /* If True, use the following colors to color text */
358     /* Strings for colors, as "fg, bg, bold" (strings used in xboard only) */
359     char *colorShout;
360     char *colorSShout;
361     char *colorChannel1;
362     char *colorChannel;
363     char *colorKibitz;
364     char *colorTell;
365     char *colorChallenge;
366     char *colorRequest;
367     char *colorSeek;
368     char *colorNormal;
369     char *soundProgram; /* sound-playing program */
370     char *soundShout;
371     char *soundSShout;
372     char *soundChannel1;
373     char *soundChannel;
374     char *soundKibitz;
375     char *soundTell;
376     char *soundChallenge;
377     char *soundRequest;
378     char *soundSeek;
379     char *soundMove;
380     char *soundIcsWin;
381     char *soundIcsLoss;
382     char *soundIcsDraw;
383     char *soundIcsUnfinished;
384     char *soundIcsAlarm;
385     Boolean reuseFirst;
386     Boolean reuseSecond;
387     Boolean animateDragging; /* If True, animate mouse dragging of pieces */
388     Boolean animate;    /* If True, animate non-mouse moves */
389     int animSpeed;      /* Delay in milliseconds between animation frames */
390     Boolean popupMoveErrors;
391     Boolean popupExitMessage;
392     int showJail;
393     Boolean highlightLastMove;
394     Boolean highlightDragging;
395     Boolean blindfold;          /* if true, no pieces are drawn */
396     Boolean premove;            /* true if premove feature enabled */ 
397     Boolean premoveWhite;       /* true if premoving White first move  */ 
398     char *premoveWhiteText;     /* text of White premove 1 */ 
399     Boolean premoveBlack;       /* true if premoving Black first move */ 
400     char *premoveBlackText;     /* text of Black premove 1 */ 
401     Boolean icsAlarm;           /* true if sounding alarm at a certain time */  
402     int icsAlarmTime;           /* time to sound alarm, in milliseconds */
403     Boolean autoRaiseBoard;
404     int fontSizeTolerance; /* xboard only */
405     char *initialMode;
406     char *variant;
407     int firstProtocolVersion;
408     int secondProtocolVersion;
409     Boolean showButtonBar;
410         Boolean icsEngineAnalyze; 
411 #if ZIPPY
412     char *zippyLines;
413     char *zippyPinhead;
414     char *zippyPassword;
415     char *zippyPassword2;
416     char *zippyWrongPassword;
417     char *zippyAcceptOnly;
418     int zippyUseI;
419     int zippyBughouse;
420     int zippyNoplayCrafty;
421     char *zippyGameEnd;
422     char *zippyGameStart;
423     int zippyAdjourn;
424     int zippyAbort;
425     char *zippyVariants;
426     int zippyMaxGames;
427     int zippyReplayTimeout; /*seconds*/
428 #endif
429 } AppData, *AppDataPtr;
430
431 extern AppData appData;
432
433 typedef struct {
434     /* PGN 7-tag info */
435     char *event;
436     char *site;
437     char *date;
438     char *round;
439     char *white;
440     char *black;
441     ChessMove result;
442     /* Additional info */
443     char *fen;          /* NULL or FEN for starting position; input only */
444     char *resultDetails;
445     char *timeControl;
446     char *extraTags;    /* NULL or "[Tag \"Value\"]\n", etc. */
447     int whiteRating;    /* -1 if unknown */
448     int blackRating;    /* -1 if unknown */
449     VariantClass variant;
450 } GameInfo;
451
452
453 #endif