1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #ifndef CURL_DOES_CONVERSIONS
28 #define _U (1<<0) /* upper case */
30 #define _L (1<<1) /* lower case */
32 #define _N (1<<2) /* decimal numerical digit */
34 #define _S (1<<3) /* space */
36 #define _P (1<<4) /* punctuation */
38 #define _C (1<<5) /* control */
40 #define _X (1<<6) /* hexadecimal letter */
42 #define _B (1<<7) /* blank */
44 static const unsigned char ascii[128] = {
45 _C, _C, _C, _C, _C, _C, _C, _C,
46 _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
47 _C, _C, _C, _C, _C, _C, _C, _C,
48 _C, _C, _C, _C, _C, _C, _C, _C,
49 _S|_B, _P, _P, _P, _P, _P, _P, _P,
50 _P, _P, _P, _P, _P, _P, _P, _P,
51 _N, _N, _N, _N, _N, _N, _N, _N,
52 _N, _N, _P, _P, _P, _P, _P, _P,
53 _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
54 _U, _U, _U, _U, _U, _U, _U, _U,
55 _U, _U, _U, _U, _U, _U, _U, _U,
56 _U, _U, _U, _P, _P, _P, _P, _P,
57 _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
58 _L, _L, _L, _L, _L, _L, _L, _L,
59 _L, _L, _L, _L, _L, _L, _L, _L,
60 _L, _L, _L, _P, _P, _P, _P, _C
63 int Curl_isspace(int c)
65 if((c < 0) || (c >= 0x80))
67 return (ascii[c] & _S);
70 int Curl_isdigit(int c)
72 if((c < 0) || (c >= 0x80))
74 return (ascii[c] & _N);
77 int Curl_isalnum(int c)
79 if((c < 0) || (c >= 0x80))
81 return (ascii[c] & (_N|_U|_L));
84 int Curl_isxdigit(int c)
86 if((c < 0) || (c >= 0x80))
88 return (ascii[c] & (_N|_X));
91 int Curl_isgraph(int c)
93 if((c < 0) || (c >= 0x80) || (c == ' '))
95 return (ascii[c] & (_N|_X|_U|_L|_P|_S));
98 int Curl_isprint(int c)
100 if((c < 0) || (c >= 0x80))
102 return (ascii[c] & (_N|_X|_U|_L|_P|_S));
105 int Curl_isalpha(int c)
107 if((c < 0) || (c >= 0x80))
109 return (ascii[c] & (_U|_L));
112 int Curl_isupper(int c)
114 if((c < 0) || (c >= 0x80))
116 return (ascii[c] & (_U));
119 int Curl_islower(int c)
121 if((c < 0) || (c >= 0x80))
123 return (ascii[c] & (_L));
126 int Curl_iscntrl(int c)
128 if((c < 0) || (c >= 0x80))
130 return (ascii[c] & (_C));
133 #endif /* !CURL_DOES_CONVERSIONS */