1*2561b634Sjoerg /* $NetBSD: swprintf.c,v 1.3 2013/04/19 15:22:25 joerg Exp $ */
2f432bbb6Schristos
3f432bbb6Schristos /*-
4f432bbb6Schristos * Copyright (c) 2002 Tim J. Robbins
5f432bbb6Schristos * All rights reserved.
6f432bbb6Schristos *
7f432bbb6Schristos * Redistribution and use in source and binary forms, with or without
8f432bbb6Schristos * modification, are permitted provided that the following conditions
9f432bbb6Schristos * are met:
10f432bbb6Schristos * 1. Redistributions of source code must retain the above copyright
11f432bbb6Schristos * notice, this list of conditions and the following disclaimer.
12f432bbb6Schristos * 2. Redistributions in binary form must reproduce the above copyright
13f432bbb6Schristos * notice, this list of conditions and the following disclaimer in the
14f432bbb6Schristos * documentation and/or other materials provided with the distribution.
15f432bbb6Schristos *
16f432bbb6Schristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17f432bbb6Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18f432bbb6Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19f432bbb6Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20f432bbb6Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21f432bbb6Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22f432bbb6Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23f432bbb6Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24f432bbb6Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25f432bbb6Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26f432bbb6Schristos * SUCH DAMAGE.
27f432bbb6Schristos */
28f432bbb6Schristos
29f432bbb6Schristos #include <sys/cdefs.h>
30f432bbb6Schristos #if defined(LIBC_SCCS) && !defined(lint)
31f432bbb6Schristos #if 0
32f432bbb6Schristos __FBSDID("$FreeBSD: src/lib/libc/stdio/swprintf.c,v 1.1 2002/09/21 13:00:30 tjr Exp $");
33f432bbb6Schristos #else
34*2561b634Sjoerg __RCSID("$NetBSD: swprintf.c,v 1.3 2013/04/19 15:22:25 joerg Exp $");
35f432bbb6Schristos #endif
36f432bbb6Schristos #endif /* LIBC_SCCS and not lint */
37f432bbb6Schristos
38*2561b634Sjoerg #include "namespace.h"
39f432bbb6Schristos #include <stdarg.h>
40f432bbb6Schristos #include <stdio.h>
41f432bbb6Schristos #include <wchar.h>
42f432bbb6Schristos
__weak_alias(swprintf_l,_swprintf_l)43*2561b634Sjoerg __weak_alias(swprintf_l, _swprintf_l)
44*2561b634Sjoerg
45f432bbb6Schristos int
46f432bbb6Schristos swprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt, ...)
47f432bbb6Schristos {
48f432bbb6Schristos int ret;
49f432bbb6Schristos va_list ap;
50f432bbb6Schristos
51f432bbb6Schristos va_start(ap, fmt);
52f432bbb6Schristos ret = vswprintf(s, n, fmt, ap);
53f432bbb6Schristos va_end(ap);
54f432bbb6Schristos
55526d9427Schristos return ret;
56f432bbb6Schristos }
57*2561b634Sjoerg
58*2561b634Sjoerg int
swprintf_l(wchar_t * __restrict s,size_t n,locale_t loc,const wchar_t * __restrict fmt,...)59*2561b634Sjoerg swprintf_l(wchar_t * __restrict s, size_t n, locale_t loc,
60*2561b634Sjoerg const wchar_t * __restrict fmt, ...)
61*2561b634Sjoerg {
62*2561b634Sjoerg int ret;
63*2561b634Sjoerg va_list ap;
64*2561b634Sjoerg
65*2561b634Sjoerg va_start(ap, fmt);
66*2561b634Sjoerg ret = vswprintf_l(s, n, loc, fmt, ap);
67*2561b634Sjoerg va_end(ap);
68*2561b634Sjoerg
69*2561b634Sjoerg return ret;
70*2561b634Sjoerg }
71