diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-09-22 19:41:43 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-09-22 22:29:20 -0700 |
commit | 8d37b6c92b61d9ab66b48ca67fd3e42751f5cf43 (patch) | |
tree | 77288aaa8016931f0258337360103307c392e9b3 /deps/uv/src/unix/tty.c | |
parent | 74c02066fe0e963722b0d7d5a78c703fd14c0275 (diff) | |
download | android-node-v8-8d37b6c92b61d9ab66b48ca67fd3e42751f5cf43.tar.gz android-node-v8-8d37b6c92b61d9ab66b48ca67fd3e42751f5cf43.tar.bz2 android-node-v8-8d37b6c92b61d9ab66b48ca67fd3e42751f5cf43.zip |
upgrade libuv
Diffstat (limited to 'deps/uv/src/unix/tty.c')
-rw-r--r-- | deps/uv/src/unix/tty.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c index 9de7dd9fcb..88ce52a24b 100644 --- a/deps/uv/src/unix/tty.c +++ b/deps/uv/src/unix/tty.c @@ -23,6 +23,7 @@ #include "internal.h" #include <assert.h> +#include <unistd.h> #include <termios.h> #include <errno.h> @@ -71,3 +72,43 @@ fatal: int uv_is_tty(uv_file file) { return isatty(file); } + + +int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { + struct winsize ws; + + if (ioctl(tty->fd, TIOCGWINSZ, &ws) < 0) { + uv_err_new(tty->loop, errno); + return -1; + } + + *width = ws.ws_col; + *height = ws.ws_row; + + return 0; +} + + +uv_handle_type uv_guess_handle(uv_file file) { + struct stat s; + + if (file < 0) { + uv_err_new(NULL, EINVAL); /* XXX Need loop? */ + return -1; + } + + if (isatty(file)) { + return UV_TTY; + } + + if (fstat(file, &s)) { + uv_err_new(NULL, errno); /* XXX Need loop? */ + return -1; + } + + if (!S_ISSOCK(s.st_mode) && !S_ISFIFO(s.st_mode)) { + return UV_FILE; + } + + return UV_NAMED_PIPE; +} |