1: #if !defined(lint) && defined(DOSCCS) 2: static char *sccsid = "@(#)mkey3.c 4.1.1 (2.11BSD) 1996/10/23"; 3: #endif 4: 5: #include <stdio.h> 6: #define COMNUM 500 7: #define COMTSIZE 997 8: 9: char *comname = "/usr/share/misc/eign"; 10: static int cgate = 0; 11: int comcount = 100; 12: static char cbuf[COMNUM*9]; 13: static char *cwds[COMTSIZE]; 14: static char *cbp; 15: 16: common (s) 17: char *s; 18: { 19: if (cgate==0) cominit(); 20: return (c_look(s, 1)); 21: } 22: 23: cominit() 24: { 25: int i; 26: FILE *f; 27: cgate=1; 28: f = fopen(comname, "r"); 29: if (f==NULL) return; 30: cbp=cbuf; 31: for(i=0; i<comcount; i++) 32: { 33: if (fgets(cbp, 15, f)==NULL) 34: break; 35: trimnl(cbp); 36: c_look (cbp, 0); 37: while (*cbp++); 38: } 39: fclose(f); 40: } 41: 42: c_look (s, fl) 43: char *s; 44: { 45: int h; 46: h = hash(s) % (COMTSIZE); 47: while (cwds[h] != 0) 48: { 49: if (strcmp(s, cwds[h])==0) 50: return(1); 51: h = (h+1) % (COMTSIZE); 52: } 53: if (fl==0) 54: cwds[h] = s; 55: return(0); 56: }