home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 118_01 / tools.h < prev    next >
Text File  |  1980-07-09  |  7KB  |  308 lines

  1. /* Standard header for Software Tools
  2.  * This file includes a version of BDSCIO.h
  3.  * source: tools.h
  4.  * version:  August 23, 1981
  5.  */
  6.  
  7. /* This file contains: 
  8.  
  9.     1.  Unchanging constants used by BDS C.
  10.     2.  Unchanging constants used by Software Tools.
  11.     3.  Global variables for the Software tools and
  12.         constants used to define those variables.
  13.  
  14.    All software tools should include tools.h and
  15.    should NOT include bdscio.h
  16. */
  17.  
  18.  
  19. /* Part 1 -- Unchanging constants used by BDS C*/
  20.  
  21. #define BASE 0        /* Base of CP/M system RAM  */
  22. #define NULL 0
  23. #define EOF -1        /* Physical EOF returned by */
  24.             /* low level I/O functions */
  25. #define ERROR -1
  26. #define OK 0
  27. #define CPMEOF 0x1a    /* CP/M End-of-text-file marker */
  28.             /*  (sometimes!)  */
  29. #define SECSIZ 128    /* Sector size for read/write calls */
  30. #define TRUE 1
  31. #define FALSE 0
  32.  
  33.  
  34. /* Part 2 -- Unchanging constants used by Software Tools */
  35.  
  36. #define    BEGINNING_OF_FILE -2    /* seek to start of file */
  37. #define    END_OF_FILE EOF        /* flag to seek for eof */
  38.  
  39. #define DIGIT    '0'
  40. #define LETTER    'A'
  41.  
  42. #define    ERR    ERROR
  43. #define    HUGE    30000    /* some arbitrarily large number */
  44. #define    LAMBDA    0    /* end of list marker */
  45. #define    NO    0
  46. #define    YES    1
  47. #define NOERR    OK
  48.  
  49.  
  50. /* file types */
  51.  
  52. /* comment out ----- (file types)
  53. #define    ALPHA    -9
  54. #define    ASCII    12
  55. #define BINARY  60
  56. #define LOCAL    6
  57. ----- end comment out */
  58.  
  59.  
  60. /* ASCII control character definitions */
  61.  
  62. #define    NUL    0
  63.  
  64. #define    BEL    7
  65. #define    BS    8
  66. #define    HT    9
  67. #define    LF    10
  68. #define    VT    11
  69. #define    FF    12
  70. #define    CR    13
  71.  
  72. #define    CAN    24
  73.  
  74. #define    ESC    27
  75.  
  76. #define    DEL    127
  77.  
  78.  
  79. /* Synonyms for important non-printing ASCII characters */
  80.  
  81. #define    BACKSPACE 8
  82. #define    BELL    7
  83. #define    BLANK    32
  84. #define    NEWLINE 10
  85. #define    RUBOUT    127
  86. #define    TAB    9
  87.  
  88.  
  89. /* Printable ASCII characters */
  90.  
  91. #define DQUOTE 34
  92. #define    LBRACE    123
  93. #define    LBRACK    91
  94. #define    LPAREN    40
  95. #define    RBRACE    125
  96. #define    RBRACK    93
  97. #define    RPAREN    41
  98. #define    SQUOTE    39
  99. #define    UNDERLINE 95
  100.  
  101. /* Ratfor language extensions */
  102.  
  103. #define FILEDES int
  104. #define POINTER int
  105. #define BOOL int
  106. #define EOS 0
  107.  
  108. /* comment out -----
  109. define (DS_DECL,integer $1($2);common/cdsmem/$1)
  110. define (IS_DIGIT,(DIG0<=$1&$1<=DIG9))    # valid only for ASCII!
  111. define (IS_LETTER,(IS_UPPER($1)|IS_LOWER($1)))
  112. define (IS_LOWER,(LETA<=$1&$1<=LETZ))
  113. define (IS_UPPER,(BIGA<=$1&$1<=BIGZ))
  114. ----- end comment out */
  115.  
  116.  
  117. /* Machine-dependent parameters */
  118.  
  119. /* comment out -----
  120. #define    BITS_PER_CHAR    8
  121. #define    BITS_PER_WORD    16
  122. #define    CHARS_PER_WORD    2
  123. #define    MAX_INTEGER    32767
  124. #define    MIN_INTEGER    -32768
  125. #define    MAX_REAL_EXP    38
  126. #define    MIN_REAL_EXP    -38
  127. #define    REAL_PRECISION    6
  128. ----- comment out */
  129.  
  130.  
  131. /*
  132. DRIVER and DRETURN have been eliminated.
  133. Instead, each tool should start as follows:
  134.  
  135. main(arc, argv)
  136. int argc;
  137. char ** argv;
  138. {
  139.     initst(argc, argv);
  140.     tool();
  141. }
  142.  
  143. */
  144.  
  145. /* Definitions for 'spawn' primitive */
  146.  
  147. /* comment out ----------
  148. #define    WAIT    'w'    wait for subprocess to complete
  149. #define    NOWAIT    'n'    control returns as soon as
  150.             subprocess starts
  151. #define    BACKGR    'b'    spawning a background process
  152. ---------- end comment out */
  153.  
  154.  
  155. /* Part 3 -- Define global variables */
  156.  
  157. /* max chars in file name (including EOS)
  158.    for CP/M =
  159.     2 (disk)
  160.     8 (filename)
  161.     1 (dot)
  162.     3 (extension)
  163.     1 (EOS)
  164. */
  165.  
  166. #define    SYS_MAXFN 15    /* replaces FILENAMESIZE, MAXNAME */
  167.  
  168. #define MAXLINE 135    /* used by BOTH BDS and tools */
  169.  
  170. #define    MAXCARD    80    /* "card" size */
  171.             /* to be replaced */
  172.  
  173. #define    MAXCHARS 20    /* max nbr of chars when converting */
  174.             /* from integers to characters */
  175.             /* (used by putint, outnum, etc.) */
  176.  
  177. #define    MAXPAT    128    /* max size of encoded patterns */
  178.             /* (used in string matching) */
  179.  
  180. #define    NCHARS    33    /* number of special characters */
  181.  
  182.  
  183. /* define size of I/O buffers
  184.  
  185.    The NSECTS symbol controls the size of the file buffers.
  186.    To change the buffer size allocation, follow these steps:
  187.  
  188.      1) Alter NSECTS to the desired value here in tools.h
  189.      2) Re-compile ALL bds files.
  190.  
  191.    Make sure you use declare all your I/O buffers with the a
  192.    statement such as:
  193.  
  194.           char buf_name[BUFSIZ];
  195. */
  196.  
  197. #define NSECTS 8    /* Number of sectors to buffer up in ram */
  198.  
  199. #define BUFSIZ (NSECTS * SECSIZ + 6 )    /* Don't touch this */
  200.  
  201. struct _buf {                /* Or this...        */
  202.     int _fd;
  203.     int _nleft;
  204.     char *_nextp;
  205.     char _buff[NSECTS * SECSIZ];
  206. };
  207.  
  208. /* seed for random number generators */
  209.  
  210. int sys_seed;
  211.  
  212. /* time and date */
  213.  
  214. char sys_date [MAXLINE];
  215.  
  216. /* dynamic storage allocation information */
  217.  
  218. struct _header  {
  219.     struct _header *_ptr;
  220.     unsigned _size;
  221.  };
  222.  
  223. struct _header _base;
  224. struct _header *_allocp;
  225.  
  226.  
  227.  /* command line argument information */
  228.  
  229.  int sys_narg;        /* number of arguments in list */
  230.             /* init to 0 */
  231.  int sys_args[30];    /* pointers to n'th argument */
  232.             /* BDS C has max of 30 arguments */
  233.  
  234. /* file information:
  235.    
  236.    Units are either standard units or explicitly opened files.
  237.  
  238.    Units 0, 1, and 2 are the STDIN, STDOUT, and ERROUT units.
  239. By default, these units are the same as the user's console,
  240. but these units may be redirected to files via the
  241. command line characters >, < and ?.
  242.  
  243.    Units 3 and 4 are always assigned to the user's console
  244. and line printer respectively.  These units can not be
  245. reassigned.  Reading from unit 4 is not permitted.
  246.  
  247.    The user need never open units 0 through 4, although it
  248. is permissible to do so.
  249.  
  250.    Units with numbers greater than 4 are files.  These units
  251. must always be opened by calling open().  Normally, these
  252. units are disk files.  However, these units may assign to the
  253. files TTY or PRINTER.  All I/O assigned to TTY is assigned to
  254. unit 3.  All I/O assigned to PRINTER is assigned to unit 4.
  255.  
  256.    I/O from standard units may be redirected to any file,
  257. including TTY and PRINTER.
  258.  
  259.    Sys_bufp [unit] != ERR ==> unit is directed to a disk file.
  260.    Sys_spec [unit] != ERR ==> unit is directed to special file.
  261.    Otherwise, the unit is closed.
  262. */
  263.  
  264.  
  265. /* define access modes */
  266.  
  267. #define READ 1
  268. #define WRITE 2
  269. #define APPEND 3
  270. #define READWRITE 4
  271.  
  272. /* define standard unit numbers */
  273.  
  274. #define SYS_STD 5        /* # of standard units */
  275.  
  276. #define STDIN 0
  277. #define STDOUT 1
  278. #define ERROUT 2
  279. #define STDERR ERROUT
  280. #define SYS_TERM 3
  281. #define SYS_PRT 4
  282.  
  283. /* define reserved filenames */
  284.  
  285. #define TERMINAL "TTY"        /* user's terminal */
  286. #define PRINTER  "PRINTER"    /* user's printer */
  287.  
  288. #define MAXOFILES 5        /* max # of open files */
  289.  
  290. int sys_bufp [SYS_STD + MAXOFILES];    /* ERR or ^ buffer */
  291.  
  292. int sys_bufn [SYS_STD + MAXOFILES];    /* buffer number */
  293.  
  294. int sys_spec [SYS_STD + MAXOFILES];    /* ERR or std unit */
  295.  
  296. int sys_acc  [SYS_STD + MAXOFILES];    /* access mode */
  297.  
  298. char sys_bufs  [MAXOFILES * BUFSIZ];    /* file buffers */
  299.  
  300.  
  301. #define TERMINAL "TTY"        /* user's terminal */
  302. #define PRINTER  "PRINTER"    /* user's printer */
  303.  
  304. #define MAXOFILES 5        /* max # of open files */
  305.  
  306. int sys_bufp [SYS_STD + MAXOFILES];    /* ERR or ^ buffer */
  307.  
  308. int sys_bufn [SYS_STD + MAXOFILES];    /* buffer