#include #include #include #include "lib.h" #ifdef __SOZOBON__ /* Electronic brain... */ static FILE dummyf = {0L, (unsigned char *)0, (unsigned char *)0, _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX, '\0'}; #endif #if __STDC__ int sprintf(char *buf, const char *fmt, ...) #else int sprintf(buf, fmt) char *buf; const char *fmt; #endif { va_list args; register int n; #ifndef __SOZOBON__ /* A little bit of braindeath here, methinks. */ FILE sf = {0L, (unsigned char *)buf, (unsigned char *)buf, _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX,'\0'}; #else FILE sf; sf = dummyf; sf._ptr = sf._base = (unsigned char *)buf; #endif va_start(args, fmt); n = _doprnt(&sf, fmt, args); *(sf._ptr) = '\0'; /* always tie off the string */ va_end(args); return(n); } int vsprintf(buf, fmt, args) char *buf; const char *fmt; va_list args; { register int n; #ifndef __SOZOBON__ /* Same again, please, landlord. */ FILE sf = {0L, (unsigned char *)buf, (unsigned char *)buf, _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX,'\0'}; #else FILE sf; sf = dummyf; sf._ptr = sf._base = (unsigned char *)buf; #endif n = _doprnt(&sf, fmt, args); *(sf._ptr) = '\0'; /* always tie of the string */ return(n); }