Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting
#include 
#include 

int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask) {
	unsigned d1, d2, d3, d4, m;
	int res;
	if ((res = sscanf((char *)s, "%u.%u.%u.%u/%u", &d1, &d2, &d3, &d4, &m)) < 4) return 0;
	if(mask && res == 4) *mask = 0xFFFFFFFF;
	else if (mask) *mask = htonl(0xFFFFFFFF << (32 - m));
	*ip = htonl ((d1<<24) ^ (d2<<16) ^ (d3<<8) ^ d4);
	return res;
}


int main(int argc, char* argv[]){
	struct sockaddr_in sins;
	struct hostent* hp;
	unsigned long ip;

	WSADATA wd;

	WSAStartup(MAKEWORD( 1, 1 ), &wd);

	
	if(argc!=2 || scanaddr(argv[1], &ip, NULL)!=4){
		fprintf(stderr, "Usage: %s ip\n", argc?argv[0]:"-");
		return 2;
	}
	hp = gethostbyaddr((char *)&ip, 4, AF_INET);
	if (!hp) {
		printf("gethostbyaddr failed\n");
		return 102;
	}	
	printf("h_name: %s\n", hp->h_name);
	return 0;
}


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library