int __cdecl _vsnwprintf (
        wchar_t *string,
        size_t count,
        const wchar_t *format,
        va_list ap
        )
#endif  /* _COUNT_ */

{
        FILE str;
        REG1 FILE *outfile = &str;
        REG2 int retval;

        _ASSERTE(string != NULL);
        _ASSERTE(format != NULL);

        outfile->_flag = _IOWRT|_IOSTRG;
        outfile->_ptr = outfile->_base = (char *) string;
#ifndef _COUNT_
        outfile->_cnt = MAXSTR;
#else  /* _COUNT_ */
        outfile->_cnt = count*sizeof(wchar_t);
#endif  /* _COUNT_ */

        retval = _woutput(outfile,format,ap );
        _putc_lk('\0',outfile);     /* no-lock version */
        _putc_lk('\0',outfile);     /* 2nd byte for wide char version */

        return(retval);
}
Beispiel #2
0
int __cdecl _snprintf (
	char *string,
	size_t count,
	const char *format,
	...
	)
#endif

{
	FILE str;
	REG1 FILE *outfile = &str;
	va_list arglist;
	REG2 int retval;

	va_start(arglist, format);

	_ASSERTE(string != NULL);
	_ASSERTE(format != NULL);

	outfile->_flag = _IOWRT|_IOSTRG;
	outfile->_ptr = outfile->_base = string;
#ifndef _COUNT_
	outfile->_cnt = MAXSTR;
#else
	outfile->_cnt = count;
#endif

	retval = _output(outfile,format,arglist);

	_putc_lk('\0',outfile); /* no-lock version */

	return(retval);
}
int __cdecl _vsnprintf (
        char *string,
        size_t count,
        const char *format,
        va_list ap
        )
#endif  /* _COUNT_ */

{
        FILE str;
        REG1 FILE *outfile = &str;
        REG2 int retval;

        _ASSERTE(string != NULL);
        _ASSERTE(format != NULL);

        outfile->_flag = _IOWRT|_IOSTRG;
        outfile->_ptr = outfile->_base = string;
#ifndef _COUNT_
        outfile->_cnt = MAXSTR;
#else  /* _COUNT_ */
        outfile->_cnt = count;
#endif  /* _COUNT_ */

        retval = _output(outfile,format,ap );
        _putc_lk('\0',outfile);

        return(retval);
}
Beispiel #4
0
int __cdecl _putw (
    int word,
    FILE *str
)
{
    REG1 FILE *stream;
    REG3 int bytecount = sizeof(int);
    REG2 char *byteptr = (char *)&word;
    int retval;

    _ASSERTE(str != NULL);

    /* Init stream pointer */
    stream = str;

    _lock_str(stream);

    while (bytecount--)
    {
        _putc_lk(*byteptr,stream);
        ++byteptr;
    }
    retval = (ferror(stream) ? EOF : word);

    _unlock_str(stream);
    return(retval);
}
Beispiel #5
0
wint_t __cdecl fputwc (
        wint_t ch,
        FILE *str
        )
{

#endif  /* _MT */

        if (!(str->_flag & _IOSTRG) && (_osfile_safe(_fileno(str)) & FTEXT))
        {
                int size;
                char mbc[4];

                /* text (multi-byte) mode */
                if ((size = wctomb(mbc, ch)) == -1)
                {
                        /*
                         * Conversion failed! Set errno and return
                         * failure.
                         */
                        errno = EILSEQ;
                        return WEOF;
                }
                else if ( size == 1 )
                {
                        if ( _putc_lk(mbc[0], str) == EOF )
                                return WEOF;
                        return (wint_t)(0xffff & ch);
                }
                else { /* size == 2 */
                        if ( (_putc_lk(mbc[0], str) == EOF) ||
                             (_putc_lk(mbc[1], str) == EOF) )
                                return WEOF;
                        return (wint_t)(0xffff & ch);
                }
        }
        /* binary (Unicode) mode */
        if ( (str->_cnt -= sizeof(wchar_t)) >= 0 )
                return (wint_t) (0xffff & (*((wchar_t *)(str->_ptr))++ = (wchar_t)ch));
        else
                return (wint_t) _flswbuf(ch, str);
}
int __cdecl _putts (
        const _TCHAR *string
        )
{
        int buffing;
#ifndef _UNICODE
        unsigned int length;
        unsigned int ndone;
#endif  /* _UNICODE */
        int retval = _TEOF; /* error */

        _ASSERTE(string != NULL);

        _lock_str2(1, stdout);
        buffing = _stbuf(stdout);

#ifdef _UNICODE
        while (*string) {
            if (_putwchar_lk(*string++) == WEOF)
                goto done;
        }
        if (_putwchar_lk(L'\n') != WEOF)
            retval = 0; /* success */
#else  /* _UNICODE */
        length = strlen(string);
        ndone = _fwrite_lk(string,1,length,stdout);

        if (ndone == length) {
                _putc_lk('\n',stdout);
                retval = 0;     /* success */
        }
#endif  /* _UNICODE */

#ifdef _UNICODE
done:
#endif  /* _UNICODE */
        _ftbuf(buffing, stdout);
        _unlock_str2(1, stdout);

        return retval;
}