1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 #if defined(LIBC_SCCS) && !defined(lint) 14 static char sccsid[] = "@(#)fprintf.c 5.3 (Berkeley) 12/12/87"; 15 #endif /* LIBC_SCCS and not lint */ 16 17 #include <stdio.h> 18 19 fprintf(iop, fmt, args) 20 register FILE *iop; 21 char *fmt; 22 int args; 23 { 24 int len; 25 char localbuf[BUFSIZ]; 26 27 if (iop->_flag & _IONBF) { 28 iop->_flag &= ~_IONBF; 29 iop->_ptr = iop->_base = localbuf; 30 iop->_bufsiz = BUFSIZ; 31 len = _doprnt(fmt, &args, iop); 32 fflush(iop); 33 iop->_flag |= _IONBF; 34 iop->_base = NULL; 35 iop->_bufsiz = NULL; 36 iop->_cnt = 0; 37 } else 38 len = _doprnt(fmt, &args, iop); 39 return(ferror(iop) ? EOF : len); 40 } 41