Character Streams

Collaboration diagram for Character Streams:

Data Structures

struct  stream
 A generic byte stream. More...

Modules

 Character Stream Implementation
 Debug Console

Functions

int stream_putstr (struct stream *stream, const char *str)
 Write a string to a stream.
int stream_putchar (struct stream *stream, int c)
 Write a single character to a stream.
int stream_vprintf (struct stream *stream, const char *format, va_list ap)
 Formatted output conversion to a stream.
int stream_printf (struct stream *stream, const char *format,...)
 Formatted output conversion.

Detailed Description

A character stream is a FIFO queue of characters. At the front end, characters are inserted into the queue (the stream buffer), while at the back end, characters are extracted from the queue and usually processed in some way (e.g. sent to a hardware device).

The helper functions defined in this module ensure that the stream backend driver is notified when new data is inserted into the buffer, and they also wait for the backend to process some of the data when the buffer becomes too full to insert all the requested data.


Function Documentation

int stream_printf ( struct stream stream,
const char *  format,
  ... 
)

Formatted output conversion.

This is simply a convenience wrapper around stream_vprintf() taking a variable number of arguments.

int stream_putchar ( struct stream stream,
int  c 
)

Write a single character to a stream.

Parameters:
stream The stream to which the output is to be sent
c The character to write.
Returns:
c as an unsigned char cast to an int.
int int stream_putstr ( struct stream stream,
const char *  str 
)

Write a string to a stream.

Parameters:
stream The stream to which the output is to be sent
str NUL-terminated string.
Returns:
The number of characters written.
int stream_vprintf ( struct stream stream,
const char *  format,
va_list  ap 
)

Formatted output conversion to a stream.

Produce output according to format to the given stream. format is interpreted as a regular printf()-style format string with a few limitations (some specifiers are accepted but ignored.)

Parameters:
stream The stream to which the output is to be sent
format Format specification.
ap Format arguments as a vararg list.
Returns:
The number of characters sent to stream. If stream signals that it cannot accept any more characters at some point, the return value indicates the number of characters that would have been sent if stream had accepted them.

Referenced by snprintf(), and sprintf().

Generated on Thu Apr 29 15:18:23 2010 for display-training by  doxygen 1.6.3