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/interplane-forge/blob/main/dl/tests/tmain.om # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / dl / tests / tmain.om` 352 lines ยท 5802 bytes Raw Blame History 1 note dl/tests/tmain.om: TEST-ONLY driver. One request per process, no socket: 2 note dltest STORE ALLOWFILE METHOD PATH BASE INM QUERY [PATH2 ...] (INM and QUERY: - for none) 3 note Extra PATHs are served by the same process after the first (state kept, as in the server). 4 note STORE ends in /; ALLOWFILE has lines " ". Sets the contract request globals the 5 note way the server does (fridx, frid, fown, frepo, frest), calls dlroute, and prints the response: 6 note METHOD BLOBF calls dlblobf (browse's large /raw/ entry point) on the PATH rest after the repo. 7 note METHOD CLONE calls dlclone instead (PATH still selects the repo). Prints STATUS / KIND / CT / CD / ETAG / CC / LOC / FILE / TITLE lines, "--", then fob. 8 global gtarg uchar 4096 9 global gtargl ulong 1 10 global gtal uchar 65536 11 global gtall ulong 1 12 text tthead "HEAD" 13 text ttclone "CLONE" 14 text ttblobf "BLOBF" 15 text ttget "GET" 16 text ttst "STATUS " 17 text ttkind "KIND " 18 text ttct "CT " 19 text ttcd "CD " 20 text ttet "ETAG " 21 text ttcc "CC " 22 text ttloc "LOC " 23 text ttfile "FILE " 24 text ttti "TITLE " 25 text ttra "RETRY " 26 text ttsep "--\n" 27 text ttnl "\n" 28 fn tout t view uchar * to void 29 x = write 1 t 0 len t 30 end 31 fn toutn v ulong to void 32 d = new uchar 20 0 33 i = ulong 20 34 x = v 35 for it ulong 20 36 i = sub i 1 37 put d i uchar add rem x 10 48 38 x = div x 10 39 if eq x 0 40 break 41 end 42 end 43 w = write 1 d i sub 20 i 44 end 45 fn targ i ulong to bool 46 put gtargl 0 0 47 if ge i ulong argcnt 48 ret false 49 end 50 n = argread i gtarg 0 4096 51 if lt n 0 52 ret false 53 end 54 put gtargl 0 ulong n 55 ret true 56 end 57 fn targis t view uchar * to bool 58 if ne get gtargl 0 len t 59 ret false 60 end 61 for i ulong len t 62 if ne get gtarg i get t i 63 ret false 64 end 65 end 66 ret true 67 end 68 fn tdash to bool 69 ret and eq get gtargl 0 1 eq get gtarg 0 45 70 end 71 fn tloadal to bool 72 fd = fopen gtarg 0 get gtargl 0 524288 0 73 if lt fd 0 74 ret false 75 end 76 r = read int fd gtal 0 65536 77 x = fclose int fd 78 if lt r 0 79 ret false 80 end 81 put gtall 0 ulong r 82 ret true 83 end 84 note tlfind scans for the repo name frepo and fills frid; returns the line index or 9999 85 fn tlfind to ulong 86 n = get gtall 0 87 s = ulong 0 88 k = ulong 0 89 for i ulong n 90 if eq get gtal i 10 91 if tlmatch s i 92 ret k 93 end 94 k = add k 1 95 s = add i 1 96 end 97 end 98 ret 9999 99 end 100 fn tlmatch s ulong e ulong to bool 101 m = get frepol 0 102 if le sub e s add m 1 103 ret false 104 end 105 for i ulong m 106 if ne get gtal add s i get frepo i 107 ret false 108 end 109 end 110 if ne get gtal add s m 32 111 ret false 112 end 113 a = add add s m 1 114 put fridl 0 sub e a 115 for i ulong sub e a 116 put frid i get gtal add a i 117 end 118 ret true 119 end 120 fn tcount to ulong 121 k = ulong 0 122 for i ulong get gtall 0 123 if eq get gtal i 10 124 k = add k 1 125 end 126 end 127 ret k 128 end 129 note tsplit: fpath = // 130 fn tsplit to void 131 put fridx 0 9999 132 n = get fpathl 0 133 i = ulong 1 134 for it ulong n 135 if or ge i n eq get fpath i 47 136 break 137 end 138 i = add i 1 139 end 140 if ge i n 141 ret 142 end 143 put fownl 0 sub i 1 144 for k ulong sub i 1 145 put fown k get fpath add k 1 146 end 147 j = add i 1 148 for it ulong n 149 if or ge j n eq get fpath j 47 150 break 151 end 152 j = add j 1 153 end 154 if or le j add i 1 gt sub sub j i 1 127 155 ret 156 end 157 put frepol 0 sub sub j i 1 158 for k ulong get frepol 0 159 put frepo k get fpath add add i 1 k 160 end 161 put frestl 0 sub n j 162 for k ulong sub n j 163 put frest k get fpath add j k 164 end 165 if not tisowner 166 ret 167 end 168 put fridx 0 tlfind 169 end 170 fn tisowner to bool 171 if ne get fownl 0 len tfowner 172 ret false 173 end 174 for i ulong len tfowner 175 if ne get fown i get tfowner i 176 ret false 177 end 178 end 179 ret true 180 end 181 fn tcp1 to void 182 n = get gtargl 0 183 for i ulong n 184 put gtstore i get gtarg i 185 end 186 put gtstl 0 n 187 end 188 fn tsetreq to bool 189 put fmeth 0 0 190 if targis ttget 191 put fmeth 0 1 192 end 193 if targis tthead 194 put fmeth 0 2 195 end 196 if targis ttclone 197 put fmeth 0 9 198 end 199 if targis ttblobf 200 put fmeth 0 8 201 end 202 if not targ 4 203 ret false 204 end 205 n = get gtargl 0 206 for i ulong n 207 put fpath i get gtarg i 208 end 209 put fpathl 0 n 210 if not targ 5 211 ret false 212 end 213 n = get gtargl 0 214 for i ulong n 215 put fbase i get gtarg i 216 end 217 put fbasel 0 n 218 ret tsetreq2 219 end 220 fn tsetreq2 to bool 221 put finml 0 0 222 if not targ 6 223 ret false 224 end 225 if not tdash 226 n = get gtargl 0 227 for i ulong n 228 put finm i get gtarg i 229 end 230 put finml 0 n 231 end 232 put fqsl 0 0 233 if not targ 7 234 ret false 235 end 236 if not tdash 237 n = get gtargl 0 238 for i ulong n 239 put fqs i get gtarg i 240 end 241 put fqsl 0 n 242 end 243 ret true 244 end 245 fn tprint st long to void 246 tout ttst 247 toutn ulong st 248 tout ttnl 249 tout ttkind 250 toutn get fkind 0 251 tout ttnl 252 x = write 1 ttct 0 len ttct 253 x = write 1 fct 0 get fctl 0 254 tout ttnl 255 x = write 1 ttcd 0 len ttcd 256 x = write 1 fcd 0 get fcdl 0 257 tout ttnl 258 x = write 1 ttet 0 len ttet 259 x = write 1 fetag 0 get fetagl 0 260 tout ttnl 261 tprint2 262 end 263 fn tprint2 to void 264 x = write 1 ttcc 0 len ttcc 265 x = write 1 fcc 0 get fccl 0 266 tout ttnl 267 x = write 1 ttloc 0 len ttloc 268 x = write 1 floc 0 get flocl 0 269 tout ttnl 270 x = write 1 ttfile 0 len ttfile 271 x = write 1 ffile 0 get ffilel 0 272 tout ttnl 273 x = write 1 ttti 0 len ttti 274 x = write 1 fti 0 get ftil 0 275 tout ttnl 276 tout ttra 277 toutn get fretry 0 278 tout ttnl 279 tout ttsep 280 x = write 1 fob 0 get fobl 0 281 end 282 fn main to int 283 if not targ 1 284 ret 2 285 end 286 tcp1 287 if not targ 2 288 ret 2 289 end 290 if not tloadal 291 ret 3 292 end 293 put fan 0 tcount 294 if not targ 3 295 ret 2 296 end 297 if not tsetreq 298 ret 2 299 end 300 tsplit 301 put fkind 0 0 302 st = long 0 303 if eq get fmeth 0 9 304 dlclone 305 else 306 st = tblobf 307 end 308 tprint st 309 for k ulong 8 310 if not targ add 8 k 311 break 312 end 313 tnext 314 end 315 ret 0 316 end 317 note tblobf: METHOD BLOBF calls dlblobf on PATH's rest after the repo (///) 318 fn tblobf to long 319 if ne get fmeth 0 8 320 ret dlroute 321 end 322 n = get frestl 0 323 if or lt n 1 gt n 64 324 ret -9 325 end 326 b = new uchar 64 0 327 for i ulong sub n 1 328 put b i get frest add i 1 329 end 330 ret dlblobf view part b 0 sub n 1 331 end 332 note tnext: one more request on the PATH in gtarg, response fields cleared as the server does 333 fn tnext to void 334 n = get gtargl 0 335 for i ulong n 336 put fpath i get gtarg i 337 end 338 put fpathl 0 n 339 put fkind 0 0 340 put fctl 0 0 341 put fcdl 0 0 342 put fetagl 0 0 343 put fccl 0 0 344 put flocl 0 0 345 put ffilel 0 0 346 put ftil 0 0 347 put fobl 0 0 348 put fretry 0 0 349 tsplit 350 st = dlroute 351 tprint st 352 end