code wiki / (root) / nx_sevenz_lib.nx

nx_sevenz_lib.nx

buildroot/runtime/nx_sevenz_lib.nx

40454 B835 linesdepth 7pulls 10 transitivereach 11 importersview sourcekind librarytopic sevenz
docsdependenciesstructsconstsfunctions

about

nx_sevenz_lib.nx -- THE 7z CONTAINER READER (/compare/modding MD29 sz_walk, 2026-09-06), written from the mirrored format document (knowledge/fetched/cmp_modding_7zFormat.txt, pin 395ad336) and method table (cmp_modding_7z_Methods.txt, pin 418d0748), both READ first. It composes the incumbents and adds no second ruler: nx_lzma_lib (LZMA and LZMA2 coders, the x86 BCJ branch converter), nxzip_crc32 from nx_zip (the reflected CRC-32 the 7z digests use), and nx_bundle_ingest_lib's record table, so a 7z walks to the SAME typed rows the zip walker fills and the texture binder and the partition run unchanged over both. WHAT IT READS: the 32-byte signature header (its own CRC verified), the next header (CRC verified), an ENCODED header (decoded through the folder that carries it, then parsed as the plain header), pack info, coders info (folders with their coder ids, properties, bind pairs and unpack sizes), substreams info (sizes and digests), and files info (empty-stream and empty-file bit vectors, UTF-16LE names converted to UTF-8). Directories are counted and left out of the table; empty files are rows with no bytes. Every member's bytes are CRC-checked against the archive's OWN digest -- the container is the oracle for the decoder. Coders: Copy (00), LZMA (03 01 01), LZMA2 (21), and the two-coder folder 7-Zip writes for executables, x86 BCJ (03 03 01 03) over LZMA or LZMA2 with the one bind pair in0 <- out1; any other coder or chain is REPORTED unsupported by name on every member it holds, never guessed at. Solid folders decode once into one buffer sized from the folder's declared unpack size and every member is a window into it. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 4 importers

nx_syscalls.nx nx_lzma_lib.nx nx_bundle_ingest_lib.nx nx_sevenz_lib.nx nx_bundle_ingest.nx nx_pushback_lib.nx nx_sevenz.nx nx_sevenz_gate.nx

imports: nx_syscalls.nxnx_lzma_lib.nxnx_bundle_ingest_lib.nx

imported by: nx_bundle_ingest.nxnx_pushback_lib.nxnx_sevenz.nxnx_sevenz_gate.nx

structs

none

consts

21const SZ_SIG_LEN: i64 = 32
22const SZ_START_HDR_OFF: i64 = 12
23const SZ_START_HDR_LEN: i64 = 20
24const SZ_NID_END: i64 = 0
25const SZ_NID_HEADER: i64 = 1
26const SZ_NID_ARCHIVE_PROPS: i64 = 2
27const SZ_NID_ADDITIONAL: i64 = 3
28const SZ_NID_MAIN: i64 = 4
29const SZ_NID_FILES: i64 = 5
30const SZ_NID_PACK: i64 = 6
31const SZ_NID_UNPACK: i64 = 7
32const SZ_NID_SUBSTREAMS: i64 = 8
33const SZ_NID_SIZE: i64 = 9
34const SZ_NID_CRC: i64 = 10
35const SZ_NID_FOLDER: i64 = 11
36const SZ_NID_CODERS_UNPACK: i64 = 12
37const SZ_NID_NUM_UNPACK: i64 = 13
38const SZ_NID_EMPTY_STREAM: i64 = 14
39const SZ_NID_EMPTY_FILE: i64 = 15
40const SZ_NID_NAME: i64 = 17
41const SZ_NID_ENCODED: i64 = 23
42const SZ_CODER_COPY: i64 = 0
43const SZ_CODER_LZMA: i64 = 196865 // 03 01 01 = 3*65536 + 1*256 + 1 (the first cut wrote 197121 = 03 02 01 and read every LZMA header as unsupported)
44const SZ_CODER_LZMA2: i64 = 33 // 21
45const SZ_CODER_BCJ_X86: i64 = 50528515 // 03 03 01 03 = 3*16777216 + 3*65536 + 256 + 3; as a CLASS it means BCJ x86 over an LZMA-family second coder
46const SZ_CODER_UNSUPPORTED: i64 = 0 - 1
47const SZ_CODER_CHAIN: i64 = 0 - 2
48const SZ_MAX_FOLDERS_PER_BYTES: i64 = 8 // derived caps: a folder or a file costs at least this many header bytes
49const SZ_MAX_FILES_PER_BYTES: i64 = 2
51const SZ_OK: i64 = 0
52const SZ_ERR_NOT_7Z: i64 = 0 - 1
53const SZ_ERR_START_CRC: i64 = 0 - 2
54const SZ_ERR_TRUNCATED: i64 = 0 - 3
55const SZ_ERR_HEADER_CRC: i64 = 0 - 4
56const SZ_ERR_HEADER_CODER: i64 = 0 - 5
57const SZ_ERR_SYNTAX: i64 = 0 - 6
58const SZ_ERR_EXTERNAL: i64 = 0 - 7
59const SZ_ERR_HEADER_DECODE: i64 = 0 - 8
61const SZ_M_ERR: i64 = 0
62const SZ_M_NPACK: i64 = 1
63const SZ_M_PACKPOS: i64 = 2
64const SZ_M_PACKSIZES: i64 = 3
65const SZ_M_NFOLD: i64 = 4
66const SZ_M_FCODER: i64 = 5
67const SZ_M_FPROPS_OFF: i64 = 6
68const SZ_M_FPROPS_LEN: i64 = 7
69const SZ_M_FUNPACK: i64 = 8
70const SZ_M_FCRC: i64 = 9
71const SZ_M_FCRCDEF: i64 = 10
72const SZ_M_FNSUB: i64 = 11
73const SZ_M_FPACKIDX: i64 = 12
74const SZ_M_FNCODERS: i64 = 13
75const SZ_M_NSUB: i64 = 14
76const SZ_M_SUBSIZE: i64 = 15
77const SZ_M_SUBCRC: i64 = 16
78const SZ_M_SUBCRCDEF: i64 = 17
79const SZ_M_NFILES: i64 = 18
80const SZ_M_FILE_EMPTYSTREAM: i64 = 19
81const SZ_M_FILE_EMPTYFILE: i64 = 20
82const SZ_M_NAMES: i64 = 21
83const SZ_M_NAMEOFF: i64 = 22
84const SZ_M_NAMELEN: i64 = 23
85const SZ_M_ENCODED: i64 = 24
86const SZ_M_DIRS: i64 = 25
87const SZ_M_EMPTYFILES: i64 = 26
88const SZ_M_DATAFILES: i64 = 27
89const SZ_M_HDRBUF: i64 = 28
90const SZ_M_HDRLEN: i64 = 29
91const SZ_M_BASE: i64 = 30
92const SZ_M_NEMPTYSTREAMS: i64 = 31
93const SZ_M_HDR_CODERID: i64 = 32
94const SZ_M_HDR_NCODERS: i64 = 33
95const SZ_M_FCODER0RAW: i64 = 34
96const SZ_M_FCODER1RAW: i64 = 35
97const SZ_M_FPROPS2_OFF: i64 = 36
98const SZ_M_FPROPS2_LEN: i64 = 37
99const SZ_M_FUNPACK2: i64 = 38
100const SZ_M_FBIND_IN: i64 = 39
101const SZ_M_FBIND_OUT: i64 = 40
102const SZ_M_N: i64 = 48

