home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_02 / wprintf.c < prev    next >
C/C++ Source or Header  |  1991-03-17  |  711b  |  49 lines

  1. /* wprintf
  2.  *    window-limitted printf function
  3.  *
  4.  *    supports all ANSI codes except total # bytes output must be < 500
  5.  */
  6. #include "wsys.h"
  7. #include <stdarg.h>
  8.  
  9.  
  10.  
  11.  
  12.  
  13. int wprintf( char *format, ...) {
  14.  
  15.  
  16.     char *buffer;
  17.     va_list arg_ptr;
  18.     int num;
  19.  
  20.     #if __TINY__
  21.         werror("WPRINTF - not supported in tiny model");
  22.     #endif     /* model is other than TINY, so stack exists  */
  23.  
  24.  
  25.  
  26.     buffer = wmalloc (WPRINTF_LIMIT, "wprintf");
  27.  
  28.  
  29.     va_start(arg_ptr, format);
  30.  
  31.  
  32.     num = vsprintf(buffer, format, arg_ptr);
  33.  
  34.     if (WPRINTF_LIMIT < num )
  35.         {
  36.         werror('W', "WPRINTF string too long.");
  37.         }
  38.  
  39.     va_end(arg_ptr);
  40.  
  41.     wputs(buffer);
  42.  
  43.  
  44.     free (buffer);
  45.  
  46.     return(num);
  47.  
  48.     }/* end of wprintf */
  49.