*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->NetBSD man pages -> bitmask_snprintf (9)              



NAME    [Toc]    [Back]

     bitmask_snprintf - bitmask output conversion

SYNOPSIS    [Toc]    [Back]

     #include <sys/systm.h>

     bitmask_snprintf(u_quad_t val, const char *fmt, char *buf,
             size_t buflen);

DESCRIPTION    [Toc]    [Back]

     The bitmask_snprintf() function formats a bitmask into a mnemonic form
     suitable for printing.

     This conversion is useful for decoding bit fields in device registers.
     It formats the integer val into the buffer buf, of size buflen, using a
     specified radix and an interpretation of the bits within that integer as
     though they were flags.

     The decoding directive string fmt describes how the bitfield is to be
     interpreted and displayed.  The first character of fmt is a binary character
 representation of the output numeral base in which the bitfield
     will be printed before it is decoded.  Recognized radix values (in C
     escape-character format) are \10 (octal), \12 (decimal), and \20

     The remaining characters in fmt are interpreted as a list of bit-position-description
 pairs.  A bit-position-description pair begins with a
     binary character value that represents the position of the bit being
     described.  A bit position value of one describes the least significant
     bit.  Whereas a position value of 32 (octal 40, hexadecimal 20, the ASCII
     space character) describes the most significant bit.

     The remaining characters in a bit-position-description pair are the characters
 to print should the bit being described be set.  Description
     strings are delimited by the next bit position value character encountered
 (distinguishable by its value being <= 32), or the end of the
     decoding directive string itself.

RETURN VALUES    [Toc]    [Back]

     The bitmask_snprintf() function returns the buffer buf.  The returned
     string is always NULL-terminated.

EXAMPLES    [Toc]    [Back]

     Two examples of the old formatting style:

           bitmask_snprintf(3, "\10\2BITTWO\1BITONE", buf, buflen)
           => "3<BITTWO,BITONE>"

                   buf, buflen)

ERRORS    [Toc]    [Back]

     If the buffer buf is too small to hold the formatted output,
     bitmask_snprintf() will still return the buffer, containing a truncated

SEE ALSO    [Toc]    [Back]


CODE REFERENCES    [Toc]    [Back]


HISTORY    [Toc]    [Back]

     The bitmask_snprintf() function was originally implemented as a non-standard
 %b format string for the kernel printf() function in NetBSD 1.5 and
     earlier releases.

BUGS    [Toc]    [Back]

     bitmask_snprintf() supports a new extended form of formatting string,
     which is not yet described here.

BSD                              July 28, 2000                             BSD
[ Back ]
 Similar pages
Name OS Title
fprintf FreeBSD formatted output conversion
printf OpenBSD formatted output conversion
snprintf NetBSD formatted output conversion
snprintf OpenBSD formatted output conversion
sprintf NetBSD formatted output conversion
vsnprintf NetBSD formatted output conversion
vasprintf NetBSD formatted output conversion
vfprintf NetBSD formatted output conversion
vasprintf OpenBSD formatted output conversion
vfprintf OpenBSD formatted output conversion
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service