xref: /titanic_41/usr/src/lib/libc/port/i18n/strtows.c (revision 0adc16190e36914964740716575460dda750de39)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 #include "synonyms.h"
31 #include <limits.h>
32 #include <widec.h>
33 #include <errno.h>
34 #include <stdlib.h>
35 
36 wchar_t *
37 strtows(wchar_t *s1, char *s2)
38 {
39 	size_t ret;
40 
41 	ret = mbstowcs(s1, s2, TMP_MAX);
42 	if (ret == (size_t)-1) {
43 		errno = EILSEQ;
44 		return (NULL);
45 	}
46 	return (s1);
47 }
48 
49 char *
50 wstostr(char *s1, wchar_t *s2)
51 {
52 	size_t ret;
53 
54 	ret = wcstombs(s1, s2, TMP_MAX);
55 	if (ret == (size_t)-1) {
56 		errno = EILSEQ;
57 		return (NULL);
58 	}
59 	return (s1);
60 }
61