home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
files
/
mint
/
mntlib18
/
sprintf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
1KB
|
58 lines
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
#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);
}