|
|
1.1 ! root 1: #ifndef lint ! 2: static char *sccsid = "@(#)mkey3.c 4.1 (Berkeley) 5/6/83"; ! 3: #endif ! 4: ! 5: #include <stdio.h> ! 6: #define COMNUM 500 ! 7: #define COMTSIZE 997 ! 8: ! 9: char *comname = "/usr/lib/eign"; ! 10: static int cgate = 0; ! 11: extern char *comname; ! 12: int comcount = 100; ! 13: static char cbuf[COMNUM*9]; ! 14: static char *cwds[COMTSIZE]; ! 15: static char *cbp; ! 16: ! 17: common (s) ! 18: char *s; ! 19: { ! 20: if (cgate==0) cominit(); ! 21: return (c_look(s, 1)); ! 22: } ! 23: ! 24: cominit() ! 25: { ! 26: int i; ! 27: FILE *f; ! 28: cgate=1; ! 29: f = fopen(comname, "r"); ! 30: if (f==NULL) return; ! 31: cbp=cbuf; ! 32: for(i=0; i<comcount; i++) ! 33: { ! 34: if (fgets(cbp, 15, f)==NULL) ! 35: break; ! 36: trimnl(cbp); ! 37: c_look (cbp, 0); ! 38: while (*cbp++); ! 39: } ! 40: fclose(f); ! 41: } ! 42: ! 43: c_look (s, fl) ! 44: char *s; ! 45: { ! 46: int h; ! 47: h = hash(s) % (COMTSIZE); ! 48: while (cwds[h] != 0) ! 49: { ! 50: if (strcmp(s, cwds[h])==0) ! 51: return(1); ! 52: h = (h+1) % (COMTSIZE); ! 53: } ! 54: if (fl==0) ! 55: cwds[h] = s; ! 56: return(0); ! 57: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.