1*16626Ssam /* defs.h 1.2 84/06/23 */ 2*16626Ssam 314605Ssam /* 414605Ssam * Public definitions, common to all. 514605Ssam */ 614605Ssam 714605Ssam #include <stdio.h> 814605Ssam 914605Ssam #define new(type) ((type) malloc(sizeof(struct type))) 1014605Ssam #define newarr(type, n) ((type *) malloc((unsigned) (n) * sizeof(type))) 1114605Ssam #define dispose(ptr) { free((char *) ptr); ptr = 0; } 1214605Ssam 1314605Ssam #define public 1414605Ssam #define private static 1514605Ssam 1614605Ssam #define ord(enumcon) ((unsigned int) enumcon) 1714605Ssam #define nil 0 1814605Ssam #define and && 1914605Ssam #define or || 2014605Ssam #define not ! 2114605Ssam #define div / 2214605Ssam #define mod % 2314605Ssam #define max(a, b) ((a) > (b) ? (a) : (b)) 2414605Ssam #define min(a, b) ((a) < (b) ? (a) : (b)) 2514605Ssam 2614605Ssam #define assert(b) { \ 2714605Ssam if (not(b)) { \ 2814605Ssam panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \ 2914605Ssam } \ 3014605Ssam } 3114605Ssam 3214605Ssam #define badcaseval(v) { \ 3314605Ssam panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \ 3414605Ssam } 3514605Ssam 3614605Ssam #define checkref(p) { \ 3714605Ssam if (p == nil) { \ 3814605Ssam panic("reference through nil pointer at line %d in file %s", \ 3914605Ssam __LINE__, __FILE__); \ 4014605Ssam } \ 4114605Ssam } 4214605Ssam 4314605Ssam typedef int Integer; 4416608Ssam typedef int integer; 4514605Ssam typedef char Char; 4614605Ssam typedef double Real; 4716608Ssam typedef double real; 4814605Ssam typedef enum { false, true } Boolean; 4916608Ssam typedef Boolean boolean; 5014605Ssam typedef char *String; 5114605Ssam 5214605Ssam #define strdup(s) strcpy(malloc((unsigned) strlen(s) + 1), s) 5314605Ssam #define streq(s1, s2) (strcmp(s1, s2) == 0) 5414605Ssam 5514605Ssam typedef FILE *File; 5614605Ssam typedef int Fileid; 5714605Ssam typedef String Filename; 5814605Ssam 5914605Ssam #define get(f, var) fread((char *) &(var), sizeof(var), 1, f) 6014605Ssam #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f) 6114605Ssam 6214605Ssam #undef FILE 6314605Ssam 6414605Ssam extern long atol(); 6514605Ssam extern double atof(); 6614605Ssam extern char *malloc(); 6714605Ssam extern String strcpy(), index(), rindex(); 6814605Ssam extern int strlen(); 6914605Ssam 7014605Ssam extern String cmdname; 7114605Ssam extern String errfilename; 7214605Ssam extern short errlineno; 7314605Ssam extern int debug_flag[]; 74