xref: /titanic_50/usr/src/lib/libc/port/stdio/wscanf.c (revision 7257d1b4d25bfac0c802847390e98a464fd787ac)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include "lint.h"
30 #include "file64.h"
31 #include <mtlib.h>
32 #include <stdio.h>
33 #include <stdarg.h>
34 #include <string.h>
35 #include <thread.h>
36 #include <synch.h>
37 #include <wchar.h>
38 #include <errno.h>
39 #include <stdlib.h>
40 #include <alloca.h>
41 #include "mse.h"
42 #include "stdiom.h"
43 #include "libc.h"
44 
45 int
wscanf(const wchar_t * fmt,...)46 wscanf(const wchar_t *fmt, ...)
47 {
48 	int ret;
49 	va_list	ap;
50 
51 	va_start(ap, fmt);
52 	ret = vwscanf(fmt, ap);
53 	va_end(ap);
54 
55 	return (ret);
56 }
57 
58 int
fwscanf(FILE * iop,const wchar_t * fmt,...)59 fwscanf(FILE *iop, const wchar_t *fmt, ...)
60 {
61 	int ret;
62 	va_list	ap;
63 
64 	va_start(ap, fmt);
65 	ret = vfwscanf(iop, fmt, ap);
66 	va_end(ap);
67 
68 	return (ret);
69 }
70 
71 int
swscanf(const wchar_t * wstr,const wchar_t * fmt,...)72 swscanf(const wchar_t *wstr, const wchar_t *fmt, ...)
73 {
74 	int ret;
75 	va_list	ap;
76 
77 	va_start(ap, fmt);
78 	ret = vswscanf(wstr, fmt, ap);
79 	va_end(ap);
80 
81 	return (ret);
82 }
83 
84 
85 #ifndef _LP64
86 
87 /*
88  * 32-bit shadow function _wscanf_c89(), _fwscanf_c89(), _swscanf_c89()
89  * are included here.
90  * When using the c89 compiler to build 32-bit applications, the size
91  * of intmax_t is 32-bits, otherwise the size of intmax_t is 64-bits.
92  * The shadow function uses 32-bit size of intmax_t for %j conversion.
93  * The #pragma redefine_extname in <stdio.h> selects the proper routine
94  * at compile time for the user application.
95  * NOTE: the shadow function only exists in the 32-bit library.
96  */
97 
98 int
_wscanf_c89(const wchar_t * fmt,...)99 _wscanf_c89(const wchar_t *fmt, ...)
100 {
101 	int ret;
102 	va_list	ap;
103 
104 	va_start(ap, fmt);
105 	ret = _vwscanf_c89(fmt, ap);
106 	va_end(ap);
107 
108 	return (ret);
109 }
110 
111 int
_fwscanf_c89(FILE * iop,const wchar_t * fmt,...)112 _fwscanf_c89(FILE *iop, const wchar_t *fmt, ...)
113 {
114 	int ret;
115 	va_list	ap;
116 
117 	va_start(ap, fmt);
118 	ret = _vfwscanf_c89(iop, fmt, ap);
119 	va_end(ap);
120 
121 	return (ret);
122 }
123 
124 int
_swscanf_c89(const wchar_t * wstr,const wchar_t * fmt,...)125 _swscanf_c89(const wchar_t *wstr, const wchar_t *fmt, ...)
126 {
127 	int ret;
128 	va_list	ap;
129 
130 	va_start(ap, fmt);
131 	ret = _vswscanf_c89(wstr, fmt, ap);
132 	va_end(ap);
133 
134 	return (ret);
135 }
136 #endif	/* _LP64 */
137