home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / sprintf.c < prev    next >
C/C++ Source or Header  |  1992-07-08  |  1KB  |  61 lines

  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <limits.h>
  4. #include "lib.h"
  5.  
  6. #ifndef __GNUC__
  7. static FILE dummyf =
  8.     {0L, (unsigned char *)0, (unsigned char *)0,
  9.          _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX, '\0'};
  10. #endif
  11.  
  12. __EXTERN int _doprnt __PROTO((FILE *file, const char *fmt, va_list argp));
  13.  
  14. #ifdef __STDC__
  15. int sprintf(char *buf, const char *fmt, ...)
  16. #else
  17. int sprintf(buf, fmt)
  18.     char *buf;
  19.     const char *fmt;
  20. #endif
  21.     {
  22.     register int n;
  23.     va_list argp;
  24. #ifdef __GNUC__
  25.     FILE sf = 
  26.     {0L, (unsigned char *)buf, (unsigned char *)buf,
  27.          _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX,'\0'};
  28. #else
  29.     FILE sf;
  30.  
  31.     sf = dummyf;
  32.     sf._ptr = sf._base = (unsigned char *)buf;
  33. #endif
  34.     
  35.     va_start(argp, fmt);
  36.     n = _doprnt(&sf, fmt, argp);
  37.     *(sf._ptr) = '\0';        /* always tie of the string */
  38.     return(n);
  39.     }
  40.  
  41. int vsprintf(buf, fmt, args)
  42.     char *buf;
  43.     const char *fmt;
  44.     va_list args;
  45.     {
  46.     register int n;
  47. #ifdef __GNUC__    
  48.     FILE sf = 
  49.     {0L, (unsigned char *)buf, (unsigned char *)buf,
  50.          _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX,'\0'};
  51. #else
  52.     FILE sf;
  53.  
  54.     sf = dummyf;
  55.     sf._ptr = sf._base = (unsigned char *)buf;
  56. #endif
  57.     n = _doprnt(&sf, fmt, args);
  58.     *(sf._ptr) = '\0';        /* always tie of the string */
  59.     return(n);
  60.     }
  61.