1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)useful.h 4.5 (Berkeley) 12/28/88 18 */ 19 20 # include <sys/types.h> 21 22 /* support for bool type */ 23 typedef char bool; 24 # define TRUE 1 25 # define FALSE 0 26 27 # ifndef NULL 28 # define NULL 0 29 # endif NULL 30 31 /* bit hacking */ 32 # define bitset(bit, word) (((word) & (bit)) != 0) 33 34 /* some simple functions */ 35 # ifndef max 36 # define max(a, b) ((a) > (b) ? (a) : (b)) 37 # define min(a, b) ((a) < (b) ? (a) : (b)) 38 # endif max 39 40 /* assertions */ 41 # ifndef NASSERT 42 # define ASSERT(expr, msg, parm)\ 43 if (!(expr))\ 44 {\ 45 fprintf(stderr, "assertion botch: %s:%d: ", __FILE__, __LINE__);\ 46 fprintf(stderr, msg, parm);\ 47 } 48 # else NASSERT 49 # define ASSERT(expr, msg, parm) 50 # endif NASSERT 51 52 /* sccs id's */ 53 # ifndef lint 54 # define SCCSID(arg) static char SccsId[] = "arg"; 55 # else lint 56 # define SCCSID(arg) 57 # endif lint 58 59 /* define the types of some common functions */ 60 extern char *strcpy(), *strncpy(); 61 extern char *strcat(), *strncat(); 62 extern char *malloc(); 63 extern char *index(), *rindex(); 64 extern int errno; 65 extern time_t time(); 66 extern char *ctime(); 67 extern char *getenv(); 68