int __cdecl _snprintf_c( char* string, size_t count, const char* format, ... ) #endif /* _SWPRINTFS_ERROR_RETURN_FIX */ #endif /* _COUNT_ */ { FILE str; REG1 FILE* outfile = &str; va_list arglist; REG2 int retval; _VALIDATE_RETURN((format != NULL), EINVAL, -1); #ifdef _COUNT_ _VALIDATE_RETURN((count == 0) || (string != NULL), EINVAL, -1); #else /* _COUNT_ */ _VALIDATE_RETURN((string != NULL), EINVAL, -1); #endif /* _COUNT_ */ va_start(arglist, format); #ifndef _COUNT_ outfile->_cnt = MAXSTR; #else /* _COUNT_ */ if (count > INT_MAX) { /* old-style functions allow any large value to mean unbounded */ outfile->_cnt = INT_MAX; } else { outfile->_cnt = (int)(count); } #endif /* _COUNT_ */ outfile->_flag = _IOWRT | _IOSTRG; outfile->_ptr = outfile->_base = string; retval = _output_l(outfile, format, NULL, arglist); if (string == NULL) { return (retval); } #ifndef _SWPRINTFS_ERROR_RETURN_FIX _putc_nolock('\0', outfile); /* no-lock version */ return (retval); #else /* _SWPRINTFS_ERROR_RETURN_FIX */ if ((retval >= 0) && (_putc_nolock('\0', outfile) != EOF)) { return (retval); } string[0] = 0; return -1; #endif /* _SWPRINTFS_ERROR_RETURN_FIX */ }
int __cdecl _putw ( int word, FILE *str ) { REG1 FILE *stream; REG3 int bytecount = sizeof(int); REG2 char *byteptr = (char *)&word; int retval; _VALIDATE_RETURN((str != NULL), EINVAL, EOF); /* Init stream pointer */ stream = str; _lock_str(stream); __try { while (bytecount--) { _putc_nolock(*byteptr,stream); ++byteptr; } retval = (ferror(stream) ? EOF : word); } __finally { _unlock_str(stream); } return(retval); }
int __cdecl _vswprintf_helper ( WOUTPUTFN woutfn, wchar_t *string, size_t count, const wchar_t *format, va_list ap ) { miniFILE str; miniFILE *outfile = &str; int retval; _VALIDATE_RETURN( (format != NULL), EINVAL, -1); _VALIDATE_RETURN( (count == 0) || (string != NULL), EINVAL, -1 ); outfile->_flag = _IOWRT|_IOSTRG; outfile->_ptr = outfile->_base = (char *) string; if(count>(INT_MAX/sizeof(wchar_t))) { /* old-style functions allow any large value to mean unbounded */ outfile->_cnt = INT_MAX; } else { outfile->_cnt = (int)(count*sizeof(wchar_t)); } retval = woutfn(outfile, format, ap ); if(string==NULL) { return retval; } if((retval >= 0) && (_putc_nolock('\0',outfile) != EOF) && (_putc_nolock('\0',outfile) != EOF)) return(retval); string[count - 1] = 0; if (outfile->_cnt < 0) { /* the buffer was too small; we return -2 to indicate truncation */ return -2; } return -1; }
int VMPI_putc_unlocked(int c, FILE *stream) { return _putc_nolock( c, stream ); }