Annotation of 43BSDTahoe/usr.lib/libpc/READE.c, revision 1.1

1.1     ! root        1: /* Copyright (c) 1979 Regents of the University of California */
        !             2: 
        !             3: static char sccsid[] = "@(#)READE.c 1.6 10/28/83";
        !             4: 
        !             5: #include "h00vars.h"
        !             6: 
        !             7: long
        !             8: READE(curfile, name)
        !             9: 
        !            10:        register struct iorec   *curfile;
        !            11:        char                    *name;
        !            12: {
        !            13:        register short  *sptr;
        !            14:        register int    len;
        !            15:        register int    nextlen;
        !            16:        register int    cnt;
        !            17:        char            *cp;
        !            18:        char            namebuf[NAMSIZ];
        !            19:        int             retval;
        !            20: 
        !            21:        if (curfile->funit & FWRITE) {
        !            22:                ERROR("%s: Attempt to read, but open for writing\n",
        !            23:                        curfile->pfname);
        !            24:                return;
        !            25:        }
        !            26:        UNSYNC(curfile);
        !            27:        retval = fscanf(curfile->fbuf,
        !            28:            "%*[ \t\n]%74[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]",
        !            29:            namebuf);
        !            30:        if (retval == EOF) {
        !            31:                ERROR("%s: Tried to read past end of file\n", curfile->pfname);
        !            32:                return;
        !            33:        }
        !            34:        if (retval == 0)
        !            35:                goto ename;
        !            36:        for (len = 0; len < NAMSIZ && namebuf[len]; len++)
        !            37:                /* void */;
        !            38:        len++;
        !            39:        sptr = (short *)name;
        !            40:        cnt = *sptr++;
        !            41:        cp = name + sizeof (short) + *sptr;
        !            42:        do      {
        !            43:                nextlen = *sptr++;
        !            44:                nextlen = *sptr - nextlen;
        !            45:                if (nextlen == len && RELEQ(len, namebuf, cp)) {
        !            46:                        return *((short *) name) - cnt;
        !            47:                }
        !            48:                cp += (int)nextlen;
        !            49:        } while (--cnt);
        !            50: ename:
        !            51:        ERROR("Unknown name \"%s\" found on enumerated type read\n", namebuf);
        !            52: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.