1: /* 2: * Copyright (c) 1983 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)defs.h 5.1 (Berkeley) 5/31/85 7: */ 8: 9: /* 10: * Public definitions, common to all. 11: */ 12: 13: #include <stdio.h> 14: 15: #define new(type) ((type) malloc(sizeof(struct type))) 16: #define newarr(type, n) ((type *) malloc((unsigned) (n) * sizeof(type))) 17: #define dispose(ptr) { free((char *) ptr); ptr = 0; } 18: 19: #define public 20: #define private static 21: 22: #define ord(enumcon) ((unsigned int) enumcon) 23: #define nil 0 24: #define and && 25: #define or || 26: #define not ! 27: #define div / 28: #define mod % 29: #define max(a, b) ((a) > (b) ? (a) : (b)) 30: #define min(a, b) ((a) < (b) ? (a) : (b)) 31: 32: #define assert(b) { \ 33: if (not(b)) { \ 34: panic("assertion failed at line %d in file %s", __LINE__, __FILE__); \ 35: } \ 36: } 37: 38: #define badcaseval(v) { \ 39: panic("unexpected value %d at line %d in file %s", v, __LINE__, __FILE__); \ 40: } 41: 42: #define checkref(p) { \ 43: if (p == nil) { \ 44: panic("reference through nil pointer at line %d in file %s", \ 45: __LINE__, __FILE__); \ 46: } \ 47: } 48: 49: typedef int Integer; 50: typedef int integer; 51: typedef char Char; 52: typedef double Real; 53: typedef double real; 54: typedef enum { false, true } Boolean; 55: typedef Boolean boolean; 56: typedef char *String; 57: 58: #define strdup(s) strcpy(malloc((unsigned) strlen(s) + 1), s) 59: #define streq(s1, s2) (strcmp(s1, s2) == 0) 60: 61: typedef FILE *File; 62: typedef int Fileid; 63: typedef String Filename; 64: 65: #define get(f, var) fread((char *) &(var), sizeof(var), 1, f) 66: #define put(f, var) fwrite((char *) &(var), sizeof(var), 1, f) 67: 68: #undef FILE 69: 70: extern long atol(); 71: extern double atof(); 72: extern char *malloc(); 73: extern String strcpy(), index(), rindex(); 74: extern int strlen(); 75: 76: extern String cmdname; 77: extern String errfilename; 78: extern short errlineno; 79: extern int debug_flag[];