char *line;
char *word;
char *addr;
+ char *rr_str;
ldns_buffer *linebuf;
+ ldns_rr *rr;
+ ldns_rr_list *list;
bool ip6;
linebuf = ldns_buffer_new(MAXLINE_LEN);
line = XMALLOC(char, MAXLINE_LEN + 1);
word = XMALLOC(char, MAXLINE_LEN + 1);
addr = XMALLOC(char, MAXLINE_LEN + 1);
+ rr_str = XMALLOC(char, MAXLINE_LEN + 1);
ip6 = false;
+ list = ldns_rr_list_new();
+ rr = NULL;
for(i = ldns_fget_token(fp, line, "\n", 0);
i > 0;
} else {
/* la al la la */
if (ip6) {
- printf("%s IN AAAA %s\n", addr, word);
+ snprintf(rr_str, MAXLINE_LEN, "%s IN AAAA %s", word, addr);
} else {
- printf("%s IN A %s\n", addr, word);
+ snprintf(rr_str, MAXLINE_LEN, "%s IN A %s", word, addr);
}
+ rr = ldns_rr_new_frm_str(rr_str);
}
}
+ if (rr) {
+ ldns_rr_list_push_rr(list, rr);
+ }
}
FREE(line);
FREE(word);
FREE(addr);
- return NULL;
+ FREE(rr_str);
+ return list;
}
* \param[in] fp the file pointer to use
* \return ldns_rr_list * with the names
*/
-ldns_rr_list * ldns_get_rr_list_host_frm_fp(FILE *fp);
+ldns_rr_list * ldns_get_rr_list_hosts_frm_fp(FILE *fp);
/**
* wade through fp (a /etc/hosts like file)
* \param[in] filename the filename to use (NULL for /etc/hosts)
* \return ldns_rr_list * with the names
*/
-ldns_rr_list * ldns_get_rr_list_host_frm_file(char *filename);
+ldns_rr_list * ldns_get_rr_list_hosts_frm_file(char *filename);
{
ldns_resolver *r;
ldns_rdf *aaaa;
+ ldns_rr_list *hosts;
r = ldns_resolver_new_frm_file(NULL);
if (!r) {
aaaa = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_AAAA, "::0");
ldns_rdf_print(stdout, aaaa);
printf("\n\n");
-
ldns_resolver_print(stdout, r);
+
+ hosts = ldns_get_rr_list_hosts_frm_file(NULL);
+
+ ldns_rr_list_print(stdout, hosts);
+
return 0;
}