_dlr_fetch_one.nx source
↩ module page · 23 lines · 940 B
1// _dlr_fetch_one.nx -- single-URL TEXT fetch unit for the guarded crawler.
2// Staged fetch (validated HTTPS + redirect follow + chunked decode) is the
3// SHARED nx_fetch_unit (Rule #15 -- extracted 2026-06-10 standards audit);
4// this child adds only html->text + the output write. Runs under
5// nx_guarded_run. Exit 0 = text written; 2 = fetch failed; 3 = bad args.
6// usage: _dlr_fetch_one <url> <out_text_path>
7import "nx_syscalls.nx"
8import "nx_fetch_unit.nx"
9import "nx_html_to_text.nx"
10
11func main(argc: i64, argv: *i64) -> i64 {
12 if argc < 3 { return 3 }
13 let body: *u8 = sys_mmap(FU_CAP)
14 let blen: i64 = nx_fetch_staged(argv[1] as *u8, body, FU_CAP)
15 if blen <= 0 { return 2 }
16 let text: *u8 = sys_mmap(FU_CAP)
17 let tl: i64 = nx_html_to_text(body, blen, text, FU_CAP)
18 let fd: i64 = sys_openat_wr(argv[2] as *u8, 0x1a4)
19 if fd < 0 { return 2 }
20 sys_write(fd, text, tl)
21 sys_close(fd)
22 return 0
23}