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 / apps / interplane-forge / patch / p7route.om
| 1 | note patch/p7route.om: paroute, the slice's entry point (server/route.om fslices asks it before collab). |
| 2 | note GET /<o>/<r>/patches[?page=N] the list (HTML, or forge/patch-list/1) |
| 3 | note GET /<o>/<r>/patches/new how to open a patch |
| 4 | note POST /<o>/<r>/patches/new the upload (patch/p4take.om) |
| 5 | note GET /<o>/<r>/patches/<id> one item, signed or imported (HTML, or forge/patch/1); <id> is |
| 6 | note 16 lowercase hex |
| 7 | note GET /<o>/<r>/patches/<id>.patch the stored mbox bytes |
| 8 | note GET /<o>/<r>/patches/<id>.diff the stored diff, or the bundle diff of an imported item |
| 9 | note GET /<o>/<r>/patches/<id>.bundle the stored head.bundle of an imported item |
| 10 | note GET /<o>/<r>/pulls 302 to .../patches; /pulls/<id> and /pull/<id> 302 to |
| 11 | note .../patches/<id> (the names other forges use) |
| 12 | note Returns 0 when the path is not one of these. |
| 13 | note paseg t: frest starts with the segment t, followed by its end or a slash |
| 14 | fn paseg t view uchar * to bool |
| 15 | if not frstpre t |
| 16 | ret false |
| 17 | end |
| 18 | n = len t |
| 19 | if eq n get frestl 0 |
| 20 | ret true |
| 21 | end |
| 22 | ret eq get frest n 47 |
| 23 | end |
| 24 | note paidrq a: frest[a, a+16) is 16 lowercase hex; copied into gpid |
| 25 | fn paidrq a ulong to bool |
| 26 | for i ulong 16 |
| 27 | c = get frest add a i |
| 28 | if lt sohexv c 0 |
| 29 | ret false |
| 30 | end |
| 31 | put gpid i c |
| 32 | end |
| 33 | ret true |
| 34 | end |
| 35 | note pasfx a t: frest from a to its end equals t |
| 36 | fn pasfx a ulong t view uchar * to bool |
| 37 | if ne sub get frestl 0 a len t |
| 38 | ret false |
| 39 | end |
| 40 | for i ulong len t bound 16 |
| 41 | if ne get frest add a i get t i |
| 42 | ret false |
| 43 | end |
| 44 | end |
| 45 | ret true |
| 46 | end |
| 47 | note paalias o: /pulls or /pull (o its length): the same pages under the names other forges use |
| 48 | fn paalias o ulong to long |
| 49 | if ne get fmeth 0 1 |
| 50 | ret 405 |
| 51 | end |
| 52 | n = get frestl 0 |
| 53 | id = false |
| 54 | if and ne n o ne n add o 1 |
| 55 | if ne sub n add o 1 16 |
| 56 | ret 404 |
| 57 | end |
| 58 | if not paidrq add o 1 |
| 59 | ret 404 |
| 60 | end |
| 61 | id = true |
| 62 | else |
| 63 | if eq o len tppull |
| 64 | ret 404 |
| 65 | end |
| 66 | end |
| 67 | put fkind 0 2 |
| 68 | flocrepo |
| 69 | floct tppats |
| 70 | if id |
| 71 | flocc 47 |
| 72 | for i ulong 16 |
| 73 | flocc get gpid i |
| 74 | end |
| 75 | end |
| 76 | ret 302 |
| 77 | end |
| 78 | fn paroute to long |
| 79 | if ge get fridx 0 get fan 0 |
| 80 | ret 0 |
| 81 | end |
| 82 | if paseg tppulls |
| 83 | ret paalias len tppulls |
| 84 | end |
| 85 | if paseg tppull |
| 86 | ret paalias len tppull |
| 87 | end |
| 88 | if not paseg tppats |
| 89 | ret 0 |
| 90 | end |
| 91 | m = get fmeth 0 |
| 92 | n = get frestl 0 |
| 93 | o = len tppats |
| 94 | if or eq n o eq n add o 1 |
| 95 | if ne m 1 |
| 96 | ret 405 |
| 97 | end |
| 98 | ret palist |
| 99 | end |
| 100 | if frsteq tppnew |
| 101 | if eq m 3 |
| 102 | ret patake |
| 103 | end |
| 104 | if ne m 1 |
| 105 | ret 405 |
| 106 | end |
| 107 | ret panewpg |
| 108 | end |
| 109 | if ne m 1 |
| 110 | ret 405 |
| 111 | end |
| 112 | a = add o 1 |
| 113 | l = sub n a |
| 114 | if lt l 16 |
| 115 | ret 404 |
| 116 | end |
| 117 | if not paidrq a |
| 118 | ret 404 |
| 119 | end |
| 120 | if eq l 16 |
| 121 | ret pashow |
| 122 | end |
| 123 | if pasfx add a 16 tpsfxp |
| 124 | ret paraws 0 |
| 125 | end |
| 126 | if pasfx add a 16 tpsfxd |
| 127 | ret paraws 1 |
| 128 | end |
| 129 | if pasfx add a 16 tpsfxb |
| 130 | ret paraws 2 |
| 131 | end |
| 132 | ret 404 |
| 133 | end |