Problem with DNS-Records in C

Hey community,

I'm coding an application in ANSI-C that needs to locate IP-Adresses.
I fount that a good and very cheap way to do this would be to make DNS-queries against Blacklist provider UCEPROTECT's Country zone (country.uceprotect.net)

They seem to offer a TXT-Record and also an A Record to get that information.

So if I want to get the result "IE" for the IP 81.17.242.186 I would have to query either:

dig txt 186.242.17.81.country.uceprotect.net

; <<>> DiG 9.2.3 <<>> txt 186.242.17.81.country.uceprotect.net
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20321
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;186.242.17.81.country.uceprotect.net. IN TXT

;; ANSWER SECTION:
186.242.17.81.country.uceprotect.net. 2100 IN TXT "IE"

;; AUTHORITY SECTION:
country.uceprotect.net. 3468    IN      NS      dnsbl-mirrors.uceprotect.net.

;; Query time: 103 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Mar  8 17:47:47 2010
;; MSG SIZE  rcvd: 97

or I could also query the A-Record which results in an NUMBER which seems to be ascii code too.

dig a 186.242.17.81.country.uceprotect.net

results in:
;; QUESTION SECTION:
;186.242.17.81.country.uceprotect.net. IN A

;; ANSWER SECTION:
186.242.17.81.country.uceprotect.net. 2100 IN A 127.0.73.69

;; AUTHORITY SECTION:
country.uceprotect.net. 3245    IN      NS      dnsbl-mirrors.uceprotect.net

Since 73 seems to be I and 69 seems to be E that would also work but be possibly more complicated to code.

Unfortunable I have no clue how to do a routine in C that works on Linux or FreeBSD that can ask an IP against country.uceprotect.net for txt or a record and then displays the result.

Can you help me to do this? Would be nice if someone can give me an answer.

Thank you

Hansi