13839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o/*
23839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Copyright (c) 1988 Regents of the University of California.
33839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * All rights reserved.
43839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o *
53839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * Redistribution and use in source and binary forms are permitted
63839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * provided that the above copyright notice and this paragraph are
73839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * duplicated in all such forms and that any documentation,
83839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * advertising materials, and other materials related to such
93839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * distribution and use acknowledge that the software was developed
103839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * by the University of California, Berkeley.  The name of the
113839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * University may not be used to endorse or promote products derived
123839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * from this software without specific prior written permission.
133839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
143839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
153839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
163839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o */
173839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
183839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#if defined(LIBC_SCCS) && !defined(lint)
193839e65723771b85975f4263102dd3ceec4523cTheodore Ts'ostatic char sccsid[] = "@(#)vfprintf.c	5.2 (Berkeley) 6/27/88";
203839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#endif /* LIBC_SCCS and not lint */
213839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
2250e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#if !HAVE_VPRINTF && HAVE_DOPRNT
233839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include <stdio.h>
243839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o#include <varargs.h>
253839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
263839e65723771b85975f4263102dd3ceec4523cTheodore Ts'oint
273839e65723771b85975f4263102dd3ceec4523cTheodore Ts'ovfprintf(iop, fmt, ap)
283839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	FILE *iop;
293839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	char *fmt;
303839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	va_list ap;
313839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o{
323839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	int len;
333839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	char localbuf[BUFSIZ];
343839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
353839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	if (iop->_flag & _IONBF) {
363839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		iop->_flag &= ~_IONBF;
373839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		iop->_ptr = iop->_base = localbuf;
383839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		len = _doprnt(fmt, ap, iop);
393839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		(void) fflush(iop);
403839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		iop->_flag |= _IONBF;
413839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		iop->_base = NULL;
423839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		iop->_bufsiz = 0;
433839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		iop->_cnt = 0;
443839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	} else
453839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o		len = _doprnt(fmt, ap, iop);
463839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o
473839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o	return (ferror(iop) ? EOF : len);
483839e65723771b85975f4263102dd3ceec4523cTheodore Ts'o}
4950e1e10fa0ac12a3e2a9d20a75ee9041873cda96Theodore Ts'o#endif /* !HAVE_VPRINTF */
50