code wiki / (root) / nx_png_chunks.nx

nx_png_chunks.nx

buildroot/runtime/nx_png_chunks.nx

5795 B123 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind librarytopic png
docsdependenciesstructsconstsfunctions

about

nx_png_chunks.nx -- THE PNG CHUNK WALK (one reader, shared): signature, then [length(4, big-endian)][type(4)][data][crc(4)] until IEND. First consumer is companionchat CC2 (a Tavern V2 character card is base64 JSON inside a tEXt chunk whose keyword is `chara`); gen G15 (workflow ingest from a rival's PNG metadata) names the same walk. EXTRACTED here so there is exactly one chunk walker in the estate -- go_png_dim in the orchestrator reads only the IHDR dimensions and stays as is. DECLARED IMPRECISION: CRCs are not verified. This walker EXTRACTS metadata; it does not validate an image, and a wrong CRC on a text chunk cannot change the bytes it returns. A chunk whose declared length overruns the buffer is MALFORMED and the walk stops there rather than reading past the end. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_png_chunks.nx nx_card_compile.nx nx_card_import_gate.nx

imports: nx_syscalls.nx

imported by: nx_card_compile.nxnx_card_import_gate.nx

structs

none

consts

10const PNG_SIG_LEN: i64 = 8
11const PNG_CHUNK_HDR_LEN: i64 = 8
12const PNG_CRC_LEN: i64 = 4
13const PNG_TYPE_LEN: i64 = 4
14const PNG_BYTE_MASK: i64 = 255
15const PNG_BITS_PER_BYTE: i64 = 8
16const PNG_CH_NUL: i64 = 0
18const PNG_FOUND: i64 = 1
19const PNG_ABSENT: i64 = 0
20const PNG_NOT_PNG: i64 = 0 - 1
21const PNG_MALFORMED: i64 = 0 - 2

functions

23func png_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: png_find_text
24func png_be32(b: *u8, p: i64) -> i64
31func png_is(buf: *u8, n: i64) -> i64
44func png_type_is(buf: *u8, p: i64, t: *u8) -> i64
50func png_chunk_count(buf: *u8, n: i64) -> i64
called by 1: main calls 3: png_ispng_be32png_type_is
69func png_find_text(buf: *u8, n: i64, keyword: *u8, out: *i64) -> i64
103func png_put_chunk(buf: *u8, off: i64, t: *u8, data: *u8, dlen: i64) -> i64
called by 1: cg_build_png
119func png_put_sig(buf: *u8) -> i64
called by 1: cg_build_png