Annotation of coherent/b/lib/libc/XSTDIO/_stropen.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libc/stdio/_stropen.c
                      3:  * ANSI-compliant C standard i/o library internals.
                      4:  * _stropen()
                      5:  * Open string stream.
                      6:  * Called by sprintf(), sscanf(), vsprintf().
                      7:  */
                      8: 
                      9: #include <stdio.h>
                     10: #include <limits.h>
                     11: 
                     12: extern int     _fputstr();
                     13: 
                     14: /* length is -1 for output to string, strlen(string) for input from string. */
                     15: FILE *
                     16: _stropen(string, length, fp) char *string; int length; register FILE *fp;
                     17: {
                     18:        register _FILE2 *f2p;
                     19: 
                     20:        f2p = fp->_f2p;
                     21:        f2p->_bp = fp->_cp = string;
                     22:        fp->_mode = _MODE_STR;
                     23:        if (length < 0) {
                     24:                fp->_ff1 |= _FWONLY;
                     25:                fp->_cc = INT_MAX;
                     26:                f2p->_pt = &_fputstr;
                     27:                f2p->_gt = &_fgete;
                     28:        } else {
                     29:                fp->_ff1 |= _FRONLY;
                     30:                fp->_cc = length;
                     31:                f2p->_pt = &_fpute;
                     32:                f2p->_gt = &_fgetstr;
                     33:        }
                     34:        return fp;
                     35: }
                     36: 
                     37: /*
                     38:  * _fputstr() is static;
                     39:  * _fgetstr() (in _fgetstr.c) is not, because it must be visible to ungetc().
                     40:  */
                     41: static
                     42: int
                     43: _fputstr(c, fp) int c; register FILE *fp;
                     44: {
                     45:        return (*fp->_cp++ = (unsigned char)c);
                     46: }
                     47: 
                     48: /* end of libc/stdio/_stropen.c */

unix.superglobalmegacorp.com

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