xref: /titanic_44/usr/src/head/widec.h (revision 01fbe6ad23cb7fa68bde22fb8edde979ebfb34da)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24ba3594baSGarrett D'Amore  *
257c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*	Copyright (c) 1986 AT&T	*/
307c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*	This module is created for NLS on Jun.04.86		*/
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifndef	_WIDEC_H
367c478bd9Sstevel@tonic-gate #define	_WIDEC_H
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <stdio.h>	/* For definition of FILE */
417c478bd9Sstevel@tonic-gate #include <euc.h>
427c478bd9Sstevel@tonic-gate #include <wchar.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /* Character based input and output functions */
497c478bd9Sstevel@tonic-gate extern wchar_t	*getws(wchar_t *);
507c478bd9Sstevel@tonic-gate extern int	putws(const wchar_t *);
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #if !defined(__lint)
537c478bd9Sstevel@tonic-gate #define	getwc(p)	fgetwc(p)
547c478bd9Sstevel@tonic-gate #define	putwc(x, p)	fputwc((x), (p))
557c478bd9Sstevel@tonic-gate #define	getwchar()	getwc(stdin)
567c478bd9Sstevel@tonic-gate #define	putwchar(x)	putwc((x), stdout)
577c478bd9Sstevel@tonic-gate #endif
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /* wchar_t string operation functions */
607c478bd9Sstevel@tonic-gate extern wchar_t	*strtows(wchar_t *, char *);
617c478bd9Sstevel@tonic-gate extern wchar_t	*wscpy(wchar_t *, const wchar_t *);
627c478bd9Sstevel@tonic-gate extern wchar_t	*wsncpy(wchar_t *, const wchar_t *, size_t);
637c478bd9Sstevel@tonic-gate extern wchar_t	*wscat(wchar_t *, const wchar_t *);
647c478bd9Sstevel@tonic-gate extern wchar_t	*wsncat(wchar_t *, const wchar_t *, size_t);
657c478bd9Sstevel@tonic-gate extern wchar_t	*wschr(const wchar_t *, wchar_t);
667c478bd9Sstevel@tonic-gate extern wchar_t	*wsrchr(const wchar_t *, wchar_t);
677c478bd9Sstevel@tonic-gate extern wchar_t	*wspbrk(const wchar_t *, const wchar_t *);
687c478bd9Sstevel@tonic-gate extern wchar_t	*wstok(wchar_t *, const wchar_t *);
697c478bd9Sstevel@tonic-gate extern char	*wstostr(char *, wchar_t *);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate extern int	wscmp(const wchar_t *, const wchar_t *);
727c478bd9Sstevel@tonic-gate extern int	wsncmp(const wchar_t *, const wchar_t *, size_t);
737c478bd9Sstevel@tonic-gate extern size_t	wslen(const wchar_t *);
747c478bd9Sstevel@tonic-gate extern size_t	wsspn(const wchar_t *, const wchar_t *);
757c478bd9Sstevel@tonic-gate extern size_t	wscspn(const wchar_t *, const wchar_t *);
767c478bd9Sstevel@tonic-gate extern int	wscoll(const wchar_t *, const wchar_t *);
777c478bd9Sstevel@tonic-gate extern size_t	wsxfrm(wchar_t *, const wchar_t *, size_t);
787c478bd9Sstevel@tonic-gate 
79*01fbe6adSRichard Lowe #if !defined(_STRICT_SYMBOLS)
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate extern wchar_t	*wsdup(const wchar_t *);
827c478bd9Sstevel@tonic-gate extern int	wscol(const wchar_t *);
837c478bd9Sstevel@tonic-gate extern double	wstod(const wchar_t *, wchar_t **);
847c478bd9Sstevel@tonic-gate extern long	wstol(const wchar_t *, wchar_t **, int);
857c478bd9Sstevel@tonic-gate extern int	wscasecmp(const wchar_t *, const wchar_t *);
867c478bd9Sstevel@tonic-gate extern int	wsncasecmp(const wchar_t *, const wchar_t *, size_t);
877c478bd9Sstevel@tonic-gate extern int	wsprintf(wchar_t *, const char *, ...);
887c478bd9Sstevel@tonic-gate #if defined(_LONGLONG_TYPE)
897c478bd9Sstevel@tonic-gate extern long long	wstoll(const wchar_t *, wchar_t **, int);
907c478bd9Sstevel@tonic-gate #endif	/* defined(_LONGLONG_TYPE) */
917c478bd9Sstevel@tonic-gate 
92*01fbe6adSRichard Lowe #endif /* !defined(_STRICT_SYMBOLS) */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /* Returns the code set number for the process code c. */
957c478bd9Sstevel@tonic-gate #define	WCHAR_SHIFT	7
967c478bd9Sstevel@tonic-gate #define	WCHAR_S_MASK	0x7f
977c478bd9Sstevel@tonic-gate #define	wcsetno(c) \
987c478bd9Sstevel@tonic-gate 	(((c)&0x20000000)?(((c)&0x10000000)?1:3):(((c)&0x10000000)?2:0))
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /* Aliases... */
1017c478bd9Sstevel@tonic-gate #define	windex		wschr
1027c478bd9Sstevel@tonic-gate #define	wrindex		wsrchr
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate #define	watol(s)	wstol((s), (wchar_t **)0, 10)
1057c478bd9Sstevel@tonic-gate #if defined(_LONGLONG_TYPE) && !defined(__lint)
1067c478bd9Sstevel@tonic-gate #define	watoll(s)	wstoll((s), (wchar_t **)0, 10)
1077c478bd9Sstevel@tonic-gate #endif	/* defined(_LONGLONG_TYPE) && !defined(__lint) */
1087c478bd9Sstevel@tonic-gate #define	watoi(s)	((int)wstol((s), (wchar_t **)0, 10))
1097c478bd9Sstevel@tonic-gate #define	watof(s)	wstod((s), (wchar_t **)0)
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /*
1127c478bd9Sstevel@tonic-gate  * other macros.
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate #define	WCHAR_CSMASK	0x30000000
1157c478bd9Sstevel@tonic-gate #define	EUCMASK		0x30000000
1167c478bd9Sstevel@tonic-gate #define	WCHAR_CS0	0x00000000
1177c478bd9Sstevel@tonic-gate #define	WCHAR_CS1	0x30000000
1187c478bd9Sstevel@tonic-gate #define	WCHAR_CS2	0x10000000
1197c478bd9Sstevel@tonic-gate #define	WCHAR_CS3	0x20000000
1207c478bd9Sstevel@tonic-gate #define	WCHAR_BYTE_OF(wc, i) (((wc&~0x30000000)>>(7*(3-i)))&0x7f)
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate #endif
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #endif	/* _WIDEC_H */
127