1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)useful.h 4.6 (Berkeley) 06/01/90 8 */ 9 10 # include <sys/types.h> 11 12 /* support for bool type */ 13 typedef char bool; 14 # define TRUE 1 15 # define FALSE 0 16 17 # ifndef NULL 18 # define NULL 0 19 # endif NULL 20 21 /* bit hacking */ 22 # define bitset(bit, word) (((word) & (bit)) != 0) 23 24 /* some simple functions */ 25 # ifndef max 26 # define max(a, b) ((a) > (b) ? (a) : (b)) 27 # define min(a, b) ((a) < (b) ? (a) : (b)) 28 # endif max 29 30 /* assertions */ 31 # ifndef NASSERT 32 # define ASSERT(expr, msg, parm)\ 33 if (!(expr))\ 34 {\ 35 fprintf(stderr, "assertion botch: %s:%d: ", __FILE__, __LINE__);\ 36 fprintf(stderr, msg, parm);\ 37 } 38 # else NASSERT 39 # define ASSERT(expr, msg, parm) 40 # endif NASSERT 41 42 /* sccs id's */ 43 # ifndef lint 44 # define SCCSID(arg) static char SccsId[] = "arg"; 45 # else lint 46 # define SCCSID(arg) 47 # endif lint 48 49 /* define the types of some common functions */ 50 extern char *strcpy(), *strncpy(); 51 extern char *strcat(), *strncat(); 52 extern char *malloc(); 53 extern char *index(), *rindex(); 54 extern int errno; 55 extern time_t time(); 56 extern char *ctime(); 57 extern char *getenv(); 58