functions

104func sz_is_7z(b: *u8, n: i64) -> i64
called by 3: mainmainsz_parse
114func sz_u32(b: *u8, o: i64) -> i64 { return ((b[o] & 0xff) as i64) | (((b[o + 1] & 0xff) as i64) * 256) | (((b[o + 2] & 0xff) as i64) * 65536) | (((b[o + 3] & 0xff) as i64) * 16777216) }
115func sz_u64(b: *u8, o: i64) -> i64 { return sz_u32(b, o) + sz_u32(b, o + 4) * 4294967296 }
called by 1: sz_parse calls 1: sz_u32
117func sz_rd8(b: *u8, p: *i64, end: i64, m: *i64) -> i64
124func sz_num(b: *u8, p: *i64, end: i64, m: *i64) -> i64
137func sz_skip(p: *i64, end: i64, n: i64, m: *i64) -> i64
called by 1: sz_header
143func sz_bit(v: *u8, i: i64) -> i64 { return (((v[i / 8] & 0xff) as i64) / lz_pow2(7 - (i % 8))) & 1 }
called by 2: sz_digestssz_header calls 1: lz_pow2
145func sz_digests(b: *u8, p: *i64, end: i64, m: *i64, n: i64, def: *i64, crc: *i64) -> i64
called by 1: sz_streams_info calls 3: sz_rd8sz_bitsz_u32
162func sz_streams_info(b: *u8, p: *i64, end: i64, m: *i64) -> i64
393func sz_utf16_to_utf8(b: *u8, off: i64, units: i64, out: *u8, o0: i64, cap: i64) -> i64
called by 1: sz_header
411func sz_header(b: *u8, p: *i64, end: i64, m: *i64) -> i64
489func sz_decode_folder(b: *u8, n: i64, m: *i64, f: i64, rc: *i64) -> *u8
547func sz_parse(b: *u8, n: i64, m: *i64) -> i64
609func sz_err_name(e: i64) -> *u8
called by 2: mainszc_walk
620func sz_coder_name(c: i64) -> *u8
629func sz_count(b: *u8, n: i64) -> i64
639func sz_walk(b: *u8, n: i64, tbl: *i64, maxm: i64, names: *u8, ncap: i64, st: *i64) -> i64
739func sz_put8(o: *u8, p: *i64, v: i64) -> i64 { o[p[0]] = (v & 255) as u8; p[0] = p[0] + 1; return 1 }
740func sz_put32(o: *u8, p: *i64, v: i64) -> i64 { var i: i64 = 0; var x: i64 = v; while i < 4 { sz_put8(o, p, x & 255); x = x / 256; i = i + 1 } return 4 }
called by 1: sz_write_copy calls 1: sz_put8
741func sz_put64(o: *u8, p: *i64, v: i64) -> i64 { var i: i64 = 0; var x: i64 = v; while i < 8 { sz_put8(o, p, x & 255); x = x / 256; i = i + 1 } return 8 }
called by 2: sz_putnumsz_write_copy calls 1: sz_put8
743func sz_putnum(o: *u8, p: *i64, v: i64) -> i64
764func sz_write_copy(names: *i64, datas: *i64, lens: *i64, nfiles: i64, out: *u8, outcap: i64) -> i64