FreeBSD/usr.sbin/ifmcstat/printb.c
/*
 * Print a value a la the %b format of the kernel's printf
 */
Print a value a la the %b format of the kernel's printf
Print a value a la the %b format of the kernel ' s printf
void
printb(const char *s, unsigned int v, const char *bits)
{
	int i, any = 0;
	char c;
	if (bits && *bits == 8)
		printf("%s=%o", s, v);
	else
		printf("%s=%x", s, v);
	bits++;
	if (bits) {
		putchar('<');
		while ((i = *bits++) != '\0') {
			if (v & (1 << (i-1))) {
				if (any)
					putchar(',');
				any = 1;
				for (; (c = *bits) > 32; bits++)
					putchar(c);
			} else
				for (; *bits > 32; bits++)
					;
		}
		putchar('>');
	}
}
void printb ( const char * s , unsigned int v , const char * bits ) { int i , any = 0 ; char c ; if ( bits && * bits == 8 ) printf ( " " , s , v ) ; else printf ( " " , s , v ) ; bits ++ ; if ( bits ) { putchar ( ' ' ) ; while ( ( i = * bits ++ ) != ' \0 ' ) { if ( v & ( 1 << ( i - 1 ) ) ) { if ( any ) putchar ( ' ' ) ; any = 1 ; for ( ; ( c = * bits ) > 32 ; bits ++ ) putchar ( c ) ; } else for ( ; * bits > 32 ; bits ++ ) ; } putchar ( ' ' ) ; } }
Print a value a la the %b format of the kernel's printf
Print a value a la the %b format of the kernel ' s printf