bstr_printf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bstr_printf(9)

okay so welcome to bstr_printf(9) from the Kernel API Manual β€” yes bestie, the kernel has its own manual and we're reading it, main character energy fr fr ✨


🌸 NAME

bstr_printf β€” format a string from binary arguments and place it in a buffer πŸŽ€


✨ SYNOPSIS

int bstr_printf (char *buf , size_t size , const char *fmt_str , const
       u32 *bin_buf );

πŸ¦‹ ARGUMENTS

  • buf β€” the buffer you're dropping the result into πŸ’Œ
  • size β€” how big that buffer is, including the trailing null space (yes, the null counts, don't forget it πŸ™ˆ)
  • fmt_str β€” the format string you wanna use 🌈
  • bin_buf β€” the binary arguments for that format string 🧚

πŸ‘‘ DESCRIPTION

So this function is like C99 vsnprintf, but there's a difference: vsnprintf grabs its arguments off the stack, and bstr_printf grabs its arguments from bin_buf, which is a binary buffer that was generated by vbin_printf. it's giving "same vibe, different source" πŸ’«

The format follows C99 vsnprintf, but it's got some extensions β€” see the vsnprintf comment for the details, iykyk πŸ“

Now, the return value: it's the number of characters which would be generated for the given input, excluding the trailing number of characters written into buf as return value (not including the trailing ' '), use vscnprintf. (yes, that trailing ' ' is literally how it's printed on the page β€” don't come for me, I'm just the messenger πŸ’€)

⚠️ And listen: if the return is greater than or equal to size, the resulting string gets truncated. so keep an eye on that πŸ‘€

πŸ”₯ SEE ALSO

Kernel file ./lib/vsprintf.c, plus: simple_strtoull(9), simple_strtoul(9), simple_strtol(9), simple_strtoll(9), vsnprintf(9), vscnprintf(9), snprintf(9), scnprintf(9), vsprintf(9), sprintf(9), vbin_printf(9), vsscanf(9), sscanf(9) 🌟


and that's the page, bestie β€” brought to you from ./lib, dated October 2026, filed under bstr_printf(9). slay, go format something πŸ’…πŸ’–

πŸ“¦ where this page comes from