code wiki / _hdl_build / nx_media_cover_lib.nx

nx_media_cover_lib.nx

buildroot/runtime/_hdl_build/nx_media_cover_lib.nx

11302 B225 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind librarytopic media
docsdependenciesstructsconstsfunctions

about

nx_media_cover_lib.nx -- SOVEREIGN book-cover resolution for the media server (/api/cover). A book's embedded cover is extracted to knowledge/staging/media/reader/<slug>/<coverfile> as a side effect of decoding (nx_epub_book / nx_mobi_book / nx_kf8_book all write the image + record "cover":"<file>" in book.json). This lib maps a NAS book path -> that on-disk cover image, extracting on cache-miss, so the library grid can show real covers WITHOUT generating or downloading anything (operator: no internet, extract embedded only). Shared by nx_media_server (serve) and nx_media_cover_gate (test) so the slug + resolution logic has ONE definition. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_media_cover_lib.nx nx_media_cover_gate.nx nx_media_server.nx

imports: nx_syscalls.nx

imported by: nx_media_cover_gate.nxnx_media_server.nx

structs

none

consts

9const MC_MAGIC_1469598103: i64 = 1469598103
10const MC_MAGIC_72057594037927931: i64 = 72057594037927931
11const MC_MAGIC_262144: i64 = 262144
13const MC_READER_ROOT: *u8 = "knowledge/staging/media/reader/"

functions

15func mc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
16func mc_app(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { dst[off+i] = src[i]; i = i + 1 } return off + n }
called by 1: mc_apps
17func mc_apps(dst: *u8, off: i64, s: *u8) -> i64 { return mc_app(dst, off, s, mc_slen(s)) }
18func mc_dec(dst: *u8, off: i64, v: i64) -> i64 { let t: *u8 = sys_mmap(28); var m: i64=v; var k: i64=0; if m==0 {t[0]=48;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 { dst[off+i]=t[k-1-i]; i=i+1 } return off+k }
called by 1: mc_serve_image calls 1: sys_mmap
19func mc_hexc(d: i64) -> i64 { if d < 10 { return 48 + d } return 87 + d }
called by 1: mc_pathslug
22func mc_contains(hay: *u8, hl: i64, needle: *u8) -> i64
called by 2: mainmc_cover_resolve calls 1: mc_slen
37func mc_pathslug(p: *u8, n: i64, out: *u8) -> i64
called by 1: mc_cover_resolve calls 2: sys_mmapmc_hexc
53func mc_ctype(path: *u8) -> *u8
called by 1: mc_serve_image calls 1: mc_slen
69func mc_cover_field(jbuf: *u8, jn: i64, out: *u8, cap: i64) -> i64
called by 1: mc_try_resolved calls 1: mc_slen
92func mc_extract(path: *u8, pn: i64, slug: *u8) -> i64
121func mc_first_page_field(jbuf: *u8, jn: i64, out: *u8, cap: i64) -> i64
called by 1: mc_try_resolved calls 1: mc_slen
142func mc_try_resolved(slug: *u8, outfull: *u8) -> i64
200func mc_cover_resolve(path: *u8, pn: i64, outfull: *u8, cap: i64) -> i64
211func mc_serve_image(cfd: i64, full: *u8) -> i64