helper functions

このコミットが含まれているのは:
woosh 2023-11-13 13:14:29 +00:00
コミット 9b1b6ea5b6
1個のファイルの変更23行の追加0行の削除

23
uttt.c
ファイルの表示

@ -286,6 +286,29 @@ void ut_show_boards(const struct ut_state *state) {
}
}
int info_line; // set this to 21 and reset it on erase TODO
void ut_info(const char *str)
{
mvaddstr(info_line, 0, str);
info_line++;
}
int readfill(int fd, char *x, size_t l)
{
while(l > 0)
{
int r = read(fd, x, l);
if(r < 0)
{
if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {continue;}
else {return 1;}
}
else if(r == 0) {return 2;}
x += r; l -= r;
}
return 0;
}
bool getpos(const struct ut_state *state, int *x, int *y) {
while (true) {
printf("Place token %c at position x,y: ", state->player);