Annotation of 40BSD/libc/stdio/portli.cc, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #define        ntof(n) (&_iob[n])
        !             3: 
        !             4: int    cin     0;
        !             5: int    cout    1;
        !             6: 
        !             7: cclose(n)
        !             8: {
        !             9:        return(fclose(ntof(n)));
        !            10: }
        !            11: 
        !            12: ceof(n)
        !            13: {
        !            14:        return(feof(ntof(n)));
        !            15: }
        !            16: 
        !            17: cexit(x)
        !            18: {
        !            19:        exit(x);
        !            20: }
        !            21: 
        !            22: cflush(n)
        !            23: {
        !            24:        return(fflush(ntof(n)));
        !            25: }
        !            26: 
        !            27: cgetc(n)
        !            28: {
        !            29:        register c;
        !            30: 
        !            31:        if ((c = getc(ntof(n))) < 0)
        !            32:                return(0);
        !            33:        return(c);
        !            34: }
        !            35: 
        !            36: copen(f, m)
        !            37: char m;
        !            38: {
        !            39:        register struct _iobuf *iop;
        !            40: 
        !            41:        if ((iop = fopen(f, &m)) == NULL)
        !            42:                return(-1);
        !            43:        return(fileno(iop));
        !            44: }
        !            45: 
        !            46: cputc(c, n)
        !            47: {
        !            48:        putc(c, ntof(n));
        !            49: }
        !            50: 
        !            51: cread(a, b, c, n)
        !            52: {
        !            53:        return(fread(a, b, c, ntof(n)));
        !            54: }
        !            55: 
        !            56: cwrite(a, b, c, n)
        !            57: {
        !            58:        return(fwrite(a, b, c, ntof(n)));
        !            59: }
        !            60: getcharz()
        !            61: {
        !            62:        register c;
        !            63: 
        !            64:        if ((c = getc(ntof(cin))) < 0)
        !            65:                return(0);
        !            66:        return(c);
        !            67: }
        !            68: 
        !            69: printf(a, b, c, d)
        !            70: {
        !            71:        struct _iobuf _strbuf;
        !            72:        if (a==-1) {
        !            73:                _strbuf._flag = _IOWRT+_IOSTRG;
        !            74:                _strbuf._ptr = b;
        !            75:                _strbuf._cnt = 32767;
        !            76:                _doprnt(c, &d, &_strbuf);
        !            77:                putc('\0', &_strbuf);
        !            78:        } else if (a<=10) {
        !            79:                _doprnt(b, &c, ntof(a));
        !            80:        } else
        !            81:                _doprnt(a, &b, ntof(cout));
        !            82: }
        !            83: 
        !            84: putcharz(c)
        !            85: {
        !            86:        return(putc(c, ntof(cout)));
        !            87: }
        !            88: 
        !            89: gets(s)
        !            90: char *s;
        !            91: {
        !            92:        register c;
        !            93:        register char *cs;
        !            94: 
        !            95:        cs = s;
        !            96:        while ((c = getc(ntof(cin))) != '\n' && c>=0)
        !            97:                *cs++ = c;
        !            98:        if (c<0 && cs==s)
        !            99:                return(NULL);
        !           100:        *cs++ = '\0';
        !           101:        return(s);
        !           102: }
        !           103: 
        !           104: puts(s)
        !           105: char *s;
        !           106: {
        !           107:        register c;
        !           108: 
        !           109:        while (c = *s++)
        !           110:                putc(c, ntof(cout));
        !           111:        putc('\n', ntof(cout));
        !           112: }
        !           113: 
        !           114: rew(n)
        !           115: {
        !           116:        rewind(ntof(n));
        !           117: }
        !           118: 
        !           119: scanf(a, b, c, d)
        !           120: {
        !           121:        struct _iobuf strbuf;
        !           122:        register char *s;
        !           123: 
        !           124:        if (a == -1) {
        !           125:                strbuf._flag = _IOREAD|_IOSTRG;
        !           126:                strbuf._ptr = strbuf._base = b;
        !           127:                strbuf._cnt = 0;
        !           128:                s = b;
        !           129:                while (*s++)
        !           130:                        strbuf._cnt++;
        !           131:                return(_doscan(&strbuf, c, &d));
        !           132:        } else if (a<=10)
        !           133:                return(_doscan(ntof(a), b, &c));
        !           134:        else
        !           135:                return(_doscan(ntof(cin), a, &b));
        !           136: }

unix.superglobalmegacorp.com

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