5 static const int StringSize = 4096;
\r
18 #include "xboard2uci.h"
\r
19 #include "uci2uci.h"
\r
23 static void mainloop_init ();
\r
24 static void mainloop_wait_for_event ();
\r
25 static void mainloop_engine_step(char * string);
\r
26 static void mainloop_gui_step(char * string);
\r
32 static void mainloop_init(){
\r
33 if(!option_get_bool("UCI")){
\r
34 xboard2uci_init(); // the default
\r
38 // mainloop_engine_step()
\r
40 static void mainloop_engine_step(char * string){
\r
41 if(option_get_bool("UCI")){
\r
42 uci2uci_engine_step(string);
\r
44 xboard2uci_engine_step(string);
\r
48 // mainloop_gui_step()
\r
50 static void mainloop_gui_step(char * string){
\r
51 if(option_get_bool("UCI")){
\r
52 uci2uci_gui_step(string);
\r
53 }else if(my_string_equal(string,"uci")){ // mode auto detection
\r
54 my_log("POLYGLOT *** Switching to UCI mode ***\n");
\r
55 option_set("UCI","TRUE");
\r
56 uci2uci_gui_step(string);
\r
58 xboard2uci_gui_step(string);
\r
65 char string[StringSize];
\r
67 while (!engine_eof(Engine)) {
\r
68 // process buffered lines
\r
70 if(gui_get_non_blocking(GUI,string)){
\r
71 mainloop_gui_step(string);
\r
72 }else if(!engine_eof(Engine) &&
\r
73 engine_get_non_blocking(Engine,string) ){
\r
74 mainloop_engine_step(string);
\r
79 mainloop_wait_for_event();
\r
81 my_log("POLYGLOT *** Mainloop has ended ***\n");
\r
82 // This should be handled better.
\r
83 engine_close(Engine);
\r
84 my_log("POLYGLOT Calling exit\n");
\r
92 // mainloop_wait_for_event()
\r
94 static void mainloop_wait_for_event(){
\r
96 pipex[0]=GUI->pipex;
\r
97 pipex[1]=Engine->pipex;
\r
99 pipex_wait_event(pipex);
\r