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