1*2561b634Sjoerg /* $NetBSD: dprintf.c,v 1.2 2013/04/19 15:22:25 joerg Exp $ */
24ddc2fb3Schristos
34ddc2fb3Schristos /*-
44ddc2fb3Schristos * Copyright (c) 1990, 1993
54ddc2fb3Schristos * The Regents of the University of California. All rights reserved.
64ddc2fb3Schristos *
74ddc2fb3Schristos * This code is derived from software contributed to Berkeley by
84ddc2fb3Schristos * Chris Torek.
94ddc2fb3Schristos *
104ddc2fb3Schristos * Redistribution and use in source and binary forms, with or without
114ddc2fb3Schristos * modification, are permitted provided that the following conditions
124ddc2fb3Schristos * are met:
134ddc2fb3Schristos * 1. Redistributions of source code must retain the above copyright
144ddc2fb3Schristos * notice, this list of conditions and the following disclaimer.
154ddc2fb3Schristos * 2. Redistributions in binary form must reproduce the above copyright
164ddc2fb3Schristos * notice, this list of conditions and the following disclaimer in the
174ddc2fb3Schristos * documentation and/or other materials provided with the distribution.
184ddc2fb3Schristos * 3. Neither the name of the University nor the names of its contributors
194ddc2fb3Schristos * may be used to endorse or promote products derived from this software
204ddc2fb3Schristos * without specific prior written permission.
214ddc2fb3Schristos *
224ddc2fb3Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
234ddc2fb3Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244ddc2fb3Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254ddc2fb3Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
264ddc2fb3Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274ddc2fb3Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284ddc2fb3Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294ddc2fb3Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304ddc2fb3Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314ddc2fb3Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324ddc2fb3Schristos * SUCH DAMAGE.
334ddc2fb3Schristos */
344ddc2fb3Schristos
354ddc2fb3Schristos #include <sys/cdefs.h>
364ddc2fb3Schristos #if defined(LIBC_SCCS) && !defined(lint)
37*2561b634Sjoerg __RCSID("$NetBSD: dprintf.c,v 1.2 2013/04/19 15:22:25 joerg Exp $");
384ddc2fb3Schristos #endif /* LIBC_SCCS and not lint */
394ddc2fb3Schristos
404ddc2fb3Schristos #include "namespace.h"
414ddc2fb3Schristos #include <sys/types.h>
424ddc2fb3Schristos
434ddc2fb3Schristos #include <stdio.h>
444ddc2fb3Schristos #include <stdarg.h>
454ddc2fb3Schristos
464ddc2fb3Schristos #include "reentrant.h"
474ddc2fb3Schristos #include "local.h"
484ddc2fb3Schristos
__weak_alias(dprintf_l,_dprintf_l)49*2561b634Sjoerg __weak_alias(dprintf_l, _dprintf_l)
50*2561b634Sjoerg
514ddc2fb3Schristos int
524ddc2fb3Schristos dprintf(int fd, const char * __restrict fmt, ...)
534ddc2fb3Schristos {
544ddc2fb3Schristos va_list ap;
554ddc2fb3Schristos int ret;
564ddc2fb3Schristos
574ddc2fb3Schristos va_start(ap, fmt);
584ddc2fb3Schristos ret = vdprintf(fd, fmt, ap);
594ddc2fb3Schristos va_end(ap);
604ddc2fb3Schristos return ret;
614ddc2fb3Schristos }
62*2561b634Sjoerg
63*2561b634Sjoerg int
dprintf_l(int fd,locale_t loc,const char * __restrict fmt,...)64*2561b634Sjoerg dprintf_l(int fd, locale_t loc, const char * __restrict fmt, ...)
65*2561b634Sjoerg {
66*2561b634Sjoerg va_list ap;
67*2561b634Sjoerg int ret;
68*2561b634Sjoerg
69*2561b634Sjoerg va_start(ap, fmt);
70*2561b634Sjoerg ret = vdprintf_l(fd, loc, fmt, ap);
71*2561b634Sjoerg va_end(ap);
72*2561b634Sjoerg return ret;
73*2561b634Sjoerg }
74