* ----------------------------------------------------------------------
* Copyright (c) 1993, 1994, 1995 Matthias Mutz
* Copyright (c) 1999 Michael Vanier and the Free Software Foundation
+ * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation
*
* GNU SHOGI is based on GNU CHESS
*
#include <sys/param.h>
#include <sys/types.h>
#include <sys/file.h>
+#ifndef WIN32
#include <poll.h>
#include <unistd.h>
+#endif
#include "gnushogi.h"
#include "rawdsp.h"
if (XSHOGI)
{
-#ifdef HAVE_SETLINEBUF
- setlinebuf(stdout);
+#ifdef WIN32
+ /* needed because of inconsistency between MSVC run-time system and gcc includes */
+ setbuf(stdout, NULL);
#else
-# ifdef HAVE_SETVBUF
+#ifdef HAVE_SETVBUF
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+#else
+# ifdef HAVE_SETLINEBUF
+ setlinebuf(stdout);
# else
-# error "Need setlinebuf() or setvbuf() to compile gnushogi!"
+# error "Need setvbuf() or setlinebuf() to compile gnushogi!"
# endif
#endif
- printf("GNU Shogi %sp%s\n", version, patchlevel);
+#endif
+ printf("GNU Shogi %s\n", PACKAGE_VERSION);
}
if (hard_time_limit)
Raw_help(void)
{
Raw_ClearScreen();
- printf("GNU Shogi %sp%s command summary\n", version, patchlevel);
+ printf("GNU Shogi %s command summary\n", PACKAGE_VERSION);
printf("----------------------------------"
"------------------------------\n");
fputs ("7g7f move from 7g to 7f quit Exit Shogi\n", stdout);
void
Raw_PollForInput(void)
{
+#ifdef WIN32
+ DWORD cnt;
+ if (!PeekNamedPipe(GetStdHandle(STD_INPUT_HANDLE), NULL, 0, NULL, &cnt, NULL))
+ cnt = 1;
+#else
static struct pollfd pollfds[1] = { /* [0] = */ { /* .fd = */ STDIN_FILENO,
/* .events = */ POLLIN } };
int cnt = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 0);
perror("polling standard input");
ExitShogi();
}
+#endif
if (cnt) { /* if anything to read, or error occured */
if (!flag.timeout)
flag.back = true; /* previous: flag.timeout = true; */