X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fdspwrappers.c;h=382c43878bcb7a908958cb9e4e291b679ab238fe;hb=3f589711eb3ecc7644378d6a0f2f29bc4b4c7db9;hp=0a27ec0defa30b3fe7e0367b7d215a2c4683e765;hpb=3798317748e880b96d230bae0922d0e9c4b8d864;p=gnushogi.git diff --git a/gnushogi/dspwrappers.c b/gnushogi/dspwrappers.c index 0a27ec0..382c438 100644 --- a/gnushogi/dspwrappers.c +++ b/gnushogi/dspwrappers.c @@ -37,15 +37,23 @@ #include "rawdsp.h" #include "cursesdsp.h" +#include +#include + #define CASE_DSP_RAW(func,args) \ case DISPLAY_RAW: \ case DISPLAY_X: \ func args; \ break + +#ifdef HAVE_LIBCURSES #define CASE_DSP_CURSES(func,args) \ case DISPLAY_CURSES: \ func args; \ break; +#else +#define CASE_DSP_CURSES(func,args) +#endif #define DISPLAY_FUNC(func,argsdecl,args) \ void func argsdecl \ @@ -58,6 +66,18 @@ #define DISPLAY_VOIDFUNC(func) \ DISPLAY_FUNC(func,(void),()) +#define DISPLAY_STDARGFUNC(func,argsdecl,last,args) \ + void func argsdecl \ + { \ + va_list ap; \ + va_start(ap, last); \ + switch (display_type) { \ + CASE_DSP_RAW(Raw_ ## func, args); \ + CASE_DSP_CURSES(Curses_ ## func, args); \ + } \ + va_end(ap); \ + } + DISPLAY_VOIDFUNC(ChangeAlphaWindow) DISPLAY_VOIDFUNC(ChangeBetaWindow) DISPLAY_VOIDFUNC(ChangeHashDepth) @@ -70,6 +90,7 @@ 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)) @@ -79,6 +100,8 @@ 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(ShowPatternCount, (short side, short n), (side, n)) DISPLAY_FUNC(ShowPostnValue, (short sq), (sq)) DISPLAY_VOIDFUNC(ShowPostnValues) @@ -89,3 +112,17 @@ 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); +}