X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fdspwrappers.c;h=cd7c3da62739ca710e2705e4ff9e30bf408c45db;hb=8b72032924de9040facee8d8923536541a6b9390;hp=10b06b45a0d1f8e745d5a45a2d7e42cdeef8e127;hpb=1be442641b610fa1b6172a38d9acffe2d22797b6;p=gnushogi.git diff --git a/gnushogi/dspwrappers.c b/gnushogi/dspwrappers.c index 10b06b4..cd7c3da 100644 --- a/gnushogi/dspwrappers.c +++ b/gnushogi/dspwrappers.c @@ -38,6 +38,7 @@ #include "cursesdsp.h" #include +#include #define CASE_DSP_RAW(func,args) \ case DISPLAY_RAW: \ @@ -85,10 +86,12 @@ DISPLAY_VOIDFUNC(ChangeXwindow) DISPLAY_VOIDFUNC(ClearScreen) DISPLAY_VOIDFUNC(DoDebug) DISPLAY_FUNC(DoTable, (short table[NO_SQUARES]), (table)) +DISPLAY_FUNC(ElapsedTime, (ElapsedTime_mode iop), (iop)) DISPLAY_VOIDFUNC(EditBoard) DISPLAY_VOIDFUNC(ExitShogi) DISPLAY_VOIDFUNC(GiveHint) DISPLAY_VOIDFUNC(Initialize) +DISPLAY_FUNC(ShowNodeCnt, (long NodeCnt), (NodeCnt)) DISPLAY_VOIDFUNC(OutputMove) DISPLAY_VOIDFUNC(SetContempt) DISPLAY_FUNC(SearchStartStuff, (short side), (side)) @@ -98,11 +101,12 @@ DISPLAY_FUNC(ShowDepth, (char ch), (ch)) DISPLAY_VOIDFUNC(ShowGameType) DISPLAY_FUNC(ShowLine, (unsigned short *bstline), (bstline)) DISPLAY_FUNC(ShowMessage, (char *s), (s)) +DISPLAY_STDARGFUNC(AlwaysShowMessage, (const char *format, ...), format, (format, ap)) DISPLAY_STDARGFUNC(Printf, (const char *format, ...), format, (format, ap)) -DISPLAY_FUNC(RequestInputString, (char* buffer), (buffer)) DISPLAY_FUNC(ShowPatternCount, (short side, short n), (side, n)) DISPLAY_FUNC(ShowPostnValue, (short sq), (sq)) DISPLAY_VOIDFUNC(ShowPostnValues) +DISPLAY_VOIDFUNC(ShowPrompt) DISPLAY_VOIDFUNC(ShowResponseTime) DISPLAY_FUNC(ShowResults, (short score, unsigned short *bstline, char ch), (score, bstline, ch)) DISPLAY_VOIDFUNC(ShowSidetoMove) @@ -110,3 +114,46 @@ DISPLAY_VOIDFUNC(ShowStage) DISPLAY_FUNC(TerminateSearch, (int sig), (sig)) DISPLAY_FUNC(UpdateDisplay, (short f, short t, short redraw, short isspec), (f, t, redraw, isspec)) DISPLAY_VOIDFUNC(help) + +DISPLAY_FUNC(doRequestInputString, (const char* fmt, char* buffer), (fmt, buffer)) +void RequestInputString(char* buffer, unsigned bufsize) +{ + static char fmt[10]; + int ret = snprintf(fmt, sizeof(fmt), "%%%us", bufsize); + if (ret >= sizeof(fmt)) { + fprintf(stderr, + "Insufficient format-buffer size in %s for bufsize=%u\n", + __FUNCTION__, bufsize); + exit(1); + } + doRequestInputString(fmt, buffer); +} + +/*********/ + +#define CASE_DSPFUNC_RAW(func,args) \ + case DISPLAY_RAW: \ + case DISPLAY_X: \ + return (func args); \ + break + +#ifdef HAVE_LIBCURSES +#define CASE_DSPFUNC_CURSES(func,args) \ + case DISPLAY_CURSES: \ + return (func args); \ + break; +#else +#define CASE_DSPFUNC_CURSES(func,args) +#endif + +#define DISPLAY_INTFUNC(func,argsdecl,args) \ + int func argsdecl \ + { \ + switch (display_type) { \ + CASE_DSPFUNC_RAW(Raw_ ## func, args); \ + CASE_DSPFUNC_CURSES(Curses_ ## func, args); \ + } \ + assert(0); \ + } + +DISPLAY_INTFUNC(GetString, (char* sx), (sx))