ReactOS
0.4.16-dev-752-g47bae01
iputils.c
Go to the documentation of this file.
1
#include <
headers.h
>
2
#include <
datatypes.h
>
3
#include <options.h>
4
#include <
utils.h
>
5
6
int
split_ip
(
char
*
text
,
u8b
*
dest
,
int
place
)
7
{
8
int
dotcount;
9
10
/* Don't touch this, unless you like pointer aritmethic */
11
12
*
dest
= 0;
13
14
if
( !
text
)
15
return
-1;
16
17
for
( dotcount = 0; (dotcount <
place
) && (
text
);
text
++ )
18
if
( *
text
==
'.'
)
19
dotcount++;
20
21
if
( !
text
)
22
return
-2;
23
24
while
(( *
text
!=
'.'
) && ( *
text
!=
'\0'
))
25
{
26
*
dest
*= 10;
27
*
dest
+= (
u8b
)(*
text
-48);
28
/* 48 is not a hack, is just the code of 0 */
29
text
++;
30
}
31
32
return
0;
33
}
34
35
int
get_ip
(
char
*
text
,
u32b
*
dest
)
36
{
37
/* Don't touch this, unless you like pointer aritmethic */
38
39
*
dest
= 0;
40
41
if
( !
text
)
42
return
-1;
43
44
while
( *
text
!=
'\0'
)
45
{
46
if
( *
text
==
'.'
)
47
{
48
*
dest
= *
dest
<< 8;
49
text
++;
50
continue
;
51
}
52
*
dest
*= 10;
53
*
dest
+= (
u8b
)(*
text
-48);
54
/* 48 is not a hack, is just the code of 0 */
55
text
++;
56
}
57
58
return
0;
59
}
datatypes.h
u32b
unsigned int u32b
Definition:
datatypes.h:6
u8b
unsigned char u8b
Definition:
datatypes.h:4
text
const WCHAR * text
Definition:
package.c:1794
headers.h
get_ip
int get_ip(char *text, u32b *dest)
Definition:
iputils.c:35
split_ip
int split_ip(char *text, u8b *dest, int place)
Definition:
iputils.c:6
dest
static char * dest
Definition:
rtl.c:135
place
static char * place
Definition:
getopt.c:55
utils.h
modules
rosapps
applications
net
dhcpd
src
utils
iputils.c
Generated on Mon Feb 17 2025 06:06:33 for ReactOS by
1.9.6