📄 ida_8cpp-source.html
字号:
<a name="l00316"></a>00316 {<a name="l00317"></a>00317 <span class="keywordflow">if</span> (!blocking)<a name="l00318"></a>00318 <span class="keywordflow">throw</span> BlockingInputOnly(<span class="stringliteral">"InformationDispersal"</span>);<a name="l00319"></a>00319 <a name="l00320"></a>00320 <span class="keywordflow">while</span> (length--)<a name="l00321"></a>00321 {<a name="l00322"></a>00322 <a class="code" href="class_information_dispersal.html#fd962aac086ce5c3fbf16157d59e4e63">m_ida</a>.<a class="code" href="class_raw_i_d_a.html#3fa15d51e46a8eaee252a0a7034aac47">ChannelData</a>(<a class="code" href="class_information_dispersal.html#4bd5ab80c6221a3274033470cbc83620">m_nextChannel</a>, begin, 1, <span class="keyword">false</span>);<a name="l00323"></a>00323 begin++;<a name="l00324"></a>00324 <a class="code" href="class_information_dispersal.html#4bd5ab80c6221a3274033470cbc83620">m_nextChannel</a>++;<a name="l00325"></a>00325 <span class="keywordflow">if</span> (<a class="code" href="class_information_dispersal.html#4bd5ab80c6221a3274033470cbc83620">m_nextChannel</a> == <a class="code" href="class_information_dispersal.html#fd962aac086ce5c3fbf16157d59e4e63">m_ida</a>.<a class="code" href="class_raw_i_d_a.html#cbdf3bfeabd7a7c64b03b61fa8929d4c">GetThreshold</a>())<a name="l00326"></a>00326 <a class="code" href="class_information_dispersal.html#4bd5ab80c6221a3274033470cbc83620">m_nextChannel</a> = 0;<a name="l00327"></a>00327 }<a name="l00328"></a>00328 <a name="l00329"></a>00329 <span class="keywordflow">if</span> (messageEnd)<a name="l00330"></a>00330 {<a name="l00331"></a>00331 <a class="code" href="class_information_dispersal.html#fd962aac086ce5c3fbf16157d59e4e63">m_ida</a>.<a class="code" href="class_auto_signaling.html#e63c0428295aeec8ffd9557ef1d86db9">SetAutoSignalPropagation</a>(messageEnd-1);<a name="l00332"></a>00332 <span class="keywordflow">if</span> (<a class="code" href="class_information_dispersal.html#fc464de54c9d574c9bff3d674907fd42">m_pad</a>)<a name="l00333"></a>00333 <a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">InformationDispersal::Put</a>(1);<a name="l00334"></a>00334 <span class="keywordflow">for</span> (word32 i=0; i<<a class="code" href="class_information_dispersal.html#fd962aac086ce5c3fbf16157d59e4e63">m_ida</a>.<a class="code" href="class_raw_i_d_a.html#cbdf3bfeabd7a7c64b03b61fa8929d4c">GetThreshold</a>(); i++)<a name="l00335"></a>00335 <a class="code" href="class_information_dispersal.html#fd962aac086ce5c3fbf16157d59e4e63">m_ida</a>.<a class="code" href="class_raw_i_d_a.html#3fa15d51e46a8eaee252a0a7034aac47">ChannelData</a>(i, NULL, 0, <span class="keyword">true</span>);<a name="l00336"></a>00336 }<a name="l00337"></a>00337 <a name="l00338"></a>00338 <span class="keywordflow">return</span> 0;<a name="l00339"></a>00339 }<a name="l00340"></a>00340 <a name="l00341"></a>00341 <span class="keywordtype">void</span> InformationRecovery::IsolatedInitialize(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &parameters)<a name="l00342"></a>00342 {<a name="l00343"></a>00343 <a class="code" href="class_information_recovery.html#8836fa3444af96b7d9a3bc0e45afd4f7">m_pad</a> = parameters.<a class="code" href="class_name_value_pairs.html#943b2009297783f1c35bae46efc3b5f7" title="get a named value, returns the default if the name doesn't exist">GetValueWithDefault</a>(<span class="stringliteral">"RemovePadding"</span>, <span class="keyword">true</span>);<a name="l00344"></a>00344 RawIDA::IsolatedInitialize(parameters);<a name="l00345"></a>00345 }<a name="l00346"></a>00346 <a name="l00347"></a>00347 <span class="keywordtype">void</span> InformationRecovery::FlushOutputQueues()<a name="l00348"></a>00348 {<a name="l00349"></a>00349 <span class="keywordflow">while</span> (<a class="code" href="class_raw_i_d_a.html#ae55af87cd9751e8b37923bde5aacd82">m_outputQueues</a>[0].<a class="code" href="class_buffered_transformation.html#8c1e2ca57fc06a1f3694d8fe7f8508ff" title="returns whether any bytes are currently ready for retrieval">AnyRetrievable</a>())<a name="l00350"></a>00350 {<a name="l00351"></a>00351 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<<a class="code" href="class_raw_i_d_a.html#376de5858283ae6ec368ee49d53febad">m_outputChannelIds</a>.size(); i++)<a name="l00352"></a>00352 <a class="code" href="class_raw_i_d_a.html#ae55af87cd9751e8b37923bde5aacd82">m_outputQueues</a>[i].<a class="code" href="class_buffered_transformation.html#91c4526148274ae9cb68803bb2d2a2aa" title="move transferMax bytes of the buffered output to target as input">TransferTo</a>(<a class="code" href="class_information_recovery.html#3d12ccc4618e3fa5e0c0412fe2f8f0e1">m_queue</a>, 1);<a name="l00353"></a>00353 }<a name="l00354"></a>00354 <a name="l00355"></a>00355 <span class="keywordflow">if</span> (<a class="code" href="class_information_recovery.html#8836fa3444af96b7d9a3bc0e45afd4f7">m_pad</a>)<a name="l00356"></a>00356 <a class="code" href="class_information_recovery.html#3d12ccc4618e3fa5e0c0412fe2f8f0e1">m_queue</a>.<a class="code" href="class_buffered_transformation.html#91c4526148274ae9cb68803bb2d2a2aa" title="move transferMax bytes of the buffered output to target as input">TransferTo</a>(*<a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>(), <a class="code" href="class_information_recovery.html#3d12ccc4618e3fa5e0c0412fe2f8f0e1">m_queue</a>.<a class="code" href="class_byte_queue.html#ad7436088ce8a852e9e95d291590a9f9" title="returns number of bytes that is currently ready for retrieval">MaxRetrievable</a>()-4*m_threshold);<a name="l00357"></a>00357 <span class="keywordflow">else</span><a name="l00358"></a>00358 <a class="code" href="class_information_recovery.html#3d12ccc4618e3fa5e0c0412fe2f8f0e1">m_queue</a>.<a class="code" href="class_buffered_transformation.html#91c4526148274ae9cb68803bb2d2a2aa" title="move transferMax bytes of the buffered output to target as input">TransferTo</a>(*<a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>());<a name="l00359"></a>00359 }<a name="l00360"></a>00360 <a name="l00361"></a>00361 <span class="keywordtype">void</span> InformationRecovery::OutputMessageEnds()<a name="l00362"></a>00362 {<a name="l00363"></a>00363 <span class="keywordflow">if</span> (<a class="code" href="class_information_recovery.html#8836fa3444af96b7d9a3bc0e45afd4f7">m_pad</a>)<a name="l00364"></a>00364 {<a name="l00365"></a>00365 <a class="code" href="class_padding_remover.html">PaddingRemover</a> paddingRemover(<span class="keyword">new</span> <a class="code" href="class_redirector.html" title="Redirect input to another BufferedTransformation without owning it.">Redirector</a>(*<a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()));<a name="l00366"></a>00366 <a class="code" href="class_information_recovery.html#3d12ccc4618e3fa5e0c0412fe2f8f0e1">m_queue</a>.<a class="code" href="class_buffered_transformation.html#80b60bff9f62976c15effdbc45cbc5f1">TransferAllTo</a>(paddingRemover);<a name="l00367"></a>00367 }<a name="l00368"></a>00368 <a name="l00369"></a>00369 <span class="keywordflow">if</span> (<a class="code" href="class_auto_signaling.html#011dc89743a4790bdd2ddefd9f176766">GetAutoSignalPropagation</a>() != 0)<a name="l00370"></a>00370 <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-><a class="code" href="class_buffered_transformation.html#20ae0ef2e4ff338b43849e541e9b940f">MessageEnd</a>(<a class="code" href="class_auto_signaling.html#011dc89743a4790bdd2ddefd9f176766">GetAutoSignalPropagation</a>()-1);<a name="l00371"></a>00371 }<a name="l00372"></a>00372 <a name="l00373"></a>00373 <span class="keywordtype">size_t</span> <a class="code" href="class_padding_remover.html#ae803b9a474a16cc10ae3ab66630b299" title="input multiple bytes for blocking or non-blocking processing">PaddingRemover::Put2</a>(<span class="keyword">const</span> byte *begin, <span class="keywordtype">size_t</span> length, <span class="keywordtype">int</span> messageEnd, <span class="keywordtype">bool</span> blocking)<a name="l00374"></a>00374 {<a name="l00375"></a>00375 <span class="keywordflow">if</span> (!blocking)<a name="l00376"></a>00376 <span class="keywordflow">throw</span> BlockingInputOnly(<span class="stringliteral">"PaddingRemover"</span>);<a name="l00377"></a>00377 <a name="l00378"></a>00378 <span class="keyword">const</span> byte *<span class="keyword">const</span> end = begin + length;<a name="l00379"></a>00379 <a name="l00380"></a>00380 <span class="keywordflow">if</span> (m_possiblePadding)<a name="l00381"></a>00381 {<a name="l00382"></a>00382 <span class="keywordtype">size_t</span> len = find_if(begin, end, bind2nd(not_equal_to<byte>(), 0)) - begin;<a name="l00383"></a>00383 m_zeroCount += len;<a name="l00384"></a>00384 begin += len;<a name="l00385"></a>00385 <span class="keywordflow">if</span> (begin == end)<a name="l00386"></a>00386 <span class="keywordflow">return</span> 0;<a name="l00387"></a>00387 <a name="l00388"></a>00388 <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-><a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(1);<a name="l00389"></a>00389 <span class="keywordflow">while</span> (m_zeroCount--)<a name="l00390"></a>00390 <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-><a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(0);<a name="l00391"></a>00391 <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-><a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(*begin++);<a name="l00392"></a>00392 m_possiblePadding = <span class="keyword">false</span>;<a name="l00393"></a>00393 }<a name="l00394"></a>00394 <a name="l00395"></a>00395 <span class="preprocessor">#if defined(_MSC_VER) && !defined(__MWERKS__) && (_MSC_VER <= 1300)</span><a name="l00396"></a>00396 <span class="preprocessor"></span> <span class="comment">// VC60 and VC7 workaround: built-in reverse_iterator has two template parameters, Dinkumware only has one</span><a name="l00397"></a>00397 <span class="keyword">typedef</span> reverse_bidirectional_iterator<const byte *, const byte> RevIt;<a name="l00398"></a>00398 <span class="preprocessor">#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)</span><a name="l00399"></a>00399 <span class="preprocessor"></span> <span class="keyword">typedef</span> reverse_iterator<const byte *, random_access_iterator_tag, const byte> RevIt;<a name="l00400"></a>00400 <span class="preprocessor">#else</span><a name="l00401"></a>00401 <span class="preprocessor"></span> <span class="keyword">typedef</span> reverse_iterator<const byte *> RevIt;<a name="l00402"></a>00402 <span class="preprocessor">#endif</span><a name="l00403"></a>00403 <span class="preprocessor"></span> <span class="keyword">const</span> byte *x = find_if(RevIt(end), RevIt(begin), bind2nd(not_equal_to<byte>(), 0)).base();<a name="l00404"></a>00404 <span class="keywordflow">if</span> (x != begin && *(x-1) == 1)<a name="l00405"></a>00405 {<a name="l00406"></a>00406 <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-><a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(begin, x-begin-1);<a name="l00407"></a>00407 m_possiblePadding = <span class="keyword">true</span>;<a name="l00408"></a>00408 m_zeroCount = end - x;<a name="l00409"></a>00409 }<a name="l00410"></a>00410 <span class="keywordflow">else</span><a name="l00411"></a>00411 <a class="code" href="class_filter.html#c8fc888888b2dad88bf64fc703044a93" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>()-><a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(begin, end-begin);<a name="l00412"></a>00412 <a name="l00413"></a>00413 <span class="keywordflow">if</span> (messageEnd)<a name="l00414"></a>00414 {<a name="l00415"></a>00415 m_possiblePadding = <span class="keyword">false</span>;<a name="l00416"></a>00416 <a class="code" href="class_filter.html#a05cdcaa161f2131cf4d5dcb8903e11f">Output</a>(0, begin, length, messageEnd, blocking);<a name="l00417"></a>00417 }<a name="l00418"></a>00418 <span class="keywordflow">return</span> 0;<a name="l00419"></a>00419 }<a name="l00420"></a>00420 <a name="l00421"></a>00421 NAMESPACE_END</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jun 1 11:11:21 2007 for Crypto++ by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -