home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BDSC / BDSC-1 / BDSCIO50.H < prev    next >
C/C++ Source or Header  |  2000-06-30  |  3KB  |  103 lines

  1. /*
  2.  *    The BDS C Standard I/O header file --  v1.50    7/27/82
  3.  *
  4.  *    This file contains global definitions, for use in all C programs
  5.  *    in PLACE of (yechhh) CONSTANTS. Characteristics of your system such
  6.  *    buffered I/O allocations, storage allocator state, etc., should all
  7.  *    be configured just once within this file. Any program which needs
  8.  *    them should contain the preprocessor directive:
  9.  *
  10.  *        #include "bdscio.h"
  11.  *
  12.  *    near the beginning. 
  13.  */
  14.  
  15.  
  16. /*
  17.  *    General purpose Symbolic constants:
  18.  */
  19.  
  20. #define BASE 0        /* Base of CP/M system RAM (0 or 0x4200)  */
  21. #define NULL 0
  22. #define EOF -1        /* Physical EOF returned by low level I/O functions */
  23. #define ERROR -1    /* General "on error" return value */
  24. #define OK 0        /* General purpose "no error" return value */
  25. #define JBUFSIZE 6    /* Length of setjump/longjump buffer    */
  26. #define CPMEOF 0x1a    /* CP/M End-of-text-file marker (sometimes!)  */
  27. #define SECSIZ 128    /* Sector size for CP/M read/write calls */
  28. #define MAXLINE 150    /* Longest line of input expected from the console */
  29. #define TRUE 1        /* general purpose true truth value    */
  30. #define FALSE 0        /* general purpose false truth value     */
  31.  
  32. /*
  33.  *    The NSECTS symbol controls the compilation of the buffered
  34.  *    I/O routines within STDLIB2.C, allowing each user to set the
  35.  *    buffer size most convenient for his system, while keeping
  36.  *    the numbers totally invisible to the C source programs using
  37.  *    buffered I/O (via the BUFSIZ defined symbol.) For larger
  38.  *    NSECTS, the disk I/O is faster...but more ram is taken up.
  39.  *    To change the buffer size allocation, follow these steps:
  40.  *
  41.  *    1) Alter NSECTS to the desired value here in bdscio.h
  42.  *    2) Re-compile STDLIB1.C and STDLIB2.C
  43.  *    3) Use CLIB to combine STDLIB1.CRL and STDLIB2.CRL to make
  44.  *       a new DEFF.CRL.
  45.  *
  46.  *    Make sure you use declare all your I/O buffers with the a
  47.  *    statement such as:
  48.  *
  49.  *        char buf_name[BUFSIZ];
  50.  */
  51.  
  52. #define NSECTS 8    /* Number of sectors to buffer up in ram */
  53.  
  54. #define BUFSIZ (NSECTS * SECSIZ + 7)    /* Don't touch this */
  55.  
  56. struct _buf {                /* Or this...        */
  57.     int _fd;
  58.     int _nleft;
  59.     char *_nextp;
  60.     char _buff[NSECTS * SECSIZ];
  61.     char _flags;
  62. };
  63.  
  64. #define FILE struct _buf    /* Poor man's "typedef" */
  65.  
  66. #define _READ 1
  67. #define _WRITE 2
  68.  
  69.  
  70. /*
  71.  *    If you plan to use the high-level storage allocation functions
  72.  *    from the library ("alloc" and "free") then:
  73.  *
  74.  *      1) Uncomment (enable) the "ALLOC_ON" definition, and comment out the
  75.  *         "ALLOC_OFF" definition from this file.
  76.  *
  77.  *      2) Re-compile STDLIB1.C, and use CLIB to transfer "alloc"
  78.  *         and "free" into the DEFF.CRL library file.
  79.  *
  80.  *    Remember to include bdscio.h in all files of your C program.
  81.  *
  82.  */
  83.  
  84. /*
  85. #define ALLOC_OFF 1    /* disables storage allocation if uncommented */
  86. */
  87.             /* only ONE of these two lines should be uncommented */
  88.  
  89. #define ALLOC_ON 1    /* enables storgage allocation if uncommented */
  90.  
  91. #ifdef ALLOC_ON            /* if storage allocation enabled, */
  92.  
  93. struct _header  {
  94.     struct _header *_ptr;
  95.     unsigned _size;
  96.  };
  97.  
  98. struct _header _base;        /* declare this external data to  */
  99. struct _header *_allocp;    /* be used by alloc() and free()  */
  100.  
  101. #endif
  102.  
  103.