#!/usr/local/perl/bin/perl

use strict;
use warnings;

# 2010-05-26 (ed)
#       script that prints what's in the cache.
#       feed this program a set of header files and it will spit
#       back the URL of the request.
#
#       find cache_dir -type f -name '*.header' \
#               perl cache_uris.pl

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

while( my $fn = <STDIN> ) {
	chomp $fn;
	my $buffer;
	open( F, $fn ) or die $!; #sub { print $!, "\n"; next; }
	seek( F, 48, 0 );

	# ie refuses to use URLs > 2083 characters (IIRC)
	read( F, $buffer, 8192 ) or die $!;# sub { print $!, "\n"; next; }
	close(F);
	my @p = split( /\?/, $buffer, 2 );

	print $p[0], "\n";
}


