nx_png_chunks.nx
buildroot/runtime/nx_png_chunks.nx
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
imports: nx_syscalls.nx
imported by: nx_card_compile.nxnx_card_import_gate.nx
structs
| none |
consts
| 10 | const PNG_SIG_LEN: i64 = 8 |
| 11 | const PNG_CHUNK_HDR_LEN: i64 = 8 |
| 12 | const PNG_CRC_LEN: i64 = 4 |
| 13 | const PNG_TYPE_LEN: i64 = 4 |
| 14 | const PNG_BYTE_MASK: i64 = 255 |
| 15 | const PNG_BITS_PER_BYTE: i64 = 8 |
| 16 | const PNG_CH_NUL: i64 = 0 |
| 18 | const PNG_FOUND: i64 = 1 |
| 19 | const PNG_ABSENT: i64 = 0 |
| 20 | const PNG_NOT_PNG: i64 = 0 - 1 |
| 21 | const PNG_MALFORMED: i64 = 0 - 2 |
functions
| 23 | func 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 |
| 24 | func png_be32(b: *u8, p: i64) -> i64 |
| 31 | func png_is(buf: *u8, n: i64) -> i64 |
| 44 | func png_type_is(buf: *u8, p: i64, t: *u8) -> i64 |
| 50 | func png_chunk_count(buf: *u8, n: i64) -> i64 |
| 69 | func png_find_text(buf: *u8, n: i64, keyword: *u8, out: *i64) -> i64 |
| 103 | func png_put_chunk(buf: *u8, off: i64, t: *u8, data: *u8, dlen: i64) -> i64 called by 1: cg_build_png |
| 119 | func png_put_sig(buf: *u8) -> i64 called by 1: cg_build_png |