|
AquilaOS documentation
How it works, and its code
|
snprintf() and vsnprintf(): formatting into a buffer, with the formats printk() has: c, s, d and u (32-bit), ld and lu (64-bit), x and lx (hexadecimal), b (binary) and p. More...
#include <core/system.h>Go to the source code of this file.
Functions | |
| static int | snputc (char *s, size_t n, char c) |
| Writes one character, if there is room. | |
| static int | snputs (char *s, size_t n, char *str) |
| Writes a string, as much of it as fits. | |
| static int | snputx (char *s, size_t n, uint32_t val) |
| Writes a 32-bit number in hexadecimal, all 8 digits. | |
| static int | snputlx (char *s, size_t n, uint64_t val) |
| Writes a 64-bit number in hexadecimal, all 16 digits. | |
| static int | snputud (char *s, size_t n, uint32_t val) |
| Writes an unsigned 32-bit number in decimal. | |
| static int | snputul (char *s, size_t n, uint64_t val) |
| Writes an unsigned 64-bit number in decimal. | |
| static int | snputb (char *s, size_t n, uint8_t val) |
| Writes a byte in binary, all 8 digits. | |
| int | vsnprintf (char *s, size_t n, const char *fmt, va_list args) |
| Formats a string into a buffer, with its arguments in a va_list. | |
| int | snprintf (char *s, size_t n, const char *fmt,...) |
| Formats a string into a buffer. | |
snprintf() and vsnprintf(): formatting into a buffer, with the formats printk() has: c, s, d and u (32-bit), ld and lu (64-bit), x and lx (hexadecimal), b (binary) and p.
The l formats take a 64-bit argument on every architecture. Each helper below writes at most n characters to s, and returns how many it wrote.
Definition in file snprintf.c.
| int snprintf | ( | char * | s, |
| size_t | n, | ||
| const char * | fmt, | ||
| ... ) |
Formats a string into a buffer.
| s | the buffer |
| n | its size: at most n - 1 characters are written, and a NUL after them (nothing at all if n is 0) |
| fmt | the format (see the top of this file for what it supports) |
Definition at line 226 of file snprintf.c.
References snprintf(), va_end, va_list, va_start, and vsnprintf().
Referenced by apic_describe(), arch_interrupts_info(), csi(), netif_register(), procfs_buddyinfo(), procfs_cmdline(), procfs_devices(), procfs_filesystems(), procfs_finddir(), procfs_kvmem(), procfs_meminfo(), procfs_mounts(), procfs_proc_maps(), procfs_proc_status(), procfs_proc_vmstats(), procfs_rdcmdline(), procfs_readdir(), procfs_uptime(), procfs_version(), pts_new(), pty_free(), and snprintf().
Writes a byte in binary, all 8 digits.
Definition at line 104 of file snprintf.c.
References snputb(), and snputs().
Referenced by snputb(), and vsnprintf().
|
static |
Writes one character, if there is room.
Definition at line 13 of file snprintf.c.
References snputc().
Referenced by snputc(), snputud(), snputul(), and vsnprintf().
Writes a 64-bit number in hexadecimal, all 16 digits.
Definition at line 53 of file snprintf.c.
References snputlx(), and snputs().
Referenced by snputlx(), and vsnprintf().
|
static |
Writes a string, as much of it as fits.
Definition at line 24 of file snprintf.c.
References snputs().
Referenced by snputb(), snputlx(), snputs(), snputud(), snputul(), snputx(), and vsnprintf().
Writes an unsigned 32-bit number in decimal.
Definition at line 67 of file snprintf.c.
References snputc(), snputs(), and snputud().
Referenced by snputud(), and vsnprintf().
Writes an unsigned 64-bit number in decimal.
Definition at line 86 of file snprintf.c.
References snputc(), snputs(), and snputul().
Referenced by snputul(), and vsnprintf().
Writes a 32-bit number in hexadecimal, all 8 digits.
Definition at line 37 of file snprintf.c.
References snputs(), and snputx().
Referenced by snputx(), and vsnprintf().
Formats a string into a buffer, with its arguments in a va_list.
| s | the buffer |
| n | its size: at most n - 1 characters are written, and a NUL after them (nothing at all if n is 0) |
| fmt | the format (see the top of this file for what it supports) |
| args | the arguments |
Definition at line 128 of file snprintf.c.
References snputb(), snputc(), snputlx(), snputs(), snputud(), snputul(), snputx(), va_arg, va_list, and vsnprintf().
Referenced by snprintf(), and vsnprintf().