iPXE
Data Structures | Macros | Functions | Variables
vsprintf.c File Reference
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
#include <wchar.h>
#include <ipxe/vsprintf.h>

Go to the source code of this file.

Data Structures

struct  sputc_context
 Context used by vsnprintf() and friends. More...
 

Macros

#define CHAR_LEN   0
 "hh" length modifier More...
 
#define SHORT_LEN   1
 "h" length modifier More...
 
#define INT_LEN   2
 no length modifier More...
 
#define LONG_LEN   3
 "l" length modifier More...
 
#define LONGLONG_LEN   4
 "ll" length modifier More...
 
#define SIZE_T_LEN   5
 "z" length modifier More...
 
#define LCASE   0x20
 Use lower-case for hexadecimal digits. More...
 
#define ALT_FORM   0x02
 Use "alternate form". More...
 
#define ZPAD   0x10
 Use zero padding. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static char * format_hex (char *end, unsigned long long num, int width, int flags)
 Format a hexadecimal number. More...
 
static char * format_decimal (char *end, signed long num, int width, int flags)
 Format a decimal number. More...
 
static void cputchar (struct printf_context *ctx, unsigned char c)
 Print character via a printf context. More...
 
size_t vcprintf (struct printf_context *ctx, const char *fmt, va_list args)
 Write a formatted string to a printf context. More...
 
static void printf_sputc (struct printf_context *ctx, unsigned int c)
 Write character to buffer. More...
 
int vsnprintf (char *buf, size_t size, const char *fmt, va_list args)
 Write a formatted string to a buffer. More...
 
int snprintf (char *buf, size_t size, const char *fmt,...)
 Write a formatted string to a buffer. More...
 
int vssnprintf (char *buf, ssize_t ssize, const char *fmt, va_list args)
 Version of vsnprintf() that accepts a signed buffer size. More...
 
int ssnprintf (char *buf, ssize_t ssize, const char *fmt,...)
 Version of vsnprintf() that accepts a signed buffer size. More...
 
static void printf_putchar (struct printf_context *ctx __unused, unsigned int c)
 Write character to console. More...
 
int vprintf (const char *fmt, va_list args)
 Write a formatted string to the console. More...
 
int printf (const char *fmt,...)
 Write a formatted string to the console. More...
 

Variables

static uint8_t type_sizes []
 

Macro Definition Documentation

◆ CHAR_LEN

#define CHAR_LEN   0

"hh" length modifier

Definition at line 35 of file vsprintf.c.

◆ SHORT_LEN

#define SHORT_LEN   1

"h" length modifier

Definition at line 36 of file vsprintf.c.

◆ INT_LEN

#define INT_LEN   2

no length modifier

Definition at line 37 of file vsprintf.c.

◆ LONG_LEN

#define LONG_LEN   3

"l" length modifier

Definition at line 38 of file vsprintf.c.

◆ LONGLONG_LEN

#define LONGLONG_LEN   4

"ll" length modifier

Definition at line 39 of file vsprintf.c.

◆ SIZE_T_LEN

#define SIZE_T_LEN   5

"z" length modifier

Definition at line 40 of file vsprintf.c.

◆ LCASE

#define LCASE   0x20

Use lower-case for hexadecimal digits.

Note that this value is set to 0x20 since that makes for very efficient calculations. (Bitwise-ORing with LCASE converts to a lower-case character, for example.)

Definition at line 58 of file vsprintf.c.

◆ ALT_FORM

#define ALT_FORM   0x02

Use "alternate form".

For hexadecimal numbers, this means to add a "0x" or "0X" prefix to the number.

Definition at line 66 of file vsprintf.c.

◆ ZPAD

#define ZPAD   0x10

Use zero padding.

Note that this value is set to 0x10 since that allows the pad character to be calculated as 0x20|(flags&ZPAD)

Definition at line 74 of file vsprintf.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ format_hex()

static char* format_hex ( char *  end,
unsigned long long  num,
int  width,
int  flags 
)
static

Format a hexadecimal number.

Parameters
endEnd of buffer to contain number
numNumber to format
widthMinimum field width
flagsFormat flags
Return values
ptrEnd of buffer

