Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_ascii.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Uniform Resource Identifier (URI) helpers
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 static const afw_octet_t
17 impl_hex_digits[16] =
18 { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
19 
20 static const afw_octet_t
21 impl_hex_lookup[] = {
22  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 16 */
23  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 32 */
24  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 48 */
25  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, /* 64 */
26  255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 80 */
27  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 96 */
28  255, 10, 11, 12, 13, 14, 15 };
29 
32 {
33  return (octet >= sizeof(impl_hex_lookup))
34  ? 255
35  : impl_hex_lookup[octet];
36 }
37 
40 {
41  return (octet >= 16)
42  ? 255
43  : impl_hex_digits[octet];
44 }
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
afw_ascii_encode_hex_digit(afw_octet_t octet)
Encode ascii hex digit.
Definition: afw_ascii.c:39
afw_ascii_decode_hex_digit(afw_octet_t octet)
Decode ascii hex digit.
Definition: afw_ascii.c:31
unsigned char afw_octet_t
8 bits (unsigned).
Definition: afw_common.h:211