2002-11-02 12:35:07 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include "barpainet.h"
|
|
|
|
|
|
|
|
int inet_aton (const char * str, struct in_addr * add) {
|
2005-12-22 03:10:11 +02:00
|
|
|
const char * pch = str;
|
|
|
|
unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0;
|
2005-12-17 20:14:38 +02:00
|
|
|
|
2005-12-22 03:10:11 +02:00
|
|
|
add1 = atoi(pch);
|
|
|
|
pch = strpbrk(pch,".");
|
|
|
|
if (pch == 0 || ++pch == 0) goto done;
|
|
|
|
add2 = atoi(pch);
|
|
|
|
pch = strpbrk(pch,".");
|
|
|
|
if (pch == 0 || ++pch == 0) goto done;
|
|
|
|
add3 = atoi(pch);
|
|
|
|
pch = strpbrk(pch,".");
|
|
|
|
if (pch == 0 || ++pch == 0) goto done;
|
|
|
|
add4 = atoi(pch);
|
2002-11-02 12:35:07 +02:00
|
|
|
|
|
|
|
done:
|
2005-12-22 03:10:11 +02:00
|
|
|
add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1;
|
2005-12-17 20:14:38 +02:00
|
|
|
|
2005-12-22 03:10:11 +02:00
|
|
|
return 1;
|
2002-11-02 12:35:07 +02:00
|
|
|
}
|