diff options
author | root <root@phone01.(none)> | 2010-09-26 20:32:34 +0200 |
---|---|---|
committer | root <root@phone01.(none)> | 2010-09-26 20:32:34 +0200 |
commit | 0543208957f3f1a14f66d0c70fcc813e779f7638 (patch) | |
tree | 95f23d46c20688ad874a659274affe1f45c7a21e /console.c | |
parent | d0b22a46b53c968de3ec85022251f318d97e6b27 (diff) | |
download | MAC-Telnet-0543208957f3f1a14f66d0c70fcc813e779f7638.tar.gz MAC-Telnet-0543208957f3f1a14f66d0c70fcc813e779f7638.zip |
Working login, buggy terminal-data reception
Diffstat (limited to 'console.c')
-rw-r--r-- | console.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/console.c b/console.c new file mode 100644 index 0000000..558184f --- /dev/null +++ b/console.c @@ -0,0 +1,21 @@ +#include <sys/ioctl.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> +#include <stdio.h> + +int getTerminalSize(unsigned short *width, unsigned short *height) { + struct winsize ws; + + if (ioctl(0,TIOCGWINSZ,&ws) != 0) { + fprintf(stderr,"TIOCGWINSZ:%s\n",strerror(errno)); + return -1; + } + + *width = ws.ws_col; + *height = ws.ws_row; + + printf("Console width: %d, height: %d\n", *width, *height); + + return 1; +} |