home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixlib36d
/
src
/
stdio
/
c
/
printf
< prev
next >
Wrap
Text File
|
1994-03-08
|
1KB
|
76 lines
static char sccs_id[] = "@(#) printf.c 1.1 " __DATE__ " HJR";
/* printf.c (c) Copyright 1990 H.Rogers */
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
__STDIOLIB__
int
vsprintf (register char *buf, register const char *format,
register va_list ap)
{
return (__printf (buf, format, ap));
}
int
vfprintf (register FILE * f, register const char *format, register va_list ap)
{
register int n;
if (!__pbuf)
if (!(__pbuf = malloc (BUFSIZ << 1)))
return (-1);
n = __printf (__pbuf, format, ap);
if ((n = __fwrite (f, __pbuf, n)) < 0)
return (-1);
if (f->o_ptr > f->o_base && !!(f->flag & _IOLBF) && __flsbuf (-1, f) < 0)
return (-1);
return (n);
}
int
vprintf (register const char *format, register va_list ap)
{
return (vfprintf (stdout, format, ap));
}
int
sprintf (register char *buf, const char *format,...)
{
va_list ap;
register int r;
va_start (ap, format);
r = vsprintf (buf, format, ap);
va_end (ap);
return (r);
}
int
fprintf (register FILE * f, const char *format,...)
{
va_list ap;
register int r;
va_start (ap, format);
r = vfprintf (f, format, ap);
va_end (ap);
return (r);
}
int
printf (const char *format,...)
{
va_list ap;
register int r;
va_start (ap, format);
r = vfprintf (stdout, format, ap);
va_end (ap);
return (r);
}