"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "OpenVerse/lib/GifHeader.tcl" of archive OpenVerse-0.8-7.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) Tcl/Tk source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 #!/usr/bin/tclsh
    2 #
    3 # changed
    4 #
    5 # This will read in a gif file header and decide
    6 # if it is within bounds. (or even a valid file)
    7 #
    8 
    9 proc CheckGif {file} {
   10 	global MV
   11 
   12 	set infile [open $file r]
   13 	fconfigure $infile -translation binary
   14 	set bits [read $infile 10]
   15 	close $infile
   16 	binary scan $bits c* var1
   17 	if {[string range $bits 0 2] != "GIF"} {puts "FAILED";return 0}
   18 	binary scan $bits s* var2
   19 	if {[lindex $var2 3] < $MV(maxheight) & [lindex $var2 4] < $MV(maxwidth)} {
   20 		puts "PASSED"
   21 		return 1
   22 	} else {
   23 		puts "FAILED"
   24 		return 0
   25 	}
   26 }