Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch core_zip_vfs Through [c6b845bda5] Excluding Merge-Ins
This is equivalent to a diff from c750138b4b to c6b845bda5
|
2014-09-12
| ||
| 16:06 | Merging in changes from trunk check-in: ba85013c28 user: hypnotoad tags: core_zip_vfs | |
| 16:03 | Developed an improved bootloader built around TclSetPreInitScript. The new bootloader now mounts th... check-in: c6b845bda5 user: hypnotoad tags: core_zip_vfs | |
|
2014-09-09
| ||
| 15:23 | Folding the core_zip_vfs_static work back into main branch. The pure-dynamic line of research was no... check-in: c5e069de45 user: hypnotoad tags: core_zip_vfs | |
|
2014-09-08
| ||
| 21:22 | Exceptional handling of oo::class has to be consistent throughout. check-in: 084ef81a6c user: dgp tags: trunk | |
|
2014-09-05
| ||
| 20:34 | Updating to the latest trunk check-in: 6c37892758 user: hypnotoad tags: core_zip_vfs | |
| 19:04 | Remove unused macros. check-in: c750138b4b user: dgp tags: trunk | |
| 18:30 | Make corrections to long-false comments. check-in: 2558fa2094 user: dgp tags: trunk | |
Changes to changes.
| ︙ | ︙ | |||
8448 8449 8450 8451 8452 8453 8454 | 2014-08-17 (bug fix)[7d52e11] [info class subclasses oo::object] should include ::oo::class (fellows) 2014-08-25 (TIP 429) New command [string cat] (leitgeb,ferrieux) --- Released 8.6.2, August 27, 2014 --- http://core.tcl.tk/tcl/ for details | > > | 8448 8449 8450 8451 8452 8453 8454 8455 8456 | 2014-08-17 (bug fix)[7d52e11] [info class subclasses oo::object] should include ::oo::class (fellows) 2014-08-25 (TIP 429) New command [string cat] (leitgeb,ferrieux) --- Released 8.6.2, August 27, 2014 --- http://core.tcl.tk/tcl/ for details 2014-08-29 (TIP TBD) Added a C Implementation of ZipVFS to provide Tcl/Wishkit building capbilities in the core (hypnotoad) |
Changes to doc/tclsh.1.
| ︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 | The variable \fBtcl_prompt2\fR is used in a similar way when a newline is typed but the current command is not yet complete; if \fBtcl_prompt2\fR is not set then no prompt is output for incomplete commands. .SH "STANDARD CHANNELS" .PP See \fBTcl_StandardChannels\fR for more explanations. .SH "SEE ALSO" auto_path(n), encoding(n), env(n), fconfigure(n) .SH KEYWORDS application, argument, interpreter, prompt, script file, shell | > > > > > > > > > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | The variable \fBtcl_prompt2\fR is used in a similar way when a newline is typed but the current command is not yet complete; if \fBtcl_prompt2\fR is not set then no prompt is output for incomplete commands. .SH "STANDARD CHANNELS" .PP See \fBTcl_StandardChannels\fR for more explanations. .SH ZIPVFS .PP When a zipfile is concatenated to the end of a \fBtclsh\fR, on startup the contents of the zip archive will be mounted as the virtual file system /zvfs. If a top level directory tcl8.6 is present in the zip archive, it will become the directory loaded as env(TCL_LIBRARY). If a file named \fBmain.tcl\fR is present in the top level directory of the zip archive, it will be sourced instead of the shell's normal command line handing. .SH "SEE ALSO" auto_path(n), encoding(n), env(n), fconfigure(n) .SH KEYWORDS application, argument, interpreter, prompt, script file, shell |
Added doc/zvfs.n.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
'\"
'\" Copyright (c) 2014 Sean Woods
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH zvfs n 0.1 Zvfs "Zvfs Commands"
.so man.macros
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
zvfs \- Mount and work with ZIP files within Tcl
.SH SYNOPSIS
.nf
\fBpackage require zvfs \fR?\fB0.1\fR?
.sp
\fB::zvfs::add\fR ?\fB\-fconfigure \fIoptpairs...\fR? \fIarchive file1\fR ?\fIfile2 ...\fR?
\fB::zvfs::append\fR \fIarchive\fR ?\fIsource destination\fR? ?\fIsource destination...\fR?
\fB::zvfs::dump\fR \fIzipfile\fR
\fB::zvfs::exists\fR \fIfilename\fR
\fB::zvfs::info\fR \fIfile\fR
\fB::zvfs::list\fR ?\fB\-glob\fR|\fB\-regexp\fR? ?\fIpattern\fR?
\fB::zvfs::mount ?\fIarchive\fR? ?\fImountpoint\fR?
\fB::zvfs::start\fR \fIzipfile\fR
\fB::zvfs::unmount \fIarchive\fR
.fi
.BE
.SH DESCRIPTION
.PP
The \fBzvfs\fR package provides tcl with the ability to manipulate
the contents of a zip file archive as a virtual file system.
.TP
\fB::zvfs::mount ?\fIarchive\fR? ?\fImountpoint\fR?
.
The \fB::zvfs::mount\fR procedure mounts a zipfile as a VFS.
After this command
executes, files contained in the ZIP archive, \fIarchive\fR, will appear to Tcl to be
regular files at the mount point.
.RS
.PP
With no \fImountpoint\fR, returns the mount point for \fIarchive\fR. With no \fIarchive\fR,
return all archive/mount pairs. If \fImountpoint\fR is specified as an empty
string, mount on file path.
.RE
.TP
\fB::zvfs::unmount \fIarchive\fR
.
Unmounts a previously mounted zip, \fIarchive\fR.
.TP
\fB::zvfs::append\fR \fIarchive\fR ?\fIsource destination\fR? ?\fIsource destination...\fR?
.
This command reads \fIsource\fR files and appends them (using the name
\fIdestination\fR) to the zip archive named \fIarchive\fR. A new zip archive is created
if it does not already exist. If \fIarchive\fR refers to a file which exists but
is not a zip archive, then this command turns \fIarchive\fR into a zip archive by
appending the necessary records and the table of contents. Treat all files
as binary.
.RS
.PP
Note: No duplicate checking is done, so multiple occurances of the same file is
allowed.
.RE
.TP
\fB::zvfs::add\fR ?\fB\-fconfigure \fIoptpairs...\fR? \fIarchive file1\fR ?\fIfile2 ...\fR?
.
This command is similar to \fBzvfs::append\fR in that it adds files to the zip archive
named \fIarchive\fR, however file names are relative the current directory. In
addition, \fBfconfigure\fR is used to apply option pairs to set upon opening of
each file. Otherwise, default translation is allowed for those file
extensions listed in the \fB::zvfs::auto_ext\fR variable. Binary translation will be
used for unknown extensions.
.RS
.PP
NOTE: Use
.QW "\fB\-fconfigure {}\fR"
to use auto translation for all.
.RE
.TP
\fB::zvfs::exists\fR \fIfilename\fR
.
Return TRUE if the given filename exists in the mounted ZVFS and FALSE if it does
not.
.TP
\fB::zvfs::info\fR \fIfile\fR
.
Return information about the given file in the mounted ZVFS. The information
consists of (1) the name of the ZIP archive that contains the file, (2) the
size of the file after decompressions, (3) the compressed size of the file,
and (4) the offset of the compressed data in the archive.
.RS
.PP
Note: querying the mount point gives the start of zip data offset in (4),
which can be used to truncate the zip info off an executable.
.RE
.TP
\fB::zvfs::list\fR ?\fB\-glob\fR|\fB\-regexp\fR? ?\fIpattern\fR?
.
Return a list of all files in the mounted ZVFS. The order of the names in the list
is arbitrary.
.TP
\fB::zvfs::dump\fR \fIzipfile\fR
.
Describe the contents of a zip.
.TP
\fB::zvfs::start\fR \fIzipfile\fR
.
This command strips returns the offset of zip data.
.SH "SEE ALSO"
tclsh(1), file(n), zlib(n)
.SH "KEYWORDS"
compress, filesystem, zip
'\" Local Variables:
'\" mode: nroff
'\" End:
|
Changes to generic/tclInt.h.
| ︙ | ︙ | |||
3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 | MODULE_SCOPE void TclFinalizeThreadStorage(void); #ifdef TCL_WIDE_CLICKS MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void); MODULE_SCOPE double TclpWideClicksToNanoseconds(Tcl_WideInt clicks); #endif MODULE_SCOPE Tcl_Obj * TclDisassembleByteCodeObj(Tcl_Obj *objPtr); MODULE_SCOPE int TclZlibInit(Tcl_Interp *interp); MODULE_SCOPE void * TclpThreadCreateKey(void); MODULE_SCOPE void TclpThreadDeleteKey(void *keyPtr); MODULE_SCOPE void TclpThreadSetMasterTSD(void *tsdKeyPtr, void *ptr); MODULE_SCOPE void * TclpThreadGetMasterTSD(void *tsdKeyPtr); MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, const char *msg, int length); | > | 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 | MODULE_SCOPE void TclFinalizeThreadStorage(void); #ifdef TCL_WIDE_CLICKS MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void); MODULE_SCOPE double TclpWideClicksToNanoseconds(Tcl_WideInt clicks); #endif MODULE_SCOPE Tcl_Obj * TclDisassembleByteCodeObj(Tcl_Obj *objPtr); MODULE_SCOPE int TclZlibInit(Tcl_Interp *interp); MODULE_SCOPE int TclZvfsInit(Tcl_Interp *interp); MODULE_SCOPE void * TclpThreadCreateKey(void); MODULE_SCOPE void TclpThreadDeleteKey(void *keyPtr); MODULE_SCOPE void TclpThreadSetMasterTSD(void *tsdKeyPtr, void *ptr); MODULE_SCOPE void * TclpThreadGetMasterTSD(void *tsdKeyPtr); MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, const char *msg, int length); |
| ︙ | ︙ |
Added generic/tclZipVfs.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 |
/*
* Copyright (c) 2000 D. Richard Hipp
* Copyright (c) 2007 PDQ Interfaces Inc.
* Copyright (c) 2013-2014 Sean Woods
*
* This file is now released under the BSD style license outlined in the
* included file license.terms.
*
************************************************************************
* A ZIP archive virtual filesystem for Tcl.
*
* This package of routines enables Tcl to use a Zip file as a virtual file
* system. Each of the content files of the Zip archive appears as a real
* file to Tcl.
*
* Well, almost... Actually, the virtual file system is limited in a number
* of ways. The only things you can do are "stat" and "read" file content
* files. You cannot use "cd". But it turns out that "stat" and "read" are
* sufficient for most purposes.
*
* This version has been modified to run under Tcl 8.6
*/
#include "tcl.h"
#include <stddef.h>
#include <ctype.h>
#include <zlib.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
/*
* Size of the decompression input buffer
*/
#define COMPR_BUF_SIZE 8192
/*TODO: use thread-local as appropriate*/
static int openarch = 0; /* Set to 1 when opening archive. */
/*
* All static variables are collected into a structure named "local". That
* way, it is clear in the code when we are using a static variable because
* its name begins with "local.".
*/
static struct {
Tcl_HashTable fileHash; /* One entry for each file in the ZVFS. The
* key is the virtual filename. The data is an
* instance of the ZvfsFile structure. */
Tcl_HashTable archiveHash; /* One entry for each archive. Key is the
* name. The data is the ZvfsArchive
* structure. */
int isInit; /* True after initialization */
} local;
/*
* Each ZIP archive file that is mounted is recorded as an instance of this
* structure
*/
typedef struct ZvfsArchive {
char *zName; /* Name of the archive */
char *zMountPoint; /* Where this archive is mounted */
struct ZvfsFile *pFiles; /* List of files in that archive */
} ZvfsArchive;
/*
* Particulars about each virtual file are recorded in an instance of the
* following structure.
*/
typedef struct ZvfsFile {
char *zName; /* The full pathname of the virtual file */
ZvfsArchive *pArchive; /* The ZIP archive holding this file data */
int iOffset; /* Offset into the ZIP archive of the data */
int nByte; /* Uncompressed size of the virtual file */
int nByteCompr; /* Compressed size of the virtual file */
time_t timestamp; /* Modification time */
int isdir; /* Set to 2 if directory, or 1 if mount */
int depth; /* Number of slashes in path. */
int permissions; /* File permissions. */
struct ZvfsFile *pNext; /* Next file in the same archive */
struct ZvfsFile *pNextName; /* A doubly-linked list of files with the
* _same_ name. Only the first is in
* local.fileHash */
struct ZvfsFile *pPrevName;
} ZvfsFile;
/*
* Information about each file within a ZIP archive is stored in an instance
* of the following structure. A list of these structures forms a table of
* contents for the archive.
*/
typedef struct ZFile ZFile;
struct ZFile {
char *zName; /* Name of the file */
int isSpecial; /* Not really a file in the ZIP archive */
int dosTime; /* Modification time (DOS format) */
int dosDate; /* Modification date (DOS format) */
int iOffset; /* Offset into the ZIP archive of the data */
int nByte; /* Uncompressed size of the virtual file */
int nByteCompr; /* Compressed size of the virtual file */
int nExtra; /* Extra space in the TOC header */
int iCRC; /* Cyclic Redundancy Check of the data */
int permissions; /* File permissions. */
int flags; /* Deletion = bit 0. */
ZFile *pNext; /* Next file in the same archive */
};
EXTERN int Tcl_Zvfs_Mount(Tcl_Interp *interp,const char *zArchive,const char *zMountPoint);
EXTERN int Tcl_Zvfs_Umount(const char *zArchive);
EXTERN int TclZvfsInit(Tcl_Interp *interp);
EXTERN int Tcl_Zvfs_SafeInit(Tcl_Interp *interp);
/*
* Macros to read 16-bit and 32-bit big-endian integers into the native format
* of this local processor. B is an array of characters and the integer
* begins at the N-th character of the array.
*/
#define INT16(B, N) (B[N] + (B[N+1]<<8))
#define INT32(B, N) (INT16(B,N) + (B[N+2]<<16) + (B[N+3]<<24))
/*
* Write a 16- or 32-bit integer as little-endian into the given buffer.
*/
static void
put16(
char *z,
int v)
{
z[0] = v & 0xff;
z[1] = (v>>8) & 0xff;
}
static void
put32(
char *z,
int v)
{
z[0] = v & 0xff;
z[1] = (v>>8) & 0xff;
z[2] = (v>>16) & 0xff;
z[3] = (v>>24) & 0xff;
}
/*
* Make a new ZFile structure with space to hold a name of the number of
* characters given. Return a pointer to the new structure.
*/
static ZFile *
newZFile(
int nName,
ZFile **ppList)
{
ZFile *pNew = (void *) Tcl_Alloc(sizeof(*pNew) + nName + 1);
memset(pNew, 0, sizeof(*pNew));
pNew->zName = (char*)&pNew[1];
pNew->pNext = *ppList;
*ppList = pNew;
return pNew;
}
/*
* Delete an entire list of ZFile structures
*/
static void
deleteZFileList(
ZFile *pList)
{
ZFile *pNext;
while( pList ){
pNext = pList->pNext;
Tcl_Free((char*)pList);
pList = pNext;
}
}
/* Convert DOS time to unix time. */
static void
UnixTimeDate(
struct tm *tm,
int *dosDate,
int *dosTime)
{
*dosDate = ((((tm->tm_year-80)<<9)&0xfe00) | (((tm->tm_mon+1)<<5)&0x1e0)
| (tm->tm_mday&0x1f));
*dosTime = (((tm->tm_hour<<11)&0xf800) | ((tm->tm_min<<5)&0x7e0)
| (tm->tm_sec&0x1f));
}
/* Convert DOS time to unix time. */
static time_t
DosTimeDate(
int dosDate,
int dosTime)
{
time_t now;
struct tm *tm;
now = time(NULL);
tm = localtime(&now);
tm->tm_year = (((dosDate&0xfe00)>>9) + 80);
tm->tm_mon = ((dosDate&0x1e0)>>5);
tm->tm_mday = (dosDate & 0x1f);
tm->tm_hour = (dosTime&0xf800)>>11;
tm->tm_min = (dosTime&0x7e0)>>5;
tm->tm_sec = (dosTime&0x1f);
return mktime(tm);
}
/*
* Translate a DOS time and date stamp into a human-readable string.
*/
static void
translateDosTimeDate(
char *zStr,
int dosDate,
int dosTime){
static char *zMonth[] = { "nil",
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
};
sprintf(zStr, "%02d-%s-%d %02d:%02d:%02d",
dosDate & 0x1f,
zMonth[ ((dosDate&0x1e0)>>5) ],
((dosDate&0xfe00)>>9) + 1980,
(dosTime&0xf800)>>11,
(dosTime&0x7e)>>5,
dosTime&0x1f);
}
/* Return count of char ch in str */
int
strchrcnt(
char *str,
char ch)
{
int cnt = 0;
char *cp = str;
while ((cp = strchr(cp,ch)) != NULL) {
cp++;
cnt++;
}
return cnt;
}
/*
* Concatenate zTail onto zRoot to form a pathname. zRoot will begin with
* "/". After concatenation, simplify the pathname be removing unnecessary
* ".." and "." directories. Under windows, make all characters lower case.
*
* Resulting pathname is returned. Space to hold the returned path is
* obtained form Tcl_Alloc() and should be freed by the calling function.
*/
static char *
CanonicalPath(
const char *zRoot,
const char *zTail)
{
char *zPath;
int i, j, c;
#ifdef __WIN32__
if (isalpha(zTail[0]) && zTail[1] == ':') {
zTail += 2;
}
if (zTail[0] == '\\') {
zRoot = "";
zTail++;
}
#endif
if (zTail[0] == '/') {
zRoot = "";
zTail++;
}
zPath = Tcl_Alloc(strlen(zRoot) + strlen(zTail) + 2);
if (zTail[0]) {
sprintf(zPath, "%s/%s", zRoot, zTail);
} else {
strcpy(zPath, zRoot);
}
for (i=j=0 ; (c = zPath[i]) != 0 ; i++) {
#ifdef __WIN32__
if (isupper(c)) {
c = tolower(c);
} else if (c == '\\') {
c = '/';
}
#endif
if (c == '/') {
int c2 = zPath[i+1];
if (c2 == '/') {
continue;
}
if (c2 == '.') {
int c3 = zPath[i+2];
if (c3 == '/' || c3 == 0) {
i++;
continue;
}
if (c3 == '.' && (zPath[i+3] == '.' || zPath[i+3] == 0)) {
i += 2;
while (j > 0 && zPath[j-1] != '/') {
j--;
}
continue;
}
}
}
zPath[j++] = c;
}
if (j == 0) {
zPath[j++] = '/';
}
/* if (j>1 && zPath[j-1] == '/') j--; */
zPath[j] = 0;
return zPath;
}
/*
* Construct an absolute pathname where memory is obtained from Tcl_Alloc that
* means the same file as the pathname given.
*/
static char *
AbsolutePath(
const char *zRelative)
{
Tcl_DString pwd;
char *zResult;
int len;
Tcl_DStringInit(&pwd);
if (zRelative[0] == '~' && zRelative[1] == '/') {
/* TODO: do this for all paths??? */
if (Tcl_TranslateFileName(0, zRelative, &pwd) != NULL) {
zResult = CanonicalPath("", Tcl_DStringValue(&pwd));
goto done;
}
} else if (zRelative[0] != '/') {
#ifdef __WIN32__
if (!(zRelative[0]=='\\' || (zRelative[0] && zRelative[1] == ':'))) {
/*Tcl_GetCwd(0, &pwd); */
}
#else
Tcl_GetCwd(0, &pwd);
#endif
}
zResult = CanonicalPath(Tcl_DStringValue(&pwd), zRelative);
done:
Tcl_DStringFree(&pwd);
len = strlen(zResult);
if (len > 0 && zResult[len-1] == '/') {
zResult[len-1] = 0;
}
return zResult;
}
int
ZvfsReadTOCStart(
Tcl_Interp *interp, /* Leave error messages in this interpreter */
Tcl_Channel chan,
ZFile **pList,
int *iStart)
{
int nFile; /* Number of files in the archive */
int iPos; /* Current position in the archive file */
unsigned char zBuf[100]; /* Space into which to read from the ZIP
* archive */
ZFile *p;
int zipStart;
if (!chan) {
return TCL_ERROR;
}
if (Tcl_SetChannelOption(interp, chan, "-translation",
"binary") != TCL_OK){
return TCL_ERROR;
}
if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) {
return TCL_ERROR;
}
/*
* Read the "End Of Central Directory" record from the end of the ZIP
* archive.
*/
iPos = Tcl_Seek(chan, -22, SEEK_END);
Tcl_Read(chan, (char *) zBuf, 22);
if (memcmp(zBuf, "\120\113\05\06", 4)) {
/* Tcl_AppendResult(interp, "not a ZIP archive", NULL); */
return TCL_BREAK;
}
/*
* Compute the starting location of the directory for the ZIP archive in
* iPos then seek to that location.
*/
zipStart = iPos;
nFile = INT16(zBuf,8);
iPos -= INT32(zBuf,12);
Tcl_Seek(chan, iPos, SEEK_SET);
while (1) {
int lenName; /* Length of the next filename */
int lenExtra=0; /* Length of "extra" data for next file */
int iData; /* Offset to start of file data */
if (nFile-- <= 0) {
break;
}
/*
* Read the next directory entry. Extract the size of the filename,
* the size of the "extra" information, and the offset into the
* archive file of the file data.
*/
Tcl_Read(chan, (char *) zBuf, 46);
if (memcmp(zBuf, "\120\113\01\02", 4)) {
Tcl_AppendResult(interp, "ill-formed central directory entry",
NULL);
return TCL_ERROR;
}
lenName = INT16(zBuf,28);
lenExtra = INT16(zBuf,30) + INT16(zBuf,32);
iData = INT32(zBuf,42);
if (iData < zipStart) {
zipStart = iData;
}
p = newZFile(lenName, pList);
if (!p) {
break;
}
Tcl_Read(chan, p->zName, lenName);
p->zName[lenName] = 0;
if (lenName > 0 && p->zName[lenName-1] == '/') {
p->isSpecial = 1;
}
p->dosDate = INT16(zBuf, 14);
p->dosTime = INT16(zBuf, 12);
p->nByteCompr = INT32(zBuf, 20);
p->nByte = INT32(zBuf, 24);
p->nExtra = INT32(zBuf, 28);
p->iCRC = INT32(zBuf, 32);
if (nFile < 0) {
break;
}
/*
* Skip over the extra information so that the next read will be from
* the beginning of the next directory entry.
*/
Tcl_Seek(chan, lenExtra, SEEK_CUR);
}
*iStart = zipStart;
return TCL_OK;
}
int
ZvfsReadTOC(
Tcl_Interp *interp, /* Leave error messages in this interpreter */
Tcl_Channel chan,
ZFile **pList)
{
int iStart;
return ZvfsReadTOCStart(interp, chan, pList, &iStart);
}
/*
* Read a ZIP archive and make entries in the virutal file hash table for all
* content files of that ZIP archive. Also initialize the ZVFS if this
* routine has not been previously called.
*/
int
Tcl_Zvfs_Mount(
Tcl_Interp *interp, /* Leave error messages in this interpreter */
const char *zArchive, /* The ZIP archive file */
const char *zMountPoint) /* Mount contents at this directory */
{
Tcl_Channel chan; /* Used for reading the ZIP archive file */
char *zArchiveName = 0; /* A copy of zArchive */
char *zTrueName = 0; /* A copy of zMountPoint */
int nFile; /* Number of files in the archive */
int iPos; /* Current position in the archive file */
ZvfsArchive *pArchive; /* The ZIP archive being mounted */
Tcl_HashEntry *pEntry; /* Hash table entry */
int isNew; /* Flag to tell use when a hash entry is
* new */
unsigned char zBuf[100]; /* Space into which to read from the ZIP
* archive */
Tcl_HashSearch zSearch; /* Search all mount points */
unsigned int startZip;
if (!local.isInit) {
return TCL_ERROR;
}
/*
* If null archive name, return all current mounts.
*/
if (!zArchive) {
Tcl_DString dStr;
Tcl_DStringInit(&dStr);
pEntry = Tcl_FirstHashEntry(&local.archiveHash,&zSearch);
while (pEntry) {
pArchive = Tcl_GetHashValue(pEntry);
if (pArchive) {
Tcl_DStringAppendElement(&dStr, pArchive->zName);
Tcl_DStringAppendElement(&dStr, pArchive->zMountPoint);
}
pEntry = Tcl_NextHashEntry(&zSearch);
}
Tcl_DStringResult(interp, &dStr);
return TCL_OK;
}
/*
* If null mount, return mount point.
*/
/*TODO: cleanup allocations of Absolute() path.*/
if (!zMountPoint) {
zTrueName = AbsolutePath(zArchive);
pEntry = Tcl_FindHashEntry(&local.archiveHash, zTrueName);
if (pEntry) {
pArchive = Tcl_GetHashValue(pEntry);
if (pArchive && interp) {
Tcl_AppendResult(interp, pArchive->zMountPoint, 0);
}
}
Tcl_Free(zTrueName);
return TCL_OK;
}
chan = Tcl_OpenFileChannel(interp, zArchive, "r", 0);
if (!chan) {
return TCL_ERROR;
}
if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK){
return TCL_ERROR;
}
if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) {
return TCL_ERROR;
}
/*
* Read the "End Of Central Directory" record from the end of the ZIP
* archive.
*/
iPos = Tcl_Seek(chan, -22, SEEK_END);
Tcl_Read(chan, (char *) zBuf, 22);
if (memcmp(zBuf, "\120\113\05\06", 4)) {
if(interp) Tcl_AppendResult(interp, "not a ZIP archive", NULL);
return TCL_ERROR;
}
/*
* Construct the archive record.
*/
zArchiveName = AbsolutePath(zArchive);
pEntry = Tcl_CreateHashEntry(&local.archiveHash, zArchiveName, &isNew);
if (!isNew) {
pArchive = Tcl_GetHashValue(pEntry);
if (interp) {
Tcl_AppendResult(interp, "already mounted at ", pArchive->zMountPoint,0);
}
Tcl_Free(zArchiveName);
Tcl_Close(interp, chan);
return TCL_ERROR;
}
/*
* Empty string is the special case of mounting on itself.
*/
if (!*zMountPoint) {
zMountPoint = zTrueName = AbsolutePath(zArchive);
}
pArchive = (void *) Tcl_Alloc(sizeof(*pArchive) + strlen(zMountPoint)+1);
pArchive->zName = zArchiveName;
pArchive->zMountPoint = (char *) &pArchive[1];
strcpy(pArchive->zMountPoint, zMountPoint);
pArchive->pFiles = 0;
Tcl_SetHashValue(pEntry, pArchive);
/*
* Compute the starting location of the directory for the ZIP archive in
* iPos then seek to that location.
*/
nFile = INT16(zBuf, 8);
iPos -= INT32(zBuf, 12);
Tcl_Seek(chan, iPos, SEEK_SET);
startZip = iPos;
while (1) {
int lenName; /* Length of the next filename */
int lenExtra=0; /* Length of "extra" data for next file */
int iData; /* Offset to start of file data */
int dosTime;
int dosDate;
int isdir;
ZvfsFile *pZvfs; /* A new virtual file */
char *zFullPath; /* Full pathname of the virtual file */
char zName[1024]; /* Space to hold the filename */
if (nFile-- <= 0) {
isdir = 1;
zFullPath = CanonicalPath(zMountPoint, "");
iData = startZip;
goto addentry;
}
/*
* Read the next directory entry. Extract the size of the filename,
* the size of the "extra" information, and the offset into the
* archive file of the file data.
*/
Tcl_Read(chan, (char *) zBuf, 46);
if (memcmp(zBuf, "\120\113\01\02", 4)) {
if(interp) {
Tcl_AppendResult(interp, "ill-formed central directory entry",NULL);
}
if (zTrueName) {
Tcl_Free(zTrueName);
}
return TCL_ERROR;
}
lenName = INT16(zBuf, 28);
lenExtra = INT16(zBuf, 30) + INT16(zBuf, 32);
iData = INT32(zBuf, 42);
/*
* If the virtual filename is too big to fit in zName[], then skip
* this file
*/
if (lenName >= sizeof(zName)) {
Tcl_Seek(chan, lenName + lenExtra, SEEK_CUR);
continue;
}
/*
* Construct an entry in local.fileHash for this virtual file.
*/
Tcl_Read(chan, zName, lenName);
isdir = 0;
if (lenName > 0 && zName[lenName-1] == '/') {
lenName--;
isdir = 2;
}
zName[lenName] = 0;
zFullPath = CanonicalPath(zMountPoint, zName);
addentry:
pZvfs = (void *) Tcl_Alloc(sizeof(*pZvfs));
pZvfs->zName = zFullPath;
pZvfs->pArchive = pArchive;
pZvfs->isdir = isdir;
pZvfs->depth = strchrcnt(zFullPath, '/');
pZvfs->iOffset = iData;
if (iData < startZip) {
startZip = iData;
}
dosDate = INT16(zBuf, 14);
dosTime = INT16(zBuf, 12);
pZvfs->timestamp = DosTimeDate(dosDate, dosTime);
pZvfs->nByte = INT32(zBuf, 24);
pZvfs->nByteCompr = INT32(zBuf, 20);
pZvfs->pNext = pArchive->pFiles;
pZvfs->permissions = 0xffff & (INT32(zBuf, 38) >> 16);
pArchive->pFiles = pZvfs;
pEntry = Tcl_CreateHashEntry(&local.fileHash, zFullPath, &isNew);
if (isNew) {
pZvfs->pNextName = 0;
} else {
ZvfsFile *pOld = Tcl_GetHashValue(pEntry);
pOld->pPrevName = pZvfs;
pZvfs->pNextName = pOld;
}
pZvfs->pPrevName = 0;
Tcl_SetHashValue(pEntry, pZvfs);
if (nFile < 0) {
break;
}
/*
* Skip over the extra information so that the next read will be from
* the beginning of the next directory entry.
*/
Tcl_Seek(chan, lenExtra, SEEK_CUR);
}
Tcl_Close(interp, chan);
if (zTrueName) {
Tcl_Free(zTrueName);
}
return TCL_OK;
}
/*
* Locate the ZvfsFile structure that corresponds to the file named. Return
* NULL if there is no such ZvfsFile.
*/
static ZvfsFile *
ZvfsLookup(
char *zFilename)
{
char *zTrueName;
Tcl_HashEntry *pEntry;
ZvfsFile *pFile;
if (local.isInit == 0) {
return 0;
}
zTrueName = AbsolutePath(zFilename);
pEntry = Tcl_FindHashEntry(&local.fileHash, zTrueName);
pFile = pEntry ? Tcl_GetHashValue(pEntry) : 0;
Tcl_Free(zTrueName);
return pFile;
}
/*
* Unmount all the files in the given ZIP archive.
*/
int
Tcl_Zvfs_Umount(
const char *zArchive)
{
char *zArchiveName;
ZvfsArchive *pArchive;
ZvfsFile *pFile, *pNextFile;
Tcl_HashEntry *pEntry;
zArchiveName = AbsolutePath(zArchive);
pEntry = Tcl_FindHashEntry(&local.archiveHash, zArchiveName);
Tcl_Free(zArchiveName);
if (pEntry == 0) {
return 0;
}
pArchive = Tcl_GetHashValue(pEntry);
Tcl_DeleteHashEntry(pEntry);
Tcl_Free(pArchive->zName);
for(pFile=pArchive->pFiles ; pFile; pFile=pNextFile) {
pNextFile = pFile->pNext;
if (pFile->pNextName) {
pFile->pNextName->pPrevName = pFile->pPrevName;
}
if (pFile->pPrevName) {
pFile->pPrevName->pNextName = pFile->pNextName;
} else {
pEntry = Tcl_FindHashEntry(&local.fileHash, pFile->zName);
if (pEntry == 0) {
Tcl_Panic("This should never happen");
} else if (pFile->pNextName) {
Tcl_SetHashValue(pEntry, pFile->pNextName);
} else {
Tcl_DeleteHashEntry(pEntry);
}
}
Tcl_Free(pFile->zName);
Tcl_Free((void *) pFile);
}
return 1;
}
/*
* zvfs::mount Zip-archive-name mount-point
*
* Create a new mount point on the given ZIP archive. After this command
* executes, files contained in the ZIP archive will appear to Tcl to be
* regular files at the mount point.
*
* With no mount-point, return mount point for archive. With no archive,
* return all archive/mount pairs. If mount-point is specified as an empty
* string, mount on file path.
*/
static int
ZvfsMountObjCmd(
ClientData clientData, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
/*TODO: Convert to Tcl_Obj API!*/
if (objc > 3) {
Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]),
" ? ZIP-FILE ? MOUNT-POINT ? ?\"", 0);
return TCL_ERROR;
}
return Tcl_Zvfs_Mount(interp, objc>1?Tcl_GetString(objv[1]):NULL, objc>2?Tcl_GetString(objv[2]):NULL);
}
/*
* zvfs::unmount Zip-archive-name
*
* Undo the effects of zvfs::mount.
*/
static int
ZvfsUnmountObjCmd(
ClientData clientData, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
ZvfsArchive *pArchive; /* The ZIP archive being mounted */
Tcl_HashEntry *pEntry; /* Hash table entry */
Tcl_HashSearch zSearch; /* Search all mount points */
char *zFilename;
if (objc != 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]),
" ZIP-FILE\"", 0);
return TCL_ERROR;
}
if (!local.isInit) {
return TCL_ERROR;
}
zFilename=Tcl_GetString(objv[1]);
if (Tcl_Zvfs_Umount(zFilename)) {
return TCL_OK;
}
pEntry = Tcl_FirstHashEntry(&local.archiveHash,&zSearch);
while (pEntry) {
pArchive = Tcl_GetHashValue(pEntry);
if (pArchive && pArchive->zMountPoint[0]
&& (strcmp(pArchive->zMountPoint, zFilename) == 0)) {
if (Tcl_Zvfs_Umount(pArchive->zName)) {
return TCL_OK;
}
break;
}
pEntry = Tcl_NextHashEntry(&zSearch);
}
Tcl_AppendResult(interp, "unknown zvfs mount point or file: ", zFilename,
NULL);
return TCL_ERROR;
}
/*
* zvfs::exists filename
*
* Return TRUE if the given filename exists in the ZVFS and FALSE if it does
* not.
*/
static int
ZvfsExistsObjCmd(
ClientData clientData, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
char *zFilename;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "FILENAME");
return TCL_ERROR;
}
zFilename = Tcl_GetString(objv[1]);
Tcl_SetBooleanObj(Tcl_GetObjResult(interp), ZvfsLookup(zFilename)!=0);
return TCL_OK;
}
/*
* zvfs::info filename
*
* Return information about the given file in the ZVFS. The information
* consists of (1) the name of the ZIP archive that contains the file, (2) the
* size of the file after decompressions, (3) the compressed size of the file,
* and (4) the offset of the compressed data in the archive.
*
* Note: querying the mount point gives the start of zip data offset in (4),
* which can be used to truncate the zip info off an executable.
*/
static int
ZvfsInfoObjCmd(
ClientData clientData, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
char *zFilename;
ZvfsFile *pFile;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "FILENAME");
return TCL_ERROR;
}
zFilename = Tcl_GetString(objv[1]);
pFile = ZvfsLookup(zFilename);
if (pFile) {
Tcl_Obj *pResult = Tcl_GetObjResult(interp);
Tcl_ListObjAppendElement(interp, pResult,
Tcl_NewStringObj(pFile->pArchive->zName, -1));
Tcl_ListObjAppendElement(interp, pResult,
Tcl_NewIntObj(pFile->nByte));
Tcl_ListObjAppendElement(interp, pResult,
Tcl_NewIntObj(pFile->nByteCompr));
Tcl_ListObjAppendElement(interp, pResult,
Tcl_NewIntObj(pFile->iOffset));
}
return TCL_OK;
}
/*
* zvfs::list
*
* Return a list of all files in the ZVFS. The order of the names in the list
* is arbitrary.
*/
static int
ZvfsListObjCmd(
ClientData clientData, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
char *zPattern = 0;
Tcl_RegExp pRegexp = 0;
Tcl_HashEntry *pEntry;
Tcl_HashSearch sSearch;
Tcl_Obj *pResult = Tcl_GetObjResult(interp);
if (objc > 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?(-glob|-regexp)? ?PATTERN?");
return TCL_ERROR;
}
if (local.isInit == 0) {
return TCL_OK;
}
if (objc == 3) {
int n;
char *zSwitch = Tcl_GetStringFromObj(objv[1], &n);
if (n >= 2 && strncmp(zSwitch,"-glob",n) == 0) {
zPattern = Tcl_GetString(objv[2]);
} else if (n >= 2 && strncmp(zSwitch,"-regexp",n) == 0) {
pRegexp = Tcl_RegExpCompile(interp, Tcl_GetString(objv[2]));
if (pRegexp == 0) {
return TCL_ERROR;
}
} else {
Tcl_AppendResult(interp, "unknown option: ", zSwitch, 0);
return TCL_ERROR;
}
} else if (objc == 2) {
zPattern = Tcl_GetString(objv[1]);
}
/*
* Do the listing.
*/
if (zPattern) {
for (pEntry = Tcl_FirstHashEntry(&local.fileHash, &sSearch);
pEntry; pEntry = Tcl_NextHashEntry(&sSearch)){
ZvfsFile *pFile = Tcl_GetHashValue(pEntry);
char *z = pFile->zName;
if (Tcl_StringCaseMatch(z, zPattern, 1)) {
Tcl_ListObjAppendElement(interp, pResult,
Tcl_NewStringObj(z, -1));
}
}
} else if (pRegexp) {
for(pEntry = Tcl_FirstHashEntry(&local.fileHash, &sSearch);
pEntry; pEntry = Tcl_NextHashEntry(&sSearch)){
ZvfsFile *pFile = Tcl_GetHashValue(pEntry);
char *z = pFile->zName;
if (Tcl_RegExpExec(interp, pRegexp, z, z)) {
Tcl_ListObjAppendElement(interp, pResult,
Tcl_NewStringObj(z, -1));
}
}
} else {
for (pEntry = Tcl_FirstHashEntry(&local.fileHash, &sSearch);
pEntry; pEntry = Tcl_NextHashEntry(&sSearch)){
ZvfsFile *pFile = Tcl_GetHashValue(pEntry);
char *z = pFile->zName;
Tcl_ListObjAppendElement(interp, pResult,
Tcl_NewStringObj(z, -1));
}
}
return TCL_OK;
}
/*
* Whenever a ZVFS file is opened, an instance of this structure is attached
* to the open channel where it will be available to the ZVFS I/O routines
* below. All state information about an open ZVFS file is held in this
* structure.
*/
typedef struct ZvfsChannelInfo {
unsigned int nByte; /* number of bytes of read uncompressed
* data */
unsigned int nByteCompr; /* number of bytes of unread compressed
* data */
unsigned int nData; /* total number of bytes of compressed data */
int readSoFar; /* Number of bytes read so far */
long startOfData; /* File position of start of data in ZIP
* archive */
int isCompressed; /* True data is compressed */
Tcl_Channel chan; /* Open to the archive file */
unsigned char *zBuf; /* buffer used by the decompressor */
z_stream stream; /* state of the decompressor */
} ZvfsChannelInfo;
/*
* This routine is called as an exit handler. If we do not set
* ZvfsChannelInfo.chan to NULL, then Tcl_Close() will be called on that
* channel twice when Tcl_Exit runs. This will lead to a core dump.
*/
static void
vfsExit(
void *pArg)
{
ZvfsChannelInfo *pInfo = pArg;
pInfo->chan = 0;
}
/*
* This routine is called when the ZVFS channel is closed
*/
static int
vfsClose(
ClientData instanceData, /* A ZvfsChannelInfo structure */
Tcl_Interp *interp) /* The TCL interpreter */
{
ZvfsChannelInfo* pInfo = instanceData;
if (pInfo->zBuf) {
Tcl_Free((void *) pInfo->zBuf);
inflateEnd(&pInfo->stream);
}
if (pInfo->chan) {
Tcl_Close(interp, pInfo->chan);
Tcl_DeleteExitHandler(vfsExit, pInfo);
}
Tcl_Free((void *) pInfo);
return TCL_OK;
}
/*
* The TCL I/O system calls this function to actually read information from a
* ZVFS file.
*/
static int
vfsInput(
ClientData instanceData, /* The channel to read from */
char *buf, /* Buffer to fill */
int toRead, /* Requested number of bytes */
int *pErrorCode) /* Location of error flag */
{
ZvfsChannelInfo* pInfo = instanceData;
if (toRead > pInfo->nByte) {
toRead = pInfo->nByte;
}
if (toRead == 0) {
return 0;
}
if (pInfo->isCompressed) {
int err = Z_OK;
z_stream *stream = &pInfo->stream;
stream->next_out = (unsigned char *) buf;
stream->avail_out = toRead;
while (stream->avail_out) {
if (!stream->avail_in) {
int len = pInfo->nByteCompr;
if (len > COMPR_BUF_SIZE) {
len = COMPR_BUF_SIZE;
}
len = Tcl_Read(pInfo->chan, (char *) pInfo->zBuf, len);
pInfo->nByteCompr -= len;
stream->next_in = pInfo->zBuf;
stream->avail_in = len;
}
err = inflate(stream, Z_NO_FLUSH);
if (err) {
break;
}
}
if (err == Z_STREAM_END) {
if (stream->avail_out != 0) {
*pErrorCode = err; /* premature end */
return -1;
}
}else if (err) {
*pErrorCode = err; /* some other zlib error */
return -1;
}
} else {
toRead = Tcl_Read(pInfo->chan, buf, toRead);
}
pInfo->nByte -= toRead;
pInfo->readSoFar += toRead;
*pErrorCode = 0;
return toRead;
}
/*
* Write to a ZVFS file. ZVFS files are always read-only, so this routine
* always returns an error.
*/
static int
vfsOutput(
ClientData instanceData, /* The channel to write to */
const char *buf, /* Data to be stored. */
int toWrite, /* Number of bytes to write. */
int *pErrorCode) /* Location of error flag. */
{
*pErrorCode = EINVAL;
return -1;
}
/*
* Move the file pointer so that the next byte read will be "offset".
*/
static int
vfsSeek(
ClientData instanceData, /* The file structure */
long offset, /* Offset to seek to */
int mode, /* One of SEEK_CUR, SEEK_SET or SEEK_END */
int *pErrorCode) /* Write the error code here */
{
ZvfsChannelInfo* pInfo = instanceData;
switch (mode) {
case SEEK_CUR:
offset += pInfo->readSoFar;
break;
case SEEK_END:
offset += pInfo->readSoFar + pInfo->nByte;
break;
default:
/* Do nothing */
break;
}
if (offset < 0) {
offset = 0;
}
if (!pInfo->isCompressed) {
Tcl_Seek(pInfo->chan, offset + pInfo->startOfData, SEEK_SET);
pInfo->nByte = pInfo->nData;
pInfo->readSoFar = offset;
} else {
if (offset < pInfo->readSoFar) {
z_stream *stream = &pInfo->stream;
inflateEnd(stream);
stream->zalloc = (alloc_func)0;
stream->zfree = (free_func)0;
stream->opaque = (voidpf)0;
stream->avail_in = 2;
stream->next_in = pInfo->zBuf;
pInfo->zBuf[0] = 0x78;
pInfo->zBuf[1] = 0x01;
inflateInit(&pInfo->stream);
Tcl_Seek(pInfo->chan, pInfo->startOfData, SEEK_SET);
pInfo->nByte += pInfo->readSoFar;
pInfo->nByteCompr = pInfo->nData;
pInfo->readSoFar = 0;
}
while (pInfo->readSoFar < offset) {
int toRead, errCode;
char zDiscard[100];
toRead = offset - pInfo->readSoFar;
if (toRead > sizeof(zDiscard)) {
toRead = sizeof(zDiscard);
}
vfsInput(instanceData, zDiscard, toRead, &errCode);
}
}
return pInfo->readSoFar;
}
/*
* Handle events on the channel. ZVFS files do not generate events, so this
* is a no-op.
*/
static void
vfsWatchChannel(
ClientData instanceData, /* Channel to watch */
int mask) /* Events of interest */
{
return;
}
/*
* Called to retrieve the underlying file handle for this ZVFS file. As the
* ZVFS file has no underlying file handle, this is a no-op.
*/
static int
vfsGetFile(
ClientData instanceData, /* Channel to query */
int direction, /* Direction of interest */
ClientData* handlePtr) /* Space to the handle into */
{
return TCL_ERROR;
}
/*
* This structure describes the channel type structure for access to the ZVFS.
*/
static Tcl_ChannelType vfsChannelType = {
"vfs", /* Type name. */
NULL, /* Set blocking/nonblocking behaviour.
* NULL'able */
vfsClose, /* Close channel, clean instance data */
vfsInput, /* Handle read request */
vfsOutput, /* Handle write request */
vfsSeek, /* Move location of access point. NULL'able */
NULL, /* Set options. NULL'able */
NULL, /* Get options. NULL'able */
vfsWatchChannel, /* Initialize notifier */
vfsGetFile /* Get OS handle from the channel. */
};
/*
* This routine attempts to do an open of a file. Check to see if the file is
* located in the ZVFS. If so, then open a channel for reading the file. If
* not, return NULL.
*/
static Tcl_Channel
ZvfsFileOpen(
Tcl_Interp *interp, /* The TCL interpreter doing the open */
char *zFilename, /* Name of the file to open */
char *modeString, /* Mode string for the open (ignored) */
int permissions) /* Permissions for a newly created file
* (ignored). */
{
ZvfsFile *pFile;
ZvfsChannelInfo *pInfo;
Tcl_Channel chan;
static int count = 1;
char zName[50];
unsigned char zBuf[50];
pFile = ZvfsLookup(zFilename);
if (pFile == 0) {
return NULL;
}
openarch = 1;
chan = Tcl_OpenFileChannel(interp, pFile->pArchive->zName, "r", 0);
openarch = 0;
if (chan == 0) {
return 0;
}
if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
|| Tcl_SetChannelOption(interp, chan, "-encoding", "binary")){
/* this should never happen */
Tcl_Close(0, chan);
return 0;
}
Tcl_Seek(chan, pFile->iOffset, SEEK_SET);
Tcl_Read(chan, (char *) zBuf, 30);
if (memcmp(zBuf, "\120\113\03\04", 4)) {
if (interp) {
Tcl_AppendResult(interp, "local header mismatch: ", NULL);
}
Tcl_Close(interp, chan);
return 0;
}
pInfo = (void *) Tcl_Alloc(sizeof(*pInfo));
pInfo->chan = chan;
Tcl_CreateExitHandler(vfsExit, pInfo);
pInfo->isCompressed = INT16(zBuf, 8);
if (pInfo->isCompressed) {
z_stream *stream = &pInfo->stream;
pInfo->zBuf = (void *) Tcl_Alloc(COMPR_BUF_SIZE);
stream->zalloc = NULL;
stream->zfree = NULL;
stream->opaque = NULL;
stream->avail_in = 2;
stream->next_in = pInfo->zBuf;
pInfo->zBuf[0] = 0x78;
pInfo->zBuf[1] = 0x01;
inflateInit(&pInfo->stream);
} else {
pInfo->zBuf = 0;
}
pInfo->nByte = INT32(zBuf, 22);
pInfo->nByteCompr = pInfo->nData = INT32(zBuf, 18);
pInfo->readSoFar = 0;
Tcl_Seek(chan, INT16(zBuf, 26) + INT16(zBuf, 28), SEEK_CUR);
pInfo->startOfData = Tcl_Tell(chan);
sprintf(zName, "zvfs_%x",count++);
chan = Tcl_CreateChannel(&vfsChannelType, zName, pInfo, TCL_READABLE);
return chan;
}
/*
* This routine does a stat() system call for a ZVFS file.
*/
static int
Tobe_FSStatProc(
Tcl_Obj *pathObj,
Tcl_StatBuf *buf)
{
char *path=Tcl_GetString(pathObj);
ZvfsFile *pFile;
pFile = ZvfsLookup(path);
if (pFile == 0) {
return -1;
}
memset(buf, 0, sizeof(*buf));
if (pFile->isdir) {
buf->st_mode = 040555;
} else {
buf->st_mode = (0100000|pFile->permissions);
}
buf->st_ino = 0;
buf->st_size = pFile->nByte;
buf->st_mtime = pFile->timestamp;
buf->st_ctime = pFile->timestamp;
buf->st_atime = pFile->timestamp;
return 0;
}
/*
* This routine does an access() system call for a ZVFS file.
*/
static int
Tobe_FSAccessProc(
Tcl_Obj *pathPtr,
int mode)
{
char *path=Tcl_GetString(pathPtr);
ZvfsFile *pFile;
if (mode & 3) {
return -1;
}
pFile = ZvfsLookup(path);
if (pFile == 0) {
return -1;
}
return 0;
}
Tcl_Channel
Tobe_FSOpenFileChannelProc(
Tcl_Interp *interp,
Tcl_Obj *pathPtr,
int mode,
int permissions)
{
static int inopen=0;
Tcl_Channel chan;
if (inopen) {
puts("recursive zvfs open");
return NULL;
}
inopen = 1;
/* if (mode != O_RDONLY) return NULL; */
chan = ZvfsFileOpen(interp, Tcl_GetString(pathPtr), 0, permissions);
inopen = 0;
return chan;
}
Tcl_Obj* Tobe_FSFilesystemSeparatorProc(Tcl_Obj *pathPtr) {
return Tcl_NewStringObj("/",-1);;
}
/*
* Function to process a 'Tobe_FSMatchInDirectory()'. If not implemented,
* then glob and recursive copy functionality will be lacking in the
* filesystem.
*/
int
Tobe_FSMatchInDirectoryProc(
Tcl_Interp* interp,
Tcl_Obj *result,
Tcl_Obj *pathPtr,
const char *pattern,
Tcl_GlobTypeData * types)
{
Tcl_HashEntry *pEntry;
Tcl_HashSearch sSearch;
int scnt, len, l, dirglob, dirmnt;
char *zPattern = NULL, *zp=Tcl_GetStringFromObj(pathPtr,&len);
if (!zp) {
return TCL_ERROR;
}
if (pattern != NULL) {
l = strlen(pattern);
if (!zp) {
zPattern = Tcl_Alloc(len + 1);
memcpy(zPattern, pattern, len + 1);
} else {
zPattern = Tcl_Alloc(len + l + 3);
sprintf(zPattern, "%s%s%s", zp, zp[len-1]=='/'?"":"/", pattern);
}
scnt = strchrcnt(zPattern, '/');
}
dirglob = (types && types->type && (types->type&TCL_GLOB_TYPE_DIR));
dirmnt = (types && types->type && (types->type&TCL_GLOB_TYPE_MOUNT));
if (strcmp(zp, "/") == 0 && strcmp(zPattern, ".*") == 0) {
/*TODO: What goes here?*/
}
for (pEntry = Tcl_FirstHashEntry(&local.fileHash, &sSearch);
pEntry; pEntry = Tcl_NextHashEntry(&sSearch)){
ZvfsFile *pFile = Tcl_GetHashValue(pEntry);
char *z = pFile->zName;
if (zPattern != NULL) {
if (Tcl_StringCaseMatch(z, zPattern, 0) == 0 ||
(scnt != pFile->depth /* && !dirglob */)) { // TODO: ???
continue;
}
} else {
if (strcmp(zp, z)) {
continue;
}
}
if (dirmnt) {
if (pFile->isdir != 1) {
continue;
}
} else if (dirglob) {
if (!pFile->isdir) {
continue;
}
} else if (types && !(types->type & TCL_GLOB_TYPE_DIR)) {
if (pFile->isdir) {
continue;
}
}
Tcl_ListObjAppendElement(interp, result, Tcl_NewStringObj(z, -1));
}
if (zPattern) {
Tcl_Free(zPattern);
}
return TCL_OK;
}
/*
* Function to check whether a path is in this filesystem. This is the most
* important filesystem procedure.
*/
int
Tobe_FSPathInFilesystemProc(
Tcl_Obj *pathPtr,
ClientData *clientDataPtr)
{
ZvfsFile *zFile;
char *path = Tcl_GetString(pathPtr);
if (openarch) {
return -1;
}
zFile = ZvfsLookup(path);
if (zFile != NULL && strcmp(path, zFile->pArchive->zName)) {
return TCL_OK;
}
return -1;
}
Tcl_Obj *
Tobe_FSListVolumesProc(void)
{
Tcl_HashEntry *pEntry; /* Hash table entry */
Tcl_HashSearch zSearch; /* Search all mount points */
ZvfsArchive *pArchive; /* The ZIP archive being mounted */
Tcl_Obj *pVols = NULL, *pVol;
pEntry = Tcl_FirstHashEntry(&local.archiveHash,&zSearch);
while (pEntry) {
pArchive = Tcl_GetHashValue(pEntry);
if (pArchive) {
if (!pVols) {
pVols = Tcl_NewListObj(0, 0);
Tcl_IncrRefCount(pVols);
}
pVol = Tcl_NewStringObj(pArchive->zMountPoint, -1);
Tcl_ListObjAppendElement(NULL, pVols, pVol);
}
pEntry = Tcl_NextHashEntry(&zSearch);
}
return pVols;
}
const char * const*
Tobe_FSFileAttrStringsProc(
Tcl_Obj *pathPtr,
Tcl_Obj** objPtrRef)
{
char *path = Tcl_GetString(pathPtr);
#ifdef __WIN32__
static const char *attrs[] = {
"-archive", "-hidden", "-readonly", "-system", "-shortname", 0
};
#else
static const char *attrs[] = {
"-group", "-owner", "-permissions", 0
};
#endif
if (ZvfsLookup(path) == 0) {
return NULL;
}
return attrs;
}
int
Tobe_FSFileAttrsGetProc(
Tcl_Interp *interp,
int index,
Tcl_Obj *pathPtr,
Tcl_Obj **objPtrRef)
{
char *path = Tcl_GetString(pathPtr);
#ifndef __WIN32__
char buf[50];
#endif
ZvfsFile *zFile = ZvfsLookup(path);
if (zFile == 0) {
return TCL_ERROR;
}
switch (index) {
#ifdef __WIN32__
case 0: /* -archive */
*objPtrRef = Tcl_NewStringObj("0", -1); break;
case 1: /* -hidden */
*objPtrRef = Tcl_NewStringObj("0", -1); break;
case 2: /* -readonly */
*objPtrRef = Tcl_NewStringObj("", -1); break;
case 3: /* -system */
*objPtrRef = Tcl_NewStringObj("", -1); break;
case 4: /* -shortname */
*objPtrRef = Tcl_NewStringObj("", -1);
#else
case 0: /* -group */
*objPtrRef = Tcl_NewStringObj("", -1); break;
case 1: /* -owner */
*objPtrRef = Tcl_NewStringObj("", -1); break;
case 2: /* -permissions */
sprintf(buf, "%03o", zFile->permissions);
*objPtrRef = Tcl_NewStringObj(buf, -1); break;
#endif
}
return TCL_OK;
}
/****************************************************/
/*
* Function to unload a previously successfully loaded file. If load was
* implemented, then this should also be implemented, if there is any cleanup
* action required.
*/
/* We have to declare the utime structure here. */
int Tobe_FSUtimeProc(Tcl_Obj *pathPtr, struct utimbuf *tval) { return 0; }
int Tobe_FSFileAttrsSetProc(Tcl_Interp *interp, int index, Tcl_Obj *pathPtr,
Tcl_Obj *objPtr) { return 0; }
static Tcl_Filesystem Tobe_Filesystem = {
"tobe", /* The name of the filesystem. */
sizeof(Tcl_Filesystem), /* Length of this structure, so future binary
* compatibility can be assured. */
TCL_FILESYSTEM_VERSION_1, /* Version of the filesystem type. */
Tobe_FSPathInFilesystemProc,/* Function to check whether a path is in this
* filesystem. This is the most important
* filesystem procedure. */
NULL, /* Function to duplicate internal fs rep. May
* be NULL (but then fs is less efficient). */
NULL, /* Function to free internal fs rep. Must be
* implemented, if internal representations
* need freeing, otherwise it can be NULL. */
NULL,
/* Function to convert internal representation
* to a normalized path. Only required if the
* fs creates pure path objects with no
* string/path representation. */
NULL,
/* Function to create a filesystem-specific
* internal representation. May be NULL if
* paths have no internal representation, or
* if the Tobe_FSPathInFilesystemProc for this
* filesystem always immediately creates an
* internal representation for paths it
* accepts. */
NULL, /* Function to normalize a path. Should be
* implemented for all filesystems which can
* have multiple string representations for
* the same path object. */
NULL,
/* Function to determine the type of a path in
* this filesystem. May be NULL. */
Tobe_FSFilesystemSeparatorProc,
/* Function to return the separator
* character(s) for this filesystem. Must be
* implemented. */
Tobe_FSStatProc, /* Function to process a 'Tobe_FSStat()' call.
* Must be implemented for any reasonable
* filesystem. */
Tobe_FSAccessProc, /* Function to process a 'Tobe_FSAccess()'
* call. Must be implemented for any
* reasonable filesystem. */
Tobe_FSOpenFileChannelProc, /* Function to process a
* 'Tobe_FSOpenFileChannel()' call. Must be
* implemented for any reasonable
* filesystem. */
Tobe_FSMatchInDirectoryProc,/* Function to process a
* 'Tobe_FSMatchInDirectory()'. If not
* implemented, then glob and recursive copy
* functionality will be lacking in the
* filesystem. */
Tobe_FSUtimeProc, /* Function to process a 'Tobe_FSUtime()'
* call. Required to allow setting (not
* reading) of times with 'file mtime', 'file
* atime' and the open-r/open-w/fcopy
* implementation of 'file copy'. */
NULL, /* Function to process a 'Tobe_FSLink()' call.
* Should be implemented only if the
* filesystem supports links. */
Tobe_FSListVolumesProc, /* Function to list any filesystem volumes
* added by this filesystem. Should be
* implemented only if the filesystem adds
* volumes at the head of the filesystem. */
Tobe_FSFileAttrStringsProc, /* Function to list all attributes strings
* which are valid for this filesystem. If
* not implemented the filesystem will not
* support the 'file attributes' command.
* This allows arbitrary additional
* information to be attached to files in the
* filesystem. */
Tobe_FSFileAttrsGetProc, /* Function to process a
* 'Tobe_FSFileAttrsGet()' call, used by 'file
* attributes'. */
Tobe_FSFileAttrsSetProc, /* Function to process a
* 'Tobe_FSFileAttrsSet()' call, used by 'file
* attributes'. */
NULL, /* Function to process a
* 'Tobe_FSCreateDirectory()' call. Should be
* implemented unless the FS is read-only. */
NULL, /* Function to process a
* 'Tobe_FSRemoveDirectory()' call. Should be
* implemented unless the FS is read-only. */
NULL, /* Function to process a 'Tobe_FSDeleteFile()'
* call. Should be implemented unless the FS
* is read-only. */
NULL, /* Function to process a 'Tobe_FSCopyFile()'
* call. If not implemented Tcl will fall
* back on open-r, open-w and fcopy as a
* copying mechanism. */
NULL, /* Function to process a 'Tobe_FSRenameFile()'
* call. If not implemented, Tcl will fall
* back on a copy and delete mechanism. */
NULL, /* Function to process a
* 'Tobe_FSCopyDirectory()' call. If not
* implemented, Tcl will fall back on a
* recursive create-dir, file copy
* mechanism. */
NULL, /* Function to process a 'Tobe_FSLoadFile()'
* call. If not implemented, Tcl will fall
* back on a copy to native-temp followed by a
* Tobe_FSLoadFile on that temporary copy. */
NULL, /* Function to unload a previously
* successfully loaded file. If load was
* implemented, then this should also be
* implemented, if there is any cleanup action
* required. */
NULL, /* Function to process a 'Tobe_FSGetCwd()'
* call. Most filesystems need not implement
* this. It will usually only be called once,
* if 'getcwd' is called before 'chdir'. May
* be NULL. */
NULL, /* Function to process a 'Tobe_FSChdir()'
* call. If filesystems do not implement this,
* it will be emulated by a series of
* directory access checks. Otherwise, virtual
* filesystems which do implement it need only
* respond with a positive return result if
* the dirName is a valid directory in their
* filesystem. They need not remember the
* result, since that will be automatically
* remembered for use by GetCwd. Real
* filesystems should carry out the correct
* action (i.e. call the correct system
* 'chdir' api). If not implemented, then 'cd'
* and 'pwd' will fail inside the
* filesystem. */
};
//////////////////////////////////////////////////////////////
void (*Zvfs_PostInit)(Tcl_Interp *) = 0;
static int ZvfsAppendObjCmd(void *NotUsed, Tcl_Interp *interp, int objc, Tcl_Obj *const* objv);
static int ZvfsAddObjCmd(void *NotUsed, Tcl_Interp *interp, int objc, Tcl_Obj *const* objv);
static int ZvfsDumpObjCmd(void *NotUsed, Tcl_Interp *interp, int objc, Tcl_Obj *const* objv);
static int ZvfsStartObjCmd(void *NotUsed, Tcl_Interp *interp, int objc, Tcl_Obj *const* objv);
static int Zvfs_Common_Init(Tcl_Interp *interp) {
if (local.isInit) return TCL_OK;
/* One-time initialization of the ZVFS */
if(Tcl_FSRegister(interp, &Tobe_Filesystem)) {
return TCL_ERROR;
}
Tcl_InitHashTable(&local.fileHash, TCL_STRING_KEYS);
Tcl_InitHashTable(&local.archiveHash, TCL_STRING_KEYS);
local.isInit = 1;
return TCL_OK;
}
/*
* Initialize the ZVFS system.
*/
int
Zvfs_doInit(
Tcl_Interp *interp,
int safe)
{
#ifdef USE_TCL_STUBS
if (Tcl_InitStubs(interp, "8.0", 0) == 0) {
return TCL_ERROR;
}
#endif
Tcl_StaticPackage(interp, "zvfs", TclZvfsInit, Tcl_Zvfs_SafeInit);
if (!safe) {
Tcl_CreateObjCommand(interp, "zvfs::mount", ZvfsMountObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "zvfs::unmount", ZvfsUnmountObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "zvfs::append", ZvfsAppendObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "zvfs::add", ZvfsAddObjCmd, 0, 0);
}
Tcl_CreateObjCommand(interp, "zvfs::exists", ZvfsExistsObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "zvfs::info", ZvfsInfoObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "zvfs::list", ZvfsListObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "zvfs::dump", ZvfsDumpObjCmd, 0, 0);
Tcl_CreateObjCommand(interp, "zvfs::start", ZvfsStartObjCmd, 0, 0);
Tcl_SetVar(interp, "::zvfs::auto_ext",
".tcl .tk .itcl .htcl .txt .c .h .tht", TCL_GLOBAL_ONLY);
/* Tcl_CreateObjCommand(interp, "zip::open", ZipOpenObjCmd, 0, 0); */
if(Zvfs_Common_Init(interp)) {
return TCL_ERROR;
}
if (Zvfs_PostInit) {
Zvfs_PostInit(interp);
}
return TCL_OK;
}
/*
** Boot a shell, mount the executable's VFS, detect main.tcl
*/
int Tcl_Zvfs_Boot(const char *archive,const char *vfsmountpoint,const char *initscript) {
FILE *fout;
Zvfs_Common_Init(NULL);
if(!vfsmountpoint) {
vfsmountpoint="/zvfs";
}
if(!initscript) {
initscript="main.tcl";
}
/* We have to initialize the virtual filesystem before calling
** Tcl_Init(). Otherwise, Tcl_Init() will not be able to find
** its startup script files.
*/
if(!Tcl_Zvfs_Mount(NULL, archive, vfsmountpoint)) {
Tcl_DString filepath;
Tcl_DString preinit;
Tcl_Obj *vfsinitscript;
Tcl_Obj *vfstcllib;
Tcl_Obj *vfstklib;
Tcl_Obj *vfspreinit;
Tcl_DStringInit(&filepath);
Tcl_DStringInit(&preinit);
Tcl_DStringInit(&filepath);
Tcl_DStringAppend(&filepath,vfsmountpoint,-1);
Tcl_DStringAppend(&filepath,"/",-1);
Tcl_DStringAppend(&filepath,initscript,-1);
vfsinitscript=Tcl_NewStringObj(Tcl_DStringValue(&filepath),-1);
Tcl_DStringFree(&filepath);
Tcl_DStringInit(&filepath);
Tcl_DStringAppend(&filepath,vfsmountpoint,-1);
Tcl_DStringAppend(&filepath,"/tcl8.6",-1);
vfstcllib=Tcl_NewStringObj(Tcl_DStringValue(&filepath),-1);
Tcl_DStringFree(&filepath);
Tcl_DStringInit(&filepath);
Tcl_DStringAppend(&filepath,vfsmountpoint,-1);
Tcl_DStringAppend(&filepath,"/tk8.6",-1);
vfstklib=Tcl_NewStringObj(Tcl_DStringValue(&filepath),-1);
Tcl_DStringFree(&filepath);
Tcl_IncrRefCount(vfsinitscript);
Tcl_IncrRefCount(vfstcllib);
Tcl_IncrRefCount(vfstklib);
if(Tcl_FSAccess(vfsinitscript,F_OK)==0) {
/* Startup script should be set before calling Tcl_AppInit */
fprintf(fout,"%s\n",Tcl_GetString(vfsinitscript));
Tcl_SetStartupScript(vfsinitscript,NULL);
}
if(Tcl_FSAccess(vfsinitscript,F_OK)==0) {
/* Startup script should be set before calling Tcl_AppInit */
Tcl_SetStartupScript(vfsinitscript,NULL);
} else {
Tcl_SetStartupScript(NULL,NULL);
}
if(Tcl_FSAccess(vfstcllib,F_OK)==0) {
Tcl_DStringAppend(&preinit,"\nset tcl_library ",-1);
Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstcllib));
}
if(Tcl_FSAccess(vfstklib,F_OK)==0) {
Tcl_DStringAppend(&preinit,"\nset tk_library ",-1);
Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstklib));
}
vfspreinit=Tcl_NewStringObj(Tcl_DStringValue(&preinit),-1);
/* NOTE: We never decr this refcount, lest the contents of the script be deallocated */
Tcl_IncrRefCount(vfspreinit);
TclSetPreInitScript(Tcl_GetString(vfspreinit));
Tcl_DecrRefCount(vfsinitscript);
Tcl_DecrRefCount(vfstcllib);
Tcl_DecrRefCount(vfstklib);
}
return TCL_OK;
}
int
TclZvfsInit(
Tcl_Interp *interp)
{
return Zvfs_doInit(interp, 0);
}
int
Tcl_Zvfs_SafeInit(
Tcl_Interp *interp)
{
return Zvfs_doInit(interp, 1);
}
/************************************************************************/
/************************************************************************/
/************************************************************************/
/*
* Implement the zvfs::dump command
*
* zvfs::dump ARCHIVE
*
* Each entry in the list returned is of the following form:
*
* {FILENAME DATE-TIME SPECIAL-FLAG OFFSET SIZE COMPRESSED-SIZE}
*/
static int
ZvfsDumpObjCmd(
void *NotUsed, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
Tcl_Obj *zFilenameObj;
Tcl_Channel chan;
ZFile *pList;
int rc;
Tcl_Obj *pResult;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "FILENAME");
return TCL_ERROR;
}
zFilenameObj=objv[1];
chan = Tcl_FSOpenFileChannel(interp, zFilenameObj, "r", 0);
if (chan == 0) {
return TCL_ERROR;
}
rc = ZvfsReadTOC(interp, chan, &pList);
if (rc == TCL_ERROR) {
deleteZFileList(pList);
return rc;
}
Tcl_Close(interp, chan);
pResult = Tcl_GetObjResult(interp);
while (pList) {
Tcl_Obj *pEntry = Tcl_NewObj();
ZFile *pNext;
char zDateTime[100];
Tcl_ListObjAppendElement(interp, pEntry,
Tcl_NewStringObj(pList->zName,-1));
translateDosTimeDate(zDateTime, pList->dosDate, pList->dosTime);
Tcl_ListObjAppendElement(interp, pEntry,
Tcl_NewStringObj(zDateTime, -1));
Tcl_ListObjAppendElement(interp, pEntry,
Tcl_NewIntObj(pList->isSpecial));
Tcl_ListObjAppendElement(interp, pEntry,
Tcl_NewIntObj(pList->iOffset));
Tcl_ListObjAppendElement(interp, pEntry, Tcl_NewIntObj(pList->nByte));
Tcl_ListObjAppendElement(interp, pEntry,
Tcl_NewIntObj(pList->nByteCompr));
Tcl_ListObjAppendElement(interp, pResult, pEntry);
pNext = pList->pNext;
Tcl_Free((void *) pList);
pList = pNext;
}
return TCL_OK;
}
/*
* Write a file record into a ZIP archive at the current position of the write
* cursor for channel "chan". Add a ZFile record for the file to *ppList. If
* an error occurs, leave an error message on interp and return TCL_ERROR.
* Otherwise return TCL_OK.
*/
static int
writeFile(
Tcl_Interp *interp, /* Leave an error message here */
Tcl_Channel out, /* Write the file here */
Tcl_Channel in, /* Read data from this file */
Tcl_Obj *zSrcPtr, /* Name the new ZIP file entry this */
Tcl_Obj *zDestPtr, /* Name the new ZIP file entry this */
ZFile **ppList) /* Put a ZFile struct for the new file here */
{
char *zDest=Tcl_GetString(zDestPtr);
z_stream stream;
ZFile *p;
int iEndOfData;
int nameLen;
int skip;
int toOut;
char zHdr[30];
char zInBuf[100000];
char zOutBuf[100000];
struct tm *tm;
time_t now;
Tcl_StatBuf stat;
/*
* Create a new ZFile structure for this file.
* TODO: fill in date/time etc.
*/
nameLen = strlen(zDest);
p = newZFile(nameLen, ppList);
strcpy(p->zName, zDest);
p->isSpecial = 0;
Tcl_FSStat(zSrcPtr, &stat);
now = stat.st_mtime;
tm = localtime(&now);
UnixTimeDate(tm, &p->dosDate, &p->dosTime);
p->iOffset = Tcl_Tell(out);
p->nByte = 0;
p->nByteCompr = 0;
p->nExtra = 0;
p->iCRC = 0;
p->permissions = stat.st_mode;
/*
* Fill in as much of the header as we know.
*/
put32(&zHdr[0], 0x04034b50);
put16(&zHdr[4], 0x0014);
put16(&zHdr[6], 0);
put16(&zHdr[8], 8);
put16(&zHdr[10], p->dosTime);
put16(&zHdr[12], p->dosDate);
put16(&zHdr[26], nameLen);
put16(&zHdr[28], 0);
/*
* Write the header and filename.
*/
Tcl_Write(out, zHdr, 30);
Tcl_Write(out, zDest, nameLen);
/*
* The first two bytes that come out of the deflate compressor are some
* kind of header that ZIP does not use. So skip the first two output
* bytes.
*/
skip = 2;
/*
* Write the compressed file. Compute the CRC as we progress.
*/
stream.zalloc = NULL;
stream.zfree = NULL;
stream.opaque = 0;
stream.avail_in = 0;
stream.next_in = (unsigned char *) zInBuf;
stream.avail_out = sizeof(zOutBuf);
stream.next_out = (unsigned char *) zOutBuf;
deflateInit(&stream, 9);
p->iCRC = crc32(0, 0, 0);
while (!Tcl_Eof(in)) {
if (stream.avail_in == 0) {
int amt = Tcl_Read(in, zInBuf, sizeof(zInBuf));
if (amt <= 0) {
break;
}
p->iCRC = crc32(p->iCRC, (unsigned char *) zInBuf, amt);
stream.avail_in = amt;
stream.next_in = (unsigned char *) zInBuf;
}
deflate(&stream, 0);
toOut = sizeof(zOutBuf) - stream.avail_out;
if (toOut > skip) {
Tcl_Write(out, &zOutBuf[skip], toOut - skip);
skip = 0;
} else {
skip -= toOut;
}
stream.avail_out = sizeof(zOutBuf);
stream.next_out = (unsigned char *) zOutBuf;
}
do{
stream.avail_out = sizeof(zOutBuf);
stream.next_out = (unsigned char *) zOutBuf;
deflate(&stream, Z_FINISH);
toOut = sizeof(zOutBuf) - stream.avail_out;
if (toOut > skip) {
Tcl_Write(out, &zOutBuf[skip], toOut - skip);
skip = 0;
} else {
skip -= toOut;
}
} while (stream.avail_out == 0);
p->nByte = stream.total_in;
p->nByteCompr = stream.total_out - 2;
deflateEnd(&stream);
Tcl_Flush(out);
/*
* Remember were we are in the file. Then go back and write the header,
* now that we know the compressed file size.
*/
iEndOfData = Tcl_Tell(out);
Tcl_Seek(out, p->iOffset, SEEK_SET);
put32(&zHdr[14], p->iCRC);
put32(&zHdr[18], p->nByteCompr);
put32(&zHdr[22], p->nByte);
Tcl_Write(out, zHdr, 30);
Tcl_Seek(out, iEndOfData, SEEK_SET);
/*
* Close the input file.
*/
Tcl_Close(interp, in);
return TCL_OK;
}
/*
* The arguments are two lists of ZFile structures sorted by iOffset. Either
* or both list may be empty. This routine merges the two lists together into
* a single sorted list and returns a pointer to the head of the unified list.
*
* This is part of the merge-sort algorithm.
*/
static ZFile *
mergeZFiles(
ZFile *pLeft,
ZFile *pRight)
{
ZFile fakeHead;
ZFile *pTail;
pTail = &fakeHead;
while (pLeft && pRight) {
ZFile *p;
if (pLeft->iOffset <= pRight->iOffset) {
p = pLeft;
pLeft = p->pNext;
} else {
p = pRight;
pRight = p->pNext;
}
pTail->pNext = p;
pTail = p;
}
if (pLeft) {
pTail->pNext = pLeft;
} else if (pRight) {
pTail->pNext = pRight;
} else {
pTail->pNext = 0;
}
return fakeHead.pNext;
}
/*
* Sort a ZFile list so in accending order by iOffset.
*/
static ZFile *
sortZFiles(
ZFile *pList)
{
#define NBIN 30
int i;
ZFile *p;
ZFile *aBin[NBIN+1];
for (i=0; i<=NBIN; i++) {
aBin[i] = 0;
}
while (pList) {
p = pList;
pList = p->pNext;
p->pNext = 0;
for (i=0; i<NBIN && aBin[i]; i++) {
p = mergeZFiles(aBin[i],p);
aBin[i] = 0;
}
aBin[i] = aBin[i] ? mergeZFiles(aBin[i], p) : p;
}
p = 0;
for (i=0; i<=NBIN; i++) {
if (aBin[i] == 0) {
continue;
}
p = mergeZFiles(p, aBin[i]);
}
return p;
}
/*
* Write a ZIP archive table of contents to the given channel.
*/
static void
writeTOC(
Tcl_Channel chan,
ZFile *pList)
{
int iTocStart, iTocEnd;
int nEntry = 0;
int i;
char zBuf[100];
iTocStart = Tcl_Tell(chan);
for (; pList; pList=pList->pNext) {
if (pList->isSpecial) {
continue;
}
put32(&zBuf[0], 0x02014b50);
put16(&zBuf[4], 0x0317);
put16(&zBuf[6], 0x0014);
put16(&zBuf[8], 0);
put16(&zBuf[10], pList->nByte>pList->nByteCompr ? 0x0008 : 0x0000);
put16(&zBuf[12], pList->dosTime);
put16(&zBuf[14], pList->dosDate);
put32(&zBuf[16], pList->iCRC);
put32(&zBuf[20], pList->nByteCompr);
put32(&zBuf[24], pList->nByte);
put16(&zBuf[28], strlen(pList->zName));
put16(&zBuf[30], 0);
put16(&zBuf[32], pList->nExtra);
put16(&zBuf[34], 1);
put16(&zBuf[36], 0);
put32(&zBuf[38], pList->permissions<<16);
put32(&zBuf[42], pList->iOffset);
Tcl_Write(chan, zBuf, 46);
Tcl_Write(chan, pList->zName, strlen(pList->zName));
for (i=pList->nExtra; i>0; i-=40) {
int toWrite = i<40 ? i : 40;
/* CAREFUL! String below is intentionally 40 spaces! */
Tcl_Write(chan," ",
toWrite);
}
nEntry++;
}
iTocEnd = Tcl_Tell(chan);
put32(&zBuf[0], 0x06054b50);
put16(&zBuf[4], 0);
put16(&zBuf[6], 0);
put16(&zBuf[8], nEntry);
put16(&zBuf[10], nEntry);
put32(&zBuf[12], iTocEnd - iTocStart);
put32(&zBuf[16], iTocStart);
put16(&zBuf[20], 0);
Tcl_Write(chan, zBuf, 22);
Tcl_Flush(chan);
}
/*
* Implementation of the zvfs::append command.
*
* zvfs::append ARCHIVE (SOURCE DESTINATION)*
*
* This command reads SOURCE files and appends them (using the name
* DESTINATION) to the zip archive named ARCHIVE. A new zip archive is created
* if it does not already exist. If ARCHIVE refers to a file which exists but
* is not a zip archive, then this command turns ARCHIVE into a zip archive by
* appending the necessary records and the table of contents. Treat all files
* as binary.
*
* Note: No dup checking is done, so multiple occurances of the same file is
* allowed.
*/
static int
ZvfsAppendObjCmd(
void *NotUsed, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
Tcl_Obj *zArchiveObj;
Tcl_Channel chan;
ZFile *pList = NULL, *pToc;
int rc = TCL_OK, i;
/*
* Open the archive and read the table of contents
*/
if (objc<2 || (objc&1)!=0) {
Tcl_WrongNumArgs(interp, 1, objv, "ARCHIVE (SRC DEST)+");
return TCL_ERROR;
}
zArchiveObj=objv[1];
chan = Tcl_FSOpenFileChannel(interp, zArchiveObj, "r+", 0644);
if (chan == 0) {
chan = Tcl_FSOpenFileChannel(interp, zArchiveObj, "w+", 0644);
if (chan == 0) {
return TCL_ERROR;
}
}
if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
|| Tcl_SetChannelOption(interp, chan, "-encoding", "binary")){
/* this should never happen */
Tcl_Close(0, chan);
return TCL_ERROR;
}
if (Tcl_Seek(chan, 0, SEEK_END) == 0) {
/* Null file is ok, we're creating new one. */
} else {
Tcl_Seek(chan, 0, SEEK_SET);
if (ZvfsReadTOC(interp, chan, &pList) == TCL_ERROR) {
deleteZFileList(pList);
Tcl_Close(interp, chan);
return TCL_ERROR;
}
rc = TCL_OK;
}
/*
* Move the file pointer to the start of the table of contents.
*/
for (pToc=pList; pToc; pToc=pToc->pNext) {
if (pToc->isSpecial && strcmp(pToc->zName, "*TOC*") == 0) {
break;
}
}
if (pToc) {
Tcl_Seek(chan, pToc->iOffset, SEEK_SET);
} else {
Tcl_Seek(chan, 0, SEEK_END);
}
/*
* Add new files to the end of the archive.
*/
for (i=2; rc==TCL_OK && i<objc; i+=2) {
Tcl_Obj *zSrcObj=objv[i];
Tcl_Obj *zDestObj=objv[i+1];
Tcl_Channel in;
/*
* Open the file that is to be added to the ZIP archive
*/
in = Tcl_FSOpenFileChannel(interp, zSrcObj, "r", 0);
if (in == 0) {
break;
}
if (Tcl_SetChannelOption(interp, in, "-translation", "binary")
|| Tcl_SetChannelOption(interp, in, "-encoding", "binary")){
/* this should never happen */
Tcl_Close(0, in);
rc = TCL_ERROR;
break;
}
rc = writeFile(interp, chan, in, zSrcObj, zDestObj, &pList);
}
/*
* Write the table of contents at the end of the archive.
*/
if (rc == TCL_OK) {
pList = sortZFiles(pList);
writeTOC(chan, pList);
}
/*
* Close the channel and exit
*/
deleteZFileList(pList);
Tcl_Close(interp, chan);
return rc;
}
static const char *
GetExtension(
const char *name)
{
const char *p, *lastSep;
#ifdef __WIN32__
lastSep = NULL;
for (p = name; *p != '\0'; p++) {
if (strchr("/\\:", *p) != NULL) {
lastSep = p;
}
}
#else
lastSep = strrchr(name, '/');
#endif
p = strrchr(name, '.');
if ((p != NULL) && (lastSep != NULL) && (lastSep > p)) {
p = NULL;
}
return p;
}
/*
* Implementation of the zvfs::add command.
*
* zvfs::add ?-fconfigure optpairs? ARCHIVE FILE1 FILE2 ...
*
* This command is similar to append in that it adds files to the zip archive
* named ARCHIVE, however file names are relative the current directory. In
* addition, fconfigure is used to apply option pairs to set upon opening of
* each file. Otherwise, default translation is allowed for those file
* extensions listed in the ::zvfs::auto_ext var. Binary translation will be
* used for unknown extensions.
*
* NOTE Use '-fconfigure {}' to use auto translation for all.
*/
static int
ZvfsAddObjCmd(
void *NotUsed, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
Tcl_Obj *zArchiveObj;
Tcl_Channel chan;
ZFile *pList = NULL, *pToc;
int rc = TCL_OK, i, j, oLen;
char *zOpts = NULL;
Tcl_Obj *confOpts = NULL;
int tobjc;
Tcl_Obj **tobjv;
Tcl_Obj *varObj = NULL;
/*
* Open the archive and read the table of contents
*/
if (objc > 3) {
zOpts = Tcl_GetStringFromObj(objv[1], &oLen);
if (!strncmp("-fconfigure", zOpts, oLen)) {
confOpts = objv[2];
if (TCL_OK != Tcl_ListObjGetElements(interp, confOpts,
&tobjc, &tobjv) || (tobjc%2)) {
return TCL_ERROR;
}
objc -= 2;
objv += 2;
}
}
if (objc == 2) {
return TCL_OK;
}
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-fconfigure OPTPAIRS? ARCHIVE FILE1 FILE2 ..");
return TCL_ERROR;
}
zArchiveObj = objv[1];
chan = Tcl_FSOpenFileChannel(interp, zArchiveObj, "r+", 0644);
if (chan == 0) {
chan = Tcl_FSOpenFileChannel(interp, zArchiveObj, "w+", 0644);
if (chan == 0) {
return TCL_ERROR;
}
}
if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
|| Tcl_SetChannelOption(interp, chan, "-encoding", "binary")){
/* this should never happen */
Tcl_Close(0, chan);
return TCL_ERROR;
}
if (Tcl_Seek(chan, 0, SEEK_END) == 0) {
/* Null file is ok, we're creating new one. */
} else {
Tcl_Seek(chan, 0, SEEK_SET);
if (ZvfsReadTOC(interp, chan, &pList) == TCL_ERROR) {
deleteZFileList(pList);
Tcl_Close(interp, chan);
return TCL_ERROR;
}
rc = TCL_OK;
}
/*
* Move the file pointer to the start of the table of contents.
*/
for (pToc=pList; pToc; pToc=pToc->pNext) {
if (pToc->isSpecial && strcmp(pToc->zName, "*TOC*") == 0) {
break;
}
}
if (pToc) {
Tcl_Seek(chan, pToc->iOffset, SEEK_SET);
} else {
Tcl_Seek(chan, 0, SEEK_END);
}
/*
* Add new files to the end of the archive.
*/
for (i=2; rc==TCL_OK && i<objc; i++) {
Tcl_Obj *zSrcObj=objv[i];
char *zSrc = Tcl_GetString(zSrcObj);
Tcl_Channel in;
/*
* Open the file that is to be added to the ZIP archive
*/
in = Tcl_FSOpenFileChannel(interp, zSrcObj, "r", 0);
if (in == 0) {
break;
}
if (confOpts == NULL) {
const char *ext = GetExtension(zSrc);
if (ext != NULL) {
/* Use auto translation for known text files. */
if (varObj == NULL) {
varObj = Tcl_GetVar2Ex(interp, "::zvfs::auto_ext", NULL,
TCL_GLOBAL_ONLY);
}
if (varObj && TCL_OK != Tcl_ListObjGetElements(interp, varObj,
&tobjc, &tobjv)) {
for (j=0; j<tobjc; j++) {
if (!strcmp(ext, Tcl_GetString(tobjv[j]))) {
break;
}
}
if (j >= tobjc) {
ext = NULL;
}
}
}
if (ext == NULL) {
if (Tcl_SetChannelOption(interp, in, "-translation", "binary")
|| Tcl_SetChannelOption(interp, in, "-encoding",
"binary")) {
/* this should never happen */
Tcl_Close(0, in);
rc = TCL_ERROR;
break;
}
}
} else {
for (j=0; j<tobjc; j+=2) {
if (Tcl_SetChannelOption(interp, in, Tcl_GetString(tobjv[j]),
Tcl_GetString(tobjv[j+1]))) {
Tcl_Close(0, in);
rc = TCL_ERROR;
break;
}
}
}
if (rc == TCL_OK) {
rc = writeFile(interp, chan, in, zSrcObj, zSrcObj, &pList);
}
}
/*
* Write the table of contents at the end of the archive.
*/
if (rc == TCL_OK) {
pList = sortZFiles(pList);
writeTOC(chan, pList);
}
/*
* Close the channel and exit
*/
deleteZFileList(pList);
Tcl_Close(interp, chan);
return rc;
}
/*
* Implementation of the zvfs::start command.
*
* zvfs::start ARCHIVE
*
* This command strips returns the offset of zip data.
*/
static int
ZvfsStartObjCmd(
void *NotUsed, /* Client data for this command */
Tcl_Interp *interp, /* The interpreter used to report errors */
int objc, /* Number of arguments */
Tcl_Obj *const* objv) /* Values of all arguments */
{
Tcl_Obj *zArchiveObj;
Tcl_Channel chan;
ZFile *pList = NULL;
int zipStart;
/*
* Open the archive and read the table of contents
*/
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "ARCHIVE");
return TCL_ERROR;
}
zArchiveObj=objv[1];
chan = Tcl_FSOpenFileChannel(interp, zArchiveObj, "r", 0644);
if (chan == 0) {
return TCL_ERROR;
}
if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
|| Tcl_SetChannelOption(interp, chan, "-encoding", "binary")){
/* this should never happen */
Tcl_Close(0, chan);
return TCL_ERROR;
}
if (Tcl_Seek(chan, 0, SEEK_END) == 0) {
Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
return TCL_OK;
}
Tcl_Seek(chan, 0, SEEK_SET);
if (ZvfsReadTOCStart(interp, chan, &pList, &zipStart) != TCL_OK) {
deleteZFileList(pList);
Tcl_Close(interp, chan);
Tcl_AppendResult(interp, "not an archive", 0);
return TCL_ERROR;
}
/*
* Close the channel and exit
*/
deleteZFileList(pList);
Tcl_Close(interp, chan);
Tcl_SetObjResult(interp, Tcl_NewIntObj(zipStart));
return TCL_OK;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|
Changes to library/http/http.tcl.
| ︙ | ︙ | |||
8 9 10 11 12 13 14 | # See the file "license.terms" for information on usage and redistribution of # this file, and for a DISCLAIMER OF ALL WARRANTIES. package require Tcl 8.6 # Keep this in sync with pkgIndex.tcl and with the install directories in # Makefiles package provide http 2.8.8 | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
package require Tcl 8.6
# Keep this in sync with pkgIndex.tcl and with the install directories in
# Makefiles
package provide http 2.8.8
puts [list LOADED [info script]]
namespace eval http {
# Allow resourcing to not clobber existing data
variable http
if {![info exists http]} {
array set http {
-accept */*
|
| ︙ | ︙ |
Added tools/mkVfs.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
proc cat fname {
set fname [open $fname r]
set data [read $fname]
close $fname
return $data
}
proc pkgIndexDir {root fout d1} {
puts [format {%*sIndexing %s} [expr {4 * [info level]}] {} \
[file tail $d1]]
set idx [string length $root]
foreach ftail [glob -directory $d1 -nocomplain -tails *] {
set f [file join $d1 $ftail]
if {[file isdirectory $f] && [string compare CVS $ftail]} {
pkgIndexDir $root $fout $f
} elseif {[file tail $f] eq "pkgIndex.tcl"} {
puts $fout "set dir \${VFSROOT}[string range $d1 $idx end]"
puts $fout [cat $f]
}
}
}
###
# Script to build the VFS file system
###
proc copyDir {d1 d2} {
puts [format {%*sCreating %s} [expr {4 * [info level]}] {} \
[file tail $d2]]
file delete -force -- $d2
file mkdir $d2
foreach ftail [glob -directory $d1 -nocomplain -tails *] {
set f [file join $d1 $ftail]
if {[file isdirectory $f] && [string compare CVS $ftail]} {
copyDir $f [file join $d2 $ftail]
} elseif {[file isfile $f]} {
file copy -force $f [file join $d2 $ftail]
if {$::tcl_platform(platform) eq {unix}} {
file attributes [file join $d2 $ftail] -permissions 0644
} else {
file attributes [file join $d2 $ftail] -readonly 1
}
}
}
if {$::tcl_platform(platform) eq {unix}} {
file attributes $d2 -permissions 0755
} else {
file attributes $d2 -readonly 1
}
}
if {[llength $argv] < 3} {
puts "Usage: VFS_ROOT TCLSRC_ROOT PLATFORM"
exit 1
}
set TCL_SCRIPT_DIR [lindex $argv 0]
set TCLSRC_ROOT [lindex $argv 1]
set PLATFORM [lindex $argv 2]
puts "Building [file tail $TCL_SCRIPT_DIR] for $PLATFORM"
copyDir ${TCLSRC_ROOT}/library ${TCL_SCRIPT_DIR}
if {$PLATFORM == "windows"} {
set ddedll [glob -nocomplain ${TCLSRC_ROOT}/win/tcldde*.dll]
puts "DDE DLL $ddedll"
if {$ddedll != {}} {
file copy $ddedll ${TCL_SCRIPT_DIR}/dde
}
set regdll [glob -nocomplain ${TCLSRC_ROOT}/win/tclreg*.dll]
puts "REG DLL $ddedll"
if {$regdll != {}} {
file copy $regdll ${TCL_SCRIPT_DIR}/reg
}
} else {
# Remove the dde and reg package paths
file delete -force ${TCL_SCRIPT_DIR}/dde
file delete -force ${TCL_SCRIPT_DIR}/reg
}
# For the following packages, cat their pkgIndex files to tclIndex
file attributes ${TCL_SCRIPT_DIR}/tclIndex -readonly 0
set fout [open ${TCL_SCRIPT_DIR}/tclIndex a]
puts $fout {#
# MANIFEST OF INCLUDED PACKAGES
#
set VFSROOT $dir
}
pkgIndexDir ${TCL_SCRIPT_DIR} $fout ${TCL_SCRIPT_DIR}
close $fout
exit 0
puts $fout {
# Save Tcl the trouble of hunting for these packages
}
set ddedll [glob -nocomplain ${TCLSRC_ROOT}/win/tcldde*.dll]
if {$ddedll != {}} {
puts $fout [cat ${TCL_SCRIPT_DIR}/dde/pkgIndex.tcl]
}
set regdll [glob -nocomplain ${TCLSRC_ROOT}/win/tclreg*.dll]
if {$regdll != {}} {
puts $fout [cat ${TCL_SCRIPT_DIR}/reg/pkgIndex.tcl]
}
close $fout
file attributes ${TCL_SCRIPT_DIR}/tclIndex -readonly 1
|
Changes to unix/Makefile.in.
| ︙ | ︙ | |||
163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# NATIVE_TCLSH is the name of a tclsh executable that is available *BEFORE*
# running make for the first time. Certain build targets (make genstubs) need
# it to be available on the PATH. This executable should *NOT* be required
# just to do a normal build although it can be required to run make dist.
# Do not use SHELL_ENV for NATIVE_TCLSH unless it is the tclsh being built.
EXE_SUFFIX = @EXEEXT@
TCL_EXE = tclsh${EXE_SUFFIX}
TCLTEST_EXE = tcltest${EXE_SUFFIX}
NATIVE_TCLSH = @TCLSH_PROG@
# The symbols below provide support for dynamic loading and shared libraries.
# See configure.in for a description of what the symbols mean. The values of
# the symbols are normally set by the configure script. You shouldn't normally
# need to modify any of these definitions by hand.
| > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# NATIVE_TCLSH is the name of a tclsh executable that is available *BEFORE*
# running make for the first time. Certain build targets (make genstubs) need
# it to be available on the PATH. This executable should *NOT* be required
# just to do a normal build although it can be required to run make dist.
# Do not use SHELL_ENV for NATIVE_TCLSH unless it is the tclsh being built.
EXE_SUFFIX = @EXEEXT@
TCL_EXE = tclsh${EXE_SUFFIX}
TCLKIT_EXE = tclkit${EXE_SUFFIX}
TCLKIT_LIB = tclkit${EXE_SUFFIX}
TCLTEST_EXE = tcltest${EXE_SUFFIX}
NATIVE_TCLSH = @TCLSH_PROG@
# The symbols below provide support for dynamic loading and shared libraries.
# See configure.in for a description of what the symbols mean. The values of
# the symbols are normally set by the configure script. You shouldn't normally
# need to modify any of these definitions by hand.
|
| ︙ | ︙ | |||
197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# this symbol to an empty string, in which case the shared libraries aren't
# built.
BUILD_DLTEST = @BUILD_DLTEST@
#BUILD_DLTEST =
TCL_LIB_FILE = @TCL_LIB_FILE@
#TCL_LIB_FILE = libtcl.a
# Generic lib name used in rules that apply to tcl and tk
LIB_FILE = ${TCL_LIB_FILE}
TCL_LIB_FLAG = @TCL_LIB_FLAG@
#TCL_LIB_FLAG = -ltcl
| > > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# this symbol to an empty string, in which case the shared libraries aren't
# built.
BUILD_DLTEST = @BUILD_DLTEST@
#BUILD_DLTEST =
TCL_LIB_FILE = @TCL_LIB_FILE@
#TCL_LIB_FILE = libtcl.a
TCL_KIT_LIB_FILE = @TCL_KIT_LIB_FILE@
#TCL_KIT_LIB_FILE = libtclkit.a
# Generic lib name used in rules that apply to tcl and tk
LIB_FILE = ${TCL_LIB_FILE}
TCL_LIB_FLAG = @TCL_LIB_FLAG@
#TCL_LIB_FLAG = -ltcl
|
| ︙ | ︙ | |||
354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
DTRACE_OBJ = tclDTrace.o
ZLIB_OBJS = Zadler32.o Zcompress.o Zcrc32.o Zdeflate.o Zinfback.o \
Zinffast.o Zinflate.o Zinftrees.o Ztrees.o Zuncompr.o Zzutil.o
TCL_OBJS = ${GENERIC_OBJS} ${UNIX_OBJS} ${NOTIFY_OBJS} ${COMPAT_OBJS} \
${OO_OBJS} @DL_OBJS@ @PLAT_OBJS@
OBJS = ${TCL_OBJS} ${TOMMATH_OBJS} @DTRACE_OBJ@ @ZLIB_OBJS@
TCL_DECLS = \
$(GENERIC_DIR)/tcl.decls \
$(GENERIC_DIR)/tclInt.decls \
$(GENERIC_DIR)/tclOO.decls \
| > > | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
DTRACE_OBJ = tclDTrace.o
ZLIB_OBJS = Zadler32.o Zcompress.o Zcrc32.o Zdeflate.o Zinfback.o \
Zinffast.o Zinflate.o Zinftrees.o Ztrees.o Zuncompr.o Zzutil.o
TCL_OBJS = ${GENERIC_OBJS} ${UNIX_OBJS} ${NOTIFY_OBJS} ${COMPAT_OBJS} \
${OO_OBJS} @DL_OBJS@ @PLAT_OBJS@
TCLKIT_OBJS = tclKitInit.o tclZipVfs.o
OBJS = ${TCL_OBJS} ${TOMMATH_OBJS} @DTRACE_OBJ@ @ZLIB_OBJS@
TCL_DECLS = \
$(GENERIC_DIR)/tcl.decls \
$(GENERIC_DIR)/tclInt.decls \
$(GENERIC_DIR)/tclOO.decls \
|
| ︙ | ︙ | |||
458 459 460 461 462 463 464 465 466 467 468 469 470 471 | $(GENERIC_DIR)/tclThreadJoin.c \ $(GENERIC_DIR)/tclThreadStorage.c \ $(GENERIC_DIR)/tclTimer.c \ $(GENERIC_DIR)/tclTrace.c \ $(GENERIC_DIR)/tclUtil.c \ $(GENERIC_DIR)/tclVar.c \ $(GENERIC_DIR)/tclAssembly.c \ $(GENERIC_DIR)/tclZlib.c OO_SRCS = \ $(GENERIC_DIR)/tclOO.c \ $(GENERIC_DIR)/tclOOBasic.c \ $(GENERIC_DIR)/tclOOCall.c \ $(GENERIC_DIR)/tclOODefineCmds.c \ | > | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | $(GENERIC_DIR)/tclThreadJoin.c \ $(GENERIC_DIR)/tclThreadStorage.c \ $(GENERIC_DIR)/tclTimer.c \ $(GENERIC_DIR)/tclTrace.c \ $(GENERIC_DIR)/tclUtil.c \ $(GENERIC_DIR)/tclVar.c \ $(GENERIC_DIR)/tclAssembly.c \ $(GENERIC_DIR)/tclZipVfs.obj \ $(GENERIC_DIR)/tclZlib.c OO_SRCS = \ $(GENERIC_DIR)/tclOO.c \ $(GENERIC_DIR)/tclOOBasic.c \ $(GENERIC_DIR)/tclOOCall.c \ $(GENERIC_DIR)/tclOODefineCmds.c \ |
| ︙ | ︙ | |||
603 604 605 606 607 608 609 610 611 612 613 614 615 | # Note: don't include DL_SRCS or MAC_OSX_SRCS in SRCS: most of those files # won't compile on the current machine, and they will cause problems for # things like "make depend". SRCS = $(GENERIC_SRCS) $(TOMMATH_SRCS) $(UNIX_SRCS) $(NOTIFY_SRCS) \ $(OO_SRCS) $(STUB_SRCS) @PLAT_SRCS@ @ZLIB_SRCS@ #-------------------------------------------------------------------------- # Start of rules #-------------------------------------------------------------------------- all: binaries libraries doc packages | > > > | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
# Note: don't include DL_SRCS or MAC_OSX_SRCS in SRCS: most of those files
# won't compile on the current machine, and they will cause problems for
# things like "make depend".
SRCS = $(GENERIC_SRCS) $(TOMMATH_SRCS) $(UNIX_SRCS) $(NOTIFY_SRCS) \
$(OO_SRCS) $(STUB_SRCS) @PLAT_SRCS@ @ZLIB_SRCS@
PWD=`pwd`
VFS_INSTALL_DIR=${PWD}/tclkit.vfs/tcl8.6
#--------------------------------------------------------------------------
# Start of rules
#--------------------------------------------------------------------------
all: binaries libraries doc packages
binaries: ${LIB_FILE} ${TCL_EXE} ${TCLKIT_EXE}
libraries:
doc:
# The following target is configured by autoconf to generate either a shared
# library or non-shared library for Tcl.
${LIB_FILE}: ${STUB_LIB_FILE} ${OBJS}
rm -f $@
@MAKE_LIB@
${STUB_LIB_FILE}: ${STUB_LIB_OBJS}
@if test "x${LIB_FILE}" = "xlibtcl${MAJOR_VERSION}.${MINOR_VERSION}.dll"; then \
(cd ${TOP_DIR}/win; ${MAKE} tcldde14.dll tclreg13.dll); \
fi
rm -f $@
@MAKE_STUB_LIB@
${TCL_KIT_LIB_FILE}: ${TCL_OBJS} ${TOMMATH_OBJS} ${ZLIB_OBJS}
rm -f $@
@MAKE_KIT_LIB@
# Make target which outputs the list of the .o contained in the Tcl lib useful
# to build a single big shared library containing Tcl and other extensions.
# Used for the Tcl Plugin. -- dl
# The dependency on OBJS is not there because we just want the list of objects
# here, not actually building them
tclLibObjs:
@echo ${OBJS}
# This targets actually build the objects needed for the lib in the above case
objs: ${OBJS}
${TCL_EXE}: ${TCLSH_OBJS} ${TCL_LIB_FILE} ${TCL_STUB_LIB_FILE}
${CC} ${CFLAGS} ${LDFLAGS} ${TCLSH_OBJS} \
@TCL_BUILD_LIB_SPEC@ ${TCL_STUB_LIB_FILE} ${LIBS} @EXTRA_TCLSH_LIBS@ \
${CC_SEARCH_FLAGS} -o ${TCL_EXE}
# Must be empty so it doesn't conflict with rule for ${TCL_EXE} above
${NATIVE_TCLSH}:
null.zip:
touch .empty
zip null.zip .empty
# Rather than force an install, pack the files we need into a
# file system under our control
tclkit.vfs:
@echo "Building VFS File system in tclkit.vfs"
@$(TCL_EXE) "$(TOP_DIR)/tools/mkVfs.tcl" \
"$(UNIX_DIR)/tclkit.vfs/tcl$(VERSION)" "$(TOP_DIR)" unix
# Assemble all of the tcl sources into a single executable
${TCLKIT_EXE}:
# Builds an executable directly from the Tcl sources
tclkit-direct: ${TCLKIT_OBJS} ${OBJS} ${ZLIB_OBJS} null.zip tclkit.vfs
${CC} ${CFLAGS} ${LDFLAGS} \
${TCLKIT_OBJS} ${OBJS} ${ZLIB_OBJS} \
${LIBS} @EXTRA_TCLSH_LIBS@ \
${CC_SEARCH_FLAGS} -o ${TCLKIT_EXE}
cat null.zip >> ${TCLKIT_EXE}
cd tclkit.vfs ; zip -rAq ${UNIX_DIR}/${TCLKIT_EXE} .
# Builds an executable linked to the Tcl dynamic library
tclkit-dynamic: ${TCLKIT_OBJS} ${TCL_LIB_FILE} ${TCL_STUB_LIB_FILE} null.zip tclkit.vfs
${CC} ${CFLAGS} ${LDFLAGS} \
${TCLKIT_OBJS} \
@TCL_BUILD_LIB_SPEC@ \
${LIBS} @EXTRA_TCLSH_LIBS@ \
${CC_SEARCH_FLAGS} -o ${TCLKIT_EXE}
cat null.zip >> ${TCLKIT_EXE}
cd tclkit.vfs ; zip -rAq ${UNIX_DIR}/${TCLKIT_EXE} .
# Builds a tcl static library, as well as an executable linked to the Tcl static library
tclkit-kitlib: ${TCLKIT_OBJS} ${TCL_KIT_LIB_FILE} null.zip tclkit.vfs
${CC} ${CFLAGS} ${LDFLAGS} \
${TCLKIT_OBJS} \
@TCL_BUILD_KIT_LIB_SPEC@ \
${LIBS} @EXTRA_TCLSH_LIBS@ \
${CC_SEARCH_FLAGS} -o ${TCLKIT_EXE}
cat null.zip >> ${TCLKIT_EXE}
cd tclkit.vfs ; zip -rAq ${UNIX_DIR}/${TCLKIT_EXE} .
Makefile: $(UNIX_DIR)/Makefile.in $(DLTEST_DIR)/Makefile.in
$(SHELL) config.status
#tclConfig.h: $(UNIX_DIR)/tclConfig.h.in
# $(SHELL) config.status
clean: clean-packages
rm -f *.a *.o libtcl* core errs *~ \#* TAGS *.E a.out \
errors ${TCL_EXE} ${TCLTEST_EXE} lib.exp Tcl @DTRACE_HDR@ \
${TCLKIT_EXE}
rm -rf tclkit.vfs null.zip
cd dltest ; $(MAKE) clean
distclean: distclean-packages clean
rm -rf Makefile config.status config.cache config.log tclConfig.sh \
tclConfig.h *.plist Tcl.framework tcl.pc
cd dltest ; $(MAKE) distclean
|
| ︙ | ︙ | |||
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
fi; \
done;
@echo "Installing $(LIB_FILE) to $(DLL_INSTALL_DIR)/"
@@INSTALL_LIB@
@chmod 555 "$(DLL_INSTALL_DIR)/$(LIB_FILE)"
@echo "Installing ${TCL_EXE} as $(BIN_INSTALL_DIR)/tclsh$(VERSION)${EXE_SUFFIX}"
@$(INSTALL_PROGRAM) ${TCL_EXE} "$(BIN_INSTALL_DIR)/tclsh$(VERSION)${EXE_SUFFIX}"
@echo "Installing tclConfig.sh to $(CONFIG_INSTALL_DIR)/"
@$(INSTALL_DATA) tclConfig.sh "$(CONFIG_INSTALL_DIR)/tclConfig.sh"
@echo "Installing tclooConfig.sh to $(CONFIG_INSTALL_DIR)/"
@$(INSTALL_DATA) $(UNIX_DIR)/tclooConfig.sh \
"$(CONFIG_INSTALL_DIR)/tclooConfig.sh"
@if test "$(STUB_LIB_FILE)" != "" ; then \
echo "Installing $(STUB_LIB_FILE) to $(LIB_INSTALL_DIR)/"; \
@INSTALL_STUB_LIB@ ; \
fi
@EXTRA_INSTALL_BINARIES@
@echo "Installing pkg-config file to $(LIB_INSTALL_DIR)/pkgconfig/"
@$(INSTALL_DATA_DIR) $(LIB_INSTALL_DIR)/pkgconfig
@$(INSTALL_DATA) tcl.pc $(LIB_INSTALL_DIR)/pkgconfig/tcl.pc
install-libraries: libraries
| > > > > > > | 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
fi; \
done;
@echo "Installing $(LIB_FILE) to $(DLL_INSTALL_DIR)/"
@@INSTALL_LIB@
@chmod 555 "$(DLL_INSTALL_DIR)/$(LIB_FILE)"
@echo "Installing ${TCL_EXE} as $(BIN_INSTALL_DIR)/tclsh$(VERSION)${EXE_SUFFIX}"
@$(INSTALL_PROGRAM) ${TCL_EXE} "$(BIN_INSTALL_DIR)/tclsh$(VERSION)${EXE_SUFFIX}"
@echo "Installing ${TCLKIT_EXE} as $(BIN_INSTALL_DIR)/tclkit$(VERSION)${EXE_SUFFIX}"
@$(INSTALL_PROGRAM) ${TCLKIT_EXE} "$(BIN_INSTALL_DIR)/tclkit$(VERSION)${EXE_SUFFIX}"
@echo "Installing tclConfig.sh to $(CONFIG_INSTALL_DIR)/"
@$(INSTALL_DATA) tclConfig.sh "$(CONFIG_INSTALL_DIR)/tclConfig.sh"
@echo "Installing tclooConfig.sh to $(CONFIG_INSTALL_DIR)/"
@$(INSTALL_DATA) $(UNIX_DIR)/tclooConfig.sh \
"$(CONFIG_INSTALL_DIR)/tclooConfig.sh"
@if test "$(STUB_LIB_FILE)" != "" ; then \
echo "Installing $(STUB_LIB_FILE) to $(LIB_INSTALL_DIR)/"; \
@INSTALL_STUB_LIB@ ; \
fi
@if test "$(TCL_KIT_LIB_FILE)" != "" ; then \
echo "Installing $(TCL_KIT_LIB_FILE) to $(LIB_INSTALL_DIR)/"; \
@INSTALL_KIT_LIB@ ; \
fi
@EXTRA_INSTALL_BINARIES@
@echo "Installing pkg-config file to $(LIB_INSTALL_DIR)/pkgconfig/"
@$(INSTALL_DATA_DIR) $(LIB_INSTALL_DIR)/pkgconfig
@$(INSTALL_DATA) tcl.pc $(LIB_INSTALL_DIR)/pkgconfig/tcl.pc
install-libraries: libraries
|
| ︙ | ︙ | |||
1019 1020 1021 1022 1023 1024 1025 |
-DTCL_BUILDTIME_LIBRARY="\"${TCL_BUILDTIME_LIBRARY}\"" \
-DTCL_TEST -DTCL_XT_TEST $(UNIX_DIR)/tclAppInit.c
rm -f xtTestInit.o
mv tclAppInit.o xtTestInit.o
@if test -f tclAppInit.sav ; then \
mv tclAppInit.sav tclAppInit.o; \
fi;
| | > > > > | 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 |
-DTCL_BUILDTIME_LIBRARY="\"${TCL_BUILDTIME_LIBRARY}\"" \
-DTCL_TEST -DTCL_XT_TEST $(UNIX_DIR)/tclAppInit.c
rm -f xtTestInit.o
mv tclAppInit.o xtTestInit.o
@if test -f tclAppInit.sav ; then \
mv tclAppInit.sav tclAppInit.o; \
fi;
tclKitInit.o: $(UNIX_DIR)/tclAppInit.c ${TCL_EXE}
$(CC) -c $(APP_CC_SWITCHES) \
-DTCL_ZIPVFS $(UNIX_DIR)/tclAppInit.c -o tclKitInit.o
# Object files used on all Unix systems:
REGHDRS=$(GENERIC_DIR)/regex.h $(GENERIC_DIR)/regguts.h \
$(GENERIC_DIR)/regcustom.h
TCLREHDRS=$(GENERIC_DIR)/tclRegexp.h
COMPILEHDR=$(GENERIC_DIR)/tclCompile.h
FSHDR=$(GENERIC_DIR)/tclFileSystem.h
|
| ︙ | ︙ | |||
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 | tclUtf.o: $(GENERIC_DIR)/tclUtf.c $(GENERIC_DIR)/tclUniData.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclUtf.c tclVar.o: $(GENERIC_DIR)/tclVar.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclVar.c tclZlib.o: $(GENERIC_DIR)/tclZlib.c $(CC) -c $(CC_SWITCHES) $(ZLIB_INCLUDE) $(GENERIC_DIR)/tclZlib.c tclTest.o: $(GENERIC_DIR)/tclTest.c $(IOHDR) $(TCLREHDRS) $(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tclTest.c tclTestObj.o: $(GENERIC_DIR)/tclTestObj.c $(MATHHDRS) | > > > | 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 | tclUtf.o: $(GENERIC_DIR)/tclUtf.c $(GENERIC_DIR)/tclUniData.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclUtf.c tclVar.o: $(GENERIC_DIR)/tclVar.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclVar.c tclZipVfs.o: $(GENERIC_DIR)/tclZipVfs.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclZipVfs.c tclZlib.o: $(GENERIC_DIR)/tclZlib.c $(CC) -c $(CC_SWITCHES) $(ZLIB_INCLUDE) $(GENERIC_DIR)/tclZlib.c tclTest.o: $(GENERIC_DIR)/tclTest.c $(IOHDR) $(TCLREHDRS) $(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tclTest.c tclTestObj.o: $(GENERIC_DIR)/tclTestObj.c $(MATHHDRS) |
| ︙ | ︙ | |||
2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 | .PHONY: clean distclean depend genstubs checkstubs checkexports checkuchar .PHONY: shell gdb valgrind valgrindshell dist alldist rpm .PHONY: tclLibObjs tcltest-real test-tcl gdb-test ro-test trace-test xttest .PHONY: topDirName gendate gentommath_h trace-shell checkdoc .PHONY: install-tzdata install-msgs .PHONY: packages configure-packages test-packages clean-packages .PHONY: dist-packages distclean-packages install-packages #-------------------------------------------------------------------------- # DO NOT DELETE THIS LINE -- make depend depends on it. | > | 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 | .PHONY: clean distclean depend genstubs checkstubs checkexports checkuchar .PHONY: shell gdb valgrind valgrindshell dist alldist rpm .PHONY: tclLibObjs tcltest-real test-tcl gdb-test ro-test trace-test xttest .PHONY: topDirName gendate gentommath_h trace-shell checkdoc .PHONY: install-tzdata install-msgs .PHONY: packages configure-packages test-packages clean-packages .PHONY: dist-packages distclean-packages install-packages .PHONY: tclkit-direct tclkit-dynamic tclkit-kitlib #-------------------------------------------------------------------------- # DO NOT DELETE THIS LINE -- make depend depends on it. |
Changes to unix/configure.
more than 10,000 changes
Changes to unix/configure.in.
| ︙ | ︙ | |||
889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
else
TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
fi
#--------------------------------------------------------------------
# The statements below define various symbols relating to Tcl
# stub support.
#--------------------------------------------------------------------
# Replace ${VERSION} with contents of ${TCL_VERSION}
# double-eval to account for TCL_TRIM_DOTS.
#
eval "TCL_STUB_LIB_FILE=libtclstub${TCL_UNSHARED_LIB_SUFFIX}"
| > > > > > > > > > > > > > > > > > > > > > > > | 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
else
TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
fi
#--------------------------------------------------------------------
# The statements below define various symbols relating to Tcl
# core vfs and kit support.
#--------------------------------------------------------------------
eval "TCL_KIT_LIB_FILE=libtclkit${UNSHARED_LIB_SUFFIX}"
eval "TCL_KIT_LIB_FILE=${TCL_KIT_LIB_FILE}"
eval "TCL_KIT_LIB_FILE=libtclkit${TCL_UNSHARED_LIB_SUFFIX}"
eval "TCL_KIT_LIB_FILE=\"${TCL_KIT_LIB_FILE}\""
eval "TCL_KIT_LIB_DIR=${libdir}"
if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
TCL_KIT_LIB_FLAG="-ltclkit${TCL_VERSION}"
else
TCL_KIT_LIB_FLAG="-ltclkit`echo ${TCL_VERSION} | tr -d .`"
fi
TCL_BUILD_KIT_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TCL_KIT_LIB_FLAG}"
TCL_KIT_LIB_SPEC="-L${TCL_KIT_LIB_DIR} ${TCL_KIT_LIB_FLAG}"
TCL_BUILD_KIT_LIB_PATH="`pwd`/${TCL_KIT_LIB_FILE}"
TCL_KIT_LIB_PATH="${TCL_KIT_LIB_DIR}/${TCL_KIT_LIB_FILE}"
#--------------------------------------------------------------------
# The statements below define various symbols relating to Tcl
# stub support.
#--------------------------------------------------------------------
# Replace ${VERSION} with contents of ${TCL_VERSION}
# double-eval to account for TCL_TRIM_DOTS.
#
eval "TCL_STUB_LIB_FILE=libtclstub${TCL_UNSHARED_LIB_SUFFIX}"
|
| ︙ | ︙ | |||
929 930 931 932 933 934 935 936 937 938 939 | AC_SUBST(TCL_PATCH_LEVEL) AC_SUBST(TCL_YEAR) AC_SUBST(PKG_CFG_ARGS) AC_SUBST(TCL_LIB_FILE) AC_SUBST(TCL_LIB_FLAG) AC_SUBST(TCL_LIB_SPEC) AC_SUBST(TCL_STUB_LIB_FILE) AC_SUBST(TCL_STUB_LIB_FLAG) AC_SUBST(TCL_STUB_LIB_SPEC) AC_SUBST(TCL_STUB_LIB_PATH) | > > | | > > > > > | > > > < | 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 | AC_SUBST(TCL_PATCH_LEVEL) AC_SUBST(TCL_YEAR) AC_SUBST(PKG_CFG_ARGS) AC_SUBST(TCL_LIB_FILE) AC_SUBST(TCL_LIB_FLAG) AC_SUBST(TCL_LIB_SPEC) AC_SUBST(TCL_BUILD_LIB_SPEC) AC_SUBST(TCL_STUB_LIB_FILE) AC_SUBST(TCL_STUB_LIB_FLAG) AC_SUBST(TCL_STUB_LIB_SPEC) AC_SUBST(TCL_STUB_LIB_PATH) AC_SUBST(TCL_BUILD_STUB_LIB_SPEC) AC_SUBST(TCL_BUILD_STUB_LIB_PATH) AC_SUBST(TCL_KIT_LIB_FILE) AC_SUBST(TCL_KIT_LIB_FLAG) AC_SUBST(TCL_KIT_LIB_SPEC) AC_SUBST(TCL_KIT_LIB_PATH) AC_SUBST(TCL_BUILD_KIT_LIB_SPEC) AC_SUBST(TCL_BUILD_KIT_LIB_PATH) AC_SUBST(TCL_INCLUDE_SPEC) AC_SUBST(TCL_SRC_DIR) AC_SUBST(CFG_TCL_SHARED_LIB_SUFFIX) AC_SUBST(CFG_TCL_UNSHARED_LIB_SUFFIX) AC_SUBST(TCL_SHARED_BUILD) AC_SUBST(LD_LIBRARY_PATH_VAR) AC_SUBST(TCL_LIB_VERSIONS_OK) AC_SUBST(TCL_SHARED_LIB_SUFFIX) AC_SUBST(TCL_UNSHARED_LIB_SUFFIX) AC_SUBST(TCL_HAS_LONGLONG) |
| ︙ | ︙ |
Changes to unix/tcl.m4.
| ︙ | ︙ | |||
2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 |
MAKE_LIB='$(STLIB_LD) [$]@ ${OBJS}'
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(LIB_INSTALL_DIR)/$(LIB_FILE)"'
], [
MAKE_LIB='${STLIB_LD} [$]@ ${OBJS} ; ${RANLIB} [$]@'
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(LIB_INSTALL_DIR)/$(LIB_FILE)" ; (cd "$(LIB_INSTALL_DIR)" ; $(RANLIB) $(LIB_FILE))'
])
])
# Stub lib does not depend on shared/static configuration
AS_IF([test "$RANLIB" = ""], [
MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS}'
INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) "$(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)"'
], [
MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS} ; ${RANLIB} [$]@'
| > > > > > > > > | 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 |
MAKE_LIB='$(STLIB_LD) [$]@ ${OBJS}'
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(LIB_INSTALL_DIR)/$(LIB_FILE)"'
], [
MAKE_LIB='${STLIB_LD} [$]@ ${OBJS} ; ${RANLIB} [$]@'
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(LIB_INSTALL_DIR)/$(LIB_FILE)" ; (cd "$(LIB_INSTALL_DIR)" ; $(RANLIB) $(LIB_FILE))'
])
])
AS_IF([test "$RANLIB" = ""], [
MAKE_KIT_LIB='$(STLIB_LD) [$]@ ${TCL_OBJS} ${TOMMATH_OBJS} ${ZLIB_OBJS}'
INSTALL_KIT_LIB='$(INSTALL_LIBRARY) $(TCL_KIT_LIB_FILE) "$(LIB_INSTALL_DIR)/$(TCL_KIT_LIB_FILE)"'
], [
MAKE_KIT_LIB='${STLIB_LD} [$]@ ${TCL_OBJS} ${TOMMATH_OBJS} ${ZLIB_OBJS} ; ${RANLIB} [$]@'
INSTALL_KIT_LIB='$(INSTALL_LIBRARY) $(TCL_KIT_LIB_FILE) "$(LIB_INSTALL_DIR)/$(TCL_KIT_LIB_FILE)" ; (cd "$(LIB_INSTALL_DIR)" ; $(RANLIB) $(TCL_KIT_LIB_FILE))'
])
# Stub lib does not depend on shared/static configuration
AS_IF([test "$RANLIB" = ""], [
MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS}'
INSTALL_STUB_LIB='$(INSTALL_LIBRARY) $(STUB_LIB_FILE) "$(LIB_INSTALL_DIR)/$(STUB_LIB_FILE)"'
], [
MAKE_STUB_LIB='${STLIB_LD} [$]@ ${STUB_LIB_OBJS} ; ${RANLIB} [$]@'
|
| ︙ | ︙ | |||
2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 |
AC_SUBST(SHLIB_LD_LIBS)
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_SUFFIX)
AC_DEFINE_UNQUOTED(TCL_SHLIB_EXT,"${SHLIB_SUFFIX}",
[What is the default extension for shared libraries?])
AC_SUBST(MAKE_LIB)
AC_SUBST(MAKE_STUB_LIB)
AC_SUBST(INSTALL_LIB)
AC_SUBST(DLL_INSTALL_DIR)
AC_SUBST(INSTALL_STUB_LIB)
AC_SUBST(RANLIB)
])
#--------------------------------------------------------------------
# SC_MISSING_POSIX_HEADERS
#
# Supply substitutes for missing POSIX header files. Special
| > > | 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 |
AC_SUBST(SHLIB_LD_LIBS)
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_SUFFIX)
AC_DEFINE_UNQUOTED(TCL_SHLIB_EXT,"${SHLIB_SUFFIX}",
[What is the default extension for shared libraries?])
AC_SUBST(MAKE_LIB)
AC_SUBST(MAKE_KIT_LIB)
AC_SUBST(MAKE_STUB_LIB)
AC_SUBST(INSTALL_LIB)
AC_SUBST(DLL_INSTALL_DIR)
AC_SUBST(INSTALL_STUB_LIB)
AC_SUBST(INSTALL_KIT_LIB)
AC_SUBST(RANLIB)
])
#--------------------------------------------------------------------
# SC_MISSING_POSIX_HEADERS
#
# Supply substitutes for missing POSIX header files. Special
|
| ︙ | ︙ |
Changes to unix/tclAppInit.c.
| ︙ | ︙ | |||
36 37 38 39 40 41 42 | #define TCL_LOCAL_APPINIT Tcl_AppInit #endif #ifndef MODULE_SCOPE # define MODULE_SCOPE extern #endif MODULE_SCOPE int TCL_LOCAL_APPINIT(Tcl_Interp *); MODULE_SCOPE int main(int, char **); | | > > > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #define TCL_LOCAL_APPINIT Tcl_AppInit #endif #ifndef MODULE_SCOPE # define MODULE_SCOPE extern #endif MODULE_SCOPE int TCL_LOCAL_APPINIT(Tcl_Interp *); MODULE_SCOPE int main(int, char **); #ifdef TCL_ZIPVFS MODULE_SCOPE int Tcl_Zvfs_Boot(const char *,const char *,const char *); MODULE_SCOPE int TclZvfsInit(Tcl_Interp *); #endif /* TCL_ZIPVFS */ /* * The following #if block allows you to change how Tcl finds the startup * script, prime the library or encoding paths, fiddle with the argv, etc., * without needing to rewrite Tcl_Main() */ #ifdef TCL_LOCAL_MAIN_HOOK |
| ︙ | ︙ | |||
76 77 78 79 80 81 82 |
#ifdef TCL_XT_TEST
XtToolkitInitialize();
#endif
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
| | > > > > > > | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
#ifdef TCL_XT_TEST
XtToolkitInitialize();
#endif
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
#ifdef TCL_ZIPVFS
#define TCLKIT_INIT "main.tcl"
#define TCLKIT_VFSMOUNT "/zvfs"
Tcl_FindExecutable(argv[0]);
CONST char *cp=Tcl_GetNameOfExecutable();
Tcl_Zvfs_Boot(cp,TCLKIT_VFSMOUNT,TCLKIT_INIT);
#endif
Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
return 0; /* Needed only to prevent compiler warning. */
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
int
Tcl_AppInit(
Tcl_Interp *interp) /* Interpreter for application. */
{
if ((Tcl_Init)(interp) == TCL_ERROR) {
return TCL_ERROR;
}
| > > > > | > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
int
Tcl_AppInit(
Tcl_Interp *interp) /* Interpreter for application. */
{
if ((Tcl_Init)(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#ifdef TCL_ZIPVFS
/* Load the ZipVfs package */
if (TclZvfsInit(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#endif
#ifdef TCL_XT_TEST
if (Tclxttest_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#endif
#ifdef TCL_TEST
|
| ︙ | ︙ |
Changes to unix/tclConfig.sh.in.
| ︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | TCL_LDFLAGS_OPTIMIZE='@LDFLAGS_OPTIMIZE@' # Flag, 1: we built a shared lib, 0 we didn't TCL_SHARED_BUILD=@TCL_SHARED_BUILD@ # The name of the Tcl library (may be either a .a file or a shared library): TCL_LIB_FILE='@TCL_LIB_FILE@' # Additional libraries to use when linking Tcl. TCL_LIBS='@TCL_LIBS@' # Top-level directory in which Tcl's platform-independent files are # installed. TCL_PREFIX='@prefix@' | > > > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | TCL_LDFLAGS_OPTIMIZE='@LDFLAGS_OPTIMIZE@' # Flag, 1: we built a shared lib, 0 we didn't TCL_SHARED_BUILD=@TCL_SHARED_BUILD@ # The name of the Tcl library (may be either a .a file or a shared library): TCL_LIB_FILE='@TCL_LIB_FILE@' # The name of the static Tcl library (intended for kits): TCL_KIT_LIB_FILE='@TCL_KIT_LIB_FILE@' # Additional libraries to use when linking Tcl. TCL_LIBS='@TCL_LIBS@' # Top-level directory in which Tcl's platform-independent files are # installed. TCL_PREFIX='@prefix@' |
| ︙ | ︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 150 | # compiled. TCL_SRC_DIR='@TCL_SRC_DIR@' # List of standard directories in which to look for packages during # "package require" commands. Contains the "prefix" directory plus also # the "exec_prefix" directory, if it is different. TCL_PACKAGE_PATH='@TCL_PACKAGE_PATH@' # Tcl supports stub. TCL_SUPPORTS_STUBS=1 # The name of the Tcl stub library (.a): TCL_STUB_LIB_FILE='@TCL_STUB_LIB_FILE@' | > > > > > > > > > > > > > > > > > > > > > > > > > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | # compiled. TCL_SRC_DIR='@TCL_SRC_DIR@' # List of standard directories in which to look for packages during # "package require" commands. Contains the "prefix" directory plus also # the "exec_prefix" directory, if it is different. TCL_PACKAGE_PATH='@TCL_PACKAGE_PATH@' # Core VFS Kit Support TCL_SUPPORT_KITS=1 # The name of the Tcl kit library (.a): TCL_KIT_LIB_FILE='@TCL_KIT_LIB_FILE@' # -l flag to pass to the linker to pick up the Tcl kit library TCL_KIT_LIB_FLAG='@TCL_KIT_LIB_FLAG@' # String to pass to linker to pick up the Tcl kit library from its # build directory. TCL_BUILD_KIT_LIB_SPEC='@TCL_BUILD_KIT_LIB_SPEC@' # String to pass to linker to pick up the Tcl kit library from its # installed directory. TCL_KIT_LIB_SPEC='@TCL_KIT_LIB_SPEC@' # Path to the Tcl kit library in the build directory. TCL_BUILD_KIT_LIB_PATH='@TCL_BUILD_KIT_LIB_PATH@' # Path to the Tcl kit library in the install directory. TCL_KIT_LIB_PATH='@TCL_KIT_LIB_PATH@' # END VFS SUPPORT # Tcl supports stub. TCL_SUPPORTS_STUBS=1 # The name of the Tcl stub library (.a): TCL_STUB_LIB_FILE='@TCL_STUB_LIB_FILE@' |
| ︙ | ︙ |
Changes to win/Makefile.in.
| ︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 | TOP_DIR = $(shell cd @srcdir@/..; pwd -P) GENERIC_DIR = $(TOP_DIR)/generic TOMMATH_DIR = $(TOP_DIR)/libtommath WIN_DIR = $(TOP_DIR)/win COMPAT_DIR = $(TOP_DIR)/compat PKGS_DIR = $(TOP_DIR)/pkgs ZLIB_DIR = $(COMPAT_DIR)/zlib # Converts a POSIX path to a Windows native path. CYGPATH = @CYGPATH@ GENERIC_DIR_NATIVE = $(shell $(CYGPATH) '$(GENERIC_DIR)' | sed 's!\\!/!g') TOMMATH_DIR_NATIVE = $(shell $(CYGPATH) '$(TOMMATH_DIR)' | sed 's!\\!/!g') WIN_DIR_NATIVE = $(shell $(CYGPATH) '$(WIN_DIR)' | sed 's!\\!/!g') | > > > > | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | TOP_DIR = $(shell cd @srcdir@/..; pwd -P) GENERIC_DIR = $(TOP_DIR)/generic TOMMATH_DIR = $(TOP_DIR)/libtommath WIN_DIR = $(TOP_DIR)/win COMPAT_DIR = $(TOP_DIR)/compat PKGS_DIR = $(TOP_DIR)/pkgs ZLIB_DIR = $(COMPAT_DIR)/zlib VFS_SCRIPT_INSTALL_DIR = $(WIN_DIR)/tclvfs.zip/tcl$(VERSION) VFS_PKG_INSTALL_DIR = $(WIN_DIR)/tclvfs.zip/lib # Converts a POSIX path to a Windows native path. CYGPATH = @CYGPATH@ GENERIC_DIR_NATIVE = $(shell $(CYGPATH) '$(GENERIC_DIR)' | sed 's!\\!/!g') TOMMATH_DIR_NATIVE = $(shell $(CYGPATH) '$(TOMMATH_DIR)' | sed 's!\\!/!g') WIN_DIR_NATIVE = $(shell $(CYGPATH) '$(WIN_DIR)' | sed 's!\\!/!g') |
| ︙ | ︙ | |||
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
TEST_LIB_FILE = @LIBPREFIX@tcltest$(VER)${LIBSUFFIX}
ZLIB_DLL_FILE = zlib1.dll
SHARED_LIBRARIES = $(TCL_DLL_FILE) @ZLIB_DLL_FILE@
STATIC_LIBRARIES = $(TCL_LIB_FILE)
TCLSH = tclsh$(VER)${EXESUFFIX}
CAT32 = cat32$(EXEEXT)
MAN2TCL = man2tcl$(EXEEXT)
# For cross-compiled builds, TCL_EXE is the name of a tclsh executable that is
# available *BEFORE* running make for the first time. Certain build targets
# (make genstubs, make install) need it to be available on the PATH. This
# executable should *NOT* be required just to do a normal build although
| > | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
TEST_LIB_FILE = @LIBPREFIX@tcltest$(VER)${LIBSUFFIX}
ZLIB_DLL_FILE = zlib1.dll
SHARED_LIBRARIES = $(TCL_DLL_FILE) @ZLIB_DLL_FILE@
STATIC_LIBRARIES = $(TCL_LIB_FILE)
TCLSH = tclsh$(VER)${EXESUFFIX}
TCLKIT = tclkit$(VER)${EXESUFFIX}
CAT32 = cat32$(EXEEXT)
MAN2TCL = man2tcl$(EXEEXT)
# For cross-compiled builds, TCL_EXE is the name of a tclsh executable that is
# available *BEFORE* running make for the first time. Certain build targets
# (make genstubs, make install) need it to be available on the PATH. This
# executable should *NOT* be required just to do a normal build although
|
| ︙ | ︙ | |||
291 292 293 294 295 296 297 | tclTimer.$(OBJEXT) \ tclTomMathInterface.$(OBJEXT) \ tclTrace.$(OBJEXT) \ tclUtf.$(OBJEXT) \ tclUtil.$(OBJEXT) \ tclVar.$(OBJEXT) \ tclZlib.$(OBJEXT) | | | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
tclTimer.$(OBJEXT) \
tclTomMathInterface.$(OBJEXT) \
tclTrace.$(OBJEXT) \
tclUtf.$(OBJEXT) \
tclUtil.$(OBJEXT) \
tclVar.$(OBJEXT) \
tclZlib.$(OBJEXT)
TOMMATH_OBJS = \
bncore.${OBJEXT} \
bn_reverse.${OBJEXT} \
bn_fast_s_mp_mul_digs.${OBJEXT} \
bn_fast_s_mp_sqr.${OBJEXT} \
bn_mp_add.${OBJEXT} \
bn_mp_add_d.${OBJEXT} \
|
| ︙ | ︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 |
inftrees.$(OBJEXT) \
trees.$(OBJEXT) \
uncompr.$(OBJEXT) \
zutil.$(OBJEXT)
TCL_OBJS = ${GENERIC_OBJS} $(TOMMATH_OBJS) ${WIN_OBJS} @ZLIB_OBJS@
TCL_DOCS = "$(ROOT_DIR_NATIVE)"/doc/*.[13n]
all: binaries libraries doc packages
tcltest: $(TCLSH) $(TEST_DLL_FILE)
| > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
inftrees.$(OBJEXT) \
trees.$(OBJEXT) \
uncompr.$(OBJEXT) \
zutil.$(OBJEXT)
TCL_OBJS = ${GENERIC_OBJS} $(TOMMATH_OBJS) ${WIN_OBJS} @ZLIB_OBJS@
TCLKIT_OBJS = tclKitInit.$(OBJEXT) tclZipVfs.$(OBJEXT)
TCL_DOCS = "$(ROOT_DIR_NATIVE)"/doc/*.[13n]
all: binaries libraries doc packages
tcltest: $(TCLSH) $(TEST_DLL_FILE)
binaries: $(TCL_STUB_LIB_FILE) @LIBRARIES@ $(DDE_DLL_FILE) $(REG_DLL_FILE) $(TCLSH) $(TCLKIT)
libraries:
doc:
$(TCLSH): $(TCLSH_OBJS) @LIBRARIES@ $(TCL_STUB_LIB_FILE) tclsh.$(RES)
$(CC) $(CFLAGS) $(TCLSH_OBJS) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
@VC_MANIFEST_EMBED_EXE@
tclkit: $(TCLKIT)
null.zip:
touch .empty
zip -q null.zip .empty
# Rather than force an install, pack the files we need into a
# file system under our control
tclkit.vfs: $(TCLSH) $(DDE_DLL_FILE) $(REG_DLL_FILE)
@echo "Building VFS File system in tclkit.vfs"
@$(TCL_EXE) "$(ROOT_DIR)/tools/mkVfs.tcl" \
"$(WIN_DIR)/tclkit.vfs/tcl$(VERSION)" "$(ROOT_DIR)" windows
$(TCLKIT): tclkit-direct
# Builds an executable directly from the Tcl sources
tclkit-direct: $(TCLKIT_OBJS) ${GENERIC_OBJS} $(TOMMATH_OBJS) ${WIN_OBJS} ${ZLIB_OBJS} @LIBRARIES@ $(TCL_STUB_LIB_FILE) tclsh.$(RES) null.zip tclkit.vfs
rm *.$(OBJEXT)
$(CC) $(CFLAGS) -DSTATIC_BUILD -UUSE_STUBS $(TCLKIT_OBJS) \
${GENERIC_OBJS} $(TOMMATH_OBJS) ${WIN_OBJS} ${ZLIB_OBJS} \
$(LIBS) \
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
@VC_MANIFEST_EMBED_EXE@
rm *.$(OBJEXT)
cat null.zip >> $(TCLKIT)
cd tclkit.vfs ; zip -rAq $(WIN_DIR)/$(TCLKIT) .
# Builds an executable linked to the Tcl dynamic library
tclkit-dynamic: $(TCLKIT_OBJS) @LIBRARIES@ $(TCL_STUB_LIB_FILE) tclsh.$(RES) null.zip tclkit.vfs
$(CC) $(CFLAGS) $(TCLKIT_OBJS) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
@VC_MANIFEST_EMBED_EXE@
cat null.zip >> $(TCLKIT)
cd tclkit.vfs ; zip -rAq $(WIN_DIR)/$(TCLKIT) .
tclkit-kitlib: $(TCLKIT_OBJS) @LIBRARIES@ $(TCL_STUB_LIB_FILE) tclsh.$(RES) null.zip tclkit.vfs
$(CC) $(CFLAGS) $(TCLKIT_OBJS) $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE) $(LIBS) \
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
@VC_MANIFEST_EMBED_EXE@
cat null.zip >> $(TCLKIT)
cd tclkit.vfs ; zip -rAq $(WIN_DIR)/$(TCLKIT) .
cat32.$(OBJEXT): cat.c
$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
$(CAT32): cat32.$(OBJEXT)
$(CC) $(CFLAGS) cat32.$(OBJEXT) $(CC_EXENAME) $(LIBS) $(LDFLAGS_CONSOLE)
# The following targets are configured by autoconf to generate either a shared
|
| ︙ | ︙ | |||
481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
testMain.${OBJEXT}: tclAppInit.c
$(CC) -c $(CC_SWITCHES) -DTCL_TEST @DEPARG@ $(CC_OBJNAME)
tclMain2.${OBJEXT}: tclMain.c
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl -DTCL_ASCII_MAIN @DEPARG@ $(CC_OBJNAME)
# TIP #59, embedding of configuration information into the binary library.
#
# Part of Tcl's configuration information are the paths where it was installed
# and where it will look for its libraries (which can be different). We derive
# this information from the variables which can be overridden by the user. As
# every path can be configured separately we do not remember one general
# prefix/exec_prefix but all the different paths individually.
| > > > | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
testMain.${OBJEXT}: tclAppInit.c
$(CC) -c $(CC_SWITCHES) -DTCL_TEST @DEPARG@ $(CC_OBJNAME)
tclMain2.${OBJEXT}: tclMain.c
$(CC) -c $(CC_SWITCHES) -DBUILD_tcl -DTCL_ASCII_MAIN @DEPARG@ $(CC_OBJNAME)
tclKitInit.${OBJEXT}: tclAppInit.c
$(CC) -c $(CC_SWITCHES) -DTCL_ZIPVFS @DEPARG@ $(CC_OBJNAME)
# TIP #59, embedding of configuration information into the binary library.
#
# Part of Tcl's configuration information are the paths where it was installed
# and where it will look for its libraries (which can be different). We derive
# this information from the variables which can be overridden by the user. As
# every path can be configured separately we do not remember one general
# prefix/exec_prefix but all the different paths individually.
|
| ︙ | ︙ | |||
565 566 567 568 569 570 571 | do \ if [ ! -d $(LIB_INSTALL_DIR)/$$i ] ; then \ echo "Making directory $(LIB_INSTALL_DIR)/$$i"; \ $(MKDIR) $(LIB_INSTALL_DIR)/$$i; \ else true; \ fi; \ done; | | | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | do \ if [ ! -d $(LIB_INSTALL_DIR)/$$i ] ; then \ echo "Making directory $(LIB_INSTALL_DIR)/$$i"; \ $(MKDIR) $(LIB_INSTALL_DIR)/$$i; \ else true; \ fi; \ done; @for i in $(TCL_DLL_FILE) $(ZLIB_DLL_FILE) $(TCLSH) $(TCLKIT); \ do \ if [ -f $$i ]; then \ echo "Installing $$i to $(BIN_INSTALL_DIR)/"; \ $(COPY) $$i "$(BIN_INSTALL_DIR)"; \ fi; \ done @for i in tclConfig.sh tclooConfig.sh $(TCL_LIB_FILE) $(TCL_STUB_LIB_FILE); \ |
| ︙ | ︙ | |||
730 731 732 733 734 735 736 |
./config.status
cleanhelp:
$(RM) *.hlp *.cnt *.GID *.rtf man2tcl.exe
clean: cleanhelp clean-packages
$(RM) *.lib *.a *.exp *.dll *.$(RES) *.${OBJEXT} *~ \#* TAGS a.out
| | > | 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
./config.status
cleanhelp:
$(RM) *.hlp *.cnt *.GID *.rtf man2tcl.exe
clean: cleanhelp clean-packages
$(RM) *.lib *.a *.exp *.dll *.$(RES) *.${OBJEXT} *~ \#* TAGS a.out
$(RM) $(TCLSH) $(CAT32) $(TCLKIT) null.zip
$(RM) *.pch *.ilk *.pdb
$(RMDIR) tclkit.vfs
distclean: distclean-packages clean
$(RM) Makefile config.status config.cache config.log tclConfig.sh \
tcl.hpj config.status.lineno
#
# Bundled package targets
|
| ︙ | ︙ | |||
863 864 865 866 867 868 869 | # .PHONY: all tcltest binaries libraries doc gendate gentommath_h install .PHONY: install-binaries install-libraries install-tzdata install-msgs .PHONY: install-doc install-private-headers test test-tcl runtest shell .PHONY: gdb depend cleanhelp clean distclean packages install-packages .PHONY: test-packages clean-packages distclean-packages genstubs html | | > > | 917 918 919 920 921 922 923 924 925 926 927 928 | # .PHONY: all tcltest binaries libraries doc gendate gentommath_h install .PHONY: install-binaries install-libraries install-tzdata install-msgs .PHONY: install-doc install-private-headers test test-tcl runtest shell .PHONY: gdb depend cleanhelp clean distclean packages install-packages .PHONY: test-packages clean-packages distclean-packages genstubs html .PHONY: html-tcl html-tk tclkit .PHONY: tclkit-direct tclkit-dynamic tclkit-kitlib # DO NOT DELETE THIS LINE -- make depend depends on it. |
Changes to win/makefile.bc.
| ︙ | ︙ | |||
271 272 273 274 275 276 277 278 279 280 281 282 283 284 | $(TMPDIR)\tclWinInit.obj \ $(TMPDIR)\tclWinLoad.obj \ $(TMPDIR)\tclWinNotify.obj \ $(TMPDIR)\tclWinPipe.obj \ $(TMPDIR)\tclWinSock.obj \ $(TMPDIR)\tclWinThrd.obj \ $(TMPDIR)\tclWinTime.obj \ $(TMPDIR)\tclZlib.obj TCLSTUBOBJS = \ $(TMPDIR)\tclStubLib.obj \ $(TMPDIR)\tclTomMathStubLib.obj \ $(TMPDIR)\tclOOStubLib.obj | > | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | $(TMPDIR)\tclWinInit.obj \ $(TMPDIR)\tclWinLoad.obj \ $(TMPDIR)\tclWinNotify.obj \ $(TMPDIR)\tclWinPipe.obj \ $(TMPDIR)\tclWinSock.obj \ $(TMPDIR)\tclWinThrd.obj \ $(TMPDIR)\tclWinTime.obj \ $(TMP_DIR)\tclZipVfs.obj \ $(TMPDIR)\tclZlib.obj TCLSTUBOBJS = \ $(TMPDIR)\tclStubLib.obj \ $(TMPDIR)\tclTomMathStubLib.obj \ $(TMPDIR)\tclOOStubLib.obj |
| ︙ | ︙ |
Changes to win/makefile.vc.
| ︙ | ︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 | $(TMP_DIR)\tclThreadStorage.obj \ $(TMP_DIR)\tclTimer.obj \ $(TMP_DIR)\tclTomMathInterface.obj \ $(TMP_DIR)\tclTrace.obj \ $(TMP_DIR)\tclUtf.obj \ $(TMP_DIR)\tclUtil.obj \ $(TMP_DIR)\tclVar.obj \ $(TMP_DIR)\tclZlib.obj ZLIBOBJS = \ $(TMP_DIR)\adler32.obj \ $(TMP_DIR)\compress.obj \ $(TMP_DIR)\crc32.obj \ $(TMP_DIR)\deflate.obj \ | > | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | $(TMP_DIR)\tclThreadStorage.obj \ $(TMP_DIR)\tclTimer.obj \ $(TMP_DIR)\tclTomMathInterface.obj \ $(TMP_DIR)\tclTrace.obj \ $(TMP_DIR)\tclUtf.obj \ $(TMP_DIR)\tclUtil.obj \ $(TMP_DIR)\tclVar.obj \ $(TMP_DIR)\tclZipVfs.obj \ $(TMP_DIR)\tclZlib.obj ZLIBOBJS = \ $(TMP_DIR)\adler32.obj \ $(TMP_DIR)\compress.obj \ $(TMP_DIR)\crc32.obj \ $(TMP_DIR)\deflate.obj \ |
| ︙ | ︙ | |||
927 928 929 930 931 932 933 934 935 936 937 938 939 940 | $(TMP_DIR)\tclTestObj.obj: $(GENERICDIR)\tclTestObj.c $(cc32) $(TCL_CFLAGS) -Fo$@ $? $(TMP_DIR)\tclWinTest.obj: $(WINDIR)\tclWinTest.c $(cc32) $(TCL_CFLAGS) -Fo$@ $? $(TMP_DIR)\tclZlib.obj: $(GENERICDIR)\tclZlib.c $(cc32) $(TCL_CFLAGS) -I$(COMPATDIR)\zlib -DBUILD_tcl -Fo$@ $? $(TMP_DIR)\tclPkgConfig.obj: $(GENERICDIR)\tclPkgConfig.c $(cc32) -DBUILD_tcl $(TCL_CFLAGS) \ -DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \ -DCFG_INSTALL_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \ | > > > | 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 | $(TMP_DIR)\tclTestObj.obj: $(GENERICDIR)\tclTestObj.c $(cc32) $(TCL_CFLAGS) -Fo$@ $? $(TMP_DIR)\tclWinTest.obj: $(WINDIR)\tclWinTest.c $(cc32) $(TCL_CFLAGS) -Fo$@ $? $(TMP_DIR)\tclZipVfs.obj: $(GENERICDIR)\tclZipVfs.c $(cc32) $(TCL_CFLAGS) -I$(COMPATDIR)\zlib -DBUILD_tcl -Fo$@ $? $(TMP_DIR)\tclZlib.obj: $(GENERICDIR)\tclZlib.c $(cc32) $(TCL_CFLAGS) -I$(COMPATDIR)\zlib -DBUILD_tcl -Fo$@ $? $(TMP_DIR)\tclPkgConfig.obj: $(GENERICDIR)\tclPkgConfig.c $(cc32) -DBUILD_tcl $(TCL_CFLAGS) \ -DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \ -DCFG_INSTALL_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \ |
| ︙ | ︙ |
Changes to win/tclAppInit.c.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <tchar.h> #ifdef TCL_TEST extern Tcl_PackageInitProc Tcltest_Init; extern Tcl_PackageInitProc Tcltest_SafeInit; #endif /* TCL_TEST */ #if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES extern Tcl_PackageInitProc Registry_Init; extern Tcl_PackageInitProc Dde_Init; extern Tcl_PackageInitProc Dde_SafeInit; #endif #ifdef TCL_BROKEN_MAINARGS | > > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <tchar.h> #ifdef TCL_TEST extern Tcl_PackageInitProc Tcltest_Init; extern Tcl_PackageInitProc Tcltest_SafeInit; #endif /* TCL_TEST */ #ifdef TCL_ZIPVFS MODULE_SCOPE int Tcl_Zvfs_Boot(const char *,const char *,const char *); MODULE_SCOPE int TclZvfsInit(Tcl_Interp *); #endif /* TCL_ZIPVFS */ #if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES extern Tcl_PackageInitProc Registry_Init; extern Tcl_PackageInitProc Dde_Init; extern Tcl_PackageInitProc Dde_SafeInit; #endif #ifdef TCL_BROKEN_MAINARGS |
| ︙ | ︙ | |||
119 120 121 122 123 124 125 |
*p = '/';
}
}
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
| | > > > > > > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
*p = '/';
}
}
#ifdef TCL_LOCAL_MAIN_HOOK
TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
#ifdef TCL_ZIPVFS
#define TCLKIT_INIT "main.tcl"
#define TCLKIT_VFSMOUNT "/zvfs"
Tcl_FindExecutable(argv[0]);
CONST char *cp=Tcl_GetNameOfExecutable();
Tcl_Zvfs_Boot(cp,TCLKIT_VFSMOUNT,TCLKIT_INIT);
#endif
Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
return 0; /* Needed only to prevent compiler warning. */
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
150 151 152 153 154 155 156 |
int
Tcl_AppInit(
Tcl_Interp *interp) /* Interpreter for application. */
{
if ((Tcl_Init)(interp) == TCL_ERROR) {
return TCL_ERROR;
}
| > > > > | > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
int
Tcl_AppInit(
Tcl_Interp *interp) /* Interpreter for application. */
{
if ((Tcl_Init)(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#ifdef TCL_ZIPVFS
/* Load the ZipVfs package */
if (TclZvfsInit(interp) == TCL_ERROR) {
return TCL_ERROR;
}
#endif
#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
if (Registry_Init(interp) == TCL_ERROR) {
return TCL_ERROR;
}
Tcl_StaticPackage(interp, "registry", Registry_Init, NULL);
if (Dde_Init(interp) == TCL_ERROR) {
|
| ︙ | ︙ |
Added win/tclkit.exe.manifest.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
version="@TCL_WIN_VERSION@"
processorArchitecture="@MACHINE@"
name="Tcl.tclsh"
type="win32"
/>
<description>Tcl self-contained executable (tclkit)</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
<asmv3:application>
<asmv3:windowsSettings
xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="@MACHINE@"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
|
Added win/tclkit.rc.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
//
// Version Resource Script
//
#include <winver.h>
#include <tcl.h>
//
// build-up the name suffix that defines the type of build this is.
//
#if TCL_THREADS
#define SUFFIX_THREADS "t"
#else
#define SUFFIX_THREADS ""
#endif
#if STATIC_BUILD
#define SUFFIX_STATIC "s"
#else
#define SUFFIX_STATIC ""
#endif
#if DEBUG && !UNCHECKED
#define SUFFIX_DEBUG "g"
#else
#define SUFFIX_DEBUG ""
#endif
#define SUFFIX SUFFIX_THREADS SUFFIX_STATIC SUFFIX_DEBUG
LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */
VS_VERSION_INFO VERSIONINFO
FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL
PRODUCTVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL
FILEFLAGSMASK 0x3fL
#ifdef DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "Tclkit Application\0"
VALUE "OriginalFilename", "tclkit" STRINGIFY(TCL_MAJOR_VERSION) STRINGIFY(TCL_MINOR_VERSION) SUFFIX ".exe\0"
VALUE "CompanyName", "ActiveState Corporation\0"
VALUE "FileVersion", TCL_PATCH_LEVEL
VALUE "LegalCopyright", "Copyright \251 2000 by ActiveState Corporation, et al\0"
VALUE "ProductName", "Tcl " TCL_VERSION " for Windows\0"
VALUE "ProductVersion", TCL_PATCH_LEVEL
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
//
// Icon
//
tclsh ICON DISCARDABLE "tclsh.ico"
//
// This is needed for Windows 8.1 onwards.
//
#ifndef RT_MANIFEST
#define RT_MANIFEST 24
#endif
#ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#endif
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "tclkit.exe.manifest"
|