• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/json-c/doc/html/printbuf_8h.html

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 <html xmlns="http://www.w3.org/1999/xhtml">
  3 <head>
  4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6 <title>json-c: /home/erh/json-c-0.15/printbuf.h File Reference</title>
  7 <link href="tabs.css" rel="stylesheet" type="text/css"/>
  8 <script type="text/javascript" src="jquery.js"></script>
  9 <script type="text/javascript" src="dynsections.js"></script>
 10 <link href="doxygen.css" rel="stylesheet" type="text/css" />
 11 </head>
 12 <body>
 13 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
 14 <div id="titlearea">
 15 <table cellspacing="0" cellpadding="0">
 16  <tbody>
 17  <tr style="height: 56px;">
 18   <td style="padding-left: 0.5em;">
 19    <div id="projectname">json-c
 20    &#160;<span id="projectnumber">0.15</span>
 21    </div>
 22   </td>
 23  </tr>
 24  </tbody>
 25 </table>
 26 </div>
 27 <!-- end header part -->
 28 <!-- Generated by Doxygen 1.8.2 -->
 29   <div id="navrow1" class="tabs">
 30     <ul class="tablist">
 31       <li><a href="index.html"><span>Main&#160;Page</span></a></li>
 32       <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
 33       <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
 34       <li class="current"><a href="files.html"><span>Files</span></a></li>
 35     </ul>
 36   </div>
 37   <div id="navrow2" class="tabs2">
 38     <ul class="tablist">
 39       <li><a href="files.html"><span>File&#160;List</span></a></li>
 40       <li><a href="globals.html"><span>Globals</span></a></li>
 41     </ul>
 42   </div>
 43 <div id="nav-path" class="navpath">
 44   <ul>
 45 <li class="navelem"><a class="el" href="dir_71f13e590eb9d766c31051438785ada5.html">json-c-0.15</a></li>  </ul>
 46 </div>
 47 </div><!-- top -->
 48 <div class="header">
 49   <div class="summary">
 50 <a href="#nested-classes">Data Structures</a> &#124;
 51 <a href="#define-members">Macros</a> &#124;
 52 <a href="#typedef-members">Typedefs</a> &#124;
 53 <a href="#func-members">Functions</a>  </div>
 54   <div class="headertitle">
 55 <div class="title">printbuf.h File Reference</div>  </div>
 56 </div><!--header-->
 57 <div class="contents">
 58 
 59 <p>Internal string buffer handing. Unless you're writing a json_object_to_json_string_fn implementation for use with <a class="el" href="json__object_8h.html#a889345512a214b8f78f6a73561523c7c">json_object_set_serializer()</a> direct use of this is not recommended.  
 60 <a href="#details">More...</a></p>
 61 <table class="memberdecls">
 62 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
 63 Data Structures</h2></td></tr>
 64 <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structprintbuf.html">printbuf</a></td></tr>
 65 <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
 66 </table><table class="memberdecls">
 67 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
 68 Macros</h2></td></tr>
 69 <tr class="memitem:a2a31d5c00f3a4712f2d5d62aee66344e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a>&#160;&#160;&#160;extern</td></tr>
 70 <tr class="separator:a2a31d5c00f3a4712f2d5d62aee66344e"><td class="memSeparator" colspan="2">&#160;</td></tr>
 71 <tr class="memitem:a6f3a4dc87fab41c37e3eff42f40dc346"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a6f3a4dc87fab41c37e3eff42f40dc346">printbuf_memappend_fast</a>(p, bufptr, bufsize)</td></tr>
 72 <tr class="separator:a6f3a4dc87fab41c37e3eff42f40dc346"><td class="memSeparator" colspan="2">&#160;</td></tr>
 73 <tr class="memitem:acdd84ad88987c0166b7ba0e3f1f8f1bb"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#acdd84ad88987c0166b7ba0e3f1f8f1bb">printbuf_length</a>(p)&#160;&#160;&#160;((p)-&gt;bpos)</td></tr>
 74 <tr class="separator:acdd84ad88987c0166b7ba0e3f1f8f1bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
 75 <tr class="memitem:a2f30492682f5fbc59a8749b428e0e4ba"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a2f30492682f5fbc59a8749b428e0e4ba">printbuf_strappend</a>(pb, str)&#160;&#160;&#160;<a class="el" href="printbuf_8h.html#a9c193d30e9ca4936ea28a6c9e8e4f6f0">printbuf_memappend</a>((pb), _printbuf_check_literal(str), sizeof(str) - 1)</td></tr>
 76 <tr class="separator:a2f30492682f5fbc59a8749b428e0e4ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
 77 </table><table class="memberdecls">
 78 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
 79 Typedefs</h2></td></tr>
 80 <tr class="memitem:ace274df280df67463ff417b1b3392395"><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="structprintbuf.html">printbuf</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#ace274df280df67463ff417b1b3392395">printbuf</a></td></tr>
 81 <tr class="separator:ace274df280df67463ff417b1b3392395"><td class="memSeparator" colspan="2">&#160;</td></tr>
 82 </table><table class="memberdecls">
 83 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
 84 Functions</h2></td></tr>
 85 <tr class="memitem:a645670fa132f0ae9a75f43c0b464bdaf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> struct <a class="el" href="structprintbuf.html">printbuf</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a645670fa132f0ae9a75f43c0b464bdaf">printbuf_new</a> (void)</td></tr>
 86 <tr class="separator:a645670fa132f0ae9a75f43c0b464bdaf"><td class="memSeparator" colspan="2">&#160;</td></tr>
 87 <tr class="memitem:a9c193d30e9ca4936ea28a6c9e8e4f6f0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a9c193d30e9ca4936ea28a6c9e8e4f6f0">printbuf_memappend</a> (struct <a class="el" href="structprintbuf.html">printbuf</a> *p, const char *buf, int size)</td></tr>
 88 <tr class="separator:a9c193d30e9ca4936ea28a6c9e8e4f6f0"><td class="memSeparator" colspan="2">&#160;</td></tr>
 89 <tr class="memitem:a93a27f4f8a092c58666724de23ae804d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a93a27f4f8a092c58666724de23ae804d">printbuf_memset</a> (struct <a class="el" href="structprintbuf.html">printbuf</a> *pb, int offset, int charvalue, int len)</td></tr>
 90 <tr class="separator:a93a27f4f8a092c58666724de23ae804d"><td class="memSeparator" colspan="2">&#160;</td></tr>
 91 <tr class="memitem:a61f6bc0b1ca5787f0faca6799d61a0bb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a61f6bc0b1ca5787f0faca6799d61a0bb">sprintbuf</a> (struct <a class="el" href="structprintbuf.html">printbuf</a> *p, const char *msg,...)</td></tr>
 92 <tr class="separator:a61f6bc0b1ca5787f0faca6799d61a0bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
 93 <tr class="memitem:a705c62167df13e65e04de9ae60f6e136"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a705c62167df13e65e04de9ae60f6e136">printbuf_reset</a> (struct <a class="el" href="structprintbuf.html">printbuf</a> *p)</td></tr>
 94 <tr class="separator:a705c62167df13e65e04de9ae60f6e136"><td class="memSeparator" colspan="2">&#160;</td></tr>
 95 <tr class="memitem:a2b744266191ef5e3102fbf910e790a98"><td class="memItemLeft" align="right" valign="top"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="printbuf_8h.html#a2b744266191ef5e3102fbf910e790a98">printbuf_free</a> (struct <a class="el" href="structprintbuf.html">printbuf</a> *p)</td></tr>
 96 <tr class="separator:a2b744266191ef5e3102fbf910e790a98"><td class="memSeparator" colspan="2">&#160;</td></tr>
 97 </table>
 98 <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
 99 <div class="textblock"><p>Internal string buffer handing. Unless you're writing a json_object_to_json_string_fn implementation for use with <a class="el" href="json__object_8h.html#a889345512a214b8f78f6a73561523c7c">json_object_set_serializer()</a> direct use of this is not recommended. </p>
