4 * Wrapper functions which call analogous functions in rawdsp.c
5 * or cursesdsp.c depending on the interface.
7 * ----------------------------------------------------------------------
8 * Copyright (c) 1993, 1994, 1995 Matthias Mutz
9 * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
10 * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation
12 * GNU SHOGI is based on GNU CHESS
14 * Copyright (c) 1988, 1989, 1990 John Stanback
15 * Copyright (c) 1992 Free Software Foundation
17 * This file is part of GNU SHOGI.
19 * GNU Shogi is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 3 of the License,
22 * or (at your option) any later version.
24 * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
25 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29 * You should have received a copy of the GNU General Public License along
30 * with GNU Shogi; see the file COPYING. If not, see
31 * <http://www.gnu.org/licenses/>.
32 * ----------------------------------------------------------------------
36 /* request *snprintf prototypes*/
37 #define _POSIX_C_SOURCE 200112L
40 #include "dspwrappers.h"
42 #include "cursesdsp.h"
46 #define CASE_DSP_RAW(func,args) \
53 #define CASE_DSP_CURSES(func,args) \
54 case DISPLAY_CURSES: \
58 #define CASE_DSP_CURSES(func,args)
61 #define DISPLAY_FUNC(func,argsdecl,args) \
64 switch (display_type) { \
65 CASE_DSP_RAW(Raw_ ## func, args); \
66 CASE_DSP_CURSES(Curses_ ## func, args); \
69 #define DISPLAY_VOIDFUNC(func) \
70 DISPLAY_FUNC(func,(void),())
72 #define DISPLAY_STDARGFUNC(func,argsdecl,last,args) \
77 switch (display_type) { \
78 CASE_DSP_RAW(Raw_ ## func, args); \
79 CASE_DSP_CURSES(Curses_ ## func, args); \
84 DISPLAY_VOIDFUNC(ChangeAlphaWindow
)
85 DISPLAY_VOIDFUNC(ChangeBetaWindow
)
86 DISPLAY_VOIDFUNC(ChangeHashDepth
)
87 DISPLAY_VOIDFUNC(ChangeSearchDepth
)
88 DISPLAY_VOIDFUNC(ChangeXwindow
)
89 DISPLAY_VOIDFUNC(ClearScreen
)
90 DISPLAY_VOIDFUNC(DoDebug
)
91 DISPLAY_FUNC(DoTable
, (short table
[NO_SQUARES
]), (table
))
92 DISPLAY_VOIDFUNC(EditBoard
)
93 DISPLAY_VOIDFUNC(ExitShogi
)
94 DISPLAY_VOIDFUNC(GiveHint
)
95 DISPLAY_VOIDFUNC(Initialize
)
96 DISPLAY_FUNC(ShowNodeCnt
, (long NodeCnt
), (NodeCnt
))
97 DISPLAY_VOIDFUNC(OutputMove
)
98 DISPLAY_VOIDFUNC(PollForInput
)
99 DISPLAY_VOIDFUNC(SetContempt
)
100 DISPLAY_FUNC(SearchStartStuff
, (short side
), (side
))
101 DISPLAY_FUNC(SelectLevel
, (char *sx
), (sx
))
102 DISPLAY_VOIDFUNC(SetupBoard
)
103 DISPLAY_FUNC(ShowCurrentMove
, (short pnt
, short f
, short t
), (pnt
, f
, t
))
104 DISPLAY_FUNC(ShowDepth
, (char ch
), (ch
))
105 DISPLAY_VOIDFUNC(ShowGameType
)
106 DISPLAY_FUNC(ShowLine
, (unsigned short *bstline
), (bstline
))
107 DISPLAY_FUNC(ShowMessage
, (char *s
), (s
))
108 DISPLAY_STDARGFUNC(AlwaysShowMessage
, (const char *format
, ...), format
, (format
, ap
))
109 DISPLAY_STDARGFUNC(Printf
, (const char *format
, ...), format
, (format
, ap
))
110 DISPLAY_FUNC(ShowPatternCount
, (short side
, short n
), (side
, n
))
111 DISPLAY_FUNC(ShowPostnValue
, (short sq
), (sq
))
112 DISPLAY_VOIDFUNC(ShowPostnValues
)
113 DISPLAY_VOIDFUNC(ShowPrompt
)
114 DISPLAY_VOIDFUNC(ShowResponseTime
)
115 DISPLAY_FUNC(ShowResults
, (short score
, unsigned short *bstline
, char ch
), (score
, bstline
, ch
))
116 DISPLAY_VOIDFUNC(ShowSidetoMove
)
117 DISPLAY_VOIDFUNC(ShowStage
)
118 DISPLAY_FUNC(TerminateSearch
, (int sig
), (sig
))
119 DISPLAY_VOIDFUNC(UpdateClocks
)
120 DISPLAY_FUNC(UpdateDisplay
, (short f
, short t
, short redraw
, short isspec
), (f
, t
, redraw
, isspec
))
121 DISPLAY_VOIDFUNC(help
)
123 DISPLAY_FUNC(doRequestInputString
, (const char* fmt
, char* buffer
), (fmt
, buffer
))
124 void RequestInputString(char* buffer
, unsigned bufsize
)
127 int ret
= snprintf(fmt
, sizeof(fmt
), "%%%us", bufsize
);
128 if (ret
>= sizeof(fmt
)) {
130 "Insufficient format-buffer size in %s for bufsize=%u\n",
131 __FUNCTION__
, bufsize
);
134 doRequestInputString(fmt
, buffer
);
139 #define CASE_DSPFUNC_RAW(func,args) \
142 return (func args); \
145 #ifdef HAVE_LIBCURSES
146 #define CASE_DSPFUNC_CURSES(func,args) \
147 case DISPLAY_CURSES: \
148 return (func args); \
151 #define CASE_DSPFUNC_CURSES(func,args)
154 #define DISPLAY_INTFUNC(func,argsdecl,args) \
157 switch (display_type) { \
158 CASE_DSPFUNC_RAW(Raw_ ## func, args); \
159 CASE_DSPFUNC_CURSES(Curses_ ## func, args); \
164 DISPLAY_INTFUNC(GetString
, (char* sx
), (sx
))