better init for random number generator
[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 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 void ModeHighlight P((void));
64 void SetICSMode P((void));
65 void SetGNUMode P((void));
66 void SetNCPMode P((void));
67 void SetCmailMode P((void));
68 void SetTrainingModeOn P((void));
69 void SetTrainingModeOff P((void));
70 void SetUserThinkingEnables P((void));
71 void SetMachineThinkingEnables P((void));
72 void DisplayTitle P((String title));
73 void DisplayMessage P((String message, String extMessage));
74 void DisplayError P((String message, int error));
75 void DisplayMoveError P((String message));
76
77 /* If status == 0, we are exiting with a benign message, not an error */
78 void DisplayFatalError P((String message, int error, int status));
79
80 void DisplayInformation P((String message));
81 void DisplayNote P((String message));
82 void AskQuestion P((String title, String question, String replyPrefix,
83                     ProcRef pr));
84 void DisplayIcsInteractionTitle P((String title));
85 void DrawPosition P((int fullRedraw, Board board));
86 void ResetFrontEnd P((void));
87 void NotifyFrontendLogin P((void));
88 void CommentPopUp P((String title, String comment));
89 void CommentPopDown P((void));
90 void EditCommentPopUp P((int index, String title, String text));
91
92 void RingBell P((void));
93 void PlayIcsWinSound P((void));
94 void PlayIcsLossSound P((void));
95 void PlayIcsDrawSound P((void));
96 void PlayIcsUnfinishedSound P((void));
97 void PlayAlarmSound P((void));
98 void EchoOn P((void));
99 void EchoOff P((void));
100 void Raw P((void));
101 void Colorize P((ColorClass cc, int continuation));
102
103 char *UserName P((void));
104 char *HostName P((void));
105
106 int ClockTimerRunning P((void));
107 int StopClockTimer P((void));
108 void StartClockTimer P((long millisec));
109 void DisplayWhiteClock P((long timeRemaining, int highlight));
110 void DisplayBlackClock P((long timeRemaining, int highlight));
111
112 int LoadGameTimerRunning P((void));
113 int StopLoadGameTimer P((void));
114 void StartLoadGameTimer P((long millisec));
115 void AutoSaveGame P((void));
116
117 typedef void (*DelayedEventCallback) P((void));
118 void ScheduleDelayedEvent P((DelayedEventCallback cb, long millisec));
119 DelayedEventCallback GetDelayedEvent P((void));
120 void CancelDelayedEvent P((void));
121 // [HGM] mouse: next six used by mouse handler, which was moved to backend
122 extern int fromX, fromY, toX, toY;
123 typedef enum { Press, Release } ClickType;
124 void PromotionPopUp P((void));
125 void DragPieceBegin P((int x, int y));
126 void DragPieceEnd P((int x, int y));
127 void LeftClick P((ClickType c, int x, int y));
128
129 int StartChildProcess P((char *cmdLine, char *dir, ProcRef *pr));
130 void DestroyChildProcess P((ProcRef pr, int/*boolean*/ signal));
131 void InterruptChildProcess P((ProcRef pr));
132
133 int OpenTelnet P((char *host, char *port, ProcRef *pr));
134 int OpenTCP P((char *host, char *port, ProcRef *pr));
135 int OpenCommPort P((char *name, ProcRef *pr));
136 int OpenLoopback P((ProcRef *pr));
137 int OpenRcmd P((char *host, char *user, char *cmd, ProcRef *pr));
138
139 typedef void (*InputCallback) P((InputSourceRef isr, VOIDSTAR closure,
140                                  char *buf, int count, int error));
141 /* pr == NoProc means the local keyboard */
142 InputSourceRef AddInputSource P((ProcRef pr, int lineByLine,
143                                  InputCallback func, VOIDSTAR closure));
144 void RemoveInputSource P((InputSourceRef isr));
145
146 /* pr == NoProc means the local display */
147 int OutputToProcess P((ProcRef pr, char *message, int count, int *outError));
148 int OutputToProcessDelayed P((ProcRef pr, char *message, int count,
149                               int *outError, long msdelay));
150
151 void CmailSigHandlerCallBack P((InputSourceRef isr, VOIDSTAR closure,
152                                 char *buf, int count, int error));
153
154 extern ProcRef cmailPR;
155
156 /* these are in wgamelist.c */
157 void GameListPopUp P((FILE *fp, char *filename));
158 void GameListPopDown P((void));
159 void GameListHighlight P((int index));
160 void GameListDestroy P((void));
161
162 /* these are in wedittags.c */
163 void EditTagsPopUp P((char *tags));
164 void TagsPopUp P((char *tags, char *msg));
165 void TagsPopDown P((void));
166
167 void ICSInitScript P((void));
168 void StartAnalysisClock P((void));
169 void EngineOutputPopUp P((void));
170 void EgineOutputPopDown P((void));
171
172 void SetHighlights P((int fromX, int fromY, int toX, int toY));
173 void ClearHighlights P((void));
174 void SetPremoveHighlights P((int fromX, int fromY, int toX, int toY));
175 void ClearPremoveHighlights P((void));
176
177 void ShutDownFrontEnd P((void));
178 void BoardToTop P((void));
179 void AnimateMove P((Board board, int fromX, int fromY, int toX, int toY));
180 void HistorySet P((char movelist[][2*MOVE_LEN], int first, int last, int current));
181 void FreezeUI P((void));
182 void ThawUI P((void));
183 extern char *programName;
184
185 typedef struct FrontEndProgramStats_TAG {
186     int which;
187     int depth;
188     unsigned long nodes;
189     int score;
190     int time;
191     char * pv;
192     char * hint;
193     int an_move_index;
194     int an_move_count;
195 } FrontEndProgramStats;
196
197 void SetProgramStats P(( FrontEndProgramStats * stats )); /* [AS] */
198
199 #endif