3.5   Other Formatted I/O

3.5.1   Special Cases: printf( ), sprintf( ), and sscanf( )

The routines printf( ), sprintf( ), and sscanf( ) are generally considered to be part of the standard stdio package. However, the VxWorks implementation of these routines, while functionally the same, does not use the stdio package. Instead, it uses a self-contained, formatted, non-buffered interface to the I/O system in the library fioLib. Note that these routines provide the functionality specified by ANSI; however, printf( ) is not buffered.

Because these routines are implemented in this way, the full stdio package, which is optional, can be omitted from a VxWorks configuration without sacrificing their availability. Applications requiring printf-style output that is buffered can still accomplish this by calling fprintf( ) explicitly to stdout.

While sscanf( ) is implemented in fioLib and can be used even if stdio is omitted, the same is not true of scanf( ), which is implemented in the usual way in stdio.

3.5.2   Additional Routines: printErr( ) and fdprintf( )

Additional routines in fioLib provide formatted but unbuffered output. The routine printErr( ) is analogous to printf( ) but outputs formatted strings to the standard error fd (2). The routine fdprintf( ) outputs formatted strings to a specified fd.

3.5.3   Message Logging

Another higher-level I/O facility is provided by the library logLib, which allows formatted messages to be logged without having to do I/O in the current task's context, or when there is no task context. The message format and parameters are sent on a message queue to a logging task, which then formats and outputs the message. This is useful when messages must be logged from interrupt level, or when it is desirable not to delay the current task for I/O or use the current task's stack for message formatting (which can take up significant stack space). The message is displayed on the console unless otherwise redirected at system startup using logInit( ) or dynamically using logFdSet( ).