geoip2_c 0.3.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +23 -0
  3. data/.github/workflows/ubuntu.yml +17 -8
  4. data/.github/workflows/windows.yml +18 -8
  5. data/.gitmodules +0 -3
  6. data/ext/geoip2/extconf.rb +9 -25
  7. data/ext/geoip2/geoip2.c +82 -32
  8. data/geoip2_c.gemspec +1 -0
  9. data/lib/geoip2/version.rb +1 -1
  10. metadata +18 -182
  11. data/ext/geoip2/libmaxminddb/.gitignore +0 -38
  12. data/ext/geoip2/libmaxminddb/.gitmodules +0 -9
  13. data/ext/geoip2/libmaxminddb/.perltidyrc +0 -11
  14. data/ext/geoip2/libmaxminddb/.travis.yml +0 -70
  15. data/ext/geoip2/libmaxminddb/.uncrustify.cfg +0 -78
  16. data/ext/geoip2/libmaxminddb/AUTHORS +0 -0
  17. data/ext/geoip2/libmaxminddb/Changes.md +0 -277
  18. data/ext/geoip2/libmaxminddb/LICENSE +0 -202
  19. data/ext/geoip2/libmaxminddb/Makefile.am +0 -41
  20. data/ext/geoip2/libmaxminddb/NOTICE +0 -13
  21. data/ext/geoip2/libmaxminddb/README.dev.md +0 -69
  22. data/ext/geoip2/libmaxminddb/README.md +0 -122
  23. data/ext/geoip2/libmaxminddb/appveyor.yml +0 -33
  24. data/ext/geoip2/libmaxminddb/bin/Makefile.am +0 -10
  25. data/ext/geoip2/libmaxminddb/bin/mmdblookup.c +0 -715
  26. data/ext/geoip2/libmaxminddb/bootstrap +0 -21
  27. data/ext/geoip2/libmaxminddb/common.mk +0 -7
  28. data/ext/geoip2/libmaxminddb/configure.ac +0 -132
  29. data/ext/geoip2/libmaxminddb/dev-bin/make-man-pages.pl +0 -76
  30. data/ext/geoip2/libmaxminddb/dev-bin/ppa-release.sh +0 -53
  31. data/ext/geoip2/libmaxminddb/dev-bin/regen-prototypes.pl +0 -136
  32. data/ext/geoip2/libmaxminddb/dev-bin/regen-win32-test-projs.pl +0 -54
  33. data/ext/geoip2/libmaxminddb/dev-bin/release.sh +0 -113
  34. data/ext/geoip2/libmaxminddb/dev-bin/uncrustify-all.sh +0 -21
  35. data/ext/geoip2/libmaxminddb/dev-bin/valgrind-all.pl +0 -53
  36. data/ext/geoip2/libmaxminddb/doc/libmaxminddb.md +0 -889
  37. data/ext/geoip2/libmaxminddb/doc/mmdblookup.md +0 -103
  38. data/ext/geoip2/libmaxminddb/include/maxminddb.h +0 -241
  39. data/ext/geoip2/libmaxminddb/include/maxminddb_config.h.in +0 -14
  40. data/ext/geoip2/libmaxminddb/projects/VS12/README.md +0 -59
  41. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-release.props +0 -32
  42. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-x64.props +0 -14
  43. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.props +0 -32
  44. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.sln +0 -150
  45. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj +0 -143
  46. data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj.filters +0 -32
  47. data/ext/geoip2/libmaxminddb/projects/VS12/maxminddb_config.h +0 -14
  48. data/ext/geoip2/libmaxminddb/projects/VS12-tests/bad_pointers.vcxproj +0 -105
  49. data/ext/geoip2/libmaxminddb/projects/VS12-tests/basic_lookup.vcxproj +0 -105
  50. data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_entry_list.vcxproj +0 -105
  51. data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_types.vcxproj +0 -105
  52. data/ext/geoip2/libmaxminddb/projects/VS12-tests/dump.vcxproj +0 -105
  53. data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value.vcxproj +0 -105
  54. data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value_pointer_bug.vcxproj +0 -105
  55. data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv4_start_cache.vcxproj +0 -105
  56. data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv6_lookup_in_ipv4.vcxproj +0 -105
  57. data/ext/geoip2/libmaxminddb/projects/VS12-tests/libtap.vcxproj +0 -85
  58. data/ext/geoip2/libmaxminddb/projects/VS12-tests/maxminddb_test_helper.vcxproj +0 -107
  59. data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata.vcxproj +0 -105
  60. data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata_pointers.vcxproj +0 -105
  61. data/ext/geoip2/libmaxminddb/projects/VS12-tests/no_map_get_value.vcxproj +0 -105
  62. data/ext/geoip2/libmaxminddb/projects/VS12-tests/read_node.vcxproj +0 -105
  63. data/ext/geoip2/libmaxminddb/projects/VS12-tests/shared.vcxproj +0 -104
  64. data/ext/geoip2/libmaxminddb/projects/VS12-tests/threads.vcxproj +0 -103
  65. data/ext/geoip2/libmaxminddb/projects/VS12-tests/version.vcxproj +0 -105
  66. data/ext/geoip2/libmaxminddb/projects/test.vcxproj.template +0 -105
  67. data/ext/geoip2/libmaxminddb/src/Makefile.am +0 -25
  68. data/ext/geoip2/libmaxminddb/src/data-pool.c +0 -180
  69. data/ext/geoip2/libmaxminddb/src/data-pool.h +0 -52
  70. data/ext/geoip2/libmaxminddb/src/libmaxminddb.pc.in +0 -11
  71. data/ext/geoip2/libmaxminddb/src/maxminddb-compat-util.h +0 -167
  72. data/ext/geoip2/libmaxminddb/src/maxminddb.c +0 -2181
  73. data/ext/geoip2/libmaxminddb/t/Makefile.am +0 -27
  74. data/ext/geoip2/libmaxminddb/t/bad_databases_t.c +0 -67
  75. data/ext/geoip2/libmaxminddb/t/bad_pointers_t.c +0 -53
  76. data/ext/geoip2/libmaxminddb/t/basic_lookup_t.c +0 -207
  77. data/ext/geoip2/libmaxminddb/t/compile_c++_t.pl +0 -107
  78. data/ext/geoip2/libmaxminddb/t/data-pool-t.c +0 -374
  79. data/ext/geoip2/libmaxminddb/t/data_entry_list_t.c +0 -353
  80. data/ext/geoip2/libmaxminddb/t/data_types_t.c +0 -439
  81. data/ext/geoip2/libmaxminddb/t/dump_t.c +0 -103
  82. data/ext/geoip2/libmaxminddb/t/external_symbols_t.pl +0 -106
  83. data/ext/geoip2/libmaxminddb/t/get_value_pointer_bug_t.c +0 -66
  84. data/ext/geoip2/libmaxminddb/t/get_value_t.c +0 -249
  85. data/ext/geoip2/libmaxminddb/t/ipv4_start_cache_t.c +0 -36
  86. data/ext/geoip2/libmaxminddb/t/ipv6_lookup_in_ipv4_t.c +0 -48
  87. data/ext/geoip2/libmaxminddb/t/libtap/.gitignore +0 -13
  88. data/ext/geoip2/libmaxminddb/t/libtap/.travis.yml +0 -13
  89. data/ext/geoip2/libmaxminddb/t/libtap/COPYING +0 -165
  90. data/ext/geoip2/libmaxminddb/t/libtap/INSTALL +0 -41
  91. data/ext/geoip2/libmaxminddb/t/libtap/Makefile +0 -72
  92. data/ext/geoip2/libmaxminddb/t/libtap/Makefile.win +0 -37
  93. data/ext/geoip2/libmaxminddb/t/libtap/README.md +0 -268
  94. data/ext/geoip2/libmaxminddb/t/libtap/t/cmp_mem.c +0 -20
  95. data/ext/geoip2/libmaxminddb/t/libtap/t/cmp_mem.expected +0 -28
  96. data/ext/geoip2/libmaxminddb/t/libtap/t/cmpok.c +0 -16
  97. data/ext/geoip2/libmaxminddb/t/libtap/t/cmpok.expected +0 -37
  98. data/ext/geoip2/libmaxminddb/t/libtap/t/diag.c +0 -10
  99. data/ext/geoip2/libmaxminddb/t/libtap/t/diag.expected +0 -2
  100. data/ext/geoip2/libmaxminddb/t/libtap/t/diesok.c +0 -14
  101. data/ext/geoip2/libmaxminddb/t/libtap/t/diesok.expected +0 -6
  102. data/ext/geoip2/libmaxminddb/t/libtap/t/is.c +0 -24
  103. data/ext/geoip2/libmaxminddb/t/libtap/t/is.expected +0 -58
  104. data/ext/geoip2/libmaxminddb/t/libtap/t/like.c +0 -10
  105. data/ext/geoip2/libmaxminddb/t/libtap/t/like.expected +0 -4
  106. data/ext/geoip2/libmaxminddb/t/libtap/t/simple.c +0 -31
  107. data/ext/geoip2/libmaxminddb/t/libtap/t/simple.expected +0 -32
  108. data/ext/geoip2/libmaxminddb/t/libtap/t/skip.c +0 -23
  109. data/ext/geoip2/libmaxminddb/t/libtap/t/skip.expected +0 -9
  110. data/ext/geoip2/libmaxminddb/t/libtap/t/synopsis.c +0 -13
  111. data/ext/geoip2/libmaxminddb/t/libtap/t/synopsis.expected +0 -9
  112. data/ext/geoip2/libmaxminddb/t/libtap/t/test.c +0 -28
  113. data/ext/geoip2/libmaxminddb/t/libtap/t/todo.c +0 -17
  114. data/ext/geoip2/libmaxminddb/t/libtap/t/todo.expected +0 -11
  115. data/ext/geoip2/libmaxminddb/t/libtap/tap.c +0 -354
  116. data/ext/geoip2/libmaxminddb/t/libtap/tap.h +0 -115
  117. data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitattributes +0 -1
  118. data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitconfig +0 -2
  119. data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitignore +0 -2
  120. data/ext/geoip2/libmaxminddb/t/maxmind-db/.perltidyallrc +0 -11
  121. data/ext/geoip2/libmaxminddb/t/maxmind-db/.tidyallrc +0 -7
  122. data/ext/geoip2/libmaxminddb/t/maxmind-db/LICENSE +0 -4
  123. data/ext/geoip2/libmaxminddb/t/maxmind-db/MaxMind-DB-spec.md +0 -558
  124. data/ext/geoip2/libmaxminddb/t/maxmind-db/README.md +0 -4
  125. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/README.md +0 -7
  126. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/libmaxminddb/libmaxminddb-offset-integer-overflow.mmdb +0 -0
  127. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/cyclic-data-structure.mmdb +0 -0
  128. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-bytes-length.mmdb +0 -1
  129. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-data-record-offset.mmdb +0 -0
  130. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-map-key-length.mmdb +0 -0
  131. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-string-length.mmdb +0 -1
  132. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/metadata-is-an-uint128.mmdb +0 -1
  133. data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/unexpected-bytes.mmdb +0 -0
  134. data/ext/geoip2/libmaxminddb/t/maxmind-db/perltidyrc +0 -12
  135. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Anonymous-IP-Test.json +0 -32
  136. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-City-Test.json +0 -12616
  137. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Connection-Type-Test.json +0 -102
  138. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Country-Test.json +0 -10975
  139. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-DensityIncome-Test.json +0 -14
  140. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Domain-Test.json +0 -452
  141. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Enterprise-Test.json +0 -666
  142. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-ISP-Test.json +0 -12585
  143. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Precision-Enterprise-Test.json +0 -1035
  144. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoLite2-ASN-Test.json +0 -37
  145. data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/README +0 -13
  146. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Anonymous-IP-Test.mmdb +0 -0
  147. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb +0 -0
  148. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb +0 -0
  149. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test.mmdb +0 -0
  150. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Connection-Type-Test.mmdb +0 -0
  151. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Country-Test.mmdb +0 -0
  152. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-DensityIncome-Test.mmdb +0 -0
  153. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Domain-Test.mmdb +0 -0
  154. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Enterprise-Test.mmdb +0 -0
  155. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-ISP-Test.mmdb +0 -0
  156. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Precision-Enterprise-Test.mmdb +0 -0
  157. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoLite2-ASN-Test.mmdb +0 -0
  158. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb +0 -0
  159. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-string-value-entries.mmdb +0 -0
  160. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-broken-pointers-24.mmdb +0 -0
  161. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb +0 -0
  162. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-decoder.mmdb +0 -0
  163. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-24.mmdb +0 -0
  164. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-28.mmdb +0 -0
  165. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-32.mmdb +0 -0
  166. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-24.mmdb +0 -0
  167. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-28.mmdb +0 -0
  168. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-32.mmdb +0 -0
  169. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-metadata-pointers.mmdb +0 -0
  170. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-24.mmdb +0 -0
  171. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-28.mmdb +0 -0
  172. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-32.mmdb +0 -0
  173. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-nested.mmdb +0 -0
  174. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/README.md +0 -26
  175. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/maps-with-pointers.raw +0 -0
  176. data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/write-test-data.pl +0 -614
  177. data/ext/geoip2/libmaxminddb/t/maxmind-db/tidyall.ini +0 -5
  178. data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.c +0 -255
  179. data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.h +0 -69
  180. data/ext/geoip2/libmaxminddb/t/metadata_pointers_t.c +0 -32
  181. data/ext/geoip2/libmaxminddb/t/metadata_t.c +0 -226
  182. data/ext/geoip2/libmaxminddb/t/mmdblookup_t.pl +0 -158
  183. data/ext/geoip2/libmaxminddb/t/no_map_get_value_t.c +0 -32
  184. data/ext/geoip2/libmaxminddb/t/read_node_t.c +0 -157
  185. data/ext/geoip2/libmaxminddb/t/threads_t.c +0 -196
  186. data/ext/geoip2/libmaxminddb/t/version_t.c +0 -10
