Annotation of coherent/b/lib/libc/XSTDIO/_fputa.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * libc/stdio/_fputa.c
        !             3:  * ANSI-compliant C standard i/o library internals.
        !             4:  * _fputa()
        !             5:  * Append character to end of file.
        !             6:  * Executed on first write after seek on append mode stream.
        !             7:  */
        !             8: 
        !             9: #include <stdio.h>
        !            10: 
        !            11: int
        !            12: _fputa(c, fp) int c; register FILE *fp;
        !            13: {
        !            14:        register _FILE2 *f2p;
        !            15: 
        !            16: #if    _ASCII
        !            17:        register int isascii;
        !            18: 
        !            19:        isascii = fp->_ff2 & _FASCII;
        !            20: #endif
        !            21:        /* Seek to end. */
        !            22:        if (lseek(fileno(fp), 0L, SEEK_END) == -1L)
        !            23:                return EOF;
        !            24: 
        !            25:        /* Restore appropriate put function pointer. */
        !            26:        f2p = fp->_f2p;
        !            27:        switch (fp->_mode) {
        !            28: 
        !            29:        case _MODE_UNINIT:
        !            30:                f2p->_pt = &_fpinit;
        !            31:                break;
        !            32: 
        !            33:        case _MODE_FBUF:
        !            34: #if    _ASCII
        !            35:                f2p->_pt = isascii ? &_fputba : &_fputb;
        !            36: #else
        !            37:                f2p->_pt = &_fputb;
        !            38: #endif
        !            39:                break;
        !            40: 
        !            41:        case _MODE_LBUF:
        !            42: #if    _ASCII
        !            43:                f2p->_pt = isascii ? &_fputta : &_fputt;
        !            44: #else
        !            45:                f2p->_pt = &_fputt;
        !            46: #endif
        !            47:                break;
        !            48: 
        !            49:        case _MODE_NBUF:
        !            50: #if    _ASCII
        !            51:                f2p->_pt = isascii ? &_fputca : &_fputc;
        !            52: #else
        !            53:                f2p->_pt = &_fputc;
        !            54: #endif
        !            55:                break;
        !            56: 
        !            57:        default:
        !            58:                return EOF;                             /* should not happen */
        !            59:                break;
        !            60:        }
        !            61: 
        !            62:        /* Put the character. */
        !            63:        return (*f2p->_pt)(c, fp);
        !            64: }
        !            65: 
        !            66: /* end of libc/stdio/_fputa.c */

unix.superglobalmegacorp.com

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