Difference between revisions of "Nszlib"

From AOLserver Wiki
Jump to navigation Jump to search
(imported from WiKit id 142)
 
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
 
Allows compressing/uncompressing Tcl strings as well as gzip file support.
 
Allows compressing/uncompressing Tcl strings as well as gzip file support.
  
Download: http://www.crystalballinc.com/vlad/software/
+
Integrated into the AOLserver core as of version 4.5 - see [[ns_zlib]]
 +
 
 +
Download: http://www.crystalballinc.com/vlad/software/ for older versions of AOLserver
 +
 
 +
'''EXAMPLES'''
 +
 
 +
    # Compress Tcl string
 +
    set test "This is test string for compression"
 +
 
 +
    set data [ns_zlib compress $test]
 +
 
 +
    set test [ns_zlib uncompress $data]
 +
    ns_log Debug Uncompress: $test
 +
 
 +
    # Compress the string into gzip format
 +
    set gzip [ns_zlib gzip $test]
 +
 
 +
    # Save as gzip file
 +
    set fd [open /tmp/test.gz w]
 +
    fconfigure $fd -translation binary -encoding binary
 +
    puts -nonewline $fd $gzip
 +
    close $fd
 +
 
 +
    # Uncompress gzipped file
 +
    set test [ns_zlib gunzip /tmp/test.gz]
 +
    ns_log Debug Ungzipped: $test

Latest revision as of 00:59, 19 June 2010

Author: Vlad Seryakov

This is AOLserver module that implements Zlib interface. Allows compressing/uncompressing Tcl strings as well as gzip file support.

Integrated into the AOLserver core as of version 4.5 - see ns_zlib

Download: http://www.crystalballinc.com/vlad/software/ for older versions of AOLserver

EXAMPLES

   # Compress Tcl string
   set test "This is test string for compression"
   set data [ns_zlib compress $test]
   set test [ns_zlib uncompress $data]
   ns_log Debug Uncompress: $test
   # Compress the string into gzip format
   set gzip [ns_zlib gzip $test]
   # Save as gzip file
   set fd [open /tmp/test.gz w]
   fconfigure $fd -translation binary -encoding binary
   puts -nonewline $fd $gzip
   close $fd
   # Uncompress gzipped file
   set test [ns_zlib gunzip /tmp/test.gz]
   ns_log Debug Ungzipped: $test