code wiki / _hdl_build / nx_media_cover_lib.nx
nx_media_cover_lib.nx
buildroot/runtime/_hdl_build/nx_media_cover_lib.nx
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
imports: nx_syscalls.nx
imported by: nx_media_cover_gate.nxnx_media_server.nx
structs
| none |
consts
| 9 | const MC_MAGIC_1469598103: i64 = 1469598103 |
| 10 | const MC_MAGIC_72057594037927931: i64 = 72057594037927931 |
| 11 | const MC_MAGIC_262144: i64 = 262144 |
| 13 | const MC_READER_ROOT: *u8 = "knowledge/staging/media/reader/" |
functions
| 15 | func mc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 16 | func 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 |
| 17 | func mc_apps(dst: *u8, off: i64, s: *u8) -> i64 { return mc_app(dst, off, s, mc_slen(s)) } |
| 18 | func 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 } |
| 19 | func mc_hexc(d: i64) -> i64 { if d < 10 { return 48 + d } return 87 + d } called by 1: mc_pathslug |
| 22 | func mc_contains(hay: *u8, hl: i64, needle: *u8) -> i64 |
| 37 | func mc_pathslug(p: *u8, n: i64, out: *u8) -> i64 |
| 53 | func mc_ctype(path: *u8) -> *u8 |
| 69 | func mc_cover_field(jbuf: *u8, jn: i64, out: *u8, cap: i64) -> i64 |
| 92 | func mc_extract(path: *u8, pn: i64, slug: *u8) -> i64 |
| 121 | func mc_first_page_field(jbuf: *u8, jn: i64, out: *u8, cap: i64) -> i64 |
| 142 | func mc_try_resolved(slug: *u8, outfull: *u8) -> i64 called by 1: mc_cover_resolve calls 7: sys_mmapmc_appssys_read_filemc_cover_fieldsys_openat_rdsys_close+1 |
| 200 | func mc_cover_resolve(path: *u8, pn: i64, outfull: *u8, cap: i64) -> i64 |
| 211 | func mc_serve_image(cfd: i64, full: *u8) -> i64 |