home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / pdksh-4.9-src.tgz / tar.out / contrib / pdksh / std / stdc / sprintf.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  848b  |  65 lines

  1. /*
  2.  * sprintf and vsprintf
  3.  */
  4.  
  5. /* $Id: sprintf.c,v 1.4 93/05/05 21:18:20 sjg Exp $ */
  6.  
  7. #ifdef __STDC__
  8. #include <stdarg.h>
  9. #else
  10. #include <varargs.h>
  11. #endif
  12. #include <stdio.h>
  13.  
  14. #if _V7 || _BSD
  15.  
  16. int
  17. #ifdef __STDC__
  18. sprintf(char *s, const char *fmt, ...) {
  19. #else
  20. sprintf(va_alist) va_dcl
  21. {
  22.     char *s;
  23.     char *fmt;
  24. #endif
  25.     register va_list va;
  26.     int n;
  27.  
  28. #ifdef __STDC__
  29.     va_start(va, fmt);
  30. #else
  31.     va_start(va);
  32.     s = va_arg(va, char *);
  33.     fmt = va_arg(va, char *);
  34. #endif
  35.     n = vsprintf(s, fmt, va);
  36.     va_end(va);
  37.     return n;
  38. }
  39.  
  40. int
  41. #ifdef __STDC__
  42. vsprintf(char *s, const char *fmt, va_list va) {
  43. #else
  44. vsprintf(s, fmt, va)
  45.     char *s;
  46.     char *fmt;
  47.     va_list va;
  48. {
  49. #endif
  50.     int n;
  51.     static FILE siob;
  52.  
  53.     siob._flag = _IOWRT;
  54.     siob._base = siob._ptr = s;
  55.     siob._cnt = BUFSIZ;
  56.     siob._file = -1;
  57.  
  58.     n = vfprintf(&siob, fmt, va);
  59.     *siob._ptr = 0;
  60.     return n;
  61. }
  62.  
  63. #endif
  64.  
  65.