Fills a buffer in reverse order with a formatted hexadecimal number. The number will be zero-padded to the specified width. Lower-case and "alternate form" (i.e. "0x" prefix) flags may be set.

There must be enough space in the buffer to contain the largest number that this function can format.

Definition at line 93 of file vsprintf.c.

94  {
95  char *ptr = end;
96  int case_mod = ( flags & LCASE );
97  int pad = ( ( flags & ZPAD ) | ' ' );
98 
99  /* Generate the number */
100  do {
101  *(--ptr) = "0123456789ABCDEF"[ num & 0xf ] | case_mod;
102  num >>= 4;
103  } while ( num );
104 
105  /* Pad to width */
106  while ( ( end - ptr ) < width )
107  *(--ptr) = pad;
108 
109  /* Add "0x" or "0X" if alternate form specified */
110  if ( flags & ALT_FORM ) {
111  *(--ptr) = 'X' | case_mod;
112  *(--ptr) = '0';
113  }
114 
115  return ptr;
116 }
#define ALT_FORM
Use "alternate form".
Definition: vsprintf.c:66
u32 pad[9]
Padding.
Definition: ar9003_mac.h:90
#define LCASE
Use lower-case for hexadecimal digits.
Definition: vsprintf.c:58
char unsigned long * num
Definition: xenstore.h:17
#define ZPAD
Use zero padding.
Definition: vsprintf.c:74
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint8_t flags
Flags.
Definition: ena.h:18

References ALT_FORM, end, flags, LCASE, num, pad, and ZPAD.

Referenced by vcprintf().

◆ format_decimal()

static char* format_decimal ( char *  end,
signed long  num,
int  width,
int  flags 
)
static

Format a decimal number.

Parameters
endEnd of buffer to contain number
numNumber to format
widthMinimum field width
flagsFormat flags
Return values
ptrEnd of buffer

Fills a buffer in reverse order with a formatted decimal number. The number will be space-padded to the specified width.

There must be enough space in the buffer to contain the largest number that this function can format.

Definition at line 133 of file vsprintf.c.

134  {
135  char *ptr = end;
136  int negative = 0;
137  int zpad = ( flags & ZPAD );
138  int pad = ( zpad | ' ' );
139 
140  /* Generate the number */
141  if ( num < 0 ) {
142  negative = 1;
143  num = -num;
144  }
145  do {
146  *(--ptr) = '0' + ( num % 10 );
147  num /= 10;
148  } while ( num );
149 
150  /* Add "-" if necessary */
151  if ( negative && ( ! zpad ) )
152  *(--ptr) = '-';
153 
154  /* Pad to width */
155  while ( ( end - ptr ) < width )
156  *(--ptr) = pad;
157 
158  /* Add "-" if necessary */
159  if ( negative && zpad )
160  *ptr = '-';
161 
162  return ptr;
163 }
u32 pad[9]
Padding.
Definition: ar9003_mac.h:90
char unsigned long * num
Definition: xenstore.h:17
#define ZPAD
Use zero padding.
Definition: vsprintf.c:74
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint8_t flags
Flags.
Definition: ena.h:18

References end, flags, num, pad, and ZPAD.

Referenced by vcprintf().

◆ cputchar()

static void cputchar ( struct printf_context ctx,
unsigned char  c 
)
inlinestatic

Print character via a printf context.

Parameters
ctxContext
cCharacter

Call's the printf_context::handler() method and increments printf_context::len.

Definition at line 174 of file vsprintf.c.

174  {
175  ctx->handler ( ctx, c );
176  ++ctx->len;
177 }
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
struct golan_eq_context ctx
Definition: CIB_PRM.h:28

References c, and ctx.

Referenced by vcprintf().

◆ vcprintf()

size_t vcprintf ( struct printf_context ctx,
const char *  fmt,
va_list  args 
)

Write a formatted string to a printf context.

Parameters
ctxContext
fmtFormat string
argsArguments corresponding to the format string
Return values
lenLength of formatted string

Definition at line 187 of file vsprintf.c.

