hive_geoip2 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8db3b40343a6db6c1c0ffc20f8f31fd8a62d82e5
4
- data.tar.gz: 7627dbb58b18b2b34410993bebe29127f7ef36e6
3
+ metadata.gz: 4d4afa678b6f16d1b3930d2097190ffa062314b5
4
+ data.tar.gz: a28800070b21496a1ff4fcac98675de12f08f9c7
5
5
  SHA512:
6
- metadata.gz: 6ba971888c29661ff3fddf3d46d00f67d0d734c82af1ef3fb1967f3eaa0d4b1fb5ae34f47b4e83f79563ae5be1a35c15a730aa42ca019dd0ec11c0327a321f37
7
- data.tar.gz: 6c22963486413a1f7448d8a3483b8de9b4d97937b1cf1fd2556a0edc8defcf5eb33507db0e5660ad62d642336cb6449c9931ee1a930c35f638102be40f157107
6
+ metadata.gz: 7fb3f12ad482847d12f730b788a4670567d642c318bba406bd1c915576487ba999c51721fafa91a6ad7e05da3a02e21c76d3cc381a8e1b73b9d1fcf320e08da3
7
+ data.tar.gz: a617549a489b8e3895d61c75e46574d4efb80e365de2098c45999c8eea94ece737fad297bd6c35d3ed9924f49a3e05a7f10f2a76afaa1d31ec3cdbf26b1d9983
@@ -5,9 +5,6 @@
5
5
 
6
6
  #include "maxminddb.h"
7
7
 
8
- #define WORDS_64 (64 / CHAR_BIT / SIZEOF_LONG)
9
- #define WORDS_128 (128/ CHAR_BIT / SIZEOF_LONG)
10
-
11
8
  VALUE rb_mHive;
12
9
  VALUE rb_cGeoIP2;
13
10
 
@@ -160,7 +157,21 @@ parse_data_list(MMDB_entry_data_list_s *data_list, VALUE *ret_obj) {
160
157
 
161
158
  case MMDB_DATA_TYPE_UINT64:
162
159
  {
163
- *ret_obj = rb_big_unpack(&data_list->entry_data.uint64, WORDS_64);
160
+ const uint8_t *hex = "0123456789abcdef";
161
+ int i, idx = 0;
162
+
163
+ size_t size = sizeof(uint64_t);
164
+ char buf[size * 2 + 1];
165
+ uint8_t *data = &data_list->entry_data.uint64;
166
+
167
+ for (i = size - 1; i >= 0; i--) {
168
+ buf[idx++] = hex[data[i] >> 4];
169
+ buf[idx++] = hex[data[i] & 0x0f];
170
+ }
171
+
172
+ buf[idx] = '\0';
173
+
174
+ *ret_obj = rb_cstr2inum(buf, 16);
164
175
 
165
176
  data_list = data_list->next;
166
177
 
@@ -169,21 +180,30 @@ parse_data_list(MMDB_entry_data_list_s *data_list, VALUE *ret_obj) {
169
180
 
170
181
  case MMDB_DATA_TYPE_UINT128:
171
182
  {
183
+ const uint8_t *hex = "0123456789abcdef";
184
+ int i, idx = 0;
172
185
  #if MMDB_UINT128_IS_BYTE_ARRAY
173
- char buf[16];
174
- uint8_t i;
175
- uint8_t idx = 15;
186
+ size_t size = 16;
187
+ char buf[size * 2 + 1];
176
188
  uint8_t *data = data_list->entry_data.uint128;
177
189
 
178
- for (i = 0; i < 16; ++i) {
179
- buf[i] = data[idx];
180
- idx--;
190
+ for (i = 0; i < size; ++i) {
191
+ buf[idx++] = hex[data[i] >> 4];
192
+ buf[idx++] = hex[data[i] & 0x0f];
181
193
  }
182
-
183
- *ret_obj = rb_big_unpack(&buf, WORDS_128);
184
194
  #else
185
- *ret_obj = rb_big_unpack(&data_list->entry_data.uint128, WORDS_128);
195
+ size_t size = sizeof(mmdb_uint128_t);
196
+ uint8_t buf[size * 2 + 1];
197
+ uint8_t *data = &data_list->entry_data.uint128;
198
+
199
+ for (i = size - 1; i >= 0; i--) {
200
+ buf[idx++] = hex[data[i] >> 4];
201
+ buf[idx++] = hex[data[i] & 0x0f];
202
+ }
186
203
  #endif
204
+ buf[idx] = '\0';
205
+
206
+ *ret_obj = rb_cstr2inum(buf, 16);
187
207
 
188
208
  data_list = data_list->next;
189
209
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'hive_geoip2'
3
- s.version = '0.1.0'
3
+ s.version = '0.1.1'
4
4
  s.summary = 'libmaxminddb GeoIP2 Ruby bindings'
5
5
  s.author = 'Maxime Youdine'
6
6
  s.license = 'MIT'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hive_geoip2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Youdine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-22 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,10 +17,10 @@ extensions:
17
17
  - ext/hive_geoip2/extconf.rb
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ext/hive_geoip2/extconf.rb
21
- - ext/hive_geoip2/hive_geoip2.c
22
20
  - hive_geoip2.gemspec
23
21
  - lib/hive_geoip2/hive_geoip2.rb
22
+ - ext/hive_geoip2/extconf.rb
23
+ - ext/hive_geoip2/hive_geoip2.c
24
24
  homepage: https://github.com/desuwa/hive_geoip2
25
25
  licenses:
26
26
  - MIT
@@ -31,17 +31,17 @@ require_paths:
31
31
  - lib
32
32
  required_ruby_version: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ">="
34
+ - - '>='
35
35
  - !ruby/object:Gem::Version
36
36
  version: 1.9.2
37
37
  required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements: []
43
43
  rubyforge_project:
44
- rubygems_version: 2.4.1
44
+ rubygems_version: 2.0.14
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: libmaxminddb GeoIP2 Ruby bindings