xref: /illumos-gate/usr/src/lib/libxcurses/h/m_invari.h (revision 1da57d55)
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 /*
237c478bd9Sstevel@tonic-gate  * Copyright (c) 1996, by Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate  * All rights reserved.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * Copyright 1993 by Mortice Kern Systems Inc.  All rights reserved.
297c478bd9Sstevel@tonic-gate  *
307c478bd9Sstevel@tonic-gate  * $Header: /rd/h/rcs/m_invari.h 1.12 1994/07/06 17:41:39 miked Exp $
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
34*1da57d55SToomas Soome  * m_invari.h:
357c478bd9Sstevel@tonic-gate  *    Configuration and definitions for support of on systems (e.g EBCDIC)
367c478bd9Sstevel@tonic-gate  *    where the POSIX.2 portable characters are not invariant
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifndef __M_M_INVARI_H__
407c478bd9Sstevel@tonic-gate #define	__M_M_INVARI_H__
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Are all characters in the portable character set invariant across
447c478bd9Sstevel@tonic-gate  * all locales?  The results, for posix, if not, are undefined.
457c478bd9Sstevel@tonic-gate  * For systems that want to try to deal with this, M_VARIANTS is set.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate #ifdef	M_VARIANTS
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate extern char	__m_invariant[];
507c478bd9Sstevel@tonic-gate extern char	__m_unvariant[];
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * The M_INVARIANTINIT macro must be called to initialize: it returns -1
547c478bd9Sstevel@tonic-gate  * on memory allocation error.  It may be called multiple times, but has
557c478bd9Sstevel@tonic-gate  * no effect after the first call.  To reinitialize the variant <-->
567c478bd9Sstevel@tonic-gate  * invariant tables after a new setlocale(), use M_INVARIANTREINIT().
577c478bd9Sstevel@tonic-gate  * On error, m_error will have been invoked with an appropriate message.
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate #define	M_INVARIANTINIT()	m_invariantinit()
607c478bd9Sstevel@tonic-gate extern void	m_invariantinit(void);
617c478bd9Sstevel@tonic-gate #define	M_INVARIANTREINIT()	__m_setinvariant()
627c478bd9Sstevel@tonic-gate extern void	__m_setinvariant(void);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Assume wide characters are always ok.
667c478bd9Sstevel@tonic-gate  * Otherwise, always indirect thru the narrow un/invariant table.
677c478bd9Sstevel@tonic-gate  * INVARIANT takes the character in the current locale, and produces an
687c478bd9Sstevel@tonic-gate  * invariant value, equal to that the C compiler would have compiled.
697c478bd9Sstevel@tonic-gate  * UNVARIANT is the inverse; it takes what the C compiler would have
707c478bd9Sstevel@tonic-gate  * compiled, and returns the value in the current locale.
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate #define	M_INVARIANT(c)	(wctob(c) == EOF ? (c) : __m_invariant[c])
737c478bd9Sstevel@tonic-gate #define	M_UNVARIANT(c)	(wctob(c) == EOF ? (c) : __m_unvariant[c])
747c478bd9Sstevel@tonic-gate #define	M_UNVARIANTSTR(s)	m_unvariantstr(s)
757c478bd9Sstevel@tonic-gate char *m_unvariantstr(char const *);
767c478bd9Sstevel@tonic-gate #define	M_WUNVARIANTSTR(ws)	m_wunvariantstr(ws)
777c478bd9Sstevel@tonic-gate wchar_t *m_wunvariantstr(wchar_t const *);
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #else	/* M_VARIANTS */
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /* Normal system */
827c478bd9Sstevel@tonic-gate #define	M_INVARIANTINIT()	/* NULL */
837c478bd9Sstevel@tonic-gate #define M_INVARIANTREINIT()	/* NULL */
847c478bd9Sstevel@tonic-gate #define	M_INVARIANT(c)		(c)
857c478bd9Sstevel@tonic-gate #define	M_UNVARIANT(c)		(c)
867c478bd9Sstevel@tonic-gate #define	M_UNVARIANTSTR(s)	(s)
877c478bd9Sstevel@tonic-gate #define	M_WUNVARIANTSTR(ws)	(ws)
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #endif	/* M_VARIANTS */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #endif /*__M_M_INVARI_H__*/
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 
95