1*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate */ 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate /* 12*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 14*7c478bd9Sstevel@tonic-gate */ 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate 19*7c478bd9Sstevel@tonic-gate #include <stdio.h> 20*7c478bd9Sstevel@tonic-gate #include <locale.h> 21*7c478bd9Sstevel@tonic-gate 22*7c478bd9Sstevel@tonic-gate hash (s) 23*7c478bd9Sstevel@tonic-gate char *s; 24*7c478bd9Sstevel@tonic-gate { 25*7c478bd9Sstevel@tonic-gate int c, n; 26*7c478bd9Sstevel@tonic-gate for(n=0; c= *s; s++) 27*7c478bd9Sstevel@tonic-gate n += (c*n+ c << (n%4)); 28*7c478bd9Sstevel@tonic-gate return(n>0 ? n : -n); 29*7c478bd9Sstevel@tonic-gate } 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate err (s, a) 32*7c478bd9Sstevel@tonic-gate char *s; 33*7c478bd9Sstevel@tonic-gate { 34*7c478bd9Sstevel@tonic-gate fprintf(stderr, gettext("Error: ")); 35*7c478bd9Sstevel@tonic-gate fprintf(stderr, s, a); 36*7c478bd9Sstevel@tonic-gate putc('\n', stderr); 37*7c478bd9Sstevel@tonic-gate exit(1); 38*7c478bd9Sstevel@tonic-gate } 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate prefix(t, s) 41*7c478bd9Sstevel@tonic-gate char *t, *s; 42*7c478bd9Sstevel@tonic-gate { 43*7c478bd9Sstevel@tonic-gate int c; 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate while ((c= *t++) == *s++) 46*7c478bd9Sstevel@tonic-gate if (c==0) return(1); 47*7c478bd9Sstevel@tonic-gate return(c==0 ? 1: 0); 48*7c478bd9Sstevel@tonic-gate } 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate char * 51*7c478bd9Sstevel@tonic-gate mindex(s, c) 52*7c478bd9Sstevel@tonic-gate char *s; 53*7c478bd9Sstevel@tonic-gate { 54*7c478bd9Sstevel@tonic-gate register char *p; 55*7c478bd9Sstevel@tonic-gate for( p=s; *p; p++) 56*7c478bd9Sstevel@tonic-gate if (*p ==c) 57*7c478bd9Sstevel@tonic-gate return(p); 58*7c478bd9Sstevel@tonic-gate return(0); 59*7c478bd9Sstevel@tonic-gate } 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate zalloc(m,n) 62*7c478bd9Sstevel@tonic-gate { 63*7c478bd9Sstevel@tonic-gate char *calloc(); 64*7c478bd9Sstevel@tonic-gate int t; 65*7c478bd9Sstevel@tonic-gate # if D1 66*7c478bd9Sstevel@tonic-gate fprintf(stderr, "calling calloc for %d*%d bytes\n",m,n); 67*7c478bd9Sstevel@tonic-gate # endif 68*7c478bd9Sstevel@tonic-gate t = (int) calloc(m,n); 69*7c478bd9Sstevel@tonic-gate # if D1 70*7c478bd9Sstevel@tonic-gate fprintf(stderr, "calloc returned %o\n", t); 71*7c478bd9Sstevel@tonic-gate # endif 72*7c478bd9Sstevel@tonic-gate return(t); 73*7c478bd9Sstevel@tonic-gate } 74