Bugfix draw offer to engine if color zippy enable.
[xboard.git] / backend.h
1 /*
2  * backend.h -- Interface exported by XBoard back end
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 #ifndef _BACKEND
49 #define _BACKEND
50
51 #include "lists.h"
52 #include "frontend.h"
53
54 extern int gotPremove;
55 extern GameMode gameMode;
56 extern int pausing, cmailMsgLoaded, flipView;
57 extern char white_holding[], black_holding[];
58 extern int currentMove, backwardMostMove, forwardMostMove;
59 extern int blackPlaysFirst;
60 extern FILE *debugFP;
61 extern char* programVersion;
62 extern ProcRef firstProgramPR, secondProgramPR;
63 extern Board boards[];
64
65 char *CmailMsg P((void));
66 char *PositionToFEN P((int move));
67 void EditPositionPasteFEN P((char *fen));
68 void TimeDelay P((long ms));
69 void SendMultiLineToICS P(( char *text ));
70 void AnalysisPeriodicEvent P((int force));
71 void SetWhiteToPlayEvent P((void));
72 void SetBlackToPlayEvent P((void));
73 void InitBackEnd1 P((void));
74 void InitBackEnd2 P((void));
75 int IsPromotion P((int fromX, int fromY, int toX, int toY));
76 int PieceForSquare P((int x, int y));
77 int OKToStartUserMove P((int x, int y));
78 void Reset P((int redraw, int init));
79 void ResetGameEvent P((void));
80 int LoadGame P((FILE *f, int n, char *title, int useList));
81 int LoadGameFromFile P((char *filename, int n, char *title, int useList));
82 int CmailLoadGame P((FILE *f, int n, char *title, int useList));
83 int ReloadGame P((int offset));
84 int SaveGame P((FILE *f, int dummy, char *dummy2));
85 int SaveGameToFile P((char *filename, int append));
86 int LoadPosition P((FILE *f, int n, char *title));
87 int ReloadPosition P((int offset));
88 int SavePosition P((FILE *f, int dummy, char *dummy2));
89 void EditPositionEvent P((void));
90 void FlipViewEvent P((void));
91 void MachineWhiteEvent P((void));
92 void MachineBlackEvent P((void));
93 void TwoMachinesEvent P((void));
94 void EditGameEvent P((void));
95 void TrainingEvent P((void));
96 void IcsClientEvent P((void));
97 void ForwardEvent P((void));
98 void BackwardEvent P((void));
99 void ToEndEvent P((void));
100 void ToStartEvent P((void));
101 void ToNrEvent P((int to));
102 void RevertEvent P((void));
103 void RetractMoveEvent P((void));
104 void MoveNowEvent P((void));
105 void TruncateGameEvent P((void));
106 void PauseEvent P((void));
107 void CallFlagEvent P((void));
108 void AcceptEvent P((void));
109 void DeclineEvent P((void));
110 void RematchEvent P((void));
111 void DrawEvent P((void));
112 void AbortEvent P((void));
113 void AdjournEvent P((void));
114 void ResignEvent P((void));
115 void StopObservingEvent P((void));
116 void StopExaminingEvent P((void));
117 void PonderNextMoveEvent P((int newState));
118 void ShowThinkingEvent P((int newState));
119 void PeriodicUpdatesEvent P((int newState));
120 void HintEvent P((void));
121 void BookEvent P((void));
122 void AboutGameEvent P((void));
123 void ExitEvent P((int status));
124 char *DefaultFileName P((char *));
125 void UserMoveEvent P((int fromX, int fromY, int toX, int toY, int promoChar));
126 void DecrementClocks P((void));
127 char *TimeString P((long millisec));
128 void AutoPlayGameLoop P((void));
129 void DisplayBothClocks P((void));
130 void EditPositionMenuEvent P((ChessSquare selection, int x, int y));
131 void DropMenuEvent P((ChessSquare selection, int x, int y));
132 int ParseTimeControl P((char *tc, int ti, int mps));
133 void ProcessICSInitScript P((FILE * f));
134 void EditCommentEvent P((void));
135 void ReplaceComment P((int index, char *text));
136 int ReplaceTags P((char *tags, GameInfo *gi));/* returns nonzero on error */
137 void AppendComment P((int index, char *text));
138 void ReloadCmailMsgEvent P((int unregister));
139 void MailMoveEvent P((void));
140 void EditTagsEvent P((void));
141 void GetMoveListEvent P((void));
142 void ExitAnalyzeMode P((void));
143 void AnalyzeModeEvent P((void));
144 void AnalyzeFileEvent P((void));
145 void DoEcho P((void));
146 void DontEcho P((void));
147 void TidyProgramName P((char *prog, char *host, char *buf));
148 void AskQuestionEvent P((char *title, char *question,
149                          char *replyPrefix, char *which));
150 Boolean ParseOneMove P((char *move, int moveNum,
151                         ChessMove *moveType, int *fromX, int *fromY,
152                         int *toX, int *toY, char *promoChar));
153 char *VariantName P((VariantClass v));
154 VariantClass StringToVariant P((char *e));
155
156 char *StrStr P((char *string, char *match));
157 char *StrCaseStr P((char *string, char *match));
158 char *StrSave P((char *s));
159 char *StrSavePtr P((char *s, char **savePtr));
160
161 #ifndef _amigados
162 int StrCaseCmp P((char *s1, char *s2));
163 int ToLower P((int c));
164 int ToUpper P((int c));
165 #else
166 #define StrCaseCmp Stricmp  /*  Use utility.library functions   */
167 #include <proto/utility.h>
168 #endif
169
170 extern GameInfo gameInfo;
171
172 /* ICS vars used with backend.c and zippy.c */
173 #define ICS_GENERIC 0
174 #define ICS_ICC 1
175 #define ICS_FICS 2
176 #define ICS_CHESSNET 3 /* not really supported */
177 int ics_type;
178
179
180 /* pgntags.c prototypes
181  */
182 char *PGNTags P((GameInfo *));
183 void PrintPGNTags P((FILE *f, GameInfo *));
184 int ParsePGNTag P((char *, GameInfo *));
185 char *PGNResult P((ChessMove result));
186
187
188 /* gamelist.c prototypes
189  */
190 /* A game node in the double linked list of games.
191  */
192 typedef struct _ListGame {
193     ListNode node;
194     int number;
195     unsigned long offset;   /*  Byte offset of game within file.     */
196     GameInfo gameInfo;      /*  Note that some entries may be NULL. */
197 } ListGame;
198
199 extern List gameList;
200 void ClearGameInfo P((GameInfo *));
201 int GameListBuild P((FILE *));
202 void GameListInitGameInfo P((GameInfo *));
203 char *GameListLine P((int, GameInfo *));
204
205 extern char* StripHighlight P((char *));  /* returns static data */
206 extern char* StripHighlightAndTitle P((char *));  /* returns static data */
207
208
209 typedef struct _CPS {
210     char *which;
211     int maybeThinking;
212     ProcRef pr;
213     InputSourceRef isr;
214     char *twoMachinesColor; /* "white\n" or "black\n" */
215     char *program;
216     char *host;
217     char *dir;
218     struct _CPS *other;
219     char *initString;
220     char *computerString;
221     int sendTime; /* 0=don't, 1=do, 2=test */
222     int sendDrawOffers;
223     int useSigint;
224     int useSigterm;
225     int offeredDraw; /* countdown */
226     int reuse;
227     int useSetboard; /* 0=use "edit"; 1=use "setboard" */
228     int useSAN;      /* 0=use coordinate notation; 1=use SAN */
229     int usePing;     /* 0=not OK to use ping; 1=OK */
230     int lastPing;
231     int lastPong;
232     int usePlayother;/* 0=not OK to use playother; 1=OK */
233     int useColors;   /* 0=avoid obsolete white/black commands; 1=use them */
234     int useUsermove; /* 0=just send move; 1=send "usermove move" */
235     int sendICS;     /* 0=don't use "ics" command; 1=do */
236     int sendName;    /* 0=don't use "name" command; 1=do */
237     int sdKludge;    /* 0=use "sd DEPTH" command; 1=use "depth\nDEPTH" */
238     int stKludge;    /* 0=use "st TIME" command; 1=use "level 1 TIME" */
239     char tidy[MSG_SIZ];
240     int matchWins;
241     char variants[MSG_SIZ];
242     int analysisSupport;
243     int analyzing;
244     int protocolVersion;
245     int initDone;
246 } ChessProgramState;
247
248 extern ChessProgramState first, second;
249
250 #endif /* _BACKEND */