Subversion Repositories Kolibri OS

Rev

Rev 1871 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * vsprintf - print formatted output without ellipsis on an array
  3.  */
  4. /* $Header$ */
  5.  
  6. #include    "stdio.h"
  7. #include   <stdarg.h>
  8. #include   <limits.h>
  9. #include        "loc_incl.h"
  10.  
  11. #define putc(c, p)  (--(p)->_count >= 0 ? \
  12.                     (int) (*(p)->_ptr++ = (c)) : EOF)
  13.  
  14. int
  15. vsnprintf(char *s, unsigned n, const char *format, va_list arg)
  16. {
  17.         int retval;
  18.         FILE tmp_stream;
  19.  
  20.         tmp_stream._fd     = -1;
  21.         tmp_stream._flags  = _IOWRITE + _IONBF + _IOWRITING;
  22.         tmp_stream._buf    = (unsigned char *) s;
  23.         tmp_stream._ptr    = (unsigned char *) s;
  24.         tmp_stream._count  = n-1;
  25.  
  26.         retval = _doprnt(format, arg, &tmp_stream);
  27.         tmp_stream._count  = 1;
  28.         putc('\0',&tmp_stream);
  29.  
  30.         return retval;
  31. }
  32.  
  33. int
  34. vsprintf(char *s, const char *format, va_list arg)
  35. {
  36.         return vsnprintf(s, INT_MAX, format, arg);
  37. }
  38.