1267931Srpaulo/* 2267931Srpaulo * CDDL HEADER START 3267931Srpaulo * 4267931Srpaulo * The contents of this file are subject to the terms of the 5267931Srpaulo * Common Development and Distribution License (the "License"). 6267931Srpaulo * You may not use this file except in compliance with the License. 7267931Srpaulo * 8267931Srpaulo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9267931Srpaulo * or http://www.opensolaris.org/os/licensing. 10267931Srpaulo * See the License for the specific language governing permissions 11267931Srpaulo * and limitations under the License. 12267931Srpaulo * 13267931Srpaulo * When distributing Covered Code, include this CDDL HEADER in each 14267931Srpaulo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15267931Srpaulo * If applicable, add the following below this CDDL HEADER, with the 16267931Srpaulo * fields enclosed by brackets "[]" replaced with your own identifying 17267931Srpaulo * information: Portions Copyright [yyyy] [name of copyright owner] 18267931Srpaulo * 19267931Srpaulo * CDDL HEADER END 20267931Srpaulo */ 21267931Srpaulo 22267931Srpaulo/* 23267931Srpaulo * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24267931Srpaulo * Use is subject to license terms. 25267931Srpaulo */ 26267931Srpaulo 27267931Srpaulo/* Copyright (c) 1988 AT&T */ 28267931Srpaulo/* All Rights Reserved */ 29267931Srpaulo 30267931Srpaulo#ifndef _COMMON_UTIL_CTYPE_H 31267931Srpaulo#define _COMMON_UTIL_CTYPE_H 32267931Srpaulo 33267931Srpaulo#ifdef __cplusplus 34267931Srpauloextern "C" { 35267931Srpaulo#endif 36267931Srpaulo 37267931Srpaulo/* 38267931Srpaulo * This header file contains a collection of macros that the strtou?ll? 39267931Srpaulo * functions in common/util use to test characters. What we need is a kernel 40267931Srpaulo * version of ctype.h. 41267931Srpaulo * 42267931Srpaulo * NOTE: These macros are used within several DTrace probe context functions. 43267931Srpaulo * They must not be altered to make function calls or perform actions not 44267931Srpaulo * safe in probe context. 45267931Srpaulo */ 46267931Srpaulo 47267937Srpaulo#if defined(sun) && (defined(_KERNEL) || defined(_BOOT)) 48267931Srpaulo 49267931Srpaulo#define isalnum(ch) (isalpha(ch) || isdigit(ch)) 50267931Srpaulo#define isalpha(ch) (isupper(ch) || islower(ch)) 51267931Srpaulo#define isdigit(ch) ((ch) >= '0' && (ch) <= '9') 52267931Srpaulo#define islower(ch) ((ch) >= 'a' && (ch) <= 'z') 53267931Srpaulo#define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \ 54267931Srpaulo ((ch) == '\t') || ((ch) == '\f')) 55267931Srpaulo#define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z') 56267931Srpaulo#define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \ 57267931Srpaulo ((ch) >= 'A' && (ch) <= 'F')) 58267931Srpaulo 59267931Srpaulo#endif /* _KERNEL || _BOOT */ 60267931Srpaulo 61267931Srpaulo#define DIGIT(x) \ 62267931Srpaulo (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A') 63267931Srpaulo 64267931Srpaulo#define MBASE ('z' - 'a' + 1 + 10) 65267931Srpaulo 66267931Srpaulo/* 67267931Srpaulo * The following macro is a version of isalnum() that limits alphabetic 68267931Srpaulo * characters to the ranges a-z and A-Z; locale dependent characters will not 69267931Srpaulo * return 1. The members of a-z and A-Z are assumed to be in ascending order 70267931Srpaulo * and contiguous. 71267931Srpaulo */ 72267931Srpaulo#define lisalnum(x) \ 73267931Srpaulo (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z')) 74267931Srpaulo 75267931Srpaulo#ifdef __cplusplus 76267931Srpaulo} 77267931Srpaulo#endif 78267931Srpaulo 79267931Srpaulo#endif /* _COMMON_UTIL_CTYPE_H */ 80