1 /*- 2 * %sccs.include.proprietary.c% 3 */ 4 5 #ifndef lint 6 static char sccsid[] = "@(#)deliv2.c 4.2 (Berkeley) 04/18/91"; 7 #endif /* not lint */ 8 9 #include <stdio.h> 10 11 hash (s) 12 char *s; 13 { 14 int c, n; 15 for(n=0; c= *s; s++) 16 n += (c*n+ c << (n%4)); 17 return(n>0 ? n : -n); 18 } 19 20 err (s, a) 21 char *s; 22 { 23 fprintf(stderr, "Error: "); 24 fprintf(stderr, s, a); 25 putc('\n', stderr); 26 exit(1); 27 } 28 29 prefix(t, s) 30 char *t, *s; 31 { 32 int c; 33 34 while ((c= *t++) == *s++) 35 if (c==0) return(1); 36 return(c==0 ? 1: 0); 37 } 38 39 char * 40 mindex(s, c) 41 char *s; 42 { 43 register char *p; 44 for( p=s; *p; p++) 45 if (*p ==c) 46 return(p); 47 return(0); 48 } 49 50 zalloc(m,n) 51 { 52 char *calloc(); 53 int t; 54 # if D1 55 fprintf(stderr, "calling calloc for %d*%d bytes\n",m,n); 56 # endif 57 t = (int) calloc(m,n); 58 # if D1 59 fprintf(stderr, "calloc returned %o\n", t); 60 # endif 61 return(t); 62 } 63