FreeBSD/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
/*
 * Given a numeric suffix, convert the value into a number of bits that the
 * resulting value must be shifted.
 */
Given a numeric suffix, convert the value into a number of bits that the
resulting value must be shifted.
Given a numeric suffix convert the value into a number of bits that the resulting value must be shifted .
static int
str2shift(libzfs_handle_t *hdl, const char *buf)
{
	const char *ends = "BKMGTPEZ";
	int i;
	if (buf[0] == '\0')
		return (0);
	for (i = 0; i < strlen(ends); i++) {
		if (toupper(buf[0]) == ends[i])
			break;
	}
	if (i == strlen(ends)) {
		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
		    "invalid numeric suffix '%s'"), buf);
		return (-1);
	}
	if (buf[1] == '\0' || (toupper(buf[1]) == 'B' && buf[2] == '\0' &&
	    toupper(buf[0]) != 'B'))
		return (10*i);
	zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
	    "invalid numeric suffix '%s'"), buf);
	return (-1);
}
static int str2shift ( libzfs_handle_t * hdl , const char * buf ) { const char * ends = " " ; int i ; if ( buf [ 0 ] == ' \0 ' ) return ( 0 ) ; for ( i = 0 ; i < strlen ( ends ) ; i ++ ) { if ( toupper ( buf [ 0 ] ) == ends [ i ] ) break ; } if ( i == strlen ( ends ) ) { zfs_error_aux ( hdl , dgettext ( TEXT_DOMAIN , " " ) , buf ) ; return ( -1 ) ; } if ( buf [ 1 ] == ' \0 ' || ( toupper ( buf [ 1 ] ) == ' ' && buf [ 2 ] == ' \0 ' && toupper ( buf [ 0 ] ) != ' ' ) ) return ( 10 * i ) ; zfs_error_aux ( hdl , dgettext ( TEXT_DOMAIN , " " ) , buf ) ; return ( -1 ) ; }
Given a numeric suffix, convert the value into a number of bits that the
 resulting value must be shifted.
Given a numeric suffix convert the value into a number of bits that the resulting value must be shifted .
/*
	 * We want to allow trailing 'b' characters for 'GB' or 'Mb'.  But don't
	 * allow 'BB' - that's just weird.
	 */