Skip to content
Snippets Groups Projects
Verified Commit b42195a2 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Tomas Krizek
Browse files

lua bindings: compatibility with both libknot versions

parent 0b7c4502
1 merge request!864add compatibility with libknot 2.9
...@@ -22,14 +22,6 @@ typedef struct { ...@@ -22,14 +22,6 @@ typedef struct {
uint16_t compress_ptr[16]; uint16_t compress_ptr[16];
} knot_rrinfo_t; } knot_rrinfo_t;
typedef unsigned char knot_dname_t; typedef unsigned char knot_dname_t;
typedef struct {
uint16_t len;
uint8_t data[];
} knot_rdata_t;
typedef struct {
uint16_t count;
knot_rdata_t *rdata;
} knot_rdataset_t;
typedef struct { typedef struct {
knot_dname_t *_owner; knot_dname_t *_owner;
uint32_t _ttl; uint32_t _ttl;
......
...@@ -75,8 +75,8 @@ ${CDEFS} ${LIBKRES} types <<-EOF ...@@ -75,8 +75,8 @@ ${CDEFS} ${LIBKRES} types <<-EOF
knot_section_t knot_section_t
knot_rrinfo_t knot_rrinfo_t
knot_dname_t knot_dname_t
knot_rdata_t #knot_rdata_t
knot_rdataset_t #knot_rdataset_t
EOF EOF
genResType() { genResType() {
......
...@@ -57,6 +57,40 @@ int inet_pton(int af, const char *src, void *dst); ...@@ -57,6 +57,40 @@ int inet_pton(int af, const char *src, void *dst);
int gettimeofday(struct timeval *tv, struct timezone *tz); int gettimeofday(struct timeval *tv, struct timezone *tz);
]] ]]
-- TMP: compatibility with both libknot 2.8 and 2.9
local knot_rdataset_t_cdef
local sover_pos = string.find(libknot_SONAME, '%d')
if not sover_pos then
error('unexpected libknot soname: ' .. libknot_SONAME)
end
local sover = string.sub(libknot_SONAME, sover_pos , sover_pos)
if sover == '8' then
knot_rdataset_t_cdef = [[
typedef struct {
uint16_t count;
knot_rdata_t *rdata;
} knot_rdataset_t;
]]
elseif sover == '9' then
knot_rdataset_t_cdef = [[
typedef struct {
uint16_t count;
uint32_t size;
knot_rdata_t *rdata;
} knot_rdataset_t;
]]
else
error('unexpected libknot version: ' .. sover)
end
ffi.cdef([[
typedef struct {
uint16_t len;
uint8_t data[];
} knot_rdata_t;
]] .. knot_rdataset_t_cdef)
require('kres-gen') require('kres-gen')
-- Error code representation -- Error code representation
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment