From: Miek Gieben Date: Tue, 7 Dec 2004 10:38:19 +0000 (+0000) Subject: some more ground work - it does not compile :) X-Git-Tag: release-0.50~755 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c9271bef674496aef7e3ef8f1a7ec0b9db6793f;p=thirdparty%2Fldns.git some more ground work - it does not compile :) --- diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..74fecf0b --- /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 95fa2ac9..21880272 100644 --- a/main.c +++ b/main.c @@ -3,11 +3,13 @@ * */ +#include + #include "rdata.h" int main(void) { - printf("Hallo\n"); + return(0); } diff --git a/prototype.h b/prototype.h new file mode 100644 index 00000000..2a8837e4 --- /dev/null +++ b/prototype.h @@ -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 +#include + +/* util.c */ +void * xmalloc(size_t); diff --git a/rdata.c b/rdata.c index e68a6624..8e5eccf8 100644 --- a/rdata.c +++ b/rdata.c @@ -12,6 +12,7 @@ #include +#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 index 00000000..31f03d91 --- /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; +}