home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd6.lzh / SRC / io.h < prev    next >
Text File  |  1989-12-21  |  1KB  |  83 lines

  1. /*
  2.   C BASED FORTH-83 MULTI-TASKING IO MANAGEMENT DEFINITIONS
  3.  
  4.   Copyright (c) 1989 by Mikael R.K. Patel
  5.  
  6. */
  7.  
  8.  
  9. /* INCLUDE FILES: STANDARD INPUT/OUTPUT */
  10.  
  11. #include <stdio.h>
  12.  
  13.  
  14. /* STANDARD INPUT AND OUTPUT DESCRIPTORS */
  15.  
  16. #define STDIN  0
  17. #define STDOUT 1
  18.  
  19.  
  20. /* WHITE SPACE DEFINITION AND CHARACTER MASK */
  21.  
  22. #define ISSPACE(c) ((c) <= ' ')
  23. #define CMASK 0377
  24.  
  25.  
  26. /* FILE BUFFER DEFINITION */
  27.  
  28. #define BUFSIZE 1024
  29.  
  30. typedef struct {
  31.     int  fd;
  32.     int  bufp;
  33.     int  cc;
  34.     char buf[BUFSIZE];
  35. } FILE_BUFFER;
  36.  
  37. extern FILE_BUFFER *io_fstack[];
  38. extern int io_fsp;
  39.  
  40.  
  41. /* APPEND ORDER FOR IO_PATH */
  42.  
  43. #define IO_PATH_FIRST 1
  44. #define IO_PATH_LAST 0
  45.  
  46.  
  47. /* IO MANAGE ERROR CODES */
  48.  
  49. #define IO_NO_ERROR 0
  50. #define IO_EOF -1
  51. #define IO_PATH_DEFINED -1
  52. #define IO_FILE_INCLUDED -1
  53. #define IO_UNKNOWN_FILE -2
  54. #define IO_UNKNOWN_PATH -2
  55. #define IO_TOO_MANY_PATHS -3
  56. #define IO_TOO_MANY_FILES -3
  57.  
  58.  
  59. /* EXPORTED MACROS, FUNCTIONS, AND PROCEDURES */
  60.  
  61. #define io_getchar() \
  62.     ((io_fstack[io_fsp] -> bufp < io_fstack[io_fsp] -> cc) ? \
  63.      (long) io_fstack[io_fsp] -> buf[io_fstack[io_fsp] -> bufp++] & CMASK : \
  64.      (long) io_fillbuf())
  65.  
  66. #define io_eof() (io_fsp == -1)
  67.  
  68. #define io_not_eof() (io_fsp > -1)
  69.  
  70. int  io_path();
  71. int  io_infile();
  72. int  io_fillbuf();
  73.  
  74. void io_flush();
  75.  
  76. void io_skip();
  77. void io_scan();
  78. void io_skipspace();
  79.  
  80. void io_initiate();
  81. void io_finish();
  82.  
  83.