nx_lib_pdf_probe.nx source
↩ module page · 34 lines · 1628 B
1// nx_lib_pdf_probe.nx -- LIVE proof of the sovereign PDF axis via the library
2// organ nx_lib_pdf: one call fetches a real PDF over TLS-1.3 and extracts text.
3import "nx_syscalls.nx"
4import "nx_lib_pdf.nx"
5const K_MAGIC_16777216: i64 = 16777216
6
7func pp_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
8func pp_wr(p: *u8, n: i64) -> i64 { sys_write(1, p, n); return 0 }
9func pp_putn(v: i64) -> i64 {
10 let bb: *u8 = sys_mmap(28); var m: i64 = v
11 if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) }
12 let t: *u8 = sys_mmap(28); var k: i64 = 0
13 if m == 0 { t[0] = 48 as u8; k = 1 }
14 while m > 0 { t[k] = (48 + (m - (m/10)*10)) as u8; m = m / 10; k = k + 1 }
15 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0
16}
17
18func main() -> i64 {
19 let store: *TrustStore = nx_lib_fetch_store()
20 if store == 0 as *TrustStore { pp_puts("no CA store\n"); return 1 }
21 pp_puts("CA store ("); pp_putn(trust_store_count(store)); pp_puts(" CAs) -- nx_lib_pdf_fetch_text over sovereign TLS-1.3...\n")
22
23 let url: *u8 = "https://arxiv.org/pdf/1706.03762\x00"
24 let cap: i64 = K_MAGIC_16777216
25 let out: *u8 = sys_mmap(cap)
26 let tn: i64 = nx_lib_pdf_fetch_text(store, url, out, cap)
27 pp_puts("nx_lib_pdf_fetch_text -> extracted text bytes="); pp_putn(tn); pp_puts("\n")
28 if tn <= 0 { return 2 }
29 pp_puts("--- first 700 chars ---\n")
30 var tt: i64 = 700; if tn < 700 { tt = tn }
31 pp_wr(out, tt)
32 pp_puts("\n--- end (sovereign: TLS-1.3 fetch + PDF text, no httpx/docling/python) ---\n")
33 return 0
34}