<%args>
$ipass
$definition
%options=>(notused => "on")
</%args>

<%perl>

# chef (c) 2000 Chris Snell <chris@blueaspen.com>
# chef reads configurations from the definitions file and
# assembles them into IMG tags which then call Grapher.pm
#
# 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


# # # # # # # # # # # # # # # #
#  C O N F I G U R A T I O N  #
# # # # # # # # # # # # # # # #

# you'll want to change the hostname of course
# but you'll probably want to leave the /grapher part
# intact, unless you specified it differently in your
# httpd.conf
my $URL_BASE="http://bronc.blueaspen.com/grapher";

use URI::Escape;
my $targ;
my $dog;
my $option;
my $url;
my $c_url;
my $c_file;
my $c_color;
my $c_type;
my $a_target;
my $c_title;
my $c_vertical_label;
my $c_graph_width;
my $c_graph_height;
my $c_resize_width;
my $c_resize_height;
my $c_interlaced;
my $c_logarithmic;
my $c_start;
my $c_end;
my $c_legend_title;
my $c_legend_formula;
my $c_legend_text;
my $c_cdef;
my $c_cdef_title;
my $c_target_label;
my $a_legend;
my $a_cdef;

my $count = 1;
foreach $a_target (@{$ipass->[$definition]{'targets'}}) {
	$c_url = uri_escape($a_target->{'target'});
	$c_target_label = uri_escape($a_target->{'label'});
	$url .= "&t$count=$a_target->{'target'}";
	if ($a_target->{'label'}) {
		$url .= "&tl$count=$c_target_label";
	}
	if ($a_target->{'file'}) {
		$c_file = uri_escape($a_target->{'file'});
		$url .= "&fi$count=$c_file";
	}
	if ($a_target->{'color'}) {
		$c_color = uri_escape($a_target->{'color'});
		$url .= "&c$count=$c_color";
	}
	if ($a_target->{'type'}) {
		$c_type = uri_escape($a_target->{'type'});
		$url .= "&gt$count=$c_type";
	}
	$count++;
}
#my $debugger=`echo \" $ipass->[$definition]{'options'}{'title'} \" > /tmp/macy`;
$url =~ s/^\&/\?/g;  # heh, doesn't my perl suck?!?!!
if (! $ipass->[$definition]{'options'}{'notused'}) {
	if ($ipass->[$definition]{'options'}{'title'}) {
		$c_title = uri_escape($ipass->[$definition]{'options'}{'title'});
		$url .= "&ti=$c_title";
	}
	if ($ipass->[$definition]{'options'}{'vertical_label'}) {
		$c_vertical_label = uri_escape($ipass->[$definition]{'options'}{'vertical_label'});
		$url .= "&vl=$c_vertical_label";
	}
	if ($ipass->[$definition]{'options'}{'graph_width'}) {
		$c_graph_width = uri_escape($ipass->[$definition]{'options'}{'graph_width'});
		$url .= "&gw=$c_graph_width";
	}
	if ($ipass->[$definition]{'options'}{'graph_height'}) {
		$c_graph_height = uri_escape($ipass->[$definition]{'options'}{'graph_height'});
		$url .= "&gh=$c_graph_height";
	}
        if ($ipass->[$definition]{'options'}{'resize_width'}) {
                $c_resize_width = uri_escape($ipass->[$definition]{'options'}{'resize_width'});
                $url .= "&sx=$c_resize_width";
        }
        if ($ipass->[$definition]{'options'}{'resize_height'}) {
                $c_resize_height = uri_escape($ipass->[$definition]{'options'}{'resize_height'});
                $url .= "&sy=$c_resize_height";
        }
        if ($ipass->[$definition]{'options'}{'interlaced'}) {
                $c_interlaced = uri_escape($ipass->[$definition]{'options'}{'interlaced'});
                $url .= "&il=$c_interlaced";
        }
	if ($ipass->[$definition]{'options'}{'logarithmic'}) {
		$c_logarithmic = uri_escape($ipass->[$definition]{'options'}{'logarithmic'});
		$url .= "&lg=$c_logarithmic";
	}
	if ($ipass->[$definition]{'options'}{'start'}) {
		$c_start = uri_escape($ipass->[$definition]{'options'}{'start'});
		$url .= "&st=$c_start";
	}
	if ($ipass->[$definition]{'options'}{'end'}) {
		$c_end = uri_escape($ipass->[$definition]{'options'}{'end'});
		$url .= "&et=$c_end";
	}
	if ($ipass->[$definition]{'options'}{'composite_defs'}) {
		$count = 1;
		foreach $a_cdef ( keys %{$ipass->[$definition]{'options'}{'composite_defs'}} ) {
			$c_cdef = uri_escape($ipass->[$definition]{'options'}{'composite_defs'}{$a_cdef});
			$url .= "&ct$count=$a_cdef&cp$count=$c_cdef";
			$count++;
		}
	}
	if ($ipass->[$definition]{'options'}{'legend'}) {
		$count = 0;
		foreach $a_legend ( @{$ipass->[$definition]{'options'}{'legend'}} ) {
			$c_legend_title = uri_escape(${$ipass->[$definition]{'options'}{'legend'}}[$count]->{'target'});
			$c_legend_formula = uri_escape(${$ipass->[$definition]{'options'}{'legend'}}[$count]->{'formula'});
			$c_legend_text = uri_escape(${$ipass->[$definition]{'options'}{'legend'}}[$count]->{'text'});
			$url .= "&lt$count=$c_legend_title&lf$count=$c_legend_formula&lx$count=$c_legend_text";
			$count++;
		}
	}
}
my $epoch = time;
mc_out "<IMG BORDER=0 SRC=\"${URL_BASE}$url&cb=$epoch\">";
</%perl>
