ADDED embedded/www/tcllib/files/modules/udpcluster/udpcluster.html Index: embedded/www/tcllib/files/modules/udpcluster/udpcluster.html ================================================================== --- /dev/null +++ embedded/www/tcllib/files/modules/udpcluster/udpcluster.html @@ -0,0 +1,175 @@ +
+ +
[ + Main Table Of Contents +| Table Of Contents +| Keyword Index +| Categories +| Modules +| Applications + ]
+
+

udpcluster(n) 0.3 tcllib "Lightweight UDP based tool for cluster node discovery"

+

Name

+

udpcluster - UDP Peer-to-Peer cluster

+
+ +

Synopsis

+
+
    +
  • package require Tcl 8.5
  • +
  • package require ip
  • +
  • package require nettool
  • +
  • package require comm
  • +
  • package require interp
  • +
  • package require dicttool
  • +
  • package require cron
  • +
+
+
+

Description

+

This package is a lightweight alternative to Zeroconf. It utilizes UDP packets to +populate a table of services provided by each node on a local network. Each participant +broadcasts a key/value list in plain UTF-8 which lists what ports are open, and what +protocols are expected on those ports. Developers are free to add any additional key/value +pairs beyond those.

+

Using udpcluster.

+

For every service you wish to publish invoke:

+
+cluster::publish echo@[cluster::macid] {port 10000 protocol echo}
+
+

To query what services are available on the local network:

+
+set results [cluster::search PATTERN]
+# And inside that result...
+echo@LOCALMACID {
+   port 10000
+   protocol echo
+}
+
+

To unpublish a service:

+
+cluster::unpublish echo@[cluster::macid]
+
+

Results will +Historical Notes:

+

This tool was originally known as nns::cluster, but as development progressed, it was +clear that it wasn't interacting with any of the other facilities in NNS.

+
+

Bugs, Ideas, Feedback

+

This document, and the package it describes, will undoubtedly contain +bugs and other problems. +Please report such in the category nameserv of the +Tcllib Trackers. +Please also report any ideas for enhancements you may have for either +package and/or documentation.

+
+ +

Category

+

Networking

+
+ +
Index: embedded/www/tcllib/files/modules/zip/decode.html ================================================================== --- embedded/www/tcllib/files/modules/zip/decode.html +++ embedded/www/tcllib/files/modules/zip/decode.html @@ -97,11 +97,11 @@ | Categories | Modules | Applications ]
-

zipfile::decode(n) 0.6 tcllib "Zip archive handling"

+

zipfile::decode(n) 0.7.1 tcllib "Zip archive handling"

Name

zipfile::decode - Access to zip archives

