Annotation of coherent/b/lib/libc/stdio/_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: #include "stdio.int.h"
        !            11: 
        !            12: int
        !            13: _fputa(c, fp) int c; register FILE *fp;
        !            14: {
        !            15:        register _FILE2 *f2p;
        !            16: 
        !            17: #if    _ASCII
        !            18:        register int isascii;
        !            19: 
        !            20:        isascii = fp->_ff2 & _FASCII;
        !            21: #endif
        !            22:        /* Seek to end. */
        !            23:        if (lseek(fileno(fp), 0L, SEEK_END) == -1L)
        !            24:                return EOF;
        !            25: 
        !            26:        /* Restore appropriate put function pointer. */
        !            27:        f2p = fp->_f2p;
        !            28:        switch (fp->_mode) {
        !            29: 
        !            30:        case _MODE_UNINIT:
        !            31:                f2p->_pt = &_fpinit;
        !            32:                break;
        !            33: 
        !            34:        case _MODE_FBUF:
        !            35: #if    _ASCII
        !            36:                f2p->_pt = isascii ? &_fputba : &_fputb;
        !            37: #else
        !            38:                f2p->_pt = &_fputb;
        !            39: #endif
        !            40:                break;
        !            41: 
        !            42:        case _MODE_LBUF:
        !            43: #if    _ASCII
        !            44:                f2p->_pt = isascii ? &_fputta : &_fputt;
        !            45: #else
        !            46:                f2p->_pt = &_fputt;
        !            47: #endif
        !            48:                break;
        !            49: 
        !            50:        case _MODE_NBUF:
        !            51: #if    _ASCII
        !            52:                f2p->_pt = isascii ? &_fputca : &_fputc;
        !            53: #else
        !            54:                f2p->_pt = &_fputc;
        !            55: #endif
        !            56:                break;
        !            57: 
        !            58:        default:
        !            59:                return EOF;                             /* should not happen */
        !            60:                break;
        !            61:        }
        !            62: 
        !            63:        /* Put the character. */
        !            64:        return (*f2p->_pt)(c, fp);
        !            65: }
        !            66: 
        !            67: /* 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.