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