blob: b7f4834fc98ae3ebf5aba6a23fe93c606afd3538 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include "__dns.h"
int inet_pton(int af, const char *s, void *a0)
{
unsigned char *a = a0;
const char *z;
unsigned long x;
int i;
/* Reimplement this because inet_pton cannot accept special v4 forms */
if (af==AF_INET) {
for (i=0; i<4 && *s; i++) {
a[i] = x = strtoul(s, (char **)&z, 10);
if (!isdigit(*s) || z==s || (*z && *z != '.') || x>255)
return 0;
s=z+1;
}
return 1;
} else if (af==AF_INET6) {
return !__ipparse(a, AF_INET6, s);
}
errno = EAFNOSUPPORT;
return -1;
}
|