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

  1.  
  2. /*
  3.  *  SPRINTF.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.     _slow_bcopy(buf, *sst, n);
  28.     *sst += n;
  29.     return(0);
  30. }
  31.  
  32. int
  33. sprintf(buf, ctl)
  34. char *buf;
  35. const char *ctl;
  36. {
  37.     char *ptr = buf;
  38.     int error;
  39.     va_list va;
  40.  
  41.     va_start(va, ctl);
  42.     error = _pfmt(ctl, va, _swrite, &ptr);
  43.     va_end(va);
  44.     *ptr = 0;
  45.     return(error);
  46. }
  47.  
  48.