util/stream/stream_string.c File Reference

Generic stream formatted print implementation. More...

#include <util.h>
#include <string.h>
#include <stream.h>
#include <compiler.h>

Go to the source code of this file.

Data Structures

struct  string_stream
 string stream object to convert from a string buffer to a struct stream object. More...

Defines

#define BUFFER_STREAM_BUFFER_SIZE   32
 Internal string stream buffer.

Functions

static struct string_streamstring_stream_of (struct stream *s)
 Return the buffer stream containing the stream s.
static void snprintf_stream_commit (struct stream *s)
static void sprintf_stream_commit (struct stream *s)
static bool string_stream_make_room (struct stream *s, unsigned int goal)
int snprintf (char *str, size_t size, const char *format,...)
 Streamed formatted size limited output conversion.
int sprintf (char *str, const char *format,...)
 Streamed formatted output conversion.

Detailed Description

Generic stream formatted print implementation.

Copyright (C) 2010 Atmel Corporation. All rights reserved.

Definition in file stream_string.c.


Define Documentation

#define BUFFER_STREAM_BUFFER_SIZE   32

Internal string stream buffer.

For internal use only.

Definition at line 47 of file stream_string.c.

Referenced by snprintf(), and sprintf().


Function Documentation

int snprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

Streamed formatted size limited output conversion.

This is simply a convenience wrapper around stream_printf(), which will translate a character buffer in memory into a stream object. It will at most write size bytes to the str buffer from the format stream, and it does also take a variable number of arguments.

Definition at line 152 of file stream_string.c.

References string_stream::buffer, BUFFER_STREAM_BUFFER_SIZE, stream::data, memset(), string_stream::offset, string_stream::stream, and stream_vprintf().

Referenced by calc_update_display(), memgame_print_tries(), screen_draw_file_list_from_index(), screen_draw_file_system_info(), and string_file_size().

static void snprintf_stream_commit ( struct stream s  )  [static]
int sprintf ( char *  str,
const char *  format,
  ... 
)

Streamed formatted output conversion.

This is simply a convenience wrapper around stream_printf(), which will translate a character buffer in memory into a stream object. It will write to the str buffer from the format stream until it reaches the null byte terminator, hence the user must be careful to avoid buffer overflow. It does also take a variable number of arguments.

Definition at line 196 of file stream_string.c.

References string_stream::buffer, BUFFER_STREAM_BUFFER_SIZE, stream::data, memset(), string_stream::offset, string_stream::stream, and stream_vprintf().

static void sprintf_stream_commit ( struct stream s  )  [static]
static bool string_stream_make_room ( struct stream s,
unsigned int  goal 
) [static]

For internal use only.

See also:
stream_ops::make_room

Definition at line 128 of file stream_string.c.

References stream_ops::commit, and stream::ops.

static struct string_stream* string_stream_of ( struct stream s  )  [static, read]

Return the buffer stream containing the stream s.

For internal use only.

Definition at line 71 of file stream_string.c.

References container_of.

Referenced by snprintf_stream_commit(), and sprintf_stream_commit().

Generated on Thu Apr 29 14:09:58 2010 for display-demo by  doxygen 1.6.3