13 static const int StringSize = 4096;
23 static void sig_quit(int dummy){
24 my_log("POLYGLOT *** SIGINT Received ***\n");
31 void gui_init(gui_t *gui){
33 // the following is nice if the "GUI" is a console!
34 signal(SIGINT,sig_quit);
36 signal(SIGTERM,SIG_IGN);
38 signal(SIGPIPE,SIG_IGN);
43 (gui->pipeStdin).Open();
46 gui->io->in_fd = STDIN_FILENO;
47 gui->io->out_fd = STDOUT_FILENO;
48 gui->io->name = "GUI";
55 // gui_get_non_blocking()
57 // this is only non_blocking on windows!
59 bool gui_get_non_blocking(gui_t * gui, char string[], int size) {
65 if (!io_get_line(gui->io,string,size)) { // EOF
66 my_log("POLYGLOT *** EOF from GUI ***\n");
71 if ((gui->pipeStdin).LineInput(string)) {
72 my_log("GUI->Adapter: %s\n", string);
84 void gui_get(gui_t * gui, char string[], int size) {
87 data_available=gui_get_non_blocking(gui, string, size);
99 void gui_send(gui_t * gui, const char format[], ...) {
102 char string[StringSize];
105 ASSERT(format!=NULL);
109 va_start(arg_list,format);
110 vsprintf(string,format,arg_list);
116 io_send(gui->io,"%s",string);
118 printf("%s\n",string);
120 my_log("Adapter->GUI: %s\n",string);