added Pcpstream example

This commit is contained in:
TLINDEN
2014-02-20 21:02:52 +01:00
parent 254c4cd39b
commit 30481fed9a
59 changed files with 253 additions and 105 deletions

View File

@@ -80,50 +80,50 @@
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;<span class="preprocessor">#include &quot;defines.h&quot;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<span class="preprocessor">#include &quot;buffer.h&quot;</span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;</div>
<div class="line"><a name="l00054"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html"> 54</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">_pcp_stream_t</a> {</div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#ab3be4b7b5c57f456ed996cb0b5d53f27"> 55</a></span>&#160; FILE *<a class="code" href="struct__pcp__stream__t.html#ab3be4b7b5c57f456ed996cb0b5d53f27" title="The backend FILE stream.">fd</a>; </div>
<div class="line"><a name="l00056"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#a320a3c593ebcf0a651700f9263e5d9b4"> 56</a></span>&#160; <a class="code" href="struct__pcp__buffer.html" title="A flexible buffer object wich automatically resizes, if neccessary.">Buffer</a> *<a class="code" href="struct__pcp__stream__t.html#a320a3c593ebcf0a651700f9263e5d9b4" title="The backend Buffer object.">b</a>; </div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#a5fc108c71fb18d9835f7083e1b2ff5fa"> 57</a></span>&#160; uint8_t <a class="code" href="struct__pcp__stream__t.html#a5fc108c71fb18d9835f7083e1b2ff5fa" title="Set to 1 if the backend is a Buffer.">is_buffer</a>; </div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#a4b0242f83eec494ee19ad41e08e924af"> 58</a></span>&#160; uint8_t <a class="code" href="struct__pcp__stream__t.html#a4b0242f83eec494ee19ad41e08e924af" title="Set to 1 if EOF reached.">eof</a>; </div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#aaed1bd389ba84b3cd87839088b4057ea"> 59</a></span>&#160; uint8_t <a class="code" href="struct__pcp__stream__t.html#aaed1bd389ba84b3cd87839088b4057ea" title="Set to 1 if an error occured.">err</a>; </div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;};</div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="code" href="group__Pcpstream.html#gaec72241f86d5391d5cae7477c66cdd73"> 63</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">_pcp_stream_t</a> <a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a>;</div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160;</div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;<span class="comment">/* initialize a new empty stream */</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *ps_init(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160;</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *<a class="code" href="group__Pcpstream.html#ga6733979d79704b2e3ce914662b0cebc8" title="Create a new stream, backed with an open file.">ps_new_file</a>(FILE *backendfd);</div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160;</div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *<a class="code" href="group__Pcpstream.html#ga1b50c92fdad290e59317af2404460662" title="Create a new input stream, backed with filled a buffer.">ps_new_inbuffer</a>(<a class="code" href="struct__pcp__buffer.html" title="A flexible buffer object wich automatically resizes, if neccessary.">Buffer</a> *<a class="code" href="struct__pcp__stream__t.html#a320a3c593ebcf0a651700f9263e5d9b4" title="The backend Buffer object.">b</a>);</div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160;</div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *<a class="code" href="group__Pcpstream.html#ga13ec0245b579949e6d586e1817615d2e" title="Create a new output stream, backed with a buffer.">ps_new_outbuffer</a>();</div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160;</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160;</div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#gacfede4b1e9fa1ce0ccd7a55379ff6f15" title="Read bytes into the given buffer from the current stream.">ps_read</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream, <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> readbytes);</div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160;</div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#gab8e98ef81e802a242fbdb788b4387873" title="Write bytes from the given buffer into the current stream.">ps_write</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream, <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> writebytes);</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160;</div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#gafd50eb5e9c8ba399e133b6029eca8856" title="Write a formatted string to the stream.">ps_print</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream, <span class="keyword">const</span> <span class="keywordtype">char</span> * fmt, ...);</div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160;</div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#ga72812698d6b6aca964c7289be41eccf8" title="Tell the current read or write offset.">ps_tell</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160;</div>
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>&#160;<a class="code" href="struct__pcp__buffer.html" title="A flexible buffer object wich automatically resizes, if neccessary.">Buffer</a> *<a class="code" href="group__Pcpstream.html#ga64bc34dfbc1b3951c3d62e82a1ae8c34" title="Access the Buffer backend pointer.">ps_buffer</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>&#160;</div>
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__Pcpstream.html#ga4a68da22eca6e9bd854d54467a071d0a" title="Close the stream and frees allocated memory.">ps_close</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00188"></a><span class="lineno"> 188</span>&#160;</div>
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group__Pcpstream.html#gac845e4dc3677aeef5e4de343d3f8033d" title="Check if EOF have been reached.">ps_end</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160;</div>
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group__Pcpstream.html#ga97b83164ecda8fd66897863ec7976890" title="Check if an error occurred during a read or write operation.">ps_err</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160;</div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160;</div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160;<span class="preprocessor">#endif // HAVE_PCP_PCPSTEAM_H</span></div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html"> 58</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">_pcp_stream_t</a> {</div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#ab3be4b7b5c57f456ed996cb0b5d53f27"> 59</a></span>&#160; FILE *<a class="code" href="struct__pcp__stream__t.html#ab3be4b7b5c57f456ed996cb0b5d53f27" title="The backend FILE stream.">fd</a>; </div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#a320a3c593ebcf0a651700f9263e5d9b4"> 60</a></span>&#160; <a class="code" href="struct__pcp__buffer.html" title="A flexible buffer object wich automatically resizes, if neccessary.">Buffer</a> *<a class="code" href="struct__pcp__stream__t.html#a320a3c593ebcf0a651700f9263e5d9b4" title="The backend Buffer object.">b</a>; </div>
<div class="line"><a name="l00061"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#a5fc108c71fb18d9835f7083e1b2ff5fa"> 61</a></span>&#160; uint8_t <a class="code" href="struct__pcp__stream__t.html#a5fc108c71fb18d9835f7083e1b2ff5fa" title="Set to 1 if the backend is a Buffer.">is_buffer</a>; </div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#a4b0242f83eec494ee19ad41e08e924af"> 62</a></span>&#160; uint8_t <a class="code" href="struct__pcp__stream__t.html#a4b0242f83eec494ee19ad41e08e924af" title="Set to 1 if EOF reached.">eof</a>; </div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="code" href="struct__pcp__stream__t.html#aaed1bd389ba84b3cd87839088b4057ea"> 63</a></span>&#160; uint8_t <a class="code" href="struct__pcp__stream__t.html#aaed1bd389ba84b3cd87839088b4057ea" title="Set to 1 if an error occured.">err</a>; </div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160;};</div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160;</div>
<div class="line"><a name="l00067"></a><span class="lineno"><a class="code" href="group__Pcpstream.html#gaec72241f86d5391d5cae7477c66cdd73"> 67</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">_pcp_stream_t</a> <a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a>;</div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160;</div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160;<span class="comment">/* initialize a new empty stream */</span></div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *ps_init(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160;</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *<a class="code" href="group__Pcpstream.html#ga6733979d79704b2e3ce914662b0cebc8" title="Create a new stream, backed with an open file.">ps_new_file</a>(FILE *backendfd);</div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160;</div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *<a class="code" href="group__Pcpstream.html#ga1b50c92fdad290e59317af2404460662" title="Create a new input stream, backed with filled a buffer.">ps_new_inbuffer</a>(<a class="code" href="struct__pcp__buffer.html" title="A flexible buffer object wich automatically resizes, if neccessary.">Buffer</a> *<a class="code" href="struct__pcp__stream__t.html#a320a3c593ebcf0a651700f9263e5d9b4" title="The backend Buffer object.">b</a>);</div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160;</div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160;<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *<a class="code" href="group__Pcpstream.html#ga13ec0245b579949e6d586e1817615d2e" title="Create a new output stream, backed with a buffer.">ps_new_outbuffer</a>();</div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160;</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160;</div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#gacfede4b1e9fa1ce0ccd7a55379ff6f15" title="Read bytes into the given buffer from the current stream.">ps_read</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream, <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> readbytes);</div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160;</div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#gab8e98ef81e802a242fbdb788b4387873" title="Write bytes from the given buffer into the current stream.">ps_write</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream, <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> writebytes);</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160;</div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#gafd50eb5e9c8ba399e133b6029eca8856" title="Write a formatted string to the stream.">ps_print</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream, <span class="keyword">const</span> <span class="keywordtype">char</span> * fmt, ...);</div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160;</div>
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160;<span class="keywordtype">size_t</span> <a class="code" href="group__Pcpstream.html#ga72812698d6b6aca964c7289be41eccf8" title="Tell the current read or write offset.">ps_tell</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160;</div>
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>&#160;<a class="code" href="struct__pcp__buffer.html" title="A flexible buffer object wich automatically resizes, if neccessary.">Buffer</a> *<a class="code" href="group__Pcpstream.html#ga64bc34dfbc1b3951c3d62e82a1ae8c34" title="Access the Buffer backend pointer.">ps_buffer</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span>&#160;</div>
<div class="line"><a name="l00191"></a><span class="lineno"> 191</span>&#160;<span class="keywordtype">void</span> <a class="code" href="group__Pcpstream.html#ga4a68da22eca6e9bd854d54467a071d0a" title="Close the stream and frees allocated memory.">ps_close</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>&#160;</div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group__Pcpstream.html#gac845e4dc3677aeef5e4de343d3f8033d" title="Check if EOF have been reached.">ps_end</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160;</div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group__Pcpstream.html#ga97b83164ecda8fd66897863ec7976890" title="Check if an error occurred during a read or write operation.">ps_err</a>(<a class="code" href="struct__pcp__stream__t.html" title="An I/O wrapper object backed by a file or a buffer.">Pcpstream</a> *stream);</div>
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160;</div>
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160;</div>
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160;<span class="preprocessor">#endif // HAVE_PCP_PCPSTEAM_H</span></div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160;</div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Feb 20 2014 19:59:14 for libpcp by &#160;<a href="http://www.doxygen.org/index.html">
Generated on Thu Feb 20 2014 20:58:12 for libpcp by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.2
</small></address>