Table Of Contents

    @@ -118,14 +118,14 @@

    Synopsis

    • package require Tcl 8.4
    • package require fileutil::magic::mimetype
    • -
    • package require fileutil::decode 0.2
    • +
    • package require fileutil::decode 0.2.1
    • package require Trf
    • package require zlibtcl
    • -
    • package require zipfile::decode ?0.6?
    • +
    • package require zipfile::decode ?0.7.1?

    Category

    File

    ADDED idoc/man/files/modules/udpcluster/udpcluster.n Index: idoc/man/files/modules/udpcluster/udpcluster.n ================================================================== --- /dev/null +++ idoc/man/files/modules/udpcluster/udpcluster.n @@ -0,0 +1,351 @@ +'\" +'\" Generated from file 'udpcluster\&.man' by tcllib/doctools with format 'nroff' +'\" Copyright (c) 2016 Sean Woods +'\" +.TH "udpcluster" n 0\&.3 tcllib "Lightweight UDP based tool for cluster node discovery" +.\" The -*- nroff -*- definitions below are for supplemental macros used +.\" in Tcl/Tk manual entries. +.\" +.\" .AP type name in/out ?indent? +.\" Start paragraph describing an argument to a library procedure. +.\" type is type of argument (int, etc.), in/out is either "in", "out", +.\" or "in/out" to describe whether procedure reads or modifies arg, +.\" and indent is equivalent to second arg of .IP (shouldn't ever be +.\" needed; use .AS below instead) +.\" +.\" .AS ?type? ?name? +.\" Give maximum sizes of arguments for setting tab stops. Type and +.\" name are examples of largest possible arguments that will be passed +.\" to .AP later. If args are omitted, default tab stops are used. +.\" +.\" .BS +.\" Start box enclosure. From here until next .BE, everything will be +.\" enclosed in one large box. +.\" +.\" .BE +.\" End of box enclosure. +.\" +.\" .CS +.\" Begin code excerpt. +.\" +.\" .CE +.\" End code excerpt. +.\" +.\" .VS ?version? ?br? +.\" Begin vertical sidebar, for use in marking newly-changed parts +.\" of man pages. The first argument is ignored and used for recording +.\" the version when the .VS was added, so that the sidebars can be +.\" found and removed when they reach a certain age. If another argument +.\" is present, then a line break is forced before starting the sidebar. +.\" +.\" .VE +.\" End of vertical sidebar. +.\" +.\" .DS +.\" Begin an indented unfilled display. +.\" +.\" .DE +.\" End of indented unfilled display. +.\" +.\" .SO ?manpage? +.\" Start of list of standard options for a Tk widget. The manpage +.\" argument defines where to look up the standard options; if +.\" omitted, defaults to "options". The options follow on successive +.\" lines, in three columns separated by tabs. +.\" +.\" .SE +.\" End of list of standard options for a Tk widget. +.\" +.\" .OP cmdName dbName dbClass +.\" Start of description of a specific option. cmdName gives the +.\" option's name as specified in the class command, dbName gives +.\" the option's name in the option database, and dbClass gives +.\" the option's class in the option database. +.\" +.\" .UL arg1 arg2 +.\" Print arg1 underlined, then print arg2 normally. +.\" +.\" .QW arg1 ?arg2? +.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation). +.\" +.\" .PQ arg1 ?arg2? +.\" Print an open parenthesis, arg1 in quotes, then arg2 normally +.\" (for trailing punctuation) and then a closing parenthesis. +.\" +.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. +.if t .wh -1.3i ^B +.nr ^l \n(.l +.ad b +.\" # Start an argument description +.de AP +.ie !"\\$4"" .TP \\$4 +.el \{\ +. ie !"\\$2"" .TP \\n()Cu +. el .TP 15 +.\} +.ta \\n()Au \\n()Bu +.ie !"\\$3"" \{\ +\&\\$1 \\fI\\$2\\fP (\\$3) +.\".b +.\} +.el \{\ +.br +.ie !"\\$2"" \{\ +\&\\$1 \\fI\\$2\\fP +.\} +.el \{\ +\&\\fI\\$1\\fP +.\} +.\} +.. +.\" # define tabbing values for .AP +.de AS +.nr )A 10n +.if !"\\$1"" .nr )A \\w'\\$1'u+3n +.nr )B \\n()Au+15n +.\" +.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n +.nr )C \\n()Bu+\\w'(in/out)'u+2n +.. +.AS Tcl_Interp Tcl_CreateInterp in/out +.\" # BS - start boxed text +.\" # ^y = starting y location +.\" # ^b = 1 +.de BS +.br +.mk ^y +.nr ^b 1u +.if n .nf +.if n .ti 0 +.if n \l'\\n(.lu\(ul' +.if n .fi +.. +.\" # BE - end boxed text (draw box now) +.de BE +.nf +.ti 0 +.mk ^t +.ie n \l'\\n(^lu\(ul' +.el \{\ +.\" Draw four-sided box normally, but don't draw top of +.\" box if the box started on an earlier page. +.ie !\\n(^b-1 \{\ +\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.el \}\ +\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.\} +.fi +.br +.nr ^b 0 +.. +.\" # VS - start vertical sidebar +.\" # ^Y = starting y location +.\" # ^v = 1 (for troff; for nroff this doesn't matter) +.de VS +.if !"\\$2"" .br +.mk ^Y +.ie n 'mc \s12\(br\s0 +.el .nr ^v 1u +.. +.\" # VE - end of vertical sidebar +.de VE +.ie n 'mc +.el \{\ +.ev 2 +.nf +.ti 0 +.mk ^t +\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' +.sp -1 +.fi +.ev +.\} +.nr ^v 0 +.. +.\" # Special macro to handle page bottom: finish off current +.\" # box/sidebar if in box/sidebar mode, then invoked standard +.\" # page bottom macro. +.de ^B +.ev 2 +'ti 0 +'nf +.mk ^t +.if \\n(^b \{\ +.\" Draw three-sided box if this is the box's first page, +.\" draw two sides but no top otherwise. +.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.\} +.if \\n(^v \{\ +.nr ^x \\n(^tu+1v-\\n(^Yu +\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c +.\} +.bp +'fi +.ev +.if \\n(^b \{\ +.mk ^y +.nr ^b 2 +.\} +.if \\n(^v \{\ +.mk ^Y +.\} +.. +.\" # DS - begin display +.de DS +.RS +.nf +.sp +.. +.\" # DE - end display +.de DE +.fi +.RE +.sp +.. +.\" # SO - start of list of standard options +.de SO +'ie '\\$1'' .ds So \\fBoptions\\fR +'el .ds So \\fB\\$1\\fR +.SH "STANDARD OPTIONS" +.LP +.nf +.ta 5.5c 11c +.ft B +.. +.\" # SE - end of list of standard options +.de SE +.fi +.ft R +.LP +See the \\*(So manual entry for details on the standard options. +.. +.\" # OP - start of full description for a single option +.de OP +.LP +.nf +.ta 4c +Command-Line Name: \\fB\\$1\\fR +Database Name: \\fB\\$2\\fR +Database Class: \\fB\\$3\\fR +.fi +.IP +.. +.\" # CS - begin code excerpt +.de CS +.RS +.nf +.ta .25i .5i .75i 1i +.. +.\" # CE - end code excerpt +.de CE +.fi +.RE +.. +.\" # UL - underline word +.de UL +\\$1\l'|0\(ul'\\$2 +.. +.\" # QW - apply quotation marks to word +.de QW +.ie '\\*(lq'"' ``\\$1''\\$2 +.\"" fix emacs highlighting +.el \\*(lq\\$1\\*(rq\\$2 +.. +.\" # PQ - apply parens and quotation marks to word +.de PQ +.ie '\\*(lq'"' (``\\$1''\\$2)\\$3 +.\"" fix emacs highlighting +.el (\\*(lq\\$1\\*(rq\\$2)\\$3 +.. +.\" # QR - quoted range +.de QR +.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3 +.\"" fix emacs highlighting +.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3 +.. +.\" # MT - "empty" string +.de MT +.QW "" +.. +.BS +.SH NAME +udpcluster \- UDP Peer-to-Peer cluster +.SH SYNOPSIS +package require \fBTcl 8\&.5\fR +.sp +package require \fBip \fR +.sp +package require \fBnettool \fR +.sp +package require \fBcomm \fR +.sp +package require \fBinterp \fR +.sp +package require \fBdicttool \fR +.sp +package require \fBcron \fR +.sp +.BE +.SH DESCRIPTION +This package is a lightweight alternative to Zeroconf\&. It utilizes UDP packets to +populate a table of services provided by each node on a local network\&. Each participant +broadcasts a key/value list in plain UTF-8 which lists what ports are open, and what +protocols are expected on those ports\&. Developers are free to add any additional key/value +pairs beyond those\&. +.PP +Using udpcluster\&. +.PP +For every service you wish to publish invoke: +.PP +.CS + + +cluster::publish echo@[cluster::macid] {port 10000 protocol echo} + +.CE +.PP +To query what services are available on the local network: +.CS + + +set results [cluster::search PATTERN] +# And inside that result\&.\&.\&. +echo@LOCALMACID { + port 10000 + protocol echo +} + +.CE +.PP +To unpublish a service: +.CS + + +cluster::unpublish echo@[cluster::macid] + +.CE +.PP +Results will +Historical Notes: +.PP +This tool was originally known as nns::cluster, but as development progressed, it was +clear that it wasn't interacting with any of the other facilities in NNS\&. +.SH "BUGS, IDEAS, FEEDBACK" +This document, and the package it describes, will undoubtedly contain +bugs and other problems\&. +Please report such in the category \fInameserv\fR of the +\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&. +Please also report any ideas for enhancements you may have for either +package and/or documentation\&. +.SH KEYWORDS +name service, server +.SH CATEGORY +Networking +.SH COPYRIGHT +.nf +Copyright (c) 2016 Sean Woods + +.fi Index: idoc/man/files/modules/zip/decode.n ================================================================== --- idoc/man/files/modules/zip/decode.n +++ idoc/man/files/modules/zip/decode.n @@ -1,10 +1,10 @@ '\" '\" Generated from file 'decode\&.man' by tcllib/doctools with format 'nroff' -'\" Copyright (c) 2008-2014 Andreas Kupries +'\" Copyright (c) 2008-2016 Andreas Kupries '\" -.TH "zipfile::decode" n 0\&.6 tcllib "Zip archive handling" +.TH "zipfile::decode" n 0\&.7\&.1 tcllib "Zip archive handling" .\" The -*- nroff -*- definitions below are for supplemental macros used .\" in Tcl/Tk manual entries. .\" .\" .AP type name in/out ?indent? .\" Start paragraph describing an argument to a library procedure. @@ -276,17 +276,17 @@ .SH SYNOPSIS package require \fBTcl 8\&.4\fR .sp package require \fBfileutil::magic::mimetype \fR .sp -package require \fBfileutil::decode 0\&.2\fR +package require \fBfileutil::decode 0\&.2\&.1\fR .sp package require \fBTrf \fR .sp package require \fBzlibtcl \fR .sp -package require \fBzipfile::decode ?0\&.6?\fR +package require \fBzipfile::decode ?0\&.7\&.1?\fR .sp \fB::zipfile::decode::archive\fR .sp \fB::zipfile::decode::close\fR .sp @@ -401,8 +401,8 @@ decompression, zip .SH CATEGORY File .SH COPYRIGHT .nf -Copyright (c) 2008-2014 Andreas Kupries +Copyright (c) 2008-2016 Andreas Kupries .fi ADDED idoc/www/tcllib/files/modules/udpcluster/udpcluster.html Index: idoc/www/tcllib/files/modules/udpcluster/udpcluster.html ================================================================== --- /dev/null +++ idoc/www/tcllib/files/modules/udpcluster/udpcluster.html @@ -0,0 +1,184 @@ + +udpcluster - Lightweight UDP based tool for cluster node discovery + + + + + +
    [ + Tcllib Home +| Main Table Of Contents +| Table Of Contents +| Keyword Index +| Categories +| Modules +| Applications + ]
    +
    +

    udpcluster(n) 0.3 tcllib "Lightweight UDP based tool for cluster node discovery"

    +

    Name

    +

    udpcluster - UDP Peer-to-Peer cluster

    +
    + +

    Synopsis

    +
    +
      +
    • package require Tcl 8.5
    • +
    • package require ip
    • +
    • package require nettool
    • +
    • package require comm
    • +
    • package require interp
    • +
    • package require dicttool
    • +
    • package require cron
    • +
    +
    +
    +

    Description

    +

    This package is a lightweight alternative to Zeroconf. It utilizes UDP packets to +populate a table of services provided by each node on a local network. Each participant +broadcasts a key/value list in plain UTF-8 which lists what ports are open, and what +protocols are expected on those ports. Developers are free to add any additional key/value +pairs beyond those.

    +

    Using udpcluster.

    +

    For every service you wish to publish invoke:

    +
    +cluster::publish echo@[cluster::macid] {port 10000 protocol echo}
    +
    +

    To query what services are available on the local network:

    +
    +set results [cluster::search PATTERN]
    +# And inside that result...
    +echo@LOCALMACID {
    +   port 10000
    +   protocol echo
    +}
    +
    +

    To unpublish a service:

    +
    +cluster::unpublish echo@[cluster::macid]
    +
    +

    Results will +Historical Notes:

    +

    This tool was originally known as nns::cluster, but as development progressed, it was +clear that it wasn't interacting with any of the other facilities in NNS.

    +
    +

    Bugs, Ideas, Feedback

    +

    This document, and the package it describes, will undoubtedly contain +bugs and other problems. +Please report such in the category nameserv of the +Tcllib Trackers. +Please also report any ideas for enhancements you may have for either +package and/or documentation.

    +
    + +

    Category

    +

    Networking

    +
    + +
    Index: idoc/www/tcllib/files/modules/zip/decode.html ================================================================== --- idoc/www/tcllib/files/modules/zip/decode.html +++ idoc/www/tcllib/files/modules/zip/decode.html @@ -92,11 +92,11 @@ } --> -
    [ Tcllib Home @@ -106,11 +106,11 @@ | Categories | Modules | Applications ]
    -

    zipfile::decode(n) 0.6 tcllib "Zip archive handling"

    +

    zipfile::decode(n) 0.7.1 tcllib "Zip archive handling"

    Name

    zipfile::decode - Access to zip archives

    Table Of Contents

      @@ -127,14 +127,14 @@

      Synopsis

      • package require Tcl 8.4
      • package require fileutil::magic::mimetype
      • -
      • package require fileutil::decode 0.2
      • +
      • package require fileutil::decode 0.2.1
      • package require Trf
      • package require zlibtcl
      • -
      • package require zipfile::decode ?0.6?
      • +
      • package require zipfile::decode ?0.7.1?

      Category

      File

      Index: modules/fileutil/decode.tcl ================================================================== --- modules/fileutil/decode.tcl +++ modules/fileutil/decode.tcl @@ -1,9 +1,9 @@ # -*- tcl -*- # ### ### ### ######### ######### ######### -## Copyright (c) 2008-2009 ActiveState Software Inc. -## Andreas Kupries +## Copyright (c) 2008-2009 ActiveState Software Inc., Andreas Kupries +## 2016 Andreas Kupries ## BSD License ## # Package to help the writing of file decoders. Provides generic # low-level support commands. @@ -52,11 +52,13 @@ proc ::fileutil::decode::rewind {} { variable chan variable mark if {$mark == {}} { - return -code error "No mark to rewind to" + return -code error \ + -errorcode {FILE DECODE NO MARK} \ + "No mark to rewind to" } seek $chan $mark start set mark {} return } @@ -69,31 +71,35 @@ # ### ### ### ######### ######### ######### ## proc ::fileutil::decode::byte {} { variable chan + variable mask 0xff variable val [read $chan 1] binary scan $val c val return } proc ::fileutil::decode::short-le {} { variable chan + variable mask 0xffff variable val [read $chan 2] binary scan $val s val return } proc ::fileutil::decode::long-le {} { variable chan + variable mask 0xffffffff variable val [read $chan 4] binary scan $val i val return } proc ::fileutil::decode::nbytes {n} { variable chan + variable mask {} variable val [read $chan $n] return } proc ::fileutil::decode::skip {n} { @@ -107,11 +113,17 @@ ## proc ::fileutil::decode::unsigned {} { variable val if {$val >= 0} return - set val [format %u [expr {$val & 0xffffffff}]] + variable mask + if {$mask eq {}} { + return -code error \ + -errorcode {FILE DECODE ILLEGAL UNSIGNED} \ + "Unsigned not possible here" + } + set val [format %u [expr {$val & $mask}]] return } proc ::fileutil::decode::match {eval} { variable val @@ -181,11 +193,15 @@ # Remembered location in the stream variable mark {} # Buffer for accumulating structured results variable buf {} + + # Mask for trimming a value to unsigned. + # Size-dependent + variable mask {} } # ### ### ### ######### ######### ######### ## Ready -package provide fileutil::decode 0.2 +package provide fileutil::decode 0.2.1 return Index: modules/fileutil/pkgIndex.tcl ================================================================== --- modules/fileutil/pkgIndex.tcl +++ modules/fileutil/pkgIndex.tcl @@ -5,6 +5,6 @@ package ifneeded fileutil::traverse 0.6 [list source [file join $dir traverse.tcl]] if {![package vsatisfies [package provide Tcl] 8.4]} {return} package ifneeded fileutil::multi 0.1 [list source [file join $dir multi.tcl]] package ifneeded fileutil::multi::op 0.5.3 [list source [file join $dir multiop.tcl]] -package ifneeded fileutil::decode 0.2 [list source [file join $dir decode.tcl]] +package ifneeded fileutil::decode 0.2.1 [list source [file join $dir decode.tcl]] Index: modules/zip/decode.man ================================================================== --- modules/zip/decode.man +++ modules/zip/decode.man @@ -1,16 +1,16 @@ -[vset ZIP_DECODE_VERSION 0.6] +[vset ZIP_DECODE_VERSION 0.7.1] [comment {-*- tcl -*- doctools manpage}] [manpage_begin zipfile::decode n [vset ZIP_DECODE_VERSION]] [keywords decompression zip] -[copyright {2008-2014 Andreas Kupries}] +[copyright {2008-2016 Andreas Kupries}] [moddesc {Zip archive handling}] [titledesc {Access to zip archives}] [category File] [require Tcl 8.4] [require fileutil::magic::mimetype] -[require fileutil::decode 0.2] +[require fileutil::decode 0.2.1] [require Trf] [require zlibtcl] [require zipfile::decode [opt [vset ZIP_DECODE_VERSION]]] [description] [para] Index: modules/zip/decode.tcl ================================================================== --- modules/zip/decode.tcl +++ modules/zip/decode.tcl @@ -1,17 +1,17 @@ # -*- tcl -*- # ### ### ### ######### ######### ######### -## Copyright (c) 2008-2012 ActiveState Software Inc. -## Andreas Kupries +## Copyright (c) 2008-2012 ActiveState Software Inc., Andreas Kupries +## 2016 Andreas Kupries ## BSD License ## # Package providing commands for the decoding of basic zip-file # structures. package require Tcl 8.4 package require fileutil::magic::mimetype ; # Tcllib. File type determination via magic constants -package require fileutil::decode 0.2 ; # Framework for easy decoding of files. +package require fileutil::decode 0.2.1 ; # Framework for easy decoding of files. namespace eval ::zipfile::decode {} if {[package vcompare $tcl_patchLevel "8.6"] < 0} { # Only needed pre-8.6 package require Trf ; # Wrapper to zlib package require zlibtcl ; # Zlib usage. No commands, access through Trf @@ -58,12 +58,11 @@ proc ::zipfile::decode::open {fname} { variable eoa if {[catch { set eoa [LocateEnd $fname] } msg]} { - return -code error -errorcode {ZIP DECODE BAD ARCHIVE} \ - "\"$fname\" is not a zip file" + Error "\"$fname\" is not a zip file" BAD ARCHIVE } fileutil::decode::open $fname return } @@ -97,12 +96,11 @@ proc ::zipfile::decode::copyfile {zdict src dst} { array set _ $zdict array set f $_(files) if {![info exists f($src)]} { - return -code error -errorcode {ZIP DECODE BAD PATH} \ - "File \"$src\" not known" + Error "File \"$src\" not known" BAD PATH } array set fd $f($src) CopyFile $src fd $dst return @@ -111,12 +109,11 @@ proc ::zipfile::decode::getfile {zdict src} { array set _ $zdict array set f $_(files) if {![info exists f($src)]} { - return -code error -errorcode {ZIP DECODE BAD PATH} \ - "File \"$src\" not known" + Error "File \"$src\" not known" BAD PATH } array set fd $f($src) return [GetFile $src fd] } @@ -180,12 +177,12 @@ [getval]] } ::close $out } default { - return -code error -errorcode {ZIP DECODE BAD COMPRESSION} \ - "Unable to handle file \"$src\" compressed with method \"$fd(cm)\"" + Error "Unable to handle file \"$src\" compressed with method \"$fd(cm)\"" \ + BAD COMPRESSION } } if { ($::tcl_platform(platform) ne "windows") && @@ -208,10 +205,13 @@ return } proc ::zipfile::decode::GetFile {src fdv} { + # See also CopyFile for similar code. + # TODO: Check with CopyFile for refactoring opportunity + upvar 1 $fdv fd # Entry is a directory. if {[string match */ $src]} {return {}} @@ -232,12 +232,12 @@ go $fd(fileloc) nbytes $fd(csize) return [zip -mode decompress -nowrap 1 -- [getval]] } default { - return -code error -errorcode {ZIP DECODE BAD COMPRESSION} \ - "Unable to handle file \"$src\" compressed with method \"$fd(cm)\"" + Error "Unable to handle file \"$src\" compressed with method \"$fd(cm)\"" \ + BAD COMPRESSION } } # FUTURE: Run crc checksum on created file and compare to the # ......: stored information. @@ -297,13 +297,13 @@ clear short-le ; unsigned ; recode VER ; put vmb ; # ++ version made by short-le ; unsigned ; recode VER ; put vnte ; # version needed to extract short-le ; unsigned ; put gpbf ; # general purpose bitflag - short-le ; unsigned ; recode CM ; put cm ; # compression method - short-le ; unsigned ; put lmft ; # last mod file time - short-le ; unsigned ; put lmfd ; # last mod file date + short-le ; unsigned ; recode CM ; put cm ; # compression method + short-le ; unsigned ; put lmft ; # last mod file time + short-le ; unsigned ; put lmfd ; # last mod file date long-le ; unsigned ; put crc ; # crc32 | zero's here imply non-seekable, long-le ; unsigned ; put csize ; # compressed file size | data is in a DDS behind the stored long-le ; unsigned ; put ucsize ; # uncompressed file size | file. short-le ; unsigned ; put fnamelen ; # file name length short-le ; unsigned ; put efieldlen2 ; # extra field length @@ -384,12 +384,11 @@ array set hdr [get] set hdr(ddpresent) 1 setbuf [array get hdr] } } else { - return -code error -errorcode {ZIP DECODE INCOMPLETE} \ - "Search data descriptor. Not Yet Implementyed" + Error "Search data descriptor. Not Yet Implemented" INCOMPLETE } return 1 } proc ::zipfile::decode::archive {} { @@ -415,23 +414,21 @@ # LFH command already used that up. set here [at] go [expr {$cb(base) + $_(localloc)}] if {![localfileheader]} { - return -code error -errorcode {ZIP DECODE BAD ARCHIVE} \ - "Bad zip file. Directory entry without file." + ArchiveError "Directory entry without file." DIR WITHOUT FILE } array set lh [get] ; clear go $here # Compare the information in the CFH entry and associated # LFH. Should match. if {![hdrmatch lh _]} { - return -code error -errorcode {ZIP DECODE BAD ARCHIVE} \ - "Bad zip file. File/Dir Header mismatch." + ArchiveError "File/Dir Header mismatch." HEADER MISMATCH FILE/DIR } # Merge local and central data. array set lh $data @@ -439,20 +436,21 @@ unset lh _ incr nentries } if {![endcentralfiledir]} { - return -code error "Bad zip file. Bad closure." + ArchiveError "Bad closure." BAD CLOSURE } array set _ [get] ; clear #parray _ #puts \#$nentries if {$nentries != $_(tnecd)} { - return -code error "Bad zip file. \#Files does match \#Actual files" + ArchiveError "\#Files ($_(tnecd)) does not match \#Actual files ($nentries)" \ + MISMATCH COUNTS } set _(files) [array get fn] return [array get _] } @@ -592,10 +590,23 @@ return $res } # ### ### ### ######### ######### ######### + +proc ::zipfile::decode::ArchiveError {msg args} { + # Inlined "Error" -- Avoided eval/linsert dance + set code [linsert $args 0 ZIP DECODE BAD ARCHIVE] + return -code error -errorcode $code "Bad zip file. $msg" +} + +proc ::zipfile::decode::Error {msg args} { + set code [linsert $args 0 ZIP DECODE] + return -code error -errorcode $code $msg +} + +# ### ### ### ######### ######### ######### ## Decode the zip file by locating its end (of the central file ## header). The higher levels will then use the information ## inside to locate and read the CFH. No scanning from the beginning ## This piece of code lifted from tclvs/library/zipvfs (v 1.0.3). @@ -633,11 +644,11 @@ # sequence for the inner, uncompressed archive. set pos [string last "PK\05\06" $hdr] if {$pos == -1} { if {$at >= $sz} { - return -code error "no header found" + ArchiveError "No header found" HEADER MISSING } # after the 1st iteration we force an overlap with last # buffer to ensure that the pattern we look for is not # split at a buffer boundary, nor the header itself @@ -684,7 +695,7 @@ return [array get cb] } # ### ### ### ######### ######### ######### ## Ready -package provide zipfile::decode 0.7 +package provide zipfile::decode 0.7.1 return Index: modules/zip/pkgIndex.tcl ================================================================== --- modules/zip/pkgIndex.tcl +++ modules/zip/pkgIndex.tcl @@ -1,8 +1,8 @@ if {![package vsatisfies [package provide Tcl] 8.4]} {return} -package ifneeded zipfile::decode 0.7 [list source [file join $dir decode.tcl]] -package ifneeded zipfile::encode 0.4 [list source [file join $dir encode.tcl]] +package ifneeded zipfile::decode 0.7.1 [list source [file join $dir decode.tcl]] +package ifneeded zipfile::encode 0.4 [list source [file join $dir encode.tcl]] if {![package vsatisfies [package provide Tcl] 8.6]} {return} package ifneeded zipfile::mkzip 1.2 [list source [file join $dir mkzip.tcl]]