nx_archive_viewer.nx
buildroot/runtime/nx_archive_viewer.nx
about
nx_archive_viewer.nx -- make the time-machine VISIBLE. Pulls page3.com's real Wayback CDX, browses as-of-1997,
fetches the actual archived page, and EMITS a viewable web artifact under web_assets/archive/:
page.html = the reconstructed page (its <img src> rewritten to the archive's image endpoint so it renders)
index.html = a dashboard: provenance (bytes/CID/dates), the capture timeline, the rendered page in an iframe,
and the raw archived HTML (exactly what we grabbed).
Sovereign TLS-1.3. Status-aware retry (handles transient 503 rate-limits) + a DISK CACHE so we fetch each artifact
once and never re-hammer the archive. Read-only except the cache + the two output files. license_tier: ORIGINAL
dependencies 6 imports · 0 importers
imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_cdx_parse.nxnx_temporal_index.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 14 | const K_MAGIC_1000000007: i64 = 1000000007 |
| 15 | const K_MAGIC_4194304: i64 = 4194304 |
| 16 | const K_MAGIC_4096: i64 = 4096 |
| 17 | const K_MAGIC_19970601: i64 = 19970601 |
| 18 | const K_MAGIC_2048: i64 = 2048 |
functions
| 20 | func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 21 | func gn(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 t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var w: i64=0; var q: i64=k-1; while q>=0 { o[w]=t[q]; w=w+1; q=q-1 } sys_write(1,o,w); return 0 } |
| 22 | func ap(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8) { buf[off+i]=s[i]; i=i+1 } return off+i } |
| 23 | func apn(buf: *u8, off: i64, v: i64) -> i64 { if v==0 { buf[off]=0x30 as u8; return off+1 } var m: i64=v; if m<0 { buf[off]=0x2d as u8; off=off+1; m=0-m } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var o: i64=off; var q: i64=k-1; while q>=0 { buf[o]=t[q]; o=o+1; q=q-1 } return o } |
| 24 | func apslice(dst: *u8, off: i64, src: *u8, so: i64, sl: i64) -> i64 { var i: i64=0; while i<sl { dst[off+i]=src[so+i]; i=i+1 } return off+sl } |
| 25 | func cid_hash(buf: *u8, n: i64) -> i64 { var h: i64=0; var i: i64=0; while i<n { h=(h*131+(buf[i] as i64))%K_MAGIC_1000000007; i=i+1 } return h } called by 1: rewrite_render |
| 26 | func dstarts(buf: *u8, off: i64, n: i64, lit: *u8, litlen: i64) -> i64 { if off+litlen>n { return 0 } var i: i64=0; while i<litlen { var a: i64=buf[off+i] as i64; if a>=0x41 { if a<=0x5a { a=a+0x20 } } if a != (lit[i] as i64) { return 0 } i=i+1 } return 1 } |
| 27 | func count_img(buf: *u8, n: i64) -> i64 { var c: i64=0; var i: i64=0; while i+4<=n { if dstarts(buf,i,n,"<img" as *u8,4)==1 { c=c+1; i=i+4 } else { i=i+1 } } return c } |
| 28 | func esc_html(dst: *u8, doff: i64, src: *u8, n: i64) -> i64 |
| 37 | func rewrite_render(dst: *u8, doff: i64, src: *u8, n: i64, ts: *u8, tso: i64, tsl: i64) -> i64 |
| 57 | func save_file(path: *u8, buf: *u8, n: i64) -> i64 |
| 64 | func read_file(path: *u8, buf: *u8, cap: i64, lenbox: *i64) -> i64 |
| 74 | func fetch_retry(url: *u8, store: *TrustStore, out: *u8, cap: i64, st: *i64, tries: i64) -> i64 |
| 83 | func main() -> i64 |