home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / unixlib / h / tty < prev    next >
Encoding:
Text File  |  2004-09-05  |  1.8 KB  |  67 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/unixlib/tty.h,v $
  4.  * $Date: 2002/09/24 21:02:37 $
  5.  * $Revision: 1.3 $
  6.  * $State: Exp $
  7.  * $Author: admin $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. #ifndef __UNIXLIB_TTY_H
  12. #define __UNIXLIB_TTY_H
  13.  
  14. #ifndef __UNIXLIB_FEATURES_H
  15. #include <unixlib/features.h>
  16. #endif
  17.  
  18. #ifndef __TERMIOS_H
  19. #include <termios.h>
  20. #endif
  21.  
  22. #ifndef __SYS_IOCTL_H
  23. #include <sys/ioctl.h>
  24. #endif
  25.  
  26. #ifndef __SYS_PARAM_H
  27. #include <sys/param.h>
  28. #endif
  29.  
  30. __BEGIN_DECLS
  31.  
  32. #define MAXTTY    2
  33.  
  34. #define TTY_CON 0
  35. #define TTY_423 1
  36.  
  37. struct tty
  38.   {
  39.   struct termios t[1];
  40.   struct winsize w[1];
  41.   int (*out) (int);
  42.   int (*in) (void);
  43.   int (*scan) (int);
  44.   int (*init) (void);
  45.   int (*flush) (void);
  46.   int sx,cx;        /* screen x, character x */
  47.   int cnt;        /* number of characters in input buffer */
  48.   char *ptr;        /* read pointer in input buffer */
  49.   char buf[MAX_INPUT];  /* input buffer */
  50.   char del[MAX_INPUT];  /* number of displayed characters for character cx */
  51.   int lookahead;    /* [1 byte or -1] lookahead to allow select() */
  52.   };
  53.  
  54. /* Note, the buf and del buffers are declared statically in the tty struct.
  55.    This is so that an exec'd process which shares the tty struct doesn't
  56.    free something allocated by the parent process.  Such a call to free would
  57.    confuse the memory allocation system since the buffer wouldn't have been
  58.    allocated by that process but by the parent process.  We could check the
  59.    address of the buffer against __lomem and __break, but we might aswell
  60.    just live with the statically allocated memory compared to the extra code
  61.    we would need to have.  Lazy, probably, but it works okay and only costs
  62.    MAXTTY * MAX_INPUT * 2 (= 1024 bytes in current implementation).  */
  63.  
  64. __END_DECLS
  65.  
  66. #endif
  67.