11682Smckusick /* Copyright (c) 1979 Regents of the University of California */ 21682Smckusick 3*2223Smckusic static char sccsid[] = "@(#)READE.c 1.2 01/24/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]; 21*2223Smckusic int retval; 221682Smckusick 231682Smckusick if (curfile->funit & FWRITE) { 241682Smckusick ERROR(EREADIT, curfile->pfname); 251682Smckusick return; 261682Smckusick } 271682Smckusick UNSYNC(curfile); 28*2223Smckusic retval = fscanf(curfile->fbuf, 291682Smckusick "%*[ \t\n]%74[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]", 30*2223Smckusic namebuf); 31*2223Smckusic if (retval == EOF) { 32*2223Smckusic ERROR(EPASTEOF, curfile->pfname); 33*2223Smckusic return; 34*2223Smckusic } 35*2223Smckusic if (retval == 0) { 361682Smckusick ERROR(ENUMNTFD, namebuf); 371682Smckusick return; 381682Smckusick } 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 } 521682Smckusick cp += nextlen; 531682Smckusick } while (--cnt); 541682Smckusick ERROR(ENUMNTFD, namebuf); 551682Smckusick } 56