diff options
author | Oscar Najera <hi@oscarnajera.com> | 2025-06-06 12:39:53 +0200 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2025-06-06 12:39:53 +0200 |
commit | 4ac27a35cbce9a59f3135726d48fd2e353146632 (patch) | |
tree | 1b7c64d4397b202b2a1667d8e4e964d63a6c489e /geoip/ip.lisp | |
parent | 33fb0957d240e0c5fdac77a6d331b026e3e71e37 (diff) | |
download | scratch-4ac27a35cbce9a59f3135726d48fd2e353146632.tar.gz scratch-4ac27a35cbce9a59f3135726d48fd2e353146632.tar.bz2 scratch-4ac27a35cbce9a59f3135726d48fd2e353146632.zip |
read some more types
Diffstat (limited to 'geoip/ip.lisp')
-rw-r--r-- | geoip/ip.lisp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/geoip/ip.lisp b/geoip/ip.lisp index 95d2ae2..8db396d 100644 --- a/geoip/ip.lisp +++ b/geoip/ip.lisp @@ -142,6 +142,12 @@ (incf-pointer db-ptr size) r))) +(defun mread-int32 (db-ptr length) + (let ((uval (mread-unsigned db-ptr length))) + (if (and (= length 4) (logbitp 31 uval)) + (- uval #.(expt 2 32)) + uval))) + (5am:test reader (with-foreign-array (a #(0 0 1 23 126 195 159 195 156) '(:array :uint8 9)) (let ((r (make-db-reader :db-ptr a))) @@ -183,9 +189,13 @@ (destructuring-bind (type length) (mread-datafield-metadata db-ptr) (ecase type (2 (mread-uft8 db-ptr length)) + (4 (bytes-from-foreign db-ptr length)) ((5 6 9 10) (mread-unsigned db-ptr length)) (7 (mread-map db-ptr length)) - (11 (mread-list db-ptr length))))) + (8 (mread-int32 db-ptr length)) + (11 (mread-list db-ptr length)) + (14 (< 0 length)) ; bool + ))) (defvar *refdb* (cl-maxminddb:make-mmdb "GeoLite2-Country.mmdb")) |