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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SMBSRV_CTYPE_H 27 #define _SMBSRV_CTYPE_H 28 29 #pragma ident "@(#)ctype.h 1.1 07/10/25 SMI" 30 31 #include <smbsrv/codepage.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #define _mts_between(l, c, u) ((l) <= (c) && (c) <= (u)) 38 39 /* 40 * These macros take non-ascii characters into account. 41 * Their behavior depends on the codepage that is used. 42 */ 43 #define mts_islower(c) codepage_islower((c)) 44 #define mts_isupper(c) codepage_isupper((c)) 45 #define mts_tolower(c) codepage_tolower((c)) 46 #define mts_toupper(c) codepage_toupper((c)) 47 48 #define mts_isalpha(c) (mts_islower(c) || mts_isupper(c)) 49 #define mts_isdigit(c) _mts_between('0', (c), '9') 50 #define mts_isalnum(c) (mts_isalpha(c) || mts_isdigit(c)) 51 #define mts_isxdigit(c) (mts_isdigit(c) || \ 52 _mts_between('a', (c), 'f') || \ 53 _mts_between('A', (c), 'F')) 54 #define mts_isblank(c) ((c) == ' ' || (c) == '\t') 55 #define mts_isspace(c) ((c) == ' ' || \ 56 (c) == '\t' || \ 57 (c) == '\n' || \ 58 (c) == '\r' || \ 59 (c) == '\f') 60 #define mts_isascii(c) (!((c) &~ 0x7F)) 61 62 /* These macros only apply to ASCII */ 63 #define mts_isalpha_ascii(c) \ 64 (_mts_between('a', (c), 'z') || _mts_between('A', (c), 'Z')) 65 #define mts_isalnum_ascii(c) (mts_isalpha_ascii(c) || mts_isdigit(c)) 66 67 /* should it include non-ascii characters ? */ 68 #define mts_isprint(c) _mts_between('!', (c), '~') 69 #define mts_iscntrl(c) (((c) >= 0) && ((c) <= 0x1f)) || ((c) == 0x7f)) 70 #define mts_ispunct(c) (mts_isprint(c) && !mts_isxdigit(c) && !mts_isspace(c)) 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif /* _SMBSRV_CTYPE_H */ 77