nx_archive_media_recovery.nx
buildroot/runtime/nx_archive_media_recovery.nx
about
nx_archive_media_recovery.nx -- R6 step B (recovery half): the DIFFERENTIATOR. Reads media/manifest.tsv + the
stored image bytes, decodes each (nx_img_to_gray: JPEG/PNG; GIF returns 0 -> perceptual pending), perceptual-hashes
the decodable ones (dHash, Krawetz 2011), and DEMONSTRATES recovery: a dead image URL is recovered by perceptual
match -- a resized/re-encoded copy of the SAME image still matches (small Hamming) while an unrelated image does
not (large Hamming), and nx_phash_nearest picks the survivor. This is what the Wayback Machine cannot do. Emits
web_assets/archive/recovery.html (gallery of OUR grabbed media + the recovery proof). Image stack only (composes
nx_phash + nx_image_gray over syscalls.nx) -- file-based handoff from nx_archive_media_fetch. license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_phash.nxnx_image_gray.nxnx_gif_decode.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const K_MAGIC_1000000007: i64 = 1000000007 |
| 12 | const K_MAGIC_4194304: i64 = 4194304 |
functions
| 14 | func iputs(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 1: main |
| 15 | func inum(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 } called by 1: main |
| 16 | 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 } called by 1: main |
| 17 | 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 } called by 1: main |
| 18 | func aphex(buf: *u8, off: i64, v: i64) -> i64 { let tmp: *u8=sys_mmap(16); var m: i64=v; var k: i64=0; while k<16 { let nib: i64=m&0xf; var c: i64=nib+0x30; if nib>9 { c=nib+0x57 } tmp[k]=c as u8; m=m>>4; k=k+1 } var j: i64=0; while j<16 { buf[off+j]=tmp[15-j]; j=j+1 } return off+16 } called by 1: main |
| 19 | 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 } called by 1: main |
| 20 | func save_file(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64=sys_openat_wr(path, 0x1a4); if fd<0 { return 0 } var off: i64=0; while off<n { let w: i64=sys_write(fd, ((buf as i64)+off) as *u8, n-off); if w<=0 { sys_close(fd); return 0 } off=off+w } sys_close(fd); return 1 } |
| 22 | func decode_any(path: *u8, wh: *i64) -> *u8 |
| 30 | 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: main |
| 32 | func main() -> i64 |