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

  man pages->OpenBSD man pages -> vsnprintf (9)              



NAME    [Toc]    [Back]

     printf, snprintf, vprintf,  vsnprintf,  uprintf,  ttyprintf,
db_printf -
     kernel formatted output conversion

SYNOPSIS    [Toc]    [Back]

     #include <sys/types.h>
     #include <sys/systm.h>

     printf(const char *format, ...);

     snprintf(char *buf, size_t size, const char *format, ...);

     vprintf(const char *format, va_list ap);

     vsnprintf(char  *buf,  size_t size, const char *fmt, va_list

     uprintf(const char *format, ...);

     ttyprintf(struct tty *tty, const char *format, ...);

     db_printf(const char *format, ...);

DESCRIPTION    [Toc]    [Back]

     The printf(), snprintf(), vprintf(), vsnprintf(), uprintf(),
     and db_printf() functions allow the kernel to send formatted
messages to
     various  output  devices.   The   functions   printf()   and
vprintf() send formatted
  strings to the system console and to the system log.
The functions
 uprintf() and ttyprintf() send  formatted  strings  to
the current
     process's  controlling tty and a specific tty, respectively.
The function
     db_printf() sends formatted strings to the ddb console,  and
is only used
     to implement ddb(4).

     Since each of these kernel functions is a variant of its user space counterpart,
 this page describes only  the  differences  between
the user space
     and  kernel versions.  Refer to printf(3) for functional details.

   FORMAT OPTIONS    [Toc]    [Back]
     The kernel functions don't support any floating  point  formatting specifiers.
   In  addition  to other formatting specifiers common
with the user
     space functions, the kernel functions accept  the  following
format specifiers
 in the format string format:

     %b     Bit field expansion.  This format specifier is useful
for decoding
           bit fields in device registers.  It displays an  integer using a
           specified  radix  (base)  and an interpretation of the
bits within
           that integer as though they were flags.   It  requires
two arguments
           from the argument vector, the first argument being the
bit field to
           be decoded (as an integer) and the second being a  decoding directive

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

           The remaining characters  in  the  decoding  directive
string 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
           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.

     %r    Displays an integer using the current DDB radix.  This
           interpretation of %r is only available to db_printf().

     %z    Displays a signed integer using the C-style  hexadecimal constant
           format.   This  format  specifier is only available to

RETURN VALUES    [Toc]    [Back]

     The printf(), snprintf(), vprintf(), and  vsnprintf()  functions return the
     number of characters they placed in the buffer buf.

EXAMPLES    [Toc]    [Back]

     Use  of  the  %b format specifier for decoding device registers.

           printf("reg=%b0, 3, "102BITTWO1BITONE")
           => "reg=3<BITTWO,BITONE>"

           printf("enablereg=%b0, 0xe860,
           =>   "enablereg=e860<NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE>"

SEE ALSO    [Toc]    [Back]

     revoke(2), printf(3), ddb(4), log(9)

CODE REFERENCES    [Toc]    [Back]


LIMITATIONS    [Toc]    [Back]

     The  %b  format  specifier cannot be used to decode integers
greater than 32
     bits in size.

OpenBSD     3.6                        September     1,      1998
[ Back ]
 Similar pages
Name OS Title
vsnprintf NetBSD formatted output conversion
vprintf FreeBSD formatted output conversion
fprintf OpenBSD formatted output conversion
vfprintf FreeBSD formatted output conversion
asprintf FreeBSD formatted output conversion
vasprintf FreeBSD formatted output conversion
uprintf FreeBSD formatted output conversion
tprintf FreeBSD formatted output conversion
asprintf OpenBSD formatted output conversion
snprintf FreeBSD formatted output conversion
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service