code wiki / _hdl_build / nx_media_usable.nx

nx_media_usable.nx

buildroot/runtime/_hdl_build/nx_media_usable.nx

5401 B85 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic media
docsdependenciesstructsconstsfunctions

about

nx_media_usable.nx -- MEDIA USABILITY VERIFIER (operator 2026-07-04: "lots of our systems dont confirm if the media is USABLE -- i have a bunch of broken books like comic books, table headers... keep going but flag this"). Serving != working: this organ opens a comic/image book the way the READER would and proves every page actually DECODES (not just "the file exists"). Given a book dir (reader/<slug>), it reads cbx.json, then for each page: missing on disk / 0-byte / undecodable-bytes (e.g. an HTML error page saved as .jpg) / tiny(junk) -> BROKEN. decodes to real W*H via nx_img_dims (jpeg/png/gif/webp) -> OK. Verdict: OK (all pages decode) | DEGRADED (some broken) | BROKEN (no manifest or 0 usable pages). Read-only; safe on root-owned live book dirs (world-readable). Prints a machine-readable line so the library UI + a census can consume it. This is the books/comics rung of the media-liveness plane; video/movie verifiers are separate rungs. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_img_dims.nx nx_media_usable.nx

imports: nx_syscalls.nxnx_img_dims.nx

imported by: nobody (leaf or entry point)

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

main mw sys_write sys_exit sys_mmap mu_check_book sys_mmap ↻ mu_apps sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close mw ↻ mu_find nx_img_dims _be32 _le16 _le24 _le32b _be16 sys_write ↻ mn sys_mmap ↻ mw ↻ sys_write ↻ mu_verdict_str

structs

none

consts

13const MU_MAGIC_2048: i64 = 2048
14const MU_MAGIC_4096: i64 = 4096
16const MU_MIN_EDGE: i64 = 120 // a real readable page's long edge; below = nav-icon/spacer/broken (matches the manga junk floor's ethos; TODO svc-config)

functions

18func mw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 3: mnmu_check_bookmain calls 1: sys_write
19func mn(v: i64) -> i64 { let b: *u8=sys_mmap(24); var m: i64=v; if m<0{mw("-" as *u8);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 3: sys_mmapmwsys_write
20func mu_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
21func mu_apps(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[o+i]=s[i];i=i+1} return o+i }
called by 1: mu_check_book
23func mu_find(buf: *u8, n: i64, needle: *u8, from: i64) -> i64
called by 1: mu_check_book
31func mu_check_book(dir: *u8, out: *i64, verbose: i64) -> i64
74func mu_verdict_str(v: i64) -> *u8 { if v==2 {return "OK" as *u8} if v==1 {return "DEGRADED" as *u8} return "BROKEN" as *u8 }
called by 1: main
76func main(argc: i64, argv: *i64) -> i64