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
......@@ -22,14 +22,6 @@ typedef struct {
uint16_t compress_ptr[16];
} knot_rrinfo_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 {
knot_dname_t *_owner;
uint32_t _ttl;
......
......@@ -75,8 +75,8 @@ ${CDEFS} ${LIBKRES} types <<-EOF
knot_section_t
knot_rrinfo_t
knot_dname_t
knot_rdata_t
knot_rdataset_t
#knot_rdata_t
#knot_rdataset_t
EOF
genResType() {
......
......@@ -57,6 +57,40 @@ int inet_pton(int af, const char *src, void *dst);
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')
-- Error code representation
......
Markdown is supported
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