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

  man pages->FreeBSD man pages -> printf (9)              
Title
Content
Arch
Section
 

PRINTF(9)

Contents


NAME    [Toc]    [Back]

     printf, uprintf, tprintf -- formatted output conversion

SYNOPSIS    [Toc]    [Back]

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

     int
     printf(const char *fmt, ...);

     void
     tprintf(struct proc *p, int pri, const char *fmt, ...);

     int
     uprintf(const char *fmt, ...);

DESCRIPTION    [Toc]    [Back]

     The printf(9) family of functions are similar to the printf(3) family of
     functions.  The three functions each use a different output stream.  The
     uprintf() function outputs to the current process' controlling tty, while
     printf() writes to the console as well as to the logging facility.  The
     tprintf() function outputs to the tty associated with the process p and
     the logging facility if pri is not -1.

     Each of these related functions use the fmt parameter in the same manner
     as printf(3).  However, printf(9) adds two other conversion specifiers.

     The %b identifier expects two arguments: an int and a char *.  These are
     used as a register value and a print mask for decoding bitmasks.  The
     print mask is made up of two parts: the base and the arguments.  The base
     value is the output base expressed as an integer value; for example, \10
     gives octal and \20 gives hexadecimal.  The arguments are made up of a
     sequence of bit identifiers.  Each bit identifier begins with an integer
     value which is the number of the bit this identifier describes.  The rest
     of the identifier is a string of characters containing the name of the
     bit.  The string is terminated by either the bit number at the start of
     the next bit identifier or NUL for the last bit identifier.

     The %D identifier is meant to assist in hexdumps.	It requires two arguments:
 a u_char * pointer and a char * string.  The memory pointed to be
     the pointer is output in hexadecimal one byte at a time.  The string is
     used as a delimiter between individual bytes.  If present, a width directive
 will specify the number of bytes to display.	By default, 16 bytes
     of data are output.

RETURN VALUES    [Toc]    [Back]

     The printf() and the uprintf() functions return the number of characters
     displayed.

EXAMPLES    [Toc]    [Back]

     This example demonstrates the use of the %b and %D conversion specifiers.
     The function

	   void
	   printf_test(void)
	   {

		   printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
		   printf("out: %4D\n", "AAAA", ":");
	   }

     will produce the following output:

	   reg=3<BITTWO,BITONE>
	   out: 41:41:41:41

SEE ALSO    [Toc]    [Back]

      
      
     printf(3)


FreeBSD 5.2.1			April 25, 2001			 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
tprintf NetBSD kernel formatted output conversion
kprintf NetBSD kernel formatted output conversion
printf NetBSD kernel formatted output conversion
sprintf NetBSD kernel formatted output conversion
vprintf NetBSD kernel formatted output conversion
tprintf_close NetBSD kernel formatted output conversion
tprintf_open NetBSD kernel formatted output conversion
ttyprintf NetBSD kernel formatted output conversion
vsprintf NetBSD kernel formatted output conversion
uprintf NetBSD kernel formatted output conversion
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service