187  {
188  int flags;
189  int width;
190  uint8_t *length;
191  char *ptr;
192  char tmp_buf[32]; /* 32 is enough for all numerical formats.
193  * Insane width fields could overflow this buffer. */
194  wchar_t *wptr;
195 
196  /* Initialise context */
197  ctx->len = 0;
198 
199  for ( ; *fmt ; fmt++ ) {
200  /* Pass through ordinary characters */
201  if ( *fmt != '%' ) {
202  cputchar ( ctx, *fmt );
203  continue;
204  }
205  fmt++;
206  /* Process flag characters */
207  flags = 0;
208  for ( ; ; fmt++ ) {
209  if ( *fmt == '#' ) {
210  flags |= ALT_FORM;
211  } else if ( *fmt == '0' ) {
212  flags |= ZPAD;
213  } else {
214  /* End of flag characters */
215  break;
216  }
217  }
218  /* Process field width */
219  width = 0;
220  for ( ; ; fmt++ ) {
221  if ( ( ( unsigned ) ( *fmt - '0' ) ) < 10 ) {
222  width = ( width * 10 ) + ( *fmt - '0' );
223  } else {
224  break;
225  }
226  }
227  /* We don't do floating point */
228  /* Process length modifier */
230  for ( ; ; fmt++ ) {
231  if ( *fmt == 'h' ) {
232  length--;
233  } else if ( *fmt == 'l' ) {
234  length++;
235  } else if ( *fmt == 'z' ) {
237  } else {
238  break;
239  }
240  }
241  /* Process conversion specifier */
242  ptr = tmp_buf + sizeof ( tmp_buf ) - 1;
243  *ptr = '\0';
244  wptr = NULL;
245  if ( *fmt == 'c' ) {
246  if ( length < &type_sizes[LONG_LEN] ) {
247  cputchar ( ctx, va_arg ( args, unsigned int ) );
248  } else {
249  wchar_t wc;
250  size_t len;
251 
252  wc = va_arg ( args, wint_t );
253  len = wcrtomb ( tmp_buf, wc, NULL );
254  tmp_buf[len] = '\0';
255  ptr = tmp_buf;
256  }
257  } else if ( *fmt == 's' ) {
258  if ( length < &type_sizes[LONG_LEN] ) {
259  ptr = va_arg ( args, char * );
260  if ( ! ptr )
261  ptr = "<NULL>";
262  } else {
263  wptr = va_arg ( args, wchar_t * );
264  if ( ! wptr )
265  ptr = "<NULL>";
266  }
267  } else if ( *fmt == 'p' ) {
268  intptr_t ptrval;
269 
270  ptrval = ( intptr_t ) va_arg ( args, void * );
271  ptr = format_hex ( ptr, ptrval, width,
272  ( ALT_FORM | LCASE ) );
273  } else if ( ( *fmt & ~0x20 ) == 'X' ) {
274  unsigned long long hex;
275 
276  flags |= ( *fmt & 0x20 ); /* LCASE */
277  if ( *length >= sizeof ( unsigned long long ) ) {
278  hex = va_arg ( args, unsigned long long );
279  } else if ( *length >= sizeof ( unsigned long ) ) {
280  hex = va_arg ( args, unsigned long );
281  } else {
282  hex = va_arg ( args, unsigned int );
283  }
284  ptr = format_hex ( ptr, hex, width, flags );
285  } else if ( ( *fmt == 'd' ) || ( *fmt == 'i' ) ){
286  signed long decimal;
287 
288  if ( *length >= sizeof ( signed long ) ) {
289  decimal = va_arg ( args, signed long );
290  } else {
291  decimal = va_arg ( args, signed int );
292  }
293  ptr = format_decimal ( ptr, decimal, width, flags );
294  } else {
295  *(--ptr) = *fmt;
296  }
297  /* Write out conversion result */
298  if ( wptr == NULL ) {
299  for ( ; *ptr ; ptr++ ) {
300  cputchar ( ctx, *ptr );
301  }
302  } else {
303  for ( ; *wptr ; wptr++ ) {
304  size_t len = wcrtomb ( tmp_buf, *wptr, NULL );
305  for ( ptr = tmp_buf ; len-- ; ptr++ ) {
306  cputchar ( ctx, *ptr );
307  }
308  }
309  }
310  }
311 
312  return ctx->len;
313 }
uint16_t length
Length.
Definition: intel.h:14
static wchar_t wc
Definition: wchar.h:22
#define ALT_FORM
Use "alternate form".
Definition: vsprintf.c:66
static void cputchar(struct printf_context *ctx, unsigned char c)
Print character via a printf context.
Definition: vsprintf.c:174
static char * format_decimal(char *end, signed long num, int width, int flags)
Format a decimal number.
Definition: vsprintf.c:133
char hex[8]
Count (as an eight-digit hex value)
Definition: pccrd.h:12
#define INT_LEN
no length modifier
Definition: vsprintf.c:37
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
unsigned long intptr_t
Definition: stdint.h:21
#define LCASE
Use lower-case for hexadecimal digits.
Definition: vsprintf.c:58
#define LONG_LEN
"l" length modifier
Definition: vsprintf.c:38
#define SIZE_T_LEN
"z" length modifier
Definition: vsprintf.c:40
#define va_arg(ap, type)
Definition: stdarg.h:8
uint8_t tmp_buf[tmp_len]
Definition: entropy.h:155
#define ZPAD
Use zero padding.
Definition: vsprintf.c:74
static char * format_hex(char *end, unsigned long long num, int width, int flags)
Format a hexadecimal number.
Definition: vsprintf.c:93
static uint8_t type_sizes[]
Definition: vsprintf.c:42
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length.
Definition: ena.h:14
int ssize_t const char * fmt
Definition: vsprintf.h:72
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
__WINT_TYPE__ wint_t
Definition: stddef.h:50
uint8_t flags
Flags.
Definition: ena.h:18

