Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-office/blob/main/src/sink.om # omega-office Omega office documents: read and write office files in Omega Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-office / src / sink.om` 198 lines ยท 4198 bytes Raw Blame History 1 note ======== src/sink.om: the output sink the vendored zip engine calls, buffered stdout, refusals ======== 2 note vendor/omega-zip/src/io.om (unchanged, omega-zip's own seam) checksums win[0 .. n) and then calls 3 note wout n. Here those bytes go to the XML reader of the current mode; in mode 0 (no XML reader) they go 4 note to woutfd, the zip engine's own file-descriptor sink. Standard output is buffered in obuf and 5 note written by oflush; a refusal exits without flushing, so only exit 0 means a complete result. 6 7 global obuf uchar 65536 8 global on ulong 1 9 note fbuf: input buffer for a plain XML file (xmlev without ENTRY) 10 global fbuf uchar 65536 11 note handler modes (xs[QMODE]); 0 is the zip engine's own file sink 12 const MEV ulong 1 13 const MRL ulong 2 14 const MCT ulong 3 15 const MDOC ulong 4 16 const MWB ulong 5 17 const MSS ulong 6 18 const MSH ulong 7 19 20 fn quit c int m view uchar * to void 21 warn kpre 22 warn m 23 warn tnl 24 exit c 25 end 26 27 note xfastok: the next byte may take the fast path: UTF-8 input, not inside a multi-byte sequence, no CR 28 note waiting for its LF. A fast-path byte (printable ASCII) never changes these three. 29 fn xfastok to bool 30 if ne get xs QENC 1 31 ret false 32 end 33 ret and eq get xs QU8 0 eq get xs QCR 0 34 end 35 36 note wout: the zip engine's window win[0 .. n) into the XML reader. Printable ASCII in character data, 37 note in attribute values and in names is stored inline here (the same effect as xin, without its calls); 38 note every other byte, and any byte at a bound, goes through xin. It returns n: io.om's wflush assigns 39 note the result ("w = wout n"), so a build without this function is refused by omc (error 3). 40 fn wout n ulong to ulong 41 if eq get xs QMODE 0 42 woutfd n 43 ret n 44 end 45 ok = xfastok 46 i = ulong 0 47 while lt i n bound 32769 48 c = ulong get win i 49 i = add i 1 50 f = ulong get ccls c 51 if and ok ne f 0 52 s = get xs QST 53 if and eq s ZTX ne and f 1 0 54 t = get xs QTL 55 if and ne get xs QDEP 0 lt t XTBUF 56 put tbuf t uchar c 57 put xs QTL add t 1 58 put xs QBR 0 59 put xs QPOS add get xs QPOS 1 60 if eq add t 1 XTBUF 61 tflush 62 end 63 continue 64 end 65 end 66 if and eq s ZAV ne and f 4 0 67 p = get xs QAP 68 if lt p XAPOOL 69 put apool p uchar c 70 put xs QAP add p 1 71 put xs QPOS add get xs QPOS 1 72 continue 73 end 74 end 75 if and ne and f 8 0 or eq s ZLT eq s ZEN 76 if wfirst s c 77 continue 78 end 79 end 80 if and ne and f 2 0 eq get xs QNF 1 81 if wname s c 82 continue 83 end 84 end 85 end 86 xin c 87 ok = xfastok 88 end 89 ret n 90 end 91 92 note wname: an ASCII name character c in state s (start-tag, attribute or end-tag name) stored inline; 93 note false when it must take the full path (another state, or the name is at its bound). 94 fn wname s ulong c ulong to bool 95 if eq s ZSN 96 p = get xs QNL 97 if lt p XNAME 98 put xname p uchar c 99 put xs QNL add p 1 100 put xs QPOS add get xs QPOS 1 101 ret true 102 end 103 ret false 104 end 105 if eq s ZAN 106 p = get xs QAP 107 if and lt p XAPOOL lt sub p get anoff get xs QAC XNAME 108 put apool p uchar c 109 put xs QAP add p 1 110 put xs QPOS add get xs QPOS 1 111 ret true 112 end 113 ret false 114 end 115 if eq s ZEN 116 p = get xs QNB 117 if lt p XNAME 118 put nbuf p uchar c 119 put xs QNB add p 1 120 put xs QPOS add get xs QPOS 1 121 ret true 122 end 123 end 124 ret false 125 end 126 127 note wfirst: an ASCII NameStartChar c right after "<" (an element name begins, as zlt) or right after "