12ef9abdcSjv /* 22ef9abdcSjv * CDDL HEADER START 32ef9abdcSjv * 42ef9abdcSjv * The contents of this file are subject to the terms of the 52ef9abdcSjv * Common Development and Distribution License (the "License"). 62ef9abdcSjv * You may not use this file except in compliance with the License. 72ef9abdcSjv * 82ef9abdcSjv * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92ef9abdcSjv * or http://www.opensolaris.org/os/licensing. 102ef9abdcSjv * See the License for the specific language governing permissions 112ef9abdcSjv * and limitations under the License. 122ef9abdcSjv * 132ef9abdcSjv * When distributing Covered Code, include this CDDL HEADER in each 142ef9abdcSjv * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152ef9abdcSjv * If applicable, add the following below this CDDL HEADER, with the 162ef9abdcSjv * fields enclosed by brackets "[]" replaced with your own identifying 172ef9abdcSjv * information: Portions Copyright [yyyy] [name of copyright owner] 182ef9abdcSjv * 192ef9abdcSjv * CDDL HEADER END 202ef9abdcSjv */ 212ef9abdcSjv 222ef9abdcSjv /* 232ef9abdcSjv * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 242ef9abdcSjv * Use is subject to license terms. 252ef9abdcSjv */ 262ef9abdcSjv 272ef9abdcSjv /* Copyright (c) 1988 AT&T */ 282ef9abdcSjv /* All Rights Reserved */ 292ef9abdcSjv 302ef9abdcSjv #ifndef _COMMON_UTIL_CTYPE_H 312ef9abdcSjv #define _COMMON_UTIL_CTYPE_H 322ef9abdcSjv 332ef9abdcSjv #ifdef __cplusplus 342ef9abdcSjv extern "C" { 352ef9abdcSjv #endif 362ef9abdcSjv 372ef9abdcSjv /* 382ef9abdcSjv * This header file contains a collection of macros that the strtou?ll? 392ef9abdcSjv * functions in common/util use to test characters. What we need is a kernel 402ef9abdcSjv * version of ctype.h. 41*f497f9feSJoshua M. Clulow * 42*f497f9feSJoshua M. Clulow * NOTE: These macros are used within several DTrace probe context functions. 43*f497f9feSJoshua M. Clulow * They must not be altered to make function calls or perform actions not 44*f497f9feSJoshua M. Clulow * safe in probe context. 452ef9abdcSjv */ 462ef9abdcSjv 472ef9abdcSjv #if defined(_KERNEL) && !defined(_BOOT) 482ef9abdcSjv 492ef9abdcSjv #define isalnum(ch) (isalpha(ch) || isdigit(ch)) 502ef9abdcSjv #define isalpha(ch) (isupper(ch) || islower(ch)) 512ef9abdcSjv #define isdigit(ch) ((ch) >= '0' && (ch) <= '9') 522ef9abdcSjv #define islower(ch) ((ch) >= 'a' && (ch) <= 'z') 532ef9abdcSjv #define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \ 542ef9abdcSjv ((ch) == '\t') || ((ch) == '\f')) 552ef9abdcSjv #define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z') 562ef9abdcSjv #define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \ 572ef9abdcSjv ((ch) >= 'A' && (ch) <= 'F')) 582ef9abdcSjv 592ef9abdcSjv #endif /* _KERNEL && !_BOOT */ 602ef9abdcSjv 612ef9abdcSjv #define DIGIT(x) \ 622ef9abdcSjv (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A') 632ef9abdcSjv 642ef9abdcSjv #define MBASE ('z' - 'a' + 1 + 10) 652ef9abdcSjv 662ef9abdcSjv /* 672ef9abdcSjv * The following macro is a version of isalnum() that limits alphabetic 682ef9abdcSjv * characters to the ranges a-z and A-Z; locale dependent characters will not 692ef9abdcSjv * return 1. The members of a-z and A-Z are assumed to be in ascending order 702ef9abdcSjv * and contiguous. 712ef9abdcSjv */ 722ef9abdcSjv #define lisalnum(x) \ 732ef9abdcSjv (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z')) 742ef9abdcSjv 752ef9abdcSjv #ifdef __cplusplus 762ef9abdcSjv } 772ef9abdcSjv #endif 782ef9abdcSjv 792ef9abdcSjv #endif /* _COMMON_UTIL_CTYPE_H */ 80