/*************************************************************************** * Copyright (C) 29/04/2006 by Psyco_Rabbit * * PsycoRabbit@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Berkeley Software Distribution (BSD) * * License. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include #include #include #include using namespace std; int main() { struct hostent *host; //it contains informations about host struct in_addr addr; //in this struct there is our address char address[32]; string c; do{ cout<<"DNS by Psyco_Rabbit"< ip"< hostname"<>i; while (i!="1" && i!="2"){ cout<<"Type 1 or 2!"<>i; } char s[32]; cout<<"Type address:"<>s; if (i=="1"){ if ((host=gethostbyname(s))==NULL) //system call to obtain ip address by hostname herror("gethostbyname"); else{ inet_ntop(AF_INET,host->h_addr,address,sizeof(address)); //transform h_addr in a readable format cout<h_name<>c; while (c!="n" && c!="y") cin>>c; }while (c!="n"); return EXIT_SUCCESS; }