1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>vsnprintf</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-simple-strtoll.html" title="simple_strtoll"><link rel="next" href="API-vscnprintf.html" title="vscnprintf"></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">vsnprintf</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-simple-strtoll.html">Prev</a>&#160;</td><th width="60%" align="center">String Conversions</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-vscnprintf.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-vsnprintf"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>vsnprintf &#8212; 
2     Format a string 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">vsnprintf </b>(</code></td><td>char * <var class="pdparam">buf</var>, </td></tr><tr><td>&#160;</td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td>&#160;</td><td>const char * <var class="pdparam">fmt</var>, </td></tr><tr><td>&#160;</td><td>va_list <var class="pdparam">args</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1122599292"></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>args</code></em></span></dt><dd><p>
10     Arguments for the format string
11    </p></dd></dl></div></div><div class="refsect1"><a name="idp1122603900"></a><h2>Description</h2><p>
12   This function follows C99 vsnprintf, but has some extensions:
13   <code class="constant">pS</code> output the name of a text symbol with offset
14   <code class="constant">ps</code> output the name of a text symbol without offset
15   <code class="constant">pF</code> output the name of a function pointer with its offset
16   <code class="constant">pf</code> output the name of a function pointer without its offset
17   <code class="constant">pB</code> output the name of a backtrace symbol with its offset
18   <code class="constant">pR</code> output the address range in a struct resource with decoded flags
19   <code class="constant">pr</code> output the address range in a struct resource with raw flags
20   <code class="constant">pb</code> output the bitmap with field width as the number of bits
21   <code class="constant">pbl</code> output the bitmap as range list with field width as the number of bits
22   <code class="constant">pM</code> output a 6-byte MAC address with colons
23   <code class="constant">pMR</code> output a 6-byte MAC address with colons in reversed order
24   <code class="constant">pMF</code> output a 6-byte MAC address with dashes
25   <code class="constant">pm</code> output a 6-byte MAC address without colons
26   <code class="constant">pmR</code> output a 6-byte MAC address without colons in reversed order
27   <code class="constant">pI4</code> print an IPv4 address without leading zeros
28   <code class="constant">pi4</code> print an IPv4 address with leading zeros
29   <code class="constant">pI6</code> print an IPv6 address with colons
30   <code class="constant">pi6</code> print an IPv6 address without colons
31   <code class="constant">pI6c</code> print an IPv6 address as specified by RFC 5952
32   <code class="constant">pIS</code> depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address
33   <code class="constant">piS</code> depending on sa_family of 'struct sockaddr *' print IPv4/IPv6 address
34   <code class="constant">pU</code>[bBlL] print a UUID/GUID in big or little endian using lower or upper
35   case.
36   %*pE[achnops] print an escaped buffer
37   %*ph[CDN] a variable-length hex string with a separator (supports up to 64
38   bytes of the input)
39   <code class="constant">pC</code> output the name (Common Clock Framework) or address (legacy clock
40   framework) of a clock
41   <code class="constant">pCn</code> output the name (Common Clock Framework) or address (legacy clock
42   framework) of a clock
43   <code class="constant">pCr</code> output the current rate of a clock
44   <code class="constant">n</code> is ignored
45   </p><p>
46
47   ** Please update Documentation/printk-formats.txt when making changes **
48   </p><p>
49
50   The return value is the number of characters which would
51   be generated for the given input, excluding the trailing
52   '\0', as per ISO C99. If you want to have the exact
53   number of characters written into <em class="parameter"><code>buf</code></em> as return value
54   (not including the trailing '\0'), use <code class="function">vscnprintf</code>. If the
55   return is greater than or equal to <em class="parameter"><code>size</code></em>, the resulting
56   string is truncated.
57   </p><p>
58
59   If you're not already dealing with a va_list consider using <code class="function">snprintf</code>.
60</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-simple-strtoll.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="libc.html#idp1122555668">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-vscnprintf.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">simple_strtoll</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">vscnprintf</span></td></tr></table></div></body></html>
61