changes from H.G. Muller; version 4.3.14
[xboard.git] / backend.h
1 /*\r
2  * backend.h -- Interface exported by XBoard back end\r
3  * $Id: backend.h,v 2.1 2003/10/27 19:21:00 mann Exp $\r
4  *\r
5  * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.\r
6  * Enhancements Copyright 1992-95 Free Software Foundation, Inc.\r
7  *\r
8  * The following terms apply to Digital Equipment Corporation's copyright\r
9  * interest in XBoard:\r
10  * ------------------------------------------------------------------------\r
11  * All Rights Reserved\r
12  *\r
13  * Permission to use, copy, modify, and distribute this software and its\r
14  * documentation for any purpose and without fee is hereby granted,\r
15  * provided that the above copyright notice appear in all copies and that\r
16  * both that copyright notice and this permission notice appear in\r
17  * supporting documentation, and that the name of Digital not be\r
18  * used in advertising or publicity pertaining to distribution of the\r
19  * software without specific, written prior permission.\r
20  *\r
21  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\r
22  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\r
23  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\r
24  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\r
25  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\r
26  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\r
27  * SOFTWARE.\r
28  * ------------------------------------------------------------------------\r
29  *\r
30  * The following terms apply to the enhanced version of XBoard distributed\r
31  * by the Free Software Foundation:\r
32  * ------------------------------------------------------------------------\r
33  * This program is free software; you can redistribute it and/or modify\r
34  * it under the terms of the GNU General Public License as published by\r
35  * the Free Software Foundation; either version 2 of the License, or\r
36  * (at your option) any later version.\r
37  *\r
38  * This program is distributed in the hope that it will be useful,\r
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
41  * GNU General Public License for more details.\r
42  *\r
43  * You should have received a copy of the GNU General Public License\r
44  * along with this program; if not, write to the Free Software\r
45  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
46  * ------------------------------------------------------------------------\r
47  */\r
48 #ifndef _BACKEND\r
49 #define _BACKEND\r
50 \r
51 #include "lists.h"\r
52 #include "frontend.h"\r
53 \r
54 extern int gotPremove;\r
55 extern GameMode gameMode;\r
56 extern int pausing, cmailMsgLoaded, flipView;\r
57 extern char white_holding[], black_holding[];\r
58 extern int currentMove, backwardMostMove, forwardMostMove;\r
59 extern int blackPlaysFirst;\r
60 extern FILE *debugFP;\r
61 extern char* programVersion;\r
62 extern ProcRef firstProgramPR, secondProgramPR;\r
63 extern Board boards[];\r
64 \r
65 char *CmailMsg P((void));\r
66 /* Tord: Added the useFEN960 parameter in PositionToFEN() below */\r
67 char *PositionToFEN P((int move, int useFEN960));\r
68 void AlphaRank P((char *s, int n)); /* [HGM] Shogi move preprocessor */\r
69 void EditPositionPasteFEN P((char *fen));\r
70 void TimeDelay P((long ms));\r
71 void SendMultiLineToICS P(( char *text ));\r
72 void AnalysisPeriodicEvent P((int force));\r
73 void SetWhiteToPlayEvent P((void));\r
74 void SetBlackToPlayEvent P((void));\r
75 void InitBackEnd1 P((void));\r
76 void InitBackEnd2 P((void));\r
77 int IsPromotion P((int fromX, int fromY, int toX, int toY));\r
78 int InPalace P((int row, int column));\r
79 int PieceForSquare P((int x, int y));\r
80 int OKToStartUserMove P((int x, int y));\r
81 void Reset P((int redraw, int init));\r
82 void ResetGameEvent P((void));\r
83 int LoadGame P((FILE *f, int n, char *title, int useList));\r
84 int LoadGameFromFile P((char *filename, int n, char *title, int useList));\r
85 int CmailLoadGame P((FILE *f, int n, char *title, int useList));\r
86 int ReloadGame P((int offset));\r
87 int SaveGame P((FILE *f, int dummy, char *dummy2));\r
88 int SaveGameToFile P((char *filename, int append));\r
89 int LoadPosition P((FILE *f, int n, char *title));\r
90 int ReloadPosition P((int offset));\r
91 int SavePosition P((FILE *f, int dummy, char *dummy2));\r
92 void EditPositionEvent P((void));\r
93 void FlipViewEvent P((void));\r
94 void MachineWhiteEvent P((void));\r
95 void MachineBlackEvent P((void));\r
96 void TwoMachinesEvent P((void));\r
97 void EditGameEvent P((void));\r
98 void TrainingEvent P((void));\r
99 void IcsClientEvent P((void));\r
100 void ForwardEvent P((void));\r
101 void BackwardEvent P((void));\r
102 void ToEndEvent P((void));\r
103 void ToStartEvent P((void));\r
104 void ToNrEvent P((int to));\r
105 void RevertEvent P((void));\r
106 void RetractMoveEvent P((void));\r
107 void MoveNowEvent P((void));\r
108 void TruncateGameEvent P((void));\r
109 void PauseEvent P((void));\r
110 void CallFlagEvent P((void));\r
111 void AcceptEvent P((void));\r
112 void DeclineEvent P((void));\r
113 void RematchEvent P((void));\r
114 void DrawEvent P((void));\r
115 void AbortEvent P((void));\r
116 void AdjournEvent P((void));\r
117 void ResignEvent P((void));\r
118 void UserAdjudicationEvent P((int result));\r
119 void StopObservingEvent P((void));\r
120 void StopExaminingEvent P((void));\r
121 void PonderNextMoveEvent P((int newState));\r
122 void ShowThinkingEvent P((int newState));\r
123 void PeriodicUpdatesEvent P((int newState));\r
124 void HintEvent P((void));\r
125 void BookEvent P((void));\r
126 void AboutGameEvent P((void));\r
127 void ExitEvent P((int status));\r
128 char *DefaultFileName P((char *));\r
129 ChessMove UserMoveTest P((int fromX, int fromY, int toX, int toY, int promoChar));\r
130 void UserMoveEvent P((int fromX, int fromY, int toX, int toY, int promoChar));\r
131 void DecrementClocks P((void));\r
132 char *TimeString P((long millisec));\r
133 void AutoPlayGameLoop P((void));\r
134 void AdjustClock P((Boolean which, int dir));\r
135 void DisplayBothClocks P((void));\r
136 void EditPositionMenuEvent P((ChessSquare selection, int x, int y));\r
137 void DropMenuEvent P((ChessSquare selection, int x, int y));\r
138 int ParseTimeControl P((char *tc, int ti, int mps));\r
139 void ProcessICSInitScript P((FILE * f));\r
140 void EditCommentEvent P((void));\r
141 void ReplaceComment P((int index, char *text));\r
142 int ReplaceTags P((char *tags, GameInfo *gi));/* returns nonzero on error */\r
143 void AppendComment P((int index, char *text));\r
144 void ReloadCmailMsgEvent P((int unregister));\r
145 void MailMoveEvent P((void));\r
146 void EditTagsEvent P((void));\r
147 void GetMoveListEvent P((void));\r
148 void ExitAnalyzeMode P((void));\r
149 void AnalyzeModeEvent P((void));\r
150 void AnalyzeFileEvent P((void));\r
151 void DoEcho P((void));\r
152 void DontEcho P((void));\r
153 void TidyProgramName P((char *prog, char *host, char *buf));\r
154 void AskQuestionEvent P((char *title, char *question,\r
155                          char *replyPrefix, char *which));\r
156 Boolean ParseOneMove P((char *move, int moveNum,\r
157                         ChessMove *moveType, int *fromX, int *fromY,\r
158                         int *toX, int *toY, char *promoChar));\r
159 char *VariantName P((VariantClass v));\r
160 VariantClass StringToVariant P((char *e));\r
161 \r
162 char *StrStr P((char *string, char *match));\r
163 char *StrCaseStr P((char *string, char *match));\r
164 char *StrSave P((char *s));\r
165 char *StrSavePtr P((char *s, char **savePtr));\r
166 \r
167 #ifndef _amigados\r
168 int StrCaseCmp P((char *s1, char *s2));\r
169 int ToLower P((int c));\r
170 int ToUpper P((int c));\r
171 #else\r
172 #define StrCaseCmp Stricmp  /*  Use utility.library functions   */\r
173 #include <proto/utility.h>\r
174 #endif\r
175 \r
176 extern GameInfo gameInfo;\r
177 \r
178 \r
179 /* pgntags.c prototypes\r
180  */\r
181 char *PGNTags P((GameInfo *));\r
182 void PrintPGNTags P((FILE *f, GameInfo *));\r
183 int ParsePGNTag P((char *, GameInfo *));\r
184 char *PGNResult P((ChessMove result));\r
185 \r
186 \r
187 /* gamelist.c prototypes\r
188  */\r
189 /* A game node in the double linked list of games.\r
190  */\r
191 typedef struct _ListGame {\r
192     ListNode node;\r
193     int number;\r
194     unsigned long offset;   /*  Byte offset of game within file.     */\r
195     GameInfo gameInfo;      /*  Note that some entries may be NULL. */\r
196 } ListGame;\r
197  \r
198 extern List gameList;\r
199 void ClearGameInfo P((GameInfo *));\r
200 int GameListBuild P((FILE *));\r
201 void GameListInitGameInfo P((GameInfo *));\r
202 char *GameListLine P((int, GameInfo *));\r
203 char * GameListLineFull P(( int, GameInfo *));\r
204 \r
205 extern char* StripHighlight P((char *));  /* returns static data */\r
206 extern char* StripHighlightAndTitle P((char *));  /* returns static data */\r
207 \r
208 typedef struct _CPS {\r
209     char *which;\r
210     int maybeThinking;\r
211     ProcRef pr;\r
212     InputSourceRef isr;\r
213     char *twoMachinesColor; /* "white\n" or "black\n" */\r
214     char *program;\r
215     char *host;\r
216     char *dir;\r
217     struct _CPS *other;\r
218     char *initString;\r
219     char *computerString;\r
220     int sendTime; /* 0=don't, 1=do, 2=test */\r
221     int sendDrawOffers;\r
222     int useSigint;\r
223     int useSigterm;\r
224     int offeredDraw; /* countdown */\r
225     int reuse;\r
226     int useSetboard; /* 0=use "edit"; 1=use "setboard" */\r
227     int useSAN;      /* 0=use coordinate notation; 1=use SAN */\r
228     int usePing;     /* 0=not OK to use ping; 1=OK */\r
229     int lastPing;\r
230     int lastPong;\r
231     int usePlayother;/* 0=not OK to use playother; 1=OK */\r
232     int useColors;   /* 0=avoid obsolete white/black commands; 1=use them */\r
233     int useUsermove; /* 0=just send move; 1=send "usermove move" */\r
234     int sendICS;     /* 0=don't use "ics" command; 1=do */\r
235     int sendName;    /* 0=don't use "name" command; 1=do */\r
236     int sdKludge;    /* 0=use "sd DEPTH" command; 1=use "depth\nDEPTH" */\r
237     int stKludge;    /* 0=use "st TIME" command; 1=use "level 1 TIME" */\r
238     char tidy[MSG_SIZ];\r
239     int matchWins;\r
240     char variants[MSG_SIZ];\r
241     int analysisSupport;\r
242     int analyzing;\r
243     int protocolVersion;\r
244     int initDone;\r
245 \r
246     /* Added by Tord: */\r
247     int useFEN960;   /* 0=use "KQkq" style FENs, 1=use "HAha" style FENs */\r
248     int useOOCastle; /* 0="O-O" notation for castling, 1="king capture rook" notation */\r
249     /* End of additions by Tord */\r
250 \r
251     int scoreIsAbsolute; /* [AS] 0=don't know (standard), 1=score is always from white side */\r
252     int isUCI;           /* [AS] 0=no (Winboard), 1=UCI (requires Polyglot) */\r
253     int hasOwnBookUCI;   /* [AS] 0=use GUI or Polyglot book, 1=has own book */\r
254 \r
255     /* [HGM] time odds */\r
256     int timeOdds;   /* factor through which we divide time for this engine  */\r
257     int debug;      /* [HGM] ignore engine debug lines starting with '#'    */\r
258     int maxNrOfSessions; /* [HGM] secondary TC: max args in 'level' command */\r
259     int accumulateTC; /* [HGM] secondary TC: how to handle extra sessions   */\r
260     int nps;          /* [HGM] nps: factor for node count to replace time   */\r
261     int supportsNPS;\r
262 } ChessProgramState;\r
263 \r
264 extern ChessProgramState first, second;\r
265 \r
266 /* [AS] Search stats from chessprogram, for the played move */\r
267 typedef struct {\r
268     int score;  /* Centipawns */\r
269     int depth;  /* Plies */\r
270     int time;   /* Milliseconds */\r
271 } ChessProgramStats_Move;\r
272 \r
273 extern ChessProgramStats_Move pvInfoList[MAX_MOVES];\r
274 extern shuffleOpenings;\r
275 \r
276 #endif /* _BACKEND */\r