code wiki / _hdl_build / nx_mobi_cover.nx

nx_mobi_cover.nx

buildroot/runtime/_hdl_build/nx_mobi_cover.nx

3821 B52 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind librarytopic mobi
docsdependenciesstructsconstsfunctions

about

nx_mobi_cover.nx -- SHARED embedded-cover extraction for the Kindle decoders (DRY: nx_mobi_book + nx_kf8_book both call it). The cover is read out of the file ITSELF, offline -- never generated, never downloaded (how Calibre does it). Grounded on the registered MOBI spec (mobileread-mobi-spec.ref): the MOBI header's "First Image index" lives at rec0off+108 (record-0-relative); EXTH 201 coveroffset / 202 thumboffset are ADDED to it to find the cover PDB record. Image records are absolute in the PDB, so the SAME record-0 First Image index serves MOBI6 and KF8 (a dual file shares its image records). Detects JPEG/PNG/GIF magic and writes <dir>/cover.<ext>; sets covername (or ""). Returns 1 if a cover was written, else 0. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_itoa_lib.nx nx_mobi_cover.nx nx_kf8_book.nx nx_mobi_book.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nx_kf8_book.nxnx_mobi_book.nx

structs

none

consts

10const K_MAGIC_1024: i64 = 1024

functions

12func mc_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: mc_p
13func mc_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+i }
called by 1: mobi_extract_cover
14func mc_be32(b: *u8, o: i64) -> i64 { return ((b[o] as i64)<<24)|((b[o+1] as i64)<<16)|((b[o+2] as i64)<<8)|(b[o+3] as i64) }
called by 1: mobi_extract_cover
15func mc_p(s: *u8) -> i64 { sys_write(1, s, mc_slen(s)); return 0 }
called by 1: mobi_extract_cover calls 2: sys_writemc_slen
20func mc_pn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: mobi_extract_cover calls 1: nxi_out
22func mobi_extract_cover(z: *u8, zl: i64, numRec: i64, rec0off: i64, coveroff: i64, coverfound: i64, thumboff: i64, thumbfound: i64, dir: *u8, covername: *u8) -> i64