Annotation of researchv10no/cmd/basic/bite/src/more.c, revision 1.1

1.1     ! root        1: 
        !             2: /* Copyright Bell Telephone Laboratories Whippany, N.J.
        !             3: 
        !             4:  *     /////////////////////////////////////
        !             5:  *     /////////////////////////////////////
        !             6:  *     /////////////// more ////////////////
        !             7:  *     /// J. P. Hawkins WH X4610 8C-001 ///
        !             8:  *     ///// Sat Feb 21 08:56:12 1981 //////
        !             9:  *     /////////////////////////////////////
        !            10:  *     /////////////////////////////////////
        !            11:  *     @(#) more.c: V1.2 9/9/81
        !            12: 
        !            13: */
        !            14: #include "bas.h"
        !            15: 
        !            16: int    moreflag[8];
        !            17: char   morebuf[8][132];
        !            18: extern struct FILTBL filtbl[];
        !            19: 
        !            20: more(fnum)
        !            21: int    fnum;           /* BASIC file designator (table position) */
        !            22: {
        !            23:        int fd;
        !            24:        fd = filtbl[fnum].fildes;       /* get real filedes */
        !            25:        moreflag[fnum] = 1;             /* set data pre-read */
        !            26:        return(getmore(fd,&morebuf[fnum][0]));
        !            27: }
        !            28: 
        !            29: /*
        !            30:  *
        !            31:  * //// GET LINE FROM FILE ////
        !            32:  */
        !            33: fgetlin(tmpbuf,fnum)
        !            34: char   tmpbuf[];
        !            35: int    fnum;                   /* file designator for BASIC */
        !            36: {
        !            37:        int fd;
        !            38: 
        !            39:        fd = filtbl[fnum].fildes; /* convert to system file descriptor */
        !            40:        if(moreflag[fnum])      /* if buffer was read by "if more" */
        !            41:        {
        !            42:                strcpy(tmpbuf,&morebuf[fnum][0]); /* just copy data already read */
        !            43:                moreflag[fnum] = 0;
        !            44:        }
        !            45:        else
        !            46:        {
        !            47:                getmore(fd,tmpbuf);     /* else do the read now */
        !            48:        }
        !            49: }
        !            50: 
        !            51: getmore(fd,tmpbuf)
        !            52: int    fd;
        !            53: char   tmpbuf[];
        !            54: {
        !            55:        register i;
        !            56: 
        !            57:        i = 0;
        !            58:        while(read(fd,&tmpbuf[i],1) > 0)
        !            59:        {
        !            60:                if(tmpbuf[i] == '\n')
        !            61:                {
        !            62:                        tmpbuf[i] = '\0';
        !            63:                        return(i);
        !            64:                }
        !            65:                i++;
        !            66:        }
        !            67:        if(i == 0)  /* make sure buffer looks empty if nothing read */
        !            68:                tmpbuf[0] = '\0';
        !            69:        return(i);
        !            70: }

unix.superglobalmegacorp.com

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