FreeBSD/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
/*
 * Given a comma-separated list of properties, construct a property list
 * containing both user-defined and native properties.  This function will
 * return a NULL list if 'all' is specified, which can later be expanded
 * by zprop_expand_list().
 */
Given a comma-separated list of properties, construct a property list
containing both user-defined and native properties.  This function will
return a NULL list if 'all' is specified, which can later be expanded
by zprop_expand_list().
Given a comma - separated list of properties construct a property list containing both user - defined and native properties . This function will return a NULL list if ' all ' is specified which can later be expanded by zprop_expand_list () .
int
zprop_get_list(libzfs_handle_t *hdl, char *props, zprop_list_t **listp,
    zfs_type_t type)
{
	*listp = NULL;
	if (strcmp(props, "all") == 0)
		return (0);
	if (props[0] == '\0') {
		zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
		    "no properties specified"));
		return (zfs_error(hdl, EZFS_BADPROP, dgettext(TEXT_DOMAIN,
		    "bad property list")));
	}
	while (*props != '\0') {
		size_t len;
		char *p;
		char c;
		if ((p = strchr(props, ',')) == NULL) {
			len = strlen(props);
			p = props + len;
		} else {
			len = p - props;
		}
		if (len == 0) {
			zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
			    "empty property name"));
			return (zfs_error(hdl, EZFS_BADPROP,
			    dgettext(TEXT_DOMAIN, "bad property list")));
		}
		c = props[len];
		props[len] = '\0';
		if (strcmp(props, "space") == 0) {
			static char *spaceprops[] = {
				"name", "avail", "used", "usedbysnapshots",
				"usedbydataset", "usedbyrefreservation",
				"usedbychildren", NULL
			};
			int i;
			for (i = 0; spaceprops[i]; i++) {
				if (addlist(hdl, spaceprops[i], listp, type))
					return (-1);
				listp = &(*listp)->pl_next;
			}
		} else {
			if (addlist(hdl, props, listp, type))
				return (-1);
			listp = &(*listp)->pl_next;
		}
		props = p;
		if (c == ',')
			props++;
	}
	return (0);
}
int zprop_get_list ( libzfs_handle_t * hdl , char * props , zprop_list_t * * listp , zfs_type_t type ) { * listp = NULL ; if ( strcmp ( props , " " ) == 0 ) return ( 0 ) ; if ( props [ 0 ] == ' \0 ' ) { zfs_error_aux ( hdl , dgettext ( TEXT_DOMAIN , " " ) ) ; return ( zfs_error ( hdl , EZFS_BADPROP , dgettext ( TEXT_DOMAIN , " " ) ) ) ; } while ( * props != ' \0 ' ) { size_t len ; char * p ; char c ; if ( ( p = strchr ( props , ' ' ) ) == NULL ) { len = strlen ( props ) ; p = props + len ; } else { len = p - props ; } if ( len == 0 ) { zfs_error_aux ( hdl , dgettext ( TEXT_DOMAIN , " " ) ) ; return ( zfs_error ( hdl , EZFS_BADPROP , dgettext ( TEXT_DOMAIN , " " ) ) ) ; } c = props [ len ] ; props [ len ] = ' \0 ' ; if ( strcmp ( props , " " ) == 0 ) { static char * spaceprops [ ] = { " " , " " , " " , " " , " " , " " , " " , NULL } ; int i ; for ( i = 0 ; spaceprops [ i ] ; i ++ ) { if ( addlist ( hdl , spaceprops [ i ] , listp , type ) ) return ( -1 ) ; listp = & ( * listp ) -> pl_next ; } } else { if ( addlist ( hdl , props , listp , type ) ) return ( -1 ) ; listp = & ( * listp ) -> pl_next ; } props = p ; if ( c == ' ' ) props ++ ; } return ( 0 ) ; }
Given a comma-separated list of properties, construct a property list
 containing both user-defined and native properties.
Given a comma - separated list of properties construct a property list containing both user - defined and native properties .
/*
	 * If 'all' is specified, return a NULL list.
	 */ /*
	 * If no props were specified, return an error.
	 */ /*
	 * It would be nice to use getsubopt() here, but the inclusion of column
	 * aliases makes this more effort than it's worth.
	 */ /*
		 * Check for empty options.
		 */ /*
		 * Check all regular property names.
		 */