Initial checkin. I created this by combining the XBoard 4.2.6 and
[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
173 /* pgntags.c prototypes
174  */
175 char *PGNTags P((GameInfo *));
176 void PrintPGNTags P((FILE *f, GameInfo *));
177 int ParsePGNTag P((char *, GameInfo *));
178 char *PGNResult P((ChessMove result));
179
180
181 /* gamelist.c prototypes
182  */
183 /* A game node in the double linked list of games.
184  */
185 typedef struct _ListGame {
186     ListNode node;
187     int number;
188     unsigned long offset;   /*  Byte offset of game within file.     */
189     GameInfo gameInfo;      /*  Note that some entries may be NULL. */
190 } ListGame;
191  
192 extern List gameList;
193 void ClearGameInfo P((GameInfo *));
194 int GameListBuild P((FILE *));
195 void GameListInitGameInfo P((GameInfo *));
196 char *GameListLine P((int, GameInfo *));
197
198 extern char* StripHighlight P((char *));  /* returns static data */
199 extern char* StripHighlightAndTitle P((char *));  /* returns static data */
200
201
202 typedef struct _CPS {
203     char *which;
204     int maybeThinking;
205     ProcRef pr;
206     InputSourceRef isr;
207     char *twoMachinesColor; /* "white\n" or "black\n" */
208     char *program;
209     char *host;
210     char *dir;
211     struct _CPS *other;
212     char *initString;
213     char *computerString;
214     int sendTime; /* 0=don't, 1=do, 2=test */
215     int sendDrawOffers;
216     int useSigint;
217     int useSigterm;
218     int offeredDraw; /* countdown */
219     int reuse;
220     int useSetboard; /* 0=use "edit"; 1=use "setboard" */
221     int useSAN;      /* 0=use coordinate notation; 1=use SAN */
222     int usePing;     /* 0=not OK to use ping; 1=OK */
223     int lastPing;
224     int lastPong;
225     int usePlayother;/* 0=not OK to use playother; 1=OK */
226     int useColors;   /* 0=avoid obsolete white/black commands; 1=use them */
227     int useUsermove; /* 0=just send move; 1=send "usermove move" */
228     int sendICS;     /* 0=don't use "ics" command; 1=do */
229     int sendName;    /* 0=don't use "name" command; 1=do */
230     int sdKludge;    /* 0=use "sd DEPTH" command; 1=use "depth\nDEPTH" */
231     int stKludge;    /* 0=use "st TIME" command; 1=use "level 1 TIME" */
232     char tidy[MSG_SIZ];
233     int matchWins;
234     char variants[MSG_SIZ];
235     int analysisSupport;
236     int analyzing;
237     int protocolVersion;
238     int initDone;
239 } ChessProgramState;
240
241 extern ChessProgramState first, second;
242
243 #endif /* _BACKEND */