FreeBSD/sys/kern/subr_bus.c
/**
 * @brief Print a description of resources in a resource list
 *
 * Print all resources of a specified type, for use in BUS_PRINT_CHILD().
 * The name is printed if at least one resource of the given type is available.
 * The format is used to print resource start and end.
 *
 * @param rl		the resource list to print
 * @param name		the name of @p type, e.g. @c "memory"
 * @param type		type type of resource entry to print
 * @param format	printf(9) format string to print resource
 *			start and end values
 *
 * @returns		the number of characters printed
 */
@brief Print a description of resources in a resource list
Print all resources of a specified type, for use in BUS_PRINT_CHILD().
The name is printed if at least one resource of the given type is available.
The format is used to print resource start and end.

@param rl            the resource list to print
@param name          the name of @p type, e.g. @c "memory"
@param type          type type of resource entry to print
@param format        printf(9) format string to print resource
start and end values

@returns             the number of characters printed
@brief Print a description of resources in a resource list Print all resources of a specified type for use in BUS_PRINT_CHILD () . The name is printed if at least one resource of the given type is available . The format is used to print resource start and end . @param rl the resource list to print @param name the name of @p type e . g . @c " memory " @param type type type of resource entry to print @param format printf ( 9 ) format string to print resource start and end values @returns the number of characters printed
int
resource_list_print_type(struct resource_list *rl, const char *name, int type,
    const char *format)
{
	struct resource_list_entry *rle;
	int printed, retval;
	printed = 0;
	retval = 0;
	STAILQ_FOREACH(rle, rl, link) {
		if (rle->type == type) {
			if (printed == 0)
				retval += printf(" %s ", name);
			else
				retval += printf(",");
			printed++;
			retval += printf(format, rle->start);
			if (rle->count > 1) {
				retval += printf("-");
				retval += printf(format, rle->start +
						 rle->count - 1);
			}
		}
	}
	return (retval);
}
int resource_list_print_type ( struct resource_list * rl , const char * name , int type , const char * format ) { struct resource_list_entry * rle ; int printed , retval ; printed = 0 ; retval = 0 ; STAILQ_FOREACH ( rle , rl , link ) { if ( rle -> type == type ) { if ( printed == 0 ) retval += printf ( " " , name ) ; else retval += printf ( " " ) ; printed ++ ; retval += printf ( format , rle -> start ) ; if ( rle -> count > 1 ) { retval += printf ( " " ) ; retval += printf ( format , rle -> start + rle -> count - 1 ) ; } } } return ( retval ) ; }
@brief Print a description of resources in a resource list
 Print all resources of a specified type, for use in BUS_PRINT_CHILD().
@brief Print a description of resources in a resource list Print all resources of a specified type for use in BUS_PRINT_CHILD () .
/* Yes, this is kinda cheating */