strtolctype.h revision f497f9fe231e0e400f339c84a7d80c4aae2ac4d5
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv/*
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * CDDL HEADER START
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv *
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * The contents of this file are subject to the terms of the
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * Common Development and Distribution License (the "License").
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * You may not use this file except in compliance with the License.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv *
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * or http://www.opensolaris.org/os/licensing.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * See the License for the specific language governing permissions
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * and limitations under the License.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv *
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * When distributing Covered Code, include this CDDL HEADER in each
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * If applicable, add the following below this CDDL HEADER, with the
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * fields enclosed by brackets "[]" replaced with your own identifying
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * information: Portions Copyright [yyyy] [name of copyright owner]
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv *
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * CDDL HEADER END
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv */
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv/*
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * Use is subject to license terms.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv */
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv/* Copyright (c) 1988 AT&T */
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv/* All Rights Reserved */
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#ifndef _COMMON_UTIL_CTYPE_H
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define _COMMON_UTIL_CTYPE_H
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#ifdef __cplusplus
2ef9abdc6ea9bad985430325b12b90938a8cd18fjvextern "C" {
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#endif
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv/*
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * This header file contains a collection of macros that the strtou?ll?
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * functions in common/util use to test characters. What we need is a kernel
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * version of ctype.h.
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow *
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * NOTE: These macros are used within several DTrace probe context functions.
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * They must not be altered to make function calls or perform actions not
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * safe in probe context.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv */
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#if defined(_KERNEL) && !defined(_BOOT)
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define isalnum(ch) (isalpha(ch) || isdigit(ch))
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define isalpha(ch) (isupper(ch) || islower(ch))
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define isdigit(ch) ((ch) >= '0' && (ch) <= '9')
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define islower(ch) ((ch) >= 'a' && (ch) <= 'z')
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv ((ch) == '\t') || ((ch) == '\f'))
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv ((ch) >= 'A' && (ch) <= 'F'))
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#endif /* _KERNEL && !_BOOT */
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define DIGIT(x) \
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define MBASE ('z' - 'a' + 1 + 10)
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv/*
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * The following macro is a version of isalnum() that limits alphabetic
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * characters to the ranges a-z and A-Z; locale dependent characters will not
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * return 1. The members of a-z and A-Z are assumed to be in ascending order
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv * and contiguous.
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv */
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#define lisalnum(x) \
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#ifdef __cplusplus
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv}
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#endif
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv
2ef9abdc6ea9bad985430325b12b90938a8cd18fjv#endif /* _COMMON_UTIL_CTYPE_H */