4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
28 * Use is subject to license terms.
44 #include <sys/types.h>
49 wprintf(const wchar_t *format
, ...)
56 FLOCKFILE(lk
, stdout
);
58 if (GET_NO_MODE(stdout
))
59 _setorientation(stdout
, _WC_MODE
);
61 if (!(stdout
->_flag
& _IOWRT
)) {
62 /* if no write flag */
63 if (stdout
->_flag
& _IORW
) {
64 /* if ok, cause read-write */
65 stdout
->_flag
|= _IOWRT
;
74 count
= _wndoprnt(format
, ap
, stdout
, 0);
76 if (FERROR(stdout
) || count
== EOF
) {
81 /* check for overflow */
82 if ((size_t)count
> MAXINT
) {
91 fwprintf(FILE *iop
, const wchar_t *format
, ...)
101 if (GET_NO_MODE(iop
))
102 _setorientation(iop
, _WC_MODE
);
104 if (!(iop
->_flag
& _IOWRT
)) {
105 /* if no write flag */
106 if (iop
->_flag
& _IORW
) {
107 /* if ok, cause read-write */
108 iop
->_flag
|= _IOWRT
;
117 count
= _wndoprnt(format
, ap
, iop
, 0);
119 if (FERROR(iop
) || count
== EOF
) {
124 /* check for overflow */
125 if ((size_t)count
> MAXINT
) {
134 swprintf(wchar_t *string
, size_t n
, const wchar_t *format
, ...)
143 siop
._cnt
= (ssize_t
)n
- 1;
144 siop
._base
= siop
._ptr
= (unsigned char *)string
;
145 siop
._flag
= _IOREAD
;
147 va_start(ap
, format
);
148 count
= _wndoprnt(format
, ap
, &siop
, 0);
150 wp
= (wchar_t *)(uintptr_t)siop
._ptr
;
155 /* check for overflow */
156 if ((size_t)count
> MAXINT
) {