code wiki / _hdl_build / nx_media_server.nx

nx_media_server.nx

buildroot/runtime/_hdl_build/nx_media_server.nx

65396 B948 linesdepth 22pulls 183 transitivereach 0 importersview sourcekind servicetopic media
docsdependenciesstructsconstsfunctions

about

nx_media_server.nx -- SOVEREIGN media server (operator 2026-06-13: NO python, Nishi hardware-up). Composes the PROVEN nx_http_server (socket/listen/accept/read/send) -- NO 3rd party. Serves the /media browser + the FULL NAS library paginated (idx_*.wsl) + range-streamed files from the drvfs NAS mounts (/mnt/nas_*). LAN-bound 0.0.0.0 (internal-network; operator-authorized 2026-06-16; PUBLIC-internet deferred to login-for-sites workstream). Fork-per-connection for a concurrent grid. license_tier: ORIGINAL

dependencies 16 imports · 0 importers

nx_syscalls.nx nx_http_server.nx nx_book_search_lib.nx _pdf_reflow_lib.nx nx_site_auth.nx nx_modern_auth_flow.nx nx_base64.nx nx_galx_authz.nx nx_media_cover_lib.nx nx_token_counter.nx nx_media_server.nx

diagram shows first 10 each side; +6 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_http_server.nxnx_book_search_lib.nx_pdf_reflow_lib.nxnx_site_auth.nxnx_modern_auth_flow.nxnx_base64.nxnx_galx_authz.nxnx_media_cover_lib.nxnx_token_counter.nxnx_reader_zoomserve.nxnx_reader_sync.nxnx_reader_library.nxnx_manga_add.nxnx_manga_search.nxnx_manga_shelf_lib.nx

imported by: nobody (leaf or entry point)

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

main ms_puts sys_write ms_slen ms_slen ↻ sys_mmap nx_uas_server_keys_load_or sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close _uas_hex_dec _uas_nib nx_csprng_fill sys_mmap ↻ nx_csprng_urandom_path sys_openat_rd ↻ sys_read ↻ sys_close ↻ nx_opq_derive_keypair sys_mmap ↻ _voprf_load_context_string u256_alloc nx_scratch nx_scratch_init sys_mmap ↻ nx_scratch_oom sys_write ↻ sys_exit sys_mmap ↻ nx_opq_hash_to_scalar sys_mmap ↻ nx_h2c_expand_message_xmd_ sys_mmap ↻ _h2c_i2osp_1 _h2c_i2osp_2 u256_alloc ↻

structs

none

consts

22const MS_MAGIC_2000000: i64 = 2000000
23const MS_MAGIC_8192: i64 = 8192
24const MS_MAGIC_262144: i64 = 262144
25const MS_MAGIC_4096: i64 = 4096
26const MS_MAGIC_120000: i64 = 120000
27const MS_MAGIC_900000: i64 = 900000
28const MS_MAGIC_16777216: i64 = 16777216
29const MS_MAGIC_5000: i64 = 5000
30const MS_MAGIC_65536: i64 = 65536
31const MS_MAGIC_1469598103: i64 = 1469598103
32const MS_MAGIC_72057594037927931: i64 = 72057594037927931
33const MS_MAGIC_4194304: i64 = 4194304
34const MS_MAGIC_1024: i64 = 1024
35const MS_MAGIC_32768: i64 = 32768
36const MS_MAGIC_2097152: i64 = 2097152
37const MS_MAGIC_86400: i64 = 86400
39const MS_PORT: i64 = 8790
40const MS_BROWSER: *u8 = "knowledge/staging/media/browser.html"
41const MS_READER: *u8 = "knowledge/staging/media/reader.html"
42const MS_CBX: *u8 = "knowledge/staging/media/cbx.html"
43const MS_ZOOM: *u8 = "knowledge/staging/media/zoom.html" // organ-emitted by nx_reader_zoom_emit (guided-view tile zoom)
44const MS_MANGA: *u8 = "knowledge/staging/media/manga.html" // organ-emitted by nx_manga_ui_emit (add + personal library UI)
45const MS_SHELF: *u8 = "knowledge/staging/media/shelf.html" // organ-emitted by nx_manga_shelf_emit (LOCAL comics/manga series browse)
46const MS_HEALTH: *u8 = "knowledge/staging/media/health.html" // organ-emitted by nx_media_health_emit (media-liveness dashboard)
47const MS_HEALTH_JSON: *u8 = "knowledge/staging/media/mediahealth.json" // written by nx_movie_probe --sweep
48const MS_READER_ROOT: *u8 = "knowledge/staging/media/reader/"
584const MS_THUMB_ELF: *u8 = "/volume1/ai/galx/nx_galx_thumb.elf"
585const MS_THUMB_MAX: *u8 = "384"

