Index: trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 13629)
+++ trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 13631)
@@ -1,5 +1,5 @@
 # Copyright (c) 2006  Paul Price, Joshua Hoblitt
 #
-# $Id: Config.pm,v 1.53 2007-06-05 02:49:03 price Exp $
+# $Id: Config.pm,v 1.54 2007-06-05 03:19:57 price Exp $
 
 package PS::IPP::Config;
@@ -86,4 +86,5 @@
 	path => $path,		# Path
 	camera => undef,	# Camera configuration
+	rejection => undef,	# Rejection data
 	_ipprc => $mdc		# The parsed configuration
 	};
@@ -95,21 +96,9 @@
 }
 
-# Define a camera to use
-sub define_camera
-{
-    my $self = shift;		# Configuration object
-    my $name = shift;		# Camera name
-
-    unless (defined $self and defined $name) {
-	carp "Programming error";
-	exit($PS_EXIT_PROG_ERROR);
-    }
-
-    my $camera_list = metadataLookupMD($self->{_ipprc}, 'CAMERAS'); # List of cameras
-    my $filename = metadataLookupStr($camera_list, $name); # Filename of camera configuration
-    unless (defined $filename) {
-	carp "Unable to find configuration file for camera $name\n";
-	exit($PS_EXIT_CONFIG_ERROR);
-    }
+# Find a configuration file, which might be anywhere in the PATH
+sub _find_config
+{
+    my $self = shift;		# Configuration object
+    my $filename = shift;	# File name to find
 
     my @path = split /:/, $self->{path}; # List of paths to try
@@ -127,5 +116,5 @@
 	    if (-f $realfile) {
 		$found = 1;
-		last;
+		return $realfile;
 	    }
 	}
@@ -143,4 +132,28 @@
 	}
     }
+
+    carp "Unable to find configuration file: $filename";
+    exit($PS_EXIT_CONFIG_ERROR);
+}
+
+# Define a camera to use
+sub define_camera
+{
+    my $self = shift;		# Configuration object
+    my $name = shift;		# Camera name
+
+    unless (defined $self and defined $name) {
+	carp "Programming error";
+	exit($PS_EXIT_PROG_ERROR);
+    }
+
+    my $camera_list = metadataLookupMD($self->{_ipprc}, 'CAMERAS'); # List of cameras
+    my $filename = metadataLookupStr($camera_list, $name); # Filename of camera configuration
+    unless (defined $filename) {
+	carp "Unable to find configuration file for camera $name\n";
+	exit($PS_EXIT_CONFIG_ERROR);
+    }
+
+    my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH
 
     # Read the file
@@ -534,16 +547,37 @@
     }
 
-    my $camera = $self->{camera}; # Camera configuration
-    unless (defined $camera) {
-	carp "Camera has not yet been defined.\n";
-	return undef;
-    }
-
-    my $rejection = metadataLookupMD($camera, 'REJECTION');	# Rejection list
-    unless (defined $rejection) {
-	carp "Can't find REJECTION list in camera configuration.\n";
-	return undef;
-    }
-
+    unless (defined $self->{rejection}) {
+	my $camera = $self->{camera}; # Camera configuration
+	unless (defined $camera) {
+	    carp "Camera has not yet been defined.\n";
+	    return undef;
+	}
+	
+	my $rejName = metadataLookupStr($camera, 'REJECTION'); # Name of rejection file
+	unless (defined $rejName) {
+	    carp "Can't find REJECTION list in camera configuration.\n";
+	    return undef;
+	}
+	
+	my $rejRealName = $self->_find_config($rejName); # Resolved filename, after hunting the PATH
+
+	my $rejFile;		# Rejection file handle
+	unless (open $rejFile, $rejRealName) {
+	    carp "Unable to open rejection file $rejRealName: $!";
+	    exit($PS_EXIT_CONFIG_ERROR);
+	}
+	my @rejContents = <$rejFile>; # Contents of the rejection file
+	close $rejFile;
+	
+	my $self->{rejection} = $parser->parse( join '', @rejContents); # The rejection metadata
+	unless (defined $self->{rejection}) {
+	    carp "Unable to parse rejection file $rejRealName.";
+	    exit($PS_EXIT_CONFIG_ERROR);
+	}
+    }
+
+    my $rejection = $self->{rejection};
+
+    # Find the appropriate entry
   TYPES: foreach my $item (@$rejection) {
       if (lc($item->{name}) eq $type) {
