]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
some easy (not so robust functions) added
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 15 Mar 2005 14:53:23 +0000 (14:53 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 15 Mar 2005 14:53:23 +0000 (14:53 +0000)
Makefile.in
ldns/rdata.h
ldns/rr.h
rdata.c
rr.c

index bc7d387a97a9fd96dca3f02fa3c0cb7f99233f2d..6da69c2c478c620c7b07adc9f0bd0cf4f335138e 100644 (file)
@@ -135,10 +135,12 @@ doc:
 clean: 
        rm -f *.o *.d
        rm -f $(TESTS)
+       rm -f $(PROG_TARGETS)
        rm -rf autom4te.cache/
        rm -f config.status
        rm -f config.log
        rm -f libldns.a
+       rm -f tags
 
 testclean:
        rm -f $(TESTS)
index 03e70903c76191e3c14cea4a2a0ce7c40fa2a840..593877f3f6ea4d0907929b6e44587888cc631929 100644 (file)
@@ -118,11 +118,13 @@ int               ldns_rdf_compare(const ldns_rdf *, const ldns_rdf *);
 uint8_t                ldns_rdf2native_int8(ldns_rdf *);
 uint16_t       ldns_rdf2native_int16(ldns_rdf *);
 uint32_t       ldns_rdf2native_int32(ldns_rdf *);
-ldns_rdf *     ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value);
-ldns_rdf *     ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value);
-ldns_rdf *     ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value);
-ldns_rdf *     ldns_native2rdf_int16_data(uint16_t size, uint8_t *data);
+ldns_rdf       *ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value);
+ldns_rdf       *ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value);
+ldns_rdf       *ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value);
+ldns_rdf       *ldns_native2rdf_int16_data(uint16_t size, uint8_t *data);
 uint32_t       ldns_str2period(const char *, const char **);
 ldns_rdf       *ldns_rdf_address_reverse(ldns_rdf *);
+ldns_rdf       *ldns_rdf_new_frm_fp(ldns_rdf_type type, FILE *fp);
+
 
 #endif /* !_LDNS_RDATA_H */
index 6d4de124e6dc518e65615dfa279a3b8ae146130b..e911a7cb765369c1210be22812b14cefb1743c8d 100644 (file)
--- a/ldns/rr.h
+++ b/ldns/rr.h
@@ -281,6 +281,9 @@ ldns_rr_list *ldns_rr_list_deep_clone(ldns_rr_list *);
 void ldns_rr_list2canonical(ldns_rr_list *);
 void ldns_rr2canonical(ldns_rr *);
 
+ldns_rr * ldns_rr_new_frm_fp(FILE *fp);
+
+
 
 
 #endif /* _LDNS_RR_H */
diff --git a/rdata.c b/rdata.c
index 30561c5710e5e614a96a693a531d39fc248cff2c..993eacb8bc6bf6942dde1998327bf85d6b1ca91f 100644 (file)
--- a/rdata.c
+++ b/rdata.c
@@ -407,6 +407,29 @@ ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
        }
 }
 
+/**
+ * Create a new rdf from a file containing a string
+ * \param[in] fp the file pointer  to use
+ * \param[in] t   type to use
+ * \return ldns_rdf*
+ */
+ldns_rdf *
+ldns_rdf_new_frm_fp(ldns_rdf_type type, FILE *fp)
+{
+       char *line;
+
+       line = XMALLOC(char, MAXLINE_LEN + 1);
+       if (!line) {
+               return NULL;
+       }
+
+       /* read an entire line in from the file */
+       if (readword(line, fp,  "\n", MAXLINE_LEN) == -1) {
+               return NULL;
+       } 
+       return ldns_rdf_new_frm_str(type, (const char*) line);
+}
+
 /**
  * reverse an rdf, only actually usefull for AAAA and A records
  * the returned rdf has the type LDNS_RDF_TYPE_DNAME!
diff --git a/rr.c b/rr.c
index cc2a60e448203d782d4b1c20c2c81650e277d9f8..c2c8a4cf849859c7718d2d564c1e04f3b0dc372f 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -176,6 +176,28 @@ ldns_rr_new_frm_str(const char *str)
 }
 
 
+/**
+ * Create a new rr from a file containing a string
+ * \param[in] fp the file pointer  to use
+ * \param[in] t   type to use
+ * \return ldns_rr*
+ */
+ldns_rr *
+ldns_rr_new_frm_fp(FILE *fp)
+{
+        char *line;
+
+        line = XMALLOC(char, MAXLINE_LEN + 1);
+        if (!line) {
+                return NULL;
+        }
+
+        /* read an entire line in from the file */
+        if (readword(line, fp,  "\n", MAXLINE_LEN) == -1) {
+                return NULL;
+        }
+        return ldns_rr_new_frm_str((const char*) line);
+}
 
 /**
  * \brief set the owner in the rr structure