cvs.delorie.com/djgpp/doc/libc/libc_495.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

ioctl (UNIX)

Syntax

 
#include <sys/ioctl.h>

int ioctl(int fd, int cmd, ... );

Description

The UNIX version first checks if an FSEXT handler is associated with the file descriptor fd. If so, it calls the handler in the usual way (see section File System Extensions).

Otherwise,the operation specified by cmd is performed on the file open on handle fd. The following operations are defined by the header `sys/ioctl.h':

TIOCGWINSZ
Fill in the winsize structure pointed to by the third argument with the screen width and height.

The winsize structure is defined in `sys/ioctl.h' as follows:

 
struct winsize
{
  unsigned short ws_row;	/* rows, in characters */
  unsigned short ws_col;	/* columns, in characters */
  unsigned short ws_xpixel;	/* horizontal size, pixels */
  unsigned short ws_ypixel;	/* vertical size, pixels */
};

Return Value

Zero for TIOCGWINSZ. Otherwise, -1 is returned and errno is set to ENOSYS for all others.

Example

 
#include <sys/ioctl.h>
#include <stdio.h>
int main(int argc, char **argv)
{
  struct winsize sz;

  ioctl(0, TIOCGWINSZ, &screen_size);
  printf("Screen width: %i  Screen height: %i\n", sz.ws_col, sz.ws_row);
  return 0;
}

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004