xref: /csrg-svn/lib/libc/stdio/fprintf.c (revision 32990)
121405Sdist /*
221405Sdist  * Copyright (c) 1980 Regents of the University of California.
3*32990Sbostic  * All rights reserved.
4*32990Sbostic  *
5*32990Sbostic  * Redistribution and use in source and binary forms are permitted
6*32990Sbostic  * provided that this notice is preserved and that due credit is given
7*32990Sbostic  * to the University of California at Berkeley. The name of the University
8*32990Sbostic  * may not be used to endorse or promote products derived from this
9*32990Sbostic  * software without specific prior written permission. This software
10*32990Sbostic  * is provided ``as is'' without express or implied warranty.
1121405Sdist  */
1221405Sdist 
1326648Sdonn #if defined(LIBC_SCCS) && !defined(lint)
14*32990Sbostic static char sccsid[] = "@(#)fprintf.c	5.3 (Berkeley) 12/12/87";
15*32990Sbostic #endif /* LIBC_SCCS and not lint */
1621405Sdist 
17*32990Sbostic #include <stdio.h>
182005Swnj 
192005Swnj fprintf(iop, fmt, args)
20*32990Sbostic 	register FILE *iop;
21*32990Sbostic 	char *fmt;
22*32990Sbostic 	int args;
232005Swnj {
24*32990Sbostic 	int len;
2516439Sralph 	char localbuf[BUFSIZ];
2616439Sralph 
2716439Sralph 	if (iop->_flag & _IONBF) {
2816439Sralph 		iop->_flag &= ~_IONBF;
2916439Sralph 		iop->_ptr = iop->_base = localbuf;
3016439Sralph 		iop->_bufsiz = BUFSIZ;
31*32990Sbostic 		len = _doprnt(fmt, &args, iop);
3216439Sralph 		fflush(iop);
3316439Sralph 		iop->_flag |= _IONBF;
3416439Sralph 		iop->_base = NULL;
3516439Sralph 		iop->_bufsiz = NULL;
3616563Sralph 		iop->_cnt = 0;
3716439Sralph 	} else
38*32990Sbostic 		len = _doprnt(fmt, &args, iop);
39*32990Sbostic 	return(ferror(iop) ? EOF : len);
402005Swnj }
41