_ctype.h revision 133559
11539Srgrimes/* 21539Srgrimes * Copyright (c) 1989, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * (c) UNIX System Laboratories, Inc. 51539Srgrimes * All or some portions of this file are derived from material licensed 61539Srgrimes * to the University of California by American Telephone and Telegraph 71539Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81539Srgrimes * the permission of UNIX System Laboratories, Inc. 91539Srgrimes * 101539Srgrimes * This code is derived from software contributed to Berkeley by 111539Srgrimes * Paul Borman at Krystal Technologies. 121539Srgrimes * 131539Srgrimes * Redistribution and use in source and binary forms, with or without 141539Srgrimes * modification, are permitted provided that the following conditions 151539Srgrimes * are met: 161539Srgrimes * 1. Redistributions of source code must retain the above copyright 171539Srgrimes * notice, this list of conditions and the following disclaimer. 181539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 191539Srgrimes * notice, this list of conditions and the following disclaimer in the 201539Srgrimes * documentation and/or other materials provided with the distribution. 211539Srgrimes * 3. All advertising materials mentioning features or use of this software 221539Srgrimes * must display the following acknowledgement: 231539Srgrimes * This product includes software developed by the University of 241539Srgrimes * California, Berkeley and its contributors. 251539Srgrimes * 4. Neither the name of the University nor the names of its contributors 261539Srgrimes * may be used to endorse or promote products derived from this software 271539Srgrimes * without specific prior written permission. 281539Srgrimes * 291539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 301539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 311539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 321539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 331539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 341539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 351539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 361539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 371539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 381539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 391539Srgrimes * SUCH DAMAGE. 401539Srgrimes * 41133559Stjr * From @(#)ctype.h 8.4 (Berkeley) 1/21/94 42133559Stjr * From FreeBSD: src/include/ctype.h,v 1.27 2004/06/23 07:11:39 tjr Exp 43133559Stjr * $FreeBSD: head/include/_ctype.h 133559 2004-08-12 09:33:47Z tjr $ 441539Srgrimes */ 451539Srgrimes 46133559Stjr#ifndef __CTYPE_H_ 47133559Stjr#define __CTYPE_H_ 481539Srgrimes 49103113Smike#include <sys/cdefs.h> 50103113Smike#include <sys/_types.h> 511539Srgrimes 5257035Sobrien#define _CTYPE_A 0x00000100L /* Alpha */ 5357035Sobrien#define _CTYPE_C 0x00000200L /* Control */ 5457035Sobrien#define _CTYPE_D 0x00000400L /* Digit */ 5557035Sobrien#define _CTYPE_G 0x00000800L /* Graph */ 5657035Sobrien#define _CTYPE_L 0x00001000L /* Lower */ 5757035Sobrien#define _CTYPE_P 0x00002000L /* Punct */ 5857035Sobrien#define _CTYPE_S 0x00004000L /* Space */ 5957035Sobrien#define _CTYPE_U 0x00008000L /* Upper */ 6057035Sobrien#define _CTYPE_X 0x00010000L /* X digit */ 6157035Sobrien#define _CTYPE_B 0x00020000L /* Blank */ 6257035Sobrien#define _CTYPE_R 0x00040000L /* Print */ 6357035Sobrien#define _CTYPE_I 0x00080000L /* Ideogram */ 6457035Sobrien#define _CTYPE_T 0x00100000L /* Special */ 6557035Sobrien#define _CTYPE_Q 0x00200000L /* Phonogram */ 66101984Skeichii#define _CTYPE_SW0 0x20000000L /* 0 width character */ 67102093Sache#define _CTYPE_SW1 0x40000000L /* 1 width character */ 68101984Skeichii#define _CTYPE_SW2 0x80000000L /* 2 width character */ 69101984Skeichii#define _CTYPE_SW3 0xc0000000L /* 3 width character */ 701539Srgrimes 71102998Smike/* See comments in <sys/_types.h> about __ct_rune_t. */ 721539Srgrimes__BEGIN_DECLS 73102227Smikeunsigned long ___runetype(__ct_rune_t); 74102227Smike__ct_rune_t ___tolower(__ct_rune_t); 75102227Smike__ct_rune_t ___toupper(__ct_rune_t); 761539Srgrimes__END_DECLS 771539Srgrimes 781539Srgrimes/* 797655Sbde * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us 807655Sbde * to generate code for extern versions of all our inline functions. 811539Srgrimes */ 827655Sbde#ifdef _EXTERNALIZE_CTYPE_INLINES_ 837655Sbde#define _USE_CTYPE_INLINE_ 847655Sbde#define static 857655Sbde#define __inline 861539Srgrimes#endif 871539Srgrimes 887655Sbde/* 897655Sbde * Use inline functions if we are allowed to and the compiler supports them. 907655Sbde */ 917655Sbde#if !defined(_DONT_USE_CTYPE_INLINE_) && \ 927655Sbde (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus)) 93103113Smike 94103113Smike#include <runetype.h> 95103113Smike 961539Srgrimesstatic __inline int 97102227Smike__maskrune(__ct_rune_t _c, unsigned long _f) 981539Srgrimes{ 9929855Sache return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) : 100130961Stjr _CurrentRuneLocale->__runetype[_c]) & _f; 1011539Srgrimes} 1021539Srgrimes 1031539Srgrimesstatic __inline int 104102227Smike__istype(__ct_rune_t _c, unsigned long _f) 10590231Sbbraun{ 10690231Sbbraun return (!!__maskrune(_c, _f)); 10790231Sbbraun} 10890231Sbbraun 10990231Sbbraunstatic __inline int 110102227Smike__isctype(__ct_rune_t _c, unsigned long _f) 1111539Srgrimes{ 11212028Sache return (_c < 0 || _c >= _CACHED_RUNES) ? 0 : 113130961Stjr !!(_DefaultRuneLocale.__runetype[_c] & _f); 1141539Srgrimes} 1151539Srgrimes 116102227Smikestatic __inline __ct_rune_t 117102227Smike__toupper(__ct_rune_t _c) 1181539Srgrimes{ 11914813Sache return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) : 120130961Stjr _CurrentRuneLocale->__mapupper[_c]; 1211539Srgrimes} 1221539Srgrimes 123102227Smikestatic __inline __ct_rune_t 124102227Smike__tolower(__ct_rune_t _c) 1251539Srgrimes{ 12614813Sache return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) : 127130961Stjr _CurrentRuneLocale->__maplower[_c]; 1281539Srgrimes} 1291539Srgrimes 1307655Sbde#else /* not using inlines */ 1311539Srgrimes 1321539Srgrimes__BEGIN_DECLS 133102227Smikeint __maskrune(__ct_rune_t, unsigned long); 134102227Smikeint __istype(__ct_rune_t, unsigned long); 135102227Smikeint __isctype(__ct_rune_t, unsigned long); 136102227Smike__ct_rune_t __toupper(__ct_rune_t); 137102227Smike__ct_rune_t __tolower(__ct_rune_t); 1381539Srgrimes__END_DECLS 1397655Sbde#endif /* using inlines */ 1401539Srgrimes 141133559Stjr#endif /* !__CTYPE_H_ */ 142