3909 "zfs send -D" does not work
[illumos-gate.git] / usr / src / common / util / strtolctype.h
blob7b7afc6e3062c54106934103d3b971a8d3aa8a2a
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #ifndef _COMMON_UTIL_CTYPE_H
31 #define _COMMON_UTIL_CTYPE_H
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
38 * This header file contains a collection of macros that the strtou?ll?
39 * functions in common/util use to test characters. What we need is a kernel
40 * version of ctype.h.
43 #if defined(_KERNEL) && !defined(_BOOT)
45 #define isalnum(ch) (isalpha(ch) || isdigit(ch))
46 #define isalpha(ch) (isupper(ch) || islower(ch))
47 #define isdigit(ch) ((ch) >= '0' && (ch) <= '9')
48 #define islower(ch) ((ch) >= 'a' && (ch) <= 'z')
49 #define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \
50 ((ch) == '\t') || ((ch) == '\f'))
51 #define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
52 #define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \
53 ((ch) >= 'A' && (ch) <= 'F'))
55 #endif /* _KERNEL && !_BOOT */
57 #define DIGIT(x) \
58 (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
60 #define MBASE ('z' - 'a' + 1 + 10)
63 * The following macro is a version of isalnum() that limits alphabetic
64 * characters to the ranges a-z and A-Z; locale dependent characters will not
65 * return 1. The members of a-z and A-Z are assumed to be in ascending order
66 * and contiguous.
68 #define lisalnum(x) \
69 (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
71 #ifdef __cplusplus
73 #endif
75 #endif /* _COMMON_UTIL_CTYPE_H */