#include <stdarg.h>
#include <stdio.h>
#include <limits.h>

static int sputc (int ch, FILE *fp);
extern int _doprnt (int (*)(int, FILE *), FILE *, const char *, va_list);

static int
sputc (ch, fp)
	int ch;
	FILE *fp;
{
	char **bufp = (char **) fp;
	*(*bufp)++ = ch;
	return ch & 0xff;
}

int __sprintf (char *buf, const char *fmt, ...)
{
	register int n;
	va_list argp;

	va_start(argp, fmt);
	n = _doprnt(sputc, (FILE *) &buf, fmt, argp);
	*buf = '\0';
	return(n);
}

int __vsprintf (buf, fmt, args)
	char *buf;
	const char *fmt;
	va_list args;
{
	register int n;
	n = _doprnt(sputc, (FILE *) &buf, fmt, args);
	*buf = '\0';
	return(n);
}
