Files
libaaruformat/docs/html/blocks_2metadata_8c.html

513 lines
42 KiB
HTML
Raw Normal View History

2025-10-11 01:35:43 +01:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libaaruformat: src/blocks/metadata.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">libaaruformat<span id="projectnumber">&#160;1.0</span>
</div>
<div id="projectbrief">Aaru Data Preservation Suite - Format Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('blocks_2metadata_8c.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">metadata.c File Reference</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;inttypes.h&gt;</code><br />
<code>#include &lt;stdint.h&gt;</code><br />
<code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &quot;<a class="el" href="aaruformat_8h_source.html">aaruformat.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="log_8h_source.html">log.h</a>&quot;</code><br />
</div>
<p><a href="blocks_2metadata_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a43974d4c183240be30d49ff09ef7b8c2" id="r_a43974d4c183240be30d49ff09ef7b8c2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a43974d4c183240be30d49ff09ef7b8c2">process_metadata_block</a> (<a class="el" href="structaaruformat__context.html">aaruformat_context</a> *ctx, const <a class="el" href="structIndexEntry.html">IndexEntry</a> *entry)</td></tr>
<tr class="memdesc:a43974d4c183240be30d49ff09ef7b8c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Processes a metadata block from the image stream. <br /></td></tr>
<tr class="memitem:a81d410de6727d95a85b827067e1a8bc6" id="r_a81d410de6727d95a85b827067e1a8bc6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a81d410de6727d95a85b827067e1a8bc6">process_geometry_block</a> (<a class="el" href="structaaruformat__context.html">aaruformat_context</a> *ctx, const <a class="el" href="structIndexEntry.html">IndexEntry</a> *entry)</td></tr>
<tr class="memdesc:a81d410de6727d95a85b827067e1a8bc6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Processes a logical geometry block from the image stream. <br /></td></tr>
<tr class="memitem:a5e0397faed8aea27c5a6a3881875de54" id="r_a5e0397faed8aea27c5a6a3881875de54"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a5e0397faed8aea27c5a6a3881875de54">process_cicm_block</a> (<a class="el" href="structaaruformat__context.html">aaruformat_context</a> *ctx, const <a class="el" href="structIndexEntry.html">IndexEntry</a> *entry)</td></tr>
<tr class="memdesc:a5e0397faed8aea27c5a6a3881875de54"><td class="mdescLeft">&#160;</td><td class="mdescRight">Processes a CICM XML metadata block from the image stream. <br /></td></tr>
<tr class="memitem:a84003ec881425a7b28ec24cb48d19f02" id="r_a84003ec881425a7b28ec24cb48d19f02"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a84003ec881425a7b28ec24cb48d19f02">process_aaru_metadata_json_block</a> (<a class="el" href="structaaruformat__context.html">aaruformat_context</a> *ctx, const <a class="el" href="structIndexEntry.html">IndexEntry</a> *entry)</td></tr>
<tr class="memdesc:a84003ec881425a7b28ec24cb48d19f02"><td class="mdescLeft">&#160;</td><td class="mdescRight">Processes an Aaru metadata JSON block from the image stream during image opening. <br /></td></tr>
2025-10-18 17:55:08 +01:00
<tr class="memitem:aa9ed74c6988c035d9ba0d11965d5cf10" id="r_aa9ed74c6988c035d9ba0d11965d5cf10"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa9ed74c6988c035d9ba0d11965d5cf10">aaruf_get_readable_sector_tags</a> (const void *context, uint8_t *buffer, size_t *length)</td></tr>
<tr class="memdesc:aa9ed74c6988c035d9ba0d11965d5cf10"><td class="mdescLeft">&#160;</td><td class="mdescRight">Retrieves which sector tags are readable in the AaruFormat image. <br /></td></tr>
<tr class="memitem:a9cfc80d1cfa399bfea980b6ac4e2208a" id="r_a9cfc80d1cfa399bfea980b6ac4e2208a"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a9cfc80d1cfa399bfea980b6ac4e2208a">aaruf_get_readable_media_tags</a> (const void *context, uint8_t *buffer, size_t *length)</td></tr>
<tr class="memdesc:a9cfc80d1cfa399bfea980b6ac4e2208a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Retrieves which media tags are present in the AaruFormat image. <br /></td></tr>
2025-10-11 01:35:43 +01:00
</table>
<a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
2025-10-18 17:55:08 +01:00
<a id="a9cfc80d1cfa399bfea980b6ac4e2208a" name="a9cfc80d1cfa399bfea980b6ac4e2208a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9cfc80d1cfa399bfea980b6ac4e2208a">&#9670;&#160;</a></span>aaruf_get_readable_media_tags()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t aaruf_get_readable_media_tags </td>
<td>(</td>
<td class="paramtype">const void *</td> <td class="paramname"><span class="paramname"><em>context</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *</td> <td class="paramname"><span class="paramname"><em>buffer</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t *</td> <td class="paramname"><span class="paramname"><em>length</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Retrieves which media tags are present in the AaruFormat image. </p>
<p>Returns an array of booleans indicating the presence of each <a class="el" href="group__MediaTags.html#gabdd09c559df8f34ae68fcb2ff1892ebe">MediaTagType</a> in the image. The array is indexed by <a class="el" href="group__MediaTags.html#gabdd09c559df8f34ae68fcb2ff1892ebe">MediaTagType</a> enum values (0 to MaxMediaTag), where each boolean is true if the corresponding media tag exists in the image's mediaTags hash table.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">context</td><td>Pointer to the aaruformat context (must be a valid, opened image context). </td></tr>
<tr><td class="paramname">buffer</td><td>Pointer to a buffer to store the boolean array. Can be NULL to query required length. </td></tr>
<tr><td class="paramname">length</td><td>Pointer to the buffer length. On input, contains buffer size; on output, contains required size.</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns one of the following status codes: </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">AARUF_STATUS_OK</td><td>(0) Successfully retrieved readable media tags. This is returned when:<ul>
<li>The context is valid and properly initialized</li>
<li>The buffer is large enough to hold all <a class="el" href="group__MediaTags.html#gabdd09c559df8f34ae68fcb2ff1892ebe">MediaTagType</a> values (0 to MaxMediaTag)</li>
<li>The output array has been populated with true/false for each <a class="el" href="group__MediaTags.html#gabdd09c559df8f34ae68fcb2ff1892ebe">MediaTagType</a></li>
</ul>
</td></tr>
<tr><td class="paramname">AARUF_ERROR_NOT_AARUFORMAT</td><td>(-1) The context is invalid. This occurs when:<ul>
<li>The context parameter is NULL</li>
<li>The context magic number doesn't match AARU_MAGIC (invalid context type)</li>
</ul>
</td></tr>
<tr><td class="paramname">AARUF_ERROR_BUFFER_TOO_SMALL</td><td>(-10) The buffer is too small. This occurs when:<ul>
<li>The buffer parameter is NULL</li>
<li>The length parameter is NULL</li>
<li>The provided buffer is smaller than required (size = MaxMediaTag + 1 bytes)</li>
<li>The length output will contain the required buffer size</li>
</ul>
</td></tr>
</table>
</dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Buffer Size: The buffer must be at least (MaxMediaTag + 1) bytes, where each byte represents whether the corresponding <a class="el" href="group__MediaTags.html#gabdd09c559df8f34ae68fcb2ff1892ebe">MediaTagType</a> is present in the image.</dd>
<dd>
Query Mode: To query the required buffer size, pass buffer == NULL or *length &lt; required. The function will return AARUF_ERROR_BUFFER_TOO_SMALL and set *length to required size.</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>The output parameters are only modified on success (AARUF_STATUS_OK). On error, their values remain unchanged. </dd></dl>
<p class="definition">Definition at line <a class="el" href="blocks_2metadata_8c_source.html#l00706">706</a> of file <a class="el" href="blocks_2metadata_8c_source.html">metadata.c</a>.</p>
<p class="reference">References <a class="el" href="decls_8h_source.html#l00045">AARU_CALL</a>, <a class="el" href="decls_8h_source.html#l00054">AARU_EXPORT</a>, <a class="el" href="consts_8h_source.html#l00064">AARU_MAGIC</a>, <a class="el" href="errors_8h_source.html#l00049">AARUF_ERROR_BUFFER_TOO_SMALL</a>, <a class="el" href="errors_8h_source.html#l00040">AARUF_ERROR_NOT_AARUFORMAT</a>, <a class="el" href="errors_8h_source.html#l00075">AARUF_STATUS_OK</a>, <a class="el" href="log_8h_source.html#l00040">FATAL</a>, <a class="el" href="context_8h_source.html#l00174">aaruformat_context::magic</a>, <a class="el" href="aaru_8h_source.html#l01011">MaxMediaTag</a>, <a class="el" href="context_8h_source.html#l00264">aaruformat_context::mediaTags</a>, and <a class="el" href="log_8h_source.html#l00025">TRACE</a>.</p>
</div>
</div>
<a id="aa9ed74c6988c035d9ba0d11965d5cf10" name="aa9ed74c6988c035d9ba0d11965d5cf10"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa9ed74c6988c035d9ba0d11965d5cf10">&#9670;&#160;</a></span>aaruf_get_readable_sector_tags()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t aaruf_get_readable_sector_tags </td>
<td>(</td>
<td class="paramtype">const void *</td> <td class="paramname"><span class="paramname"><em>context</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *</td> <td class="paramname"><span class="paramname"><em>buffer</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t *</td> <td class="paramname"><span class="paramname"><em>length</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Retrieves which sector tags are readable in the AaruFormat image. </p>
<p>Returns an array of booleans indicating whether each <a class="el" href="group__SectorTags.html#gaf863e81d172ce7a216d8687a8a23293a">SectorTagType</a> was successfully read from the image. The array is indexed by <a class="el" href="group__SectorTags.html#gaf863e81d172ce7a216d8687a8a23293a">SectorTagType</a> enum values (0 to MaxSectorTag), where each boolean is true if the corresponding sector tag data is present and readable in the image. Sector tags contain per-sector metadata such as sync headers, ECC/EDC codes, subchannels, and other sector-level information essential for exact media reconstruction.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">context</td><td>Pointer to the aaruformat context (must be a valid, opened image context). </td></tr>
<tr><td class="paramname">buffer</td><td>Pointer to a buffer to store the boolean array. Can be NULL to query required length. </td></tr>
<tr><td class="paramname">length</td><td>Pointer to the buffer length. On input, contains buffer size; on output, contains required size.</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns one of the following status codes: </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">AARUF_STATUS_OK</td><td>(0) Successfully retrieved readable sector tags. This is returned when:<ul>
<li>The context is valid and properly initialized</li>
<li>The readableSectorTags array is populated in the context</li>
<li>The buffer is large enough to hold all <a class="el" href="group__SectorTags.html#gaf863e81d172ce7a216d8687a8a23293a">SectorTagType</a> values (0 to MaxSectorTag)</li>
<li>The output array has been successfully copied from the internal readableSectorTags</li>
</ul>
</td></tr>
<tr><td class="paramname">AARUF_ERROR_NOT_AARUFORMAT</td><td>(-1) The context is invalid. This occurs when:<ul>
<li>The context parameter is NULL</li>
<li>The context magic number doesn't match AARU_MAGIC (invalid context type)</li>
<li>The context was not properly initialized by <a class="el" href="decls_8h.html#afc4932cdc795ffb2ef3a33d5b8c57656" title="Opens an existing AaruFormat image file.">aaruf_open()</a> or <a class="el" href="decls_8h.html#a7065a9fefcaabfecc4184528f01ef013" title="Creates a new AaruFormat image file.">aaruf_create()</a></li>
</ul>
</td></tr>
<tr><td class="paramname">AARUF_ERROR_METADATA_NOT_PRESENT</td><td>(-30) The sector tags array is not available. This occurs when:<ul>
<li>The readableSectorTags array is NULL (not initialized in the context)</li>
<li>The image was created without sector tag support</li>
<li>The image format does not support or require sector tags</li>
</ul>
</td></tr>
<tr><td class="paramname">AARUF_ERROR_BUFFER_TOO_SMALL</td><td>(-10) The buffer is too small. This occurs when:<ul>
<li>The buffer parameter is NULL</li>
<li>The length parameter is NULL</li>
<li>The provided buffer is smaller than required (size = (MaxSectorTag + 1) * sizeof(bool))</li>
<li>The length output will contain the required buffer size in bytes</li>
</ul>
</td></tr>
</table>
</dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Buffer Size: The buffer must be at least (MaxSectorTag + 1) bytes, where each byte represents whether the corresponding <a class="el" href="group__SectorTags.html#gaf863e81d172ce7a216d8687a8a23293a">SectorTagType</a> data was successfully read in the image. On most systems, sizeof(bool) == 1, so the required size is (MaxSectorTag + 1) bytes.</dd>
<dd>
Sector Tag Types: Sector tags preserve on-disk structures not part of main user data. Examples include:<ul>
<li>CD sector sync/header information (CdSectorSync, CdSectorHeader)</li>
<li>CD subheaders and ECC/EDC codes (CdSectorSubHeader, CdSectorEcc, CdSectorEdc)</li>
<li>DVD sector numbers and IED (DvdSectorNumber)</li>
<li>Media-specific proprietary tags (AppleProfileTagAaru, PriamDataTowerTagAaru)</li>
</ul>
</dd>
<dd>
Query Mode: To query the required buffer size, pass buffer == NULL or *length &lt; required. The function will return AARUF_ERROR_BUFFER_TOO_SMALL and set *length to required size. This allows allocation of properly sized buffers without prior knowledge of MaxSectorTag.</dd>
<dd>
Data Interpretation: A true value (non-zero) at buffer[i] indicates sector tag type i was readable. A false value (zero) at buffer[i] indicates that sector tag type i is either not present or was not successfully read from the image during opening. The readableSectorTags array is populated during image opening/processing in data blocks.</dd>
<dd>
Image Opening Context: The readableSectorTags array is initialized during <a class="el" href="decls_8h.html#afc4932cdc795ffb2ef3a33d5b8c57656" title="Opens an existing AaruFormat image file.">aaruf_open()</a> or <a class="el" href="decls_8h.html#a7065a9fefcaabfecc4184528f01ef013" title="Creates a new AaruFormat image file.">aaruf_create()</a> and populated as data blocks are processed. It reflects what was actually present and readable in the image file, not what theoretically could be present for the media type.</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>The output parameters are only modified on success (AARUF_STATUS_OK). On error, their values remain unchanged. Initialize them before calling if default values are needed on failure.</dd>
<dd>
If readableSectorTags is NULL in the context, AARUF_ERROR_NOT_FOUND is returned. This typically indicates the image format does not support sector-level tags, rather than indicating an error state. Check return value to distinguish.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__SectorTags.html#gaf863e81d172ce7a216d8687a8a23293a">SectorTagType</a> for enumeration of all available sector tag types </dd>
<dd>
<a class="el" href="decls_8h.html#ae5a85524a6e27339c02c4a5791e0db57" title="Reads a specific sector tag from the AaruFormat image.">aaruf_read_sector_tag()</a> for reading individual sector tag data </dd>
<dd>
<a class="el" href="decls_8h.html#a6a8994cd006711347fb03cec465eafa6" title="Writes per-sector tag data (auxiliary metadata) for a specific sector.">aaruf_write_sector_tag()</a> for writing sector tags during image creation </dd></dl>
<p class="definition">Definition at line <a class="el" href="blocks_2metadata_8c_source.html#l00618">618</a> of file <a class="el" href="blocks_2metadata_8c_source.html">metadata.c</a>.</p>
<p class="reference">References <a class="el" href="decls_8h_source.html#l00045">AARU_CALL</a>, <a class="el" href="decls_8h_source.html#l00054">AARU_EXPORT</a>, <a class="el" href="consts_8h_source.html#l00064">AARU_MAGIC</a>, <a class="el" href="errors_8h_source.html#l00049">AARUF_ERROR_BUFFER_TOO_SMALL</a>, <a class="el" href="errors_8h_source.html#l00069">AARUF_ERROR_METADATA_NOT_PRESENT</a>, <a class="el" href="errors_8h_source.html#l00040">AARUF_ERROR_NOT_AARUFORMAT</a>, <a class="el" href="errors_8h_source.html#l00075">AARUF_STATUS_OK</a>, <a class="el" href="log_8h_source.html#l00040">FATAL</a>, <a class="el" href="context_8h_source.html#l00174">aaruformat_context::magic</a>, <a class="el" href="aaru_8h_source.html#l00918">MaxSectorTag</a>, <a class="el" href="context_8h_source.html#l00263">aaruformat_context::readableSectorTags</a>, and <a class="el" href="log_8h_source.html#l00025">TRACE</a>.</p>
</div>
</div>
2025-10-11 01:35:43 +01:00
<a id="a84003ec881425a7b28ec24cb48d19f02" name="a84003ec881425a7b28ec24cb48d19f02"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a84003ec881425a7b28ec24cb48d19f02">&#9670;&#160;</a></span>process_aaru_metadata_json_block()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void process_aaru_metadata_json_block </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structaaruformat__context.html">aaruformat_context</a> *</td> <td class="paramname"><span class="paramname"><em>ctx</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structIndexEntry.html">IndexEntry</a> *</td> <td class="paramname"><span class="paramname"><em>entry</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Processes an Aaru metadata JSON block from the image stream during image opening. </p>
<p>Reads an Aaru metadata JSON block from the image file and loads its contents into the context for subsequent retrieval. The Aaru metadata JSON format is a structured representation of comprehensive image metadata including media information, imaging session details, hardware configuration, optical disc tracks and sessions, checksums, and preservation metadata. The JSON payload is stored in its original form without parsing or interpretation by this function, allowing higher-level code to process the structured data as needed.</p>
<p>This function is called during the image opening process (aaruf_open) when an index entry indicates the presence of an AaruMetadataJsonBlock. The function is non-critical; if reading fails or memory allocation fails, the error is logged but the image opening continues. This allows images without JSON metadata or with corrupted JSON blocks to still be opened for data access.</p>
<p><b>Processing sequence:</b></p><ol type="1">
<li>Validate context and image stream</li>
<li>Seek to the block offset specified by the index entry</li>
<li>Read the <a class="el" href="structAaruMetadataJsonBlockHeader.html" title="Header for an Aaru metadata JSON block (identifier == BlockType::AaruMetadataJsonBlock).">AaruMetadataJsonBlockHeader</a> (8 bytes: identifier + length)</li>
<li>Validate the block identifier matches AaruMetadataJsonBlock</li>
<li>Allocate memory for the JSON payload</li>
<li>Read the JSON data from the file stream</li>
<li>Store header and data pointer in the context for later retrieval</li>
</ol>
<p><b>Memory allocation:</b> The function allocates memory (via malloc) sized to hold the entire JSON payload as specified by ctx-&gt;jsonBlockHeader.length. This memory remains allocated for the lifetime of the context and is freed during <a class="el" href="decls_8h.html#a6823e139f81a9dfd08efcb0e9b213a49" title="Close an Aaru image context, flushing pending data structures and releasing resources.">aaruf_close()</a>. If allocation fails, the function returns gracefully without the JSON metadata, allowing the image to still be opened.</p>
<p><b>Image size tracking:</b> The function increments ctx-&gt;imageInfo.ImageSize by the length of the JSON payload to track the total size of metadata and structural blocks in the image.</p>
<p><b>Error handling:</b> All errors are non-fatal and handled gracefully:</p><ul>
<li>Seek failures: logged and function returns early</li>
<li>Header read failures: header zeroed, function returns</li>
<li>Identifier mismatches: header zeroed, processing continues but data is not loaded</li>
<li>Memory allocation failures: header zeroed, function returns</li>
<li>Data read failures: header zeroed, allocated memory freed, function returns</li>
</ul>
<p>In all error cases, the ctx-&gt;jsonBlockHeader is zeroed (memset to 0) to indicate that no valid JSON metadata is available, and any allocated memory is properly freed.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>Pointer to an initialized aaruformatContext being populated during image opening. Must not be NULL. ctx-&gt;imageStream must be open and readable. On success, ctx-&gt;jsonBlockHeader will contain the block header and ctx-&gt;jsonBlock will point to the allocated JSON data. </td></tr>
<tr><td class="paramname">entry</td><td>Pointer to the <a class="el" href="structIndexEntry.html" title="Single index entry describing a block&#39;s type, (optional) data classification, and file offset.">IndexEntry</a> that specifies the file offset where the AaruMetadataJsonBlock begins. Must not be NULL. entry-&gt;offset indicates the position of the block header in the file.</td></tr>
</table>
</dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>JSON Format and Encoding:<ul>
<li>The JSON payload is stored in UTF-8 encoding</li>
<li>The payload may or may not be null-terminated</li>
<li>This function treats the JSON as opaque binary data</li>
<li>No JSON parsing, interpretation, or validation is performed during loading</li>
<li>JSON schema validation is the responsibility of code that retrieves the metadata</li>
</ul>
</dd>
<dd>
Aaru Metadata JSON Purpose:<ul>
<li>Provides machine-readable structured metadata about the image</li>
<li>Includes comprehensive information about media, sessions, tracks, and checksums</li>
<li>Enables programmatic access to metadata without XML parsing overhead</li>
<li>Complements CICM XML with a more modern, structured format</li>
<li>Used by Aaru and compatible tools for metadata exchange</li>
</ul>
</dd>
<dd>
Non-Critical Nature:<ul>
<li>JSON metadata is optional and supplementary to core image data</li>
<li>Failures reading this block do not prevent image opening</li>
<li>The image remains fully functional for sector data access without JSON metadata</li>
<li>Higher-level code should check if ctx-&gt;jsonBlock is non-NULL before use</li>
</ul>
</dd>
<dd>
Distinction from CICM XML:<ul>
<li>Both CICM and Aaru JSON blocks can coexist in the same image</li>
<li>CICM XML follows the Canary Islands Computer Museum schema</li>
<li>Aaru JSON follows the Aaru-specific metadata schema</li>
<li>Different tools may prefer one format over the other</li>
</ul>
</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Memory allocated for ctx-&gt;jsonBlock persists for the context lifetime and must be freed during context cleanup (aaruf_close).</dd>
<dd>
This function does not validate JSON syntax or schema. Corrupted JSON data will be loaded successfully and errors will only be detected when attempting to parse.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="structAaruMetadataJsonBlockHeader.html" title="Header for an Aaru metadata JSON block (identifier == BlockType::AaruMetadataJsonBlock).">AaruMetadataJsonBlockHeader</a> for the on-disk structure definition. </dd>
<dd>
<a class="el" href="#a5e0397faed8aea27c5a6a3881875de54" title="Processes a CICM XML metadata block from the image stream.">process_cicm_block()</a> for processing CICM XML metadata blocks. </dd>
<dd>
<a class="el" href="decls_8h.html#afc4932cdc795ffb2ef3a33d5b8c57656" title="Opens an existing AaruFormat image file.">aaruf_open()</a> for the overall image opening sequence. </dd></dl>
<p class="definition">Definition at line <a class="el" href="blocks_2metadata_8c_source.html#l00470">470</a> of file <a class="el" href="blocks_2metadata_8c_source.html">metadata.c</a>.</p>
<p class="reference">References <a class="el" href="enums_8h_source.html#l00159">AaruMetadataJsonBlock</a>, <a class="el" href="log_8h_source.html#l00040">FATAL</a>, <a class="el" href="metadata_8h_source.html#l00121">AaruMetadataJsonBlockHeader::identifier</a>, <a class="el" href="context_8h_source.html#l00260">aaruformat_context::image_info</a>, <a class="el" href="aaru_8h_source.html#l00873">ImageInfo::ImageSize</a>, <a class="el" href="context_8h_source.html#l00176">aaruformat_context::imageStream</a>, <a class="el" href="context_8h_source.html#l00215">aaruformat_context::json_block</a>, <a class="el" href="context_8h_source.html#l00233">aaruformat_context::json_block_header</a>, <a class="el" href="metadata_8h_source.html#l00122">AaruMetadataJsonBlockHeader::length</a>, <a class="el" href="index_8h_source.html#l00112">IndexEntry::offset</a>, and <a class="el" href="log_8h_source.html#l00025">TRACE</a>.</p>
<p class="reference">Referenced by <a class="el" href="open_8c_source.html#l00125">aaruf_open()</a>.</p>
</div>
</div>
<a id="a5e0397faed8aea27c5a6a3881875de54" name="a5e0397faed8aea27c5a6a3881875de54"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5e0397faed8aea27c5a6a3881875de54">&#9670;&#160;</a></span>process_cicm_block()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void process_cicm_block </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structaaruformat__context.html">aaruformat_context</a> *</td> <td class="paramname"><span class="paramname"><em>ctx</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structIndexEntry.html">IndexEntry</a> *</td> <td class="paramname"><span class="paramname"><em>entry</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Processes a CICM XML metadata block from the image stream. </p>
<p>Reads a CICM XML metadata block from the image and updates the context with its contents.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>Pointer to the aaruformat context. </td></tr>
<tr><td class="paramname">entry</td><td>Pointer to the index entry describing the CICM block. </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="blocks_2metadata_8c_source.html#l00306">306</a> of file <a class="el" href="blocks_2metadata_8c_source.html">metadata.c</a>.</p>
<p class="reference">References <a class="el" href="context_8h_source.html#l00214">aaruformat_context::cicm_block</a>, <a class="el" href="context_8h_source.html#l00231">aaruformat_context::cicm_block_header</a>, <a class="el" href="enums_8h_source.html#l00151">CicmBlock</a>, <a class="el" href="log_8h_source.html#l00040">FATAL</a>, <a class="el" href="metadata_8h_source.html#l00109">CicmMetadataBlock::identifier</a>, <a class="el" href="context_8h_source.html#l00260">aaruformat_context::image_info</a>, <a class="el" href="aaru_8h_source.html#l00873">ImageInfo::ImageSize</a>, <a class="el" href="context_8h_source.html#l00176">aaruformat_context::imageStream</a>, <a class="el" href="metadata_8h_source.html#l00110">CicmMetadataBlock::length</a>, <a class="el" href="index_8h_source.html#l00112">IndexEntry::offset</a>, and <a class="el" href="log_8h_source.html#l00025">TRACE</a>.</p>
<p class="reference">Referenced by <a class="el" href="open_8c_source.html#l00125">aaruf_open()</a>.</p>
</div>
</div>
<a id="a81d410de6727d95a85b827067e1a8bc6" name="a81d410de6727d95a85b827067e1a8bc6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a81d410de6727d95a85b827067e1a8bc6">&#9670;&#160;</a></span>process_geometry_block()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void process_geometry_block </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structaaruformat__context.html">aaruformat_context</a> *</td> <td class="paramname"><span class="paramname"><em>ctx</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structIndexEntry.html">IndexEntry</a> *</td> <td class="paramname"><span class="paramname"><em>entry</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Processes a logical geometry block from the image stream. </p>
<p>Reads a logical geometry block from the image and updates the context with its contents.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>Pointer to the aaruformat context. </td></tr>
<tr><td class="paramname">entry</td><td>Pointer to the index entry describing the geometry block. </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="blocks_2metadata_8c_source.html#l00246">246</a> of file <a class="el" href="blocks_2metadata_8c_source.html">metadata.c</a>.</p>
<p class="reference">References <a class="el" href="context_8h_source.html#l00234">aaruformat_context::cylinders</a>, <a class="el" href="data_8h_source.html#l00093">GeometryBlockHeader::cylinders</a>, <a class="el" href="log_8h_source.html#l00040">FATAL</a>, <a class="el" href="context_8h_source.html#l00229">aaruformat_context::geometry_block</a>, <a class="el" href="enums_8h_source.html#l00148">GeometryBlock</a>, <a class="el" href="context_8h_source.html#l00235">aaruformat_context::heads</a>, <a class="el" href="data_8h_source.html#l00094">GeometryBlockHeader::heads</a>, <a class="el" href="data_8h_source.html#l00092">GeometryBlockHeader::identifier</a>, <a class="el" href="context_8h_source.html#l00260">aaruformat_context::image_info</a>, <a class="el" href="aaru_8h_source.html#l00873">ImageInfo::ImageSize</a>, <a class="el" href="context_8h_source.html#l00176">aaruformat_context::imageStream</a>, <a class="el" href="index_8h_source.html#l00112">IndexEntry::offset</a>, <a class="el" href="context_8h_source.html#l00236">aaruformat_context::sectors_per_track</a>, <a class="el" href="data_8h_source.html#l00095">GeometryBlockHeader::sectorsPerTrack</a>, and <a class="el" href="log_8h_source.html#l00025">TRACE</a>.</p>
<p class="reference">Referenced by <a class="el" href="open_8c_source.html#l00125">aaruf_open()</a>.</p>
</div>
</div>
<a id="a43974d4c183240be30d49ff09ef7b8c2" name="a43974d4c183240be30d49ff09ef7b8c2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a43974d4c183240be30d49ff09ef7b8c2">&#9670;&#160;</a></span>process_metadata_block()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void process_metadata_block </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structaaruformat__context.html">aaruformat_context</a> *</td> <td class="paramname"><span class="paramname"><em>ctx</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="structIndexEntry.html">IndexEntry</a> *</td> <td class="paramname"><span class="paramname"><em>entry</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Processes a metadata block from the image stream. </p>
<p>Reads a metadata block from the image and updates the context with its contents.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>Pointer to the aaruformat context. </td></tr>
<tr><td class="paramname">entry</td><td>Pointer to the index entry describing the metadata block. </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="blocks_2metadata_8c_source.html#l00035">35</a> of file <a class="el" href="blocks_2metadata_8c_source.html">metadata.c</a>.</p>
<p class="reference">References <a class="el" href="metadata_8h_source.html#l00071">MetadataBlockHeader::blockSize</a>, <a class="el" href="index_8h_source.html#l00110">IndexEntry::blockType</a>, <a class="el" href="context_8h_source.html#l00218">aaruformat_context::comments</a>, <a class="el" href="metadata_8h_source.html#l00078">MetadataBlockHeader::commentsLength</a>, <a class="el" href="metadata_8h_source.html#l00077">MetadataBlockHeader::commentsOffset</a>, <a class="el" href="context_8h_source.html#l00216">aaruformat_context::creator</a>, <a class="el" href="metadata_8h_source.html#l00076">MetadataBlockHeader::creatorLength</a>, <a class="el" href="metadata_8h_source.html#l00075">MetadataBlockHeader::creatorOffset</a>, <a class="el" href="context_8h_source.html#l00228">aaruformat_context::drive_firmware_revision</a>, <a class="el" href="context_8h_source.html#l00224">aaruformat_context::drive_manufacturer</a>, <a class="el" href="context_8h_source.html#l00225">aaruformat_context::drive_model</a>, <a class="el" href="context_8h_source.html#l00226">aaruformat_context::drive_serial_number</a>, <a class="el" href="metadata_8h_source.html#l00098">MetadataBlockHeader::driveFirmwareRevisionLength</a>, <a class="el" href="metadata_8h_source.html#l00097">MetadataBlockHeader::driveFirmwareRevisionOffset</a>, <a class="el" href="metadata_8h_source.html#l00092">MetadataBlockHeader::driveManufacturerLength</a>, <a class="el" href="metadata_8h_source.html#l00091">MetadataBlockHeader::driveManufacturerOffset</a>, <a class="el" href="metadata_8h_source.html#l00094">MetadataBlockHeader::driveModelLength</a>, <a class="el" href="metadata_8h_source.html#l00093">MetadataBlockHeader::driveModelOffset</a>, <a class="el" href="metadata_8h_source.html#l00096">MetadataBlockHeader::driveSerialNumberLength</a>, <a class="el" href="metadata_8h_source.html#l00095">MetadataBlockHeader::driveSerialNumberOffset</a>, <a class="el" href="log_8h_source.html#l00040">FATAL</a>, <a class="el" href="metadata_8h_source.html#l00070">MetadataBlockHeader::identifier</a>, <a class="el" href="context_8h_source.html#l00260">aaruformat_context::image_info</a>, <a class="el" href="aaru_8h_source.html#l00873">ImageInfo::ImageSize</a>, <a class="el" href="context_8h_source.html#l00176">aaruformat_context::imageStream</a>, <a class="el" href="context_8h_source.html#l00239">aaruformat_context::last_media_sequence</a>, <a class="el" href="metadata_8h_source.html#l00074">MetadataBlockHeader::lastMediaSequence</a>, <a class="el" href="context_8h_source.html#l00222">aaruformat_context::media_barcode</a>, <a class="el" href="context_8h_source.html#l00219">aaruformat_context::media_manufacturer</a>, <a class="el" href="context_8h_source.html#l00220">aaruformat_context::media_model</a>, <a class="el" href="context_8h_source.html#l00223">aaruformat_context::media_part_number</a>, <a class="el" href="context_8h_source.html#l00238">aaruformat_context::media_sequence</a>, <a class="el" href="context_8h_source.html#l00221">aaruformat_context::media_serial_number</a>, <a class="el" href="context_8h_source.html#l00217">aaruformat_context::media_title</a>, <a class="el" href="metadata_8h_source.html#l00088">MetadataBlockHeader::mediaBarcodeLength</a>, <a class="el" href="metadata_8h_source.html#l00087">MetadataBlockHeader::mediaBarcodeOffset</a>, <a class="el" href="metadata_8h_source.html#l00082">MetadataBlockHeader::mediaManufacturerLength</a>, <a class="el" href="metadata_8h_source.html#l00081">MetadataBlockHeader::mediaManufacturerOffset</a>, <a class="el" href="metadata_8h_source.html#l00084">MetadataBlockHeader::mediaModelLength</a>, <a class="el" href="metadata_8h_source.html#l00083">MetadataBlockHeader::mediaModelOffset</a>, <a class="el" href="metadata_8h_source.html#l00090">MetadataBlockHeader::mediaPartNumberLength</a>, <a class="el" href="metadata_8h_source.html#l00089">MetadataBlockHeader::mediaPartNumberOffset</a>, <a class="el" href="metadata_8h_source.html#l00072">MetadataBlockHeader::mediaSequence</a>, <a class="el" href="metadata_8h_source.html#l00086">MetadataB
<p class="reference">Referenced by <a class="el" href="open_8c_source.html#l00125">aaruf_open()</a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a href="dir_b2e0cd1ddd0a904cb261e9b68779deb4.html">blocks</a></li><li class="navelem"><a href="blocks_2metadata_8c.html">metadata.c</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
</ul>
</div>
</body>
</html>