]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
splint fails; parseerror
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 23 Aug 2005 19:40:59 +0000 (19:40 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 23 Aug 2005 19:40:59 +0000 (19:40 +0000)
lua/lua-rns.c
lua/rns-lib.lua
lua/rns.lua

index cd058b191d428dcb0e016d84e06c61204f8daa6d..c47e996531302a6103b93ca4db1db62dc3720cec 100644 (file)
@@ -64,7 +64,7 @@ version(FILE *f, char *progname)
  */
 l_rdf_new_frm_str(lua_State *L)
 {
-       uint16_t t = lua_tonumber(L, 1);
+       uint16_t t = (uint16_t)lua_tonumber(L, 1);
        char *str = strdup((char*)luaL_checkstring(L, 2));
 
        ldns_rdf *new_rdf = ldns_rdf_new_frm_str((ldns_rdf_type)t, str);
@@ -159,7 +159,7 @@ static int
 l_pkt_push_rr(lua_State *L)
 {
        ldns_pkt *pkt = (ldns_pkt*)lua_touserdata(L, 1); /* get the packet */
-       ldns_pkt_section s = lua_tonumber(L, 2); /* the section where to put it */
+       ldns_pkt_section s = (ldns_pkt_section)lua_tonumber(L, 2); /* the section where to put it */
        ldns_rr *rr = (ldns_rr*)lua_touserdata(L, 3); /* the rr to put */
 
        if (ldns_pkt_push_rr(pkt, s, rr)) {
@@ -175,7 +175,7 @@ l_pkt_insert_rr(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
        ldns_rr *rr = (ldns_rr*)lua_touserdata(L, 2);
-       unsigned int n = lua_tonumber(L, 3);
+       uint16_t n = (uint16_t)lua_tonumber(L, 3);
 
        if(ldns_pkt_insert_rr(p, rr, n)) {
                lua_pushlightuserdata(L, p);
@@ -189,7 +189,7 @@ static int
 l_pkt_get_rr(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1); /* pop from the stack */
-       uint16_t n = lua_tonumber(L, 2);
+       uint16_t n = (uint16_t) lua_tonumber(L, 2);
        ldns_rr *r;
 
        r = ldns_pkt_get_rr(p, n);
@@ -206,7 +206,7 @@ l_pkt_set_rr(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
        ldns_rr *rr = (ldns_rr*)lua_touserdata(L, 2);
-       uint16_t n = lua_tonumber(L, 3);
+       uint16_t n = (uint16_t)lua_tonumber(L, 3);
        ldns_rr *r;
 
        r = ldns_pkt_set_rr(p, rr, n);
@@ -266,7 +266,7 @@ l_server_socket_udp(lua_State *L)
        if (sockfd == 0) {
                return 0;
        }
-       lua_pushnumber(L, sockfd);
+       lua_pushnumber(L, (lua_Number)sockfd);
        return 1;
 }
 
@@ -300,7 +300,7 @@ l_write_wire_udp(lua_State *L)
        if (bytes == 0) {
                return 0;
        } else {
-               lua_pushnumber(L, bytes);
+               lua_pushnumber(L, (lua_Number)bytes);
                return 1;
        }
 }
@@ -311,7 +311,6 @@ l_read_wire_udp(lua_State *L)
        int sockfd = (int)lua_tonumber(L, 1);
        size_t size;
        uint8_t *pktbuf_raw;
-       ldns_pkt *pkt;
        ldns_buffer *pktbuf;
        /* returned frm wire */
        socklen_t from_size;
@@ -339,7 +338,7 @@ l_read_wire_udp(lua_State *L)
        /* stack func lua cal in same order buf, from, size = */
        lua_pushlightuserdata(L, pktbuf);
        lua_pushlightuserdata(L, from);
-       lua_pushnumber(L, from_size);
+       lua_pushnumber(L, (lua_Number)from_size);
        return 3;
 }
 
@@ -350,7 +349,7 @@ static int
 l_pkt_qdcount(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
-       lua_pushnumber(L, ldns_pkt_qdcount(p));
+       lua_pushnumber(L, (lua_Number)ldns_pkt_qdcount(p));
        return 1;
 }
 
@@ -358,7 +357,7 @@ static int
 l_pkt_ancount(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
-       lua_pushnumber(L, ldns_pkt_ancount(p));
+       lua_pushnumber(L, (lua_Number)ldns_pkt_ancount(p));
        return 1;
 }
 
@@ -366,7 +365,7 @@ static int
 l_pkt_nscount(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
-       lua_pushnumber(L, ldns_pkt_nscount(p));
+       lua_pushnumber(L, (lua_Number)ldns_pkt_nscount(p));
        return 1;
 }
 
@@ -374,7 +373,7 @@ static int
 l_pkt_arcount(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
-       lua_pushnumber(L, ldns_pkt_arcount(p));
+       lua_pushnumber(L, (lua_Number)ldns_pkt_arcount(p));
        return 1;
 }
 
@@ -382,7 +381,7 @@ static int
 l_pkt_set_ancount(lua_State *L)
 {
        ldns_pkt *p  = (ldns_pkt*)lua_touserdata(L, 1);
-       uint16_t count = (uint16_t) lua_tonumber(L, 2);
+       uint16_t count = (uint16_t)lua_tonumber(L, 2);
        (void)ldns_pkt_set_ancount(p, count);
        return 0;
 }
@@ -391,7 +390,7 @@ static int
 l_pkt_id(lua_State *L)
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
-       lua_pushnumber(L, ldns_pkt_id(p));
+       lua_pushnumber(L, (lua_Number)ldns_pkt_id(p));
        return 1;
 }
 
@@ -399,7 +398,7 @@ static int
 l_pkt_set_id(lua_State *L) 
 {
        ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1);
-       uint16_t id = lua_tonumber(L, 2);
+       uint16_t id = (uint16_t)lua_tonumber(L, 2);
        ldns_pkt_set_id(p, id);
        return 0;
 }
@@ -463,7 +462,7 @@ l_pkt2string(lua_State *L)
        }
        /* this is a memcpy??? */
        luaL_addlstring(&lua_b,
-                       ldns_buffer_begin(b),
+                       (char*)ldns_buffer_begin(b),
                        ldns_buffer_capacity(b)
                       );
        /* I hope so */
@@ -485,7 +484,7 @@ l_sockaddr_storage2rdf(lua_State *L)
        addr = ldns_sockaddr_storage2rdf(sock, &port);
        if (addr) {
                lua_pushlightuserdata(L, addr);
-               lua_pushnumber(L, port);
+               lua_pushnumber(L, (lua_Number)port);
                return 2;
        } else {
                return 0;
index 5a3d145b42e9735c11d8a32ad811e721e0dcb799..e3f7ae00fcace384c070833999624e3645b7579d 100644 (file)
@@ -6,6 +6,8 @@ LDNS_SECTION_ADDITIONAL         = 3
 LDNS_SECTION_ANY               = 4
 LDNS_SECTION_ANY_NOQUESTION    = 5
 
+-- BETTER FUNCTION NAMES
+
 -- rdf types
 LDNS_RDF_TYPE_NONE             = 0
 LDNS_RDF_TYPE_DNAME            = 1
@@ -35,7 +37,6 @@ LDNS_RDF_TYPE_WKS             = 24
 LDNS_RDF_TYPE_NSA              = 25
 LDNS_RDF_TYPE_IPSECKEY         = 26
 
-
 function lua_debug(...)
        print("[lua]", unpack(arg))
 end
@@ -74,8 +75,12 @@ function lua_remove_rr(pkt, n)
        print("[info] [RR] remove", "end")
 end
 
--- convert a ldns_buffer to a string in lua
-function lua_buf_to_string(buf)
+-- increment the ancount
+function lua_ancount_incr(pkt, n)
+       print("[info] [PKT] ancount incr", n)
+       an = packet.ancount(pkt)
+       n = an + n
+       packet.set_ancount(pkt, n)
 end
 
 ---------------------------------
index 2547cce8fc8d859909aa65250196a749fcef144b..020404b1d7a96d442bcc0c8cbfdec8c052aa57cf 100644 (file)
@@ -36,8 +36,7 @@ else
 
        -- set the id on the outgoing packet
        packet.set_id(pkt, id)
-       packet.set_ancount(pkt,
-                       packet.ancount(pkt) + 1)
+       lua_ancount_incr(pkt, 100)
        wirebuf2 = packet.to_buf(pkt)
 
        rdf_listen, port_listen = rdf.sockaddr_to_rdf(sockaddr_from)