m_wchar.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1996, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* Copyright 1992, 1993 by Mortice Kern Systems Inc. All rights reserved.
*
*
*/
#ifndef __M_M_WCHAR_H__
#define __M_M_WCHAR_H__ 1
/*
* m_wchar.h:
* configuration file for multi-byte vs. single byte enablement
*/
#include <wchar.h>
#include <wctype.h>
#include <limits.h> /* Fetch MB_LEN_MAX */
#ifdef M_I18N_LOCKING_SHIFT
extern char *m_strsanitize (char *);
#else
#endif /* M_I18N_LOCKING_SHIFT */
#ifdef M_I18N_MB
# ifndef MB_LEN_MAX
# endif /* MB_LEN_MAX */
#define MB_ELSE } else {
#define MB_END }
#define M_MB_L(s) L##s
#ifndef _WUCHAR_T
#define _WUCHAR_T
/* a typedef to allow single byte distinction between char and uchar
* in MKS environment
*/
#endif /*_WUCHAR_T*/
extern wchar_t *m_mbstowcsdup (const char *s);
extern char *m_wcstombsdup (const wchar_t *w);
extern char *m_mbschr (const char *, int);
extern char *m_mbsrchr (const char *, int);
extern char *m_mbspbrk (const char *, const char *);
extern int iswabsname (wchar_t *);
#define m_smalls(s) (s)
#else /* !M_I18N_MB */
/* include <stdlib.h> here,
* We must include the multibyte function prototypes (in <stdlib.h>) before
* redefining the prototype function names below.
*
* AND including <stdlib.h> DOES NOT cause a problem with wchar_t.
*
* ANSI says that the typedef of wchar_t should be defined in stdlib.h.
* Thus, the prototypes in stdlib.h are declared using stdlib's definition
* of wchar_t.
*/
#include <stdlib.h> /* DO NOT MOVE THIS include - THIS must be first */
#define m_escapewc m_escapec
#define m_mbstowcsdup strdup
#define m_wcstombsdup strdup
#define iswabsname(s) isabsname(s)
#define MB_BEGIN if (0) {
#define MB_ELSE } else {
#define MB_END }
#define M_MB_L(s) s
/*
* Types and Macros
*/
#define wchar_t char /* ensures we never use the wchar_t typedef */
#define wint_t int /* type as large as either wchar_t or WEOF */
#define wuchar_t unsigned char /* Force override of typedef */
/*
* Must define _WCHAR_T, _WINT_T and _WUCHAR_T to avoid typedefs collisions
* in other system headers.
* Most systems do something like this:
* #ifndef _WCHAR_T
* #define _WCHAR_T
* typedef unsigned short wchar_t
* #endif
* in their system headers to avoid multiple declarations of wchar_t
*/
#define _WCHAR_T
#define _WINT_T
#define _WUCHAR_T
/*
*/
/* NOTE:
* In single byte mode, both swprintf() and vswprintf() are converted to
* similar, but NOT IDENTICAL, functions that have slightly different
* semantics.
* The 2nd argument to both these routines (e.g the size_t arg)
* is not used in the singlebyte environment since sprintf() and vsprintf()
* do not support this argument.
* One has to be careful when using this routine to not depend on
* the enforcement/safety of this 2nd argument.
*
* swprintf() is converted to m_swprintf(), which is a C function
* (because it can use a variable number of args),
* which is implemented as a call to vsprint()
* vswprintf() is converted to vsprintf()
*
*/
#define swprintf m_swprintf
#ifndef m_smalls
#endif /*m_smalls*/
/*
* General Utilities
*/
#define wctomb_init() (0) /* No state dependency for nonmultibyte. */
/*
* Wide string handling
*/
#define wcwidth(c) 1
/*
* Date and time
*/
/*
* Extended Multibyte functions
*/
/*
* Define prototypes for singlebyte equivalents of multibyte functions.
* We have to use macros to map them to other function names, so that
* they do not conflict with the prototypes from <stdlib.h> that may have
* used a different definition of wchar_t. The restartable functions are
* mapped to their non-restartable counterparts, since there is no state
* information to be preserved.
*/
#define mblen(s, n) m_sb_mblen(s, n)
extern int m_sb_mblen(const char *s, size_t n);
/*
* convert definitions from <wctype.h>
*/
/*
* Note: MKS libc/gen/iswctype.c contains the system independent version
* of wctype() and iswctype().
*
* In single byte mode, we can't use the names wctype() and iswctype().
* These may have been defined in the system's headers (e.g <wctype.h>)
* using the system definition of wint_t and wctype_t.
* BUT we have just changed the meaning of wint_t above, to an 'int'
* which may not be the same size as wint_t.
* Thus, we rename them so that we don't get any prototype conflicts
*/
#define iswctype _m_iswctype
/*
* .2 Functions
*/
#include <fnmatch.h>
#include <regex.h>
#define regwdosuba regdosuba
#define regwmatch_t regmatch_t
#endif /* M_I18N_MB */
/*
* prototypes that are common to both SingleByte and MultiByte
*/
extern int m_mbswidth (const char *, size_t);
#endif /*__M_M_WCHAR_H__*/