xref: /original-bsd/lib/libc/stdio/fprintf.c (revision 540a81df)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)fprintf.c	5.5 (Berkeley) 06/01/90";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <stdio.h>
13 
14 fprintf(iop, fmt, args)
15 	register FILE *iop;
16 	char *fmt;
17 	int args;
18 {
19 	int len;
20 	char localbuf[BUFSIZ];
21 
22 	if (iop->_flag & _IONBF) {
23 		iop->_flag &= ~_IONBF;
24 		iop->_ptr = iop->_base = localbuf;
25 		iop->_bufsiz = BUFSIZ;
26 		len = _doprnt(fmt, &args, iop);
27 		fflush(iop);
28 		iop->_flag |= _IONBF;
29 		iop->_base = NULL;
30 		iop->_bufsiz = NULL;
31 		iop->_cnt = 0;
32 	} else
33 		len = _doprnt(fmt, &args, iop);
34 	return(ferror(iop) ? EOF : len);
35 }
36