Line | |
---|
1 |
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <strings.h>
|
---|
4 | #include "barpainet.h"
|
---|
5 |
|
---|
6 | int inet_aton (const char * str, struct in_addr * add) {
|
---|
7 | const char * pch = str;
|
---|
8 | unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0;
|
---|
9 |
|
---|
10 | add1 = atoi(pch);
|
---|
11 | pch = strpbrk(pch,".");
|
---|
12 | if (pch == 0 || ++pch == 0) goto done;
|
---|
13 | add2 = atoi(pch);
|
---|
14 | pch = strpbrk(pch,".");
|
---|
15 | if (pch == 0 || ++pch == 0) goto done;
|
---|
16 | add3 = atoi(pch);
|
---|
17 | pch = strpbrk(pch,".");
|
---|
18 | if (pch == 0 || ++pch == 0) goto done;
|
---|
19 | add4 = atoi(pch);
|
---|
20 |
|
---|
21 | done:
|
---|
22 | add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1;
|
---|
23 |
|
---|
24 | return 1;
|
---|
25 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.