xref: /freebsd-14.2/lib/libc/stdio/fprintf.c (revision 58f0484f)
1*58f0484fSRodney W. Grimes /*-
2*58f0484fSRodney W. Grimes  * Copyright (c) 1990, 1993
3*58f0484fSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4*58f0484fSRodney W. Grimes  *
5*58f0484fSRodney W. Grimes  * This code is derived from software contributed to Berkeley by
6*58f0484fSRodney W. Grimes  * Chris Torek.
7*58f0484fSRodney W. Grimes  *
8*58f0484fSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
9*58f0484fSRodney W. Grimes  * modification, are permitted provided that the following conditions
10*58f0484fSRodney W. Grimes  * are met:
11*58f0484fSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
12*58f0484fSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
13*58f0484fSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
14*58f0484fSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
15*58f0484fSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
16*58f0484fSRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
17*58f0484fSRodney W. Grimes  *    must display the following acknowledgement:
18*58f0484fSRodney W. Grimes  *	This product includes software developed by the University of
19*58f0484fSRodney W. Grimes  *	California, Berkeley and its contributors.
20*58f0484fSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
21*58f0484fSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
22*58f0484fSRodney W. Grimes  *    without specific prior written permission.
23*58f0484fSRodney W. Grimes  *
24*58f0484fSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25*58f0484fSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26*58f0484fSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27*58f0484fSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28*58f0484fSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29*58f0484fSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30*58f0484fSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31*58f0484fSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32*58f0484fSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33*58f0484fSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34*58f0484fSRodney W. Grimes  * SUCH DAMAGE.
35*58f0484fSRodney W. Grimes  */
36*58f0484fSRodney W. Grimes 
37*58f0484fSRodney W. Grimes #if defined(LIBC_SCCS) && !defined(lint)
38*58f0484fSRodney W. Grimes static char sccsid[] = "@(#)fprintf.c	8.1 (Berkeley) 6/4/93";
39*58f0484fSRodney W. Grimes #endif /* LIBC_SCCS and not lint */
40*58f0484fSRodney W. Grimes 
41*58f0484fSRodney W. Grimes #include <stdio.h>
42*58f0484fSRodney W. Grimes #if __STDC__
43*58f0484fSRodney W. Grimes #include <stdarg.h>
44*58f0484fSRodney W. Grimes #else
45*58f0484fSRodney W. Grimes #include <varargs.h>
46*58f0484fSRodney W. Grimes #endif
47*58f0484fSRodney W. Grimes 
48*58f0484fSRodney W. Grimes #if __STDC__
49*58f0484fSRodney W. Grimes fprintf(FILE *fp, const char *fmt, ...)
50*58f0484fSRodney W. Grimes #else
51*58f0484fSRodney W. Grimes fprintf(fp, fmt, va_alist)
52*58f0484fSRodney W. Grimes 	FILE *fp;
53*58f0484fSRodney W. Grimes 	char *fmt;
54*58f0484fSRodney W. Grimes 	va_dcl
55*58f0484fSRodney W. Grimes #endif
56*58f0484fSRodney W. Grimes {
57*58f0484fSRodney W. Grimes 	int ret;
58*58f0484fSRodney W. Grimes 	va_list ap;
59*58f0484fSRodney W. Grimes 
60*58f0484fSRodney W. Grimes #if __STDC__
61*58f0484fSRodney W. Grimes 	va_start(ap, fmt);
62*58f0484fSRodney W. Grimes #else
63*58f0484fSRodney W. Grimes 	va_start(ap);
64*58f0484fSRodney W. Grimes #endif
65*58f0484fSRodney W. Grimes 	ret = vfprintf(fp, fmt, ap);
66*58f0484fSRodney W. Grimes 	va_end(ap);
67*58f0484fSRodney W. Grimes 	return (ret);
68*58f0484fSRodney W. Grimes }
69