Mail Archives: djgpp-workers/2001/08/08/14:04:36
My take on documenting TIOCGWINSZ:
Index: ioctl.txh
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/ioctl/ioctl.txh,v
retrieving revision 1.3
diff -c -p -r1.3 ioctl.txh
*** ioctl.txh 2000/10/06 16:55:35 1.3
--- ioctl.txh 2001/08/08 18:01:58
*************** Disk file:
*** 246,252 ****
@example
#include <sys/ioctl.h>
! int main(int argc, char **argv)@{
char buf[6];
short *s;
--- 246,253 ----
@example
#include <sys/ioctl.h>
! int main(int argc, char **argv)
! @{
char buf[6];
short *s;
*************** int main(int argc, char **argv)@{
*** 263,270 ****
@end example
@node ioctl (UNIX), io
! The UNIX version first checks if an FSE handler is associated to the file
! descriptor. If so, it calls the handler in the usual way @ref{File System
! Extensions}. Otherwise it sets @var{errno} to @code{ENOTTY} and returns -1.
! As this part is still under development, it should not be used exhaustively.
--- 264,308 ----
@end example
@node ioctl (UNIX), io
! @subheading Syntax
! @example
! #include <sys/ioctl.h>
!
! int ioctl(int fd, int cmd, ... );
! @end example
!
! @subheading Description
! The UNIX version first checks if an FSEXT handler is associated with the file
! descriptor @var{fd}. If so, it calls the handler in the usual way
! @ref{File System Extensions}.
!
! Otherwise,the operation specified by @var{cmd} is performed on the file open
! on handle @var{fd}. The following operations are defined
! by the header @code{sys/ioctl.h}:
!
! @table @code
! @item TIOCGWINSZ
! Fill the @code{struct winsize} structure pointed to by the third argument
! with the screen width and height.
!
! @end table
!
! @subheading Return Value
! Zero for @code{TIOCGWINSZ}. Otherwise, -1 is returned and @var{errno} is set to
! @code{ENOSYS} for all others.
!
! @subheading Example
!
! @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;
! @}
! @end example
- Raw text -