home *** CD-ROM | disk | FTP | other *** search
/ Zodiac Super OZ / MEDIADEPOT.ISO / FILES / 13 / DJCRX201.ZIP / include / libc / ttyprvt.h < prev    next >
C/C++ Source or Header  |  1996-09-15  |  4KB  |  140 lines

  1. #ifndef __dj_include_libc_ttyprvt_h__
  2. #define __dj_include_libc_ttyprvt_h__
  3.  
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7.  
  8. #ifndef __dj_ENFORCE_ANSI_FREESTANDING
  9.  
  10. #ifndef __STRICT_ANSI__
  11.  
  12. #ifndef _POSIX_SOURCE
  13.  
  14. #include <dpmi.h>
  15. #include <termios.h>
  16. #include <unistd.h>
  17.  
  18. #define _TTY_CTRL(x) ((x) & 0x1f)
  19. #define _TTY_QUEUE_SIZE 2048
  20. #define _TTY_EDITLINE_SIZE ((_TTY_QUEUE_SIZE) / 2)
  21. #define _TTY_EDITLINE_CTRL 0
  22. #define _TTY_EDITLINE_SINGLE 1
  23. #define _TTY_EDITLINE_INVALID -1
  24.  
  25. struct tty_queue
  26. {
  27.   int size;
  28.   unsigned char *top;
  29.   unsigned char *bottom;
  30.   int count;
  31.   unsigned char *rpos;
  32.   unsigned char *wpos;
  33. };
  34.  
  35. struct tty
  36. {
  37.   struct termios __libc_termios;
  38.   struct tty_queue __libc_tty_queue;
  39.   int __libc_tty_status;
  40. };
  41.  
  42. struct tty_editline
  43. {
  44.   int col;
  45.   char flag[_TTY_EDITLINE_SIZE];
  46.   unsigned char buf[_TTY_EDITLINE_SIZE];
  47. };
  48.  
  49. #if !defined (_POSIX_VDISABLE) || (_POSIX_VDISABLE == 0)
  50. #error _POSIX_VDISABLE is undefine or zero.
  51. #endif
  52.  
  53. #define TTYDEFAULT \
  54. {                                    \
  55.   /* struct termios __libc_termios */                    \
  56.   {                                    \
  57.     /* c_cc[] */                            \
  58.     {                                    \
  59.       (cc_t) 0,               /* pad */                 \
  60.       (cc_t) _TTY_CTRL ('d'), /* VEOF */                \
  61.       (cc_t) _POSIX_VDISABLE, /* VEOL */                \
  62.       (cc_t) _TTY_CTRL ('h'), /* VERASE */                \
  63.       (cc_t) _TTY_CTRL ('c'), /* VINTR */                \
  64.       (cc_t) _TTY_CTRL ('u'), /* VKILL */                \
  65.       (cc_t) 1,               /* VMIN */                \
  66.       (cc_t) _TTY_CTRL ('\\'),/* VQUIT */                \
  67.       (cc_t) _TTY_CTRL ('q'), /* VSTART */                \
  68.       (cc_t) _TTY_CTRL ('s'), /* VSTOP */                \
  69.       (cc_t) _TTY_CTRL ('z'), /* VSUSP */                \
  70.       (cc_t) 0,               /* VTIME */                \
  71.     },                                    \
  72.     (tcflag_t) (CS8|CREAD|CLOCAL), /* c_cflag */            \
  73.     (tcflag_t) (BRKINT|ICRNL|IMAXBEL), /* c_iflag */            \
  74.     (tcflag_t) (ISIG|ICANON|ECHO|IEXTEN|ECHOE|ECHOKE|ECHOCTL), /* c_lflag */ \
  75.     (tcflag_t) (OPOST|ONLCR|ONOEOT), /* c_oflag */            \
  76.     (speed_t) (B9600), /* c_ispeed */                    \
  77.     (speed_t) (B9600), /* c_ospeed */                    \
  78.   },                                    \
  79.   /* struct tty_queue __libc_tty_queue */                \
  80.   {                                    \
  81.     _TTY_QUEUE_SIZE,                            \
  82.     __libc_tty_queue_buffer,                        \
  83.     __libc_tty_queue_buffer + _TTY_QUEUE_SIZE,                \
  84.     0,                                    \
  85.     __libc_tty_queue_buffer,                        \
  86.     __libc_tty_queue_buffer,                        \
  87.   },                                    \
  88.   /* __libc_tty_status */                        \
  89.   0,                                    \
  90. }
  91.  
  92. #define t_termios __libc_termios
  93. #define t_iflag __libc_termios.c_iflag
  94. #define t_oflag __libc_termios.c_oflag
  95. #define t_cflag __libc_termios.c_cflag
  96. #define t_lflag __libc_termios.c_lflag
  97. #define t_ispeed __libc_termios.c_ispeed
  98. #define t_ospeed __libc_termios.c_ospeed
  99. #define t_cc __libc_termios.c_cc
  100. #define t_status __libc_tty_status
  101.  
  102. #define t_size __libc_tty_queue.size
  103. #define t_top __libc_tty_queue.top
  104. #define t_bottom __libc_tty_queue.bottom
  105. #define t_count __libc_tty_queue.count
  106. #define t_rpos __libc_tty_queue.rpos
  107. #define t_wpos __libc_tty_queue.wpos
  108.  
  109. #define _TS_LNCH 0x01 /* next character is literal */
  110. #define _CC_EQU(v,c) (((c) == (unsigned char) __libc_tty_p->t_cc[(v)])    \
  111.               && ((c) != (unsigned char) _POSIX_VDISABLE))
  112. #define _CC_NEQU(v,c) (((c) != (unsigned char)__libc_tty_p->t_cc[(v)])    \
  113.                && ((c) != (unsigned char) _POSIX_VDISABLE))
  114.  
  115. /* internal buffers */
  116. extern unsigned char __libc_tty_queue_buffer[];
  117. extern struct tty __libc_tty_internal;
  118. extern struct tty *__libc_tty_p;
  119. extern struct tty_editline __libc_tty_editline;
  120.  
  121. /* termios hooks */
  122. extern int (*__libc_read_termios_hook)(int handle, void *buffer, size_t count,
  123.                        ssize_t *rv);
  124. extern int (*__libc_write_termios_hook)(int handle, const void *buffer, size_t count,
  125.                     ssize_t *rv);
  126. extern int __libc_termios_hook_common_count;
  127.  
  128. /* functions */
  129. void __libc_termios_init (void);
  130.  
  131. #endif /* !_POSIX_SOURCE */
  132. #endif /* !__STRICT_ANSI__ */
  133. #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
  134.  
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138.  
  139. #endif /* !__dj_include_libc_ttyprvt_h__ */
  140.