iPXE
Defines | Functions | Variables
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_OR_UBDL)
void putchar (int character)
 Write a single character to each console device.
int getchar (void)
 Read a single character from any console.
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:
bufBuffer into which to write the string
fmtFormat string
...Arguments corresponding to the format string
Return values:
lenLength of formatted string

Definition at line 36 of file stdio.h.

Referenced by bios_ansi_seq(), concat_args(), efi_snp_hii_fetch(), eth_ntoa(), inet6_ntoa(), inet_ntoa(), isa_id_string(), usbkbd_consume(), and uuid_ntoa().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
void putchar ( int  character)

Write a single character to each console device.

Parameters:
characterCharacter to be written

The character is written out to all enabled console devices, using each device's console_driver::putchar() method.

Definition at line 27 of file console.c.

References CONSOLE_DISABLED_OUTPUT, console_usage, CONSOLES, console_driver::disabled, for_each_table_entry, putchar(), console_driver::putchar, and console_driver::usage.

Referenced by ansiscr_putc(), clrline(), eepro_poll(), epic100_open(), falcon_init_xmac(), get_eeprom_data(), int21(), monojob_clear(), print_user_string(), printf_putchar(), putchar(), readline_history(), and sync_console().

                               {
        struct console_driver *console;

        /* Automatic LF -> CR,LF translation */
        if ( character == '\n' )
                putchar ( '\r' );

        for_each_table_entry ( console, CONSOLES ) {
                if ( ( ! ( console->disabled & CONSOLE_DISABLED_OUTPUT ) ) &&
                     ( console_usage & console->usage ) &&
                     console->putchar )
                        console->putchar ( character );
        }
}
int getchar ( void  )

Read a single character from any console.

Return values:
characterCharacter read from a console.

A character will be read from the first enabled console device that has input available using that console's console_driver::getchar() method. If no console has input available to be read, this method will block. To perform a non-blocking read, use something like

   int key = iskey() ? getchar() : -1;

The character read will not be echoed back to any console.

Definition at line 82 of file console.c.

References cpu_nap(), console_driver::getchar, has_input(), and step().

Referenced by ansiscr_getc(), dbg_more(), dbg_pause(), getchar_timeout(), int21(), keypress_interrupted(), loopback_wait(), and monojob_wait().

                     {
        struct console_driver *console;
        int character;

        while ( 1 ) {
                console = has_input();
                if ( console && console->getchar ) {
                        character = console->getchar ();
                        break;
                }

                /* Doze for a while (until the next interrupt).  This works
                 * fine, because the keyboard is interrupt-driven, and the
                 * timer interrupt (approx. every 50msec) takes care of the
                 * serial port, which is read by polling.  This reduces the
                 * power dissipation of a modern CPU considerably, and also
                 * makes Etherboot waiting for user interaction waste a lot
                 * less CPU time in a VMware session.
                 */
                cpu_nap();

                /* Keep processing background tasks while we wait for
                 * input.
                 */
                step();
        }

        /* CR -> LF translation */
        if ( character == '\r' )
                character = '\n';

        return character;
}
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))  )
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:
fmtFormat string
argsArguments corresponding to the format string
Return values:
lenLength of formatted string

Definition at line 449 of file vsprintf.c.

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

Referenced by dbg_printf(), log_vprintf(), and printf().

                                              {
        struct printf_context ctx;

        /* Hand off to vcprintf */
        ctx.handler = printf_putchar;   
        return vcprintf ( &ctx, fmt, args );    
}
int vsnprintf ( char *  buf,
size_t  size,
const char *  fmt,
va_list  args 
)

Write a formatted string to a buffer.

Parameters:
bufBuffer into which to write the string
sizeSize of buffer
fmtFormat string
argsArguments corresponding to the format string
Return values:
lenLength 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 351 of file vsprintf.c.

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

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

                                                                        {
        struct sputc_context sctx;
        size_t len;
        size_t end;

        /* Hand off to vcprintf */
        sctx.ctx.handler = printf_sputc;
        sctx.buf = buf;
        sctx.max_len = size;
        len = vcprintf ( &sctx.ctx, fmt, args );

        /* Add trailing NUL */
        if ( size ) {
                end = size - 1;
                if ( len < end )
                        end = len;
                buf[end] = '\0';
        }

        return len;
}
int vasprintf ( char **  strp,
const char *  fmt,
va_list  args 
)

Write a formatted string to newly allocated memory.

Parameters:
strpPointer to hold allocated string
fmtFormat string
argsArguments corresponding to the format string
Return values:
lenLength of formatted string

Definition at line 17 of file asprintf.c.

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

Referenced by asprintf(), and xfer_vprintf().

                                                             {
        size_t len;
        va_list args_tmp;

        /* Calculate length needed for string */
        va_copy ( args_tmp, args );
        len = ( vsnprintf ( NULL, 0, fmt, args_tmp ) + 1 );
        va_end ( args_tmp );

        /* Allocate and fill string */
        *strp = malloc ( len );
        if ( ! *strp )
                return -ENOMEM;
        return vsnprintf ( *strp, len, fmt, args );
}
static int vsprintf ( char *  buf,
const char *  fmt,
va_list  args 
) [inline, static]

Write a formatted string to a buffer.

Parameters:
bufBuffer into which to write the string
fmtFormat string
argsArguments corresponding to the format string
Return values:
lenLength of formatted string

Definition at line 47 of file stdio.h.

References vsnprintf().

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

Variable Documentation

int int size_t size

Definition at line 17 of file stdio.h.

int int size_t const char int const char* fmt

Definition at line 17 of file stdio.h.