Tue, 30 Aug 2022 19:55:56 +0200
some function can be macros using the default allocator
390 | 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 | <meta name="generator" content="Doxygen 1.8.13"/> | |
7 | <meta name="viewport" content="width=device-width, initial-scale=1"/> | |
8 | <title>ucx: /home/mike/workspace/c/ucx/src/ucx/buffer.h File Reference</title> | |
9 | <link href="tabs.css" rel="stylesheet" type="text/css"/> | |
10 | <script type="text/javascript" src="jquery.js"></script> | |
11 | <script type="text/javascript" src="dynsections.js"></script> | |
12 | <link href="search/search.css" rel="stylesheet" type="text/css"/> | |
13 | <script type="text/javascript" src="search/searchdata.js"></script> | |
14 | <script type="text/javascript" src="search/search.js"></script> | |
15 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> | |
16 | </head> | |
17 | <body> | |
18 | <div id="top"><!-- do not remove this div, it is closed by doxygen! --> | |
19 | <div id="titlearea"> | |
20 | <table cellspacing="0" cellpadding="0"> | |
21 | <tbody> | |
22 | <tr style="height: 56px;"> | |
23 | <td id="projectlogo"><img alt="Logo" src="uaplogo.png"/></td> | |
24 | <td id="projectalign" style="padding-left: 0.5em;"> | |
25 | <div id="projectname">ucx | |
26 | </div> | |
27 | <div id="projectbrief">UAP Common Extensions</div> | |
28 | </td> | |
29 | </tr> | |
30 | </tbody> | |
31 | </table> | |
32 | </div> | |
33 | <!-- end header part --> | |
34 | <!-- Generated by Doxygen 1.8.13 --> | |
35 | <script type="text/javascript"> | |
36 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); | |
37 | </script> | |
38 | <script type="text/javascript" src="menudata.js"></script> | |
39 | <script type="text/javascript" src="menu.js"></script> | |
40 | <script type="text/javascript"> | |
41 | $(function() { | |
42 | initMenu('',true,false,'search.php','Search'); | |
43 | $(document).ready(function() { init_search(); }); | |
44 | }); | |
45 | </script> | |
46 | <div id="main-nav"></div> | |
47 | <!-- window showing the filter options --> | |
48 | <div id="MSearchSelectWindow" | |
49 | onmouseover="return searchBox.OnSearchSelectShow()" | |
50 | onmouseout="return searchBox.OnSearchSelectHide()" | |
51 | onkeydown="return searchBox.OnSearchSelectKey(event)"> | |
52 | </div> | |
53 | ||
54 | <!-- iframe showing the search results (closed by default) --> | |
55 | <div id="MSearchResultsWindow"> | |
56 | <iframe src="javascript:void(0)" frameborder="0" | |
57 | name="MSearchResults" id="MSearchResults"> | |
58 | </iframe> | |
59 | </div> | |
60 | ||
61 | <div id="nav-path" class="navpath"> | |
62 | <ul> | |
63 | <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_69f4ea29401808fe6229564976cde3ce.html">ucx</a></li> </ul> | |
64 | </div> | |
65 | </div><!-- top --> | |
66 | <div class="header"> | |
67 | <div class="summary"> | |
68 | <a href="#nested-classes">Data Structures</a> | | |
69 | <a href="#define-members">Macros</a> | | |
70 | <a href="#func-members">Functions</a> </div> | |
71 | <div class="headertitle"> | |
72 | <div class="title">buffer.h File Reference</div> </div> | |
73 | </div><!--header--> | |
74 | <div class="contents"> | |
75 | ||
76 | <p>Advanced buffer implementation. | |
77 | <a href="#details">More...</a></p> | |
78 | <div class="textblock"><code>#include "<a class="el" href="ucx_8h_source.html">ucx.h</a>"</code><br /> | |
79 | <code>#include <sys/types.h></code><br /> | |
80 | <code>#include <stdio.h></code><br /> | |
81 | </div> | |
82 | <p><a href="buffer_8h_source.html">Go to the source code of this file.</a></p> | |
83 | <table class="memberdecls"> | |
84 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> | |
85 | Data Structures</h2></td></tr> | |
86 | <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structUcxBuffer.html">UcxBuffer</a></td></tr> | |
87 | <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">UCX Buffer. <a href="structUcxBuffer.html#details">More...</a><br /></td></tr> | |
88 | <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> | |
89 | </table><table class="memberdecls"> | |
90 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> | |
91 | Macros</h2></td></tr> | |
92 | <tr class="memitem:acc77c8ed7b26854f555d4a5d11e49ea2"><td class="memItemLeft" align="right" valign="top"><a id="acc77c8ed7b26854f555d4a5d11e49ea2"></a> | |
93 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#acc77c8ed7b26854f555d4a5d11e49ea2">UCX_BUFFER_DEFAULT</a>   0x00</td></tr> | |
94 | <tr class="memdesc:acc77c8ed7b26854f555d4a5d11e49ea2"><td class="mdescLeft"> </td><td class="mdescRight">No buffer features enabled (all flags cleared). <br /></td></tr> | |
95 | <tr class="separator:acc77c8ed7b26854f555d4a5d11e49ea2"><td class="memSeparator" colspan="2"> </td></tr> | |
96 | <tr class="memitem:a8bab11ad8a76719228b9ee91e2e45535"><td class="memItemLeft" align="right" valign="top"><a id="a8bab11ad8a76719228b9ee91e2e45535"></a> | |
97 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a8bab11ad8a76719228b9ee91e2e45535">UCX_BUFFER_AUTOFREE</a>   0x01</td></tr> | |
98 | <tr class="memdesc:a8bab11ad8a76719228b9ee91e2e45535"><td class="mdescLeft"> </td><td class="mdescRight">If this flag is enabled, the buffer will automatically free its contents. <br /></td></tr> | |
99 | <tr class="separator:a8bab11ad8a76719228b9ee91e2e45535"><td class="memSeparator" colspan="2"> </td></tr> | |
100 | <tr class="memitem:a05f9565f2d04399168c3b1c152a632be"><td class="memItemLeft" align="right" valign="top"><a id="a05f9565f2d04399168c3b1c152a632be"></a> | |
101 | #define </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a05f9565f2d04399168c3b1c152a632be">UCX_BUFFER_AUTOEXTEND</a>   0x02</td></tr> | |
102 | <tr class="memdesc:a05f9565f2d04399168c3b1c152a632be"><td class="mdescLeft"> </td><td class="mdescRight">If this flag is enabled, the buffer will automatically extends its capacity. <br /></td></tr> | |
103 | <tr class="separator:a05f9565f2d04399168c3b1c152a632be"><td class="memSeparator" colspan="2"> </td></tr> | |
104 | <tr class="memitem:a828353846428c2c2f695f9938f059e52"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a828353846428c2c2f695f9938f059e52">ucx_buffer_clone</a>(src, flags)   <a class="el" href="buffer_8h.html#a33fa7bb35fe08bbb3542f227514332ef">ucx_buffer_extract</a>(src, 0, (src)->capacity, flags)</td></tr> | |
105 | <tr class="memdesc:a828353846428c2c2f695f9938f059e52"><td class="mdescLeft"> </td><td class="mdescRight">A shorthand macro for the full extraction of the buffer. <a href="#a828353846428c2c2f695f9938f059e52">More...</a><br /></td></tr> | |
106 | <tr class="separator:a828353846428c2c2f695f9938f059e52"><td class="memSeparator" colspan="2"> </td></tr> | |
107 | <tr class="memitem:a374abd5aabfcc3ee0777a79d5fe651ab"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a374abd5aabfcc3ee0777a79d5fe651ab">ucx_buffer_clear</a>(buffer)</td></tr> | |
108 | <tr class="memdesc:a374abd5aabfcc3ee0777a79d5fe651ab"><td class="mdescLeft"> </td><td class="mdescRight">Clears the buffer by resetting the position and deleting the data. <a href="#a374abd5aabfcc3ee0777a79d5fe651ab">More...</a><br /></td></tr> | |
109 | <tr class="separator:a374abd5aabfcc3ee0777a79d5fe651ab"><td class="memSeparator" colspan="2"> </td></tr> | |
110 | <tr class="memitem:a0f4b64f1b3a74c4f6c5d9409d6b6086a"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a0f4b64f1b3a74c4f6c5d9409d6b6086a">ucx_buffer_to_sstr</a>(buffer)   <a class="el" href="string_8h.html#a2744c38ac44abf3e01fa059056dcf36c">sstrn</a>((buffer)->space, (buffer)->size)</td></tr> | |
111 | <tr class="memdesc:a0f4b64f1b3a74c4f6c5d9409d6b6086a"><td class="mdescLeft"> </td><td class="mdescRight">Returns the complete buffer content as <a class="el" href="structsstr__t.html" title="The UCX string structure. ">sstr_t</a>. <a href="#a0f4b64f1b3a74c4f6c5d9409d6b6086a">More...</a><br /></td></tr> | |
112 | <tr class="separator:a0f4b64f1b3a74c4f6c5d9409d6b6086a"><td class="memSeparator" colspan="2"> </td></tr> | |
113 | </table><table class="memberdecls"> | |
114 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> | |
115 | Functions</h2></td></tr> | |
116 | <tr class="memitem:aacea876d692193ec6f859ce98da7351c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#aacea876d692193ec6f859ce98da7351c">ucx_buffer_new</a> (void *space, size_t capacity, int flags)</td></tr> | |
117 | <tr class="memdesc:aacea876d692193ec6f859ce98da7351c"><td class="mdescLeft"> </td><td class="mdescRight">Creates a new buffer. <a href="#aacea876d692193ec6f859ce98da7351c">More...</a><br /></td></tr> | |
118 | <tr class="separator:aacea876d692193ec6f859ce98da7351c"><td class="memSeparator" colspan="2"> </td></tr> | |
119 | <tr class="memitem:a2af8646d8905c22c7322e7540b0440af"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a2af8646d8905c22c7322e7540b0440af">ucx_buffer_free</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer)</td></tr> | |
120 | <tr class="memdesc:a2af8646d8905c22c7322e7540b0440af"><td class="mdescLeft"> </td><td class="mdescRight">Destroys a buffer. <a href="#a2af8646d8905c22c7322e7540b0440af">More...</a><br /></td></tr> | |
121 | <tr class="separator:a2af8646d8905c22c7322e7540b0440af"><td class="memSeparator" colspan="2"> </td></tr> | |
122 | <tr class="memitem:a33fa7bb35fe08bbb3542f227514332ef"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a33fa7bb35fe08bbb3542f227514332ef">ucx_buffer_extract</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *src, size_t start, size_t length, int flags)</td></tr> | |
123 | <tr class="memdesc:a33fa7bb35fe08bbb3542f227514332ef"><td class="mdescLeft"> </td><td class="mdescRight">Creates a new buffer and fills it with extracted content from another buffer. <a href="#a33fa7bb35fe08bbb3542f227514332ef">More...</a><br /></td></tr> | |
124 | <tr class="separator:a33fa7bb35fe08bbb3542f227514332ef"><td class="memSeparator" colspan="2"> </td></tr> | |
125 | <tr class="memitem:a12a0c6a2379ef080043e6286bb8bad69"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a12a0c6a2379ef080043e6286bb8bad69">ucx_buffer_shift</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer, off_t shift)</td></tr> | |
126 | <tr class="memdesc:a12a0c6a2379ef080043e6286bb8bad69"><td class="mdescLeft"> </td><td class="mdescRight">Shifts the contents of the buffer by the given offset. <a href="#a12a0c6a2379ef080043e6286bb8bad69">More...</a><br /></td></tr> | |
127 | <tr class="separator:a12a0c6a2379ef080043e6286bb8bad69"><td class="memSeparator" colspan="2"> </td></tr> | |
128 | <tr class="memitem:a4fa10b6471495547eb981248fd4f1bc2"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a4fa10b6471495547eb981248fd4f1bc2">ucx_buffer_shift_right</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer, size_t shift)</td></tr> | |
129 | <tr class="memdesc:a4fa10b6471495547eb981248fd4f1bc2"><td class="mdescLeft"> </td><td class="mdescRight">Shifts the buffer to the right. <a href="#a4fa10b6471495547eb981248fd4f1bc2">More...</a><br /></td></tr> | |
130 | <tr class="separator:a4fa10b6471495547eb981248fd4f1bc2"><td class="memSeparator" colspan="2"> </td></tr> | |
131 | <tr class="memitem:a20431dd0ed6a6fe9f15333bd72afe4db"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a20431dd0ed6a6fe9f15333bd72afe4db">ucx_buffer_shift_left</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer, size_t shift)</td></tr> | |
132 | <tr class="memdesc:a20431dd0ed6a6fe9f15333bd72afe4db"><td class="mdescLeft"> </td><td class="mdescRight">Shifts the buffer to the left. <a href="#a20431dd0ed6a6fe9f15333bd72afe4db">More...</a><br /></td></tr> | |
133 | <tr class="separator:a20431dd0ed6a6fe9f15333bd72afe4db"><td class="memSeparator" colspan="2"> </td></tr> | |
134 | <tr class="memitem:a47d98482662073c74f35deb0957d15d1"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a47d98482662073c74f35deb0957d15d1">ucx_buffer_seek</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer, off_t offset, int whence)</td></tr> | |
135 | <tr class="memdesc:a47d98482662073c74f35deb0957d15d1"><td class="mdescLeft"> </td><td class="mdescRight">Moves the position of the buffer. <a href="#a47d98482662073c74f35deb0957d15d1">More...</a><br /></td></tr> | |
136 | <tr class="separator:a47d98482662073c74f35deb0957d15d1"><td class="memSeparator" colspan="2"> </td></tr> | |
137 | <tr class="memitem:abad7fd9ad5061224c780b8d1d4c55f09"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#abad7fd9ad5061224c780b8d1d4c55f09">ucx_buffer_eof</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer)</td></tr> | |
138 | <tr class="memdesc:abad7fd9ad5061224c780b8d1d4c55f09"><td class="mdescLeft"> </td><td class="mdescRight">Tests, if the buffer position has exceeded the buffer capacity. <a href="#abad7fd9ad5061224c780b8d1d4c55f09">More...</a><br /></td></tr> | |
139 | <tr class="separator:abad7fd9ad5061224c780b8d1d4c55f09"><td class="memSeparator" colspan="2"> </td></tr> | |
140 | <tr class="memitem:afaf97d2cd7e9faad79a9d35fe33e30c6"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#afaf97d2cd7e9faad79a9d35fe33e30c6">ucx_buffer_extend</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer, size_t additional_bytes)</td></tr> | |
141 | <tr class="memdesc:afaf97d2cd7e9faad79a9d35fe33e30c6"><td class="mdescLeft"> </td><td class="mdescRight">Extends the capacity of the buffer. <a href="#afaf97d2cd7e9faad79a9d35fe33e30c6">More...</a><br /></td></tr> | |
142 | <tr class="separator:afaf97d2cd7e9faad79a9d35fe33e30c6"><td class="memSeparator" colspan="2"> </td></tr> | |
143 | <tr class="memitem:af8aacc7401814392b58c1b7b81bffc05"><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#af8aacc7401814392b58c1b7b81bffc05">ucx_buffer_write</a> (const void *ptr, size_t size, size_t nitems, <a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer)</td></tr> | |
144 | <tr class="memdesc:af8aacc7401814392b58c1b7b81bffc05"><td class="mdescLeft"> </td><td class="mdescRight">Writes data to a <a class="el" href="structUcxBuffer.html" title="UCX Buffer. ">UcxBuffer</a>. <a href="#af8aacc7401814392b58c1b7b81bffc05">More...</a><br /></td></tr> | |
145 | <tr class="separator:af8aacc7401814392b58c1b7b81bffc05"><td class="memSeparator" colspan="2"> </td></tr> | |
146 | <tr class="memitem:ae5c3430759f0059547b35d5a254d4da5"><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#ae5c3430759f0059547b35d5a254d4da5">ucx_buffer_read</a> (void *ptr, size_t size, size_t nitems, <a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer)</td></tr> | |
147 | <tr class="memdesc:ae5c3430759f0059547b35d5a254d4da5"><td class="mdescLeft"> </td><td class="mdescRight">Reads data from a <a class="el" href="structUcxBuffer.html" title="UCX Buffer. ">UcxBuffer</a>. <a href="#ae5c3430759f0059547b35d5a254d4da5">More...</a><br /></td></tr> | |
148 | <tr class="separator:ae5c3430759f0059547b35d5a254d4da5"><td class="memSeparator" colspan="2"> </td></tr> | |
149 | <tr class="memitem:a7d6f01b9d631b0123475dfb98fb849ac"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a7d6f01b9d631b0123475dfb98fb849ac">ucx_buffer_putc</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer, int c)</td></tr> | |
150 | <tr class="memdesc:a7d6f01b9d631b0123475dfb98fb849ac"><td class="mdescLeft"> </td><td class="mdescRight">Writes a character to a buffer. <a href="#a7d6f01b9d631b0123475dfb98fb849ac">More...</a><br /></td></tr> | |
151 | <tr class="separator:a7d6f01b9d631b0123475dfb98fb849ac"><td class="memSeparator" colspan="2"> </td></tr> | |
152 | <tr class="memitem:a396339022159ce4ca6d069de9f9209b0"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#a396339022159ce4ca6d069de9f9209b0">ucx_buffer_getc</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer)</td></tr> | |
153 | <tr class="memdesc:a396339022159ce4ca6d069de9f9209b0"><td class="mdescLeft"> </td><td class="mdescRight">Gets a character from a buffer. <a href="#a396339022159ce4ca6d069de9f9209b0">More...</a><br /></td></tr> | |
154 | <tr class="separator:a396339022159ce4ca6d069de9f9209b0"><td class="memSeparator" colspan="2"> </td></tr> | |
155 | <tr class="memitem:af1d4b478e04b3ae0bf30e7c2ea964ea2"><td class="memItemLeft" align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="buffer_8h.html#af1d4b478e04b3ae0bf30e7c2ea964ea2">ucx_buffer_puts</a> (<a class="el" href="structUcxBuffer.html">UcxBuffer</a> *buffer, const char *str)</td></tr> | |
156 | <tr class="memdesc:af1d4b478e04b3ae0bf30e7c2ea964ea2"><td class="mdescLeft"> </td><td class="mdescRight">Writes a string to a buffer. <a href="#af1d4b478e04b3ae0bf30e7c2ea964ea2">More...</a><br /></td></tr> | |
157 | <tr class="separator:af1d4b478e04b3ae0bf30e7c2ea964ea2"><td class="memSeparator" colspan="2"> </td></tr> | |
158 | </table> | |
159 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> | |
160 | <div class="textblock"><p>Advanced buffer implementation. </p> | |
161 | <p>Instances of <a class="el" href="structUcxBuffer.html" title="UCX Buffer. ">UcxBuffer</a> can be used to read from or to write to like one would do with a stream. This allows the use of <a class="el" href="utils_8h.html#a41ca1344f781c0d3bf7a414a6e811392" title="Shorthand for an unbounded ucx_stream_bncopy call using a default buffer. ">ucx_stream_copy()</a> to copy contents from one buffer to another.</p> | |
162 | <p>Some features for convenient use of the buffer can be enabled. See the documentation of the macro constants for more information.</p> | |
163 | <dl class="section author"><dt>Author</dt><dd>Mike Becker </dd> | |
164 | <dd> | |
165 | Olaf Wintermann </dd></dl> | |
166 | </div><h2 class="groupheader">Macro Definition Documentation</h2> | |
167 | <a id="a374abd5aabfcc3ee0777a79d5fe651ab"></a> | |
168 | <h2 class="memtitle"><span class="permalink"><a href="#a374abd5aabfcc3ee0777a79d5fe651ab">◆ </a></span>ucx_buffer_clear</h2> | |
169 | ||
170 | <div class="memitem"> | |
171 | <div class="memproto"> | |
172 | <table class="memname"> | |
173 | <tr> | |
174 | <td class="memname">#define ucx_buffer_clear</td> | |
175 | <td>(</td> | |
176 | <td class="paramtype"> </td> | |
177 | <td class="paramname">buffer</td><td>)</td> | |
178 | <td></td> | |
179 | </tr> | |
180 | </table> | |
181 | </div><div class="memdoc"> | |
182 | <b>Value:</b><div class="fragment"><div class="line">memset((buffer)->space, 0, (buffer)->size); \</div><div class="line"> (buffer)->size = 0; (buffer)->pos = 0;</div></div><!-- fragment --> | |
183 | <p>Clears the buffer by resetting the position and deleting the data. </p> | |
184 | <p>The data is deleted by a zeroing it with call to <code>memset()</code>.</p> | |
185 | <dl class="params"><dt>Parameters</dt><dd> | |
186 | <table class="params"> | |
187 | <tr><td class="paramname">buffer</td><td>the buffer to be cleared </td></tr> | |
188 | </table> | |
189 | </dd> | |
190 | </dl> | |
191 | ||
192 | </div> | |
193 | </div> | |
194 | <a id="a828353846428c2c2f695f9938f059e52"></a> | |
195 | <h2 class="memtitle"><span class="permalink"><a href="#a828353846428c2c2f695f9938f059e52">◆ </a></span>ucx_buffer_clone</h2> | |
196 | ||
197 | <div class="memitem"> | |
198 | <div class="memproto"> | |
199 | <table class="memname"> | |
200 | <tr> | |
201 | <td class="memname">#define ucx_buffer_clone</td> | |
202 | <td>(</td> | |
203 | <td class="paramtype"> </td> | |
204 | <td class="paramname">src, </td> | |
205 | </tr> | |
206 | <tr> | |
207 | <td class="paramkey"></td> | |
208 | <td></td> | |
209 | <td class="paramtype"> </td> | |
210 | <td class="paramname">flags </td> | |
211 | </tr> | |
212 | <tr> | |
213 | <td></td> | |
214 | <td>)</td> | |
215 | <td></td><td>   <a class="el" href="buffer_8h.html#a33fa7bb35fe08bbb3542f227514332ef">ucx_buffer_extract</a>(src, 0, (src)->capacity, flags)</td> | |
216 | </tr> | |
217 | </table> | |
218 | </div><div class="memdoc"> | |
219 | ||
220 | <p>A shorthand macro for the full extraction of the buffer. </p> | |
221 | <dl class="params"><dt>Parameters</dt><dd> | |
222 | <table class="params"> | |
223 | <tr><td class="paramname">src</td><td>the source buffer </td></tr> | |
224 | <tr><td class="paramname">flags</td><td>feature mask for the new buffer </td></tr> | |
225 | </table> | |
226 | </dd> | |
227 | </dl> | |
228 | <dl class="section return"><dt>Returns</dt><dd>a new buffer with the extracted content </dd></dl> | |
229 | ||
230 | </div> | |
231 | </div> | |
232 | <a id="a0f4b64f1b3a74c4f6c5d9409d6b6086a"></a> | |
233 | <h2 class="memtitle"><span class="permalink"><a href="#a0f4b64f1b3a74c4f6c5d9409d6b6086a">◆ </a></span>ucx_buffer_to_sstr</h2> | |
234 | ||
235 | <div class="memitem"> | |
236 | <div class="memproto"> | |
237 | <table class="memname"> | |
238 | <tr> | |
239 | <td class="memname">#define ucx_buffer_to_sstr</td> | |
240 | <td>(</td> | |
241 | <td class="paramtype"> </td> | |
242 | <td class="paramname">buffer</td><td>)</td> | |
243 | <td>   <a class="el" href="string_8h.html#a2744c38ac44abf3e01fa059056dcf36c">sstrn</a>((buffer)->space, (buffer)->size)</td> | |
244 | </tr> | |
245 | </table> | |
246 | </div><div class="memdoc"> | |
247 | ||
248 | <p>Returns the complete buffer content as <a class="el" href="structsstr__t.html" title="The UCX string structure. ">sstr_t</a>. </p> | |
249 | <dl class="params"><dt>Parameters</dt><dd> | |
250 | <table class="params"> | |
251 | <tr><td class="paramname">buffer</td><td>the buffer </td></tr> | |
252 | </table> | |
253 | </dd> | |
254 | </dl> | |
255 | <dl class="section return"><dt>Returns</dt><dd>the result of <code><a class="el" href="string_8h.html#a2744c38ac44abf3e01fa059056dcf36c" title="Creates a new sstr_t of the specified length based on a C string. ">sstrn()</a></code> with the buffer space and size as arguments </dd></dl> | |
256 | ||
257 | </div> | |
258 | </div> | |
259 | <h2 class="groupheader">Function Documentation</h2> | |
260 | <a id="abad7fd9ad5061224c780b8d1d4c55f09"></a> | |
261 | <h2 class="memtitle"><span class="permalink"><a href="#abad7fd9ad5061224c780b8d1d4c55f09">◆ </a></span>ucx_buffer_eof()</h2> | |
262 | ||
263 | <div class="memitem"> | |
264 | <div class="memproto"> | |
265 | <table class="memname"> | |
266 | <tr> | |
267 | <td class="memname">int ucx_buffer_eof </td> | |
268 | <td>(</td> | |
269 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
270 | <td class="paramname"><em>buffer</em></td><td>)</td> | |
271 | <td></td> | |
272 | </tr> | |
273 | </table> | |
274 | </div><div class="memdoc"> | |
275 | ||
276 | <p>Tests, if the buffer position has exceeded the buffer capacity. </p> | |
277 | <dl class="params"><dt>Parameters</dt><dd> | |
278 | <table class="params"> | |
279 | <tr><td class="paramname">buffer</td><td>the buffer to test </td></tr> | |
280 | </table> | |
281 | </dd> | |
282 | </dl> | |
283 | <dl class="section return"><dt>Returns</dt><dd>non-zero, if the current buffer position has exceeded the last available byte of the buffer. </dd></dl> | |
284 | ||
285 | </div> | |
286 | </div> | |
287 | <a id="afaf97d2cd7e9faad79a9d35fe33e30c6"></a> | |
288 | <h2 class="memtitle"><span class="permalink"><a href="#afaf97d2cd7e9faad79a9d35fe33e30c6">◆ </a></span>ucx_buffer_extend()</h2> | |
289 | ||
290 | <div class="memitem"> | |
291 | <div class="memproto"> | |
292 | <table class="memname"> | |
293 | <tr> | |
294 | <td class="memname">int ucx_buffer_extend </td> | |
295 | <td>(</td> | |
296 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
297 | <td class="paramname"><em>buffer</em>, </td> | |
298 | </tr> | |
299 | <tr> | |
300 | <td class="paramkey"></td> | |
301 | <td></td> | |
302 | <td class="paramtype">size_t </td> | |
303 | <td class="paramname"><em>additional_bytes</em> </td> | |
304 | </tr> | |
305 | <tr> | |
306 | <td></td> | |
307 | <td>)</td> | |
308 | <td></td><td></td> | |
309 | </tr> | |
310 | </table> | |
311 | </div><div class="memdoc"> | |
312 | ||
313 | <p>Extends the capacity of the buffer. </p> | |
314 | <p><b>Note:</b> The buffer capacity increased by a power of two. I.e. the buffer capacity is doubled, as long as it would not hold the current content plus the additional required bytes.</p> | |
315 | <p><b>Attention:</b> the argument provided is the number of <em>additional</em> bytes the buffer shall hold. It is <b>NOT</b> the total number of bytes the buffer shall hold.</p> | |
316 | <dl class="params"><dt>Parameters</dt><dd> | |
317 | <table class="params"> | |
318 | <tr><td class="paramname">buffer</td><td>the buffer to extend </td></tr> | |
319 | <tr><td class="paramname">additional_bytes</td><td>the number of additional bytes the buffer shall <em>at least</em> hold </td></tr> | |
320 | </table> | |
321 | </dd> | |
322 | </dl> | |
323 | <dl class="section return"><dt>Returns</dt><dd>0 on success or a non-zero value on failure </dd></dl> | |
324 | ||
325 | </div> | |
326 | </div> | |
327 | <a id="a33fa7bb35fe08bbb3542f227514332ef"></a> | |
328 | <h2 class="memtitle"><span class="permalink"><a href="#a33fa7bb35fe08bbb3542f227514332ef">◆ </a></span>ucx_buffer_extract()</h2> | |
329 | ||
330 | <div class="memitem"> | |
331 | <div class="memproto"> | |
332 | <table class="memname"> | |
333 | <tr> | |
334 | <td class="memname"><a class="el" href="structUcxBuffer.html">UcxBuffer</a>* ucx_buffer_extract </td> | |
335 | <td>(</td> | |
336 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
337 | <td class="paramname"><em>src</em>, </td> | |
338 | </tr> | |
339 | <tr> | |
340 | <td class="paramkey"></td> | |
341 | <td></td> | |
342 | <td class="paramtype">size_t </td> | |
343 | <td class="paramname"><em>start</em>, </td> | |
344 | </tr> | |
345 | <tr> | |
346 | <td class="paramkey"></td> | |
347 | <td></td> | |
348 | <td class="paramtype">size_t </td> | |
349 | <td class="paramname"><em>length</em>, </td> | |
350 | </tr> | |
351 | <tr> | |
352 | <td class="paramkey"></td> | |
353 | <td></td> | |
354 | <td class="paramtype">int </td> | |
355 | <td class="paramname"><em>flags</em> </td> | |
356 | </tr> | |
357 | <tr> | |
358 | <td></td> | |
359 | <td>)</td> | |
360 | <td></td><td></td> | |
361 | </tr> | |
362 | </table> | |
363 | </div><div class="memdoc"> | |
364 | ||
365 | <p>Creates a new buffer and fills it with extracted content from another buffer. </p> | |
366 | <p><b>Note:</b> the <a class="el" href="buffer_8h.html#a8bab11ad8a76719228b9ee91e2e45535" title="If this flag is enabled, the buffer will automatically free its contents. ">UCX_BUFFER_AUTOFREE</a> feature is enforced for the new buffer.</p> | |
367 | <dl class="params"><dt>Parameters</dt><dd> | |
368 | <table class="params"> | |
369 | <tr><td class="paramname">src</td><td>the source buffer </td></tr> | |
370 | <tr><td class="paramname">start</td><td>the start position of extraction </td></tr> | |
371 | <tr><td class="paramname">length</td><td>the count of bytes to extract (must not be zero) </td></tr> | |
372 | <tr><td class="paramname">flags</td><td>feature mask for the new buffer </td></tr> | |
373 | </table> | |
374 | </dd> | |
375 | </dl> | |
376 | <dl class="section return"><dt>Returns</dt><dd>a new buffer containing the extraction </dd></dl> | |
377 | ||
378 | </div> | |
379 | </div> | |
380 | <a id="a2af8646d8905c22c7322e7540b0440af"></a> | |
381 | <h2 class="memtitle"><span class="permalink"><a href="#a2af8646d8905c22c7322e7540b0440af">◆ </a></span>ucx_buffer_free()</h2> | |
382 | ||
383 | <div class="memitem"> | |
384 | <div class="memproto"> | |
385 | <table class="memname"> | |
386 | <tr> | |
387 | <td class="memname">void ucx_buffer_free </td> | |
388 | <td>(</td> | |
389 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
390 | <td class="paramname"><em>buffer</em></td><td>)</td> | |
391 | <td></td> | |
392 | </tr> | |
393 | </table> | |
394 | </div><div class="memdoc"> | |
395 | ||
396 | <p>Destroys a buffer. </p> | |
397 | <p>If the <a class="el" href="buffer_8h.html#a8bab11ad8a76719228b9ee91e2e45535" title="If this flag is enabled, the buffer will automatically free its contents. ">UCX_BUFFER_AUTOFREE</a> feature is enabled, the contents of the buffer are also freed.</p> | |
398 | <dl class="params"><dt>Parameters</dt><dd> | |
399 | <table class="params"> | |
400 | <tr><td class="paramname">buffer</td><td>the buffer to destroy </td></tr> | |
401 | </table> | |
402 | </dd> | |
403 | </dl> | |
404 | ||
405 | </div> | |
406 | </div> | |
407 | <a id="a396339022159ce4ca6d069de9f9209b0"></a> | |
408 | <h2 class="memtitle"><span class="permalink"><a href="#a396339022159ce4ca6d069de9f9209b0">◆ </a></span>ucx_buffer_getc()</h2> | |
409 | ||
410 | <div class="memitem"> | |
411 | <div class="memproto"> | |
412 | <table class="memname"> | |
413 | <tr> | |
414 | <td class="memname">int ucx_buffer_getc </td> | |
415 | <td>(</td> | |
416 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
417 | <td class="paramname"><em>buffer</em></td><td>)</td> | |
418 | <td></td> | |
419 | </tr> | |
420 | </table> | |
421 | </div><div class="memdoc"> | |
422 | ||
423 | <p>Gets a character from a buffer. </p> | |
424 | <p>The current position of the buffer is increased after a successful read.</p> | |
425 | <dl class="params"><dt>Parameters</dt><dd> | |
426 | <table class="params"> | |
427 | <tr><td class="paramname">buffer</td><td>the buffer to read from </td></tr> | |
428 | </table> | |
429 | </dd> | |
430 | </dl> | |
431 | <dl class="section return"><dt>Returns</dt><dd>the character as <code>int</code> value or <code>EOF</code>, if the end of the buffer is reached </dd></dl> | |
432 | ||
433 | </div> | |
434 | </div> | |
435 | <a id="aacea876d692193ec6f859ce98da7351c"></a> | |
436 | <h2 class="memtitle"><span class="permalink"><a href="#aacea876d692193ec6f859ce98da7351c">◆ </a></span>ucx_buffer_new()</h2> | |
437 | ||
438 | <div class="memitem"> | |
439 | <div class="memproto"> | |
440 | <table class="memname"> | |
441 | <tr> | |
442 | <td class="memname"><a class="el" href="structUcxBuffer.html">UcxBuffer</a>* ucx_buffer_new </td> | |
443 | <td>(</td> | |
444 | <td class="paramtype">void * </td> | |
445 | <td class="paramname"><em>space</em>, </td> | |
446 | </tr> | |
447 | <tr> | |
448 | <td class="paramkey"></td> | |
449 | <td></td> | |
450 | <td class="paramtype">size_t </td> | |
451 | <td class="paramname"><em>capacity</em>, </td> | |
452 | </tr> | |
453 | <tr> | |
454 | <td class="paramkey"></td> | |
455 | <td></td> | |
456 | <td class="paramtype">int </td> | |
457 | <td class="paramname"><em>flags</em> </td> | |
458 | </tr> | |
459 | <tr> | |
460 | <td></td> | |
461 | <td>)</td> | |
462 | <td></td><td></td> | |
463 | </tr> | |
464 | </table> | |
465 | </div><div class="memdoc"> | |
466 | ||
467 | <p>Creates a new buffer. </p> | |
468 | <p><b>Note:</b> you may provide <code>NULL</code> as argument for <code>space</code>. Then this function will allocate the space and enforce the <a class="el" href="buffer_8h.html#a8bab11ad8a76719228b9ee91e2e45535" title="If this flag is enabled, the buffer will automatically free its contents. ">UCX_BUFFER_AUTOFREE</a> flag.</p> | |
469 | <dl class="params"><dt>Parameters</dt><dd> | |
470 | <table class="params"> | |
471 | <tr><td class="paramname">space</td><td>pointer to the memory area, or <code>NULL</code> to allocate new memory </td></tr> | |
472 | <tr><td class="paramname">capacity</td><td>the capacity of the buffer </td></tr> | |
473 | <tr><td class="paramname">flags</td><td>buffer features (see <a class="el" href="structUcxBuffer.html#ac642e07b0a03be5aac48eb4aa5bec2f7" title="Flag register for buffer features. ">UcxBuffer.flags</a>) </td></tr> | |
474 | </table> | |
475 | </dd> | |
476 | </dl> | |
477 | <dl class="section return"><dt>Returns</dt><dd>the new buffer </dd></dl> | |
478 | ||
479 | </div> | |
480 | </div> | |
481 | <a id="a7d6f01b9d631b0123475dfb98fb849ac"></a> | |
482 | <h2 class="memtitle"><span class="permalink"><a href="#a7d6f01b9d631b0123475dfb98fb849ac">◆ </a></span>ucx_buffer_putc()</h2> | |
483 | ||
484 | <div class="memitem"> | |
485 | <div class="memproto"> | |
486 | <table class="memname"> | |
487 | <tr> | |
488 | <td class="memname">int ucx_buffer_putc </td> | |
489 | <td>(</td> | |
490 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
491 | <td class="paramname"><em>buffer</em>, </td> | |
492 | </tr> | |
493 | <tr> | |
494 | <td class="paramkey"></td> | |
495 | <td></td> | |
496 | <td class="paramtype">int </td> | |
497 | <td class="paramname"><em>c</em> </td> | |
498 | </tr> | |
499 | <tr> | |
500 | <td></td> | |
501 | <td>)</td> | |
502 | <td></td><td></td> | |
503 | </tr> | |
504 | </table> | |
505 | </div><div class="memdoc"> | |
506 | ||
507 | <p>Writes a character to a buffer. </p> | |
508 | <p>The least significant byte of the argument is written to the buffer. If the end of the buffer is reached and <a class="el" href="buffer_8h.html#a05f9565f2d04399168c3b1c152a632be" title="If this flag is enabled, the buffer will automatically extends its capacity. ">UCX_BUFFER_AUTOEXTEND</a> feature is enabled, the buffer capacity is extended by <a class="el" href="buffer_8h.html#afaf97d2cd7e9faad79a9d35fe33e30c6" title="Extends the capacity of the buffer. ">ucx_buffer_extend()</a>. If the feature is disabled or buffer extension fails, <code>EOF</code> is returned.</p> | |
509 | <p>On successful write the position of the buffer is increased.</p> | |
510 | <dl class="params"><dt>Parameters</dt><dd> | |
511 | <table class="params"> | |
512 | <tr><td class="paramname">buffer</td><td>the buffer to write to </td></tr> | |
513 | <tr><td class="paramname">c</td><td>the character to write as <code>int</code> value </td></tr> | |
514 | </table> | |
515 | </dd> | |
516 | </dl> | |
517 | <dl class="section return"><dt>Returns</dt><dd>the byte that has bean written as <code>int</code> value or <code>EOF</code> when the end of the stream is reached and automatic extension is not enabled or not possible </dd></dl> | |
518 | ||
519 | </div> | |
520 | </div> | |
521 | <a id="af1d4b478e04b3ae0bf30e7c2ea964ea2"></a> | |
522 | <h2 class="memtitle"><span class="permalink"><a href="#af1d4b478e04b3ae0bf30e7c2ea964ea2">◆ </a></span>ucx_buffer_puts()</h2> | |
523 | ||
524 | <div class="memitem"> | |
525 | <div class="memproto"> | |
526 | <table class="memname"> | |
527 | <tr> | |
528 | <td class="memname">size_t ucx_buffer_puts </td> | |
529 | <td>(</td> | |
530 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
531 | <td class="paramname"><em>buffer</em>, </td> | |
532 | </tr> | |
533 | <tr> | |
534 | <td class="paramkey"></td> | |
535 | <td></td> | |
536 | <td class="paramtype">const char * </td> | |
537 | <td class="paramname"><em>str</em> </td> | |
538 | </tr> | |
539 | <tr> | |
540 | <td></td> | |
541 | <td>)</td> | |
542 | <td></td><td></td> | |
543 | </tr> | |
544 | </table> | |
545 | </div><div class="memdoc"> | |
546 | ||
547 | <p>Writes a string to a buffer. </p> | |
548 | <dl class="params"><dt>Parameters</dt><dd> | |
549 | <table class="params"> | |
550 | <tr><td class="paramname">buffer</td><td>the buffer </td></tr> | |
551 | <tr><td class="paramname">str</td><td>the string </td></tr> | |
552 | </table> | |
553 | </dd> | |
554 | </dl> | |
555 | <dl class="section return"><dt>Returns</dt><dd>the number of bytes written </dd></dl> | |
556 | ||
557 | </div> | |
558 | </div> | |
559 | <a id="ae5c3430759f0059547b35d5a254d4da5"></a> | |
560 | <h2 class="memtitle"><span class="permalink"><a href="#ae5c3430759f0059547b35d5a254d4da5">◆ </a></span>ucx_buffer_read()</h2> | |
561 | ||
562 | <div class="memitem"> | |
563 | <div class="memproto"> | |
564 | <table class="memname"> | |
565 | <tr> | |
566 | <td class="memname">size_t ucx_buffer_read </td> | |
567 | <td>(</td> | |
568 | <td class="paramtype">void * </td> | |
569 | <td class="paramname"><em>ptr</em>, </td> | |
570 | </tr> | |
571 | <tr> | |
572 | <td class="paramkey"></td> | |
573 | <td></td> | |
574 | <td class="paramtype">size_t </td> | |
575 | <td class="paramname"><em>size</em>, </td> | |
576 | </tr> | |
577 | <tr> | |
578 | <td class="paramkey"></td> | |
579 | <td></td> | |
580 | <td class="paramtype">size_t </td> | |
581 | <td class="paramname"><em>nitems</em>, </td> | |
582 | </tr> | |
583 | <tr> | |
584 | <td class="paramkey"></td> | |
585 | <td></td> | |
586 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
587 | <td class="paramname"><em>buffer</em> </td> | |
588 | </tr> | |
589 | <tr> | |
590 | <td></td> | |
591 | <td>)</td> | |
592 | <td></td><td></td> | |
593 | </tr> | |
594 | </table> | |
595 | </div><div class="memdoc"> | |
596 | ||
597 | <p>Reads data from a <a class="el" href="structUcxBuffer.html" title="UCX Buffer. ">UcxBuffer</a>. </p> | |
598 | <p>The position of the buffer is increased by the number of bytes read.</p> | |
599 | <dl class="params"><dt>Parameters</dt><dd> | |
600 | <table class="params"> | |
601 | <tr><td class="paramname">ptr</td><td>a pointer to the memory area where to store the read data </td></tr> | |
602 | <tr><td class="paramname">size</td><td>the length of one element </td></tr> | |
603 | <tr><td class="paramname">nitems</td><td>the element count </td></tr> | |
604 | <tr><td class="paramname">buffer</td><td>the <a class="el" href="structUcxBuffer.html" title="UCX Buffer. ">UcxBuffer</a> to read from </td></tr> | |
605 | </table> | |
606 | </dd> | |
607 | </dl> | |
608 | <dl class="section return"><dt>Returns</dt><dd>the total number of elements read </dd></dl> | |
609 | ||
610 | </div> | |
611 | </div> | |
612 | <a id="a47d98482662073c74f35deb0957d15d1"></a> | |
613 | <h2 class="memtitle"><span class="permalink"><a href="#a47d98482662073c74f35deb0957d15d1">◆ </a></span>ucx_buffer_seek()</h2> | |
614 | ||
615 | <div class="memitem"> | |
616 | <div class="memproto"> | |
617 | <table class="memname"> | |
618 | <tr> | |
619 | <td class="memname">int ucx_buffer_seek </td> | |
620 | <td>(</td> | |
621 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
622 | <td class="paramname"><em>buffer</em>, </td> | |
623 | </tr> | |
624 | <tr> | |
625 | <td class="paramkey"></td> | |
626 | <td></td> | |
627 | <td class="paramtype">off_t </td> | |
628 | <td class="paramname"><em>offset</em>, </td> | |
629 | </tr> | |
630 | <tr> | |
631 | <td class="paramkey"></td> | |
632 | <td></td> | |
633 | <td class="paramtype">int </td> | |
634 | <td class="paramname"><em>whence</em> </td> | |
635 | </tr> | |
636 | <tr> | |
637 | <td></td> | |
638 | <td>)</td> | |
639 | <td></td><td></td> | |
640 | </tr> | |
641 | </table> | |
642 | </div><div class="memdoc"> | |
643 | ||
644 | <p>Moves the position of the buffer. </p> | |
645 | <p>The new position is relative to the <code>whence</code> argument.</p> | |
646 | <p>SEEK_SET marks the start of the buffer. SEEK_CUR marks the current position. SEEK_END marks the end of the buffer.</p> | |
647 | <p>With an offset of zero, this function sets the buffer position to zero (SEEK_SET), the buffer size (SEEK_END) or leaves the buffer position unchanged (SEEK_CUR).</p> | |
648 | <dl class="params"><dt>Parameters</dt><dd> | |
649 | <table class="params"> | |
650 | <tr><td class="paramname">buffer</td><td></td></tr> | |
651 | <tr><td class="paramname">offset</td><td>position offset relative to <code>whence</code> </td></tr> | |
652 | <tr><td class="paramname">whence</td><td>one of SEEK_SET, SEEK_CUR or SEEK_END </td></tr> | |
653 | </table> | |
654 | </dd> | |
655 | </dl> | |
656 | <dl class="section return"><dt>Returns</dt><dd>0 on success, non-zero if the position is invalid </dd></dl> | |
657 | ||
658 | </div> | |
659 | </div> | |
660 | <a id="a12a0c6a2379ef080043e6286bb8bad69"></a> | |
661 | <h2 class="memtitle"><span class="permalink"><a href="#a12a0c6a2379ef080043e6286bb8bad69">◆ </a></span>ucx_buffer_shift()</h2> | |
662 | ||
663 | <div class="memitem"> | |
664 | <div class="memproto"> | |
665 | <table class="memname"> | |
666 | <tr> | |
667 | <td class="memname">int ucx_buffer_shift </td> | |
668 | <td>(</td> | |
669 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
670 | <td class="paramname"><em>buffer</em>, </td> | |
671 | </tr> | |
672 | <tr> | |
673 | <td class="paramkey"></td> | |
674 | <td></td> | |
675 | <td class="paramtype">off_t </td> | |
676 | <td class="paramname"><em>shift</em> </td> | |
677 | </tr> | |
678 | <tr> | |
679 | <td></td> | |
680 | <td>)</td> | |
681 | <td></td><td></td> | |
682 | </tr> | |
683 | </table> | |
684 | </div><div class="memdoc"> | |
685 | ||
686 | <p>Shifts the contents of the buffer by the given offset. </p> | |
687 | <p>If the offset is positive, the contents are shifted to the right. If auto extension is enabled, the buffer grows, if necessary. In case the auto extension fails, this function returns a non-zero value and no contents are changed. If auto extension is disabled, the contents that do not fit into the buffer are discarded.</p> | |
688 | <p>If the offset is negative, the contents are shifted to the left where the first <code>shift</code> bytes are discarded. The new size of the buffer is the old size minus the absolute shift value. If this value is larger than the buffer size, the buffer is emptied (but not cleared, see the security note below).</p> | |
689 | <p>The buffer position gets shifted alongside with the content but is kept within the boundaries of the buffer.</p> | |
690 | <p><b>Security note:</b> the shifting operation does <em>not</em> erase the previously occupied memory cells. You can easily do that manually, e.g. by calling <code>memset(buffer->space, 0, shift)</code> for a right shift or <code>memset(buffer->size, 0, buffer->capacity-buffer->size)</code> for a left shift.</p> | |
691 | <dl class="params"><dt>Parameters</dt><dd> | |
692 | <table class="params"> | |
693 | <tr><td class="paramname">buffer</td><td>the buffer </td></tr> | |
694 | <tr><td class="paramname">shift</td><td>the shift offset (negative means left shift) </td></tr> | |
695 | </table> | |
696 | </dd> | |
697 | </dl> | |
698 | <dl class="section return"><dt>Returns</dt><dd>0 on success, non-zero if a required auto-extension fails </dd></dl> | |
699 | ||
700 | </div> | |
701 | </div> | |
702 | <a id="a20431dd0ed6a6fe9f15333bd72afe4db"></a> | |
703 | <h2 class="memtitle"><span class="permalink"><a href="#a20431dd0ed6a6fe9f15333bd72afe4db">◆ </a></span>ucx_buffer_shift_left()</h2> | |
704 | ||
705 | <div class="memitem"> | |
706 | <div class="memproto"> | |
707 | <table class="memname"> | |
708 | <tr> | |
709 | <td class="memname">int ucx_buffer_shift_left </td> | |
710 | <td>(</td> | |
711 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
712 | <td class="paramname"><em>buffer</em>, </td> | |
713 | </tr> | |
714 | <tr> | |
715 | <td class="paramkey"></td> | |
716 | <td></td> | |
717 | <td class="paramtype">size_t </td> | |
718 | <td class="paramname"><em>shift</em> </td> | |
719 | </tr> | |
720 | <tr> | |
721 | <td></td> | |
722 | <td>)</td> | |
723 | <td></td><td></td> | |
724 | </tr> | |
725 | </table> | |
726 | </div><div class="memdoc"> | |
727 | ||
728 | <p>Shifts the buffer to the left. </p> | |
729 | <p>See <a class="el" href="buffer_8h.html#a12a0c6a2379ef080043e6286bb8bad69" title="Shifts the contents of the buffer by the given offset. ">ucx_buffer_shift()</a> for details. Note, however, that this method expects a positive shift offset.</p> | |
730 | <p>Since a left shift cannot fail due to memory allocation problems, this function always returns zero.</p> | |
731 | <dl class="params"><dt>Parameters</dt><dd> | |
732 | <table class="params"> | |
733 | <tr><td class="paramname">buffer</td><td>the buffer </td></tr> | |
734 | <tr><td class="paramname">shift</td><td>the shift offset </td></tr> | |
735 | </table> | |
736 | </dd> | |
737 | </dl> | |
738 | <dl class="section return"><dt>Returns</dt><dd>always zero </dd></dl> | |
739 | <dl class="section see"><dt>See also</dt><dd><a class="el" href="buffer_8h.html#a12a0c6a2379ef080043e6286bb8bad69" title="Shifts the contents of the buffer by the given offset. ">ucx_buffer_shift()</a> </dd></dl> | |
740 | ||
741 | </div> | |
742 | </div> | |
743 | <a id="a4fa10b6471495547eb981248fd4f1bc2"></a> | |
744 | <h2 class="memtitle"><span class="permalink"><a href="#a4fa10b6471495547eb981248fd4f1bc2">◆ </a></span>ucx_buffer_shift_right()</h2> | |
745 | ||
746 | <div class="memitem"> | |
747 | <div class="memproto"> | |
748 | <table class="memname"> | |
749 | <tr> | |
750 | <td class="memname">int ucx_buffer_shift_right </td> | |
751 | <td>(</td> | |
752 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
753 | <td class="paramname"><em>buffer</em>, </td> | |
754 | </tr> | |
755 | <tr> | |
756 | <td class="paramkey"></td> | |
757 | <td></td> | |
758 | <td class="paramtype">size_t </td> | |
759 | <td class="paramname"><em>shift</em> </td> | |
760 | </tr> | |
761 | <tr> | |
762 | <td></td> | |
763 | <td>)</td> | |
764 | <td></td><td></td> | |
765 | </tr> | |
766 | </table> | |
767 | </div><div class="memdoc"> | |
768 | ||
769 | <p>Shifts the buffer to the right. </p> | |
770 | <p>See <a class="el" href="buffer_8h.html#a12a0c6a2379ef080043e6286bb8bad69" title="Shifts the contents of the buffer by the given offset. ">ucx_buffer_shift()</a> for details.</p> | |
771 | <dl class="params"><dt>Parameters</dt><dd> | |
772 | <table class="params"> | |
773 | <tr><td class="paramname">buffer</td><td>the buffer </td></tr> | |
774 | <tr><td class="paramname">shift</td><td>the shift offset </td></tr> | |
775 | </table> | |
776 | </dd> | |
777 | </dl> | |
778 | <dl class="section return"><dt>Returns</dt><dd>0 on success, non-zero if a required auto-extension fails </dd></dl> | |
779 | <dl class="section see"><dt>See also</dt><dd><a class="el" href="buffer_8h.html#a12a0c6a2379ef080043e6286bb8bad69" title="Shifts the contents of the buffer by the given offset. ">ucx_buffer_shift()</a> </dd></dl> | |
780 | ||
781 | </div> | |
782 | </div> | |
783 | <a id="af8aacc7401814392b58c1b7b81bffc05"></a> | |
784 | <h2 class="memtitle"><span class="permalink"><a href="#af8aacc7401814392b58c1b7b81bffc05">◆ </a></span>ucx_buffer_write()</h2> | |
785 | ||
786 | <div class="memitem"> | |
787 | <div class="memproto"> | |
788 | <table class="memname"> | |
789 | <tr> | |
790 | <td class="memname">size_t ucx_buffer_write </td> | |
791 | <td>(</td> | |
792 | <td class="paramtype">const void * </td> | |
793 | <td class="paramname"><em>ptr</em>, </td> | |
794 | </tr> | |
795 | <tr> | |
796 | <td class="paramkey"></td> | |
797 | <td></td> | |
798 | <td class="paramtype">size_t </td> | |
799 | <td class="paramname"><em>size</em>, </td> | |
800 | </tr> | |
801 | <tr> | |
802 | <td class="paramkey"></td> | |
803 | <td></td> | |
804 | <td class="paramtype">size_t </td> | |
805 | <td class="paramname"><em>nitems</em>, </td> | |
806 | </tr> | |
807 | <tr> | |
808 | <td class="paramkey"></td> | |
809 | <td></td> | |
810 | <td class="paramtype"><a class="el" href="structUcxBuffer.html">UcxBuffer</a> * </td> | |
811 | <td class="paramname"><em>buffer</em> </td> | |
812 | </tr> | |
813 | <tr> | |
814 | <td></td> | |
815 | <td>)</td> | |
816 | <td></td><td></td> | |
817 | </tr> | |
818 | </table> | |
819 | </div><div class="memdoc"> | |
820 | ||
821 | <p>Writes data to a <a class="el" href="structUcxBuffer.html" title="UCX Buffer. ">UcxBuffer</a>. </p> | |
822 | <p>The position of the buffer is increased by the number of bytes written.</p> | |
823 | <dl class="params"><dt>Parameters</dt><dd> | |
824 | <table class="params"> | |
825 | <tr><td class="paramname">ptr</td><td>a pointer to the memory area containing the bytes to be written </td></tr> | |
826 | <tr><td class="paramname">size</td><td>the length of one element </td></tr> | |
827 | <tr><td class="paramname">nitems</td><td>the element count </td></tr> | |
828 | <tr><td class="paramname">buffer</td><td>the <a class="el" href="structUcxBuffer.html" title="UCX Buffer. ">UcxBuffer</a> to write to </td></tr> | |
829 | </table> | |
830 | </dd> | |
831 | </dl> | |
832 | <dl class="section return"><dt>Returns</dt><dd>the total count of bytes written </dd></dl> | |
833 | ||
834 | </div> | |
835 | </div> | |
836 | </div><!-- contents --> | |
837 | <!-- start footer part --> | |
838 | <hr class="footer"/><address class="footer"><small> | |
839 | Generated on Thu Dec 19 2019 19:58:24 for ucx by  <a href="http://www.doxygen.org/index.html"> | |
840 | <img class="footer" src="doxygen.png" alt="doxygen"/> | |
841 | </a> 1.8.13 | |
842 | </small></address> | |
843 | </body> | |
844 | </html> |