functions

50func ms_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
51func ms_puts(s: *u8) -> i64 { sys_write(1, s, ms_slen(s)); return 0 }
called by 1: main calls 2: sys_writems_slen
52func ms_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: ms_apps
53func ms_apps(dst: *u8, off: i64, s: *u8) -> i64 { return ms_app(dst, off, s, ms_slen(s)) }
54func ms_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 }
55func ms_starts(p: *u8, plen: i64, pre: *u8) -> i64 { let m: i64 = ms_slen(pre); if m > plen { return 0 } var i: i64 = 0; while i < m { if p[i] != pre[i] { return 0 } i = i + 1 } return 1 }
58func ms_qval(p: *u8, plen: i64, key: *u8, out: *u8, outcap: i64) -> i64
79func ms_urldec(src: *u8, slen: i64, dst: *u8) -> i64
97func ms_ctype(path: *u8) -> *u8
110func ms_idxpath(t: *u8) -> *u8
120func ms_handle_list(cfd: i64, p: *u8, plen: i64) -> i64
175func ms_handle_file(cfd: i64, p: *u8, plen: i64, req: *u8, reqn: i64) -> i64
213func ms_contains(hay: *u8, hl: i64, needle: *u8) -> i64
227func ms_serve_static(cfd: i64, path: *u8, ctype: *u8) -> i64
245func ms_handle_book(cfd: i64, p: *u8, plen: i64) -> i64
279func ms_slug_safe(s: *u8) -> i64
called by 1: ms_handle_llmpack calls 1: ms_slen
301func ms_handle_llmpack(cfd: i64, p: *u8, plen: i64) -> i64
353func ms_serve_browser(cfd: i64) -> i64
367func ms_handle_remove(cfd: i64, p: *u8, plen: i64) -> i64
379func ms_hexc(d: i64) -> i64 { if d < 10 { return 48 + d } return 87 + d }
called by 1: ms_pathslug
381func ms_pathslug(p: *u8, n: i64, out: *u8) -> i64
called by 1: ms_handle_open calls 2: sys_mmapms_hexc
397func ms_run_extractor(extractor: *u8, path: *u8, slug: *u8, target: *u8) -> i64
420func ms_handle_open(cfd: i64, p: *u8, plen: i64) -> i64
586func ms_fexists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
587func ms_thumb_run(src: *u8, outnew: *u8) -> i64
597func ms_cover_thumb(cfd: i64, full: *u8) -> i64
608func ms_handle_cover(cfd: i64, p: *u8, plen: i64) -> i64
666func ms_body_off(req: *u8, n: i64) -> i64
called by 1: ms_login
672func ms_form_field(body: *u8, body_n: i64, name: *u8, name_n: i64, out_off: *i64, out_n: *i64) -> i64
called by 1: ms_login
686func ms_emit_401(cfd: i64) -> i64
called by 1: ms_handle calls 3: sys_writems_slensys_close
691func ms_login(ctx: *NxAuthContext, cfd: i64, req: *u8, req_n: i64) -> i64
724func ms_shell(cfd: i64) -> i64
746func ms_emit_403(cfd: i64) -> i64
called by 1: ms_handle calls 3: sys_writems_slensys_close
753func ms_slug_guarded(ukey: *u8, path: *u8, plen: i64) -> i64
776func ms_handle(ctx: *NxAuthContext, cfd: i64) -> i64
902func main(argc: i64, argv: *i64) -> i64