code wiki / _hdl_build / nx_b64_cli.nx

nx_b64_cli.nx

buildroot/runtime/_hdl_build/nx_b64_cli.nx

5173 B101 linesdepth 2pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_b64_cli.nx -- base64 a file to stdout (and optionally to a file), and DECODE a base64 file back to bytes. WHY THIS EXISTS: runtime/nx_base64.nx carries a complete b64_encode/b64_decode pair and NO main, so the capability could not be INVOKED. The encode half shipped 2026-08-06; the DECODE half stayed uninvokable -- which made base64 a one-way transport: bytes could leave the estate as text but text could not become bytes again, so binary INGEST (the rigged-donor FBX lane, 2026-08-23) had no sovereign door. This adds the missing verb by composing the SAME lib -- one codec, two verbs. BUFFER-CAP LAW (operator 2026-08-14: a ceiling that has to be guessed is a defect generator): the old BC_MAX_IN 8 MiB / BC_MAX_OUT 12 MiB REFUSED any file over 8 MiB -- a 73.6 MB donor FBX (98 MB as base64) could never pass. For FILE work there is no guess to make: sys_read_file sizes its buffer from the file, and the OUTPUT bound is ARITHMETIC from the input length (encode: 4*ceil(n/3) + newline; decode: 3*n/4). Both derived, both announced, no cap remains. usage: nx_b64_cli <infile> [outfile] encode (unchanged contract) nx_b64_cli dec <in.b64> <outfile> decode; announces bytes_in/bytes_out exit 0 ok, 1 usage, 2 unreadable/empty, 3 write-failed license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_base64.nx nx_b64_cli.nx

imports: nx_syscalls.nxnx_base64.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bc_puts sys_write bc_eq sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close b64_decode b64_grab b64_dec_char sys_openat_wr sys_write ↻ sys_close ↻ bc_putn sys_write ↻ sys_mmap ↻ b64_encode b64_enc_char

structs

none

consts

21const BC_ENC_UNIT_IN: i64 = 3 // encode consumes 3 bytes...
22const BC_ENC_UNIT_OUT: i64 = 4 // ...and emits 4 chars; decode is the inverse
23const BC_TAIL_SLACK: i64 = 8 // newline + NUL + rounding of the final group
24const BC_VERB_DEC: i64 = 100 // 'd'
25const BC_EXIT_OK: i64 = 0
26const BC_EXIT_USAGE: i64 = 1
27const BC_EXIT_UNREADABLE: i64 = 2
28const BC_EXIT_WRITEFAIL: i64 = 3

functions

30func bc_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
31func bc_putn(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
44func bc_eq(a: *u8, b: *u8) -> i64
called by 1: main
51func main(argc: i64, argv: *i64) -> i64