aien-protocols-mv
Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem
Brought by drakestapleton
aien-protocols-mv / specs / latent-payload / driver.om
| 1 | om2 debug |
| 2 | note SPDX-License-Identifier: Apache-2.0 |
| 3 | note Synthetic conformance only. First 1024 stdin bytes are trusted fixture context. |
| 4 | note This combined test stream is NOT a production wire format or authority path. |
| 5 | note now=100 lastseq=4; no decoder, execution, ledger or live clock effects. |
| 6 | fn lpinput b edit uchar * to long |
| 7 | n = ulong 0 |
| 8 | while lt n len b bound 5121 |
| 9 | r = read 0 b n sub len b n |
| 10 | if lt r 0 |
| 11 | ret -1 |
| 12 | end |
| 13 | if eq r 0 |
| 14 | break |
| 15 | end |
| 16 | n = add n ulong r |
| 17 | end |
| 18 | ret long n |
| 19 | end |
| 20 | fn main to int |
| 21 | ctx = new uchar 1024 0 |
| 22 | buf = new uchar 5121 0 |
| 23 | cn = lpinput ctx |
| 24 | if ne cn 1024 |
| 25 | ret 80 |
| 26 | end |
| 27 | nread = lpinput buf |
| 28 | if lt nread 0 |
| 29 | ret 80 |
| 30 | end |
| 31 | n = ulong nread |
| 32 | rc = lpvalid part buf 0 n ctx 100 4 |
| 33 | if ne rc 0 |
| 34 | ret rc |
| 35 | end |
| 36 | p = ulong 0 |
| 37 | while lt p n bound 5120 |
| 38 | r = write 1 buf p sub n p |
| 39 | if le r 0 |
| 40 | ret 81 |
| 41 | end |
| 42 | p = add p ulong r |
| 43 | end |
| 44 | ret 0 |
| 45 | end |