|
wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
|
libc-free printf-compatible formatter. More...
Go to the source code of this file.
Macros | |
| #define | wired_va_start(ap, last) |
| Begin reading variadic arguments after last. | |
| #define | wired_va_arg(ap, type) |
| Fetch the next variadic argument as type. | |
| #define | wired_va_end(ap) |
| End variadic argument reading. | |
Typedefs | |
| typedef __builtin_va_list | wired_va_list |
| Variadic argument list (compiler builtin, not ISA specific). | |
Functions | |
| usz | wired_vsnprintf (char *out, usz cap, const char *fmt, wired_va_list ap) |
| Format into out like C99 vsnprintf. | |
| usz | wired_snprintf (char *out, usz cap, const char *fmt,...) |
| Format into out like C99 snprintf; see wired_vsnprintf. | |
| usz | wired_obuf_printf (wired_obuf *b, const char *fmt,...) |
| Append formatted text to b at b->len, like snprintf into the free space. | |
| ssz | wired_dprintf (i64 fd, const char *fmt,...) |
| Format and write to a file descriptor via write(2). | |
libc-free printf-compatible formatter.
Conversions: d i u x X p s c %% f; length modifiers hh h l ll z; flags - 0 + space #; width, precision, and * for both.
Deviations from C99 (deliberate, to stay small):
| #define wired_va_arg | ( | ap, | |
| type ) |
Fetch the next variadic argument as type.
| #define wired_va_end | ( | ap | ) |
End variadic argument reading.
| #define wired_va_start | ( | ap, | |
| last ) |
Begin reading variadic arguments after last.
Format and write to a file descriptor via write(2).
The output is formatted into a 512-byte buffer, so anything beyond 511 bytes is truncated; short writes are retried.
| fd | file descriptor |
| fmt | printf format string |
| usz wired_obuf_printf | ( | wired_obuf * | b, |
| const char * | fmt, | ||
| ... ) |
Append formatted text to b at b->len, like snprintf into the free space.
At most cap - len - 1 bytes are appended (vsnprintf's NUL needs the last byte; it is not counted in len), so output that does not fit is cut.
| b | buffer to append to (e.g. an HTTP response body) |
| fmt | printf format string |
Format into out like C99 snprintf; see wired_vsnprintf.
| out | destination |
| cap | capacity of out in bytes, including the NUL |
| fmt | printf format string |
| usz wired_vsnprintf | ( | char * | out, |
| usz | cap, | ||
| const char * | fmt, | ||
| wired_va_list | ap ) |
Format into out like C99 vsnprintf.
| out | destination (may be NULL when cap is 0) |
| cap | capacity of out in bytes, including the NUL |
| fmt | printf format string |
| ap | arguments |