nx_printer_conform_live.nx source
↩ module page · 59 lines · 3181 B
1// nx_printer_conform_live.nx -- LIVE conformance audit: query the real Brother (READ-ONLY Get-Printer-
2// Attributes) and surface the ACTIONABLE IPP conformance gaps it advertises but its UI hides. Composes the
3// proven transport (nx_ipt_query_printer) + the gated profiler (nx_printer_conform). READ-ONLY -> never-brick.
4// license_tier: ORIGINAL ; genealogy_id: project-printer-management-ipp-sclass-2026-06-20
5
6import "nx_syscalls.nx"
7import "nx_ipp_transport.nx"
8import "nx_printer_conform.nx"
9const K_MAGIC_131072: i64 = 131072
10
11func p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
12func pn(v: i64) -> i64 {
13 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
14 var m: i64 = v
15 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
16 let t: *u8 = sys_mmap(24); var k: i64 = 0
17 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
18 let b: *u8 = sys_mmap(24); var i: i64 = 0
19 while i < k { b[i] = t[k - 1 - i]; i = i + 1 }
20 sys_write(1, b, k); return 0
21}
22
23func main() -> i64 {
24 p("=== NISHI PRINTER CONFORMANCE AUDIT (live, read-only IPP) ===\n")
25 let a: i64 = 192
26 let b: i64 = 168
27 let c: i64 = 8
28 let d: i64 = 127
29 let resp: *u8 = sys_mmap(K_MAGIC_131072)
30 let body: *u8 = sys_mmap(K_MAGIC_131072)
31 let out2: *i64 = sys_mmap(16) as *i64
32 var path: *u8 = "/ipp/print"
33 var v: i64 = nx_ipt_query_printer(a, b, c, d, 631, path, resp, K_MAGIC_131072, body, K_MAGIC_131072, 5, out2)
34 var ok: i64 = 0
35 if v == NX_IPT_OK { if out2[0] == 200 { ok = 1 } }
36 if ok == 0 {
37 path = "/ipp/port1"
38 v = nx_ipt_query_printer(a, b, c, d, 631, path, resp, K_MAGIC_131072, body, K_MAGIC_131072, 5, out2)
39 if v == NX_IPT_OK { if out2[0] == 200 { ok = 1 } }
40 }
41 p("path="); p(path); p(" transport="); p(nx_ipt_verdict_name(v))
42 p(" http="); pn(out2[0]); p(" ipp_body_bytes="); pn(out2[1]); p("\n")
43 if v != NX_IPT_OK { p("RESULT: no clean IPP response -- reported, not swallowed.\n"); sys_exit(1); return 1 }
44
45 let n: i64 = out2[1]
46 let sc3: *i64 = sys_mmap(64) as *i64
47 let gaps: i64 = nx_conf_gaps(body, n, sc3)
48 if gaps < 0 { p("conformance: UNKNOWN (malformed response) -- never a confident gap list.\n"); sys_exit(1); return 1 }
49
50 p("\n--- CONFORMANCE GAPS (advertised by the printer, hidden by its UI) ---\n")
51 p("gaps surfaced: "); pn(nx_conf_gap_count(gaps)); p("\n")
52 if (gaps & NX_CONF_GAP_IPP_OLD) != 0 { p(" [GAP] only old IPP (no 2.0 advertised) -- missing IPP Everywhere features\n") }
53 if (gaps & NX_CONF_GAP_NO_PDF) != 0 { p(" [GAP] no PDF support -- the client MUST rasterize (this is why we own a URF/PWG pipeline)\n") }
54 if (gaps & NX_CONF_GAP_DUPLEX_WASTE) != 0 { p(" [GAP] duplex-capable but defaults ONE-SIDED -- silent paper waste (fix: sides=two-sided-long-edge)\n") }
55 if (gaps & NX_CONF_GAP_NO_COLOR) != 0 { p(" [GAP] monochrome (color-supported = false)\n") }
56 if gaps == 0 { p(" (no conformance gaps -- a modern, well-configured printer)\n") }
57 p("the vendor UI surfaces NONE of these; the sovereign stack surfaces all of them.\n")
58 sys_exit(0); return 0
59}