FreeBSD/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
/*
 * Given a pool and a list of properties, print out all the properties according
 * to the described layout.
 */
Given a pool and a list of properties, print out all the properties according
to the described layout.
Given a pool and a list of properties print out all the properties according to the described layout .
static void
print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
{
	zprop_list_t *pl = cb->cb_proplist;
	boolean_t first = B_TRUE;
	char property[ZPOOL_MAXPROPLEN];
	char *propstr;
	boolean_t right_justify;
	size_t width;
	for (; pl != NULL; pl = pl->pl_next) {
		width = pl->pl_width;
		if (first && cb->cb_verbose) {
			width = cb->cb_namewidth;
		}
		if (!first) {
			if (cb->cb_scripted)
				(void) printf("\t");
			else
				(void) printf("  ");
		} else {
			first = B_FALSE;
		}
		right_justify = B_FALSE;
		if (pl->pl_prop != ZPROP_INVAL) {
			if (zpool_get_prop(zhp, pl->pl_prop, property,
			    sizeof (property), NULL, cb->cb_literal) != 0)
				propstr = "-";
			else
				propstr = property;
			right_justify = zpool_prop_align_right(pl->pl_prop);
		} else if ((zpool_prop_feature(pl->pl_user_prop) ||
		    zpool_prop_unsupported(pl->pl_user_prop)) &&
		    zpool_prop_get_feature(zhp, pl->pl_user_prop, property,
		    sizeof (property)) == 0) {
			propstr = property;
		} else {
			propstr = "-";
		}
		if (cb->cb_scripted || (pl->pl_next == NULL && !right_justify))
			(void) printf("%s", propstr);
		else if (right_justify)
			(void) printf("%*s", width, propstr);
		else
			(void) printf("%-*s", width, propstr);
	}
	(void) printf("\n");
}
static void print_pool ( zpool_handle_t * zhp , list_cbdata_t * cb ) { zprop_list_t * pl = cb -> cb_proplist ; boolean_t first = B_TRUE ; char property [ ZPOOL_MAXPROPLEN ] ; char * propstr ; boolean_t right_justify ; size_t width ; for ( ; pl != NULL ; pl = pl -> pl_next ) { width = pl -> pl_width ; if ( first && cb -> cb_verbose ) { width = cb -> cb_namewidth ; } if ( ! first ) { if ( cb -> cb_scripted ) ( void ) printf ( " \t " ) ; else ( void ) printf ( " " ) ; } else { first = B_FALSE ; } right_justify = B_FALSE ; if ( pl -> pl_prop != ZPROP_INVAL ) { if ( zpool_get_prop ( zhp , pl -> pl_prop , property , sizeof ( property ) , NULL , cb -> cb_literal ) != 0 ) propstr = " " ; else propstr = property ; right_justify = zpool_prop_align_right ( pl -> pl_prop ) ; } else if ( ( zpool_prop_feature ( pl -> pl_user_prop ) || zpool_prop_unsupported ( pl -> pl_user_prop ) ) && zpool_prop_get_feature ( zhp , pl -> pl_user_prop , property , sizeof ( property ) ) == 0 ) { propstr = property ; } else { propstr = " " ; } if ( cb -> cb_scripted || ( pl -> pl_next == NULL && ! right_justify ) ) ( void ) printf ( " " , propstr ) ; else if ( right_justify ) ( void ) printf ( " " , width , propstr ) ; else ( void ) printf ( " " , width , propstr ) ; } ( void ) printf ( " \n " ) ; }
Given a pool and a list of properties, print out all the properties according
 to the described layout.
Given a pool and a list of properties print out all the properties according to the described layout .
/*
			 * Reset the width to accommodate the verbose listing
			 * of devices.
			 */ /*
		 * If this is being called in scripted mode, or if this is the
		 * last column and it is left-justified, don't include a width
		 * format specifier.
		 */