<trclass="memdesc:abaf38090f967423898b99e0455751c07"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Processes a DDT v1 block from the image stream. <br/></td></tr>
<trclass="memdesc:aabd621530978c71e2abb20d78098453e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Decodes a DDT v1 entry for a given sector address. <br/></td></tr>
<p>Decodes a DDT v1 entry for a given sector address. </p>
<p>Determines the offset and block offset for a sector using the DDT v1 table. This function performs bit manipulation on the DDT entry to extract the sector offset within a block and the block offset, and determines whether the sector was dumped or not based on the DDT entry value.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">ctx</td><td>Pointer to the aaruformat context containing the loaded DDT table. </td></tr>
<tr><tdclass="paramname">sector_address</td><td>Logical sector address to decode (must be within valid range). </td></tr>
<tr><tdclass="paramname">offset</td><td>Pointer to store the resulting sector offset within the block. </td></tr>
<tr><tdclass="paramname">block_offset</td><td>Pointer to store the resulting block offset in the image. </td></tr>
<tr><tdclass="paramname">sector_status</td><td>Pointer to store the sector status (dumped or not dumped).</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>Returns one of the following status codes: </dd></dl>
<dlclass="retval"><dt>Return values</dt><dd>
<tableclass="retval">
<tr><tdclass="paramname">AARUF_STATUS_OK</td><td>(0) Successfully decoded the DDT entry. This is always returned when:<ul>
<li>The context and image stream are valid</li>
<li>The DDT entry is successfully extracted and decoded</li>
<li>The offset, block_offset, and sector_status are successfully populated</li>
<li>A zero DDT entry is encountered (indicates sector not dumped)</li>
<li>A non-zero DDT entry is encountered (indicates sector was dumped)</li>
</ul>
</td></tr>
<tr><tdclass="paramname">AARUF_ERROR_NOT_AARUFORMAT</td><td>(-1) The context or image stream is invalid (NULL pointers). This is the only error condition that can occur in this function.</td></tr>
</table>
</dd>
</dl>
<dlclass="section note"><dt>Note</dt><dd>This is a lightweight function that performs only basic validation and bit manipulation. It does not perform bounds checking on the sector_address parameter.</dd>
<dd>
DDT Entry Decoding:<ul>
<li>Uses a bit mask derived from ctx->shift to extract the offset within block</li>
<li>Right-shifts the DDT entry by ctx->shift bits to get the block offset</li>
<li>A zero DDT entry indicates the sector was not dumped (SectorStatusNotDumped)</li>
<li>A non-zero DDT entry indicates the sector was dumped (SectorStatusDumped)</li>
</ul>
</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>The function assumes:<ul>
<li>The DDT table (ctx->userDataDdt) has been properly loaded by <aclass="el"href="#abaf38090f967423898b99e0455751c07"title="Processes a DDT v1 block from the image stream.">process_ddt_v1()</a></li>
<li>The sector_address is within the valid range of the DDT table</li>
<li>The shift value (ctx->shift) has been properly initialized</li>
<li>All output parameters (offset, block_offset, sector_status) are valid pointers</li>
</ul>
</dd>
<dd>
No bounds checking is performed on sector_address. Accessing beyond the DDT table boundaries will result in undefined behavior. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="ddt__v1_8c_source.html#l00405">405</a> of file <aclass="el"href="ddt__v1_8c_source.html">ddt_v1.c</a>.</p>
<p>Processes a DDT v1 block from the image stream. </p>
<p>Reads and decompresses (if needed) a DDT v1 block, verifies its integrity, and loads it into memory or maps it. This function handles both user data DDT blocks and CD sector prefix/suffix corrected DDT blocks, supporting both LZMA compression and uncompressed formats. On Linux, uncompressed blocks can be memory-mapped for improved performance.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">ctx</td><td>Pointer to the aaruformat context. </td></tr>
<tr><tdclass="paramname">entry</td><td>Pointer to the index entry describing the DDT block. </td></tr>
<tr><tdclass="paramname">found_user_data_ddt</td><td>Pointer to a boolean that will be set to true if a user data DDT was found and loaded.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>Returns one of the following status codes: </dd></dl>
<dlclass="retval"><dt>Return values</dt><dd>
<tableclass="retval">
<tr><tdclass="paramname">AARUF_STATUS_OK</td><td>(0) Successfully processed the DDT block. This is returned when:<ul>
<li>The DDT block is successfully read, decompressed (if needed), and loaded into memory</li>
<li>Memory mapping of uncompressed DDT succeeds on Linux systems</li>
<li>CD sector prefix/suffix corrected DDT blocks are processed successfully</li>
<li>Memory allocation failures occur for non-critical operations (processing continues)</li>
<li>File reading errors occur for compressed data or LZMA properties (processing continues)</li>
<li>Unknown compression types are encountered (block is skipped)</li>
<li>Memory mapping fails on Linux (sets found_user_data_ddt to false but continues)</li>
<li>Uncompressed DDT is encountered on non-Linux systems (not yet implemented, continues)</li>
</ul>
</td></tr>
<tr><tdclass="paramname">AARUF_ERROR_NOT_AARUFORMAT</td><td>(-1) The context or image stream is invalid (NULL pointers).</td></tr>
<tr><tdclass="paramname">AARUF_ERROR_CANNOT_READ_BLOCK</td><td>(-7) Failed to access the DDT block in the image stream. This occurs when:<ul>
<li>fseek() fails to position at the DDT block offset</li>
<li>The file position doesn't match the expected offset after seeking</li>
<li>Failed to read the DDT header from the image stream</li>
<li>The number of bytes read for the DDT header is insufficient</li>
</ul>
</td></tr>
<tr><tdclass="paramname">AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK</td><td>(-17) LZMA decompression failed. This can happen when:<ul>
<li>The LZMA decoder returns a non-zero error code during decompression</li>
<li>The decompressed data size doesn't match the expected DDT block length</li>
<li>This error causes immediate function termination and memory cleanup</li>
</ul>
</td></tr>
</table>
</dd>
</dl>
<dlclass="section note"><dt>Note</dt><dd>The function exhibits different error handling strategies depending on the operation:<ul>
<li>The found_user_data_ddt flag is updated to reflect the success of user data DDT loading</li>
</ul>
</dd>
<dd>
Memory Management:<ul>
<li>Allocated DDT data is stored in the context (ctx->userDataDdt, ctx->sectorPrefixDdt, ctx->sectorSuffixDdt)</li>
<li>On Linux, uncompressed DDTs may be memory-mapped instead of allocated</li>
<li>Memory is automatically cleaned up on decompression errors</li>
</ul>
</dd>
<dd>
Platform-specific behavior:<ul>
<li>Linux: Supports memory mapping of uncompressed DDT blocks for better performance</li>
<li>Non-Linux: Uncompressed DDT processing is not yet implemented</li>
</ul>
</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>The function modifies context state including sector count, shift value, and DDT version. Ensure proper context cleanup when the function completes. </dd></dl>
<pclass="definition">Definition at line <aclass="el"href="ddt__v1_8c_source.html#l00085">85</a> of file <aclass="el"href="ddt__v1_8c_source.html">ddt_v1.c</a>.</p>
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.14.0 </li>