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-mv/blob/main/seed/node/op.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / node / op.om` 210 lines ยท 4231 bytes Raw Blame History 1 note seed/node/op.om -- omnode-op, the operator's client of the Omega Node 2 note view (DRA-291, seed/node/view.om). OM-2; compose after seed/net/http.om 3 note and seed/net/notls.om. 4 note omnode-op PORT view [SINCE INC] GET /view, the body on stdout 5 note omnode-op PORT cmd ID OP TARGET INC VER [A [B [C [D]]]] 6 note POST /cmd, the acknowledgement 7 note omnode-op PORT health GET /health (the model server's 8 note probe, DRA-292), the body on stdout 9 note PORT is on 127.0.0.1 (never 18091). Exit 0 for 200, 1 for 409 (stale), 10 note 400 (invalid) or 500 (refused), 3 for 503 (busy) or 504 (pending: post 11 note again with the same ID), 4 no connection or no response in 10 s, 5 12 note other statuses, 2 usage. 13 text opview "view" 14 text opcmd "cmd" 15 text ophlth "health" 16 text opph "/health" 17 text opget "GET" 18 text oppost "POST" 19 text ophost "Host" 20 text ophostv "127.0.0.1" 21 text oppv "/view" 22 text oppc "/cmd" 23 text opks "?since=" 24 text opki "&inc=" 25 text opnames "?id=,&op=,&target=,&inc=,&ver=,&a=,&b=,&c=,&d=," 26 text opnl "\n" 27 28 note The decimal argument i, or all ones when it is not 1..19 digits. 29 fn op_num i ulong to ulong 30 b = new uchar 32 0 31 n = argread i b 0 32 32 if or lt n 1 gt n 19 33 ret not ulong 0 34 end 35 v = ulong 0 36 for j ulong ulong n 37 c = ulong get b j 38 if or lt c 48 gt c 57 39 ret not ulong 0 40 end 41 v = add mul v 10 sub c 48 42 end 43 ret v 44 end 45 46 note Append a to o at p; past 1000 bytes the result is 2000 (overflow), and 47 note an overflowed p stays overflowed. 48 fn op_cat o edit uchar 1024 p ulong a view uchar * to ulong 49 if gt add p len a 1000 50 ret 2000 51 end 52 for i ulong len a 53 put o add p i get a i 54 end 55 ret add p len a 56 end 57 58 fn op_dec o edit uchar 1024 p ulong v ulong to ulong 59 d = new uchar 20 0 60 k = ulong 20 61 x = v 62 for it ulong 20 63 k = sub k 1 64 put d k uchar add rem x 10 48 65 x = div x 10 66 if eq x 0 67 break 68 end 69 end 70 ret op_cat o p view part d k sub 20 k 71 end 72 73 note The request target into t; its length, or 0 on a usage error. 74 fn op_target t edit uchar 1024 to ulong 75 w = new uchar 8 0 76 n = argread 2 w 0 8 77 c = ulong argcnt 78 if heq view part w 0 ulong n opview 79 p = op_cat t 0 oppv 80 if eq c 3 81 ret p 82 end 83 if ne c 5 84 ret 0 85 end 86 p = op_cat t p opks 87 p = op_arg t p 3 88 p = op_cat t p opki 89 ret op_arg t p 4 90 end 91 if heq view part w 0 ulong n ophlth 92 if ne c 3 93 ret 0 94 end 95 ret op_cat t 0 opph 96 end 97 if not heq view part w 0 ulong n opcmd 98 ret 0 99 end 100 if or lt c 8 gt c 12 101 ret 0 102 end 103 p = op_cat t 0 oppc 104 for i ulong sub c 3 105 p = op_qn t p i 106 p = op_arg t p add i 3 107 end 108 ret p 109 end 110 111 note Append the i-th comma-terminated name of opnames. 112 fn op_qn t edit uchar 1024 p ulong i ulong to ulong 113 s = ulong 0 114 m = ulong 0 115 for j ulong len opnames 116 if eq get opnames j 44 117 if eq m i 118 ret op_cat t p view part opnames s sub j s 119 end 120 m = add m 1 121 s = add j 1 122 end 123 end 124 ret p 125 end 126 127 note Decimal argument i at t[p]; p past the end when it is not a number. 128 fn op_arg t edit uchar 1024 p ulong i ulong to ulong 129 v = op_num i 130 if eq v not ulong 0 131 ret 2000 132 end 133 ret op_dec t p v 134 end 135 136 fn op_main to int 137 cs = new ulong 320 0 138 io = new uchar 131072 0 139 t = new uchar 1024 0 140 a = new uchar 16 0 141 bd = new uchar 65536 0 142 if lt argcnt 3 143 ret 2 144 end 145 po = op_num 1 146 if or or eq po 0 gt po 65535 eq po 18091 147 ret 2 148 end 149 tn = op_target t 150 if or eq tn 0 gt tn 1000 151 ret 2 152 end 153 r = haddr4 a `2130706433` po 154 fd = hdial a `5000000000` 155 if lt fd 0 156 ret 4 157 end 158 r = hinit cs io int fd 0 159 hsettmo cs `10000000000` `10000000000` 160 hsetbdl cs `10000000000` 161 st = op_req cs io view part t 0 tn 162 if lt st 0 163 x = hclose cs 164 ret 4 165 end 166 n = hbodyall cs io bd 167 x = hclose cs 168 if gt n 0 169 x = write 1 bd 0 ulong n 170 end 171 x = write 1 opnl 0 1 172 ret op_exit st 173 end 174 175 note Send the request (POST with no body for /cmd, GET for /view and 176 note /health); the response status, or negative. 177 fn op_req cs edit ulong 320 io edit uchar 131072 t view uchar * to long 178 r = long 0 179 if eq get t 1 99 180 r = hreqst cs io oppost 181 else 182 r = hreqst cs io opget 183 end 184 r = hfe r hreqtg cs io t 185 r = hfe r hhname cs io ophost 186 r = hfe r hhval cs io ophostv 187 r = hfe r hhend cs io 0 0 188 r = hfe r hwfin cs io 189 if lt r 0 190 ret r 191 end 192 ret hrsprd cs io 193 end 194 195 fn op_exit st long to int 196 if eq st 200 197 ret 0 198 end 199 if or or eq st 409 eq st 400 eq st 500 200 ret 1 201 end 202 if or eq st 503 eq st 504 203 ret 3 204 end 205 ret 5 206 end 207 208 fn main to int 209 ret op_main 210 end