nx_eda_tooling_research_fetch.nx source
↩ module page · 76 lines · 4379 B
1// nx_eda_tooling_research_fetch.nx -- SOVEREIGN multi-source web-fetch for the EDA / BOARD-DESIGN TOOLING
2// comparison (operator: "use nishi researcher and the census and see how we compare to LibrePCB and other
3// tools that let you physically see + design the board" -- schematic editor, board editor, supply-chain
4// links, 3D visualization). The Nishi-researcher half: reuses the proven sovereign TLS-1.3 stack
5// (nx_https_fetch_follow) + Mozilla CA store, SAVES each source to knowledge/fetched/eda_*.raw so the facts
6// COMPOUND to the Library and can be grepped to CITE (>=2-source corroboration / no-hearsay). 100% sovereign
7// (own TLS, nx_cc->nxasm, no curl/wget/gcc). Benchmarks ONLY -- these 3rd-party tools are the yardstick we
8// EXCEED sovereignly, never a dependency. expect_exit: 0 license_tier: ORIGINAL
9import "nx_syscalls.nx"
10import "nx_x509_trust_store.nx"
11import "nx_trust_store_load_from_certdata.nx"
12import "nx_https_fetch_follow.nx"
13const K_MAGIC_4194304: i64 = 4194304
14const K_MAGIC_8388608: i64 = 8388608
15
16func gf_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
17func gf_putn(v: i64) -> i64 {
18 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
19 var m: i64 = v
20 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
21 let d: *u8 = sys_mmap(24); var k: i64 = 0
22 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
23 var j: i64 = k - 1
24 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 }
25 return 0
26}
27
28func have_file(path: *u8) -> i64 {
29 let fd: i64 = sys_openat_rd(path)
30 if fd < 0 { return 0 }
31 sys_close(fd)
32 return 1
33}
34
35func fetch_save(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 {
36 if have_file(opath) == 1 { gf_puts(opath); gf_puts(" [have-skip]\n"); return 1 }
37 let status: *i64 = sys_mmap(8) as *i64
38 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status)
39 gf_puts(url); gf_puts(" status="); gf_putn(status[0]); gf_puts(" bytes="); gf_putn(n)
40 if n <= 0 { gf_puts(" FETCH-FAIL\n"); return 0 }
41 var gz: i64 = 0
42 if n >= 2 { if out[0] == 0x1f as u8 { if out[1] == 0x8b as u8 { gz = 1 } } }
43 if gz == 1 { gf_puts(" [GZIP-skip]\n"); return 0 }
44 let fd: i64 = sys_openat_wr(opath, 0x1a4)
45 if fd < 0 { gf_puts(" SAVE-FAIL\n"); return 0 }
46 sys_write(fd, out, n)
47 sys_close(fd)
48 gf_puts(" SAVED\n")
49 return 1
50}
51
52func main() -> i64 {
53 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304)
54 if r <= 0 { gf_puts("EDA: certdata load failed\n"); return 1 }
55 let store: *TrustStore = r as *TrustStore
56 gf_puts("CA roots="); gf_putn(trust_store_count(store)); gf_puts("\n")
57 let cap: i64 = K_MAGIC_8388608
58 let out: *u8 = sys_mmap(cap)
59 var ok: i64 = 0
60
61 gf_puts("== EDA TOOLS (the board-design suites we benchmark vs) ==\n")
62 ok = ok + fetch_save("https://en.wikipedia.org/wiki/LibrePCB" as *u8, "knowledge/fetched/eda_librepcb.raw" as *u8, store, out, cap)
63 ok = ok + fetch_save("https://en.wikipedia.org/wiki/KiCad" as *u8, "knowledge/fetched/eda_kicad.raw" as *u8, store, out, cap)
64 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Comparison_of_EDA_software" as *u8, "knowledge/fetched/eda_comparison.raw" as *u8, store, out, cap)
65 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Electronic_design_automation" as *u8, "knowledge/fetched/eda_eda.raw" as *u8, store, out, cap)
66
67 gf_puts("== CAPABILITY AXES (schematic / netlist / DRC / BOM / 3D interchange) ==\n")
68 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Schematic_capture" as *u8, "knowledge/fetched/eda_schematic.raw" as *u8, store, out, cap)
69 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Netlist" as *u8, "knowledge/fetched/eda_netlist.raw" as *u8, store, out, cap)
70 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Design_rule_checking" as *u8, "knowledge/fetched/eda_drc.raw" as *u8, store, out, cap)
71 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Bill_of_materials" as *u8, "knowledge/fetched/eda_bom.raw" as *u8, store, out, cap)
72 ok = ok + fetch_save("https://en.wikipedia.org/wiki/ISO_10303" as *u8, "knowledge/fetched/eda_step.raw" as *u8, store, out, cap)
73
74 gf_puts("READABLE SOURCES SAVED: "); gf_putn(ok); gf_puts(" / 9\n")
75 return 0
76}