My Project
Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
soc_inet_ntoa.c
Go to the documentation of this file.
1
#include "
soc_common.h
"
2
#include <
arpa/inet.h
>
3
#include <
netinet/in.h
>
4
5
static
char
buffer[
INET_ADDRSTRLEN
];
6
7
char
*
inet_ntoa
(
struct
in_addr
in)
8
{
9
unsigned
char
*addrbuf = (
unsigned
char
*)∈
10
char
*p;
11
size_t
i;
12
unsigned
int
n;
13
14
memset(buffer, 0,
sizeof
(buffer));
15
for
(p = buffer, i = 0; i < 4; ++i) {
16
if
(i > 0) *p++ =
'.'
;
17
18
n = addrbuf[i];
19
if
(n >= 100) {
20
*p++ = n/100 +
'0'
;
21
n %= 100;
22
}
23
if
(n >= 10 || addrbuf[i] >= 100) {
24
*p++ = n/10 +
'0'
;
25
n %= 10;
26
}
27
*p++ = n +
'0'
;
28
}
29
*p = 0;
30
31
return
buffer;
32
}
soc_common.h
inet_ntoa
char * inet_ntoa(struct in_addr in)
Definition:
soc_inet_ntoa.c:7
in.h
in_addr
Definition:
in.h:19
inet.h
INET_ADDRSTRLEN
#define INET_ADDRSTRLEN
Definition:
in.h:10
source
services
soc
soc_inet_ntoa.c
Generated on Mon Nov 24 2014 23:37:59 for My Project by
1.8.8