xref: /csrg-svn/lib/libc/stdio/fprintf.c (revision 21405)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char sccsid[] = "@(#)fprintf.c	5.1 (Berkeley) 05/30/85";
9 #endif not lint
10 
11 #include	<stdio.h>
12 
13 fprintf(iop, fmt, args)
14 register FILE *iop;
15 char *fmt;
16 {
17 	char localbuf[BUFSIZ];
18 
19 	if (iop->_flag & _IONBF) {
20 		iop->_flag &= ~_IONBF;
21 		iop->_ptr = iop->_base = localbuf;
22 		iop->_bufsiz = BUFSIZ;
23 		_doprnt(fmt, &args, iop);
24 		fflush(iop);
25 		iop->_flag |= _IONBF;
26 		iop->_base = NULL;
27 		iop->_bufsiz = NULL;
28 		iop->_cnt = 0;
29 	} else
30 		_doprnt(fmt, &args, iop);
31 	return(ferror(iop)? EOF: 0);
32 }
33