1 /* ctype.h */
2 
3 /*
4  * Copyright (c) 2015 Intel Corporation.
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_CTYPE_H_
10 #define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_CTYPE_H_
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
isupper(int a)16 static inline int isupper(int a)
17 {
18 	return (int)(((unsigned)(a)-(unsigned)'A') < 26U);
19 }
20 
isalpha(int c)21 static inline int isalpha(int c)
22 {
23 	return (int)((((unsigned)c|32u)-(unsigned)'a') < 26U);
24 }
25 
isspace(int c)26 static inline int isspace(int c)
27 {
28 	return (int)(c == (int)' ' || ((unsigned)c-(unsigned)'\t') < 5U);
29 }
30 
isgraph(int c)31 static inline int isgraph(int c)
32 {
33 	return (int)((((unsigned)c) > ' ') &&
34 			(((unsigned)c) <= (unsigned)'~'));
35 }
36 
isprint(int c)37 static inline int isprint(int c)
38 {
39 	return (int)((((unsigned)c) >= ' ') &&
40 			(((unsigned)c) <= (unsigned)'~'));
41 }
42 
isdigit(int a)43 static inline int isdigit(int a)
44 {
45 	return (int)(((unsigned)(a)-(unsigned)'0') < 10U);
46 }
47 
isxdigit(int a)48 static inline int isxdigit(int a)
49 {
50 	unsigned int ua = (unsigned int)a;
51 
52 	return (int)(((ua - (unsigned)'0') < 10U) ||
53 			((ua | 32U) - (unsigned)'a' < 6U));
54 }
55 
tolower(int chr)56 static inline int tolower(int chr)
57 {
58 	return (chr >= (int)'A' && chr <= (int)'Z') ? (chr + 32) : (chr);
59 }
60 
toupper(int chr)61 static inline int toupper(int chr)
62 {
63 	return (int)((chr >= (int)'a' && chr <=
64 				(int)'z') ? (chr - 32) : (chr));
65 }
66 
isalnum(int chr)67 static inline int isalnum(int chr)
68 {
69 	return (int)(isalpha(chr) || isdigit(chr));
70 }
71 
iscntrl(int c)72 static inline int iscntrl(int c)
73 {
74 	return (int)((((unsigned int)c) <= 31U) || (((unsigned int)c) == 127U));
75 }
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif  /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_CTYPE_H_ */
82