mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
indented source to look more like other ares code,
added (somewhat ugly) typecasts to build warning-free on 64bit platforms (the result of a (char *) - (char *) cannot be stored in an int universally)
This commit is contained in:
parent
e78ddf0a95
commit
b3a8f438fc
@ -68,7 +68,8 @@
|
|||||||
* Paul Vixie (ISC), June 1996
|
* Paul Vixie (ISC), June 1996
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
|
||||||
|
{
|
||||||
static const char xdigits[] = "0123456789abcdef";
|
static const char xdigits[] = "0123456789abcdef";
|
||||||
static const char digits[] = "0123456789";
|
static const char digits[] = "0123456789";
|
||||||
int n, ch, tmp = 0, dirty, bits;
|
int n, ch, tmp = 0, dirty, bits;
|
||||||
@ -86,7 +87,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
|||||||
while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
|
while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
|
||||||
if (isupper(ch))
|
if (isupper(ch))
|
||||||
ch = tolower(ch);
|
ch = tolower(ch);
|
||||||
n = strchr(xdigits, ch) - xdigits;
|
n = (int)(strchr(xdigits, ch) - xdigits);
|
||||||
if (dirty == 0)
|
if (dirty == 0)
|
||||||
tmp = n;
|
tmp = n;
|
||||||
else
|
else
|
||||||
@ -108,7 +109,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
do {
|
do {
|
||||||
n = strchr(digits, ch) - digits;
|
n = (int)(strchr(digits, ch) - digits);
|
||||||
tmp *= 10;
|
tmp *= 10;
|
||||||
tmp += n;
|
tmp += n;
|
||||||
if (tmp > 255)
|
if (tmp > 255)
|
||||||
@ -136,7 +137,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
|||||||
ch = *src++; /* Skip over the /. */
|
ch = *src++; /* Skip over the /. */
|
||||||
bits = 0;
|
bits = 0;
|
||||||
do {
|
do {
|
||||||
n = strchr(digits, ch) - digits;
|
n = (int)(strchr(digits, ch) - digits);
|
||||||
bits *= 10;
|
bits *= 10;
|
||||||
bits += n;
|
bits += n;
|
||||||
} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
|
} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
|
||||||
@ -167,7 +168,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
|||||||
bits = 8;
|
bits = 8;
|
||||||
/* If imputed mask is narrower than specified octets, widen. */
|
/* If imputed mask is narrower than specified octets, widen. */
|
||||||
if (bits < ((dst - odst) * 8))
|
if (bits < ((dst - odst) * 8))
|
||||||
bits = (dst - odst) * 8;
|
bits = (int)(dst - odst) * 8;
|
||||||
/*
|
/*
|
||||||
* If there are no additional bits specified for a class D
|
* If there are no additional bits specified for a class D
|
||||||
* address adjust bits to 4.
|
* address adjust bits to 4.
|
||||||
@ -193,7 +194,8 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getbits(const char *src, int *bitsp) {
|
getbits(const char *src, int *bitsp)
|
||||||
|
{
|
||||||
static const char digits[] = "0123456789";
|
static const char digits[] = "0123456789";
|
||||||
int n;
|
int n;
|
||||||
int val;
|
int val;
|
||||||
@ -223,7 +225,8 @@ getbits(const char *src, int *bitsp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getv4(const char *src, unsigned char *dst, int *bitsp) {
|
getv4(const char *src, unsigned char *dst, int *bitsp)
|
||||||
|
{
|
||||||
static const char digits[] = "0123456789";
|
static const char digits[] = "0123456789";
|
||||||
unsigned char *odst = dst;
|
unsigned char *odst = dst;
|
||||||
int n;
|
int n;
|
||||||
@ -266,7 +269,8 @@ getv4(const char *src, unsigned char *dst, int *bitsp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) {
|
inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
|
||||||
|
{
|
||||||
static const char xdigits_l[] = "0123456789abcdef",
|
static const char xdigits_l[] = "0123456789abcdef",
|
||||||
xdigits_u[] = "0123456789ABCDEF";
|
xdigits_u[] = "0123456789ABCDEF";
|
||||||
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
|
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
|
||||||
@ -355,7 +359,7 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) {
|
|||||||
* Since some memmove()'s erroneously fail to handle
|
* Since some memmove()'s erroneously fail to handle
|
||||||
* overlapping regions, we'll do the shift by hand.
|
* overlapping regions, we'll do the shift by hand.
|
||||||
*/
|
*/
|
||||||
const int n = tp - colonp;
|
const int n = (int)(tp - colonp);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (tp == endp)
|
if (tp == endp)
|
||||||
@ -398,7 +402,8 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) {
|
|||||||
* Paul Vixie (ISC), June 1996
|
* Paul Vixie (ISC), June 1996
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ares_inet_net_pton(int af, const char *src, void *dst, size_t size) {
|
ares_inet_net_pton(int af, const char *src, void *dst, size_t size)
|
||||||
|
{
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
return (inet_net_pton_ipv4(src, dst, size));
|
return (inet_net_pton_ipv4(src, dst, size));
|
||||||
@ -413,7 +418,8 @@ ares_inet_net_pton(int af, const char *src, void *dst, size_t size) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(HAVE_INET_PTON) || !defined(HAVE_INET_PTON_IPV6)
|
#if !defined(HAVE_INET_PTON) || !defined(HAVE_INET_PTON_IPV6)
|
||||||
int ares_inet_pton(int af, const char *src, void *dst) {
|
int ares_inet_pton(int af, const char *src, void *dst)
|
||||||
|
{
|
||||||
int size, result;
|
int size, result;
|
||||||
|
|
||||||
if (af == AF_INET)
|
if (af == AF_INET)
|
||||||
|
Loading…
Reference in New Issue
Block a user