@@ -3,97 +3,97 @@ extern "C" {
3
3
#endif
4
4
5
5
#ifndef MAXMINDDB_H
6
- #define MAXMINDDB_H
6
+ #define MAXMINDDB_H
7
7
8
- #include "maxminddb_config.h"
9
- #include <stdarg.h>
10
- #include <stdbool.h>
11
- #include <stdint.h>
12
- #include <stdio.h>
13
- #include <sys/types.h>
8
+ #include "maxminddb_config.h"
9
+ #include <stdarg.h>
10
+ #include <stdbool.h>
11
+ #include <stdint.h>
12
+ #include <stdio.h>
13
+ #include <sys/types.h>
14
14
15
- #ifdef __has_include
16
- #if __has_include (< endian .h > )
17
- #include <endian.h>
18
- #elif __has_include (< sys /endian .h > )
19
- #include <sys/endian.h>
20
- #endif
21
- #endif
15
+ #ifdef __has_include
16
+ #if __has_include (< endian .h > )
17
+ #include <endian.h>
18
+ #elif __has_include (< sys /endian .h > )
19
+ #include <sys/endian.h>
20
+ #endif
21
+ #endif
22
22
23
- #ifdef _WIN32
24
- #include <winsock2.h>
25
- #include <ws2tcpip.h>
26
- /* libmaxminddb package version from configure */
23
+ #ifdef _WIN32
24
+ #include <winsock2.h>
25
+ #include <ws2tcpip.h>
26
+ /* libmaxminddb package version from configure */
27
27
28
- #if defined(_MSC_VER )
29
- /* MSVC doesn't define signed size_t, copy it from configure */
30
- #define ssize_t SSIZE_T
28
+ #if defined(_MSC_VER )
29
+ /* MSVC doesn't define signed size_t, copy it from configure */
30
+ #define ssize_t SSIZE_T
31
31
32
- #endif
33
- #else
34
- #include <netdb.h>
35
- #include <netinet/in.h>
36
- #include <sys/socket.h>
37
- #endif
32
+ #endif
33
+ #else
34
+ #include <netdb.h>
35
+ #include <netinet/in.h>
36
+ #include <sys/socket.h>
37
+ #endif
38
38
39
- #if !defined(MMDB_LITTLE_ENDIAN )
40
- #if defined(__BYTE_ORDER__ ) && defined(__ORDER_LITTLE_ENDIAN__ )
41
- #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
42
- #define MMDB_LITTLE_ENDIAN 1
43
- #endif
44
- #elif defined(_WIN32 ) || defined(_WIN64 )
45
- // We assume modern Windows targets are little endian
46
- #define MMDB_LITTLE_ENDIAN 1
47
- #endif
48
- #endif
39
+ #if !defined(MMDB_LITTLE_ENDIAN )
40
+ #if defined(__BYTE_ORDER__ ) && defined(__ORDER_LITTLE_ENDIAN__ )
41
+ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
42
+ #define MMDB_LITTLE_ENDIAN 1
43
+ #endif
44
+ #elif defined(_WIN32 ) || defined(_WIN64 )
45
+ // We assume modern Windows targets are little endian
46
+ #define MMDB_LITTLE_ENDIAN 1
47
+ #endif
48
+ #endif
49
49
50
- #define MMDB_DATA_TYPE_EXTENDED (0)
51
- #define MMDB_DATA_TYPE_POINTER (1)
52
- #define MMDB_DATA_TYPE_UTF8_STRING (2)
53
- #define MMDB_DATA_TYPE_DOUBLE (3)
54
- #define MMDB_DATA_TYPE_BYTES (4)
55
- #define MMDB_DATA_TYPE_UINT16 (5)
56
- #define MMDB_DATA_TYPE_UINT32 (6)
57
- #define MMDB_DATA_TYPE_MAP (7)
58
- #define MMDB_DATA_TYPE_INT32 (8)
59
- #define MMDB_DATA_TYPE_UINT64 (9)
60
- #define MMDB_DATA_TYPE_UINT128 (10)
61
- #define MMDB_DATA_TYPE_ARRAY (11)
62
- #define MMDB_DATA_TYPE_CONTAINER (12)
63
- #define MMDB_DATA_TYPE_END_MARKER (13)
64
- #define MMDB_DATA_TYPE_BOOLEAN (14)
65
- #define MMDB_DATA_TYPE_FLOAT (15)
50
+ #define MMDB_DATA_TYPE_EXTENDED (0)
51
+ #define MMDB_DATA_TYPE_POINTER (1)
52
+ #define MMDB_DATA_TYPE_UTF8_STRING (2)
53
+ #define MMDB_DATA_TYPE_DOUBLE (3)
54
+ #define MMDB_DATA_TYPE_BYTES (4)
55
+ #define MMDB_DATA_TYPE_UINT16 (5)
56
+ #define MMDB_DATA_TYPE_UINT32 (6)
57
+ #define MMDB_DATA_TYPE_MAP (7)
58
+ #define MMDB_DATA_TYPE_INT32 (8)
59
+ #define MMDB_DATA_TYPE_UINT64 (9)
60
+ #define MMDB_DATA_TYPE_UINT128 (10)
61
+ #define MMDB_DATA_TYPE_ARRAY (11)
62
+ #define MMDB_DATA_TYPE_CONTAINER (12)
63
+ #define MMDB_DATA_TYPE_END_MARKER (13)
64
+ #define MMDB_DATA_TYPE_BOOLEAN (14)
65
+ #define MMDB_DATA_TYPE_FLOAT (15)
66
66
67
- #define MMDB_RECORD_TYPE_SEARCH_NODE (0)
68
- #define MMDB_RECORD_TYPE_EMPTY (1)
69
- #define MMDB_RECORD_TYPE_DATA (2)
70
- #define MMDB_RECORD_TYPE_INVALID (3)
67
+ #define MMDB_RECORD_TYPE_SEARCH_NODE (0)
68
+ #define MMDB_RECORD_TYPE_EMPTY (1)
69
+ #define MMDB_RECORD_TYPE_DATA (2)
70
+ #define MMDB_RECORD_TYPE_INVALID (3)
71
71
72
- /* flags for open */
73
- #define MMDB_MODE_MMAP (1)
74
- #define MMDB_MODE_MASK (7)
72
+ /* flags for open */
73
+ #define MMDB_MODE_MMAP (1)
74
+ #define MMDB_MODE_MASK (7)
75
75
76
- /* error codes */
77
- #define MMDB_SUCCESS (0)
78
- #define MMDB_FILE_OPEN_ERROR (1)
79
- #define MMDB_CORRUPT_SEARCH_TREE_ERROR (2)
80
- #define MMDB_INVALID_METADATA_ERROR (3)
81
- #define MMDB_IO_ERROR (4)
82
- #define MMDB_OUT_OF_MEMORY_ERROR (5)
83
- #define MMDB_UNKNOWN_DATABASE_FORMAT_ERROR (6)
84
- #define MMDB_INVALID_DATA_ERROR (7)
85
- #define MMDB_INVALID_LOOKUP_PATH_ERROR (8)
86
- #define MMDB_LOOKUP_PATH_DOES_NOT_MATCH_DATA_ERROR (9)
87
- #define MMDB_INVALID_NODE_NUMBER_ERROR (10)
88
- #define MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR (11)
76
+ /* error codes */
77
+ #define MMDB_SUCCESS (0)
78
+ #define MMDB_FILE_OPEN_ERROR (1)
79
+ #define MMDB_CORRUPT_SEARCH_TREE_ERROR (2)
80
+ #define MMDB_INVALID_METADATA_ERROR (3)
81
+ #define MMDB_IO_ERROR (4)
82
+ #define MMDB_OUT_OF_MEMORY_ERROR (5)
83
+ #define MMDB_UNKNOWN_DATABASE_FORMAT_ERROR (6)
84
+ #define MMDB_INVALID_DATA_ERROR (7)
85
+ #define MMDB_INVALID_LOOKUP_PATH_ERROR (8)
86
+ #define MMDB_LOOKUP_PATH_DOES_NOT_MATCH_DATA_ERROR (9)
87
+ #define MMDB_INVALID_NODE_NUMBER_ERROR (10)
88
+ #define MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR (11)
89
89
90
- #if !(MMDB_UINT128_IS_BYTE_ARRAY )
91
- #if MMDB_UINT128_USING_MODE
90
+ #if !(MMDB_UINT128_IS_BYTE_ARRAY )
91
+ #if MMDB_UINT128_USING_MODE
92
92
typedef unsigned int mmdb_uint128_t __attribute__((__mode__ (TI )));
93
- #else
93
+ #else
94
94
typedef unsigned __int128 mmdb_uint128_t ;
95
- #endif
96
- #endif
95
+ #endif
96
+ #endif
97
97
98
98
/* This is a pointer into the data section for a given IP address lookup */
99
99
typedef struct MMDB_entry_s {
@@ -118,11 +118,11 @@ typedef struct MMDB_entry_data_s {
118
118
uint32_t uint32 ;
119
119
int32_t int32 ;
120
120
uint64_t uint64 ;
121
- #if MMDB_UINT128_IS_BYTE_ARRAY
121
+ #if MMDB_UINT128_IS_BYTE_ARRAY
122
122
uint8_t uint128 [16 ];
123
- #else
123
+ #else
124
124
mmdb_uint128_t uint128 ;
125
- #endif
125
+ #endif
126
126
bool boolean ;
127
127
float float_value ;
128
128
};
0 commit comments