home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 387b.lha / dice_v2.02 / lib / stdio / vsprintf.c < prev   
Encoding:
C/C++ Source or Header  |  1990-05-30  |  578 b   |  47 lines

  1.  
  2. /*
  3.  *  VSPRINTF.C
  4.  *
  5.  *  (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  6.  */
  7.  
  8. #include <stdarg.h>
  9. #include <stdio.h>
  10.  
  11. static int
  12. _swrite(buf, n1, n2, sst)
  13. const char *buf;
  14. size_t n1;
  15. size_t n2;
  16. const char **sst;
  17. {
  18.     size_t n;
  19.  
  20.     if (n1 == 1)
  21.     n = n2;
  22.     else if (n2 == 1)
  23.     n = n1;
  24.     else
  25.     n = n1 * n2;
  26.  
  27.     movmem(buf, *sst, n);
  28.     *sst += n;
  29.     return(0);
  30. }
  31.  
  32. int
  33. vsprintf(buf, ctl, va)
  34. char *buf;
  35. const char *ctl;
  36. va_list va;
  37. {
  38.     char *ptr = buf;
  39.     int error;
  40.  
  41.     error = _pfmt(ctl, va, _swrite, &ptr);
  42.     va_end(va);
  43.     *ptr = 0;
  44.     return(error);
  45. }
  46.  
  47.