1*21629Sdist /* 2*21629Sdist * Copyright (c) 1983 Regents of the University of California. 3*21629Sdist * All rights reserved. The Berkeley software License Agreement 4*21629Sdist * specifies the terms and conditions for redistribution. 5*21629Sdist * 6*21629Sdist * @(#)defs.h 5.1 (Berkeley) 05/31/85 7*21629Sdist */ 816626Ssam 914605Ssam /* 1014605Ssam * Public definitions, common to all. 1114605Ssam */ 1214605Ssam 1314605Ssam #include <stdio.h> 1414605Ssam 1514605Ssam #define new(type) ((type) malloc(sizeof(struct type))) 1614605Ssam #define newarr(type, n) ((type *) malloc((unsigned) (n) * sizeof(type))) 1714605Ssam #define dispose(ptr) { free((char *) ptr); ptr = 0; } 1814605Ssam 1914605Ssam #define public 2014605Ssam #define private static 2114605Ssam 2214605Ssam #define ord(enumcon) ((unsigned int) enumcon) 2314605Ssam #define nil 0 2414605Ssam #define and && 2514605Ssam #define or || 2614605Ssam #define not ! 2714605Ssam #define div / 2814605Ssam #define mod % 2914605Ssam #define max(a, b) ((a) > (b) ? (a) : (b)) 3014605Ssam #define min(a, b) ((a) < (b) ? (a) : (b)) 3114605Ssam 3214605Ssam #define assert(b) { \ 3314605Ssam if (not(b)) { \ 3414605Ssam panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \ 3514605Ssam } \ 3614605Ssam } 3714605Ssam 3814605Ssam #define badcaseval(v) { \ 3914605Ssam panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \ 4014605Ssam } 4114605Ssam 4214605Ssam #define checkref(p) { \ 4314605Ssam if (p == nil) { \ 4414605Ssam panic("reference through nil pointer at line %d in file %s", \ 4514605Ssam __LINE__, __FILE__); \ 4614605Ssam } \ 4714605Ssam } 4814605Ssam 4914605Ssam typedef int Integer; 5016608Ssam typedef int integer; 5114605Ssam typedef char Char; 5214605Ssam typedef double Real; 5316608Ssam typedef double real; 5414605Ssam typedef enum { false, true } Boolean; 5516608Ssam typedef Boolean boolean; 5614605Ssam typedef char *String; 5714605Ssam 5814605Ssam #define strdup(s) strcpy(malloc((unsigned) strlen(s) + 1), s) 5914605Ssam #define streq(s1, s2) (strcmp(s1, s2) == 0) 6014605Ssam 6114605Ssam typedef FILE *File; 6214605Ssam typedef int Fileid; 6314605Ssam typedef String Filename; 6414605Ssam 6514605Ssam #define get(f, var) fread((char *) &(var), sizeof(var), 1, f) 6614605Ssam #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f) 6714605Ssam 6814605Ssam #undef FILE 6914605Ssam 7014605Ssam extern long atol(); 7114605Ssam extern double atof(); 7214605Ssam extern char *malloc(); 7314605Ssam extern String strcpy(), index(), rindex(); 7414605Ssam extern int strlen(); 7514605Ssam 7614605Ssam extern String cmdname; 7714605Ssam extern String errfilename; 7814605Ssam extern short errlineno; 7914605Ssam extern int debug_flag[]; 80