References ALT_FORM, cputchar(), ctx, flags, fmt, format_decimal(), format_hex(), hex, INT_LEN, LCASE, len, length, LONG_LEN, NULL, SIZE_T_LEN, tmp_buf, type_sizes, va_arg, wc, and ZPAD.

Referenced by efi_vsnprintf(), vprintf(), vsnprintf(), and vw_printw().

◆ printf_sputc()

static void printf_sputc ( struct printf_context ctx,
unsigned int  c 
)
static

Write character to buffer.

Parameters
ctxContext
cCharacter

Definition at line 330 of file vsprintf.c.

330  {
331  struct sputc_context * sctx =
332  container_of ( ctx, struct sputc_context, ctx );
333 
334  if ( ctx->len < sctx->max_len )
335  sctx->buf[ctx->len] = c;
336 }
static __always_inline void off_t int c
Definition: efi_uaccess.h:87
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
size_t max_len
Buffer length (used by printf_sputc())
Definition: vsprintf.c:321
Context used by vsnprintf() and friends.
Definition: vsprintf.c:316
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:319

References sputc_context::buf, c, container_of, ctx, and sputc_context::max_len.

Referenced by vsnprintf().

◆ vsnprintf()

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.

351  {
352  struct sputc_context sctx;
353  size_t len;
354  size_t end;
355 
356  /* Hand off to vcprintf */
357  sctx.ctx.handler = printf_sputc;
358  sctx.buf = buf;
359  sctx.max_len = size;
360  len = vcprintf ( &sctx.ctx, fmt, args );
361 
362  /* Add trailing NUL */
363  if ( size ) {
364  end = size - 1;
365  if ( len < end )
366  end = len;
367  buf[end] = '\0';
368  }
369 
370  return len;
371 }
uint32_t len
Length.
Definition: ena.h:14
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
int ssize_t const char * fmt
Definition: vsprintf.h:72
Context used by vsnprintf() and friends.
Definition: vsprintf.c:316
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:319
static void printf_sputc(struct printf_context *ctx, unsigned int c)
Write character to buffer.
Definition: vsprintf.c:330
size_t vcprintf(struct printf_context *ctx, const char *fmt, va_list args)
Write a formatted string to a printf context.
Definition: vsprintf.c:187

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

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

◆ snprintf()

int snprintf ( char *  buf,
size_t  size,
const char *  fmt,
  ... 
)

Write a formatted string to a buffer.

Parameters
bufBuffer into which to write the string
sizeSize of buffer
fmtFormat string
...Arguments corresponding to the format string
Return values
lenLength of formatted string

Definition at line 382 of file vsprintf.c.

