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);
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 bool gui_get_non_blocking(gui_t * gui, char string[], int size) {
63 if(io_line_ready(gui->io)){
64 gui_get(GUI,string,StringSize);
72 my_log("POLYGLOT *** EOF from GUI ***\n");
74 return true; // we never get here
75 }else if ((gui->io).GetBuffer(string)) {
76 my_log("GUI->Adapter: %s\n", string);
87 void gui_get(gui_t * gui, char string[], int size) {
91 my_log("POLYGLOT *** EOF from GUI ***\n");
94 (gui->io).LineInput(string);
95 my_log("GUI->Adapter: %s\n", string);
97 if (!io_get_line(gui->io,string,size)) { // EOF
98 my_log("POLYGLOT *** EOF from GUI ***\n");
107 void gui_send(gui_t * gui, const char format[], ...) {
110 char string[StringSize];
113 ASSERT(format!=NULL);
117 va_start(arg_list,format);
118 vsprintf(string,format,arg_list);
124 io_send(gui->io,"%s",string);
126 gui->io.LineOutput(string);
127 my_log("Adapter->GUI: %s\n",string);