Annotation of coherent/b/lib/libc/stdio/_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: #include "stdio.int.h"
                     12: 
                     13: extern int     _fputstr();
                     14: 
                     15: /* length is -1 for output to string, strlen(string) for input from string. */
                     16: FILE *
                     17: _stropen(string, length, fp) char *string; int length; register FILE *fp;
                     18: {
                     19:        register _FILE2 *f2p;
                     20: 
                     21:        f2p = fp->_f2p;
                     22:        f2p->_bp = fp->_cp = string;
                     23:        f2p->_dp = f2p->_ep = f2p->_nm = NULL;
                     24:        fp->_mode = _MODE_STR;
                     25:        fp->_ff1 = fp->_ff2 = fp->_fd = f2p->_uc = 0;
                     26:        if (length < 0) {
                     27:                fp->_ff1 |= _FWONLY;
                     28:                fp->_cc = INT_MAX;
                     29:                f2p->_pt = &_fputstr;
                     30:                f2p->_gt = &_fgete;
                     31:        } else {
                     32:                fp->_ff1 |= _FRONLY;
                     33:                fp->_cc = length;
                     34:                f2p->_pt = &_fpute;
                     35:                f2p->_gt = &_fgetstr;
                     36:        }
                     37:        return fp;
                     38: }
                     39: 
                     40: /*
                     41:  * _fputstr() is static;
                     42:  * _fgetstr() (in _fgetstr.c) is not, because it must be visible to ungetc().
                     43:  */
                     44: static
                     45: int
                     46: _fputstr(c, fp) int c; register FILE *fp;
                     47: {
                     48:        return (*fp->_cp++ = (unsigned char)c);
                     49: }
                     50: 
                     51: /* 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.