home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / ntio.h < prev    next >
C/C++ Source or Header  |  1999-01-02  |  4KB  |  104 lines

  1. /* -*-C-*-
  2.  
  3. $Id: ntio.h,v 1.11 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1992-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. #ifndef SCM_NTIO_H
  23. #define SCM_NTIO_H
  24.  
  25. #include "osio.h"
  26.  
  27. typedef long channel_op_read (Tchannel, void *, unsigned long);
  28. typedef long channel_op_write (Tchannel, const void *, unsigned long);
  29. typedef void channel_op_close (Tchannel, int);
  30. typedef long channel_op_n_read (Tchannel);
  31.  
  32. typedef struct _channel_class_t
  33. {
  34.   enum channel_type type;
  35.   channel_op_read * op_read;
  36.   channel_op_write * op_write;
  37.   channel_op_close * op_close;
  38.   channel_op_n_read * op_n_read;
  39. } channel_class_t;
  40.  
  41. #define CHANNEL_CLASS_TYPE(class) ((class) -> type)
  42. #define CHANNEL_CLASS_OP_READ(class) ((class) -> op_read)
  43. #define CHANNEL_CLASS_OP_WRITE(class) ((class) -> op_write)
  44. #define CHANNEL_CLASS_OP_CLOSE(class) ((class) -> op_close)
  45. #define CHANNEL_CLASS_OP_N_READ(class) ((class) -> op_n_read)
  46.  
  47. struct channel
  48. {
  49.   channel_class_t * class;
  50.   HANDLE handle;
  51.   unsigned int internal : 1;
  52.   unsigned int nonblocking : 1;
  53.   unsigned int buffered : 1;
  54.   unsigned int cooked : 1;
  55. };
  56.  
  57. #define CHANNEL_CLASS(c) ((NT_channel_table[c]) . class)
  58. #define CHANNEL_HANDLE(c) ((NT_channel_table[c]) . handle)
  59. #define CHANNEL_INTERNAL(c) ((NT_channel_table[c]) . internal)
  60. #define CHANNEL_NONBLOCKING(c) ((NT_channel_table[c]) . nonblocking)
  61. #define CHANNEL_BUFFERED(c) ((NT_channel_table[c]) . buffered)
  62. #define CHANNEL_COOKED(c) ((NT_channel_table[c]) . cooked)
  63.  
  64. #define CHANNEL_TYPE(channel) (CHANNEL_CLASS_TYPE (CHANNEL_CLASS (channel)))
  65. #define MARK_CHANNEL_CLOSED(channel)                    \
  66.   ((CHANNEL_HANDLE (channel)) = INVALID_HANDLE_VALUE)
  67. #define CHANNEL_CLOSED_P(channel)                    \
  68.   ((CHANNEL_HANDLE (channel)) == INVALID_HANDLE_VALUE)
  69. #define CHANNEL_OPEN_P(channel)                        \
  70.   ((CHANNEL_HANDLE (channel)) != INVALID_HANDLE_VALUE)
  71. #define CHANNEL_BLOCKING_P(channel) (!CHANNEL_NONBLOCKING (channel))
  72.  
  73. extern channel_class_t * NT_channel_class_generic;
  74. extern channel_class_t * NT_channel_class_file;
  75. extern channel_class_t * NT_channel_class_screen;
  76. extern channel_class_t * NT_channel_class_console;
  77. extern channel_class_t * NT_channel_class_anonymous_pipe;
  78. extern channel_class_t * NT_channel_class_named_pipe;
  79. extern struct channel * NT_channel_table;
  80.  
  81. extern Tchannel NT_make_channel (HANDLE, channel_class_t *);
  82. extern channel_class_t * NT_handle_channel_class (HANDLE);
  83. extern Tchannel NT_open_handle (HANDLE);
  84. extern void NT_handle_close_on_abort (HANDLE);
  85. extern long NT_channel_n_read (Tchannel);
  86.  
  87. #define BACKSPACE        '\b'
  88. #define SPACE            ' '
  89. #define CARRIAGE_RETURN        '\r'
  90. #define LINEFEED        '\n'
  91. #define CNTRL_Z            '\032'
  92. #define ASCII_DELETE        '\177'
  93.  
  94. extern BOOL EXFUN (Screen_IsScreenHandle, (HANDLE));
  95.  
  96. #ifndef GUI
  97. #  define CONSOLE_HANDLE (STDIN_HANDLE)
  98. #  define IsConsoleHandle(h)  ((h) == CONSOLE_HANDLE)
  99. #else
  100. #  define IsConsoleHandle(h)  (0 == 1)
  101. #endif
  102.  
  103. #endif /* SCM_NTIO_H */
  104.