382  {
383  va_list args;
384  int i;
385 
386  va_start ( args, fmt );
387  i = vsnprintf ( buf, size, fmt, args );
388  va_end ( args );
389  return i;
390 }
#define va_end(ap)
Definition: stdarg.h:9
__builtin_va_list va_list
Definition: stdarg.h:6
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
int ssize_t const char * fmt
Definition: vsprintf.h:72
#define va_start(ap, last)
Definition: stdarg.h:7
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:319
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Write a formatted string to a buffer.
Definition: vsprintf.c:351

References sputc_context::buf, fmt, size, va_end, va_start, and vsnprintf().

Referenced by __vxge_hw_vpath_fw_ver_get(), alloc_usb(), aoedev_name(), ath9k_hw_name(), cpio_set_field(), dhcp_tag_name(), dhcpv6_type_name(), draw_menu_item(), efi_device_info(), efi_devpath_text(), efi_driver_name(), efi_driver_name2(), efi_file_find(), efi_local_open_path(), efi_locate_search_type_name(), efi_pci_info(), efi_pecoff_debug_name(), efi_status(), efi_usb_install(), eisabus_probe(), eoib_create(), fc_id_ntoa(), fc_ntoa(), fc_port_open(), fcp_parse_uri(), format_busdevfn_setting(), format_int_setting(), format_ipv4_setting(), format_ipv6_setting(), format_uint_setting(), format_uuid_setting(), guestinfo_fetch_type(), http_digest_authenticate(), http_format_authorization(), http_format_basic_auth(), http_format_connection(), http_format_content_length(), http_format_content_type(), http_format_host(), http_format_metadata_flavor(), http_format_p2p_peerdist(), http_format_p2p_peerdistex(), http_format_range(), http_format_user_agent(), ib_create_service_madx(), ib_sma_node_desc(), int22(), intelxl_admin_driver(), ipv6_sock_ntoa(), isabus_probe(), isapnpbus_probe(), iwlist(), linux_strerror(), mcabus_probe(), multiboot_add_cmdline(), multiboot_exec(), ndp_register_settings(), pci_read_config(), peerblk_retrieval_uri(), peerdist_discovery_reply_values(), peermux_progress(), profile_hex_fraction(), pxe_menu_draw_item(), pxenv_undi_get_iface_info(), register_ibdev(), register_image(), register_netdev(), select_setting_row(), setting_name(), settings_name(), show_menu(), skge_board_name(), strerror(), string_test_exec(), t509bus_probe(), tcp_progress(), tftp_apply_settings(), tftp_send_rrq(), tftp_uri(), undibus_probe(), uri_decode(), usb_bcd(), usb_endpoint_name(), usb_probe_all(), usb_speed_name(), validator_progress(), validator_start_download(), vlan_create(), vmbus_probe_channels(), xcm_create(), xenbus_probe_device(), xenstore_write_num(), xhci_speed_name(), xsigo_xds_complete(), xsmp_session_type(), xsmp_xve_type(), and xve_create().

◆ vssnprintf()

int vssnprintf ( char *  buf,
ssize_t  ssize,
const char *  fmt,
va_list  args 
)

Version of vsnprintf() that accepts a signed buffer size.

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

Definition at line 401 of file vsprintf.c.

401  {
402 
403  /* Treat negative buffer size as zero buffer size */
404  if ( ssize < 0 )
405  ssize = 0;
406 
407  /* Hand off to vsnprintf */
408  return vsnprintf ( buf, ssize, fmt, args );
409 }
int ssize_t ssize
Definition: vsprintf.h:72
int ssize_t const char * fmt
Definition: vsprintf.h:72
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:319
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Write a formatted string to a buffer.
Definition: vsprintf.c:351

References sputc_context::buf, fmt, ssize, and vsnprintf().

Referenced by ssnprintf().

◆ ssnprintf()

int ssnprintf ( char *  buf,
ssize_t  ssize,
const char *  fmt,
  ... 
)

Version of vsnprintf() that accepts a signed buffer size.

Parameters
bufBuffer into which to write the string
sizeSize of buffer
fmtFormat string
...Arguments corresponding to the format string
Return values
lenLength of formatted string

Definition at line 420 of file vsprintf.c.

