code wiki / _hdl_build / nx_rtf_book.nx
nx_rtf_book.nx
buildroot/runtime/_hdl_build/nx_rtf_book.nx
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
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
structs
| none |
consts
| 10 | const K_MAGIC_65536: i64 = 65536 |
| 11 | const K_MAGIC_1024: i64 = 1024 |
| 128 | const RCAP: i64 = 8388608 |
functions
| 13 | func rf_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 14 | func rf_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, rf_slen(s)); return 0 } |
| 15 | func rf_p(s: *u8) -> i64 { rf_w(1, s); return 0 } |
| 16 | func 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 } |
| 17 | func ensure_dir(path: *u8) -> i64 { __syscall(258, 0-100, path, 0x1ed, 0, 0, 0); return 0 } called by 1: do_rtf |
| 18 | func 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 |
| 19 | func er_wjson(fd: i64, s: *u8) -> i64 |
| 31 | func find_sub(hay: *u8, hl: i64, needle: *u8) -> i64 |
| 37 | func 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 |
| 38 | func is_digit(c: i64) -> i64 { if c>=48 { if c<=57 { return 1 } } return 0 } called by 1: rtf_to_text |
| 39 | func 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 |
| 40 | func utf8_put(out: *u8, o: i64, cp: i64) -> i64 called by 1: rtf_to_text |
| 46 | func streqn(src: *u8, off: i64, lit: *u8, litlen: i64, wlen: i64) -> i64 |
| 52 | func is_destination(src: *u8, ws: i64, wlen: i64) -> i64 |
| 67 | func rtf_to_text(src: *u8, n: i64, out: *u8, cap: i64) -> i64 |
| 116 | func extract_rtf_title(src: *u8, n: i64, out: *u8, cap: i64) -> i64 |
| 130 | func do_rtf(path: *u8, slug: *u8) -> i64 called by 1: main calls 14: sys_mmapsys_read_filerf_pextract_rtf_titlertf_to_textnx_charset_repair_utf8+8 |
| 166 | func main(argc: i64, argv: *i64) -> i64 |