interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / host / tests / links.om

77 lines · 1149 bytes Raw Blame History
1note link/symlnk take a packed two-path list: u16 count 2, then each u16 length + bytes.
2text a "pl1.tmp"
3text b "pl2.tmp"
4text c "pl3.tmp"
5text body "abcd"
6fn main to int
7fd = int fopen a 0 len a 578 420
8if lt fd 0
9ret 1
10end
11w = write fd body 0 len body
12if ne w long len body
13ret 2
14end
15r = fclose fd
16if ne r 0
17ret 3
18end
19list = new uchar 64 0
20put list 0 2
21put list 1 0
22put list 2 uchar len a
23put list 3 0
24i = ulong 0
25while lt i len a bound 64
26put list add 4 i get a i
27i = add i 1
28end
29off = add 4 len a
30put list off uchar len b
31put list add off 1 0
32i = ulong 0
33while lt i len b bound 64
34put list add add off 2 i get b i
35i = add i 1
36end
37total = add add off 2 len b
38r = link list 0 total
39if ne r 0
40ret 4
41end
42st = new uchar 128 0
43r = stat b 0 len b st 0 128
44if ne r 0
45ret 5
46end
47if ne get st 20 2
48ret 6
49end
50i = ulong 0
51while lt i len c bound 64
52put list add add off 2 i get c i
53i = add i 1
54end
55r = symlnk list 0 total
56if ne r 0
57ret 7
58end
59buf = new uchar 64 0
60n = readlnk c 0 len c buf 0 64
61if ne n long len a
62ret 8
63end
64r = unlink c 0 len c
65if ne r 0
66ret 9
67end
68r = unlink b 0 len b
69if ne r 0
70ret 10
71end
72r = unlink a 0 len a
73if ne r 0
74ret 11
75end
76ret 0
77end