paul@181 | 1 | /* |
paul@181 | 2 | * Copyright (c) 1988 Regents of the University of California. |
paul@181 | 3 | * All rights reserved. |
paul@181 | 4 | * |
paul@181 | 5 | * Redistribution and use in source and binary forms are permitted |
paul@181 | 6 | * provided that the above copyright notice and this paragraph are |
paul@181 | 7 | * duplicated in all such forms and that any documentation, |
paul@181 | 8 | * advertising materials, and other materials related to such |
paul@181 | 9 | * distribution and use acknowledge that the software was developed |
paul@181 | 10 | * by the University of California, Berkeley. The name of the |
paul@181 | 11 | * University may not be used to endorse or promote products derived |
paul@181 | 12 | * from this software without specific prior written permission. |
paul@181 | 13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
paul@181 | 14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
paul@181 | 15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
paul@181 | 16 | */ |
paul@181 | 17 | |
paul@181 | 18 | #if defined(LIBC_SCCS) && !defined(lint) |
paul@181 | 19 | static char sccsid[] = "@(#)vfprintf.c 5.2 (Berkeley) 6/27/88"; |
paul@181 | 20 | #endif /* LIBC_SCCS and not lint */ |
paul@181 | 21 | |
paul@181 | 22 | #include "config.h" |
paul@181 | 23 | #if !HAVE_VPRINTF && HAVE_DOPRNT |
paul@181 | 24 | #include <stdio.h> |
paul@181 | 25 | #include <varargs.h> |
paul@181 | 26 | |
paul@181 | 27 | int |
paul@181 | 28 | vfprintf(iop, fmt, ap) |
paul@181 | 29 | FILE *iop; |
paul@181 | 30 | char *fmt; |
paul@181 | 31 | va_list ap; |
paul@181 | 32 | { |
paul@181 | 33 | int len; |
paul@181 | 34 | char localbuf[BUFSIZ]; |
paul@181 | 35 | |
paul@181 | 36 | if (iop->_flag & _IONBF) { |
paul@181 | 37 | iop->_flag &= ~_IONBF; |
paul@181 | 38 | iop->_ptr = iop->_base = localbuf; |
paul@181 | 39 | len = _doprnt(fmt, ap, iop); |
paul@181 | 40 | (void) fflush(iop); |
paul@181 | 41 | iop->_flag |= _IONBF; |
paul@181 | 42 | iop->_base = NULL; |
paul@181 | 43 | iop->_bufsiz = 0; |
paul@181 | 44 | iop->_cnt = 0; |
paul@181 | 45 | } else |
paul@181 | 46 | len = _doprnt(fmt, ap, iop); |
paul@181 | 47 | |
paul@181 | 48 | return (ferror(iop) ? EOF : len); |
paul@181 | 49 | } |
paul@181 | 50 | #endif /* !HAVE_VPRINTF */ |