]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
some more ground work - it does not compile :)
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 7 Dec 2004 10:38:19 +0000 (10:38 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 7 Dec 2004 10:38:19 +0000 (10:38 +0000)
Makefile [new file with mode: 0644]
main.c
prototype.h [new file with mode: 0644]
rdata.c
util.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..74fecf0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,14 @@
+CC     =       gcc
+CFLAGS =       -g -Wall -Wwrite-strings -Wunused-value -Wunused-parameter
+
+LIBOBJ=rdata.o util.o
+HEADER=rdata.h prototype.h
+
+COMPILE                = $(CC) $(CFLAGS)
+LINK           = $(CC) $(CFLAGS) $(LDFLAGS)
+
+%.o:   %.c $(HEADER)
+       $(CC) $(CFLAGS) -c $<
+
+main:  main.o $(LIBOBJ)
+       $(LINK) -o $@ main.o $(LIBOBJ)
diff --git a/main.c b/main.c
index 95fa2ac929b0e717db9ce4236c1e6f3590de65a8..21880272c72744a40d85a7cf2852b4f43096a34e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -3,11 +3,13 @@
  *
  */
 
+#include <stdio.h>
+
 #include "rdata.h"
 
 int
 main(void)
 {
-
        printf("Hallo\n");
+       return(0);
 }
diff --git a/prototype.h b/prototype.h
new file mode 100644 (file)
index 0000000..2a8837e
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * prototype.h
+ *
+ * general prototyps
+ *
+ * a Net::DNS like library for C
+ *
+ * (c) NLnet Labs, 2004
+ *
+ * See the file LICENSE for the license
+ */
+#include <stdint.h>
+#include <stdlib.h>
+
+/* util.c */
+void * xmalloc(size_t);
diff --git a/rdata.c b/rdata.c
index e68a6624771e6cf428c63908d6274e90d896dac1..8e5eccf89eec85a1ed77eb97bffe6931da21404f 100644 (file)
--- a/rdata.c
+++ b/rdata.c
@@ -12,6 +12,7 @@
 
 #include <stdint.h>
 
+#include "prototype.h"
 #include "rdata.h"
 
 /* Access functions 
@@ -45,13 +46,32 @@ rd_set_size(rdata_t *rd, uint16_t s)
 }
 
 void
-rd_type(rdata_t *rd, rd_type_t t)
+rd_set_type(rdata_t *rd, rd_type_t t)
 {
        rd->_type = t;
 }
 
 void
-rd_data(rdata_t *rd, uint8_t *d)
+rd_set_data(rdata_t *rd, uint8_t *d)
 {
        rd->_data = d;
 }
+
+/* allocate a new rdata_t structure 
+ * and return it
+ */
+rdata_t *
+rd_new(uint16_t s, rd_type_t t, uint8_t *d)
+{
+       rdata_t *new;
+       new = xmalloc(sizeof(rdata_t));
+
+       if (NULL == new)
+               return NULL;
+
+       rd_set_size(new, s);
+       rd_set_type(new, t);
+       rd_set_data(new, d);
+
+       return(new);
+}
diff --git a/util.c b/util.c
new file mode 100644 (file)
index 0000000..31f03d9
--- /dev/null
+++ b/util.c
@@ -0,0 +1,21 @@
+/*
+ * util.c
+ *
+ * some general memory functions
+ *
+ * a Net::DNS like library for C
+ *
+ * (c) NLnet Labs, 2004
+ *
+ * See the file LICENSE for the license
+ */
+
+void *
+xmalloc(size_t s)
+{
+       void *p;
+       
+       p = (void*)malloc(s);
+
+       return p;
+}