# favicon.itcl # Serves images/*.ico. # # Designed to serve favicon.ico so your TiVo will have a bookmark icon. # # Almost a straight copy of serve_image in httpd-tt.tcl # # First version. 28Aug03 18:26 proc serve_ico {chan imagename head_req last_modified} { global source_dir set imagename [file rootname $imagename] set fd "" set imagedata "" set moddate "" catch { set fd [open "$source_dir/images/$imagename.ico" "r"] } if { $fd != "" } { set moddate [file mtime "$source_dir/images/$imagename.ico"] if { $head_req == 1 } { print_html_header_200 $chan "image/x-icon" $moddate } elseif { $last_modified == $moddate } { print_html_header_304 $chan } else { print_html_header_200 $chan "image/x-icon" $moddate fconfigure $chan -translation binary fconfigure $fd -translation binary fcopy $fd $chan } close $fd } else { print_html_header_404 $chan } } register_content_handler "ico" "image/x-icon" "$source_dir/images" 1 serve_ico