iPXE
|
#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 [] |
#define CHAR_LEN 0 |
"hh" length modifier
Definition at line 35 of file vsprintf.c.
#define SHORT_LEN 1 |
"h" length modifier
Definition at line 36 of file vsprintf.c.
#define INT_LEN 2 |
no length modifier
Definition at line 37 of file vsprintf.c.
#define LONG_LEN 3 |
"l" length modifier
Definition at line 38 of file vsprintf.c.
#define LONGLONG_LEN 4 |
"ll" length modifier
Definition at line 39 of file vsprintf.c.
#define SIZE_T_LEN 5 |
"z" length modifier
Definition at line 40 of file vsprintf.c.
#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.
#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.
#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.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Format a hexadecimal number.
end | End of buffer to contain number |
num | Number to format |
width | Minimum field width |
flags | Format flags |
ptr | End 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.
References ALT_FORM, end, flags, LCASE, num, pad, and ZPAD.
Referenced by vcprintf().
|
static |
Format a decimal number.
end | End of buffer to contain number |
num | Number to format |
width | Minimum field width |
flags | Format flags |
ptr | End 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.
References end, flags, num, pad, and ZPAD.
Referenced by vcprintf().
|
inlinestatic |
Print character via a printf context.
ctx | Context |
c | Character |
Call's the printf_context::handler() method and increments printf_context::len.
Definition at line 174 of file vsprintf.c.
Referenced by vcprintf().
size_t vcprintf | ( | struct printf_context * | ctx, |
const char * | fmt, | ||
va_list | args | ||
) |
Write a formatted string to a printf context.
ctx | Context |
fmt | Format string |
args | Arguments corresponding to the format string |
len | Length of formatted string |
Definition at line 187 of file vsprintf.c.
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().
|
static |
Write character to buffer.
ctx | Context |
c | Character |
Definition at line 330 of file vsprintf.c.
References sputc_context::buf, c, container_of, ctx, and sputc_context::max_len.
Referenced by vsnprintf().
Write a formatted string to a buffer.
buf | Buffer into which to write the string |
size | Size of buffer |
fmt | Format string |
args | Arguments corresponding to the format string |
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 351 of file vsprintf.c.
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().
int snprintf | ( | char * | buf, |
size_t | size, | ||
const char * | fmt, | ||
... | |||
) |
Write a formatted string to a buffer.
buf | Buffer into which to write the string |
size | Size of buffer |
fmt | Format string |
... | Arguments corresponding to the format string |
len | Length of formatted string |
Definition at line 382 of file vsprintf.c.
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_allocate_type(), efi_cmdline_init(), efi_device_info(), 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_pci_info(), efi_pecoff_debug_name(), efi_snp_probe(), efi_status(), efi_timer_delay(), efi_tpl(), 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(), 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_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(), 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().
Version of vsnprintf() that accepts a signed buffer size.
buf | Buffer into which to write the string |
size | Size of buffer |
fmt | Format string |
args | Arguments corresponding to the format string |
len | Length of formatted string |
Definition at line 401 of file vsprintf.c.
References sputc_context::buf, fmt, ssize, and vsnprintf().
Referenced by ssnprintf().
int ssnprintf | ( | char * | buf, |
ssize_t | ssize, | ||
const char * | fmt, | ||
... | |||
) |
Version of vsnprintf() that accepts a signed buffer size.
buf | Buffer into which to write the string |
size | Size of buffer |
fmt | Format string |
... | Arguments corresponding to the format string |
len | Length of formatted string |
Definition at line 420 of file vsprintf.c.
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().
|
static |
Write character to console.
ctx | Context |
c | Character |
Definition at line 437 of file vsprintf.c.
Referenced by vprintf().
int vprintf | ( | const char * | fmt, |
va_list | args | ||
) |
Write a formatted string to the console.
fmt | Format string |
args | Arguments corresponding to the format string |
len | Length of formatted string |
Definition at line 449 of file vsprintf.c.
References ctx, fmt, printf_putchar(), and vcprintf().
Referenced by dbg_printf(), log_vprintf(), and printf().
int printf | ( | const char * | fmt, |
... | |||
) |
Write a formatted string to the console.
fmt | Format string |
... | Arguments corresponding to the format string |
len | Length of formatted string |
Definition at line 464 of file vsprintf.c.
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_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(), umalloc_test(), uriboot(), vcreate_exec(), vdestroy_exec(), vt6103_read_mode(), vxge_probe(), vxgetlink(), vxsetlink(), w89c840_poll(), w89c840_probe(), w89c840_reset(), and w89c840_transmit().
|
static |
Definition at line 42 of file vsprintf.c.
Referenced by vcprintf().