From: Miek Gieben Date: Tue, 21 Dec 2004 13:17:13 +0000 (+0000) Subject: conversion2str for A X-Git-Tag: release-0.50~629 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2204d4df482dc36a1a0cedf23e086f72c0f60764;p=thirdparty%2Fldns.git conversion2str for A --- diff --git a/host2str.c b/host2str.c index 6cfa7e23..25465a01 100644 --- a/host2str.c +++ b/host2str.c @@ -14,6 +14,12 @@ #include +#include +#include + + + + #include #include "util.h" @@ -81,7 +87,7 @@ ldns_rdf2str(ldns_rdf *rdf) { char *res = NULL; - switch(rdf->_type) { + switch(ldns_rdf_get_type(rdf)) { case LDNS_RDF_TYPE_NONE: res = XMALLOC(char, 5); snprintf(res, 5, "NONE"); @@ -106,8 +112,7 @@ ldns_rdf2str(ldns_rdf *rdf) snprintf(res, 6, "INT48"); break; case LDNS_RDF_TYPE_A: - res = XMALLOC(char, 5); - snprintf(res, 5, "NONE"); + res = ldns_conv_a(rdf); break; case LDNS_RDF_TYPE_AAAA: res = XMALLOC(char, 5); @@ -166,7 +171,23 @@ ldns_rdf2str(ldns_rdf *rdf) snprintf(res, 5, "NONE"); break; } - return res; } +/** + * convert A address + */ +char * +ldns_conv_a(ldns_rdf *rd) +{ + char *r; + + r = XMALLOC(char, INET_ADDRSTRLEN); + + if (!inet_ntop(AF_INET, ldns_rdf_data(rd), r, INET_ADDRSTRLEN)) { + /* somehting is wrong */ + /* TODO NULL HERE??? */ + return NULL; + } + return r; +} diff --git a/ldns/host2str.h b/ldns/host2str.h index 36783e8d..bba00440 100644 --- a/ldns/host2str.h +++ b/ldns/host2str.h @@ -10,7 +10,8 @@ #include #include -char *ldns_rdf2str(ldns_rdf *rdf); +char *ldns_rdf2str(ldns_rdf *); +char *ldns_conv_a(ldns_rdf *); #endif