DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SCO OpenServer

printf(D3oddi)


printf -- print a message on the console

Synopsis (Not recommended for current drivers)

int printf(char *format[, arg] ...);

Description

The kernel printf( ) function prints error messages and debugging information on the system console. In addition, all messages are stored in the /usr/adm/messages file by a background program error handler. printf(D3oddi) is a simplified version of the standard C library printf(S) routine.

Arguments

The format parameter is a string to be displayed similar to the format argument to printf(S). format also accepts specifications for displaying the arg variables. The supported specifications are:

Type Description
%b two-digit hexadecimal byte
%c character
%d signed decimal
%o unsigned octal
%s string (character pointer)
%u unsigned decimal
%x hexadecimal (prints leading zeros)

 Type   Description
 %b     two-digit hexadecimal byte
 %c     character
 %d     signed decimal
 %o     unsigned octal
 %s     string (character pointer)
 %u     unsigned decimal
 %x     hexadecimal (prints leading zeros)
Specification values can be indicated in either uppercase or lowercase. Field length specifications cannot be used, but it is possible to specify precision. For example, ``%9d'' would set the minimum number of digits to be printed for a signed decimal to nine. Escaped characters such as \n (new line), \t (tab), \r (return), and so on are C language features supported by the C compiler and thus are supported in this kernel routine.

Any optional arg parameters are displayed using the format parameter.

Return values

None.

Usage

The printf routine is not interrupt-driven and therefore suspends all other system activities while executing.

It is similar to the standard C library function printf(S), except that only the formats specified here are valid, and precision is not supported.

It does not function properly on consoles running layers(C). As it is impossible for a driver to know if a console is running layers, use of printf(D3oddi) for other than debug purposes is not recommended. Use cmn_err(D3oddi) instead.

Context and synchronization

All contexts.

Hardware applicability

All

Version applicability

oddi: 1

Differences between versions

SCO OpenServer ODDI drivers should use the cmn_err(D3oddi) function instead of calling printf( ).

References

cmn_err(D3oddi), layers(C), printf(S)

``Error handling'' in HDK Technical Reference

Examples

It is often useful to use printf for driver debug statements. For example in your xxioctl routine you might do the following:
   xxioctl(dev, cmd, arg, mode)
   dev_t dev;
   int cmd, arg, mode;
   {
       printf("dev= %x, cmd= %d, addr of arg= %x, mode= %x\n",
               dev, cmd, arg, mode);
   }

19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005