1 /* $OpenBSD: ctype.h,v 1.19 2005/12/13 00:35:22 millert Exp $ */ 2 /* $NetBSD: ctype.h,v 1.14 1994/10/26 00:55:47 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1989 The Regents of the University of California. 6 * All rights reserved. 7 * (c) UNIX System Laboratories, Inc. 8 * All or some portions of this file are derived from material licensed 9 * to the University of California by American Telephone and Telegraph 10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 11 * the permission of UNIX System Laboratories, Inc. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)ctype.h 5.3 (Berkeley) 4/3/91 38 */ 39 40 #pragma once 41 42 /** 43 * @file ctype.h 44 * @brief ASCII character classification. 45 */ 46 47 #include <sys/cdefs.h> 48 #include <xlocale.h> 49 50 /** Internal implementation detail. Do not use. */ 51 #define _CTYPE_U 0x01 52 /** Internal implementation detail. Do not use. */ 53 #define _CTYPE_L 0x02 54 /** Internal implementation detail. Do not use. */ 55 #define _CTYPE_D 0x04 56 /** Internal implementation detail. Do not use. */ 57 #define _CTYPE_S 0x08 58 /** Internal implementation detail. Do not use. */ 59 #define _CTYPE_P 0x10 60 /** Internal implementation detail. Do not use. */ 61 #define _CTYPE_C 0x20 62 /** Internal implementation detail. Do not use. */ 63 #define _CTYPE_X 0x40 64 /** Internal implementation detail. Do not use. */ 65 #define _CTYPE_B 0x80 66 /** Internal implementation detail. Do not use. */ 67 #define _CTYPE_R (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_D|_CTYPE_B) 68 /** Internal implementation detail. Do not use. */ 69 #define _CTYPE_A (_CTYPE_L|_CTYPE_U) 70 /** Internal implementation detail. Do not use. */ 71 #define _CTYPE_N _CTYPE_D 72 73 __BEGIN_DECLS 74 75 /** Internal implementation detail. Do not use. */ 76 extern const char* _ctype_; 77 78 /** Returns true if `ch` is in `[A-Za-z0-9]`. */ 79 int isalnum(int __ch); 80 /** Returns true if `ch` is in `[A-Za-z]`. */ 81 int isalpha(int __ch); 82 /** Returns true if `ch` is a space or tab. */ 83 int isblank(int __ch); 84 /** Returns true if `ch` is a control character (any character before space, plus DEL). */ 85 int iscntrl(int __ch); 86 /** Returns true if `ch` is in `[0-9]`. */ 87 int isdigit(int __ch); 88 /** Returns true if `ch` is `[A-Za-z0-9]` or punctuation. */ 89 int isgraph(int __ch); 90 /** Returns true if `ch` is in `[a-z]`. */ 91 int islower(int __ch); 92 /** Returns true if `ch` is `[A-Za-z0-9]` or punctuation or space. */ 93 int isprint(int __ch); 94 /** Returns true if `ch` is punctuation. */ 95 int ispunct(int __ch); 96 /** Returns true if `ch` is in `[ \f\n\r\t\v]`. */ 97 int isspace(int __ch); 98 /** Returns true if `ch` is in `[A-Z]`. */ 99 int isupper(int __ch); 100 /** Returns true if `ch` is in `[0-9a-f]`. */ 101 int isxdigit(int __ch); 102 103 /** Returns the corresponding lower-case character if `ch` is upper-case, or `ch` otherwise. */ 104 int tolower(int __ch); 105 106 /** 107 * Returns the corresponding lower-case character if `ch` is upper-case, or undefined otherwise. 108 * 109 * Available since API level 21. 110 * 111 * Prefer tolower() instead. 112 */ 113 int _tolower(int __ch) __INTRODUCED_IN(21); 114 115 /** Returns the corresponding upper-case character if `ch` is lower-case, or `ch` otherwise. */ 116 int toupper(int __ch); 117 118 /** 119 * Returns the corresponding upper-case character if `ch` is lower-case, or undefined otherwise. 120 * 121 * Available since API level 21. 122 * 123 * Prefer toupper() instead. 124 */ 125 int _toupper(int __ch) __INTRODUCED_IN(21); 126 127 #if __ANDROID_API__ >= __ANDROID_API_L__ 128 /** Like isalnum but with an ignored `locale_t`. */ 129 int isalnum_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 130 /** Like isalpha but with an ignored `locale_t`. */ 131 int isalpha_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 132 /** Like isblank but with an ignored `locale_t`. */ 133 int isblank_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 134 /** Like iscntrl but with an ignored `locale_t`. */ 135 int iscntrl_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 136 /** Like isdigit but with an ignored `locale_t`. */ 137 int isdigit_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 138 /** Like isgraph but with an ignored `locale_t`. */ 139 int isgraph_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 140 /** Like islower but with an ignored `locale_t`. */ 141 int islower_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 142 /** Like isprint but with an ignored `locale_t`. */ 143 int isprint_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 144 /** Like ispunct but with an ignored `locale_t`. */ 145 int ispunct_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 146 /** Like isspace but with an ignored `locale_t`. */ 147 int isspace_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 148 /** Like isupper but with an ignored `locale_t`. */ 149 int isupper_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 150 /** Like isxdigit but with an ignored `locale_t`. */ 151 int isxdigit_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 152 /** Like tolower but with an ignored `locale_t`. */ 153 int tolower_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 154 /** Like toupper but with an ignored `locale_t`. */ 155 int toupper_l(int __ch, locale_t __l) __INTRODUCED_IN(21); 156 #else 157 // Implemented as static inlines before 21. 158 #endif 159 160 /** Returns true if `ch` is less than 0x80. */ 161 int isascii(int __ch); 162 /** Returns `ch & 0x7f`. */ 163 int toascii(int __ch); 164 165 __END_DECLS 166