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 #include <stdio.h> 19*7c478bd9Sstevel@tonic-gate #define COMNUM 500 20*7c478bd9Sstevel@tonic-gate #define COMTSIZE 997 21*7c478bd9Sstevel@tonic-gate 22*7c478bd9Sstevel@tonic-gate char *comname = "/usr/lib/refer/eign"; 23*7c478bd9Sstevel@tonic-gate static int cgate = 0; 24*7c478bd9Sstevel@tonic-gate extern char *comname; 25*7c478bd9Sstevel@tonic-gate int comcount = 100; 26*7c478bd9Sstevel@tonic-gate static char cbuf[COMNUM*9]; 27*7c478bd9Sstevel@tonic-gate static char *cwds[COMTSIZE]; 28*7c478bd9Sstevel@tonic-gate static char *cbp; 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate common (s) 31*7c478bd9Sstevel@tonic-gate char *s; 32*7c478bd9Sstevel@tonic-gate { 33*7c478bd9Sstevel@tonic-gate if (cgate==0) cominit(); 34*7c478bd9Sstevel@tonic-gate return (c_look(s, 1)); 35*7c478bd9Sstevel@tonic-gate } 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate cominit() 38*7c478bd9Sstevel@tonic-gate { 39*7c478bd9Sstevel@tonic-gate int i; 40*7c478bd9Sstevel@tonic-gate FILE *f; 41*7c478bd9Sstevel@tonic-gate cgate=1; 42*7c478bd9Sstevel@tonic-gate f = fopen(comname, "r"); 43*7c478bd9Sstevel@tonic-gate if (f==NULL) return; 44*7c478bd9Sstevel@tonic-gate cbp=cbuf; 45*7c478bd9Sstevel@tonic-gate for(i=0; i<comcount; i++) 46*7c478bd9Sstevel@tonic-gate { 47*7c478bd9Sstevel@tonic-gate if (fgets(cbp, 15, f)==NULL) 48*7c478bd9Sstevel@tonic-gate break; 49*7c478bd9Sstevel@tonic-gate trimnl(cbp); 50*7c478bd9Sstevel@tonic-gate c_look (cbp, 0); 51*7c478bd9Sstevel@tonic-gate while (*cbp++); 52*7c478bd9Sstevel@tonic-gate } 53*7c478bd9Sstevel@tonic-gate fclose(f); 54*7c478bd9Sstevel@tonic-gate } 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate c_look (s, fl) 57*7c478bd9Sstevel@tonic-gate char *s; 58*7c478bd9Sstevel@tonic-gate { 59*7c478bd9Sstevel@tonic-gate int h; 60*7c478bd9Sstevel@tonic-gate h = hash(s) % (COMTSIZE); 61*7c478bd9Sstevel@tonic-gate while (cwds[h] != 0) 62*7c478bd9Sstevel@tonic-gate { 63*7c478bd9Sstevel@tonic-gate if (strcmp(s, cwds[h])==0) 64*7c478bd9Sstevel@tonic-gate return(1); 65*7c478bd9Sstevel@tonic-gate h = (h+1) % (COMTSIZE); 66*7c478bd9Sstevel@tonic-gate } 67*7c478bd9Sstevel@tonic-gate if (fl==0) 68*7c478bd9Sstevel@tonic-gate cwds[h] = s; 69*7c478bd9Sstevel@tonic-gate return(0); 70*7c478bd9Sstevel@tonic-gate } 71