home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 143_01 / bdscio.h < prev    next >
Text File  |  1985-11-14  |  4KB  |  161 lines

  1. /*
  2.  *    The BDS C Standard I/O header file --  v1.50    12/29/82
  3.  *        MODIFIED 4/27/85 FOR USE WITH C/80
  4.  *
  5.  *    This file contains global definitions, for use in all C programs
  6.  *    in PLACE of (yechhh) CONSTANTS. Characteristics of your system such
  7.  *    buffered I/O allocations, storage allocator state, etc., should all
  8.  *    be configured just once within this file. Any program which needs
  9.  *    them should contain the preprocessor directive:
  10.  *
  11.  *        #include <bdscio.h>
  12.  *
  13.  *    near the beginning. 
  14.  */
  15.  
  16. #define C80    /* Define C80 if C80 compiler in use else BDS/C */
  17.  
  18. /*
  19.  *    General purpose Symbolic constants:
  20.  */
  21.  
  22. #define BASE 0        /* Base of CP/M system RAM (0 or 0x4200)  */
  23. #define NULL 0
  24. #define EOF -1        /* Physical EOF returned by low level I/O functions*/
  25. #define ERROR -1    /* General "on error" return value */
  26. #define OK 0        /* General purpose "no error" return value */
  27. #define JBUFSIZE 6    /* Length of setjump/longjump buffer    */
  28. #define CPMEOF 0x1a    /* CP/M End-of-text-file marker (sometimes!)  */
  29. #define SECSIZ 128    /* Sector size for CP/M read/write calls */
  30. #define MAXLINE 150    /* Longest line of input expected from the console */
  31. #define TRUE 1        /* logical true constant */
  32. #define FALSE 0        /* logical false constant */
  33. #define BEGIN {
  34. #define THEN {
  35. #define LOOP {
  36. #define ENDIF }
  37. #define ENDLOOP }
  38. #define END }
  39. #define FUNCTION /**/
  40.  
  41. #ifdef C80
  42. #define STDIN  fin
  43. #define STDOUT fout
  44. #define STDERR 0
  45. #define DIOIN fin
  46. #define DIOOUT fout    /* for C80 fout is equivalent to DIOOUT */
  47. extern int fin, fout;    /* for C80 fin is equivalent to DIOIN */
  48. #else
  49. #define STDIN  0
  50. #define STDOUT 1
  51. #define STDERR 4
  52. #endif
  53.  
  54. #define STDLST 2
  55. #define STDRDR 3
  56. #define STDPUN 3
  57.  
  58. /* FOR USE WITH OPEN & buffered BDS IO*/
  59. #ifdef C80
  60. #define READ   "rb"
  61. #define WRITE  "wb"
  62. #define READWRITE "ub"
  63. #define NBLCHAR 128
  64. #define fopen c_open
  65. #define fclose c_close
  66. #define putc c_putc
  67. #define getc c_getc
  68. #define read c_read
  69. #define write c_write
  70. #define seek c_seek
  71. #define fabort close
  72. #else
  73. #define READ   0
  74. #define WRITE  1
  75. #define READWRITE 2
  76. #endif
  77.  
  78. /*
  79.  *    The NSECTS symbol controls the compilation of the buffered
  80.  *    I/O routines within STDLIB2.C, allowing each user to set the
  81.  *    buffer size most convenient for his system, while keeping
  82.  *    the numbers totally invisible to the C source programs using
  83.  *    buffered I/O (via the BUFSIZ defined symbol.) For larger
  84.  *    NSECTS, the disk I/O is faster...but more ram is taken up.
  85.  *    To change the buffer size allocation, follow these steps:
  86.  *
  87.  *    1) Change NSECTS below
  88.  *    2) Re-compile STDLIB1.C and STDLIB2.C
  89.  *    3) Use CLIB to combine STDLIB1.CRL and STDLIB2.CRL to make
  90.  *       a new DEFF.CRL. This isn't as touch as it sounds.
  91.  *
  92.  *    Make sure you declare all your I/O buffers with the a
  93.  *    statement such as:
  94.  *
  95.  *        char buf_name[BUFSIZ];
  96.  */
  97.  
  98. #ifndef C80
  99. #define NSECTS 8    /* Number of sectors to buffer up in ram */
  100.  
  101. #define BUFSIZ (NSECTS * SECSIZ + 7)    /* Don't touch this */
  102.  
  103. struct _buf {                /* Or this...        */
  104.     int _fd;
  105.     int _nleft;
  106.     char *_nextp;
  107.     char _buff[NSECTS * SECSIZ];
  108.     char _flags;
  109. };
  110. #define FILE struct _buf    /* Poor man's "typedef" */
  111. #define _READ 1
  112. #define _WRITE 2
  113.  
  114. #else
  115. #define NSECTS 1
  116. #define BUFSIZ 1
  117. #define FILE int    /* for C80 define FILE as an int then 
  118.             iobuf is used as a pointer in C80 versions
  119.             of buffered IO functions */
  120. #endif
  121.  
  122. #ifdef C80
  123. #define wildexp command    /* expand wild card names in command line */
  124.  
  125. /* C/80 definitions for printf, fprintf and sprintf 
  126.     to allow multiple args. */
  127.  
  128. #define printf prnt_1(),prnt_2
  129. #define fprintf prnt_1(),prnt_3
  130. #define sprintf prnt_1(),prnt_4
  131. #define typef prnt_1(),prnt_5
  132.  
  133. /* Header file for scanf */
  134. #undef scanf
  135. #undef fscanf
  136. #undef sscanf
  137. #define scanf STK_pos(),scan_f
  138. #define fscanf STK_pos(),f_scan
  139. #define sscanf STK_pos(),s_scan
  140.  
  141. #else
  142.  
  143. struct _long {char _lc[2];};
  144. struct _float {char _ft[5];};
  145. #define LONG struct _long    /* LONG typedef */
  146. #define FLOAT struct _float    /* FLOAT typedef */
  147. #define REAL struct _float    /* REAL typedef */
  148.  
  149. /*
  150.  * Storage allocation data, used by "alloc" and "free"
  151.  */
  152.  
  153. struct _header  {
  154.     struct _header *_ptr;
  155.     unsigned _size;
  156.  };
  157.  
  158. struct _header _base;        /* declare this external data to  */
  159. struct _header *_allocp;    /* be used by alloc() and free()  */
  160. #endif
  161.