src/windows/native/java/net/Inet4AddressImpl.c
jboolean isDottedIPAddress(const char *hostname, unsigned int *addrp) {
    char *c = (char *)hostname;
    int octets = 0;
    unsigned int cur = 0;
    int digit_cnt = 0;

    while (*c) {
        if (*c == '.') {
            if (digit_cnt == 0) {
                return JNI_FALSE;
            } else {
                if (octets < 4) {
                    addrp[octets++] = cur;
                    cur = 0;
                    digit_cnt = 0;
                } else {
                    return JNI_FALSE;
                }
            }
            c++;
            continue;
        }

        if ((*c < '0') || (*c > '9')) {
            return JNI_FALSE;
        }

        digit_cnt++;
        if (digit_cnt > 3) {
            return JNI_FALSE;
        }

        /* don't check if current octet > 255 */
        cur = cur*10 + (*c - '0');

        /* Move onto next character and check for EOF */
        c++;
        if (*c == '\0') {
            if (octets < 4) {
                addrp[octets++] = cur;
            } else {
                return JNI_FALSE;
            }
        }
    }

    return (jboolean)(octets == 4);
}
/*
 * Returns true if hostname is in dotted IP address format. Note that this
 * function performs a syntax check only. For each octet it just checks that
 * the octet is at most 3 digits.
 */
Returns true if hostname is in dotted IP address format. Note that this
function performs a syntax check only. For each octet it just checks that
the octet is at most 3 digits.
Returns true if hostname is in dotted IP address format . Note that this function performs a syntax check only . For each octet it just checks that the octet is at most 3 digits .
jboolean isDottedIPAddress(const char *hostname, unsigned int *addrp) {
    char *c = (char *)hostname;
    int octets = 0;
    unsigned int cur = 0;
    int digit_cnt = 0;
    while (*c) {
        if (*c == '.') {
            if (digit_cnt == 0) {
                return JNI_FALSE;
            } else {
                if (octets < 4) {
                    addrp[octets++] = cur;
                    cur = 0;
                    digit_cnt = 0;
                } else {
                    return JNI_FALSE;
                }
            }
            c++;
            continue;
        }
        if ((*c < '0') || (*c > '9')) {
            return JNI_FALSE;
        }
        digit_cnt++;
        if (digit_cnt > 3) {
            return JNI_FALSE;
        }
        cur = cur*10 + (*c - '0');
        c++;
        if (*c == '\0') {
            if (octets < 4) {
                addrp[octets++] = cur;
            } else {
                return JNI_FALSE;
            }
        }
    }
    return (jboolean)(octets == 4);
}
jboolean isDottedIPAddress ( const char * hostname , unsigned int * addrp ) { char * c = ( char * ) hostname ; int octets = 0 ; unsigned int cur = 0 ; int digit_cnt = 0 ; while ( * c ) { if ( * c == ' ' ) { if ( digit_cnt == 0 ) { return JNI_FALSE ; } else { if ( octets < 4 ) { addrp [ octets ++ ] = cur ; cur = 0 ; digit_cnt = 0 ; } else { return JNI_FALSE ; } } c ++ ; continue ; } if ( ( * c < ' ' ) || ( * c > ' ' ) ) { return JNI_FALSE ; } digit_cnt ++ ; if ( digit_cnt > 3 ) { return JNI_FALSE ; } cur = cur * 10 + ( * c - ' ' ) ; c ++ ; if ( * c == ' \0 ' ) { if ( octets < 4 ) { addrp [ octets ++ ] = cur ; } else { return JNI_FALSE ; } } } return ( jboolean ) ( octets == 4 ) ; }
Returns true if hostname is in dotted IP address format.
Returns true if hostname is in dotted IP address format .
/* don't check if current octet > 255 */ /* Move onto next character and check for EOF */