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