code wiki / _hdl_build / nx_rtf_book.nx

nx_rtf_book.nx

buildroot/runtime/_hdl_build/nx_rtf_book.nx

10775 B173 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_rtf_book.nx -- SOVEREIGN RTF (Rich Text Format) -> Nishi reader format. The library holds .rtf books that dead-ended at /file. RTF is text-based (no proprietary compression, no DRM) so this is a clean parser: handle {} groups + per-group ignore, \* + destination groups (fonttbl/colortbl/stylesheet/info/pict/object/...) skipped, \'xx hex (CP1252 byte), \uN unicode (+ skip the \ucN fallback), \par/\line/\sect -> newline, \tab, \\ \{ \} literals, all other control words skipped -> clean prose -> chap0.txt + book.json so the zero-JS reader renders it. \title -> book title (the \info group is otherwise skipped). REUSABLE RTF->text capability. Usage: nx_rtf_book <rtf-path> <slug>. expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_charset.nx nx_rtf_book.nx

imports: nx_syscalls.nxnx_charset.nx

imported by: nobody (leaf or entry point)

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

main do_rtf sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close rf_p rf_w sys_write rf_slen extract_rtf_title find_sub rf_slen ↻ rtf_to_text sys_mmap ↻ hexval is_letter is_digit streqn utf8_put is_destination streqn ↻ nx_charset_repair_utf8 sys_mmap ↻ _cs_fill_w1252 _cs_utf8_seqlen _cs_emit ensure_dir er_cat sys_openat_wr sys_write ↻ sys_close ↻ rf_w ↻ er_wjson sys_write ↻ rf_pn sys_mmap ↻

structs

none

consts

10const K_MAGIC_65536: i64 = 65536
11const K_MAGIC_1024: i64 = 1024
128const RCAP: i64 = 8388608

functions

13func rf_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: rf_wfind_sub
14func rf_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, rf_slen(s)); return 0 }
called by 2: rf_pdo_rtf calls 2: sys_writerf_slen
15func rf_p(s: *u8) -> i64 { rf_w(1, s); return 0 }
called by 2: do_rtfmain calls 1: rf_w
16func rf_pn(v: i64) -> i64 { let b: *u8=sys_mmap(24); var m: i64=v; if m<0{m=0-m} let t: *u8=sys_mmap(24); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: do_rtf calls 2: sys_mmapsys_write
17func ensure_dir(path: *u8) -> i64 { __syscall(258, 0-100, path, 0x1ed, 0, 0, 0); return 0 }
called by 1: do_rtf
18func er_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+i }
called by 1: do_rtf
19func er_wjson(fd: i64, s: *u8) -> i64
called by 1: do_rtf calls 1: sys_write
31func find_sub(hay: *u8, hl: i64, needle: *u8) -> i64
called by 1: extract_rtf_title calls 1: rf_slen
37func is_letter(c: i64) -> i64 { if c>=65 { if c<=90 { return 1 } } if c>=97 { if c<=122 { return 1 } } return 0 }
called by 1: rtf_to_text
38func is_digit(c: i64) -> i64 { if c>=48 { if c<=57 { return 1 } } return 0 }
called by 1: rtf_to_text
39func hexval(c: i64) -> i64 { if c>=48 { if c<=57 { return c-48 } } if c>=97 { if c<=102 { return c-87 } } if c>=65 { if c<=70 { return c-55 } } return 0 }
called by 1: rtf_to_text
40func utf8_put(out: *u8, o: i64, cp: i64) -> i64
called by 1: rtf_to_text
46func streqn(src: *u8, off: i64, lit: *u8, litlen: i64, wlen: i64) -> i64
52func is_destination(src: *u8, ws: i64, wlen: i64) -> i64
called by 1: rtf_to_text calls 1: streqn
67func rtf_to_text(src: *u8, n: i64, out: *u8, cap: i64) -> i64
116func extract_rtf_title(src: *u8, n: i64, out: *u8, cap: i64) -> i64
called by 1: do_rtf calls 1: find_sub
130func do_rtf(path: *u8, slug: *u8) -> i64
166func main(argc: i64, argv: *i64) -> i64