64-bit constants need an ll, ull, i64, or ui64 suffix.
[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 /* unsigned int 64 for engine nodes work and display */
180 #ifdef WIN32
181         /* I don't know the name for this type of other compiler
182          * If it not work, just modify here
183          * This is for MS Visual Studio
184          */
185         #ifdef _MSC_VER
186                 #define u64 unsigned __int64
187                 #define s64 signed __int64
188                 #define u64Display "%I64u"
189                 #define s64Display "%I64d"
190                 #define u64Const(c) (c ## UI64)
191                 #define s64Const(c) (c ## I64)
192         #else
193                 /* place holder
194                  * or dummy types for other compiler
195                  */
196                 #define u64 unsigned __int64
197                 #define s64 signed __int64
198                 #define u64Display "%I64u"
199                 #define s64Display "%I64d"
200                 #define u64Const(c) (c ## UI64)
201                 #define s64Const(c) (c ## I64)
202         #endif
203 #else
204         /* GNU gcc */
205         #define u64 unsigned long long
206         #define s64 signed long long
207         #define u64Display "%llu"
208         #define s64Display "%lld"
209         #define u64Const(c) (c ## ull)
210         #define s64Const(c) (c ## ll)
211 #endif
212
213
214 /* pgntags.c prototypes
215  */
216 char *PGNTags P((GameInfo *));
217 void PrintPGNTags P((FILE *f, GameInfo *));
218 int ParsePGNTag P((char *, GameInfo *));
219 char *PGNResult P((ChessMove result));
220
221
222 /* gamelist.c prototypes
223  */
224 /* A game node in the double linked list of games.
225  */
226 typedef struct _ListGame {
227     ListNode node;
228     int number;
229     unsigned long offset;   /*  Byte offset of game within file.     */
230     GameInfo gameInfo;      /*  Note that some entries may be NULL. */
231 } ListGame;
232
233 extern List gameList;
234 void ClearGameInfo P((GameInfo *));
235 int GameListBuild P((FILE *));
236 void GameListInitGameInfo P((GameInfo *));
237 char *GameListLine P((int, GameInfo *));
238
239 extern char* StripHighlight P((char *));  /* returns static data */
240 extern char* StripHighlightAndTitle P((char *));  /* returns static data */
241
242
243 typedef struct _CPS {
244     char *which;
245     int maybeThinking;
246     ProcRef pr;
247     InputSourceRef isr;
248     char *twoMachinesColor; /* "white\n" or "black\n" */
249     char *program;
250     char *host;
251     char *dir;
252     struct _CPS *other;
253     char *initString;
254     char *computerString;
255     int sendTime; /* 0=don't, 1=do, 2=test */
256     int sendDrawOffers;
257     int useSigint;
258     int useSigterm;
259     int offeredDraw; /* countdown */
260     int reuse;
261     int useSetboard; /* 0=use "edit"; 1=use "setboard" */
262     int useSAN;      /* 0=use coordinate notation; 1=use SAN */
263     int usePing;     /* 0=not OK to use ping; 1=OK */
264     int lastPing;
265     int lastPong;
266     int usePlayother;/* 0=not OK to use playother; 1=OK */
267     int useColors;   /* 0=avoid obsolete white/black commands; 1=use them */
268     int useUsermove; /* 0=just send move; 1=send "usermove move" */
269     int sendICS;     /* 0=don't use "ics" command; 1=do */
270     int sendName;    /* 0=don't use "name" command; 1=do */
271     int sdKludge;    /* 0=use "sd DEPTH" command; 1=use "depth\nDEPTH" */
272     int stKludge;    /* 0=use "st TIME" command; 1=use "level 1 TIME" */
273     char tidy[MSG_SIZ];
274     int matchWins;
275     char variants[MSG_SIZ];
276     int analysisSupport;
277     int analyzing;
278     int protocolVersion;
279     int initDone;
280 } ChessProgramState;
281
282 extern ChessProgramState first, second;
283
284 #endif /* _BACKEND */