#else\r
# include <pthread.h>\r
# include <signal.h>\r
+# include <unistd.h>\r
# define NO_ERROR 0\r
# include <sys/time.h>\r
int GetTickCount() // with thanks to Tord\r
#endif\r
#include <fcntl.h>\r
#include <string.h>\r
+#include <ctype.h>\r
\r
// Set VARIANTS for in WinBoard variant feature. (With -s option this will always be reset to use "shogi".)\r
#define VARIANTS ",normal,xiangqi"\r
case PAUSE: ReadFile(hRd, &c, 1, &d, NULL);\r
}\r
#else\r
- static int syncPipe[2]; char c;\r
+ static int syncPipe[2], res; char c;\r
switch(action) {\r
- case INIT: pipe(syncPipe); break;\r
- case WAKEUP: write(syncPipe[1], "\n", 1); break;\r
- case PAUSE: read(syncPipe[0], &c, 1);\r
+ case INIT: res = pipe(syncPipe); break;\r
+ case WAKEUP: res = write(syncPipe[1], "\n", 1); break;\r
+ case PAUSE: res = read(syncPipe[0], &c, 1);\r
}\r
+ if(res < 0) printf("tellusererror UCI2WB: bad sync pipe\n"), exit(0);\r
#endif\r
}\r
\r
char line[1024], command[256]; static char egts[999];\r
\r
while(1) {\r
- int i=0, x; char *p, dummy, len;\r
+ int i=0; char *p, dummy;\r
\r
fflush(stdout); fflush(toE);\r
if(fromF && !ReadLine(fromF, line)) fromF = 0, printf("# end fake\n");\r
char line[256], command[256], *p;\r
\r
while(1) {\r
- int i, difficult;\r
+ int difficult;\r
\r
for(difficult=0; !difficult; ) { // read and handle commands that can (or must) be handled during thinking\r
fflush(toE); fflush(stdout);\r
}\r
else if(!strcmp(command, "level")) {\r
int sec = 0;\r
- sscanf(line, "level %d %d:%d %d", &mps, &tc, &sec, &inc) == 4 ||\r
- sscanf(line, "level %d %d %d", &mps, &tc, &inc);\r
+ if(sscanf(line, "level %d %d:%d %d", &mps, &tc, &sec, &inc) != 4)\r
+ sscanf(line, "level %d %d %d", &mps, &tc, &inc);\r
tc = (60*tc + sec)*1000; inc *= 1000; sTime = 0; tc /= unit; inc /= unit;\r
}\r
else if(!strcmp(command, "protover")) {\r
}\r
else if(!strcmp(command, "setboard")) {\r
stm = (strstr(line+9, " b ") ? BLACK : WHITE);\r
- if((p = strchr(line+9, '[')) && !varOpt) { char c;\r
+ if((p = strchr(line+9, '[')) && !varOpt) {\r
*p++ = 0; q = strchr(p, ']'); *q = 0; r = q + 4; \r
if(sc == 's') q[2] = 'w' + 'b' - q[2], strcpy(r=q+3, " 1\n"); // Shogi: reverse color\r
else r = strchr(strchr(q+4, ' ') + 1, ' '); // skip to second space (after e.p. square)\r
int i, toEngine[2], fromEngine[2];\r
\r
if (dir && dir[0] && chdir(dir)) { perror(dir); exit(1); }\r
- pipe(toEngine); pipe(fromEngine); // create two pipes\r
+ i = pipe(toEngine) + pipe(fromEngine); // create two pipes\r
+ if(i < 0) printf("tellusererror UCI2WB: no engine pipe\n"), exit(0);\r
\r
if ((pid = fork()) == 0) { // Child\r
dup2(toEngine[0], 0); close(toEngine[0]); close(toEngine[1]); // stdin from toE pipe\r
return NO_ERROR;\r
}\r
\r
+int\r
main(int argc, char **argv)\r
{\r
- char *dir = NULL, *p, *q; int e;\r
+ char *dir = NULL;\r
\r
\r
if(argc == 2 && !strcmp(argv[1], "-v")) { printf("UCI2WB " VERSION " by H.G.Muller\n"); exit(0); }\r
\r
// handle GUI->engine traffic in original thread\r
GUI2Engine();\r
+ return 0;\r
}\r