mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48: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
|
||||
*/
|
||||
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 digits[] = "0123456789";
|
||||
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)) {
|
||||
if (isupper(ch))
|
||||
ch = tolower(ch);
|
||||
n = strchr(xdigits, ch) - xdigits;
|
||||
n = (int)(strchr(xdigits, ch) - xdigits);
|
||||
if (dirty == 0)
|
||||
tmp = n;
|
||||
else
|
||||
@ -108,7 +109,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
||||
for (;;) {
|
||||
tmp = 0;
|
||||
do {
|
||||
n = strchr(digits, ch) - digits;
|
||||
n = (int)(strchr(digits, ch) - digits);
|
||||
tmp *= 10;
|
||||
tmp += n;
|
||||
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 /. */
|
||||
bits = 0;
|
||||
do {
|
||||
n = strchr(digits, ch) - digits;
|
||||
n = (int)(strchr(digits, ch) - digits);
|
||||
bits *= 10;
|
||||
bits += n;
|
||||
} 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;
|
||||
/* If imputed mask is narrower than specified octets, widen. */
|
||||
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
|
||||
* address adjust bits to 4.
|
||||
@ -193,7 +194,8 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) {
|
||||
}
|
||||
|
||||
static int
|
||||
getbits(const char *src, int *bitsp) {
|
||||
getbits(const char *src, int *bitsp)
|
||||
{
|
||||
static const char digits[] = "0123456789";
|
||||
int n;
|
||||
int val;
|
||||
@ -223,7 +225,8 @@ getbits(const char *src, int *bitsp) {
|
||||
}
|
||||
|
||||
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";
|
||||
unsigned char *odst = dst;
|
||||
int n;
|
||||
@ -266,7 +269,8 @@ getv4(const char *src, unsigned char *dst, int *bitsp) {
|
||||
}
|
||||
|
||||
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",
|
||||
xdigits_u[] = "0123456789ABCDEF";
|
||||
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
|
||||
* overlapping regions, we'll do the shift by hand.
|
||||
*/
|
||||
const int n = tp - colonp;
|
||||
const int n = (int)(tp - colonp);
|
||||
int i;
|
||||
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
case AF_INET:
|
||||
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
|
||||
|
||||
#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;
|
||||
|
||||
if (af == AF_INET)
|
||||
|
Loading…
Reference in New Issue
Block a user