100 </div><h2 class="groupheader">Macro Definition Documentation</h2>
101 <a class="anchor" id="a2a31d5c00f3a4712f2d5d62aee66344e"></a>
102 <div class="memitem">
103 <div class="memproto">
104       <table class="memname">
105         <tr>
106           <td class="memname">#define JSON_EXPORT&#160;&#160;&#160;extern</td>
107         </tr>
108       </table>
109 </div><div class="memdoc">
110 
111 </div>
112 </div>
113 <a class="anchor" id="acdd84ad88987c0166b7ba0e3f1f8f1bb"></a>
114 <div class="memitem">
115 <div class="memproto">
116       <table class="memname">
117         <tr>
118           <td class="memname">#define printbuf_length</td>
119           <td>(</td>
120           <td class="paramtype">&#160;</td>
121           <td class="paramname">p</td><td>)</td>
122           <td>&#160;&#160;&#160;((p)-&gt;bpos)</td>
123         </tr>
124       </table>
125 </div><div class="memdoc">
126 
127 </div>
128 </div>
129 <a class="anchor" id="a6f3a4dc87fab41c37e3eff42f40dc346"></a>
130 <div class="memitem">
131 <div class="memproto">
132       <table class="memname">
133         <tr>
134           <td class="memname">#define printbuf_memappend_fast</td>
135           <td>(</td>
136           <td class="paramtype">&#160;</td>
137           <td class="paramname">p, </td>
138         </tr>
139         <tr>
140           <td class="paramkey"></td>
141           <td></td>
142           <td class="paramtype">&#160;</td>
143           <td class="paramname">bufptr, </td>
144         </tr>
145         <tr>
146           <td class="paramkey"></td>
147           <td></td>
148           <td class="paramtype">&#160;</td>
149           <td class="paramname">bufsize&#160;</td>
150         </tr>
151         <tr>
152           <td></td>
153           <td>)</td>
154           <td></td><td></td>
155         </tr>
156       </table>
157 </div><div class="memdoc">
158 <b>Value:</b><div class="fragment"><div class="line"><span class="keywordflow">do</span>                                                           \</div>
159 <div class="line">        {                                                            \</div>
160 <div class="line">                if ((p-&gt;size - p-&gt;bpos) &gt; bufsize)                   \</div>
161 <div class="line">                {                                                    \</div>
162 <div class="line">                        memcpy(p-&gt;buf + p-&gt;bpos, (bufptr), bufsize); \</div>
163 <div class="line">                        p-&gt;bpos += bufsize;                          \</div>
164 <div class="line">                        p-&gt;buf[p-&gt;bpos] = <span class="charliteral">&#39;\0&#39;</span>;                      \</div>
165 <div class="line">                }                                                    \</div>
166 <div class="line">                else                                                 \</div>
167 <div class="line">                {                                                    \</div>
168 <div class="line">                        printbuf_memappend(p, (bufptr), bufsize);    \</div>
169 <div class="line">                }                                                    \</div>
170 <div class="line">        } <span class="keywordflow">while</span> (0)</div>
171 </div><!-- fragment -->
172 </div>
173 </div>
174 <a class="anchor" id="a2f30492682f5fbc59a8749b428e0e4ba"></a>
175 <div class="memitem">
176 <div class="memproto">
177       <table class="memname">
178         <tr>
179           <td class="memname">#define printbuf_strappend</td>
180           <td>(</td>
181           <td class="paramtype">&#160;</td>
182           <td class="paramname">pb, </td>
183         </tr>
184         <tr>
185           <td class="paramkey"></td>
186           <td></td>
187           <td class="paramtype">&#160;</td>
188           <td class="paramname">str&#160;</td>
189         </tr>
190         <tr>
191           <td></td>
192           <td>)</td>
193           <td></td><td>&#160;&#160;&#160;<a class="el" href="printbuf_8h.html#a9c193d30e9ca4936ea28a6c9e8e4f6f0">printbuf_memappend</a>((pb), _printbuf_check_literal(str), sizeof(str) - 1)</td>
194         </tr>
195       </table>
196 </div><div class="memdoc">
197 <p>This is an optimization wrapper around <a class="el" href="printbuf_8h.html#a9c193d30e9ca4936ea28a6c9e8e4f6f0">printbuf_memappend()</a> that is useful for appending string literals. Since the size of string constants is known at compile time, using this macro can avoid a costly strlen() call. This is especially helpful when a constant string must be appended many times. If you got here because of a compilation error caused by passing something other than a string literal, use <a class="el" href="printbuf_8h.html#a6f3a4dc87fab41c37e3eff42f40dc346">printbuf_memappend_fast()</a> in conjunction with strlen().</p>
198 <p>See also: <a class="el" href="printbuf_8h.html#a6f3a4dc87fab41c37e3eff42f40dc346">printbuf_memappend_fast()</a> <a class="el" href="printbuf_8h.html#a9c193d30e9ca4936ea28a6c9e8e4f6f0">printbuf_memappend()</a> <a class="el" href="printbuf_8h.html#a61f6bc0b1ca5787f0faca6799d61a0bb">sprintbuf()</a> </p>
199 
200 </div>
201 </div>
202 <h2 class="groupheader">Typedef Documentation</h2>
203 <a class="anchor" id="ace274df280df67463ff417b1b3392395"></a>
204 <div class="memitem">
205 <div class="memproto">
206       <table class="memname">
207         <tr>
208           <td class="memname">typedef struct <a class="el" href="structprintbuf.html">printbuf</a> <a class="el" href="structprintbuf.html">printbuf</a></td>
209         </tr>
210       </table>
211 </div><div class="memdoc">
212 
213 </div>
214 </div>
215 <h2 class="groupheader">Function Documentation</h2>
216 <a class="anchor" id="a2b744266191ef5e3102fbf910e790a98"></a>
217 <div class="memitem">
218 <div class="memproto">
219       <table class="memname">
220         <tr>
221           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> void printbuf_free </td>
222           <td>(</td>
223           <td class="paramtype">struct <a class="el" href="structprintbuf.html">printbuf</a> *&#160;</td>
224           <td class="paramname"><em>p</em></td><td>)</td>
225           <td></td>
226         </tr>
227       </table>
228 </div><div class="memdoc">
229 
230 </div>
231 </div>
232 <a class="anchor" id="a9c193d30e9ca4936ea28a6c9e8e4f6f0"></a>
233 <div class="memitem">
234 <div class="memproto">
235       <table class="memname">
236         <tr>
237           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int printbuf_memappend </td>
238           <td>(</td>
239           <td class="paramtype">struct <a class="el" href="structprintbuf.html">printbuf</a> *&#160;</td>
240           <td class="paramname"><em>p</em>, </td>
241         </tr>
242         <tr>
243           <td class="paramkey"></td>
244           <td></td>
245           <td class="paramtype">const char *&#160;</td>
246           <td class="paramname"><em>buf</em>, </td>
247         </tr>
248         <tr>
249           <td class="paramkey"></td>
250           <td></td>
251           <td class="paramtype">int&#160;</td>
252           <td class="paramname"><em>size</em>&#160;</td>
253         </tr>
254         <tr>
255           <td></td>
256           <td>)</td>
257           <td></td><td></td>
258         </tr>
259       </table>
260 </div><div class="memdoc">
261 
262 </div>
263 </div>
264 <a class="anchor" id="a93a27f4f8a092c58666724de23ae804d"></a>
265 <div class="memitem">
266 <div class="memproto">
267       <table class="memname">
268         <tr>
269           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int printbuf_memset </td>
270           <td>(</td>
271           <td class="paramtype">struct <a class="el" href="structprintbuf.html">printbuf</a> *&#160;</td>
272           <td class="paramname"><em>pb</em>, </td>
273         </tr>
274         <tr>
275           <td class="paramkey"></td>
276           <td></td>
277           <td class="paramtype">int&#160;</td>
278           <td class="paramname"><em>offset</em>, </td>
279         </tr>
280         <tr>
281           <td class="paramkey"></td>
282           <td></td>
283           <td class="paramtype">int&#160;</td>
284           <td class="paramname"><em>charvalue</em>, </td>
285         </tr>
286         <tr>
287           <td class="paramkey"></td>
288           <td></td>
289           <td class="paramtype">int&#160;</td>
290           <td class="paramname"><em>len</em>&#160;</td>
291         </tr>
292         <tr>
293           <td></td>
294           <td>)</td>
295           <td></td><td></td>
296         </tr>
297       </table>
298 </div><div class="memdoc">
299 <p>Set len bytes of the buffer to charvalue, starting at offset offset. Similar to calling memset(x, charvalue, len);</p>
300 <p>The memory allocated for the buffer is extended as necessary.</p>
301 <p>If offset is -1, this starts at the end of the current data in the buffer. </p>
302 
303 </div>
304 </div>
305 <a class="anchor" id="a645670fa132f0ae9a75f43c0b464bdaf"></a>
306 <div class="memitem">
307 <div class="memproto">
308 <table class="mlabels">
309   <tr>
310   <td class="mlabels-left">
311       <table class="memname">
312         <tr>
313           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> struct <a class="el" href="structprintbuf.html">printbuf</a>* printbuf_new </td>
314           <td>(</td>
315           <td class="paramtype">void&#160;</td>
316           <td class="paramname"></td><td>)</td>
317           <td></td>
318         </tr>
319       </table>
320   </td>
321   <td class="mlabels-right">
322 <span class="mlabels"><span class="mlabel">read</span></span>  </td>
323   </tr>
324 </table>
325 </div><div class="memdoc">
326 
327 </div>
328 </div>
329 <a class="anchor" id="a705c62167df13e65e04de9ae60f6e136"></a>
330 <div class="memitem">
331 <div class="memproto">
332       <table class="memname">
333         <tr>
334           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> void printbuf_reset </td>
335           <td>(</td>
336           <td class="paramtype">struct <a class="el" href="structprintbuf.html">printbuf</a> *&#160;</td>
337           <td class="paramname"><em>p</em></td><td>)</td>
338           <td></td>
339         </tr>
340       </table>
341 </div><div class="memdoc">
342 
343 </div>
344 </div>
345 <a class="anchor" id="a61f6bc0b1ca5787f0faca6799d61a0bb"></a>
346 <div class="memitem">
347 <div class="memproto">
348       <table class="memname">
349         <tr>
350           <td class="memname"><a class="el" href="printbuf_8h.html#a2a31d5c00f3a4712f2d5d62aee66344e">JSON_EXPORT</a> int sprintbuf </td>
351           <td>(</td>
352           <td class="paramtype">struct <a class="el" href="structprintbuf.html">printbuf</a> *&#160;</td>
353           <td class="paramname"><em>p</em>, </td>
354         </tr>
355         <tr>
356           <td class="paramkey"></td>
357           <td></td>
358           <td class="paramtype">const char *&#160;</td>
359           <td class="paramname"><em>msg</em>, </td>
360         </tr>
361         <tr>
362           <td class="paramkey"></td>
363           <td></td>
364           <td class="paramtype">&#160;</td>
365           <td class="paramname"><em>...</em>&#160;</td>
366         </tr>
367         <tr>
368           <td></td>
369           <td>)</td>
370           <td></td><td></td>
371         </tr>
372       </table>
373 </div><div class="memdoc">
374 <p>Formatted print to printbuf.</p>
375 <p>This function is the most expensive of the available functions for appending string data to a printbuf and should be used only where convenience is more important than speed. Avoid using this function in high performance code or tight loops; in these scenarios, consider using snprintf() with a static buffer in conjunction with one of the printbuf_*append() functions.</p>
376 <p>See also: <a class="el" href="printbuf_8h.html#a6f3a4dc87fab41c37e3eff42f40dc346">printbuf_memappend_fast()</a> <a class="el" href="printbuf_8h.html#a9c193d30e9ca4936ea28a6c9e8e4f6f0">printbuf_memappend()</a> <a class="el" href="printbuf_8h.html#a2f30492682f5fbc59a8749b428e0e4ba">printbuf_strappend()</a> </p>
377 
378 </div>
379 </div>
380 </div><!-- contents -->
381 <!-- start footer part -->
382 <hr class="footer"/><address class="footer"><small>
383 Generated on Sun Jul 26 2020 15:11:19 for json-c by &#160;<a href="http://www.doxygen.org/index.html">
384 <img class="footer" src="doxygen.png" alt="doxygen"/>
385 </a> 1.8.2
386 </small></address>
387 </body>
388 </html>

This page was automatically generated by LXR 0.3.1.  •  OpenWrt