📄 c-netapi3.html
字号:
</tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89591"> </a><b class="routine"><i class="routine">zbufInsertCopy</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89593"> </a>Copy buffer data into a zbuf.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89595"> </a><b class="routine"><i class="routine">zbufExtractCopy</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89597"> </a>Copy data from a zbuf to a buffer.</div></td><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></i></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="89598">Operations on Zbufs</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89632"> </a>The routines listed in <a href="c-netapi3.html#89605">Table 7-6</a> perform several fundamental operations on zbufs.<p class="table"><h4 class="EntityTitle"><a name="89605"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 7-6: Zbuf Operations</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="89609"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Call</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="89611"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89613"> </a><b class="routine"><i class="routine">zbufLength</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89615"> </a>Determine the length of a zbuf, in bytes.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89617"> </a><b class="routine"><i class="routine">zbufDup</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89619"> </a>Duplicate a zbuf.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89621"> </a><b class="routine"><i class="routine">zbufInsert</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89623"> </a>Insert a zbuf into another zbuf.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89625"> </a><b class="routine"><i class="routine">zbufSplit</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89627"> </a>Split a zbuf into two separate zbufs.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89629"> </a><b class="routine"><i class="routine">zbufCut</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89631"> </a>Delete bytes from a zbuf.</div></td><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p><dd><p class="Body"><a name="89634"> </a>The routine <b class="routine"><i class="routine">zbufLength</i></b><b>( )</b> reports how many bytes are in a zbuf.</p><dd><p class="Body"><a name="89636"> </a>The routine <b class="routine"><i class="routine">zbufDup</i></b><b>( )</b> provides the simplest mechanism for sharing segments between zbufs: it produces a new zbuf ID that refers to some or all of the data in the original zbuf. You can exploit this sort of sharing to get two different views of the same data. For example, after duplicating a zbuf, you can insert another zbuf into one of the two duplicates, with <b class="routine"><i class="routine">zbufInsert</i></b><b>( )</b>. None of the data in the original zbuf segments moves, yet after some byte location (the byte location where you inserted data) addressing the two zbufs gives completely different data.</p><dd><p class="Body"><a name="89639"> </a>The <b class="routine"><i class="routine">zbufSplit</i></b><b>( )</b> routine divides one zbuf into two; you specify the byte location for the split, and the result of the routine is a new zbuf ID. The new zbuf's data begins after the specified byte location. The original zbuf ID also has a modified view of the data: it is truncated to the byte location of the split. However, none of the data in the underlying segments moves through all this: if you duplicate the original zbuf before splitting it, three zbuf IDs share segments--the duplicate permits you to view the entire original range of data, another zbuf contains a leading fragment, and the third zbuf holds the trailing fragment.</p><dd><p class="Body"><a name="89641"> </a>Similarly, if you call <b class="routine"><i class="routine">zbufCut</i></b><b>( )</b> to remove some range of bytes from within a zbuf, the effects are visible only to callers who view the data through the same zbuf ID you used for the deletion; other zbuf segments can still address the original data through a shared buffer. </p><dd><p class="Body"><a name="89642"> </a>For the most part, these routines do not free data buffers or delete zbufs, but there are two exceptions:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="89644"> </a><b class="routine"><i class="routine">zbufInsert</i></b><b>( )</b> deletes the zbuf ID it inserts. No segments are freed, because they now form part of the larger zbuf.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="89646"> </a>If the bytes you remove with <b class="routine"><i class="routine">zbufCut</i></b><b>( )</b> span one or more complete segments, the free routines for those segments can be called (if no other zbuf segment refers to the same data).</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="89647"> </a>The data-buffer free routine runs only when <i class="emphasis">none</i> of the data in a segment is part of any zbuf; to avoid data copying, zbuf manipulation routines such as <b class="routine"><i class="routine">zbufCut</i></b><b>( )</b> record which parts of a segment are currently in a zbuf, postponing the deletion of a segment until no part of its data is in use.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="89648">Segments of Zbufs</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89653"> </a>The routines in <a href="c-netapi3.html#89657">Table 7-7</a> give your applications access to the underlying segments in a zbuf. <p class="table"><h4 class="EntityTitle"><a name="89657"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 7-7: Zbuf Segment Routines</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="89661"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Call</font></b></div></th><td width="10"> </td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="89663"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89665"> </a><b class="routine"><i class="routine">zbufSegFind</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89667"> </a>Find the zbuf segment containing a specified byte location.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89669"> </a><b class="routine"><i class="routine">zbufSegNext</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89671"> </a>Get the next segment in a zbuf.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89673"> </a><b class="routine"><i class="routine">zbufSegPrev</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89675"> </a>Get the previous segment in a zbuf.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89677"> </a><b class="routine"><i class="routine">zbufSegData</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89679"> </a>Determine the location of data in a zbuf segment.</div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="89681"> </a><b class="routine"><i class="routine">zbufSegLength</i></b><b>( )</b></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="89683"> </a>Determine the length of a zbuf segment.</div></td><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p><dd><p class="Body"><a name="89684"> </a>By specifying a <b class="symbol_UC">NULL</b> segment ID, you can address the entire contents of a zbuf as offsets from its very first data byte. However, it is always more efficient to address data in a zbuf relative to the closest segment. Use <b class="routine"><i class="routine">zbufSegFind</i></b><b>( )</b> to translate any zbuf byte location into the most local form. </p><dd><p class="Body"><a name="89688"> </a>The pair <b class="routine"><i class="routine">zbufSegNext</i></b><b>( )</b> and <b class="routine"><i class="routine">zbufSegPrev</i></b><b>( )</b> are useful for going through the segments of a zbuf in order, perhaps in conjunction with <b class="routine"><i class="routine">zbufSegLength</i></b><b>( )</b>.</p><dd><p class="Body"><a name="89691"> </a>Finally, <b class="routine"><i class="routine">zbufSegData</i></b><b>( )</b> allows the most direct access to the data in zbufs: it gives your application the address where a segment's data begins. If you manage segment data directly using this pointer, bear the following restrictions in mind:</p></dl><dl class="margin">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -