mailhand
mailhand: agents look after a person's email in seeded Omega. Maildir + MIME parsing, JSONL CLI and MCP, rule triage, policy-gated sending, hash-chained audit. Free (Apache-2.0).
Brought by drakestapleton
mailhand / tests / gen / mkmaildir.om
| 1 | note ======== tests/gen/mkmaildir.om: deterministic synthetic Maildir (GateBuilder benchmark) ======== |
| 2 | note Usage: mkmaildir DIR [N [SEED]] N default 10000, SEED default 1 (decimal, 0..2^64-1). |
| 3 | note Build: ./build.sh tests/units/mkmaildir.txt build/mkmaildir |
| 4 | note DIR becomes a Maildir root (INBOX): DIR/cur, DIR/new, DIR/tmp and N message files; DIR must not |
| 5 | note exist and its parent must. File names, kinds and contents: tests/bench-lib.om (top). The same N |
| 6 | note and SEED give byte-identical files. Nothing in DIR is ever overwritten (files are created with |
| 7 | note O_EXCL|O_NOFOLLOW). |
| 8 | note stdout, one line: "mkmaildir N=.. seed=.. bytes=.. new=.. cur=.. plain=.. multipart=.. qp=.. |
| 9 | note encoded_subject=.. reply=.. dir=DIR" (bytes: the sum of all message file sizes). |
| 10 | note Exit 0 written; 1 usage (argument count, N or SEED not a decimal ulong, DIR empty or longer than |
| 11 | note 4095 bytes, DIR exists); 6 I/O (stderr names errno and the path; a partial message file is removed; |
| 12 | note files written before the failure stay). |
| 13 | |
| 14 | text mmt_us "usage: mkmaildir DIR [N [SEED]] (N default 10000, SEED default 1; DIR must not exist)" |
| 15 | text mmt_head "mkmaildir " |
| 16 | text mmt_kdir " dir=" |
| 17 | |
| 18 | fn main to int |
| 19 | c = ulong argcnt |
| 20 | if or lt c 2 gt c 4 |
| 21 | mk_err mmt_us |
| 22 | ret 1 |
| 23 | end |
| 24 | b = new uchar 131072 0 |
| 25 | k = argread 1 b 0 131072 |
| 26 | if le k 0 |
| 27 | mk_err mmt_us |
| 28 | ret 1 |
| 29 | end |
| 30 | n = ulong 10000 |
| 31 | seed = ulong 1 |
| 32 | if ge c 3 |
| 33 | n = mk_argnum 2 |
| 34 | end |
| 35 | if ge c 4 |
| 36 | seed = mk_argnum 3 |
| 37 | end |
| 38 | if ne get mk_g MKG_BAD 0 |
| 39 | mk_err mmt_us |
| 40 | ret 1 |
| 41 | end |
| 42 | z = s_mem S_AUX |
| 43 | s_addt S_AUX part b 0 ulong k |
| 44 | r = mk_gen n seed |
| 45 | if ne r 0 |
| 46 | ret r |
| 47 | end |
| 48 | o_raw mmt_head |
| 49 | mk_osum |
| 50 | o_raw mmt_kdir |
| 51 | o_raw part b 0 ulong k |
| 52 | o_b 10 |
| 53 | o_flush |
| 54 | ret 0 |
| 55 | end |