%.o: %.c $(HEADER)
$(CC) $(CFLAGS) -c $<
+.PHONY: clean
+
main: main.o $(LIBOBJ)
$(LINK) -o $@ main.o $(LIBOBJ)
+
+clean:
+ rm -f *.o
+ rm -f main
#include <stdio.h>
-#include "rdata.h"
+#include "prototype.h"
int
main(void)
{
+ rdata_t *new;
+ printf("size %u\n", sizeof(struct struct_rdata_t));
+ new = rd_new(20, RD_DNAME_T, (uint8_t*)"hallo.nl");
+
printf("Hallo\n");
- return(0);
+ return 0;
}
#include <stdint.h>
#include <stdlib.h>
+#include "rdata.h"
/* util.c */
-void * xmalloc(size_t);
+void *xmalloc(size_t);
+
+/* rdata.c */
+uint16_t rd_size(rdata_t *);
+uint8_t *rd_data(rdata_t *);
+void rd_set_size(rdata_t *, uint16_t);
+void rd_set_type(rdata_t *, rd_type_t);
+void rd_set_data(rdata_t *, uint8_t *);
+rd_type_t rd_type(rdata_t *);
+rdata_t *rd_new(uint16_t, rd_type_t, uint8_t *);
#include <stdint.h>
#include "prototype.h"
-#include "rdata.h"
/* Access functions
* do this as functions to get type checking
RD_TYPE_T, /* a RR type */
RD_CLASS_T, /* a class */
RD_CERT_T, /* certificates */
- RD_ALG_T /* a key algorithm */
+ RD_ALG_T, /* a key algorithm */
+ RD_UNKNOWN_T, /* unknown types */
+ RD_TIME_T, /* time */
+ RD_SERVICE_T, /* protocol and port bitmaps */
+ RD_LOC_T /* location data */
};
typedef enum enum_rdata_type rd_type_t;
* data = network order, expanded (no compression)
*/
-struct {
+struct struct_rdata_t {
uint16_t _size;
rd_type_t _type;
uint8_t *_data;
-} struct_rdata_t;
+};
typedef struct struct_rdata_t rdata_t;
* See the file LICENSE for the license
*/
+#include <stdint.h>
+#include <stdlib.h>
+
void *
xmalloc(size_t s)
{