code wiki / _hdl_build / nx_manga_get.nx

nx_manga_get.nx

buildroot/runtime/_hdl_build/nx_manga_get.nx

19197 B335 linesdepth 21pulls 155 transitivereach 3 importersview sourcekind tooltopic manga
docsdependenciesstructsconstsfunctions

about

nx_manga_get.nx -- R2a of the native manga DOWNLOAD ladder (census row URL): a generic gallery/chapter PAGE URL -> ordered page images in a book dir + cbx.json, sovereign end-to-end (no python/gallery-dl/curl). Composes the PROVEN organs: nx_https_fetch_follow (own TLS-1.3 GET) + nx_html_extract_imgs (extract every <img src>, RESOLVED relative->absolute via nx_url_resolve) + nx_reader_library (land in the downloader's PRIVATE area). FORK-PER-IMAGE so each image fetch's TLS mmaps die with the child (the researcher's proven per-fetch-process pattern) -> a 200-page gallery never leaks. Writes reader/u_<ukey>/<slug>/page000.<ext>... + cbx.json (the reader/zoom viewer's manifest), then rl_add_personal(ukey, slug, title). The daemon calls this (fork) on an "Add manga" POST; also a CLI. LEGAL POSTURE: general capability; smoke on public-domain/legal pages; the operator points it where they like. license_tier: ORIGINAL

dependencies 8 imports · 2 importers

nx_syscalls.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_img_harvest.nx nx_manga_sites.nx nx_reader_library.nx nx_img_dims.nx nx_manga_get.nx nx_manga_get_gate.nx nx_media_import.nx

imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_img_harvest.nxnx_manga_sites.nxnx_reader_library.nxnx_img_dims.nx

imported by: nx_manga_get_gate.nxnx_media_import.nx

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

main mg_puts sys_write sys_exit nx_trust_store_load_from_c sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_nss_certdata_parse sys_mmap ↻ _pat_class_cert _pat_value_octal _pat_end _find_newline _starts_with _parse_octal_line sys_mmap ↻ _is_space _decode_octal_escape _is_octal trust_store_alloc sys_mmap ↻ nx_x509_trust_store_load sys_mmap ↻ x509_parse sys_mmap ↻ asn1_cursor_init asn1_expect_tag sys_mmap ↻ asn1_read_tlv_header asn1_read_tag asn1_read_length asn1_read_length ↻ x509_read_tlv sys_mmap ↻ asn1_expect_tag ↻

structs

none

consts

18const MG_MAGIC_2048: i64 = 2048
19const MG_MAGIC_65536: i64 = 65536
20const MG_MAGIC_2166136261: i64 = 2166136261
21const MG_MAGIC_16777619: i64 = 16777619
22const MG_MAGIC_1048576: i64 = 1048576
23const MG_MAGIC_4096: i64 = 4096
24const MG_MAGIC_4095: i64 = 4095
25const MG_MAGIC_4194304: i64 = 4194304
27const MG_MAX_IMGS: i64 = 512
28const MG_IMG_CAP: i64 = 16777216 // 16MB per image cap (fetch buffer, per child)
29const MG_HTML_CAP: i64 = 8388608 // 8MB page HTML cap
30const MG_MIN_BYTES: i64 = 1024 // floor: below this = tracker/spacer/blank, never a real manga page
31const MG_MIN_EDGE: i64 = 100 // reject nav icons/spacers/tracking-pixels: long edge < 100px is never content (real pages/photos are bigger)

functions

33func mg_puts(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 2: mg_gallery_to_pagesmain calls 1: sys_write
34func mg_putn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let d:*u8=sys_mmap(24); var k:i64=0; while m>0{d[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=k-1; while i>=0{let o:*u8=sys_mmap(1);o[0]=d[i];sys_write(1,o,1);i=i-1} return 0 }
35func mg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
36func mg_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 }
37func mg_num(dst: *u8, o: i64, v: i64) -> i64 { let t: *u8=sys_mmap(24); var m: i64=v; 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 w: i64=o; var i: i64=0; while i<k{dst[w]=t[k-1-i]; w=w+1; i=i+1} return w }
called by 2: mg_write_cbxmg_write_dl calls 1: sys_mmap
40func mg_page_name(idx: i64, ext: *u8, out: *u8) -> i64
50func mg_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]==(0 as u8){return 1} return 0 }
called by 1: mg_ext_ok
51func mg_ext_ok(e: *u8) -> i64
called by 1: mg_ext_from_url calls 1: mg_streq
60func mg_default_jpg(out: *u8) -> i64 { out[0]=46 as u8; out[1]=106 as u8; out[2]=112 as u8; out[3]=103 as u8; out[4]=0 as u8; return 4 }
called by 1: mg_ext_from_url
62func mg_ext_from_url(url: *u8, out: *u8) -> i64
85func mg_img_magic_ok(b: *u8, n: i64) -> i64
99func mg_img_complete(b: *u8, n: i64) -> i64
called by 2: mg_fetch_onemain
129func mg_fetch_one(url: *u8, store: *TrustStore, dir: *u8, pagename: *u8) -> i64
152func mg_file_fp(path: *u8) -> i64
174func mg_write_cbx(dir: *u8, title: *u8, npages: i64, exts: *i64) -> i64
205func mg_write_dl(dir: *u8, total: i64, done: i64) -> i64
314func main(argc: i64, argv: *i64) -> i64