@@ -1,66 +0,0 @@
1
- #include "maxminddb_test_helper.h"
2
-
3
- /* This test exercises a bug found in MMDB_get_value for certain types of
4
- * nested data structures which contain pointers. See
5
- * https://github.com/maxmind/libmaxminddb/issues/2 and
6
- * https://github.com/maxmind/libmaxminddb/issues/3.
7
- *
8
- * There is also the potential for a similar bug when looking up a value by
9
- * path in an array. This is not tested (yet) as we don't have the right test
10
- * data for it.
11
- *
12
- * These tests are somewhat fragile since they depend on a specific data
13
- * layout in the database. Ideally the test would check that this layout
14
- * exists before checking to see if the lookups are correct.
15
- */
16
-
17
- void test_one_ip(MMDB_s *mmdb, const char *filename, const char *mode_desc,
18
- char *ip, char *country_code)
19
- {
20
- MMDB_lookup_result_s result =
21
- lookup_string_ok(mmdb, ip, filename, mode_desc);
22
-
23
- MMDB_entry_data_s entry_data =
24
- data_ok(&result, MMDB_DATA_TYPE_UTF8_STRING, "country{iso_code}",
25
- "country", "iso_code", NULL);
26
-
27
- if (ok(entry_data.has_data, "found data for country{iso_code}")) {
28
- char *string = strndup(entry_data.utf8_string, entry_data.data_size);
29
- if (!string) {
30
- ok(0, "strndup() call failed");
31
- exit(1);
32
- }
33
- if (!ok(strcmp(string,
34
- country_code) == 0, "iso_code is %s", country_code)) {
35
- diag(" value is %s", string);
36
- }
37
- free(string);
38
- }
39
- }
40
-
41
- void run_tests(int mode, const char *mode_desc)
42
- {
43
- const char *filename = "GeoIP2-City-Test.mmdb";
44
- const char *path = test_database_path(filename);
45
- MMDB_s *mmdb = open_ok(path, mode, mode_desc);
46
- free((void *)path);
47
-
48
- /* This exercises a bug where the entire top-level value is a pointer to
49
- * another part of the data section. */
50
- test_one_ip(mmdb, filename, mode_desc, "2001:218::", "JP");
51
- /* This exercises a bug where one subnet's data shares part of the data
52
- * with another subnet - in this case it is the "country" key (and others)
53
- * in the top level map. We are testing that the "country" key's value is
54
- * handled correctly. The value _should_ be a pointer to another map. */
55
- test_one_ip(mmdb, filename, mode_desc, "81.2.69.160", "GB");
56
-
57
- MMDB_close(mmdb);
58
- free(mmdb);
59
- }
60
-
61
- int main(void)
62
- {
63
- plan(NO_PLAN);
64
- for_all_modes(&run_tests);
65
- done_testing();
66
- }
@@ -1,249 +0,0 @@
1
- #include "maxminddb_test_helper.h"
2
-
3
- void test_array_0_result(int status, MMDB_entry_data_s entry_data,
4
- char *function)
5
- {
6
- cmp_ok(status, "==", MMDB_SUCCESS,
7
- "status for %s() is MMDB_SUCCESS - array[0]", function);
8
- ok(entry_data.has_data, "found a value for array[0]");
9
- cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
10
- "returned entry type is uint32 - array[0]");
11
- cmp_ok(entry_data.uint32, "==", 1, "entry value is 1 - array[0]");
12
- }
13
-
14
- void test_array_2_result(int status, MMDB_entry_data_s entry_data,
15
- char *function)
16
- {
17
- cmp_ok(status, "==", MMDB_SUCCESS,
18
- "status for %s() is MMDB_SUCCESS - array[2]", function);
19
- ok(entry_data.has_data, "found a value for array[2]");
20
- cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
21
- "returned entry type is uint32 - array[2]");
22
- cmp_ok(entry_data.uint32, "==", 3, "entry value is 3 - array[2]");
23
- }
24
-
25
- int call_vget_value(MMDB_entry_s *entry, MMDB_entry_data_s *entry_data, ...)
26
- {
27
- va_list keys;
28
- va_start(keys, entry_data);
29
-
30
- int status = MMDB_vget_value(entry, entry_data, keys);
31
-
32
- va_end(keys);
33
-
34
- return status;
35
- }
36
-
37
- void test_simple_structure(int mode, const char *mode_desc)
38
- {
39
- const char *filename = "MaxMind-DB-test-decoder.mmdb";
40
- const char *path = test_database_path(filename);
41
- MMDB_s *mmdb = open_ok(path, mode, mode_desc);
42
- free((void *)path);
43
-
44
- const char *ip = "1.1.1.1";
45
- MMDB_lookup_result_s result =
46
- lookup_string_ok(mmdb, ip, filename, mode_desc);
47
-
48
- {
49
- MMDB_entry_data_s entry_data;
50
- const char *lookup_path[] = { "array", "0", NULL };
51
- int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
52
- test_array_0_result(status, entry_data, "MMDB_aget_value");
53
-
54
- status = MMDB_get_value(&result.entry, &entry_data, "array", "0", NULL);
55
- test_array_0_result(status, entry_data, "MMDB_get_value");
56
-
57
- status =
58
- call_vget_value(&result.entry, &entry_data, "array", "0", NULL);
59
- test_array_0_result(status, entry_data, "MMDB_vget_value");
60
- }
61
-
62
- {
63
- MMDB_entry_data_s entry_data;
64
- const char *lookup_path[] = { "array", "2", NULL };
65
- int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
66
- test_array_2_result(status, entry_data, "MMDB_aget_value");
67
-
68
- status = MMDB_get_value(&result.entry, &entry_data, "array", "2", NULL);
69
- test_array_2_result(status, entry_data, "MMDB_get_value");
70
-
71
- status =
72
- call_vget_value(&result.entry, &entry_data, "array", "2", NULL);
73
- test_array_2_result(status, entry_data, "MMDB_vget_value");
74
- }
75
-
76
-
77
- {
78
- MMDB_entry_data_s entry_data;
79
- int status = MMDB_get_value(&result.entry, &entry_data, "array", "zero",
80
- NULL);
81
- cmp_ok(status, "==", MMDB_LOOKUP_PATH_DOES_NOT_MATCH_DATA_ERROR,
82
- "MMDB_get_value() returns error on non-integer array index");
83
- }
84
-
85
- {
86
- MMDB_entry_data_s entry_data;
87
- int status = MMDB_get_value(&result.entry, &entry_data, "array", "-1",
88
- NULL);
89
- cmp_ok(status, "==", MMDB_INVALID_LOOKUP_PATH_ERROR,
90
- "MMDB_get_value() returns error on negative integer");
91
- }
92
-
93
- {
94
- MMDB_entry_data_s entry_data;
95
- int status =
96
- MMDB_get_value(&result.entry, &entry_data, "array",
97
- "18446744073709551616",
98
- NULL);
99
- cmp_ok(status, "==", MMDB_INVALID_LOOKUP_PATH_ERROR,
100
- "MMDB_get_value() returns error on integer larger than LONG_MAX");
101
- }
102
-
103
- MMDB_close(mmdb);
104
- free(mmdb);
105
- }
106
-
107
- void test_complex_map_a_result(int status, MMDB_entry_data_s entry_data,
108
- char *function)
109
- {
110
- cmp_ok(status, "==", MMDB_SUCCESS,
111
- "status for %s() is MMDB_SUCCESS - map1{map2}{array}[0]{map3}{a}",
112
- function);
113
- ok(entry_data.has_data,
114
- "found a value for map1{map2}{array}[0]{map3}{a}");
115
- cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
116
- "returned entry type is uint32 - map1{map2}{array}[0]{map3}{a}");
117
- cmp_ok(entry_data.uint32, "==", 1,
118
- "entry value is 1 - map1{map2}{array}[0]{map3}{a}");
119
- }
120
-
121
- void test_complex_map_c_result(int status, MMDB_entry_data_s entry_data,
122
- char *function)
123
- {
124
- cmp_ok(
125
- status, "==", MMDB_SUCCESS,
126
- "status for %s() is MMDB_SUCCESS - map1{map2}{array}[0]{map3}{c}",
127
- function);
128
- ok(entry_data.has_data,
129
- "found a value for map1{map2}{array}[0]{map3}{c}");
130
- cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
131
- "returned entry type is uint32 - map1{map2}{array}[0]{map3}{c}");
132
- cmp_ok(entry_data.uint32, "==", 3,
133
- "entry value is 3 - map1{map2}{array}[0]{map3}{c}");
134
- }
135
-
136
- void test_no_result(int status, MMDB_entry_data_s entry_data, char *function,
137
- char *path_description)
138
- {
139
- cmp_ok(status, "==", MMDB_LOOKUP_PATH_DOES_NOT_MATCH_DATA_ERROR,
140
- "status for %s() is MMDB_LOOKUP_PATH_DOES_NOT_MATCH_DATA_ERROR - %s",
141
- function, path_description);
142
- ok(!entry_data.has_data, "did not find a value for %s", path_description);
143
- }
144
-
145
- void test_nested_structure(int mode, const char *mode_desc)
146
- {
147
- const char *filename = "MaxMind-DB-test-nested.mmdb";
148
- const char *path = test_database_path(filename);
149
- MMDB_s *mmdb = open_ok(path, mode, mode_desc);
150
- free((void *)path);
151
-
152
- const char *ip = "1.1.1.1";
153
- MMDB_lookup_result_s result =
154
- lookup_string_ok(mmdb, ip, filename, mode_desc);
155
-
156
- {
157
- MMDB_entry_data_s entry_data;
158
- const char *lookup_path[] =
159
- { "map1", "map2", "array", "0", "map3", "a", NULL };
160
- int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
161
- test_complex_map_a_result(status, entry_data, "MMDB_aget_value");
162
-
163
- status = MMDB_get_value(&result.entry, &entry_data,
164
- "map1", "map2", "array", "0", "map3", "a",
165
- NULL);
166
- test_complex_map_a_result(status, entry_data, "MMDB_get_value");
167
-
168
- status = call_vget_value(&result.entry, &entry_data,
169
- "map1", "map2", "array", "0", "map3", "a",
170
- NULL);
171
- test_complex_map_a_result(status, entry_data, "MMDB_vget_value");
172
- }
173
-
174
- {
175
- MMDB_entry_data_s entry_data;
176
- const char *lookup_path[] =
177
- { "map1", "map2", "array", "0", "map3", "c", NULL };
178
- int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
179
- test_complex_map_c_result(status, entry_data, "MMDB_aget_value");
180
-
181
- status = MMDB_get_value(&result.entry, &entry_data,
182
- "map1", "map2", "array", "0", "map3", "c",
183
- NULL);
184
- test_complex_map_c_result(status, entry_data, "MMDB_get_value");
185
-
186
- status = call_vget_value(&result.entry, &entry_data,
187
- "map1", "map2", "array", "0", "map3", "c",
188
- NULL);
189
- test_complex_map_c_result(status, entry_data, "MMDB_vget_value");
190
- }
191
-
192
- {
193
- MMDB_entry_data_s entry_data;
194
- const char *lookup_path[] =
195
- { "map1", "map42", "array", "0", "map3", "c", NULL };
196
- int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
197
- test_no_result(status, entry_data, "MMDB_aget_value",
198
- "map1{map42}{array}[0]{map3}{c}");
199
-
200
- status = MMDB_get_value(&result.entry, &entry_data,
201
- "map1", "map42", "array", "0", "map3", "c",
202
- NULL);
203
- test_no_result(status, entry_data, "MMDB_get_value",
204
- "map1{map42}{array}[0]{map3}{c}");
205
-
206
- status = call_vget_value(&result.entry, &entry_data,
207
- "map1", "map42", "array", "0", "map3", "c",
208
- NULL);
209
- test_no_result(status, entry_data, "MMDB_vget_value",
210
- "map1{map42}{array}[0]{map3}{c}");
211
- }
212
-
213
- {
214
- MMDB_entry_data_s entry_data;
215
- const char *lookup_path[] =
216
- { "map1", "map2", "array", "9", "map3", "c", NULL };
217
- int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);
218
- test_no_result(status, entry_data, "MMDB_aget_value",
219
- "map1{map42}{array}[9]{map3}{c}");
220
-
221
- status = MMDB_get_value(&result.entry, &entry_data,
222
- "map1", "map2", "array", "9", "map3", "c",
223
- NULL);
224
- test_no_result(status, entry_data, "MMDB_get_value",
225
- "map1{map42}{array}[9]{map3}{c}");
226
-
227
- status = call_vget_value(&result.entry, &entry_data,
228
- "map1", "map2", "array", "9", "map3", "c",
229
- NULL);
230
- test_no_result(status, entry_data, "MMDB_vget_value",
231
- "map1{map42}{array}[9]{map3}{c}");
232
- }
233
-
234
- MMDB_close(mmdb);
235
- free(mmdb);
236
- }
237
-
238
- void run_tests(int mode, const char *mode_desc)
239
- {
240
- test_simple_structure(mode, mode_desc);
241
- test_nested_structure(mode, mode_desc);
242
- }
243
-
244
- int main(void)
245
- {
246
- plan(NO_PLAN);
247
- for_all_modes(&run_tests);
248
- done_testing();
249
- }
@@ -1,36 +0,0 @@
1
- #include "maxminddb_test_helper.h"
2
-
3
- void test_one_ip(MMDB_s *mmdb, const char *ip, const char *filename,
4
- const char *mode_desc)
5
- {
6
- MMDB_lookup_result_s result =
7
- lookup_string_ok(mmdb, ip, filename, mode_desc);
8
-
9
- ok(
10
- result.found_entry,
11
- "got a result for an IPv4 address included in a larger-than-IPv4 subnet - %s - %s",
12
- ip, mode_desc);
13
-
14
- data_ok(&result, MMDB_DATA_TYPE_UTF8_STRING, "string value for IP", NULL);
15
- }
16
-
17
- void run_tests(int mode, const char *mode_desc)
18
- {
19
- const char *filename = "MaxMind-DB-no-ipv4-search-tree.mmdb";
20
- const char *path = test_database_path(filename);
21
- MMDB_s *mmdb = open_ok(path, mode, mode_desc);
22
- free((void *)path);
23
-
24
- test_one_ip(mmdb, "1.1.1.1", filename, mode_desc);
25
- test_one_ip(mmdb, "255.255.255.255", filename, mode_desc);
26
-
27
- MMDB_close(mmdb);
28
- free(mmdb);
29
- }
30
-
31
- int main(void)
32
- {
33
- plan(NO_PLAN);
34
- for_all_modes(&run_tests);
35
- done_testing();
36
- }
@@ -1,48 +0,0 @@
1
- #include "maxminddb_test_helper.h"
2
-
3
- void run_tests(int mode, const char *mode_desc)
4
- {
5
- const char *filename = "MaxMind-DB-test-ipv4-28.mmdb";
6
- const char *path = test_database_path(filename);
7
- MMDB_s *mmdb = open_ok(path, mode, mode_desc);
8
- free((void *)path);
9
-
10
- const char *ip = "::abcd";
11
- int gai_error, mmdb_error;
12
- MMDB_lookup_result_s UNUSED(result) =
13
- MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
14
-
15
- cmp_ok(
16
- mmdb_error, "==", MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR,
17
- "MMDB_lookup_string sets mmdb_error to MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR when we try to look up an IPv6 address in an IPv4-only database");
18
-
19
- struct addrinfo hints = {
20
- .ai_family = AF_INET6,
21
- .ai_flags = AI_NUMERICHOST
22
- };
23
-
24
- struct addrinfo *addresses;
25
- gai_error = getaddrinfo("2001:db8:85a3:0:0:8a2e:370:7334", NULL,
26
- &hints, &addresses);
27
- if (gai_error) {
28
- BAIL_OUT("getaddrinfo failed: %s", gai_strerror(gai_error));
29
- }
30
-
31
- mmdb_error = 0;
32
- MMDB_lookup_sockaddr(mmdb, addresses->ai_addr, &mmdb_error);
33
-
34
- cmp_ok(
35
- mmdb_error, "==", MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR,
36
- "MMDB_lookup_sockaddr sets mmdb_error to MMDB_IPV6_LOOKUP_IN_IPV4_DATABASE_ERROR when we try to look up an IPv6 address in an IPv4-only database");
37
-
38
- freeaddrinfo(addresses);
39
- MMDB_close(mmdb);
40
- free(mmdb);
41
- }
42
-
43
- int main(void)
44
- {
45
- plan(NO_PLAN);
46
- for_all_modes(&run_tests);
47
- done_testing();
48
- }
@@ -1,13 +0,0 @@
1
- /t/*
2
- !/t/*.*
3
- /t/*.exe
4
- /t/*.got
5
- *.a
6
- *.lo
7
- *.o
8
- *.so
9
- *.pc
10
- usr/
11
- *.sw?
12
- /.deps
13
- /.dirstamp
@@ -1,13 +0,0 @@
1
- language: c
2
-
3
- compiler:
4
- - gcc
5
- - clang
6
-
7
- before_install: sudo apt-get install -y libtest-differences-perl
8
-
9
- install: make CC=$CC install
10
-
11
- script: make CC=$CC test
12
-
13
- after_script: make uninstall
@@ -1,165 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
@@ -1,41 +0,0 @@
1
- To install libtap on a Unix-like system:
2
-
3
- $ make
4
- $ make check
5
- $ make install
6
-
7
- To compile with gcc -ansi, run:
8
-
9
- $ ANSI=1 make
10
-
11
- To install to a different directory than /usr/local, supply the
12
- PREFIX variable to make:
13
-
14
- $ PREFIX=/usr make install
15
-
16
- On Windows, the library can be created by first setting up the
17
- correct development environment variables. Usually this is done by
18
- running vcvars32.bat included in the Visual Studio distribution.
19
- You should also install gnu make which can be found at
20
- http://gnuwin32.sourceforge.net/packages/make.htm. Once this is
21
- done, you should be able to run the following:
22
-
23
- > make -f Makefile.win
24
-
25
- If you want to use it directly in another project, you can copy tap.c
26
- and tap.h there and it shouldn't have a problem compiling.
27
-
28
- $ ls
29
- tap.c tap.h test.c
30
- $ cat test.c
31
- #include "tap.h"
32
- int main () {
33
- plan(1);
34
- ok(50 + 5, "foo %s", "bar");
35
- done_testing();
36
- }
37
- $ gcc test.c tap.c
38
- $ a.out
39
- 1..1
40
- ok 1 - foo bar
41
-