Guest User

Untitled

a guest
Feb 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. char *
  2. fqdn2ip(host)
  3. char *host;
  4. {
  5. unsigned long sum;
  6. unsigned long base[4]={16777216,65536,256,1};
  7. int i, ip[4];
  8.  
  9. if (!strcmp(host, "localhost"))
  10. return "127.0.0.1";
  11.  
  12. sum = dns_a(host);
  13.  
  14. for (i=0; i<=3; i++)
  15. {
  16. ip[i] = sum / base[i];
  17. sum -= base[i]*ip[i];
  18. }
  19. sprintf(ipaddr, "%d.%d.%d.%d\0", ip[3], ip[2], ip[1], ip[0]);
  20.  
  21. return (ipaddr);
  22. }
Add Comment
Please, Sign In to add comment