Research V7 development
[unix-history] / usr / src / cmd / refer / deliv2.c
CommitLineData
52960f2f
ML
1# include "stdio.h"
2hash (s)
3 char *s;
4{
5int c, n;
6for(n=0; c= *s; s++)
7 n += (c*n+ c << (n%4));
8return(n>0 ? n : -n);
9}
10err (s, a)
11 char *s;
12{
13fprintf(stderr, "Error: ");
14fprintf(stderr, s, a);
15putc('\n', stderr);
16exit(1);
17}
18prefix(t, s)
19 char *t, *s;
20{
21int c, d;
22while ( (c= *t++) == *s++)
23 if (c==0) return(1);
24return(c==0 ? 1: 0);
25}
26mindex(s, c)
27 char *s;
28{
29register char *p;
30for( p=s; *p; p++)
31 if (*p ==c)
32 return(p);
33return(0);
34}
35zalloc(m,n)
36{
37 int t;
38# if D1
39fprintf(stderr, "calling calloc for %d*%d bytes\n",m,n);
40# endif
41t = calloc(m,n);
42# if D1
43fprintf(stderr, "calloc returned %o\n", t);
44# endif
45return(t);
46}