11682Smckusick /* Copyright (c) 1979 Regents of the University of California */ 21682Smckusick 3*2309Smckusic static char sccsid[] = "@(#)READE.c 1.3 01/28/81"; 41682Smckusick 51682Smckusick #include "h00vars.h" 61682Smckusick #include "h01errs.h" 71682Smckusick 81682Smckusick READE(curfile, name) 91682Smckusick 101682Smckusick register struct iorec *curfile; 111682Smckusick char *name; 121682Smckusick { 131682Smckusick long data; 141682Smckusick 151682Smckusick register short *sptr; 161682Smckusick register int len; 171682Smckusick register int nextlen; 181682Smckusick register int cnt; 191682Smckusick char *cp; 201682Smckusick char namebuf[NAMSIZ]; 212223Smckusic int retval; 221682Smckusick 231682Smckusick if (curfile->funit & FWRITE) { 241682Smckusick ERROR(EREADIT, curfile->pfname); 251682Smckusick return; 261682Smckusick } 271682Smckusick UNSYNC(curfile); 282223Smckusic retval = fscanf(curfile->fbuf, 291682Smckusick "%*[ \t\n]%74[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]", 302223Smckusic namebuf); 312223Smckusic if (retval == EOF) { 322223Smckusic ERROR(EPASTEOF, curfile->pfname); 332223Smckusic return; 342223Smckusic } 352223Smckusic if (retval == 0) { 361682Smckusick ERROR(ENUMNTFD, namebuf); 371682Smckusick return; 381682Smckusick } 39*2309Smckusic curfile->funit &= ~EOLN; 401682Smckusick curfile->funit |= SYNC; 411682Smckusick for (len = 0; len < NAMSIZ && namebuf[len]; len++) 421682Smckusick /* void */; 431682Smckusick len++; 441682Smckusick sptr = (short *)name; 451682Smckusick cnt = *sptr++; 461682Smckusick cp = name + sizeof (short) + *sptr; 471682Smckusick do { 481682Smckusick nextlen = *sptr++; 491682Smckusick nextlen = *sptr - nextlen; 501682Smckusick if (nextlen == len && RELEQ(len, namebuf, cp)) { 511682Smckusick return *((short *) name) - cnt; 521682Smckusick } 531682Smckusick cp += nextlen; 541682Smckusick } while (--cnt); 551682Smckusick ERROR(ENUMNTFD, namebuf); 561682Smckusick } 57