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
omega-mv / aienux / connector / gates / hostile / net.om
| 1 | note hostile probe: connect to 127.0.0.1:PORT (decimal on stdin) and send an HTTP request |
| 2 | text m1 "socket -1\n" |
| 3 | text m2 "connect failed\n" |
| 4 | text m3 "sent\n" |
| 5 | text rq "GET /community/netprobe HTTP/1.0" |
| 6 | fn main to int |
| 7 | p = new uchar 16 0 |
| 8 | a = new uchar 16 0 |
| 9 | e = new uchar 4 0 |
| 10 | n = read 0 p 0 16 |
| 11 | v = ulong 0 |
| 12 | for i ulong 16 |
| 13 | if ge i ulong n |
| 14 | break |
| 15 | end |
| 16 | c = get p i |
| 17 | if and ge c 48 le c 57 |
| 18 | v = add mul v 10 sub ulong c 48 |
| 19 | end |
| 20 | end |
| 21 | fd = socknew 2 1 0 |
| 22 | if lt fd 0 |
| 23 | k = write 1 m1 0 len m1 |
| 24 | ret 0 |
| 25 | end |
| 26 | put a 0 2 |
| 27 | put a 2 uchar shr v 8 |
| 28 | put a 3 uchar and v 255 |
| 29 | put a 4 127 |
| 30 | put a 7 1 |
| 31 | r = connect int fd a 0 16 |
| 32 | if lt r 0 |
| 33 | k = write 1 m2 0 len m2 |
| 34 | ret 0 |
| 35 | end |
| 36 | put e 0 13 |
| 37 | put e 1 10 |
| 38 | put e 2 13 |
| 39 | put e 3 10 |
| 40 | k = write int fd rq 0 len rq |
| 41 | k = write int fd e 0 4 |
| 42 | k = write 1 m3 0 len m3 |
| 43 | ret 0 |
| 44 | end |