code wiki / _hdl_build / nx_nmz_author.nx

nx_nmz_author.nx

buildroot/runtime/_hdl_build/nx_nmz_author.nx

6688 B78 linesdepth 7pulls 8 transitivereach 0 importersview sourcekind tooltopic nmz
docsdependenciesstructsconstsfunctions

about

nx_nmz_author.nx -- NATIVE authoring into .nmz (operator: "make sure our format isnt just a translation layer but actually a SUPERIOR format on its own if people want to use it natively like ourselves for GENERATED content"). This authors content DIRECTLY into .nmz from raw generated text -- NO lock-in source format involved -- and adds the features that make .nmz superior to EPUB/MOBI/PDF as a native format, especially for generated content: @kind -- the media kind (first-class) @provenance -- FIRST-CLASS generation lineage (generator/method/origin/license). EPUB/MOBI have NO native provenance; for AI/generated content this is the authenticity record. content-addressed CID (sha256, uxf_cid) -- tamper-evident integrity. EPUB/MOBI can't detect a flipped byte. DETERMINISTIC -- same inputs -> byte-identical -> same CID. (zip-based formats vary by timestamp/order.) Also writes reader/<slug>/{book.json,chap0.txt} so native content renders in the SAME zero-JS reader (one pipeline for liberated AND generated). Usage: nx_nmz_author [slug]. expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_canon_bin.nx nx_uxf_cid.nx nx_nmz_author.nx

imports: nx_syscalls.nxnx_canon_bin.nxnx_uxf_cid.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main au_slen sys_mmap cat catn sys_mmap ↻ ensure_dir writef sys_openat_wr sys_write sys_close canon_encode_bin sys_mmap ↻ cb_cmp cb_w32 cb_slen uxf_cid_profiled sys_mmap ↻ sha256_digest sys_mmap ↻ sha256_init sys_mmap ↻ sha256_k sha256_update sha256_compress_ni_blocks blk_set_byte sha256_compress sha256_compress_ni blk_word blk_byte sha256_final blk_set_byte ↻ sha256_compress ↻ uxf_nib_hex au_p sys_write ↻ au_slen ↻ sys_exit au_pn sys_mmap ↻

structs

none

consts

15const K_MAGIC_8192: i64 = 8192
16const K_MAGIC_1024: i64 = 1024
17const K_MAGIC_1048576: i64 = 1048576

functions

19func au_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: au_pmain
20func au_p(s: *u8) -> i64 { sys_write(1, s, au_slen(s)); return 0 }
called by 1: main calls 2: sys_writeau_slen
21func au_pn(v: i64) -> i64 { let b: *u8=sys_mmap(24); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(24); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1}; sys_write(1,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
22func ensure_dir(path: *u8) -> i64 { __syscall(258, 0-100, path, 0x1ed, 0, 0, 0); return 0 }
called by 1: main
23func cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){d[o+i]=s[i];i=i+1} return o+i }
called by 1: main
24func catn(d: *u8, o0: i64, v: i64) -> i64 { var o: i64=o0; var m: i64=v; let t: *u8=sys_mmap(24); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{d[o+i]=t[k-1-i];i=i+1} return o+k }
called by 1: main calls 1: sys_mmap
25func writef(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64=sys_openat_wr(path, 0x1a4); if fd<0 {return 0-1} sys_write(fd, buf, n); sys_close(fd); return 0 }
27func main(argc: i64, argv: *i64) -> i64