zip(3trf)

πŸ’– zip β€” the data compression glow-up πŸ’–

okay bestie, welcome to zip, the 3trf manual page, aka the moment your data gets squished down to size and honestly? it's giving main character energy ✨


🌸 NAME 🌸

zip β€” Data compression "zip" πŸ—œοΈπŸ’…


✨ SYNOPSIS ✨

package require Tcl  ?8.2?

package require Trf  ?2.1.3?

zip ?options...? ?data?

like. that's the whole vibe right there. three lines. iconic.


πŸ¦‹ DESCRIPTION πŸ¦‹

so zip is one of the several data compressions that the trf package brings to the party πŸŽ‰ and if you wanna know about the whole package, go read trf-intro for the full overview, no cap.

the command is built on the deflate compression algorithm, exactly as specified in RFC 1951 (http://www.rfc-editor.org/rfc/rfc1951.txt) and as implemented by the zlib compression library (http://www.gzip.org/zlib/). also go peek at RFC 1950 (http://www.rfc-editor.org/rfc/rfc1950.txt) while you're at it 🫢

zip ?options...? ?data?

πŸŽ€ the options πŸŽ€

  • -mode compress|decompress β€” this one has to be there. like, mandatory. and it's always understood by the compression, periodt.
    • in immediate mode, the argument value tells you which operation to use. for an attached compress, it says which operation to use for writing β€” reading will automatically use the reverse operation, bestie, it just knows πŸ’…
    • see the section IMMEDIATE versus ATTACHED for what those two terms even mean.
    • beyond the argument values listed above, all unique abbreviations are recognized too. slay.
    • Compress causes the compression of arbitrary (most likely binary) data. Decompression does the reverse.
  • -level integer β€” specifies the compression level. it's either the string default or an integer number in the range 1 (minimal compression) to 9 (maximal compression). pick your fighter πŸ”₯
  • -nowrap boolean β€” if you set it to true, the command will not create the zip specific header (see RFC 1950) that's normally written before the compressed data. this option defaults to false. you have to use it when you're writing a gzip emulation in Tcl, because gzip creates a different header. iykyk.
  • -attach channel β€” whether this option is present or not literally determines the main operation mode of the transformation. the whole vibe check, honestly.
    • if it's present, the transformation gets stacked onto the channel whose handle you gave to the option and runs in attached mode. more about this in the IMMEDIATE versus ATTACHED section.
    • if it's absent, the transformation is used in immediate mode and the options listed below are recognized. again, more in IMMEDIATE versus ATTACHED.
  • -in channel β€” this option is legal if and only if the transformation is used in immediate mode. it gives you the handle of the channel that the data to transform has to be read from.
    • if the transformation is in immediate mode and this option is absent, the data to transform is expected as the last argument to the transformation.
  • -out channel β€” this option is legal if and only if the transformation is used in immediate mode. it gives you the handle of the channel that the generated transformation result gets written to.
    • if the transformation is in immediate mode and this option is absent, the generated data is returned as the result of the command itself. cute, right? 🎁

πŸ’œ IMMEDIATE VERSUS ATTACHED πŸ’œ

the transformation distinguishes between two main ways of using it, bestie. these are the immediate and attached operation modes. two modes, two moods 🧚

for the attached mode you use the option -attach to associate the transformation with an existing channel. during the execution of the command, no transformation is performed β€” instead the channel is changed in such a way that from then on, all data written to or read from it passes through the transformation and gets modified by it according to the definition above. this attachment can be revoked by executing the command unstack for the chosen channel. and heads up: this is the only way to do this at the Tcl level. no other route. periodt.

in the second mode, which you can detect by the absence of the option -attach, the transformation immediately takes data from either its commandline or a channel, transforms it, and returns the result either as the result of the command, or writes it into a channel. the mode is named after the immediate nature of its execution. it's giving instant gratification ✨

where the data is taken from, and delivered to, is governed by the presence and absence of the options -in and -out. and ngl, you should note that this ability to immediately read from and/or write to a channel is an historic artifact which was introduced at the beginning of Trf's life when Tcl version 7.6 was current β€” because that version and earlier ones had trouble dealing with \0 characters embedded into either input or output 😭 ancient lore fr fr.


🌈 SEE ALSO 🌈

  • bz2
  • trf-intro
  • zip

(go read them, they're all part of the friend group 🫢)


⭐ KEYWORDS ⭐

compression, data compression, decompression, rfc 1950, rfc 1951, rfc 1952, zip


Copyright (c) 1996-2003, Andreas Kupries <andreas_kupries@users.sourceforge.net>


and that's the whole page, bestie πŸ’– this was the Trf transformer commands page for zip, version 2.1.3, manual section zip(3trf) β€” go forth and compress responsibly, you absolute icon πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from