/*
* TermInfo.tiocgwinsz(io) => [row, col]
*
* TermInfo.tiocgwinsz returns the screen size of the terminal refered by io,
* using TIOCGWINSZ ioctl.
*/
static VALUE
rt_tiocgwinsz(VALUE self, VALUE io)
{
#ifdef TIOCGWINSZ
rb_io_t *fptr;
struct winsize sz;
int ret;
GetOpenFile(io, fptr);
ret = ioctl(FILENO(fptr), TIOCGWINSZ, &sz);
if (ret == -1) rb_raise(rb_eIOError, "TIOCGWINSZ failed");
return rb_ary_new3(2, INT2NUM(sz.ws_row), INT2NUM(sz.ws_col));
#else
rb_notimplement();
#endif
}