xref: /csrg-svn/lib/libc/stdio/fprintf.c (revision 42632)
121405Sdist /*
221405Sdist  * Copyright (c) 1980 Regents of the University of California.
332990Sbostic  * All rights reserved.
432990Sbostic  *
5*42632Sbostic  * %sccs.include.redist.c%
621405Sdist  */
721405Sdist 
826648Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42632Sbostic static char sccsid[] = "@(#)fprintf.c	5.5 (Berkeley) 06/01/90";
1032990Sbostic #endif /* LIBC_SCCS and not lint */
1121405Sdist 
1232990Sbostic #include <stdio.h>
132005Swnj 
142005Swnj fprintf(iop, fmt, args)
1532990Sbostic 	register FILE *iop;
1632990Sbostic 	char *fmt;
1732990Sbostic 	int args;
182005Swnj {
1932990Sbostic 	int len;
2016439Sralph 	char localbuf[BUFSIZ];
2116439Sralph 
2216439Sralph 	if (iop->_flag & _IONBF) {
2316439Sralph 		iop->_flag &= ~_IONBF;
2416439Sralph 		iop->_ptr = iop->_base = localbuf;
2516439Sralph 		iop->_bufsiz = BUFSIZ;
2632990Sbostic 		len = _doprnt(fmt, &args, iop);
2716439Sralph 		fflush(iop);
2816439Sralph 		iop->_flag |= _IONBF;
2916439Sralph 		iop->_base = NULL;
3016439Sralph 		iop->_bufsiz = NULL;
3116563Sralph 		iop->_cnt = 0;
3216439Sralph 	} else
3332990Sbostic 		len = _doprnt(fmt, &args, iop);
3432990Sbostic 	return(ferror(iop) ? EOF : len);
352005Swnj }
36