linux version of terminfo.c -- same code as solaris, but different headers

required...  *sigh*.  Perhaps, assuming FreeBSD and IRIX can also use the same
code (which I don't know to be true yet), I'll figure out some better way to
deal with this, so I don't have multiple identical code fragments.
This commit is contained in:
lindes 2001-08-28 01:16:19 +00:00
parent 9f5cfbd71d
commit 7e3af8197e
1 changed files with 28 additions and 0 deletions

28
arch/Linux/terminfo.c Normal file
View File

@ -0,0 +1,28 @@
/*
* arch/Linux/terminfo.c -- routines for getting terminal
* information on Linux machines.
*
* Copyright 2001, David Lindes. All rights reserved.
*/
#include <sys/ioctl.h> /* for ioctl() */
/* globals */
extern int rows;
extern int cols;
void gettermsize()
{
struct winsize info;
/* try to get data via IOCTL: */
if (ioctl(1 /* stdout */, TIOCGWINSZ, &info) != -1)
{
/* if successful, and the data seems sane, set the
* program's globals: */
if(info.ws_col > 0)
cols = info.ws_col;
if(info.ws_row > 0)
rows = info.ws_row;
}
}