> had to go around the list ... can't post from here.
>
> i think you're making this too hard. what you want is more
> of a dns query. this is very easy to do. something like
> (this might not complie -- i just typed it out.)
>
> char*
> gethostbyaddr(char *net, char *addr)
> {
> char buf[64];
> int fd, l;
>
> if(net == 0)
> net="/net";
> snprint(buf, sizeof buf, "%s/dns", net);
> fd = open(buf, ORDWR);
> if(fd < 0)
> return 0;
> snprint(buf, sizeof buf, "%s ptr", addr);
> if(write(fd, buf, strlen(buf)) < 0)
> return 0;
> l = read(fd, buf, sizeof buf);
> if(l < 0 || l == sizeof buf)
> return 0;
> return strdup(buf);
> }
>
> - erik
Thanks, this finally looks like what I need. Two points though:
1. Is 64 bytes sufficient for the domain name? Searching the ’net
I’ve found other numbers — according to <http://tinyurl.com/ykyths> it
should be 1005; <http://tinyurl.com/xdp4> links to a name about 140
bytes long and firefox handles it just fine.
2. Why the second part of “if(l < 0 || l == sizeof buf)”?
I’ll bang on this a bit and see if I can make it set errstr appropriately.
--Joel