420  {
421  va_list args;
422  int len;
423 
424  /* Hand off to vssnprintf */
425  va_start ( args, fmt );
426  len = vssnprintf ( buf, ssize, fmt, args );
427  va_end ( args );
428  return len;
429 }
#define va_end(ap)
Definition: stdarg.h:9
int vssnprintf(char *buf, ssize_t ssize, const char *fmt, va_list args)
Version of vsnprintf() that accepts a signed buffer size.
Definition: vsprintf.c:401
int ssize_t ssize
Definition: vsprintf.h:72
uint32_t len
Length.
Definition: ena.h:14
__builtin_va_list va_list
Definition: stdarg.h:6
int ssize_t const char * fmt
Definition: vsprintf.h:72
#define va_start(ap, last)
Definition: stdarg.h:7
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:319

References sputc_context::buf, fmt, len, ssize, va_end, va_start, and vssnprintf().

Referenced by efi_handle_name(), format_uri(), hex_encode(), http_format_accept_encoding(), http_format_digest_auth(), http_format_headers(), iscsi_build_login_request_strings(), snpnet_mac_text(), and uri_encode().

◆ printf_putchar()

static void printf_putchar ( struct printf_context *ctx  __unused,
unsigned int  c 
)
static

Write character to console.

Parameters
ctxContext
cCharacter

Definition at line 437 of file vsprintf.c.

438  {
439  putchar ( c );
440 }
void putchar(int character)
Write a single character to each console device.
Definition: console.c:27
static __always_inline void off_t int c
Definition: efi_uaccess.h:87

References c, and putchar().

Referenced by vprintf().

◆ vprintf()

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.

449  {
450  struct printf_context ctx;
451 
452  /* Hand off to vcprintf */
453  ctx.handler = printf_putchar;
454  return vcprintf ( &ctx, fmt, args );
455 }
static void printf_putchar(struct printf_context *ctx __unused, unsigned int c)
Write character to console.
Definition: vsprintf.c:437
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
A printf context.
Definition: vsprintf.h:47
int ssize_t const char * fmt
Definition: vsprintf.h:72
size_t vcprintf(struct printf_context *ctx, const char *fmt, va_list args)
Write a formatted string to a printf context.
Definition: vsprintf.c:187

References ctx, fmt, printf_putchar(), and vcprintf().

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

◆ printf()

int printf ( const char *  fmt,
  ... 
)

Write a formatted string to the console.

Parameters
fmtFormat string
...Arguments corresponding to the format string
Return values
lenLength of formatted string

Definition at line 464 of file vsprintf.c.

464  {
465  va_list args;
466  int i;
467 
468  va_start ( args, fmt );
469  i = vprintf ( fmt, args );
470  va_end ( args );
471  return i;
472 }
#define va_end(ap)
Definition: stdarg.h:9
__builtin_va_list va_list
Definition: stdarg.h:6
int ssize_t const char * fmt
Definition: vsprintf.h:72
int vprintf(const char *fmt, va_list args)
Write a formatted string to the console.
Definition: vsprintf.c:449
#define va_start(ap, last)
Definition: stdarg.h:7

References fmt, va_end, va_start, and vprintf().

