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/omega-mv/blob/main/src/turing/tc_tool.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / turing / tc_tool.om` 776 lines ยท 14331 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 note 4 note src/turing/tc_tool.om: turing-coder CLI in pure seeded OM-2. 5 note Commands: pstream, encode, decode, verify, envelope. 6 note Composed after seed/ng/sha256.om, tc_pstream.om, tc_range_lib.om, tc_rans.om, tc_produce.om. 7 8 text CT_USE "usage:\n turing-coder pstream \n turing-coder encode|decode|verify [--profile H] [--model H] [--dataset H]\n turing-coder envelope ...\n" 9 text CT_REF "REFUSED " 10 text CT_COL ": " 11 text CT_NODET "(no detail)" 12 text CT_CMD_PS "pstream" 13 text CT_CMD_ENC "encode" 14 text CT_CMD_DEC "decode" 15 text CT_CMD_VER "verify" 16 text CT_CMD_ENV "envelope" 17 text CT_COD_RNG "range" 18 text CT_COD_RNS "rans" 19 text CT_OPT_P "--profile" 20 text CT_OPT_M "--model" 21 text CT_OPT_D "--dataset" 22 text CT_UNI "uniform:" 23 text CT_ST_MOD "model" 24 text CT_ST_PRF "profile digest" 25 text CT_ST_DAT "dataset" 26 text CT_ST_TRC "trace" 27 text CT_ST_PRD "produce" 28 text CT_ST_SER "serialize" 29 text CT_ST_WR "write" 30 text CT_ST_PS "probability stream" 31 text CT_ST_SY "symbols" 32 text CT_ST_ENC "encode" 33 text CT_ST_COD "coded file" 34 text CT_ST_DEC "decode" 35 text CT_ST_VER "verify" 36 text CT_ST_CSV "csv" 37 text CT_ST_RT "round trip" 38 text CT_W_BADOPT "bad --profile/--model/--dataset option" 39 text CT_W_DIFF "decoded symbol file is not byte-identical to input" 40 text CT_W_RTDIFF "whole-file round trip differs" 41 text CT_K_MD "model_digest=" 42 text CT_K_LM "\nlm_bits=" 43 text CT_K_DD "\ndataset_digest=" 44 text CT_K_TD "\ntps1_digest=" 45 text CT_K_SD "\ntsy1_digest=" 46 text CT_K_CN "\ncount=" 47 text CT_K_UB "\nideal_ub=" 48 text CT_K_CB "coded_bytes=" 49 text CT_K_CBT "\ncoded_bits=" 50 text CT_K_COD "coder=" 51 text CT_K_OVH "\noverhead_ub=" 52 text CT_K_RT "\nroundtrip=byte-exact\n" 53 text CT_CSV_HDR "unit,model,index,n,ideal_ub,range_bytes,rans_bytes\n" 54 text CT_CSV_FILE "file," 55 text CT_CSV_CRUMB "crumb," 56 text CT_ENV_FILE "file " 57 text CT_ENV_MOD " model=" 58 text CT_ENV_MASK " mask=" 59 text CT_ENV_K " K=" 60 text CT_ENV_LM " lm_bits=" 61 text CT_ENV_N " n=" 62 text CT_ENV_UB " ideal_ub=" 63 text CT_ENV_RB " range_bytes=" 64 text CT_ENV_AB " rans_bytes=" 65 66 note Argument storage: up to 16 args of 1024 bytes each 67 global ct_args uchar 16384 68 global ct_alen ulong 16 69 global ct_have ulong 3 70 global ct_raw_sy uchar 524288 71 global ct_raw_sn ulong 1 72 73 fn ct_load_args to ulong 74 ac = argcnt 75 if lt ac 0 76 ret 0 77 end 78 n = ulong ac 79 if gt n 16 80 n = ulong 16 81 end 82 for i ulong n bound 16 83 k = argread i ct_args mul i 1024 1024 84 if lt k 0 85 put ct_alen i 0 86 else 87 put ct_alen i ulong k 88 end 89 end 90 ret n 91 end 92 93 fn ct_arg_eq idx ulong s view uchar * to bool 94 al = get ct_alen idx 95 if ne al len s 96 ret false 97 end 98 off = mul idx 1024 99 for i ulong al bound 1024 100 if ne get ct_args add off i get s i 101 ret false 102 end 103 end 104 ret true 105 end 106 107 fn ct_arg_prefix idx ulong s view uchar * to bool 108 al = get ct_alen idx 109 sl = len s 110 if lt al sl 111 ret false 112 end 113 off = mul idx 1024 114 for i ulong sl bound 64 115 if ne get ct_args add off i get s i 116 ret false 117 end 118 end 119 ret true 120 end 121 122 fn ct_refuse stage view uchar * rc int to int 123 tc_out_reset 124 tc_out_str CT_REF 125 tc_out_str stage 126 tc_out_str CT_COL 127 tc_out_errname rc 128 tc_out_str CT_COL 129 if gt get tc_whylen 0 0 130 tc_out_why 131 else 132 tc_out_str CT_NODET 133 end 134 tc_out_byte 10 135 z = tc_out_flush 2 136 ret 2 137 end 138 139 fn ct_parse_u64 idx ulong off_in ulong to long 140 al = get ct_alen idx 141 if ge off_in al 142 ret -1 143 end 144 base = mul idx 1024 145 v = ulong 0 146 i = off_in 147 while lt i al bound 32 148 c = ulong get ct_args add base i 149 if lt c 48 150 ret -1 151 end 152 if gt c 57 153 ret -1 154 end 155 v = add mul v 10 sub c 48 156 i = add i 1 157 end 158 ret long v 159 end 160 161 fn ct_load_model_arg idx ulong to int 162 p = new uchar 1024 0 163 off = mul idx 1024 164 al = get ct_alen idx 165 for i ulong al bound 1024 166 put p i get ct_args add off i 167 end 168 ret tc_load_model p 0 al 169 end 170 171 fn ct_unhex_arg idx ulong w ulong to int 172 p = new uchar 1024 0 173 off = mul idx 1024 174 al = get ct_alen idx 175 for i ulong al bound 1024 176 put p i get ct_args add off i 177 end 178 ret tc_unhex_to_exp p 0 al w 179 end 180 181 fn ct_sha256_arg idx ulong to int 182 p = new uchar 1024 0 183 off = mul idx 1024 184 al = get ct_alen idx 185 for i ulong al bound 1024 186 put p i get ct_args add off i 187 end 188 ret tc_file_sha256 p 0 al 189 end 190 191 fn ct_ctr1_arg idx ulong to int 192 p = new uchar 1024 0 193 off = mul idx 1024 194 al = get ct_alen idx 195 for i ulong al bound 1024 196 put p i get ct_args add off i 197 end 198 ret tp_ctr1_read p 0 al 199 end 200 201 fn ct_read_pb_arg idx ulong to int 202 p = new uchar 1024 0 203 off = mul idx 1024 204 al = get ct_alen idx 205 for i ulong al bound 1024 206 put p i get ct_args add off i 207 end 208 ret tc_read_pb p 0 al 209 end 210 211 fn ct_write_pb_arg idx ulong to int 212 p = new uchar 1024 0 213 off = mul idx 1024 214 al = get ct_alen idx 215 for i ulong al bound 1024 216 put p i get ct_args add off i 217 end 218 ret tc_write_pb p 0 al 219 end 220 221 fn ct_read_sb_arg idx ulong to int 222 p = new uchar 1024 0 223 off = mul idx 1024 224 al = get ct_alen idx 225 for i ulong al bound 1024 226 put p i get ct_args add off i 227 end 228 ret tc_read_sb p 0 al 229 end 230 231 fn ct_write_sb_arg idx ulong use_db ulong to int 232 p = new uchar 1024 0 233 off = mul idx 1024 234 al = get ct_alen idx 235 for i ulong al bound 1024 236 put p i get ct_args add off i 237 end 238 ret tc_write_sb p 0 al use_db 239 end 240 241 fn ct_read_cb_arg idx ulong to int 242 p = new uchar 1024 0 243 off = mul idx 1024 244 al = get ct_alen idx 245 for i ulong al bound 1024 246 put p i get ct_args add off i 247 end 248 ret tc_read_cb p 0 al 249 end 250 251 fn ct_write_cb_arg idx ulong to int 252 p = new uchar 1024 0 253 off = mul idx 1024 254 al = get ct_alen idx 255 for i ulong al bound 1024 256 put p i get ct_args add off i 257 end 258 ret tc_write_cb p 0 al 259 end 260 261 fn ct_get_model idx ulong to int 262 if ct_arg_prefix idx CT_UNI 263 kv = ct_parse_u64 idx 8 264 if lt kv 0 265 ret TC_E_ARG 266 end 267 ret tp_model_uniform ulong kv 268 end 269 ret ct_load_model_arg idx 270 end 271 272 fn ct_parse_expect ac ulong start ulong to int 273 put ct_have 0 0 274 put ct_have 1 0 275 put ct_have 2 0 276 i = start 277 while lt add i 1 ac bound 16 278 w = ulong 99 279 if ct_arg_eq i CT_OPT_P 280 w = ulong 0 281 else 282 if ct_arg_eq i CT_OPT_M 283 w = ulong 1 284 else 285 if ct_arg_eq i CT_OPT_D 286 w = ulong 2 287 end 288 end 289 end 290 if eq w 99 291 ret TC_E_ARG 292 end 293 vi = add i 1 294 rc = ct_unhex_arg vi w 295 if ne rc TC_OK 296 ret TC_E_ARG 297 end 298 put ct_have w 1 299 i = add i 2 300 end 301 if ne i ac 302 ret TC_E_ARG 303 end 304 ret TC_OK 305 end 306 307 fn ct_coder_id idx ulong to ulong 308 if ct_arg_eq idx CT_COD_RNG 309 ret 1 310 end 311 if ct_arg_eq idx CT_COD_RNS 312 ret 2 313 end 314 ret 0 315 end 316 317 fn ct_cmd_pstream to int 318 rc = ct_get_model 2 319 if ne rc TC_OK 320 ret ct_refuse CT_ST_MOD rc 321 end 322 rc = ct_unhex_arg 3 0 323 if ne rc TC_OK 324 ret ct_refuse CT_ST_PRF TC_E_ARG 325 end 326 for i ulong 32 327 put tp_prof_d i get tc_exp_prof i 328 end 329 rc = ct_sha256_arg 4 330 if ne rc TC_OK 331 ret ct_refuse CT_ST_DAT TC_E_IO 332 end 333 for i ulong 32 334 put tp_dat_d i get tc_sh_out i 335 end 336 rc = ct_ctr1_arg 4 337 if ne rc TC_OK 338 ret ct_refuse CT_ST_TRC TC_E_FORMAT 339 end 340 rc = tc_produce 341 if ne rc TC_OK 342 ret ct_refuse CT_ST_PRD rc 343 end 344 rc = tc_ps_serialize 345 if ne rc TC_OK 346 ret ct_refuse CT_ST_SER rc 347 end 348 rc = tc_sy_serialize 0 349 if ne rc TC_OK 350 ret ct_refuse CT_ST_SER rc 351 end 352 rc = ct_write_pb_arg 5 353 if ne rc TC_OK 354 ret ct_refuse CT_ST_WR TC_E_IO 355 end 356 rc = ct_write_sb_arg 6 0 357 if ne rc TC_OK 358 ret ct_refuse CT_ST_WR TC_E_IO 359 end 360 ub = tc_ideal_ub 0 get tc_ps_n 0 361 tc_out_reset 362 tc_out_str CT_K_MD 363 for i ulong 32 364 tc_out_hex_byte get tp_mdig i 365 end 366 tc_out_str CT_K_LM 367 tc_out_u64 get tp_mst 4 368 tc_out_str CT_K_DD 369 for i ulong 32 370 tc_out_hex_byte get tp_dat_d i 371 end 372 tc_out_str CT_K_TD 373 tc_out_hex_ps_dig 32 374 tc_out_str CT_K_SD 375 tc_out_hex_sy_dig 32 376 tc_out_str CT_K_CN 377 tc_out_u64 get tc_ps_n 0 378 tc_out_str CT_K_UB 379 tc_out_i64 ub 380 tc_out_byte 10 381 z = tc_out_flush 1 382 ret 0 383 end 384 385 fn ct_cmd_coder ac ulong mode ulong to int 386 note mode: 1=encode, 2=decode, 3=verify 387 cid = ct_coder_id 2 388 if eq cid 0 389 ret 1 390 end 391 rc = ct_read_pb_arg 3 392 if ne rc TC_OK 393 ret ct_refuse CT_ST_PS rc 394 end 395 rc = tc_ps_parse get tc_pb_len 0 396 if ne rc TC_OK 397 ret ct_refuse CT_ST_PS rc 398 end 399 rc = ct_parse_expect ac 6 400 if ne rc TC_OK 401 tc_why_set CT_W_BADOPT 402 ret ct_refuse CT_ST_PS TC_E_ARG 403 end 404 rc = tc_ps_expect get ct_have 0 get ct_have 1 get ct_have 2 405 if ne rc TC_OK 406 ret ct_refuse CT_ST_PS rc 407 end 408 if eq mode 1 409 rc = ct_read_sb_arg 4 410 if ne rc TC_OK 411 ret ct_refuse CT_ST_SY rc 412 end 413 rc = tc_sy_parse get tc_sb_len 0 414 if ne rc TC_OK 415 ret ct_refuse CT_ST_SY rc 416 end 417 if eq cid 1 418 rc = tc_range_encode 419 else 420 rc = tc_rans_encode 421 end 422 if ne rc TC_OK 423 ret ct_refuse CT_ST_ENC rc 424 end 425 rc = ct_write_cb_arg 5 426 if ne rc TC_OK 427 ret ct_refuse CT_ST_WR TC_E_IO 428 end 429 cn = get tc_cb_len 0 430 tc_out_reset 431 tc_out_str CT_K_CB 432 tc_out_u64 cn 433 tc_out_str CT_K_CBT 434 tc_out_u64 mul cn 8 435 tc_out_byte 10 436 z = tc_out_flush 1 437 ret 0 438 end 439 cidx = ulong 4 440 if eq mode 3 441 cidx = ulong 5 442 end 443 rc = ct_read_cb_arg cidx 444 if ne rc TC_OK 445 ret ct_refuse CT_ST_COD TC_E_IO 446 end 447 cn = get tc_cb_len 0 448 if eq cid 1 449 rc = tc_range_decode cn 450 else 451 rc = tc_rans_decode cn 452 end 453 if ne rc TC_OK 454 ret ct_refuse CT_ST_DEC rc 455 end 456 rc = tc_sy_serialize 1 457 if ne rc TC_OK 458 ret ct_refuse CT_ST_DEC rc 459 end 460 if eq mode 2 461 rc = ct_write_sb_arg 5 1 462 if ne rc TC_OK 463 ret ct_refuse CT_ST_WR TC_E_IO 464 end 465 ret 0 466 end 467 rc = ct_read_sb_arg 4 468 if ne rc TC_OK 469 ret ct_refuse CT_ST_SY rc 470 end 471 rawn = get tc_sb_len 0 472 for i ulong rawn bound 524288 473 put ct_raw_sy i get tc_sb i 474 end 475 put ct_raw_sn 0 rawn 476 rc = tc_sy_parse rawn 477 if ne rc TC_OK 478 ret ct_refuse CT_ST_SY rc 479 end 480 rc = tc_pair_check 481 if ne rc TC_OK 482 ret ct_refuse CT_ST_SY rc 483 end 484 dn = get tc_db_len 0 485 if ne rawn dn 486 tc_why_set CT_W_DIFF 487 ret ct_refuse CT_ST_VER TC_E_SYMBOL 488 end 489 for i ulong dn bound 524288 490 if ne get ct_raw_sy i get tc_db i 491 tc_why_set CT_W_DIFF 492 ret ct_refuse CT_ST_VER TC_E_SYMBOL 493 end 494 end 495 ub = tc_ideal_ub 0 get tc_ps_n 0 496 ovh = sub mul long mul cn 8 `1000000` ub 497 tc_out_reset 498 tc_out_str CT_K_COD 499 if eq cid 1 500 tc_out_str CT_COD_RNG 501 else 502 tc_out_str CT_COD_RNS 503 end 504 tc_out_str CT_K_TD 505 tc_out_hex_ps_dig 32 506 tc_out_str CT_K_CN 507 tc_out_u64 get tc_ps_n 0 508 tc_out_byte 10 509 tc_out_str CT_K_CB 510 tc_out_u64 cn 511 tc_out_str CT_K_CBT 512 tc_out_u64 mul cn 8 513 tc_out_str CT_K_UB 514 tc_out_i64 ub 515 tc_out_str CT_K_OVH 516 tc_out_i64 ovh 517 tc_out_str CT_K_RT 518 z = tc_out_flush 1 519 ret 0 520 end 521 522 fn ct_sym_eq lo ulong n ulong to bool 523 for i ulong n bound 500000 524 if ne get tc_dsy_sym i get tc_sy_sym add lo i 525 ret false 526 end 527 end 528 ret true 529 end 530 531 fn ct_env_crumb csv_fd int lo ulong hi ulong to int 532 n = sub hi lo 533 k = get tc_ps_k 0 534 cu = tc_ideal_ub lo hi 535 rc = tc_range_encode_raw lo n k 0 536 if ne rc TC_OK 537 ret ct_refuse CT_ST_ENC TC_E_IO 538 end 539 nx = get tc_cb_plen 0 540 rc = tc_range_decode_raw lo n k 0 nx 541 if ne rc TC_OK 542 ret ct_refuse CT_ST_RT TC_E_SYMBOL 543 end 544 if not ct_sym_eq lo n 545 ret ct_refuse CT_ST_RT TC_E_SYMBOL 546 end 547 rc = tc_rans_encode_raw lo n k 0 548 if ne rc TC_OK 549 ret ct_refuse CT_ST_ENC TC_E_IO 550 end 551 ny = get tc_cb_plen 0 552 rc = tc_rans_decode_raw lo n k 0 ny 553 if ne rc TC_OK 554 ret ct_refuse CT_ST_RT TC_E_SYMBOL 555 end 556 if not ct_sym_eq lo n 557 ret ct_refuse CT_ST_RT TC_E_SYMBOL 558 end 559 tc_out_reset 560 tc_out_str CT_CSV_CRUMB 561 for i ulong 8 562 tc_out_hex_byte get tp_mdig i 563 end 564 tc_out_byte 44 565 tc_out_u64 ulong get tc_ps_crumb lo 566 tc_out_byte 44 567 tc_out_u64 n 568 tc_out_byte 44 569 tc_out_i64 cu 570 tc_out_byte 44 571 tc_out_u64 add nx TC_CODED_HEADER 572 tc_out_byte 44 573 tc_out_u64 add ny TC_CODED_HEADER 574 tc_out_byte 10 575 z = tc_out_flush csv_fd 576 ret 0 577 end 578 579 fn ct_env_crumbs csv_fd int pn ulong to int 580 lo = ulong 0 581 while lt lo pn bound 500000 582 hi = add lo 1 583 cl = get tc_ps_crumb lo 584 while lt hi pn bound 500000 585 if ne get tc_ps_crumb hi cl 586 break 587 end 588 hi = add hi 1 589 end 590 erc = ct_env_crumb csv_fd lo hi 591 if ne erc 0 592 ret erc 593 end 594 lo = hi 595 end 596 ret 0 597 end 598 599 fn ct_env_one csv_fd int mi ulong to int 600 rc = ct_get_model mi 601 if ne rc TC_OK 602 ret ct_refuse CT_ST_MOD rc 603 end 604 rc = tc_produce 605 if ne rc TC_OK 606 ret ct_refuse CT_ST_PRD rc 607 end 608 rc = tc_ps_serialize 609 if ne rc TC_OK 610 ret ct_refuse CT_ST_SER rc 611 end 612 rc = tc_sy_serialize 0 613 if ne rc TC_OK 614 ret ct_refuse CT_ST_SER rc 615 end 616 rc = tc_ps_parse get tc_pb_len 0 617 if ne rc TC_OK 618 ret ct_refuse CT_ST_PS rc 619 end 620 rc = tc_sy_parse get tc_sb_len 0 621 if ne rc TC_OK 622 ret ct_refuse CT_ST_SY rc 623 end 624 pn = get tc_ps_n 0 625 ub = tc_ideal_ub 0 pn 626 rc = tc_range_encode 627 if ne rc TC_OK 628 ret ct_refuse CT_ST_ENC rc 629 end 630 na = get tc_cb_len 0 631 rc = tc_range_decode na 632 if ne rc TC_OK 633 ret ct_refuse CT_ST_DEC rc 634 end 635 for i ulong pn bound 500000 636 if ne get tc_dsy_sym i get tc_sy_sym i 637 tc_why_set CT_W_RTDIFF 638 ret ct_refuse CT_ST_RT TC_E_SYMBOL 639 end 640 end 641 rc = tc_rans_encode 642 if ne rc TC_OK 643 ret ct_refuse CT_ST_ENC rc 644 end 645 nb = get tc_cb_len 0 646 rc = tc_rans_decode nb 647 if ne rc TC_OK 648 ret ct_refuse CT_ST_DEC rc 649 end 650 for i ulong pn bound 500000 651 if ne get tc_dsy_sym i get tc_sy_sym i 652 tc_why_set CT_W_RTDIFF 653 ret ct_refuse CT_ST_RT TC_E_SYMBOL 654 end 655 end 656 tc_out_reset 657 tc_out_str CT_ENV_FILE 658 tlen = get ct_alen 4 659 toff = ulong 4096 660 for i ulong tlen bound 1024 661 tc_out_byte get ct_args add toff i 662 end 663 tc_out_str CT_ENV_MOD 664 for i ulong 8 665 tc_out_hex_byte get tp_mdig i 666 end 667 tc_out_str CT_ENV_MASK 668 tc_out_u64 get tp_mst 1 669 tc_out_str CT_ENV_K 670 tc_out_u64 get tp_mst 0 671 tc_out_str CT_ENV_LM 672 tc_out_u64 get tp_mst 4 673 tc_out_str CT_ENV_N 674 tc_out_u64 pn 675 tc_out_str CT_ENV_UB 676 tc_out_i64 ub 677 tc_out_str CT_ENV_RB 678 tc_out_u64 na 679 tc_out_str CT_ENV_AB 680 tc_out_u64 nb 681 tc_out_byte 10 682 z = tc_out_flush 1 683 tc_out_reset 684 tc_out_str CT_CSV_FILE 685 for i ulong 8 686 tc_out_hex_byte get tp_mdig i 687 end 688 tc_out_byte 44 689 tc_out_byte 48 690 tc_out_byte 44 691 tc_out_u64 pn 692 tc_out_byte 44 693 tc_out_i64 ub 694 tc_out_byte 44 695 tc_out_u64 na 696 tc_out_byte 44 697 tc_out_u64 nb 698 tc_out_byte 10 699 z = tc_out_flush csv_fd 700 ret ct_env_crumbs csv_fd pn 701 end 702 703 fn ct_cmd_envelope ac ulong to int 704 rc = ct_unhex_arg 2 0 705 if ne rc TC_OK 706 ret ct_refuse CT_ST_PRF TC_E_ARG 707 end 708 for i ulong 32 709 put tp_prof_d i get tc_exp_prof i 710 end 711 cfd = fopen ct_args 3072 get ct_alen 3 577 420 712 if lt cfd 0 713 ret ct_refuse CT_ST_CSV TC_E_IO 714 end 715 rc = ct_sha256_arg 4 716 if ne rc TC_OK 717 z = fclose int cfd 718 ret ct_refuse CT_ST_DAT TC_E_IO 719 end 720 for i ulong 32 721 put tp_dat_d i get tc_sh_out i 722 end 723 rc = ct_ctr1_arg 4 724 if ne rc TC_OK 725 z = fclose int cfd 726 ret ct_refuse CT_ST_TRC TC_E_FORMAT 727 end 728 tc_out_reset 729 tc_out_str CT_CSV_HDR 730 z2 = tc_out_flush int cfd 731 mi = ulong 5 732 while lt mi ac bound 16 733 erc = ct_env_one int cfd mi 734 if ne erc 0 735 z = fclose int cfd 736 ret erc 737 end 738 mi = add mi 1 739 end 740 z = fclose int cfd 741 if ne z 0 742 ret ct_refuse CT_ST_CSV TC_E_IO 743 end 744 ret 0 745 end 746 747 fn main to int 748 ac = ct_load_args 749 if eq ac 7 750 if ct_arg_eq 1 CT_CMD_PS 751 ret ct_cmd_pstream 752 end 753 end 754 if ge ac 6 755 if eq rem sub ac 6 2 0 756 if ne ct_coder_id 2 0 757 if ct_arg_eq 1 CT_CMD_ENC 758 ret ct_cmd_coder ac 1 759 end 760 if ct_arg_eq 1 CT_CMD_DEC 761 ret ct_cmd_coder ac 2 762 end 763 if ct_arg_eq 1 CT_CMD_VER 764 ret ct_cmd_coder ac 3 765 end 766 end 767 end 768 if ct_arg_eq 1 CT_CMD_ENV 769 ret ct_cmd_envelope ac 770 end 771 end 772 tc_out_reset 773 tc_out_str CT_USE 774 z = tc_out_flush 2 775 ret 1 776 end