busybox-1.32.0/networking/httpd.c
static int scan_ip(const char **strp, unsigned *ipp, unsigned char endc)
{
	const char *p = *strp;
	int auto_mask = 8;
	unsigned ip = 0;
	int j;

	if (*p == '/')
		return -auto_mask;

	for (j = 0; j < 4; j++) {
		unsigned octet;

		if ((*p < '0' || *p > '9') && *p != '/' && *p)
			return -auto_mask;
		octet = 0;
		while (*p >= '0' && *p <= '9') {
			octet *= 10;
			octet += *p - '0';
			if (octet > 255)
				return -auto_mask;
			p++;
		}
		if (*p == '.')
			p++;
		if (*p != '/' && *p)
			auto_mask += 8;
		ip = (ip << 8) | octet;
	}
	if (*p) {
		if (*p != endc)
			return -auto_mask;
		p++;
		if (*p == '\0')
			return -auto_mask;
	}
	*ipp = ip;
	*strp = p;
	return auto_mask;
}
/* Returns presumed mask width in bits or < 0 on error.
 * Updates strp, stores IP at provided pointer */
Returns presumed mask width in bits or < 0 on error.
Updates strp, stores IP at provided pointer
Returns presumed mask width in bits or < 0 on error . Updates strp stores IP at provided pointer
static int scan_ip(const char **strp, unsigned *ipp, unsigned char endc)
{
	const char *p = *strp;
	int auto_mask = 8;
	unsigned ip = 0;
	int j;
	if (*p == '/')
		return -auto_mask;
	for (j = 0; j < 4; j++) {
		unsigned octet;
		if ((*p < '0' || *p > '9') && *p != '/' && *p)
			return -auto_mask;
		octet = 0;
		while (*p >= '0' && *p <= '9') {
			octet *= 10;
			octet += *p - '0';
			if (octet > 255)
				return -auto_mask;
			p++;
		}
		if (*p == '.')
			p++;
		if (*p != '/' && *p)
			auto_mask += 8;
		ip = (ip << 8) | octet;
	}
	if (*p) {
		if (*p != endc)
			return -auto_mask;
		p++;
		if (*p == '\0')
			return -auto_mask;
	}
	*ipp = ip;
	*strp = p;
	return auto_mask;
}
static int scan_ip ( const char * * strp , unsigned * ipp , unsigned char endc ) { const char * p = * strp ; int auto_mask = 8 ; unsigned ip = 0 ; int j ; if ( * p == ' ' ) return - auto_mask ; for ( j = 0 ; j < 4 ; j ++ ) { unsigned octet ; if ( ( * p < ' ' || * p > ' ' ) && * p != ' ' && * p ) return - auto_mask ; octet = 0 ; while ( * p >= ' ' && * p <= ' ' ) { octet *= 10 ; octet += * p - ' ' ; if ( octet > 255 ) return - auto_mask ; p ++ ; } if ( * p == ' ' ) p ++ ; if ( * p != ' ' && * p ) auto_mask += 8 ; ip = ( ip << 8 ) | octet ; } if ( * p ) { if ( * p != endc ) return - auto_mask ; p ++ ; if ( * p == ' \0 ' ) return - auto_mask ; } * ipp = ip ; * strp = p ; return auto_mask ; }
Returns presumed mask width in bits or < 0 on error.
Returns presumed mask width in bits or < 0 on error .