Make engine loadable during session
[xboard.git] / frontend.h
1 /*
2  * frontend.h -- Interface exported by all XBoard front ends
3  *
4  * Copyright 1991 by Digital Equipment Corporation, Maynard,
5  * Massachusetts.
6  *
7  * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
8  * 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
9  *
10  * Enhancements Copyright 2005 Alessandro Scotti
11  *
12  * The following terms apply to Digital Equipment Corporation's copyright
13  * interest in XBoard:
14  * ------------------------------------------------------------------------
15  * All Rights Reserved
16  *
17  * Permission to use, copy, modify, and distribute this software and its
18  * documentation for any purpose and without fee is hereby granted,
19  * provided that the above copyright notice appear in all copies and that
20  * both that copyright notice and this permission notice appear in
21  * supporting documentation, and that the name of Digital not be
22  * used in advertising or publicity pertaining to distribution of the
23  * software without specific, written prior permission.
24  *
25  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
26  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
27  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
28  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
29  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
30  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
31  * SOFTWARE.
32  * ------------------------------------------------------------------------
33  *
34  * The following terms apply to the enhanced version of XBoard
35  * distributed by the Free Software Foundation:
36  * ------------------------------------------------------------------------
37  *
38  * GNU XBoard is free software: you can redistribute it and/or modify
39  * it under the terms of the GNU General Public License as published by
40  * the Free Software Foundation, either version 3 of the License, or (at
41  * your option) any later version.
42  *
43  * GNU XBoard is distributed in the hope that it will be useful, but
44  * WITHOUT ANY WARRANTY; without even the implied warranty of
45  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
46  * General Public License for more details.
47  *
48  * You should have received a copy of the GNU General Public License
49  * along with this program. If not, see http://www.gnu.org/licenses/.  *
50  *
51  *------------------------------------------------------------------------
52  ** See the file ChangeLog for a revision history.  */
53
54 #ifndef _FRONTEND
55 #define _FRONTEND
56
57 #include <stdio.h>
58
59 typedef VOIDSTAR ProcRef;
60 #define NoProc ((ProcRef) 0)
61 typedef VOIDSTAR InputSourceRef;
62
63 char *T_ P((char *s));
64 void ModeHighlight P((void));
65 void SetICSMode P((void));
66 void SetGNUMode P((void));
67 void SetNCPMode P((void));
68 void SetCmailMode P((void));
69 void SetTrainingModeOn P((void));
70 void SetTrainingModeOff P((void));
71 void SetUserThinkingEnables P((void));
72 void SetMachineThinkingEnables P((void));
73 void DisplayTitle P((String title));
74 void DisplayMessage P((String message, String extMessage));
75 void DisplayError P((String message, int error));
76 void DisplayMoveError P((String message));
77
78 /* If status == 0, we are exiting with a benign message, not an error */
79 void DisplayFatalError P((String message, int error, int status));
80
81 void DisplayInformation P((String message));
82 void DisplayNote P((String message));
83 void AskQuestion P((String title, String question, String replyPrefix,
84                     ProcRef pr));
85 void DisplayIcsInteractionTitle P((String title));
86 void ParseArgsFromString P((char *p));
87 void DrawPosition P((int fullRedraw, Board board));
88 void ResetFrontEnd P((void));
89 void NotifyFrontendLogin P((void));
90 void CommentPopUp P((String title, String comment));
91 void CommentPopDown P((void));
92 void EditCommentPopUp P((int index, String title, String text));
93 void ErrorPopDown P((void));
94 int  EventToSquare P((int x, int limit));
95 void DrawSeekAxis P(( int x, int y, int xTo, int yTo ));
96 void DrawSeekBackground P(( int left, int top, int right, int bottom ));
97 void DrawSeekText P((char *buf, int x, int y));
98 void DrawSeekDot P((int x, int y, int color));
99 void PopUpMoveDialog P((char first));
100
101 void RingBell P((void));
102 void PlayIcsWinSound P((void));
103 void PlayIcsLossSound P((void));
104 void PlayIcsDrawSound P((void));
105 void PlayIcsUnfinishedSound P((void));
106 void PlayAlarmSound P((void));
107 void EchoOn P((void));
108 void EchoOff P((void));
109 void Raw P((void));
110 void Colorize P((ColorClass cc, int continuation));
111
112 char *UserName P((void));
113 char *HostName P((void));
114
115 int ClockTimerRunning P((void));
116 int StopClockTimer P((void));
117 void StartClockTimer P((long millisec));
118 void DisplayWhiteClock P((long timeRemaining, int highlight));
119 void DisplayBlackClock P((long timeRemaining, int highlight));
120
121 int LoadGameTimerRunning P((void));
122 int StopLoadGameTimer P((void));
123 void StartLoadGameTimer P((long millisec));
124 void AutoSaveGame P((void));
125
126 typedef void (*DelayedEventCallback) P((void));
127 void ScheduleDelayedEvent P((DelayedEventCallback cb, long millisec));
128 DelayedEventCallback GetDelayedEvent P((void));
129 void CancelDelayedEvent P((void));
130 // [HGM] mouse: next six used by mouse handler, which was moved to backend
131 extern int fromX, fromY, toX, toY;
132 typedef enum { Press, Release } ClickType;
133 void PromotionPopUp P((void));
134 void DragPieceBegin P((int x, int y));
135 void DragPieceEnd P((int x, int y));
136 void LeftClick P((ClickType c, int x, int y));
137 int  RightClick P((ClickType c, int x, int y, int *col, int *row));
138
139 int StartChildProcess P((char *cmdLine, char *dir, ProcRef *pr));
140 void DestroyChildProcess P((ProcRef pr, int/*boolean*/ signal));
141 void InterruptChildProcess P((ProcRef pr));
142
143 int OpenTelnet P((char *host, char *port, ProcRef *pr));
144 int OpenTCP P((char *host, char *port, ProcRef *pr));
145 int OpenCommPort P((char *name, ProcRef *pr));
146 int OpenLoopback P((ProcRef *pr));
147 int OpenRcmd P((char *host, char *user, char *cmd, ProcRef *pr));
148
149 typedef void (*InputCallback) P((InputSourceRef isr, VOIDSTAR closure,
150                                  char *buf, int count, int error));
151 /* pr == NoProc means the local keyboard */
152 InputSourceRef AddInputSource P((ProcRef pr, int lineByLine,
153                                  InputCallback func, VOIDSTAR closure));
154 void RemoveInputSource P((InputSourceRef isr));
155
156 /* pr == NoProc means the local display */
157 int OutputToProcess P((ProcRef pr, char *message, int count, int *outError));
158 int OutputToProcessDelayed P((ProcRef pr, char *message, int count,
159                               int *outError, long msdelay));
160
161 void CmailSigHandlerCallBack P((InputSourceRef isr, VOIDSTAR closure,
162                                 char *buf, int count, int error));
163
164 extern ProcRef cmailPR;
165 extern int shiftKey;
166
167 /* in xgamelist.c or winboard.c */
168 void GLT_ClearList();
169 void GLT_DeSelectList();
170 void GLT_AddToList( char *name );
171 Boolean GLT_GetFromList( int index, char *name );
172
173 extern char lpUserGLT[];
174
175 /* these are in wgamelist.c */
176 void GameListPopUp P((FILE *fp, char *filename));
177 void GameListPopDown P((void));
178 void GameListHighlight P((int index));
179 void GameListDestroy P((void));
180
181 /* these are in wedittags.c */
182 void EditTagsPopUp P((char *tags, char **dest));
183 void TagsPopUp P((char *tags, char *msg));
184 void TagsPopDown P((void));
185
186 void ICSInitScript P((void));
187 void StartAnalysisClock P((void));
188 void EngineOutputPopUp P((void));
189 void EgineOutputPopDown P((void));
190
191 void SetHighlights P((int fromX, int fromY, int toX, int toY));
192 void ClearHighlights P((void));
193 void SetPremoveHighlights P((int fromX, int fromY, int toX, int toY));
194 void ClearPremoveHighlights P((void));
195
196 void AnimateAtomicCapture P((Board board, int fromX, int fromY, int toX, int toY));
197 void ShutDownFrontEnd P((void));
198 void BoardToTop P((void));
199 void AnimateMove P((Board board, int fromX, int fromY, int toX, int toY));
200 void HistorySet P((char movelist[][2*MOVE_LEN], int first, int last, int current));
201 void FreezeUI P((void));
202 void ThawUI P((void));
203 void ChangeDragPiece P((ChessSquare piece));
204 extern char *programName;
205 extern int commentUp;
206
207 void GreyRevert P((Boolean grey));
208
209 typedef struct FrontEndProgramStats_TAG {
210     int which;
211     int depth;
212     unsigned long nodes;
213     int score;
214     int time;
215     char * pv;
216     char * hint;
217     int an_move_index;
218     int an_move_count;
219 } FrontEndProgramStats;
220
221 void SetProgramStats P(( FrontEndProgramStats * stats )); /* [AS] */
222
223 void EngineOutputPopUp P((void));
224 void EngineOutputPopDown P((void));
225 int  EngineOutputIsUp P((void));
226 int  EngineOutputDialogExists P((void));
227 void EvalGraphPopUp P((void));
228 void EvalGraphPopDown P((void));
229 Boolean EvalGraphIsUp P((void));
230 int  EvalGraphDialogExists P((void));
231
232 /* these are in xhistory.c  */
233 Boolean MoveHistoryIsUp P((void));
234 void HistoryPopUp P((void));
235
236 #endif