Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *
- fqdn2ip(host)
- char *host;
- {
- unsigned long sum;
- unsigned long base[4]={16777216,65536,256,1};
- int i, ip[4];
- if (!strcmp(host, "localhost"))
- return "127.0.0.1";
- sum = dns_a(host);
- for (i=0; i<=3; i++)
- {
- ip[i] = sum / base[i];
- sum -= base[i]*ip[i];
- }
- sprintf(ipaddr, "%d.%d.%d.%d\0", ip[3], ip[2], ip[1], ip[0]);
- return (ipaddr);
- }
Add Comment
Please, Sign In to add comment