package PhotoPub::CLBase;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw();

use PhotoPub::Global qw($error &register_init);
use PhotoPub::Utils qw(%errorstrings);
use PhotoPub::Ages qw(&initage);

use strict;
use vars qw($query);
use Carp;

sub error {
  my ($type,$message);
  if (scalar @_==1) {
    &carp("Old parameter format sent to error handler");
    ($message)=@_;
    $type='unknown';
  } else {
    my %options=@_;
    $message=$options{'message'};
    $type=$options{'type'} || 'unknown';
  }
  $type eq 'unknown' and &carp("Didn't specify error type");

  print $errorstrings{$type}.": $message\n";

  exit unless $type eq 'warning';
}

sub printheader {
  print $query->header(-"Last-Modified" => 
		       CGI::expires(getage()-time(),'http'),@_);
}

BEGIN {
  $error=\&error;
}

&register_init('config',sub {
		 &initage();
	       });

1;
