1*1682Smckusick /* Copyright (c) 1979 Regents of the University of California */ 2*1682Smckusick 3*1682Smckusick static char sccsid[] = "@(#)READE.c 1.1 10/30/80"; 4*1682Smckusick 5*1682Smckusick #include "h00vars.h" 6*1682Smckusick #include "h01errs.h" 7*1682Smckusick 8*1682Smckusick READE(curfile, name) 9*1682Smckusick 10*1682Smckusick register struct iorec *curfile; 11*1682Smckusick char *name; 12*1682Smckusick { 13*1682Smckusick long data; 14*1682Smckusick 15*1682Smckusick register short *sptr; 16*1682Smckusick register int len; 17*1682Smckusick register int nextlen; 18*1682Smckusick register int cnt; 19*1682Smckusick char *cp; 20*1682Smckusick char namebuf[NAMSIZ]; 21*1682Smckusick 22*1682Smckusick if (curfile->funit & FWRITE) { 23*1682Smckusick ERROR(EREADIT, curfile->pfname); 24*1682Smckusick return; 25*1682Smckusick } 26*1682Smckusick UNSYNC(curfile); 27*1682Smckusick if (fscanf(curfile->fbuf, 28*1682Smckusick "%*[ \t\n]%74[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]", 29*1682Smckusick namebuf) == 0) { 30*1682Smckusick ERROR(ENUMNTFD, namebuf); 31*1682Smckusick return; 32*1682Smckusick } 33*1682Smckusick curfile->funit |= SYNC; 34*1682Smckusick for (len = 0; len < NAMSIZ && namebuf[len]; len++) 35*1682Smckusick /* void */; 36*1682Smckusick len++; 37*1682Smckusick sptr = (short *)name; 38*1682Smckusick cnt = *sptr++; 39*1682Smckusick cp = name + sizeof (short) + *sptr; 40*1682Smckusick do { 41*1682Smckusick nextlen = *sptr++; 42*1682Smckusick nextlen = *sptr - nextlen; 43*1682Smckusick if (nextlen == len && RELEQ(len, namebuf, cp)) { 44*1682Smckusick return *((short *) name) - cnt; 45*1682Smckusick } 46*1682Smckusick cp += nextlen; 47*1682Smckusick } while (--cnt); 48*1682Smckusick ERROR(ENUMNTFD, namebuf); 49*1682Smckusick } 50