]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
also _fp function for the resolver
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 15 Mar 2005 15:04:09 +0000 (15:04 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 15 Mar 2005 15:04:09 +0000 (15:04 +0000)
resolver.c

index e529bdb879076ea147eae4bff0eda3b0c3eeddc5..c3585bd9eab9a96791966848f21e3d9a739cf25a 100644 (file)
@@ -434,23 +434,10 @@ ldns_resolver_new(void)
        return r;
 }
 
-
-/**
- * configure a resolver by means of a resolv.conf file
- * The file may be NULL in which case there will  be
- * looked the RESOLV_CONF (defaults to /etc/resolv.conf
- * \param[in] filename the filename to use
- * \return ldns_resolver pointer
- */
-/* keyword recognized:
- * nameserver
- * domain
- */
 ldns_resolver *
-ldns_resolver_new_frm_file(const char *filename)
+ldns_resolver_new_frm_fp(FILE *fp)
 {
        ldns_resolver *r;
-       FILE *fp;
        const char *keyword[2];
        char *word;
        uint8_t expect;
@@ -474,16 +461,6 @@ ldns_resolver_new_frm_file(const char *filename)
        if (!r) {
                return NULL;
        }
-       if (!filename) {
-               fp = fopen(RESOLV_CONF, "r");
-
-       } else {
-               fp = fopen(filename, "r");
-       }
-       if (!fp) {
-               return NULL;
-       }
-       /* the file is opened. it's line based - this will be a bit messy */
 
        while (readword(word, fp, "\n\t ", MAXLINE_LEN) != -1) {
                /* do something */
@@ -535,6 +512,41 @@ ldns_resolver_new_frm_file(const char *filename)
                                break;
                }
        }
+       return r;
+}
+
+
+
+
+/**
+ * configure a resolver by means of a resolv.conf file
+ * The file may be NULL in which case there will  be
+ * looked the RESOLV_CONF (defaults to /etc/resolv.conf
+ * \param[in] filename the filename to use
+ * \return ldns_resolver pointer
+ */
+/* keyword recognized:
+ * nameserver
+ * domain
+ */
+ldns_resolver *
+ldns_resolver_new_frm_file(const char *filename)
+{
+       ldns_resolver *r;
+       FILE *fp;
+
+       if (!filename) {
+               fp = fopen(RESOLV_CONF, "r");
+
+       } else {
+               fp = fopen(filename, "r");
+       }
+       if (!fp) {
+               return NULL;
+       }
+       /* the file is opened. it's line based - this will be a bit messy */
+
+       r =  ldns_resolver_new_frm_fp(fp);
 
        fclose(fp);
        return r;