Referenced by __attribute__(), _dump_regs(), amd79c901_read_mode(), amd8111e_poll_link(), amd8111e_probe_ext_phy(), amd8111e_restart(), amd8111e_transmit(), amd8111e_wait_tx_ring(), ansicol_set(), ansiscr_attrs(), ansiscr_cursor(), ansiscr_erase(), ansiscr_movetoyx(), ansiscr_reset(), autoboot(), beep(), bnx2_fw_sync(), bnx2_init_board(), bnx2_init_nvram(), bnx2_probe(), bnx2_report_link(), bnx2_reset_chip(), bnx2_transmit(), bofm_test(), bofm_test_init(), cert_exec(), certstat(), check_duplex(), choose_exec(), clrline(), colour_exec(), config_exec(), console_exec(), corkscrew_probe1(), cpair_exec(), cs89x0_probe(), cs89x0_transmit(), dbg_efi_openers(), dbg_efi_protocols(), dbg_md5_da(), detect_aui(), detect_bnc(), detect_tp(), digest_exec(), dm9132_id_table(), dmfe_poll(), dmfe_probe(), echo_exec(), eepro_poll(), eepro_probe(), eepro_transmit(), eeprom_rdy(), enable_multicast(), entropy_sample_test_exec(), epic100_open(), epic100_poll(), epic100_probe(), epic100_transmit(), eth_pio_write(), eth_probe(), execv(), fcels(), fcels_exec(), fcpeerstat(), fcportstat(), fetch_next_server_and_filename(), fetch_root_path(), fetch_san_filename(), fnrec_dump(), fnrec_init(), gdbserial_init(), gdbudp_init(), get_eeprom_data(), getopt_long(), goto_exec(), help_exec(), hfa384x_copy_from_bap(), hfa384x_copy_to_bap(), hfa384x_docmd_wait(), hfa384x_drvr_getconfig(), hfa384x_drvr_setconfig(), hfa384x_wait_for_event(), ibstat(), ics1893_read_mode(), ifconf(), iflinkwait(), ifopen(), ifstat(), ifstat_errors(), imgdownload(), imgmulti_exec(), imgsingle_exec(), imgstat(), imgtrust_exec(), imgverify_exec(), inc_exec(), ipstat(), ipxe(), iwlist(), iwstat(), legacy_probe(), list_check_contents(), login_exec(), loopback_test(), loopback_wait(), lotest_exec(), main(), match_long_option(), match_short_option(), monojob_wait(), netboot(), ns8390_poll(), nslookup(), nstat(), ntp_exec(), null_reboot(), parse_fc_els_handler(), parse_fc_port(), parse_fc_port_id(), parse_gdb_transport(), parse_integer(), parse_menu(), parse_net_args(), parse_netdev(), parse_netdev_configurator(), parse_parameters(), parse_setting(), parse_settings(), pciscan_exec(), ping(), ping_callback(), pnic_api_check(), pnic_command(), pnic_command_quiet(), pnic_probe(), poweroff_exec(), print_usage(), prism2_find_plx(), prism2_pci_probe(), prism2_probe(), prism2_transmit(), profstat(), prompt(), pxe_menu_prompt_and_select(), pxe_menu_select(), pxebs(), pxebs_exec(), readline_history(), route_ipv4_print(), route_ipv6_print(), rtl8201_read_mode(), run_all_tests(), run_tests(), send_test_pkt(), set_core_exec(), set_rx_mode(), shell_banner(), show_exec(), sis900_get_mac_addr(), sis900_init_rxd(), sis900_init_rxfilter(), sis900_init_txd(), sis900_poll(), sis900_probe(), sis900_read_mode(), sis900_transmit(), sis96x_get_mac_addr(), smc9000_poll(), smc9000_probe(), smc9000_transmit(), smc_detect_phy(), smc_read_phy_register(), smc_write_phy_register(), sundance_poll(), sundance_probe(), sundance_transmit(), sync_exec(), t509_poll(), t509_transmit(), t515_poll(), t515_reset(), t529_probe(), t595_poll(), t595_transmit(), t5x9_probe(), test_ok(), time_exec(), TLan_PhyDetect(), TLan_PhyFinishAutoNeg(), tlan_probe(), tlan_transmit(), umalloc_test(), uriboot(), vcreate_exec(), vdestroy_exec(), vt6103_read_mode(), vxge_probe(), vxgetlink(), vxsetlink(), w89c840_poll(), w89c840_probe(), w89c840_reset(), and w89c840_transmit().

Variable Documentation

◆ type_sizes

uint8_t type_sizes[]
static
Initial value:
= {
[CHAR_LEN] = sizeof ( char ),
[SHORT_LEN] = sizeof ( short ),
[INT_LEN] = sizeof ( int ),
[LONG_LEN] = sizeof ( long ),
[LONGLONG_LEN] = sizeof ( long long ),
[SIZE_T_LEN] = sizeof ( size_t ),
}
#define CHAR_LEN
"hh" length modifier
Definition: vsprintf.c:35
#define INT_LEN
no length modifier
Definition: vsprintf.c:37
#define LONG_LEN
"l" length modifier
Definition: vsprintf.c:38
#define SIZE_T_LEN
"z" length modifier
Definition: vsprintf.c:40
#define SHORT_LEN
"h" length modifier
Definition: vsprintf.c:36
#define LONGLONG_LEN
"ll" length modifier
Definition: vsprintf.c:39

Definition at line 42 of file vsprintf.c.

Referenced by vcprintf().