2011-04-09 19:55:52 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
#include <netdb.h>
|
|
|
|
|
2011-05-02 12:11:12 +04:00
|
|
|
static const char *int2ip(unsigned int ip)
|
|
|
|
{
|
2011-04-09 19:55:52 +04:00
|
|
|
static char s[16];
|
2011-05-02 12:11:12 +04:00
|
|
|
sprintf(s, "%d.%d.%d.%d", ip >> 24, ip << 8 >> 24, ip << 16 >> 24, ip << 24 >> 24);
|
2011-04-09 19:55:52 +04:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2011-05-02 12:11:12 +04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
if (argc < 2) {
|
2011-04-09 19:55:52 +04:00
|
|
|
perror("need hex ip address");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int ip = 0;
|
2011-05-02 12:11:12 +04:00
|
|
|
sscanf(argv[1], "%X", &ip);
|
2011-04-09 19:55:52 +04:00
|
|
|
|
2011-05-02 12:11:12 +04:00
|
|
|
printf("%s\n", int2ip(ip));
|
2011-04-09 19:55:52 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|