Modify licenses
[scp/ocu/5gnr.git] / Include / vos_ctype.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2020 ICT/CAS.
4 *
5 *   Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       https://www.o-ran.org/software
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19
20
21
22 #ifndef _VOS_CTYPE_H
23 #define _VOS_CTYPE_H
24
25 #include "vos_types.h"
26
27 /*
28  * NOTE! This ctype does not handle EOF like the standard C
29  * library is required to.
30  */
31
32 #define _VOS_U  0x01    /* upper */
33 #define _VOS_L  0x02    /* lower */
34 #define _VOS_D  0x04    /* digit */
35 #define _VOS_C  0x08    /* cntrl */
36 #define _VOS_P  0x10    /* punct */
37 #define _VOS_S  0x20    /* white space (space/lf/tab) */
38 #define _VOS_X  0x40    /* hex digit */
39 #define _VOS_SP 0x80    /* hard space (0x20) */
40
41 extern unsigned char _vos_ctype[];
42
43 #define __vos_ismask(x) (_vos_ctype[(int)(unsigned char)(x)])
44
45 /** 同 isalnum */
46 #define vos_isalnum(c)  ((__vos_ismask(c)&(_VOS_U|_VOS_L|_VOS_D)) != 0)
47
48 /** 同 isalpha */
49 #define vos_isalpha(c)  ((__vos_ismask(c)&(_VOS_U|_VOS_L)) != 0)
50
51 /** 同 iscntrl */
52 #define vos_iscntrl(c)  ((__vos_ismask(c)&(_VOS_C)) != 0)
53
54 /** 同 isdigit */
55 #define vos_isdigit(c)  ((__vos_ismask(c)&(_VOS_D)) != 0)
56
57 /** 同 isgraph */
58 #define vos_isgraph(c)  ((__vos_ismask(c)&(_VOS_P|_VOS_U|_VOS_L|_VOS_D)) != 0)
59
60 /** 同 islower */
61 #define vos_islower(c)  ((__vos_ismask(c)&(_VOS_L)) != 0)
62
63 /** 同 isprint */
64 #define vos_isprint(c)  ((__vos_ismask(c)&(_VOS_P|_VOS_U|_VOS_L|_VOS_D|_VOS_SP)) != 0)
65
66 /** 同 ispunct */
67 #define vos_ispunct(c)  ((__vos_ismask(c)&(_VOS_P)) != 0)
68
69 /** 同 isspace */
70 #define vos_isspace(c)  ((__vos_ismask(c)&(_VOS_S)) != 0)
71
72 /** 同 isupper */
73 #define vos_isupper(c)  ((__vos_ismask(c)&(_VOS_U)) != 0)
74
75 /** 同 isxdigit */
76 #define vos_isxdigit(c) ((__vos_ismask(c)&(_VOS_D|_VOS_X)) != 0)
77
78 /** 同 isascii */
79 #define vos_isascii(c) (((unsigned char)(c))<=0x7f)
80
81 /** 同 toascii */
82 #define vos_toascii(c) (((unsigned char)(c))&0x7f)
83
84 /** 同 tolower */
85 UCHAR vos_tolower(UCHAR c);
86
87 /** 同 toupper */
88 UCHAR vos_toupper(UCHAR c);
89
90 #endif