xref: /titanic_41/usr/src/head/widec.h (revision 9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bb)
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  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1986 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 /*	This module is created for NLS on Jun.04.86		*/
32 
33 #ifndef	_WIDEC_H
34 #define	_WIDEC_H
35 
36 #pragma ident	"%Z%%M%	%I%	%E% SMI"
37 
38 #include <sys/feature_tests.h>
39 
40 #if defined(__STDC__)
41 #include <stdio.h>	/* For definition of FILE */
42 #endif
43 #include <euc.h>
44 #include <wchar.h>
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 #if defined(__STDC__)
51 /* Character based input and output functions */
52 extern wchar_t	*getws(wchar_t *);
53 extern int	putws(const wchar_t *);
54 
55 #if !defined(__lint)
56 #define	getwc(p)	fgetwc(p)
57 #define	putwc(x, p)	fputwc((x), (p))
58 #define	getwchar()	getwc(stdin)
59 #define	putwchar(x)	putwc((x), stdout)
60 #endif
61 
62 /* wchar_t string operation functions */
63 extern wchar_t	*strtows(wchar_t *, char *);
64 extern wchar_t	*wscpy(wchar_t *, const wchar_t *);
65 extern wchar_t	*wsncpy(wchar_t *, const wchar_t *, size_t);
66 extern wchar_t	*wscat(wchar_t *, const wchar_t *);
67 extern wchar_t	*wsncat(wchar_t *, const wchar_t *, size_t);
68 extern wchar_t	*wschr(const wchar_t *, wchar_t);
69 extern wchar_t	*wsrchr(const wchar_t *, wchar_t);
70 extern wchar_t	*wspbrk(const wchar_t *, const wchar_t *);
71 extern wchar_t	*wstok(wchar_t *, const wchar_t *);
72 extern char	*wstostr(char *, wchar_t *);
73 
74 extern int	wscmp(const wchar_t *, const wchar_t *);
75 extern int	wsncmp(const wchar_t *, const wchar_t *, size_t);
76 extern size_t	wslen(const wchar_t *);
77 extern size_t	wsspn(const wchar_t *, const wchar_t *);
78 extern size_t	wscspn(const wchar_t *, const wchar_t *);
79 extern int	wscoll(const wchar_t *, const wchar_t *);
80 extern size_t	wsxfrm(wchar_t *, const wchar_t *, size_t);
81 
82 #if !defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)
83 
84 extern wchar_t	*wsdup(const wchar_t *);
85 extern int	wscol(const wchar_t *);
86 extern double	wstod(const wchar_t *, wchar_t **);
87 extern long	wstol(const wchar_t *, wchar_t **, int);
88 extern int	wscasecmp(const wchar_t *, const wchar_t *);
89 extern int	wsncasecmp(const wchar_t *, const wchar_t *, size_t);
90 extern int	wsprintf(wchar_t *, const char *, ...);
91 #if defined(_LONGLONG_TYPE)
92 extern long long	wstoll(const wchar_t *, wchar_t **, int);
93 #endif	/* defined(_LONGLONG_TYPE) */
94 
95 #endif /* !defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX) */
96 
97 #else	/* !defined(__STDC__) */
98 /* Character based input and output functions */
99 extern wchar_t		*getws();
100 extern int		putws();
101 
102 #ifndef getwc
103 #define	getwc(p)	fgetwc(p)
104 #endif
105 #ifndef putwc
106 #define	putwc(x, p)	fputwc((x), (p))
107 #endif
108 #ifndef getwchar
109 #define	getwchar()	getwc(stdin)
110 #endif
111 #ifndef putwchar
112 #define	putwchar(x)	putwc((x), stdout)
113 #endif
114 
115 /* wchar_t string operation functions */
116 extern wchar_t	*strtows();
117 extern wchar_t	*wscpy();
118 extern wchar_t	*wsncpy();
119 extern wchar_t	*wscat();
120 extern wchar_t	*wsncat();
121 extern wchar_t	*wschr();
122 extern wchar_t	*wsrchr();
123 extern wchar_t	*wspbrk();
124 extern wchar_t	*wstok();
125 
126 extern int	wscmp();
127 extern int	wsncmp();
128 extern int	wslen();
129 extern int	wsspn();
130 extern int	wscspn();
131 extern int	wscoll();
132 extern int	wsxfrm();
133 
134 extern char	*wstostr();
135 extern wchar_t	*wsdup();
136 extern int	wscol();
137 extern double	wstod();
138 extern long	wstol();
139 extern int	wscasecmp();
140 extern int	wsncasecmp();
141 extern int	wsprintf();
142 #if defined(_LONGLONG_TYPE)
143 extern long long	wstoll();
144 #endif	/* defined(_LONGLONG_TYPE) */
145 
146 #endif	/* !defined(__STDC__) */
147 
148 /* Returns the code set number for the process code c. */
149 #define	WCHAR_SHIFT	7
150 #define	WCHAR_S_MASK	0x7f
151 #define	wcsetno(c) \
152 	(((c)&0x20000000)?(((c)&0x10000000)?1:3):(((c)&0x10000000)?2:0))
153 
154 /* Aliases... */
155 #define	windex		wschr
156 #define	wrindex		wsrchr
157 
158 #define	watol(s)	wstol((s), (wchar_t **)0, 10)
159 #if defined(_LONGLONG_TYPE) && !defined(__lint)
160 #define	watoll(s)	wstoll((s), (wchar_t **)0, 10)
161 #endif	/* defined(_LONGLONG_TYPE) && !defined(__lint) */
162 #define	watoi(s)	((int)wstol((s), (wchar_t **)0, 10))
163 #define	watof(s)	wstod((s), (wchar_t **)0)
164 
165 /*
166  * other macros.
167  */
168 #define	WCHAR_CSMASK	0x30000000
169 #define	EUCMASK		0x30000000
170 #define	WCHAR_CS0	0x00000000
171 #define	WCHAR_CS1	0x30000000
172 #define	WCHAR_CS2	0x10000000
173 #define	WCHAR_CS3	0x20000000
174 #define	WCHAR_BYTE_OF(wc, i) (((wc&~0x30000000)>>(7*(3-i)))&0x7f)
175 
176 #ifdef	__cplusplus
177 }
178 #endif
179 
180 #endif	/* _WIDEC_H */
181