The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Интерактивная система просмотра системных руководств (man-ов)

 [Cписок руководств | Печать]

printf (9)
  • printf (1) ( Solaris man: Команды и прикладные программы пользовательского уровня )
  • printf (1) ( FreeBSD man: Команды и прикладные программы пользовательского уровня )
  • printf (1) ( Русские man: Команды и прикладные программы пользовательского уровня )
  • printf (1) ( Linux man: Команды и прикладные программы пользовательского уровня )
  • printf (1) ( POSIX man: Команды и прикладные программы пользовательского уровня )
  • printf (3) ( Solaris man: Библиотечные вызовы )
  • printf (3) ( FreeBSD man: Библиотечные вызовы )
  • printf (3) ( Русские man: Библиотечные вызовы )
  • printf (3) ( Linux man: Библиотечные вызовы )
  • printf (3) ( POSIX man: Библиотечные вызовы )
  • >> printf (9) ( FreeBSD man: Ядро )

  • BSD mandoc


    printf , uprintf , tprintf, log
     - formatted output conversion


       #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 ...);
       #include <sys/syslog.h>
    void log (int pri const char *fmt ...);


    The printf(9) family of functions are similar to the printf(3) family of functions. The different 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 Fa p and the logging facility if Fa pri is not -1. The log ();
    function sends the message to the kernel logging facility, using the log level as indicated by Fa pri .

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

    The %b identifier expects two arguments: an Vt int and a Vt 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 (starting from 1) 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 Vt u_char * pointer and a Vt 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.

    The log ();
    function uses syslog(3) level values LOG_DEBUG through LOG_EMERG for its Fa pri parameter (mistakenly called `priority' here). Alternatively, if a Fa pri of -1 is given, the message will be appended to the last log message started by a previous call to log (.);
    As these messages are generated by the kernel itself, the facility will always be LOG_KERN  


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


    This example demonstrates the use of the %b and %D conversion specifiers. The function
            printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
            printf("out: %4D\n", "AAAA", ":");

    will produce the following output:

    out: 41:41:41:41

    The call

    log(LOG_DEBUG, "%s%d: been there.\n", sc->sc_name, sc->sc_unit);

    will add the appropriate debug message at priority ``kern.debug '' to the system log.  


    printf(3), syslog(3)




    Поиск по тексту MAN-ов: 

    Inferno Solutions
    Hosting by

    Закладки на сайте
    Проследить за страницей
    Created 1996-2024 by Maxim Chirkov
    Добавить, Поддержать, Вебмастеру