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)
 
 FILE_SECBOOT (PERMITTED)
 
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 36 of file vsprintf.c.

◆ SHORT_LEN

#define SHORT_LEN   1

"h" length modifier

Definition at line 37 of file vsprintf.c.

◆ INT_LEN

#define INT_LEN   2

no length modifier

Definition at line 38 of file vsprintf.c.

◆ LONG_LEN

#define LONG_LEN   3

"l" length modifier

Definition at line 39 of file vsprintf.c.

◆ LONGLONG_LEN

#define LONGLONG_LEN   4

"ll" length modifier

Definition at line 40 of file vsprintf.c.

◆ SIZE_T_LEN

#define SIZE_T_LEN   5

"z" length modifier

Definition at line 41 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 59 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 67 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 75 of file vsprintf.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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 94 of file vsprintf.c.

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

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

175  {
176  ctx->handler ( ctx, c );
177  ++ctx->len;
178 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28

References 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 188 of file vsprintf.c.

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

References ALT_FORM, cputchar(), ctx, flags, fmt, format_decimal(), format_hex(), hex, INT_LEN, LCASE, len, length, LONG_LEN, NULL, SIZE_T_LEN, 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 331 of file vsprintf.c.

331  {
332  struct sputc_context * sctx =
333  container_of ( ctx, struct sputc_context, ctx );
334 
335  if ( ctx->len < sctx->max_len )
336  sctx->buf[ctx->len] = c;
337 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:36
size_t max_len
Buffer length (used by printf_sputc())
Definition: vsprintf.c:322
Context used by vsnprintf() and friends.
Definition: vsprintf.c:317
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:320

References sputc_context::buf, 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 352 of file vsprintf.c.

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

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

Referenced by ipair_tx(), 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 383 of file vsprintf.c.

383  {
384  va_list args;
385  int i;
386 
387  va_start ( args, fmt );
388  i = vsnprintf ( buf, size, fmt, args );
389  va_end ( args );
390  return i;
391 }
#define va_end(ap)
Definition: stdarg.h:10
uint16_t size
Buffer size.
Definition: dwmac.h:14
__builtin_va_list va_list
Definition: stdarg.h:7
int ssize_t const char * fmt
Definition: vsprintf.h:73
#define va_start(ap, last)
Definition: stdarg.h:8
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:320
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Write a formatted string to a buffer.
Definition: vsprintf.c:352

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(), bzimage_set_cmdline(), cpio_set_field(), dhcp_tag_name(), dhcpv6_type_name(), draw_menu_item(), dt_probe_node(), efi_allocate_type(), efi_cmdline_init(), efi_device_info(), efi_device_info_pci(), efi_devpath_text(), efi_driver_name(), efi_driver_name2(), efi_file_open(), efi_local_open_path(), efi_locate_search_type_name(), efi_memory_type(), efi_pecoff_debug_name(), efi_reset_type(), efi_snp_probe(), efi_status(), efi_time(), efi_timer_delay(), efi_tpl_name(), efi_usb_install(), eisabus_probe(), ena_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(), gve_mode_name(), 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(), mcabus_probe(), mschapv2_auth(), 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_file_cmdline(), pxenv_undi_get_iface_info(), register_ibdev(), register_image(), register_netdev(), setting_name(), settings_name(), show_menu(), skge_board_name(), strerror(), string_test_exec(), t509bus_probe(), tcp_progress(), testnet_okx(), testnet_set_okx(), 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 402 of file vsprintf.c.

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

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 421 of file vsprintf.c.

421  {
422  va_list args;
423  int len;
424 
425  /* Hand off to vssnprintf */
426  va_start ( args, fmt );
427  len = vssnprintf ( buf, ssize, fmt, args );
428  va_end ( args );
429  return len;
430 }
#define va_end(ap)
Definition: stdarg.h:10
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:402
ring len
Length.
Definition: dwmac.h:231
int ssize_t ssize
Definition: vsprintf.h:73
__builtin_va_list va_list
Definition: stdarg.h:7
int ssize_t const char * fmt
Definition: vsprintf.h:73
#define va_start(ap, last)
Definition: stdarg.h:8
char * buf
Buffer for formatted string (used by printf_sputc())
Definition: vsprintf.c:320

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 438 of file vsprintf.c.

439  {
440  putchar ( c );
441 }
int putchar(int character)
Write a single character to each console device.
Definition: console.c:29

References 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 450 of file vsprintf.c.

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

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 465 of file vsprintf.c.

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

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_dummy_harvest(), bofm_dummy_probe(), bofm_dummy_update(), 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_opener(), dbg_efi_openers(), dbg_efi_protocol(), 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(), 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(), imgdecrypt_exec(), imgdownload(), imgextract(), imgmem(), 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_dynui(), parse_fc_els_handler(), parse_fc_port(), parse_fc_port_id(), parse_gdb_transport(), parse_integer(), parse_net_args(), parse_netdev(), parse_netdev_configurator(), parse_parameters(), parse_setting(), parse_settings(), parse_uuid(), 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(), ucode_exec(), uriboot(), usbscan_exec(), 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:36
#define INT_LEN
no length modifier
Definition: vsprintf.c:38
#define LONG_LEN
"l" length modifier
Definition: vsprintf.c:39
#define SIZE_T_LEN
"z" length modifier
Definition: vsprintf.c:41
#define SHORT_LEN
"h" length modifier
Definition: vsprintf.c:37
#define LONGLONG_LEN
"ll" length modifier
Definition: vsprintf.c:40

Definition at line 43 of file vsprintf.c.

Referenced by vcprintf().