stdio.h File Reference

#include <stdint.h>
#include <stdarg.h>

Go to the source code of this file.

Defines

#define sprintf(buf, fmt,...)   snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )
 Write a formatted string to a buffer.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
int __attribute__ ((format(printf, 1, 2))) printf(const char *fmt
int int __attribute__ ((format(printf, 3, 4))) snprintf(char *buf
int int size_t const char int __attribute__ ((format(printf, 2, 3))) asprintf(char **strp
int int size_t const char int
const char int 
vprintf (const char *fmt, va_list args)
 Write a formatted string to the console.
int vsnprintf (char *buf, size_t size, const char *fmt, va_list args)
 Write a formatted string to a buffer.
int vasprintf (char **strp, const char *fmt, va_list args)
 Write a formatted string to newly allocated memory.
static int vsprintf (char *buf, const char *fmt, va_list args)
 Write a formatted string to a buffer.

Variables

int int size_t size
int int size_t const char * fmt


Define Documentation

#define sprintf ( buf,
fmt,
...   )     snprintf ( (buf), ~( ( size_t ) 0 ), (fmt), ## __VA_ARGS__ )

Write a formatted string to a buffer.

Parameters:
buf Buffer into which to write the string
fmt Format string
... Arguments corresponding to the format string
Return values:
len Length of formatted string

Definition at line 32 of file stdio.h.

Referenced by eth_ntoa(), imgfill_cmdline(), inet6_ntoa(), inet_ntoa(), isa_id_string(), and uuid_ntoa().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

int __attribute__ ( (format(printf, 1, 2))   )  const

int int __attribute__ ( (format(printf, 3, 4))   ) 

int int size_t const char int __attribute__ ( (format(printf, 2, 3))   ) 

Type Constraints

int int size_t const char int const char int vprintf ( const char *  fmt,
va_list  args 
)

Write a formatted string to the console.

Parameters:
fmt Format string
args Arguments corresponding to the format string
Return values:
len Length of formatted string
Type Constraints

Definition at line 400 of file vsprintf.c.

References printf_context::handler, printf_putchar(), and vcprintf().

Referenced by printf().

00400                                               {
00401         struct printf_context ctx;
00402 
00403         /* Hand off to vcprintf */
00404         ctx.handler = printf_putchar;   
00405         return vcprintf ( &ctx, fmt, args );    
00406 }

int vsnprintf ( char *  buf,
size_t  size,
const char *  fmt,
va_list  args 
)

Write a formatted string to a buffer.

Parameters:
buf Buffer into which to write the string
size Size of buffer
fmt Format string
args Arguments corresponding to the format string
Return values:
len Length of formatted string
If the buffer is too small to contain the string, the returned length is the length that would have been written had enough space been available.

Definition at line 302 of file vsprintf.c.

References sputc_context::buf, sputc_context::ctx, printf_context::handler, sputc_context::max_len, printf_sputc(), and vcprintf().

Referenced by snprintf(), vasprintf(), vmsg(), vsprintf(), vssnprintf(), and xfer_vprintf().

00302                                                                         {
00303         struct sputc_context sctx;
00304         size_t len;
00305         size_t end;
00306 
00307         /* Hand off to vcprintf */
00308         sctx.ctx.handler = printf_sputc;
00309         sctx.buf = buf;
00310         sctx.max_len = size;
00311         len = vcprintf ( &sctx.ctx, fmt, args );
00312 
00313         /* Add trailing NUL */
00314         if ( size ) {
00315                 end = size - 1;
00316                 if ( len < end )
00317                         end = len;
00318                 buf[end] = '\0';
00319         }
00320 
00321         return len;
00322 }

int vasprintf ( char **  strp,
const char *  fmt,
va_list  args 
)

Write a formatted string to newly allocated memory.

Parameters:
strp Pointer to hold allocated string
fmt Format string
args Arguments corresponding to the format string
Return values:
len Length of formatted string

Definition at line 17 of file asprintf.c.

References ENOMEM, malloc(), NULL, va_copy, va_end, and vsnprintf().

Referenced by asprintf().

00017                                                              {
00018         size_t len;
00019         va_list args_tmp;
00020 
00021         /* Calculate length needed for string */
00022         va_copy ( args_tmp, args );
00023         len = ( vsnprintf ( NULL, 0, fmt, args_tmp ) + 1 );
00024         va_end ( args_tmp );
00025 
00026         /* Allocate and fill string */
00027         *strp = malloc ( len );
00028         if ( ! *strp )
00029                 return -ENOMEM;
00030         return vsnprintf ( *strp, len, fmt, args );
00031 }

static int vsprintf ( char *  buf,
const char *  fmt,
va_list  args 
) [inline, static]

Write a formatted string to a buffer.

Parameters:
buf Buffer into which to write the string
fmt Format string
args Arguments corresponding to the format string
Return values:
len Length of formatted string

Definition at line 43 of file stdio.h.

References vsnprintf().

00043                                                                         {
00044         return vsnprintf ( buf, ~( ( size_t ) 0 ), fmt, args );
00045 }


Variable Documentation

int int size_t size

int int size_t const char int const char* fmt

Definition at line 13 of file stdio.h.


Generated on Tue Apr 6 20:01:53 2010 for gPXE by  doxygen 1.5.7.1