code wiki / _hdl_build / nx_web_archive.nx
nx_web_archive.nx
buildroot/runtime/_hdl_build/nx_web_archive.nx
about
nx_web_archive.nx -- SOVEREIGN WARC-class archive store: the link-rot-prevention core. Preserve a captured
resource (URL + content-type + bytes) as a WARC record, and retrieve it by URL later -- so when the origin
site vanishes (abandonware, dead host), the search engine serves the PRESERVED copy instead of a 404. WARC
(ISO 28500) is the exact format the Internet Archive + Browsertrix use, so ours interoperates. A WARC is a
sequence of records: a text header block (WARC/1.0 + fields) then a Content-Length-delimited payload (so
BINARY media with embedded CRLF round-trips exactly). We write "resource" records (payload = the raw bytes).
license_tier: ORIGINAL
dependencies 1 imports · 10 importers
imports: nx_syscalls.nx
imported by: nx_archive_capture.nxnx_archive_capture_gate.nxnx_archive_daemon.nxnx_archive_live.nxnx_archive_resolve.nxnx_archive_resolve_gate.nxnx_bench_warc.nxnx_crawl_preserve.nxnx_preserve_live.nxnx_web_archive_gate.nx
structs
| none |
consts
| none |
functions
| 10 | func wa_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 11 | func wa_puts(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off]=s[i];off=off+1;i=i+1} return off } |
| 12 | func wa_putn(dst: *u8, off: i64, v: i64) -> i64 { var m: i64=v; if m==0 { dst[off]=48 as u8; return off+1 } 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 j: i64=0; while j<k { dst[off]=t[k-1-j]; off=off+1; j=j+1 } return off } |
| 13 | func wa_find(hay: *u8, hl: i64, needle: *u8, nl: i64, from: i64) -> i64 |
| 21 | func wa_write_resource(buf: *u8, off: i64, uri: *u8, date: *u8, ctype: *u8, payload: *u8, plen: i64) -> i64 |
| 35 | func wa_field_num(warc: *u8, start: i64, end: i64, field: *u8) -> i64 |
| 46 | func wa_uri_matches(warc: *u8, start: i64, end: i64, uri: *u8, ulen: i64) -> i64 |
| 62 | func wa_lookup(warc: *u8, warclen: i64, uri: *u8, ulen: i64, out_ptr: *i64, out_len: *i64) -> i64 |
| 85 | func wa_content_type(warc: *u8, start: i64, end: i64, out: *u8, cap: i64) -> i64 |
| 96 | func wa_resolve(warc: *u8, warclen: i64, uri: *u8, ulen: i64, out_ptr: *i64, out_len: *i64, out_ctype: *u8, ctcap: i64) -> i64 |
| 119 | func wa_count(warc: *u8, warclen: i64) -> i64 |
| 126 | func wa_save(path: *u8, warc: *u8, warclen: i64) -> i64 { let fd: i64 = sys_openat_wr(path, 0x1a4); if fd < 0 { return 0-1 } sys_write(fd, warc, warclen); sys_close(fd); return 0 } |
| 127 | func wa_load(path: *u8, warc: *u8, cap: i64) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } let n: i64 = sys_read(fd, warc, cap); sys_close(fd); return n } |
| 131 | func wa_write_resource_rated(buf: *u8, off: i64, uri: *u8, date: *u8, ctype: *u8, rating: *u8, payload: *u8, plen: i64) -> i64 |
| 145 | func wa_hdr_str(warc: *u8, start: i64, end: i64, field: *u8, out: *u8, cap: i64) -> i64 |
| 155 | func wa_target_uri(warc: *u8, start: i64, end: i64, out: *u8, cap: i64) -> i64 { return wa_hdr_str(warc, start, end, "WARC-Target-URI: " as *u8, out, cap) } |
| 157 | func wa_rating(warc: *u8, start: i64, end: i64, out: *u8, cap: i64) -> i64 |
| 163 | func wa_record_at(warc: *u8, warclen: i64, index: i64, out_uri: *u8, uricap: i64, out_ct: *u8, ctcap: i64, out_rating: *u8, rcap: i64, out_len: *i64) -> i64 |