blob: dcf0eab7b70f3e2e6ec3bd2096eb8eed62dabbfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
static unsigned int i2a(char* dest,unsigned int x) {
register unsigned int tmp=x;
register unsigned int len=0;
if (x>=100) { *dest++=tmp/100+'0'; tmp=tmp%100; ++len; }
if (x>=10) { *dest++=tmp/10+'0'; tmp=tmp%10; ++len; }
*dest++=tmp+'0';
return len+1;
}
char *inet_ntoa_r(struct in_addr in,char* buf) {
unsigned int len;
unsigned char *ip=(unsigned char*)∈
len=i2a(buf,ip[0]); buf[len]='.'; ++len;
len+=i2a(buf+ len,ip[1]); buf[len]='.'; ++len;
len+=i2a(buf+ len,ip[2]); buf[len]='.'; ++len;
len+=i2a(buf+ len,ip[3]); buf[len]=0;
return buf;
}
|