|
|
1.1 ! root 1: /* ! 2: * pANS stdio -- sprintf ! 3: */ ! 4: #include "iolib.h" ! 5: int snprintf(char *buf, int len, const char *fmt, ...){ ! 6: int n; ! 7: va_list args; ! 8: char *v; ! 9: #ifdef V10 ! 10: FILE _strbuf; ! 11: _strbuf._flag = _IOWRT+_IOSTRG; ! 12: _strbuf._ptr = (unsigned char *) buf; ! 13: _strbuf._cnt = len; ! 14: #define f &_strbuf ! 15: #define sclose(x) buf[n] = 0 ! 16: #else ! 17: FILE *f=sopenw(); ! 18: if(f==NULL) ! 19: return 0; ! 20: setvbuf(f, buf, _IOFBF, len); ! 21: #endif ! 22: va_start(args, fmt); ! 23: n=vfprintf(f, fmt, args); ! 24: va_end(args); ! 25: sclose(f); ! 26: return n; ! 27: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.