code wiki / _hdl_build / nx_manga_shelf_lib.nx
nx_manga_shelf_lib.nx
buildroot/runtime/_hdl_build/nx_manga_shelf_lib.nx
about
nx_manga_shelf_lib.nx -- LOCAL comics/manga SHELF catalog lib for the media server (/api/shelf).
The operator's "browse before download" complaint, LOCAL half: browse what we ALREADY OWN -- series grid
-> volume list -> the guided zoom reader. ZERO network: everything derives from disk truth.
A book joins the shelf iff (a) it is a comic archive (cbz/cbr/cb7), or (b) its calibre author dir is
listed in shelf_authors.txt (operator-editable data: manga/comics wearing epub/pdf clothes), or (c) its
extracted reader slug already carries cbx.json (PROVEN comic -- it opened in the zoom reader before).
Series grouping is data-driven: shelf_markers.txt volume markers (case-insensitive; the EARLIEST hit cuts
the title into series name + volume number) plus a same-author first-token fallback for mashed one-shot
dumps ("swordsofsorrow vampirella ..."). Multi-format calibre dirs dedupe to ONE volume (cbz > epub >
kindle > pdf). Volumes open through the EXISTING /api/open extract-on-demand chain -> /library/zoom;
covers ride the EXISTING /api/cover. Pure lib (no socket, no fork) so nx_manga_shelf_gate proves the
grouping in isolation -- the nx_galx_manga/nx_media_cover_lib lib+gate split. license_tier: ORIGINAL
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_manga_shelf_gate.nxnx_manga_shelf_scan.nxnx_media_server.nx
structs
| none |
consts
| 14 | const MSL_MAGIC_1469598103: i64 = 1469598103 |
| 15 | const MSL_MAGIC_72057594037927931: i64 = 72057594037927931 |
| 16 | const MSL_MAGIC_1024: i64 = 1024 |
| 17 | const MSL_MAGIC_2048: i64 = 2048 |
| 18 | const MSL_MAGIC_8192: i64 = 8192 |
| 20 | const MSL_IDX: *u8 = "knowledge/staging/media/idx_book.wsl" |
| 21 | const MSL_AUTHORS: *u8 = "knowledge/staging/media/shelf_authors.txt" |
| 22 | const MSL_MARKERS: *u8 = "knowledge/staging/media/shelf_markers.txt" |
| 23 | const MSL_READER: *u8 = "knowledge/staging/media/reader/" |
| 24 | const MSL_MAXVOL: i64 = 4096 |
| 25 | const MSL_MAXSER: i64 = 1024 |
functions
| 28 | func msl_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 29 | func msl_cats(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 } |
| 30 | func msl_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 40 | func msl_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } |
| 41 | func msl_hexc(d: i64) -> i64 { if d < 10 { return 48 + d } return 87 + d } called by 1: msl_pathslug |
| 45 | func msl_pathslug(p: *u8, ls: i64, le: i64, out: *u8) -> i64 |
| 60 | func msl_probe_cbx(p: *u8, ls: i64, le: i64, sc: *u8) -> i64 |
| 76 | func msl_ext_rank(p: *u8, ls: i64, le: i64) -> i64 |
| 95 | func msl_strip_id(p: *u8, ls: i64, le: i64) -> i64 called by 1: msl_add_line |
| 116 | func msl_ci_eq(a: *u8, als: i64, ale: i64, b: *u8, bls: i64, ble: i64) -> i64 |
| 125 | func msl_ci_cmp(a: *u8, als: i64, ale: i64, b: *u8, bls: i64, ble: i64) -> i64 |
| 144 | func msl_ci_find(hay: *u8, ls: i64, le: i64, needle: *u8) -> i64 |
| 159 | func msl_author_listed(a: *u8, ls: i64, le: i64, ab: *u8, an: i64) -> i64 called by 1: msl_add_line |
| 186 | func msl_marker_cut(t: *u8, ls: i64, le: i64, mk: *u8, mkn: i64, numout: *i64, nomark: *i64, one: *u8) -> i64 |
| 258 | func msl_jesc(dst: *u8, off0: i64, s: *u8, ls: i64, le: i64) -> i64 called by 1: msl_emit_series |
| 277 | func msl_ctx_new() -> *i64 |
| 290 | func msl_add_line(ctx: *i64, ls: i64, le: i64) -> i64 called by 1: msl_scan calls 6: msl_ext_rankmsl_ci_eqmsl_probe_cbxmsl_author_listedmsl_strip_idmsl_marker_cut |
| 374 | func msl_scan(ctx: *i64) -> i64 |
| 392 | func msl_tok_end(buf: *u8, ts: i64, te: i64) -> i64 called by 1: msl_firsttok |
| 400 | func msl_firsttok(ctx: *i64) -> i64 |
| 450 | func msl_group(ctx: *i64) -> i64 |
| 488 | func msl_sort_series(ctx: *i64, sidx: *i64) -> i64 |
| 515 | func msl_vol_before(ctx: *i64, a: i64, b: i64) -> i64 |
| 527 | func msl_series_vols(ctx: *i64, sid: i64, vids: *i64) -> i64 |
| 550 | func msl_emit_series(ctx: *i64, out: *u8, w0: i64, cap: i64, sid: i64, vids: *i64) -> i64 |
| 592 | func msl_emit(ctx: *i64, out: *u8, cap: i64) -> i64 |
| 617 | func msl_shelf_json(out: *u8, cap: i64) -> i64 called by 3: mainmainms_handle calls 8: msl_ctx_newsys_mmapsys_read_filemsl_catsmsl_scanmsl_firsttok+2 |