blob: 4d0d54373f13ea006b9cfd2371e6acc33bc1b89a [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>HTML Tidy: buffio.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">HTML Tidy
&#160;<span id="projectnumber">0.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.0 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
initNavTree('buffio_8h.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">buffio.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="buffio_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef __TIDY_BUFFIO_H__</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define __TIDY_BUFFIO_H__</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">/** @file buffio.h - Treat buffer as an I/O stream.</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment"> (c) 1998-2007 (W3C) MIT, ERCIM, Keio University</span>
<a name="l00007"></a>00007 <span class="comment"> See tidy.h for the copyright notice.</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment"> CVS Info :</span>
<a name="l00010"></a>00010 <span class="comment"></span>
<a name="l00011"></a>00011 <span class="comment"> $Author: arnaud02 $ </span>
<a name="l00012"></a>00012 <span class="comment"> $Date: 2007/01/23 11:17:45 $ </span>
<a name="l00013"></a>00013 <span class="comment"> $Revision: 1.9 $ </span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment"> Requires buffer to automatically grow as bytes are added.</span>
<a name="l00016"></a>00016 <span class="comment"> Must keep track of current read and write points.</span>
<a name="l00017"></a>00017 <span class="comment"></span>
<a name="l00018"></a>00018 <span class="comment">*/</span>
<a name="l00019"></a>00019
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;platform.h&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="tidy_8h.html">tidy.h</a>&quot;</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00025"></a>00025 <span class="preprocessor">#endif</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00027"></a>00027 <span class="comment">/** TidyBuffer - A chunk of memory */</span>
<a name="l00028"></a>00028 TIDY_STRUCT
<a name="l00029"></a><a class="code" href="struct__TidyBuffer.html">00029</a> <span class="keyword">struct </span><a class="code" href="struct__TidyBuffer.html">_TidyBuffer</a>
<a name="l00030"></a>00030 {
<a name="l00031"></a><a class="code" href="struct__TidyBuffer.html#ab6655c52ed81490e8016976a4810a330">00031</a> <a class="code" href="struct__TidyAllocator.html">TidyAllocator</a>* <a class="code" href="struct__TidyBuffer.html#ab6655c52ed81490e8016976a4810a330">allocator</a>; <span class="comment">/**&lt; Memory allocator */</span>
<a name="l00032"></a><a class="code" href="struct__TidyBuffer.html#a2b1c3814410eefbe2168b248485eea91">00032</a> byte* <a class="code" href="struct__TidyBuffer.html#a2b1c3814410eefbe2168b248485eea91">bp</a>; <span class="comment">/**&lt; Pointer to bytes */</span>
<a name="l00033"></a><a class="code" href="struct__TidyBuffer.html#a227728492f6266dec940bcc541046cd9">00033</a> uint <a class="code" href="struct__TidyBuffer.html#a227728492f6266dec940bcc541046cd9">size</a>; <span class="comment">/**&lt; # bytes currently in use */</span>
<a name="l00034"></a><a class="code" href="struct__TidyBuffer.html#a523a1f5f2a1b0333d70b9d8a5a52de13">00034</a> uint <a class="code" href="struct__TidyBuffer.html#a523a1f5f2a1b0333d70b9d8a5a52de13">allocated</a>; <span class="comment">/**&lt; # bytes allocated */</span>
<a name="l00035"></a><a class="code" href="struct__TidyBuffer.html#af607eaeb44ae6d8f2371e1e05b016caf">00035</a> uint <a class="code" href="struct__TidyBuffer.html#af607eaeb44ae6d8f2371e1e05b016caf">next</a>; <span class="comment">/**&lt; Offset of current input position */</span>
<a name="l00036"></a>00036 };
<a name="l00037"></a>00037 <span class="comment"></span>
<a name="l00038"></a>00038 <span class="comment">/** Initialize data structure using the default allocator */</span>
<a name="l00039"></a>00039 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a3cf251a96f69f05495744af6c9d0339b">tidyBufInit</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00040"></a>00040 <span class="comment"></span>
<a name="l00041"></a>00041 <span class="comment">/** Initialize data structure using the given custom allocator */</span>
<a name="l00042"></a>00042 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#aff43ddd9fc78532617d88db55b164f5e">tidyBufInitWithAllocator</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf, <a class="code" href="struct__TidyAllocator.html">TidyAllocator</a>* allocator );
<a name="l00043"></a>00043 <span class="comment"></span>
<a name="l00044"></a>00044 <span class="comment">/** Free current buffer, allocate given amount, reset input pointer,</span>
<a name="l00045"></a>00045 <span class="comment"> use the default allocator */</span>
<a name="l00046"></a>00046 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a896654bd99113bfe5e86b924836aacc3">tidyBufAlloc</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf, uint allocSize );
<a name="l00047"></a>00047 <span class="comment"></span>
<a name="l00048"></a>00048 <span class="comment">/** Free current buffer, allocate given amount, reset input pointer,</span>
<a name="l00049"></a>00049 <span class="comment"> use the given custom allocator */</span>
<a name="l00050"></a>00050 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a57c832b4ddbc19a329a5ab9936eb5826">tidyBufAllocWithAllocator</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf,
<a name="l00051"></a>00051 <a class="code" href="struct__TidyAllocator.html">TidyAllocator</a>* allocator,
<a name="l00052"></a>00052 uint allocSize );
<a name="l00053"></a>00053 <span class="comment"></span>
<a name="l00054"></a>00054 <span class="comment">/** Expand buffer to given size. </span>
<a name="l00055"></a>00055 <span class="comment">** Chunk size is minimum growth. Pass 0 for default of 256 bytes.</span>
<a name="l00056"></a>00056 <span class="comment">*/</span>
<a name="l00057"></a>00057 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a7a66ba1f574955d1fc1de57476e849f2">tidyBufCheckAlloc</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf,
<a name="l00058"></a>00058 uint allocSize, uint chunkSize );
<a name="l00059"></a>00059 <span class="comment"></span>
<a name="l00060"></a>00060 <span class="comment">/** Free current contents and zero out */</span>
<a name="l00061"></a>00061 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a65aae9ae4b499e62038700f4792849fc">tidyBufFree</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00062"></a>00062 <span class="comment"></span>
<a name="l00063"></a>00063 <span class="comment">/** Set buffer bytes to 0 */</span>
<a name="l00064"></a>00064 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#aa94e59f613a495b17e90c1c4778c3911">tidyBufClear</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00065"></a>00065 <span class="comment"></span>
<a name="l00066"></a>00066 <span class="comment">/** Attach to existing buffer */</span>
<a name="l00067"></a>00067 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#ac5909e78d98583cb245dd2004469bb93">tidyBufAttach</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf, byte* bp, uint size );
<a name="l00068"></a>00068 <span class="comment"></span>
<a name="l00069"></a>00069 <span class="comment">/** Detach from buffer. Caller must free. */</span>
<a name="l00070"></a>00070 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a8da2bf473b14e6bdd5cd40fc47c29903">tidyBufDetach</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="comment"></span>
<a name="l00073"></a>00073 <span class="comment">/** Append bytes to buffer. Expand if necessary. */</span>
<a name="l00074"></a>00074 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#ad59b32f81789b634758274f34be4d25b">tidyBufAppend</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf, <span class="keywordtype">void</span>* vp, uint size );
<a name="l00075"></a>00075 <span class="comment"></span>
<a name="l00076"></a>00076 <span class="comment">/** Append one byte to buffer. Expand if necessary. */</span>
<a name="l00077"></a>00077 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#af48af586ada5ff264501fe9ef4c67dd1">tidyBufPutByte</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf, byte bv );
<a name="l00078"></a>00078 <span class="comment"></span>
<a name="l00079"></a>00079 <span class="comment">/** Get byte from end of buffer */</span>
<a name="l00080"></a>00080 TIDY_EXPORT <span class="keywordtype">int</span> TIDY_CALL <a class="code" href="buffio_8h.html#af8b1e8fbe3c29d08250794d7e4925ea6">tidyBufPopByte</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="comment"></span>
<a name="l00083"></a>00083 <span class="comment">/** Get byte from front of buffer. Increment input offset. */</span>
<a name="l00084"></a>00084 TIDY_EXPORT <span class="keywordtype">int</span> TIDY_CALL <a class="code" href="buffio_8h.html#a5a2e0c47b4b14b5beb17ac982fa21eeb">tidyBufGetByte</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00085"></a>00085 <span class="comment"></span>
<a name="l00086"></a>00086 <span class="comment">/** At end of buffer? */</span>
<a name="l00087"></a>00087 TIDY_EXPORT Bool TIDY_CALL <a class="code" href="buffio_8h.html#a7e7d8e58623c8bde00d66141edb2cae0">tidyBufEndOfInput</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00088"></a>00088 <span class="comment"></span>
<a name="l00089"></a>00089 <span class="comment">/** Put a byte back into the buffer. Decrement input offset. */</span>
<a name="l00090"></a>00090 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a1d1f2039b769381d418ac1187b50b292">tidyBufUngetByte</a>( <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf, byte bv );
<a name="l00091"></a>00091
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="comment">/**************</span>
<a name="l00094"></a>00094 <span class="comment"> TIDY</span>
<a name="l00095"></a>00095 <span class="comment">**************/</span>
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="comment">/* Forward declarations</span>
<a name="l00098"></a>00098 <span class="comment">*/</span>
<a name="l00099"></a>00099 <span class="comment"></span>
<a name="l00100"></a>00100 <span class="comment">/** Initialize a buffer input source */</span>
<a name="l00101"></a>00101 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a73da3182aea89939af1d98504a3b2df0">tidyInitInputBuffer</a>( <a class="code" href="group__IO.html#ga86fcc3c86bd63b26a559938bc38d34bb">TidyInputSource</a>* inp, <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00102"></a>00102 <span class="comment"></span>
<a name="l00103"></a>00103 <span class="comment">/** Initialize a buffer output sink */</span>
<a name="l00104"></a>00104 TIDY_EXPORT <span class="keywordtype">void</span> TIDY_CALL <a class="code" href="buffio_8h.html#a882a92590a9e6ecce16d5b8e8db19fbb">tidyInitOutputBuffer</a>( <a class="code" href="group__IO.html#ga6bdd15de48364d2b5dbf2141109d3f98">TidyOutputSink</a>* outp, <a class="code" href="struct__TidyBuffer.html">TidyBuffer</a>* buf );
<a name="l00105"></a>00105
<a name="l00106"></a>00106 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00107"></a>00107 <span class="preprocessor"></span>}
<a name="l00108"></a>00108 <span class="preprocessor">#endif</span>
<a name="l00109"></a>00109 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* __TIDY_BUFFIO_H__ */</span>
<a name="l00110"></a>00110
<a name="l00111"></a>00111 <span class="comment">/*</span>
<a name="l00112"></a>00112 <span class="comment"> * local variables:</span>
<a name="l00113"></a>00113 <span class="comment"> * mode: c</span>
<a name="l00114"></a>00114 <span class="comment"> * indent-tabs-mode: nil</span>
<a name="l00115"></a>00115 <span class="comment"> * c-basic-offset: 4</span>
<a name="l00116"></a>00116 <span class="comment"> * eval: (c-set-offset &#39;substatement-open 0)</span>
<a name="l00117"></a>00117 <span class="comment"> * end:</span>
<a name="l00118"></a>00118 <span class="comment"> */</span>
</pre></div></div><!-- contents -->
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="buffio_8h.html">buffio.h</a> </li>
<li class="footer">Generated on Wed Jun 20 2012 16:58:07 for HTML Tidy by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.0 </li>
</ul>
</div>
</body>
</html>