xref: /titanic_41/usr/src/lib/libxcurses/h/m_invari.h (revision d29b2c4438482eb00488be49a1f5d6835f455546)
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 (c) 1996, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Copyright 1993 by Mortice Kern Systems Inc.  All rights reserved.
31  *
32  * $Header: /rd/h/rcs/m_invari.h 1.12 1994/07/06 17:41:39 miked Exp $
33  */
34 
35 /*
36  * m_invari.h:
37  *    Configuration and definitions for support of on systems (e.g EBCDIC)
38  *    where the POSIX.2 portable characters are not invariant
39  */
40 
41 #ifndef __M_M_INVARI_H__
42 #define	__M_M_INVARI_H__
43 
44 /*
45  * Are all characters in the portable character set invariant across
46  * all locales?  The results, for posix, if not, are undefined.
47  * For systems that want to try to deal with this, M_VARIANTS is set.
48  */
49 #ifdef	M_VARIANTS
50 
51 extern char	__m_invariant[];
52 extern char	__m_unvariant[];
53 
54 /*
55  * The M_INVARIANTINIT macro must be called to initialize: it returns -1
56  * on memory allocation error.  It may be called multiple times, but has
57  * no effect after the first call.  To reinitialize the variant <-->
58  * invariant tables after a new setlocale(), use M_INVARIANTREINIT().
59  * On error, m_error will have been invoked with an appropriate message.
60  */
61 #define	M_INVARIANTINIT()	m_invariantinit()
62 extern void	m_invariantinit(void);
63 #define	M_INVARIANTREINIT()	__m_setinvariant()
64 extern void	__m_setinvariant(void);
65 
66 /*
67  * Assume wide characters are always ok.
68  * Otherwise, always indirect thru the narrow un/invariant table.
69  * INVARIANT takes the character in the current locale, and produces an
70  * invariant value, equal to that the C compiler would have compiled.
71  * UNVARIANT is the inverse; it takes what the C compiler would have
72  * compiled, and returns the value in the current locale.
73  */
74 #define	M_INVARIANT(c)	(wctob(c) == EOF ? (c) : __m_invariant[c])
75 #define	M_UNVARIANT(c)	(wctob(c) == EOF ? (c) : __m_unvariant[c])
76 #define	M_UNVARIANTSTR(s)	m_unvariantstr(s)
77 char *m_unvariantstr(char const *);
78 #define	M_WUNVARIANTSTR(ws)	m_wunvariantstr(ws)
79 wchar_t *m_wunvariantstr(wchar_t const *);
80 
81 #else	/* M_VARIANTS */
82 
83 /* Normal system */
84 #define	M_INVARIANTINIT()	/* NULL */
85 #define M_INVARIANTREINIT()	/* NULL */
86 #define	M_INVARIANT(c)		(c)
87 #define	M_UNVARIANT(c)		(c)
88 #define	M_UNVARIANTSTR(s)	(s)
89 #define	M_WUNVARIANTSTR(ws)	(ws)
90 
91 #endif	/* M_VARIANTS */
92 
93 #endif /*__M_M_INVARI_H__*/
94 
95 
96 
97