]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
rr.c created. Access functions added
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 9 Dec 2004 13:59:53 +0000 (13:59 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 9 Dec 2004 13:59:53 +0000 (13:59 +0000)
Makefile.in
prototype.h
rdata.h
rr.c
rr.h
util.c

index cd739b021bcb18730bcf226d4e71ab063cd36988..0c42ab63299d3d61209b3faba35f5147c7542171 100644 (file)
@@ -17,7 +17,7 @@ LIBS          = @LIBS@
 #INSTALL = $(srcdir)/install-sh -c
 #INSTALL_PROGRAM = $(INSTALL)
 
-LIBDNS_SOURCES=rdata.c util.c
+LIBDNS_SOURCES=rdata.c util.c rr.c
 LIBDNS_HEADERS=rdata.h prototype.h rr.h packet.h
 LIBDNS_OBJECTS=$(LIBDNS_SOURCES:.c=.o)
 
index be8ac32bf3ccc7849f6e541f1d62c81f0bf7cab6..742669f233348262b0edc5bba4270d17413ccbf1 100644 (file)
@@ -14,7 +14,8 @@
 #define _PROTOTYPE_H
 
 /* util.c */
-void           *xmalloc(size_t);
-void           xprintf_rd_field(t_rdata_field *);
+void   *xmalloc(size_t);
+void   *xrealloc(void *, size_t);
+void   xprintf_rd_field(t_rdata_field *);
 
 #endif /* _PROTOTYPE_H */
diff --git a/rdata.h b/rdata.h
index 86ad55dd9e6766bec7c2d6265e6b07d67c7a6d0d..0230f4f2d1b4c3d669c001e7789ccb5f6d7ac196 100644 (file)
--- a/rdata.h
+++ b/rdata.h
@@ -96,6 +96,5 @@ void            rd_field_set_data(t_rdata_field *, uint8_t *, uint16_t);
 t_rd_type       rd_field_type(t_rdata_field *);
 t_rdata_field   *rd_field_new(uint16_t, t_rd_type, uint8_t *);
 uint8_t         *rd_field_data(t_rdata_field *);
-void            rd_field__destroy(t_rdata_field *);
+void            rd_field_destroy(t_rdata_field *);
 #endif /* _RDATA_H */
-
diff --git a/rr.c b/rr.c
index 2c92fe9340f798447959f56ddf22b0f74849a414..22fecc8be1b89821ca0691de76c1c10991152e2e 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -14,7 +14,7 @@
 
 #include "rdata.h"
 #include "rr.h"
-
+#include "prototype.h"
 
 /* 
  * create a new rr structure.
@@ -28,17 +28,15 @@ rr_new(void)
         if (NULL == new)
                 return NULL;
 
+       rr_set_rd_count(new, 0);
         return(new);
 }
 
-
-/* do we need access functions for all these members? */
-
 /*
  * set the owner in the rr structure
  */
 void
-rr_set_owner(t_rr *rr, uint8_t owner)
+rr_set_owner(t_rr *rr, uint8_t *owner)
 {
        rr->_owner = owner;
 }
@@ -52,23 +50,47 @@ rr_set_ttl(t_rr *rr, uint16_t ttl)
        rr->_ttl = ttl;
 }
 
+/*
+ * set the rd_count in the rr
+ */
 void
 rr_set_rd_count(t_rr *rr, uint16_t count)
 {
        rr->_rd_count = count;
 }
 
+/*
+ * set the class in the rr
+ */
 void
 rr_set_class(t_rr *rr, t_class klass)
 {
        rr->_klass = klass;
 }
 
+/* 
+ * set rd_field member in the rr, it will be 
+ * placed in the next available spot
+ */
+void
+rr_set_rd_field(t_rr *rr, t_rdata_field f)
+{
+       uint16_t rd_count;
+
+       rd_count = rr_rd_count(rr);
+       /* grow the array */
+       rr->rdata_fields = xrealloc(rr->rdata_fields, ++rd_count);
+
+       /* add the new member */
+       rr->rdata_fields[rd_count] = f;
+
+       rr_set_rd_count(rr, rd_count);
+}
 
 /*
  * return the owner name of an rr structure
  */
-uint8_t
+uint8_t *
 rr_owner(t_rr *rr)
 {
        return (rr->_owner);
@@ -82,3 +104,12 @@ rr_ttl(t_rr *rr)
 {
        return (rr->_ttl);
 }
+
+/*
+ * return the rd_count of an rr structure
+ */
+uint16_t
+rr_rd_count(t_rr *rr)
+{
+       return (rr->_rd_count);
+}
diff --git a/rr.h b/rr.h
index 6590b6bea8a4500499e38ecf3cb66f0960b9fdaf..6f14a41736d437eeb152df4287309b72a7f9c4f4 100644 (file)
--- a/rr.h
+++ b/rr.h
@@ -158,4 +158,15 @@ struct type_struct_rrset
 };
 typedef struct type_struct_rrset t_rrset;
 
+/* prototypes */
+t_rr * rr_new(void);
+void rr_set_owner(t_rr *, uint8_t *);
+void rr_set_ttl(t_rr *, uint16_t);
+void rr_set_rd_count(t_rr *, uint16_t);
+void rr_set_class(t_rr *, t_class);
+void rr_set_rd_field(t_rr *, t_rdata_field);;
+uint8_t * rr_owner(t_rr *);
+uint8_t rr_ttl(t_rr *);
+uint16_t rr_rd_count(t_rr *);
+
 #endif /* _RR_H */
diff --git a/util.c b/util.c
index 4ea3b4f7706eb84a6037a472c2f26cf27ebf7802..731eead1f6c5c4716ddbe73b247666dbcae455c7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -19,9 +19,14 @@ void *
 xmalloc(size_t s)
 {
        void *p;
-       
        p = (void*)malloc(s);
+       return p;
+}
 
+void *
+xrealloc(void *p, size_t s)
+{
+       p = (void*)realloc(p, s);
        return p;
 }