1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>bstr_printf</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux Kernel API"><link rel="up" href="libc.html#idp1122555668" title="String Conversions"><link rel="prev" href="API-vbin-printf.html" title="vbin_printf"><link rel="next" href="API-bprintf.html" title="bprintf"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">bstr_printf</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-vbin-printf.html">Prev</a> </td><th width="60%" align="center">String Conversions</th><td width="20%" align="right"> <a accesskey="n" href="API-bprintf.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-bstr-printf"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>bstr_printf — 2 Format a string from binary arguments and place it in a buffer 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">bstr_printf </b>(</code></td><td>char * <var class="pdparam">buf</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>const char * <var class="pdparam">fmt</var>, </td></tr><tr><td> </td><td>const u32 * <var class="pdparam">bin_buf</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1122690428"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>buf</code></em></span></dt><dd><p> 4 The buffer to place the result into 5 </p></dd><dt><span class="term"><em class="parameter"><code>size</code></em></span></dt><dd><p> 6 The size of the buffer, including the trailing null space 7 </p></dd><dt><span class="term"><em class="parameter"><code>fmt</code></em></span></dt><dd><p> 8 The format string to use 9 </p></dd><dt><span class="term"><em class="parameter"><code>bin_buf</code></em></span></dt><dd><p> 10 Binary arguments for the format string 11 </p></dd></dl></div></div><div class="refsect1"><a name="idp1122695044"></a><h2>Description</h2><p> 12 This function like C99 vsnprintf, but the difference is that vsnprintf gets 13 arguments from stack, and bstr_printf gets arguments from <em class="parameter"><code>bin_buf</code></em> which is 14 a binary buffer that generated by vbin_printf. 15 </p><p> 16 17 The format follows C99 vsnprintf, but has some extensions: 18 see vsnprintf comment for details. 19 </p><p> 20 21 The return value is the number of characters which would 22 be generated for the given input, excluding the trailing 23 '\0', as per ISO C99. If you want to have the exact 24 number of characters written into <em class="parameter"><code>buf</code></em> as return value 25 (not including the trailing '\0'), use <code class="function">vscnprintf</code>. If the 26 return is greater than or equal to <em class="parameter"><code>size</code></em>, the resulting 27 string is truncated. 28</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-vbin-printf.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="libc.html#idp1122555668">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-bprintf.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">vbin_printf</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">bprintf</span></td></tr></table></div></body></html> 29