]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lua bindings: compatibility with both libknot versions
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 6 Sep 2019 10:10:12 +0000 (12:10 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Fri, 20 Sep 2019 08:14:06 +0000 (10:14 +0200)
daemon/lua/kres-gen.lua
daemon/lua/kres-gen.sh
daemon/lua/kres.lua

index 07647cc84f8c9646836ea3f0903e8182b0f1240f..ed48d753e5563322650a83ef7578c5859cd140fb 100644 (file)
@@ -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;
index c28d346f2453d0f49e17f609e9dd995b124dee78..fd16e492ce5f2504870b4ed3ea85525ab4278fc5 100755 (executable)
@@ -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() {
index 2fc21503fcff24fa5935cfb3ba6e898fbd434b51..5198c2fcd0791ce5b9cacbf2cca1b06493c967ee 100644 (file)
@@ -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