27 if (strcmp(ui_type,
"edax") == 0) {
33 }
else if (strcmp(ui_type,
"gtp") == 0) {
39 }
else if (strcmp(ui_type,
"nboard") == 0) {
45 }
else if (strcmp(ui_type,
"xboard") == 0) {
51 }
else if (strcmp(ui_type,
"ggs") == 0) {
57 }
else if (strcmp(ui_type,
"cassio") == 0) {
84 if (errno == EINTR) clearerr(stdin);
86 }
else if (feof(stdin)) {
94 if (strcmp(cmd,
"stop") == 0) {
99 }
else if (ui->
type ==
UI_NBOARD && strcmp(cmd,
"ping") == 0) {
104 if (strcmp(cmd,
"quit") == 0 || strcmp(cmd,
"q") == 0) {
115 condition_signal(event);
130 while (ui->
event->
loop && !feof(stdin) && !ferror(stdin)) {
134 info(
"<exit ui_read_input>\n");
150 if (
options.
echo && *cmd) printf(
" %s %s\n", *cmd, *param ? *param :
"");
167 free(*cmd); *cmd = NULL;
168 free(*param); *param = NULL;
171 *cmd = (
char*) malloc(n + 1);
172 *param = (
char*) malloc(n + 1);
193 spin_lock(ui->
event);
195 spin_unlock(ui->
event);
@ UI_EDAX
Definition const.h:110
@ UI_GGS
Definition const.h:111
@ UI_NBOARD
Definition const.h:113
@ UI_CASSIO
Definition const.h:109
@ UI_GTP
Definition const.h:112
@ UI_XBOARD
Definition const.h:114
void ui_loop_edax(UI *ui)
Loop event.
Definition edax.c:284
void ui_init_edax(UI *ui)
initialize edax protocol.
Definition edax.c:137
void ui_free_edax(UI *ui)
free resources used by edax protocol.
Definition edax.c:157
void event_clear_messages(Event *event)
Remove all unprocessed messages.
Definition event.c:45
bool event_exist(Event *event)
Check if there is a message.
Definition event.c:176
void event_init(Event *event)
Initialize a message event.
Definition event.c:23
void event_wait(Event *event, char **cmd, char **param)
Wait input.
Definition event.c:133
void event_free(Event *event)
Free a message event.
Definition event.c:67
void event_add_message(Event *event, char *message)
Add a new message at the bottom of the list.
Definition event.c:93
char * event_peek_message(Event *event)
Peek the first message from the list.
Definition event.c:187
void ui_free_ggs(UI *ui)
ui_free_ggs
Definition ggs.c:1599
void ui_loop_ggs(UI *ui)
ui_loop_ggs
Definition ggs.c:1418
void ui_init_ggs(UI *ui)
ui_init_ggs
Definition ggs.c:1390
void ui_init_gtp(UI *ui)
initialize edax protocol
Definition gtp.c:93
void ui_loop_gtp(UI *ui)
Loop event.
Definition gtp.c:127
void ui_free_gtp(UI *ui)
free resources used by edax protocol
Definition gtp.c:115
void ui_loop_nboard(UI *ui)
Loop event.
Definition nboard.c:113
void ui_init_nboard(UI *ui)
initialize edax protocol
Definition nboard.c:80
void ui_free_nboard(UI *ui)
free resources used by edax protocol
Definition nboard.c:101
Options options
Definition options.c:22
void play_stop(Play *play)
Stop thinking.
Definition play.c:769
Thread thread
Definition event.h:24
volatile bool loop
Definition event.h:19
bool echo
Definition options.h:35
Event event[1]
Definition ui.h:38
int type
Definition ui.h:36
Play play[2]
Definition ui.h:32
void(* init)(struct UI *)
Definition ui.h:40
void(* loop)(struct UI *)
Definition ui.h:41
void(* free)(struct UI *)
Definition ui.h:42
static void ui_read_input(UI *ui)
Get an event.
Definition ui.c:73
void ui_event_init(UI *ui)
Create a new Othello User Interface.
Definition ui.c:206
bool ui_switch(UI *ui, const char *ui_type)
Switch between different User Interface.
Definition ui.c:25
void gtp_preprocess(char *line)
Definition gtp.c:34
bool ui_event_exist(UI *ui)
ui_event_exist
Definition ui.c:189
static void * ui_read_input_loop(void *v)
Read event loop.
Definition ui.c:126
void ui_event_wait(UI *ui, char **cmd, char **param)
Wait input.
Definition ui.c:147
bool ui_event_peek(UI *ui, char **cmd, char **param)
Wait input.
Definition ui.c:160
void ui_event_free(UI *ui)
Free events.
Definition ui.c:220
void ui_free_xboard(UI *)
free resources used by xboard protocol.
Definition xboard.c:97
void ui_init_xboard(UI *)
initialize xboard protocol.
Definition xboard.c:72
void ui_loop_xboard(UI *)
Loop event.
Definition xboard.c:440
char * string_duplicate(const char *s)
Duplicate a string.
Definition util.c:299
void thread_create2(Thread *thread, void *(*function)(void *), void *data)
Create a thread.
Definition util.c:922
void string_to_lowercase(char *s)
Change all char of a string to lowercase.
Definition util.c:355
char * string_read_line(FILE *f)
Read a line.
Definition util.c:265
char * parse_command(const char *string, char *cmd, char *param, const unsigned int size)
Parse a command.
Definition util.c:867
char * parse_word(const char *string, char *word, unsigned int n)
Parse a word.
Definition util.c:562
Miscellaneous utilities header.
#define fatal_error(...)
Display an error message as "FATAL_ERROR : file name : function name : line number : ....
Definition util.h:349
#define info(...)
Display a message.
Definition util.h:382