Index: branches/eam_branches/20091113/DataStore/lib/DataStore/File.pm
===================================================================
--- branches/eam_branches/20091113/DataStore/lib/DataStore/File.pm	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/lib/DataStore/File.pm	(revision 26236)
@@ -233,4 +233,8 @@
                 optional    => 1,
             },
+            no_proxy     => {
+                type        => SCALAR,
+                optional    => 1,
+            },
         },
     );
@@ -245,4 +249,10 @@
         $ua = LWP::UserAgent->new;
     }
+
+    # load proxy environment variables (if any)
+    if (!$p{no_proxy}) {
+        $ua->env_proxy;
+    }
+
     my $request = HTTP::Request->new(GET => $self->uri);
     my $filename = $p{filename};
Index: branches/eam_branches/20091113/DataStore/lib/DataStore/FileSet.pm
===================================================================
--- branches/eam_branches/20091113/DataStore/lib/DataStore/FileSet.pm	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/lib/DataStore/FileSet.pm	(revision 26236)
@@ -189,4 +189,8 @@
         {
             ua_args     => {
+                optional    => 1,
+            },
+            no_proxy     => {
+                type        => SCALAR,
                 optional    => 1,
             },
@@ -201,4 +205,10 @@
         $ua = LWP::UserAgent->new;
     }
+
+    if (!$p{no_proxy}) {
+        # load proxy environment variables (if any)
+        $ua->env_proxy;
+    }
+
     my $request = HTTP::Request->new(GET => $self->uri);
     my $response = $ua->request($request);
Index: branches/eam_branches/20091113/DataStore/lib/DataStore/Product.pm
===================================================================
--- branches/eam_branches/20091113/DataStore/lib/DataStore/Product.pm	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/lib/DataStore/Product.pm	(revision 26236)
@@ -172,4 +172,8 @@
                 optional    => 1,
             },
+            no_proxy     => {
+                type        => SCALAR,
+                optional    => 1,
+            },
         },
     );
@@ -182,4 +186,9 @@
         $ua = LWP::UserAgent->new;
     }
+
+    if (!$p{no_proxy}) {
+        # load proxy environment variables (if any)
+        $ua->env_proxy;
+    } 
 
     my $request;
Index: branches/eam_branches/20091113/DataStore/lib/DataStore/Root.pm
===================================================================
--- branches/eam_branches/20091113/DataStore/lib/DataStore/Root.pm	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/lib/DataStore/Root.pm	(revision 26236)
@@ -136,4 +136,8 @@
                 optional    => 1,
             },
+            no_proxy        => {
+                type        => SCALAR,
+                optional    => 1,
+            },
         },
     );
@@ -145,4 +149,9 @@
     } else {
         $ua = LWP::UserAgent->new;
+    }
+
+    if (!$p{no_proxy}) {
+        # load proxy environment variables (if any)
+        $ua->env_proxy;
     }
 
Index: branches/eam_branches/20091113/DataStore/scripts/dsfilesetls
===================================================================
--- branches/eam_branches/20091113/DataStore/scripts/dsfilesetls	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/scripts/dsfilesetls	(revision 26236)
@@ -16,9 +16,10 @@
 use Pod::Usage qw( pod2usage );
 
-my ($uri, $timeout);
+my ($uri, $timeout, $no_proxy);
 
 GetOptions(
     'uri|u=s'           => \$uri,
     'timeout|t=s'       => \$timeout,
+    'no-proxy'          => \$no_proxy,
 ) or pod2usage( 2 );
 
@@ -31,7 +32,9 @@
 # default http request timeout is 30s
 $timeout ||= 30;
+$no_proxy = 0 if !defined $no_proxy;
 
 my $response = DataStore::FileSet->new( uri => $uri )->request(
         ua_args  => { timeout => $timeout },
+        no_proxy => $no_proxy,
     );
 
@@ -91,4 +94,10 @@
 Optional.
 
+=item * --no-proxy
+
+Do not load proxy environment variables.
+
+Optional.
+
 =back
 
Index: branches/eam_branches/20091113/DataStore/scripts/dsget
===================================================================
--- branches/eam_branches/20091113/DataStore/scripts/dsget	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/scripts/dsget	(revision 26236)
@@ -28,4 +28,5 @@
     $timeout,
     @xattrs,
+    $no_proxy,
 );
 
@@ -44,4 +45,5 @@
     'timeout|t=s'   => \$timeout,
     'xattr|x=s'     => \@xattrs,
+    'no-proxy'      => \$no_proxy,
 ) or pod2usage( 2 );
 
@@ -80,4 +82,5 @@
 # default http request timeout is 30s
 $timeout ||= 30;
+$no_proxy = 0 if !defined $no_proxy;
 
 my %p = (
@@ -140,4 +143,5 @@
         filename => $tmpfilename,
         ua_args  => { timeout => $timeout },
+        no_proxy => $no_proxy,
     );
 
@@ -302,4 +306,10 @@
 Optional.
 
+=item * --no-proxy
+
+Do not load proxy environment variables.
+
+Optional.
+
 =item * --copies <n>
 
Index: branches/eam_branches/20091113/DataStore/scripts/dsgetfileset
===================================================================
--- branches/eam_branches/20091113/DataStore/scripts/dsgetfileset	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/scripts/dsgetfileset	(revision 26236)
@@ -17,5 +17,5 @@
 use File::Basename qw( basename );
 
-my ($uri, $outdir, $timeout, $verbose);
+my ($uri, $outdir, $timeout, $no_proxy, $verbose);
 
 GetOptions(
@@ -23,4 +23,5 @@
     'outdir|o=s'        => \$outdir,
     'timeout|t=s'       => \$timeout,
+    'no-proxy'          => \$no_proxy,
     'verbose|v'         => \$verbose,
 ) or pod2usage( 2 );
@@ -34,7 +35,9 @@
 # default http request timeout is 30s
 $timeout ||= 30;
+$no_proxy = 0 if !defined $no_proxy;
 
 my $response = DataStore::FileSet->new( uri => $uri )->request(
         ua_args  => { timeout => $timeout },
+        no_proxy => $no_proxy,
     );
 
@@ -117,4 +120,10 @@
 Optional.
 
+=item * --no-proxy
+
+Do not load proxy environment variables.
+
+Optional.
+
 =back
 
Index: branches/eam_branches/20091113/DataStore/scripts/dsleech
===================================================================
--- branches/eam_branches/20091113/DataStore/scripts/dsleech	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/scripts/dsleech	(revision 26236)
@@ -18,5 +18,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($dir, $uri, $last_fileset, $overwrite, $recall, $remember, $verbose, $timeout);
+my ($dir, $uri, $last_fileset, $overwrite, $recall, $remember, $verbose, $timeout, $no_proxy);
 
 GetOptions(
@@ -28,5 +28,6 @@
     'remember'          => \$remember,
     'verbose|v'         => \$verbose,
-    'timeout|t'         => \$timeout,
+    'timeout|t=i'       => \$timeout,
+    'no-proxy'          => \$no_proxy,
 ) or pod2usage( 2 );
 
@@ -39,4 +40,5 @@
 # default http request timeout is 30s
 $timeout ||= 30;
+$no_proxy = 0 if !defined $no_proxy;
 
 my %p = (
@@ -65,4 +67,5 @@
 my $response = DataStore::Product->new(%p)->request(
     ua_args  => { timeout => $timeout },
+    no_proxy => $no_proxy,
 );
 
@@ -281,4 +284,10 @@
 Optional.
 
+=item * --no-proxy
+
+Do not load proxy environment variables.
+
+Optional.
+
 =back
 
Index: branches/eam_branches/20091113/DataStore/scripts/dsproductls
===================================================================
--- branches/eam_branches/20091113/DataStore/scripts/dsproductls	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/scripts/dsproductls	(revision 26236)
@@ -16,5 +16,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($uri, $last_fileset, $timeout, $extra);
+my ($uri, $last_fileset, $timeout, $extra, $no_proxy);
 
 GetOptions(
@@ -22,5 +22,6 @@
     'last_fileset|l=s'  => \$last_fileset,
     'timeout|t=s'       => \$timeout,
-    'extra|e'         => \$extra,
+    'extra|e'           => \$extra,
+    'no-proxy'          => \$no_proxy,
 ) or pod2usage( 2 );
 
@@ -33,4 +34,5 @@
 # default http request timeout is 30s
 $timeout ||= 30;
+$no_proxy = 0 if !defined $no_proxy;
 
 my %p = (
@@ -42,4 +44,5 @@
 my $response = DataStore::Product->new(%p)->request(
         ua_args  => { timeout => $timeout },
+        no_proxy => $no_proxy,
     );
 
@@ -111,4 +114,10 @@
 Optional.
 
+=item * --no-proxy
+
+Do not load proxy environment variables.
+
+Optional.
+
 =back
 
Index: branches/eam_branches/20091113/DataStore/scripts/dsrootls
===================================================================
--- branches/eam_branches/20091113/DataStore/scripts/dsrootls	(revision 26235)
+++ branches/eam_branches/20091113/DataStore/scripts/dsrootls	(revision 26236)
@@ -16,9 +16,10 @@
 use Pod::Usage qw( pod2usage );
 
-my ($uri, $timeout);
+my ($uri, $timeout, $no_proxy);
 
 GetOptions(
     'uri|u=s'       => \$uri,
-    'timeout|t'     => \$timeout,
+    'timeout|t=i'   => \$timeout,
+    'no-proxy'      => \$no_proxy,
 ) or pod2usage( 2 );
 
@@ -31,4 +32,5 @@
 # default http request timeout is 30s
 $timeout ||= 30;
+$no_proxy = 0 if !defined $no_proxy;
 
 my %p = (
@@ -38,4 +40,5 @@
 my $response = DataStore::Root->new(%p)->request(
         ua_args  => { timeout => $timeout },
+        no_proxy => $no_proxy,
     );
 
@@ -93,4 +96,10 @@
 Optional.
 
+=item * --no-proxy
+
+Do not load proxy environment variables.
+
+Optional.
+
 =back
 
Index: branches/eam_branches/20091113/DataStoreServer/scripts/dsprodtool
===================================================================
--- branches/eam_branches/20091113/DataStoreServer/scripts/dsprodtool	(revision 26235)
+++ branches/eam_branches/20091113/DataStoreServer/scripts/dsprodtool	(revision 26236)
@@ -67,5 +67,5 @@
 
 # will exit if neither or both -add and -del were specified
-$err .= "Must specify either --add or --del.\n"
+show_usage( "Must specify either --add or --del.")
     unless $add xor $del;
 
@@ -79,5 +79,5 @@
     }
 
-} else {
+} elsif ($del) {
     $product = $del;
     if (! -t STDIN) {
Index: branches/eam_branches/20091113/Ohana/src/getstar/src/MatchCoords.c
===================================================================
--- branches/eam_branches/20091113/Ohana/src/getstar/src/MatchCoords.c	(revision 26235)
+++ branches/eam_branches/20091113/Ohana/src/getstar/src/MatchCoords.c	(revision 26236)
@@ -55,4 +55,8 @@
         }
 
+#ifdef notdef
+        printf("%d %8.1f %8.1f %s\n", i, x, y, dbImages[i].name);
+#endif
+
         if ((x >= xmin && x <= xmax) && (y >= ymin && y <= ymax)) {
             totalMatches++;
Index: branches/eam_branches/20091113/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- branches/eam_branches/20091113/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 26235)
+++ branches/eam_branches/20091113/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 26236)
@@ -16,5 +16,4 @@
 use File::Spec 0.87;
 use File::Temp qw( tempfile );
-use IO::Handle;
 
 use PS::IPP::Metadata::Config 1.00;
@@ -696,9 +695,5 @@
         print STDERR "   redirect stdout to $filename succeded on try $try\n";
     }
-    # turn off buffering of output so that output from this script doesn't appear later
-    # that output from execed programs
-    STDOUT->autoflush(1);
     open STDERR, ">>$filename" or ( carp "failed to redirect stderr to $filename" and return undef );
-    STDERR->autoflush(1);
 
     return 1;
Index: branches/eam_branches/20091113/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
===================================================================
--- branches/eam_branches/20091113/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 26235)
+++ branches/eam_branches/20091113/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm	(revision 26236)
@@ -84,9 +84,14 @@
 
         my $image = $results->[0];
-        if (($img_type eq "raw") or ($img_type eq "chip")) {
-            $req_type = "byexp";
-            $id = $image->{exp_name};
+        if ($img_type eq "raw") {
+            $req_type = "byid";
+            $id = $image->{exp_id};
             return undef if !$id;
-            # fall through and lookup byexp
+            # fall through and lookup byid
+        } elsif ($img_type eq "chip") {
+            $req_type = "byid";
+            $id = $image->{chip_id};
+            return undef if !$id;
+            # fall through and lookup byid
         } elsif ($img_type eq "warp") {
             $req_type = "byid";
@@ -171,5 +176,7 @@
     }
 
+    # note $magic_arg may be cleared below depending on $req_type
     my $magic_arg = $need_magic ? " -destreaked" : "";
+
     my $component_args;
     if ($img_type eq "raw") {
@@ -229,7 +236,14 @@
         $command .= " $id_opt $id";
         $command .= $component_args if $component_args;
+        # don't include -destreaked if lookup is byid. Let pstampparse check so that the
+        # error code returned to the client for a given component is 'not destreaked'
+        # instead of 'not found'
+        $magic_arg = "";
     } elsif ($req_type eq "byexp") {
         $command .= " -exp_name $id";
         $command .= $component_args if $component_args;
+        # don't include -destreaked if lookup is byexp. Let pstampparse check so that the error code gives
+        # the reason as 'not destreaked'
+        $magic_arg = "";
     } elsif ($req_type eq "byskycell") {
         die "tess_id and component are required for byskycell" if !$tess_id or ! $skycell_id;
@@ -237,4 +251,8 @@
     } elsif ($req_type eq "bycoord") {
         $command .= " -radius 3.0 -ra $x -decl $y";
+        if ($img_type ne "raw") {
+            $command .= " -tess_id $tess_id" if $tess_id;
+            $command .= " -skycell_id $skycell_id" if $skycell_id;
+        }
     } else {
         die "Unknown req_type supplied: $req_type";
@@ -299,7 +317,10 @@
         # (we do this here for raw stage)
         $out->{image}  = $image->{uri};
+
         if ($set_class_id) {
             $class_id = $image->{class_id};
             $out->{component} = $class_id;
+        } else {
+            $out->{component} = $image->{skycell_id};
         }
         my $stage_id;
@@ -307,5 +328,5 @@
             $stage_id = $image->{exp_id};
         } elsif ($img_type eq "chip") {
-            $stage_id = $image->{chip};
+            $stage_id = $image->{chip_id};
         } elsif ($img_type eq "warp") {
             $stage_id = $image->{warp_id};
@@ -315,7 +336,7 @@
             $stage_id = $image->{stack_id};
         }
-        $image->{stage_id} = $stage_id;
-        $image->{stage}    = $img_type;
-        $image->{image_db} = $image_db;
+        $out->{stage_id} = $stage_id;
+        $out->{stage}    = $img_type;
+        $out->{image_db} = $image_db;
 
         # find the mask and weight images
@@ -402,5 +423,5 @@
         }
 
-        my ($warp_id, $exp_id, $exp_name);
+        my ($warp_id, $exp_id, $exp_name, $chip_id, $cam_id);
         if ($inverse and !$image->{bothways}) {
             print STDERR "Inverse images requested for diffRun that is not bothways. Ignoring.\n";
@@ -411,8 +432,12 @@
             $exp_id = $image->{exp_id_2};
             $exp_name = $image->{exp_name_2};
+            $chip_id = $image->{chip_id_2};
+            $cam_id = $image->{cam_id_2};
         } else {
             $warp_id =  $image->{warp1};
             $exp_id = $image->{exp_id_1};
             $exp_name = $image->{exp_name_1};
+            $chip_id = $image->{chip_id_1};
+            $cam_id = $image->{cam_id_1};
         }
         # XXX difftool currently returns max long long for null
@@ -422,4 +447,6 @@
             $image->{exp_id} = $exp_id;
             $image->{exp_name} = $exp_name;
+            $image->{chip_id} = $chip_id;
+            $image->{cam_id} = $cam_id;
         } else {
             print STDERR "unexpected result warp_id not defined\n";
@@ -561,7 +588,10 @@
     }
 
-    # If there are multiple cam runs for this exposure, take the last one
-    # assuming that it has the best astrometry 
-    my $camdata = pop @$camruns;
+    # If there are multiple cam runs for this exposure, take the last completed one
+    # on the assumption that it has the best astrometry.
+    my $camdata;
+    while ($camdata = pop @$camruns) {
+        last if (($camdata->{quality} eq 0) and ($camdata->{fault} eq 0));
+    }
     if (!$camdata) {
         # no cam runs for this exposure id therefore best astrometry is whatever is in the header
Index: branches/eam_branches/20091113/dbconfig/changes.1.1.56
===================================================================
--- branches/eam_branches/20091113/dbconfig/changes.1.1.56	(revision 26235)
+++ 	(revision )
@@ -1,78 +1,0 @@
-ALTER TABLE chipRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE chipRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group;
-ALTER TABLE chipRun ADD COLUMN note VARCHAR(255) AFTER magicked;
-ALTER TABLE chipRun ADD KEY(data_group);
-ALTER TABLE chipRun ADD KEY(dist_group);
-
-UPDATE chipRun SET data_group = label;
-UPDATE chipRun SET dist_group = label;
-
-ALTER TABLE camRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE camRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group;
-ALTER TABLE camRun ADD COLUMN note VARCHAR(255) AFTER magicked;
-ALTER TABLE camRun ADD KEY(data_group);
-ALTER TABLE camRun ADD KEY(dist_group);
-
-UPDATE camRun SET data_group = label;
-UPDATE camRun SET dist_group = label;
-
-ALTER TABLE addRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE addRun ADD COLUMN note VARCHAR(255) AFTER dvodb;
-ALTER TABLE addRun ADD KEY(data_group);
-
-UPDATE addRun SET data_group = label;
-
-ALTER TABLE fakeRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE fakeRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group;
-ALTER TABLE fakeRun ADD COLUMN note VARCHAR(255) AFTER epoch;
-ALTER TABLE fakeRun ADD KEY(data_group);
-ALTER TABLE fakeRun ADD KEY(dist_group);
-
-UPDATE fakeRun SET data_group = label;
-UPDATE fakeRun SET dist_group = label;
-
-ALTER TABLE warpRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE warpRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group;
-ALTER TABLE warpRun ADD COLUMN note VARCHAR(255) AFTER magicked;
-ALTER TABLE warpRun ADD KEY(data_group);
-ALTER TABLE warpRun ADD KEY(dist_group);
-
-UPDATE warpRun SET data_group = label;
-UPDATE warpRun SET dist_group = label;
-
-ALTER TABLE stackRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE stackRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group;
-ALTER TABLE stackRun ADD COLUMN note VARCHAR(255) AFTER filter;
-ALTER TABLE stackRun ADD KEY(data_group);
-ALTER TABLE stackRun ADD KEY(dist_group);
-
-UPDATE stackRun SET data_group = label;
-UPDATE stackRun SET dist_group = label;
-
-ALTER TABLE diffRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE diffRun ADD COLUMN dist_group VARCHAR(64) AFTER data_group;
-ALTER TABLE diffRun ADD COLUMN note VARCHAR(255) AFTER magicked;
-ALTER TABLE diffRun ADD KEY(data_group);
-ALTER TABLE diffRun ADD KEY(dist_group);
-
-UPDATE diffRun SET data_group = label;
-UPDATE diffRun SET dist_group = label;
-
-ALTER TABLE magicRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE magicRun ADD COLUMN note VARCHAR(255) AFTER fault;
-ALTER TABLE magicRun ADD KEY(data_group);
-
-UPDATE magicRun SET data_group = label;
-
-ALTER TABLE magicDSRun ADD COLUMN data_group VARCHAR(64) AFTER label;
-ALTER TABLE magicDSRun ADD COLUMN fault SMALLINT after remove;
-ALTER TABLE magicDSRun ADD COLUMN note VARCHAR(255) AFTER fault;
-ALTER TABLE magicDSRun ADD KEY(fault);
-ALTER TABLE magicDSRun ADD KEY(data_group);
-
-UPDATE magicDSRun SET data_group = label;
-UPDATE magicDSRun SET fault = 0;
-
-ALTER TABLE distRun ADD COLUMN note VARCHAR(255) after fault;
-
-ALTER TABLE distTarget CHANGE COLUMN label dist_group VARCHAR(64);
Index: branches/eam_branches/20091113/dbconfig/changes.txt
===================================================================
--- branches/eam_branches/20091113/dbconfig/changes.txt	(revision 26235)
+++ branches/eam_branches/20091113/dbconfig/changes.txt	(revision 26236)
@@ -16,6 +16,6 @@
 -- Version 1.1.22 --> 1.1.23
 -- Adding support for reduction classes (which are used to specify recipes for parts of the pipeline).
-# Adding 'reduction' to detRun
-# Renaming 'recipe' in {chip,cam}{Pending,Processed}Exp to 'reduction'
+-- Adding 'reduction' to detRun
+-- Renaming 'recipe' in {chip,cam}{Pending,Processed}Exp to 'reduction'
 
 alter table detRun add column reduction varchar(64) NULL DEFAULT NULL after exp_type;
@@ -82,5 +82,5 @@
 alter table stackSumSkyfile add column hostname varchar(64) after dtime_stack;
 
-#alter table warpSkyfile add column ( dtime_warp float, hostname varchar(64) );
+-- alter table warpSkyfile add column ( dtime_warp float, hostname varchar(64) );
 alter table warpSkyfile add column dtime_warp float after bg_stdev;
 alter table warpSkyfile add column hostname varchar(64) after dtime_warp;
@@ -1424,9 +1424,9 @@
 ALTER TABLE publishClient ADD COLUMN active TINYINT DEFAULT 0 AFTER client_id;
 
-# add outdir to allow spreading files over multiple hosts
+--  add outdir to allow spreading files over multiple hosts
 ALTER TABLE distRun ADD COLUMN outdir VARCHAR(255) AFTER outroot;
 ALTER TABLE distComponent ADD COLUMN outdir VARCHAR(255) AFTER state;
 
-# populate the existing runs (except for bills' test runs)
+-- populate the existing runs (except for bills' test runs)
 UPDATE distRun SET outdir = CONCAT_WS('.', outroot, dist_id) WHERE outroot not like '%@HOST@%';
 UPDATE distRun join distComponent using(dist_id) SET distComponent.outdir = CONCAT_WS('.', distRun.outroot, dist_id);
Index: branches/eam_branches/20091113/dbconfig/config.md
===================================================================
--- branches/eam_branches/20091113/dbconfig/config.md	(revision 26235)
+++ branches/eam_branches/20091113/dbconfig/config.md	(revision 26236)
@@ -2,4 +2,4 @@
     pkg_name        STR     ippdb
     pkg_namespace   STR     ippdb
-    pkg_version     STR     1.1.56
+    pkg_version     STR     1.1.57
 END
Index: branches/eam_branches/20091113/doc/latex/html.sty
===================================================================
--- branches/eam_branches/20091113/doc/latex/html.sty	(revision 26236)
+++ branches/eam_branches/20091113/doc/latex/html.sty	(revision 26236)
@@ -0,0 +1,1083 @@
+%
+% $Id: html.sty,v 1.1 2006/02/14 22:30:19 isani Exp $
+% LaTeX2HTML Version 99.1 : html.sty
+% 
+% This file contains definitions of LaTeX commands which are
+% processed in a special way by the translator. 
+% For example, there are commands for embedding external hypertext links,
+% for cross-references between documents or for including raw HTML.
+% This file includes the comments.sty file v2.0 by Victor Eijkhout
+% In most cases these commands do nothing when processed by LaTeX.
+%
+% Place this file in a directory accessible to LaTeX (i.e., somewhere
+% in the TEXINPUTS path.)
+%
+% NOTE: This file works with LaTeX 2.09 or (the newer) LaTeX2e.
+%       If you only have LaTeX 2.09, some complex LaTeX2HTML features
+%       like support for segmented documents are not available.
+
+% Changes:
+% See the change log at end of file.
+
+
+% Exit if the style file is already loaded
+% (suggested by Lee Shombert <las@potomac.wash.inmet.com>
+\ifx \htmlstyloaded\relax \endinput\else\let\htmlstyloaded\relax\fi
+\makeatletter
+
+% protect against the hyperref package being loaded already
+
+\ifx\undefined\hyperref
+ \let\html@new=\newcommand
+\else
+ \let\html@new=\renewcommand
+\fi
+
+\providecommand{\latextohtml}{\LaTeX2\texttt{HTML}}
+
+%%% LINKS TO EXTERNAL DOCUMENTS
+%
+% This can be used to provide links to arbitrary documents.
+% The first argumment should be the text that is going to be
+% highlighted and the second argument a URL.
+% The hyperlink will appear as a hyperlink in the HTML 
+% document and as a footnote in the dvi or ps files.
+%
+\html@new{\htmladdnormallinkfoot}[2]{#1\footnote{#2}} 
+
+
+% This is an alternative definition of the command above which
+% will ignore the URL in the dvi or ps files.
+\html@new{\htmladdnormallink}[2]{#1}
+
+
+% This command takes as argument a URL pointing to an image.
+% The image will be embedded in the HTML document but will
+% be ignored in the dvi and ps files.
+%
+\html@new{\htmladdimg}[1]{}
+
+
+%%% CROSS-REFERENCES BETWEEN (LOCAL OR REMOTE) DOCUMENTS
+%
+% This can be used to refer to symbolic labels in other Latex 
+% documents that have already been processed by the translator.
+% The arguments should be:
+% #1 : the URL to the directory containing the external document
+% #2 : the path to the labels.pl file of the external document.
+% If the external document lives on a remote machine then labels.pl 
+% must be copied on the local machine.
+%
+%e.g. \externallabels{http://cbl.leeds.ac.uk/nikos/WWW/doc/tex2html/latex2html}
+%                    {/usr/cblelca/nikos/tmp/labels.pl}
+% The arguments are ignored in the dvi and ps files.
+%
+\newcommand{\externallabels}[2]{}
+
+
+% This complements the \externallabels command above. The argument
+% should be a label defined in another latex document and will be
+% ignored in the dvi and ps files.
+%
+\newcommand{\externalref}[1]{}
+
+
+% Suggested by  Uffe Engberg (http://www.brics.dk/~engberg/)
+% This allows the same effect for citations in external bibliographies.
+% An  \externallabels  command must be given, locating a labels.pl file
+% which defines the location and keys used in the external .html file.
+%  
+\newcommand{\externalcite}{\nocite}
+
+% This allows a section-heading in the TOC or mini-TOC to be just
+% a hyperlink to an external document.
+%
+%   \htmladdTOClink[<path_to_labels>]{<section-level>}{<title>}{<URL>}
+% where <section-level> is  'chapter' , 'section' , 'subsection' etc.
+% and <path_to_labels> is the path to find a  labels.pl  file,
+% so that external cross-referencing may work, as with \externallabels
+%
+\newcommand{\htmladdTOClink}[4][]{}
+
+
+%%% HTMLRULE
+% This command adds a horizontal rule and is valid even within
+% a figure caption.
+% Here we introduce a stub for compatibility.
+\newcommand{\htmlrule}{\protect\HTMLrule}
+\newcommand{\HTMLrule}{\@ifstar\htmlrulestar\htmlrulestar}
+\newcommand{\htmlrulestar}[1]{}
+
+%%% HTMLCLEAR
+% This command puts in a <BR> tag, with CLEAR="ALL"
+\newcommand{\htmlclear}{}
+
+% This command adds information within the <BODY> ... </BODY> tag
+%
+\newcommand{\bodytext}[1]{}
+\newcommand{\htmlbody}{}
+
+
+%%% HYPERREF 
+% Suggested by Eric M. Carol <eric@ca.utoronto.utcc.enfm>
+% Similar to \ref but accepts conditional text. 
+% The first argument is HTML text which will become ``hyperized''
+% (underlined).
+% The second and third arguments are text which will appear only in the paper
+% version (DVI file), enclosing the fourth argument which is a reference to a label.
+%
+%e.g. \hyperref{using the tracer}{using the tracer (see Section}{)}{trace}
+% where there is a corresponding \label{trace}
+%
+% avoid possible confict with  hyperref  package
+\ifx\undefined\hyperref
+ \newcommand{\hyperrefhyper}[4]{#4}%
+ \def\next{\newcommand}%
+\else
+ \let\hyperrefhyper\hyperref
+ \def\next{\renewcommand}%
+\fi
+\next{\hyperref}{\hyperrefi[]}\let\next=\relax
+
+\def\hyperrefi[#1]{{\def\next{#1}\def\tmp{}%
+ \ifx\next\tmp\aftergroup\hyperrefdef
+ \else\def\tmp{ref}\ifx\next\tmp\aftergroup\hyperrefref
+ \else\def\tmp{pageref}\ifx\next\tmp\aftergroup\hyperrefpageref
+ \else\def\tmp{page}\ifx\next\tmp\aftergroup\hyperrefpage
+ \else\def\tmp{noref}\ifx\next\tmp\aftergroup\hyperrefnoref
+ \else\def\tmp{no}\ifx\next\tmp\aftergroup\hyperrefno
+ \else\def\tmp{hyper}\ifx\next\tmp\aftergroup\hyperrefhyper
+ \else\def\tmp{html}\ifx\next\tmp\aftergroup\hyperrefhtml
+ \else\typeout{*** unknown option \next\space to  hyperref ***}%
+ \fi\fi\fi\fi\fi\fi\fi\fi}}
+\newcommand{\hyperrefdef}[4]{#2\ref{#4}#3}
+\newcommand{\hyperrefpageref}[4]{#2\pageref{#4}#3}
+\newcommand{\hyperrefnoref}[3]{#2}
+\let\hyperrefref=\hyperrefdef
+\let\hyperrefpage=\hyperrefpageref
+\let\hyperrefno=\hyperrefnoref
+\ifx\undefined\hyperrefhyper\newcommand{\hyperrefhyper}[4]{#4}\fi
+\let\hyperrefhtml=\hyperrefdef
+
+%%% HYPERCITE --- added by RRM
+% Suggested by Stephen Simpson <simpson@math.psu.edu>
+% effects the same ideas as in  \hyperref, but for citations.
+% It does not allow an optional argument to the \cite, in LaTeX.
+%
+%   \hypercite{<html-text>}{<LaTeX-text>}{<opt-text>}{<key>}
+%
+% uses the pre/post-texts in LaTeX, with a  \cite{<key>}
+%
+%   \hypercite[ext]{<html-text>}{<LaTeX-text>}{<key>}
+%   \hypercite[ext]{<html-text>}{<LaTeX-text>}[<prefix>]{<key>}
+%
+% uses the pre/post-texts in LaTeX, with a  \nocite{<key>}
+% the actual reference comes from an \externallabels  file.
+%
+\newcommand{\hypercite}{\hypercitei[]}
+\def\hypercitei[#1]{{\def\next{#1}\def\tmp{}%
+ \ifx\next\tmp\aftergroup\hypercitedef
+ \else\def\tmp{int}\ifx\next\tmp\aftergroup\hyperciteint
+ \else\def\tmp{cite}\ifx\next\tmp\aftergroup\hypercitecite
+ \else\def\tmp{ext}\ifx\next\tmp\aftergroup\hyperciteext
+ \else\def\tmp{nocite}\ifx\next\tmp\aftergroup\hypercitenocite
+ \else\def\tmp{no}\ifx\next\tmp\aftergroup\hyperciteno
+ \else\typeout{*** unknown option \next\space to  hypercite ***}%
+ \fi\fi\fi\fi\fi\fi}}
+\newcommand{\hypercitedef}[4]{#2{\def\tmp{#3}\def\emptyopt{}%
+ \ifx\tmp\emptyopt\cite{#4}\else\cite[#3]{#4}\fi}}
+\newcommand{\hypercitenocite}[2]{#2\hypercitenocitex[]}
+\def\hypercitenocitex[#1]#2{\nocite{#2}}
+\let\hypercitecite=\hypercitedef
+\let\hyperciteint=\hypercitedef
+\let\hyperciteext=\hypercitenocite
+\let\hyperciteno=\hypercitenocite
+
+%%% HTMLREF
+% Reference in HTML version only.
+% Mix between \htmladdnormallink and \hyperref.
+% First arg is text for in both versions, second is label for use in HTML
+% version.
+\html@new{\htmlref}[2]{#1}
+
+%%% HTMLCITE
+% Reference in HTML version only.
+% Mix between \htmladdnormallink and \hypercite.
+% First arg is text for in both versions, second is citation for use in HTML
+% version.
+\newcommand{\htmlcite}[2]{#1}
+
+
+%%% HTMLIMAGE
+% This command can be used inside any environment that is converted
+% into an inlined image (eg a "figure" environment) in order to change
+% the way the image will be translated. The argument of \htmlimage
+% is really a string of options separated by commas ie 
+% [scale=<scale factor>],[external],[thumbnail=<reduction factor>
+% The scale option allows control over the size of the final image.
+% The ``external'' option will cause the image not to be inlined 
+% (images are inlined by default). External images will be accessible
+% via a hypertext link. 
+% The ``thumbnail'' option will cause a small inlined image to be 
+% placed in the caption. The size of the thumbnail depends on the
+% reduction factor. The use of the ``thumbnail'' option implies
+% the ``external'' option.
+%
+% Example:
+% \htmlimage{scale=1.5,external,thumbnail=0.2}
+% will cause a small thumbnail image 1/5th of the original size to be
+% placed in the final document, pointing to an external image 1.5
+% times bigger than the original.
+% 
+\newcommand{\htmlimage}[1]{}
+
+
+% \htmlborder causes a border to be placed around an image or table
+% when the image is placed within a <TABLE> cell.
+\newcommand{\htmlborder}[1]{}
+
+% Put \begin{makeimage}, \end{makeimage} around LaTeX to ensure its
+% translation into an image.
+% This shields sensitive text from being translated.
+\newenvironment{makeimage}{}{}
+
+
+% A dummy environment that can be useful to alter the order
+% in which commands are processed, in LaTeX2HTML
+\newenvironment{tex2html_deferred}{}{}
+
+
+%%% HTMLADDTONAVIGATION
+% This command appends its argument to the buttons in the navigation
+% panel. It is ignored by LaTeX.
+%
+% Example:
+% \htmladdtonavigation{\htmladdnormallink
+%              {\htmladdimg{http://server/path/to/gif}}
+%              {http://server/path}}
+\newcommand{\htmladdtonavigation}[1]{}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% based upon Eijkhout's  comment.sty v2.0
+% with modifications to avoid conflicts with later versions
+% of this package, should a user be requiring it.
+%	Ross Moore,  10 March 1999
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Comment.sty   version 2.0, 19 June 1992
+% selectively in/exclude pieces of text: the user can define new
+% comment versions, and each is controlled separately.
+% This style can be used with plain TeX or LaTeX, and probably
+% most other packages too.
+%
+% Examples of use in LaTeX and TeX follow \endinput
+%
+% Author
+%    Victor Eijkhout
+%    Department of Computer Science
+%    University Tennessee at Knoxville
+%    104 Ayres Hall
+%    Knoxville, TN 37996
+%    USA
+%
+%    eijkhout@cs.utk.edu
+%
+% Usage: all text included in between
+%    \comment ... \endcomment
+% or \begin{comment} ... \end{comment}
+% is discarded. The closing command should appear on a line
+% of its own. No starting spaces, nothing after it.
+% This environment should work with arbitrary amounts
+% of comment.
+%
+% Other 'comment' environments are defined by
+% and are selected/deselected with
+% \includecomment{versiona}
+% \excludecoment{versionb}
+%
+% These environments are used as
+% \versiona ... \endversiona
+% or \begin{versiona} ... \end{versiona}
+% with the closing command again on a line of its own.
+%
+% Basic approach:
+% to comment something out, scoop up  every line in verbatim mode
+% as macro argument, then throw it away.
+% For inclusions, both the opening and closing comands
+% are defined as noop
+%
+% Changed \next to \html@next to prevent clashes with other sty files
+% (mike@emn.fr)
+% Changed \html@next to \htmlnext so the \makeatletter and
+% \makeatother commands could be removed (they were causing other
+% style files - changebar.sty - to crash) (nikos@cbl.leeds.ac.uk)
+% Changed \htmlnext back to \html@next...
+
+\def\makeinnocent#1{\catcode`#1=12 }
+\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
+
+\def\ThrowAwayComment#1{\begingroup
+    \def\CurrentComment{#1}%
+    \let\do\makeinnocent \dospecials
+    \makeinnocent\^^L% and whatever other special cases
+%%RRM
+%%  use \xhtmlComment for \xComment
+%%  use \html@next    for \next
+    \endlinechar`\^^M \catcode`\^^M=12 \xhtmlComment}
+{\catcode`\^^M=12 \endlinechar=-1 %
+ \gdef\xhtmlComment#1^^M{\def\test{#1}\edef\test{\meaning\test}
+      \csarg\ifx{PlainEnd\CurrentComment Test}\test
+          \let\html@next\endgroup
+      \else \csarg\ifx{LaLaEnd\CurrentComment Test}\test
+            \edef\html@next{\endgroup\noexpand\end{\CurrentComment}}
+      \else \csarg\ifx{LaInnEnd\CurrentComment Test}\test
+            \edef\html@next{\endgroup\noexpand\end{\CurrentComment}}
+      \else \let\html@next\xhtmlComment
+      \fi \fi \fi \html@next}
+}
+
+%%\def\includecomment	%%RRM
+\def\htmlincludecomment
+ #1{\expandafter\def\csname#1\endcsname{}%
+    \expandafter\def\csname end#1\endcsname{}}
+%%\def\excludecomment	%%RRM
+\def\htmlexcludecomment
+ #1{\expandafter\def\csname#1\endcsname{\ThrowAwayComment{#1}}%
+    {\escapechar=-1\relax
+     \edef\tmp{\string\\end#1}%
+      \csarg\xdef{PlainEnd#1Test}{\meaning\tmp}%
+     \edef\tmp{\string\\end\string\{#1\string\}}%
+      \csarg\xdef{LaLaEnd#1Test}{\meaning\tmp}%
+     \edef\tmp{\string\\end \string\{#1\string\}}%
+      \csarg\xdef{LaInnEnd#1Test}{\meaning\tmp}%
+    }}
+
+%%\excludecomment{comment}	%%RRM
+\htmlexcludecomment{comment}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% end Comment.sty
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\let\includecomment=\htmlincludecomment
+\let\excludecomment=\htmlexcludecomment
+
+%
+% Alternative code by Robin Fairbairns, 22 September 1997
+% revised to cope with % and unnested { }, by Ross Moore, 4 July 1998
+% further revised to cope with & and # in tables, 10 March 1999
+%
+\def\raw@catcodes{\catcode`\%=12 \catcode`\{=12 \catcode`\}=12
+ \catcode`\&=12 \catcode`\#=12 }
+\newcommand\@gobbleenv{\bgroup\raw@catcodes
+ \let\reserved@a\@currenvir\@gobble@nv}
+\bgroup
+ \def\expansionhead{\gdef\@gobble@nv@i##1}
+ \def\expansiontail{{\def\reserved@b{##1}\@gobble@nv@ii}}
+ \def\expansionheadii{\long\gdef\@gobble@nv##1\end}
+ \def\expansiontailii{{\@gobble@nv@i}}
+ \def\expansionmidii{##2}
+ \raw@catcodes\relax
+ \expandafter\expansionhead\expandafter}\expansiontail
+\egroup
+\long\gdef\@gobble@nv#1\end#2{\@gobble@nv@i}
+%\long\def\@gobble@nv#1\end#2{\def\reserved@b{#2}%
+\def\@gobble@nv@ii{%
+ \ifx\reserved@a\reserved@b
+  \edef\reserved@a{\egroup\noexpand\end{\reserved@a}}%
+  \expandafter\reserved@a
+ \else
+  \expandafter\@gobble@nv
+ \fi}
+
+\renewcommand{\htmlexcludecomment}[1]{%
+    \csname newenvironment\endcsname{#1}{\@gobbleenv}{}}
+\newcommand{\htmlreexcludecomment}[1]{%
+    \csname renewenvironment\endcsname{#1}{\@gobbleenv}{}}
+
+%%% RAW HTML 
+% 
+% Enclose raw HTML between a \begin{rawhtml} and \end{rawhtml}.
+% The html environment ignores its body
+%
+\htmlexcludecomment{rawhtml}
+
+
+%%% HTML ONLY
+%
+% Enclose LaTeX constructs which will only appear in the 
+% HTML output and will be ignored by LaTeX with 
+% \begin{htmlonly} and \end{htmlonly}
+%
+\htmlexcludecomment{htmlonly}
+% Shorter version
+\newcommand{\html}[1]{}
+
+% for images.tex only
+\htmlexcludecomment{imagesonly}
+
+%%% LaTeX ONLY
+% Enclose LaTeX constructs which will only appear in the 
+% DVI output and will be ignored by latex2html with 
+%\begin{latexonly} and \end{latexonly}
+%
+\newenvironment{latexonly}{}{}
+% Shorter version
+\newcommand{\latex}[1]{#1}
+
+
+%%% LaTeX or HTML
+% Combination of \latex and \html.
+% Say \latexhtml{this should be latex text}{this html text}
+%
+%\newcommand{\latexhtml}[2]{#1}
+\long\def\latexhtml#1#2{#1}
+
+
+%%% tracing the HTML conversions
+% This alters the tracing-level within the processing
+% performed by  latex2html  by adjusting  $VERBOSITY
+% (see  latex2html.config  for the appropriate values)
+%
+\newcommand{\htmltracing}[1]{}
+\newcommand{\htmltracenv}[1]{}
+
+
+%%%  \strikeout for HTML only
+% uses <STRIKE>...</STRIKE> tags on the argument
+% LaTeX just gobbles it up.
+\newcommand{\strikeout}[1]{}
+
+%%%  \htmlurl  and  \url
+%  implement \url as the simplest thing, if not already defined
+%  let \htmlurl#1  be equivalent to it 
+%
+\def\htmlurlx#1{\begin{small}\texttt{#1}\end{small}}%
+\expandafter\ifx\csname url\endcsname\relax
+ \let\htmlurl=\htmlurlx \else \let\htmlurl=\url \fi
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% JCL - stop input here if LaTeX2e is not present
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifx\if@compatibility\undefined
+  %LaTeX209
+  \makeatother\relax\expandafter\endinput
+\fi
+\if@compatibility
+  %LaTeX2e in LaTeX209 compatibility mode
+  \makeatother\relax\expandafter\endinput
+\fi
+
+%\let\real@TeXlogo = \TeX
+%\DeclareRobustCommand{\TeX}{\relax\real@TeXlogo}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Start providing LaTeX2e extension:
+% This is currently:
+%  - additional optional argument for \htmladdimg
+%  - support for segmented documents
+%
+
+%\ProvidesPackage{html}
+%          [1996/12/22 v1.1 hypertext commands for latex2html (nd, hws, rrm)]
+\ProvidesPackage{html}
+          [1999/03/12 v1.37 hypertext commands for latex2html (nd, hws, rrm)]
+
+%
+% Ensure that \includecomment and \excludecomment are bound
+% to the version defined here.
+%
+\AtBeginDocument{%
+ \let\includecomment=\htmlincludecomment
+ \let\excludecomment=\htmlexcludecomment
+ \htmlreexcludecomment{comment}}
+
+%%%  bind \htmlurl to \url if that is later loaded
+%
+\expandafter\ifx\csname url\endcsname\relax
+ \AtBeginDocument{\@ifundefined{url}{}{\let\htmlurl=\url}}\fi
+
+%%%%MG
+
+% This command takes as argument a URL pointing to an image.
+% The image will be embedded in the HTML document but will
+% be ignored in the dvi and ps files.  The optional argument
+% denotes additional HTML tags.
+%
+% Example:  \htmladdimg[ALT="portrait" ALIGN=CENTER]{portrait.gif}
+%
+\renewcommand{\htmladdimg}[2][]{}
+
+%%% HTMLRULE for LaTeX2e
+% This command adds a horizontal rule and is valid even within
+% a figure caption.
+%
+% This command is best used with LaTeX2e and HTML 3.2 support.
+% It is like \hrule, but allows for options via key--value pairs
+% as follows:  \htmlrule[key1=value1, key2=value2, ...] .
+% Use \htmlrule* to suppress the <BR> tag.
+% Eg. \htmlrule[left, 15, 5pt, "none", NOSHADE] produces
+% <BR CLEAR="left"><HR NOSHADE SIZE="15">.
+% Renew the necessary part.
+\renewcommand{\htmlrulestar}[1][all]{}
+
+%%% HTMLCLEAR for LaTeX2e
+% This command puts in a <BR> tag, with optional CLEAR="<attrib>"
+%
+\renewcommand{\htmlclear}[1][all]{}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  renew some definitions to allow optional arguments
+%
+% The description of the options is missing, as yet.
+%
+\renewcommand{\latextohtml}{\textup{\LaTeX2\texttt{HTML}}}
+\renewcommand{\htmladdnormallinkfoot}[3][]{#2\footnote{#3}} 
+\renewcommand{\htmladdnormallink}[3][]{#2}
+\renewcommand{\htmlbody}[1][]{}
+\renewcommand{\externallabels}[3][]{}
+\renewcommand{\externalref}[2][]{}
+\renewcommand{\externalcite}[1][]{\nocite}
+\renewcommand{\hyperref}[1][]{\hyperrefi[#1]}
+\renewcommand{\hypercite}[1][]{\hypercitei[#1]}
+\renewcommand{\hypercitenocite}[2]{#2\hypercitenocitex}
+\renewcommand{\hypercitenocitex}[2][]{\nocite{#2}}
+\let\hyperciteno=\hypercitenocite
+\let\hyperciteext=\hypercitenocite
+\renewcommand{\htmlref}[2][]{#2{\def\tmp{#1}\ifx\tmp\@empty
+ \aftergroup\htmlrefdef\else\aftergroup\htmlrefext\fi}}
+\newcommand{\htmlrefdef}[1]{}
+\newcommand{\htmlrefext}[2][]{}
+\renewcommand{\htmlcite}[2][]{#2{\def\tmp{#1}\ifx\tmp\@empty
+ \aftergroup\htmlcitedef\else\aftergroup\htmlciteext\fi}}
+\newcommand{\htmlcitedef}[1]{ \nocite{#1}}
+\newcommand{\htmlciteext}[2][]{}
+\renewcommand{\htmlimage}[2][]{}
+\renewcommand{\htmlborder}[2][]{}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  HTML  HTMLset  HTMLsetenv
+%
+%  These commands do nothing in LaTeX, but can be used to place
+%  HTML tags or set Perl variables during the LaTeX2HTML processing;
+%  They are intended for expert use only.
+
+\newcommand{\HTMLcode}[2][]{}
+\ifx\undefined\HTML\newcommand{\HTML}[2][]{}\else
+\typeout{*** Warning: \string\HTML\space had an incompatible definition ***}%
+\typeout{*** instead use \string\HTMLcode\space for raw HTML code ***}%
+\fi 
+\newcommand{\HTMLset}[3][]{}
+\newcommand{\HTMLsetenv}[3][]{}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% The following commands pertain to document segmentation, and
+% were added by Herbert Swan <dprhws@edp.Arco.com> (with help from
+% Michel Goossens <goossens@cern.ch>):
+%
+%
+% This command inputs internal latex2html tables so that large
+% documents can to partitioned into smaller (more manageable)
+% segments.
+%
+\newcommand{\internal}[2][internals]{}
+
+%
+%  Define a dummy stub \htmlhead{}.  This command causes latex2html
+%  to define the title of the start of a new segment.  It is not
+%  normally placed in the user's document.  Rather, it is passed to
+%  latex2html via a .ptr file written by \segment.
+%
+\newcommand{\htmlhead}[3][]{}
+
+%  In the LaTeX2HTML version this will eliminate the title line
+%  generated by a \segment command, but retains the title string
+%  for use in other places.
+%
+\newcommand{\htmlnohead}{}
+
+
+%  In the LaTeX2HTML version this put a URL into a <BASE> tag
+%  within the <HEAD>...</HEAD> portion of a document.
+%
+\newcommand{\htmlbase}[1]{}
+
+
+%  Include style information into the stylesheet; e.g. CSS
+%
+\newcommand{\htmlsetstyle}[3][]{}
+\newcommand{\htmladdtostyle}[3][]{}
+
+%  Define a style-class for information in a particular language
+%
+\newcommand{\htmllanguagestyle}[2][]{}
+
+
+%
+%  The dummy command \endpreamble is needed by latex2html to
+%  mark the end of the preamble in document segments that do
+%  not contain a \begin{document}
+%
+\newcommand{\startdocument}{}
+
+
+% \tableofchildlinks, \htmlinfo
+%     by Ross Moore  ---  extensions dated 27 September 1997
+%
+%  These do nothing in LaTeX but for LaTeX2HTML they mark 
+%  where the table of child-links and info-page should be placed,
+%  when the user wants other than the default.
+%	\tableofchildlinks	 % put mini-TOC at this location
+%	\tableofchildlinks[off]	 % not on current page
+%	\tableofchildlinks[none] % not on current and subsequent pages
+%	\tableofchildlinks[on]   % selectively on current page
+%	\tableofchildlinks[all]  % on current and all subsequent pages
+%	\htmlinfo	 	 % put info-page at this location
+%	\htmlinfo[off]		 % no info-page in current document
+%	\htmlinfo[none]		 % no info-page in current document
+%  *-versions omit the preceding <BR> tag.
+%
+\newcommand{\tableofchildlinks}{%
+  \@ifstar\tableofchildlinksstar\tableofchildlinksstar}
+\newcommand{\tableofchildlinksstar}[1][]{}
+
+\newcommand{\htmlinfo}{\@ifstar\htmlinfostar\htmlinfostar}
+\newcommand{\htmlinfostar}[1][]{}
+
+
+%  This redefines  \begin  to allow for an optional argument
+%  which is used by LaTeX2HTML to specify `style-sheet' information
+
+\let\realLaTeX@begin=\begin
+\renewcommand{\begin}[1][]{\realLaTeX@begin}
+
+
+%
+%  Allocate a new set of section counters, which will get incremented
+%  for "*" forms of sectioning commands, and for a few miscellaneous
+%  commands.
+%
+
+\@ifundefined{c@part}{\newcounter{part}}{}%
+\newcounter{lpart}
+\newcounter{lchapter}[part]
+\@ifundefined{c@chapter}%
+ {\let\Hchapter\relax \newcounter{chapter}\newcounter{lsection}[part]}%
+ {\let\Hchapter=\chapter \newcounter{lsection}[chapter]}
+\newcounter{lsubsection}[section]
+\newcounter{lsubsubsection}[subsection]
+\newcounter{lparagraph}[subsubsection]
+\newcounter{lsubparagraph}[paragraph]
+%\newcounter{lequation}
+
+%
+%  Redefine "*" forms of sectioning commands to increment their
+%  respective counters.
+%
+\let\Hpart=\part
+%\let\Hchapter=\chapter
+\let\Hsection=\section
+\let\Hsubsection=\subsection
+\let\Hsubsubsection=\subsubsection
+\let\Hparagraph=\paragraph
+\let\Hsubparagraph=\subparagraph
+\let\Hsubsubparagraph=\subsubparagraph
+
+\ifx\c@subparagraph\undefined
+ \newcounter{lsubsubparagraph}[lsubparagraph]
+\else
+ \newcounter{lsubsubparagraph}[subparagraph]
+\fi
+
+%
+%  The following definitions are specific to LaTeX2e:
+%  (They must be commented out for LaTeX 2.09)
+%
+\expandafter\ifx\csname part\endcsname\relax\else
+\renewcommand{\part}{\@ifstar{\stepcounter{lpart}%
+  \bgroup\def\tmp{*}\H@part}{\bgroup\def\tmp{}\H@part}}\fi
+\newcommand{\H@part}[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hpart\tmp}
+
+\ifx\Hchapter\relax\else
+ \def\chapter{\resetsections \@ifstar{\stepcounter{lchapter}%
+   \bgroup\def\tmp{*}\H@chapter}{\bgroup\def\tmp{}\H@chapter}}\fi
+\newcommand{\H@chapter}[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hchapter\tmp}
+
+\renewcommand{\section}{\resetsubsections
+ \@ifstar{\stepcounter{lsection}\bgroup\def\tmp{*}%
+   \H@section}{\bgroup\def\tmp{}\H@section}}
+\newcommand{\H@section}[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hsection\tmp}
+
+\renewcommand{\subsection}{\resetsubsubsections
+ \@ifstar{\stepcounter{lsubsection}\bgroup\def\tmp{*}%
+   \H@subsection}{\bgroup\def\tmp{}\H@subsection}}
+\newcommand{\H@subsection}[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hsubsection\tmp}
+
+\renewcommand{\subsubsection}{\resetparagraphs
+ \@ifstar{\stepcounter{lsubsubsection}\bgroup\def\tmp{*}%
+   \H@subsubsection}{\bgroup\def\tmp{}\H@subsubsection}}
+\newcommand{\H@subsubsection}[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hsubsubsection\tmp}
+
+\renewcommand{\paragraph}{\resetsubparagraphs
+ \@ifstar{\stepcounter{lparagraph}\bgroup\def\tmp{*}%
+   \H@paragraph}{\bgroup\def\tmp{}\H@paragraph}}
+\newcommand\H@paragraph[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hparagraph\tmp}
+
+\ifx\Hsubparagraph\relax\else\@ifundefined{subparagraph}{}{%
+\renewcommand{\subparagraph}{\resetsubsubparagraphs
+ \@ifstar{\stepcounter{lsubparagraph}\bgroup\def\tmp{*}%
+   \H@subparagraph}{\bgroup\def\tmp{}\H@subparagraph}}}\fi
+\newcommand\H@subparagraph[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hsubparagraph\tmp}
+
+\ifx\Hsubsubparagraph\relax\else\@ifundefined{subsubparagraph}{}{%
+\def\subsubparagraph{%
+ \@ifstar{\stepcounter{lsubsubparagraph}\bgroup\def\tmp{*}%
+   \H@subsubparagraph}{\bgroup\def\tmp{}\H@subsubparagraph}}}\fi
+\newcommand\H@subsubparagraph[1][]{\def\tmp@a{#1}\check@align
+ \expandafter\egroup\expandafter\Hsubsubparagraph\tmp}
+
+\def\check@align{\def\empty{}\ifx\tmp@a\empty
+ \else\def\tmp@b{center}\ifx\tmp@a\tmp@b\let\tmp@a\empty
+ \else\def\tmp@b{left}\ifx\tmp@a\tmp@b\let\tmp@a\empty
+ \else\def\tmp@b{right}\ifx\tmp@a\tmp@b\let\tmp@a\empty
+ \else\expandafter\def\expandafter\tmp@a\expandafter{\expandafter[\tmp@a]}%
+ \fi\fi\fi \def\empty{}\ifx\tmp\empty\let\tmp=\tmp@a \else 
+  \expandafter\def\expandafter\tmp\expandafter{\expandafter*\tmp@a}%
+ \fi\fi}
+%
+\def\resetsections{\setcounter{section}{0}\setcounter{lsection}{0}%
+ \reset@dependents{section}\resetsubsections }
+\def\resetsubsections{\setcounter{subsection}{0}\setcounter{lsubsection}{0}%
+ \reset@dependents{subsection}\resetsubsubsections }
+\def\resetsubsubsections{\setcounter{subsubsection}{0}\setcounter{lsubsubsection}{0}%
+ \reset@dependents{subsubsection}\resetparagraphs }
+%
+\def\resetparagraphs{\setcounter{lparagraph}{0}\setcounter{lparagraph}{0}%
+ \reset@dependents{paragraph}\resetsubparagraphs }
+\def\resetsubparagraphs{\ifx\c@subparagraph\undefined\else
+  \setcounter{subparagraph}{0}\fi \setcounter{lsubparagraph}{0}%
+ \reset@dependents{subparagraph}\resetsubsubparagraphs }
+\def\resetsubsubparagraphs{\ifx\c@subsubparagraph\undefined\else
+  \setcounter{subsubparagraph}{0}\fi \setcounter{lsubsubparagraph}{0}}
+%
+\def\reset@dependents#1{\begingroup\let \@elt \@stpelt
+ \csname cl@#1\endcsname\endgroup}
+%
+%
+%  Define a helper macro to dump a single \secounter command to a file.
+%
+\newcommand{\DumpPtr}[2]{%
+\count255=\arabic{#1}\def\dummy{dummy}\def\tmp{#2}%
+\ifx\tmp\dummy\def\ctr{#1}\else
+ \def\ctr{#2}\advance\count255 by \arabic{#2}\fi
+\immediate\write\ptrfile{%
+\noexpand\setcounter{\ctr}{\number\count255}}}
+%\expandafter\noexpand\expandafter\setcounter\expandafter{\ctr}{\number\count255}}}
+
+%
+%  Define a helper macro to dump all counters to the file.
+%  The value for each counter will be the sum of the l-counter
+%      actual LaTeX section counter.
+%  Also dump an \htmlhead{section-command}{section title} command
+%      to the file.
+%
+\newwrite\ptrfile
+\def\DumpCounters#1#2#3#4{%
+\begingroup\let\protect=\noexpand
+\immediate\openout\ptrfile = #1.ptr
+\DumpPtr{part}{lpart}%
+\ifx\Hchapter\relax\else\DumpPtr{chapter}{lchapter}\fi
+\DumpPtr{section}{lsection}%
+\DumpPtr{subsection}{lsubsection}%
+\DumpPtr{subsubsection}{lsubsubsection}%
+\DumpPtr{paragraph}{lparagraph}%
+\DumpPtr{subparagraph}{lsubparagraph}%
+\DumpPtr{equation}{dummy}%
+\DumpPtr{footnote}{dummy}%
+\def\tmp{#4}\ifx\tmp\@empty
+\immediate\write\ptrfile{\noexpand\htmlhead{#2}{#3}}\else
+\immediate\write\ptrfile{\noexpand\htmlhead[#4]{#2}{#3}}\fi
+\dumpcitestatus \dumpcurrentcolor
+\immediate\closeout\ptrfile
+\endgroup }
+
+
+%% interface to natbib.sty
+
+\def\dumpcitestatus{}
+\def\loadcitestatus{\def\dumpcitestatus{%
+  \ifciteindex\immediate\write\ptrfile{\noexpand\citeindextrue}%
+  \else\immediate\write\ptrfile{\noexpand\citeindexfalse}\fi }%
+}
+\@ifpackageloaded{natbib}{\loadcitestatus}{%
+ \AtBeginDocument{\@ifpackageloaded{natbib}{\loadcitestatus}{}}}
+
+
+%% interface to color.sty
+
+\def\dumpcurrentcolor{}
+\def\loadsegmentcolors{%
+ \let\real@pagecolor=\pagecolor
+ \let\pagecolor\segmentpagecolor
+ \let\segmentcolor\color
+ \ifx\current@page@color\undefined \def\current@page@color{{}}\fi
+ \def\dumpcurrentcolor{\bgroup\def\@empty@{{}}%
+   \expandafter\def\expandafter\tmp\space####1@{\def\thiscol{####1}}%
+  \ifx\current@color\@empty@\def\thiscol{}\else
+   \expandafter\tmp\current@color @\fi
+  \immediate\write\ptrfile{\noexpand\segmentcolor{\thiscol}}%
+  \ifx\current@page@color\@empty@\def\thiscol{}\else
+   \expandafter\tmp\current@page@color @\fi
+  \immediate\write\ptrfile{\noexpand\segmentpagecolor{\thiscol}}%
+ \egroup}%
+ \global\let\loadsegmentcolors=\relax
+}
+
+% These macros are needed within  images.tex  since this inputs
+% the <segment>.ptr files for a segment, so that counters are
+% colors are synchronised.
+%
+\newcommand{\segmentpagecolor}[1][]{%
+ \@ifpackageloaded{color}{\loadsegmentcolors\bgroup
+  \def\tmp{#1}\ifx\@empty\tmp\def\next{[]}\else\def\next{[#1]}\fi
+  \expandafter\segmentpagecolor@\next}%
+ {\@gobble}}
+\def\segmentpagecolor@[#1]#2{\def\tmp{#1}\def\tmpB{#2}%
+ \ifx\tmpB\@empty\let\next=\egroup
+ \else
+  \let\realendgroup=\endgroup
+  \def\endgroup{\edef\next{\noexpand\realendgroup
+   \def\noexpand\current@page@color{\current@color}}\next}%
+  \ifx\tmp\@empty\real@pagecolor{#2}\def\model{}%
+  \else\real@pagecolor[#1]{#2}\def\model{[#1]}%
+  \fi
+  \edef\next{\egroup\def\noexpand\current@page@color{\current@page@color}%
+  \noexpand\real@pagecolor\model{#2}}%
+ \fi\next}
+%
+\newcommand{\segmentcolor}[2][named]{\@ifpackageloaded{color}%
+ {\loadsegmentcolors\segmentcolor[#1]{#2}}{}}
+
+\@ifpackageloaded{color}{\loadsegmentcolors}{\let\real@pagecolor=\@gobble
+ \AtBeginDocument{\@ifpackageloaded{color}{\loadsegmentcolors}{}}}
+
+
+%  Define the \segment[align]{file}{section-command}{section-title} command,
+%  and its helper macros.  This command does four things:
+%       1)  Begins a new LaTeX section;
+%       2)  Writes a list of section counters to file.ptr, each
+%           of which represents the sum of the LaTeX section
+%           counters, and the l-counters, defined above;
+%       3)  Write an \htmlhead{section-title} command to file.ptr;
+%       4)  Inputs file.tex.
+
+\newcommand{\segment}{\@ifstar{\@@htmls}{\@@html}}
+%\tracingall
+\newcommand{\@endsegment}[1][]{}
+\let\endsegment\@endsegment
+\newcommand{\@@htmls}[1][]{\@@htmlsx{#1}}
+\newcommand{\@@html}[1][]{\@@htmlx{#1}}
+\def\@@htmlsx#1#2#3#4{\csname #3\endcsname* {#4}%
+                   \DumpCounters{#2}{#3*}{#4}{#1}\input{#2}}
+\def\@@htmlx#1#2#3#4{\csname #3\endcsname {#4}%
+                   \DumpCounters{#2}{#3}{#4}{#1}\input{#2}}
+
+\makeatother
+\endinput
+
+
+% Modifications:
+%
+% (The listing of Initiales see Changes)
+
+% $Log: html.sty,v $
+% Revision 1.1  2006/02/14 22:30:19  isani
+% Adding style and def files corresponding to LaTeX2HTML-99.1 which Camera group uses.
+% Modify panstarrs.cls to include package html (must be included before hyperref) and expanded hyperref options to produce bookmarks in the PDF.
+%
+% Revision 1.37  1999/03/12 07:02:38  RRM
+%  --  change macro name from \addTOCsection to \htmladdTOClink
+%  --  it has 3 + 1 optional argument, to allow a local path to a labels.pl
+%  	file for the external document, for cross-references
+%
+% Revision 1.36  1999/03/10 05:46:00  RRM
+%  --  extended the code for compatibilty with comment.sty
+%  --  allow excluded environments to work within tables,
+%  	with the excluded material spanning headers and several cells
+%  	thanks Avinash Chopde for recognising the need for this.
+%  --  added LaTeX support (ignores it) for  \htmladdTOCsection
+%  	thanks to Steffen Klupsch and Uli Wortmann for this idea.
+%
+% Revision 1.35  1999/03/08 11:16:16  RRM
+% 	html.sty  for LaTeX2HTML V99.1
+%
+%  --  ensure that html.sty can be loaded *after* hyperref.sty
+%  --  support new command  \htmlclear for <BR> in HTML, ignored by LaTeX
+%  --  ensure {part} and {chapter} counters are defined, even if not used
+%
+% Revision 1.34  1998/09/19 10:37:29  RRM
+%  --  fixed typo with \next{\hyperref}{....}
+%
+% Revision 1.33  1998/09/08 12:47:51  RRM
+%  --  changed macro-names for the \hyperref and \hypercite options
+% 	allows easier compatibility with other packages
+%
+% Revision 1.32  1998/08/24 12:15:14  RRM
+%  --  new command  \htmllanguagestyle  to associate a style class
+%  	with text declared as a particular language
+%
+% Revision 1.31  1998/07/07 14:15:41  RRM
+%  --  new commands  \htmlsetstyle  and  \htmladdtostyle
+%
+% Revision 1.30  1998/07/04 02:42:22  RRM
+%  --  cope with catcodes of % { } in rawhtml/comment/htmlonly environments
+%
+% Revision 1.29  1998/06/23 13:33:23  RRM
+%  --  use \begin{small} with the default for URLs
+%
+% Revision 1.28  1998/06/21 09:38:39  RRM
+%  --  implement \htmlurl  to agree with \url if already defined
+%     or loaded subsequently (LaTeX-2e only)
+%  --  get LaTeX to print the revision number when loading
+%
+% Revision 1.27  1998/06/20 15:13:10  RRM
+%  --  \TeX is already protected in recent versions of LaTeX
+% 	so \DeclareRobust doesn't work --- causes looping
+%  --  \part and \subparagraph need not be defined in some styles
+%
+% Revision 1.26  1998/06/01 08:36:49  latex2html
+%  --  implement optional argument for \endsegment
+%  --  made the counter value output from \DumpPtr more robust
+%
+% Revision 1.25  1998/05/09 05:43:35  latex2html
+%  --   conditionals for avoiding undefined counters
+%
+% Revision 1.23  1998/02/26 10:32:24  latex2html
+%  --  use \providecommand for  \latextohtml
+%  --  implemented \HTMLcode to do what \HTML did previously
+% 	\HTML still works, unless already defined by another package
+%  --  fixed problems remaining with undefined \chapter
+%  --  defined \endsegment
+%
+% Revision 1.22  1997/12/05 11:38:18  RRM
+%  --  implemented an optional argument to \begin for style-sheet info.
+%  --  modified use of an optional argument with sectioning-commands
+%
+% Revision 1.21  1997/11/05 10:28:56  RRM
+%  --  replaced redefinition of \@htmlrule with \htmlrulestar
+%
+% Revision 1.20  1997/10/28 02:15:58  RRM
+%  --  altered the way some special html-macros are defined, so that
+% 	star-variants are explicitly defined for LaTeX
+% 	 -- it is possible for these to occur within  images.tex
+% 	e.g. \htmlinfostar \htmlrulestar \tableofchildlinksstar
+%
+% Revision 1.19  1997/10/11 05:47:48  RRM
+%  --  allow the dummy {tex2html_nowrap} environment in LaTeX
+% 	use it to make its contents be evaluated in environment order
+%
+% Revision 1.18  1997/10/04 06:56:50  RRM
+%  --  uses Robin Fairbairns' code for ignored environments,
+%      replacing the previous  comment.sty  stuff.
+%  --  extensions to the \tableofchildlinks command
+%  --  extensions to the \htmlinfo command
+%
+% Revision 1.17  1997/07/08 11:23:39  RRM
+%     include value of footnote counter in .ptr files for segments
+%
+% Revision 1.16  1997/07/03 08:56:34  RRM
+%     use \textup  within the \latextohtml macro
+%
+% Revision 1.15  1997/06/15 10:24:58  RRM
+%      new command  \htmltracenv  as environment-ordered \htmltracing
+%
+% Revision 1.14  1997/06/06 10:30:37  RRM
+%  -   new command:  \htmlborder  puts environment into a <TABLE> cell
+%      with a border of specified width, + other attributes.
+%  -   new commands: \HTML  for setting arbitrary HTML tags, with attributes
+%                    \HTMLset  for setting Perl variables, while processing
+%                    \HTMLsetenv  same as \HTMLset , but it gets processed
+%                                 as if it were an environment.
+%  -   new command:  \latextohtml  --- to set the LaTeX2HTML name/logo
+%  -   fixed some remaining problems with \segmentcolor & \segmentpagecolor
+%
+% Revision 1.13  1997/05/19 13:55:46  RRM
+%      alterations and extra options to  \hypercite
+%
+% Revision 1.12  1997/05/09 12:28:39  RRM
+%  -  Added the optional argument to \htmlhead, also in \DumpCounters
+%  -  Implemented \HTMLset as a no-op in LaTeX.
+%  -  Fixed a bug in accessing the page@color settings.
+%
+% Revision 1.11  1997/03/26 09:32:40  RRM
+%  -  Implements LaTeX versions of  \externalcite  and  \hypercite  commands.
+%     Thanks to  Uffe Engberg  and  Stephen Simpson  for the suggestions.
+%
+% Revision 1.10  1997/03/06 07:37:58  RRM
+% Added the  \htmltracing  command, for altering  $VERBOSITY .
+%
+% Revision 1.9  1997/02/17 02:26:26  RRM
+% - changes to counter handling (RRM)
+% - shuffled around some definitions
+% - changed \htmlrule of 209 mode
+%
+% Revision 1.8  1997/01/26 09:04:12  RRM
+% RRM: added optional argument to sectioning commands
+%      \htmlbase  sets the <BASE HREF=...> tag
+%      \htmlinfo  and  \htmlinfo* allow the document info to be positioned
+%
+% Revision 1.7  1997/01/03 12:15:44  L2HADMIN
+% % - fixes to the  color  and  natbib  interfaces
+% % - extended usage of  \hyperref, via an optional argument.
+% % - extended use comment environments to allow shifting expansions
+% %     e.g. within \multicolumn  (`bug' reported by Luc De Coninck).
+% % - allow optional argument to: \htmlimage, \htmlhead,
+% %     \htmladdimg, \htmladdnormallink, \htmladdnormallinkfoot
+% % - added new commands: \htmlbody, \htmlnohead
+% % - added new command: \tableofchildlinks
+%
+% Revision 1.6  1996/12/25 03:04:54  JCL
+% added patches to segment feature from Martin Wilck
+%
+% Revision 1.5  1996/12/23 01:48:06  JCL
+%  o introduced the environment makeimage, which may be used to force
+%    LaTeX2HTML to generate an image from the contents.
+%    There's no magic, all what we have now is a defined empty environment
+%    which LaTeX2HTML will not recognize and thus pass it to images.tex.
+%  o provided \protect to the \htmlrule commands to allow for usage
+%    within captions.
+%
+% Revision 1.4  1996/12/21 19:59:22  JCL
+% - shuffled some entries
+% - added \latexhtml command
+%
+% Revision 1.3  1996/12/21 12:22:59  JCL
+% removed duplicate \htmlrule, changed \htmlrule back not to create a \hrule
+% to allow occurrence in caption
+%
+% Revision 1.2  1996/12/20 04:03:41  JCL
+% changed occurrence of \makeatletter, \makeatother
+% added new \htmlrule command both for the LaTeX2.09 and LaTeX2e
+% sections
+%
+%
+% jcl 30-SEP-96
+%  - Stuck the commands commonly used by both LaTeX versions to the top,
+%    added a check which stops input or reads further if the document
+%    makes use of LaTeX2e.
+%  - Introduced rrm's \dumpcurrentcolor and \bodytext
+% hws 31-JAN-96 - Added support for document segmentation
+% hws 10-OCT-95 - Added \htmlrule command
+% jz 22-APR-94 - Added support for htmlref
+% nd  - Created
Index: branches/eam_branches/20091113/doc/latex/panstarrs.cls
===================================================================
--- branches/eam_branches/20091113/doc/latex/panstarrs.cls	(revision 26235)
+++ branches/eam_branches/20091113/doc/latex/panstarrs.cls	(revision 26236)
@@ -11,11 +11,16 @@
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesClass{panstarrs}[2003/06/29 LaTeX class for PanSTARRS]
-\LoadClass[12pt]{article}
-\RequirePackage{tocloft,ifthen,fancyhdr,vmargin}
-\RequirePackage{hyperref,times,amsmath,amssymb}
+\LoadClass[11pt,letterpaper]{article}
+\RequirePackage{tocloft,ifthen,fancyhdr,vmargin,longtable}
+\RequirePackage{html}
+\RequirePackage[colorlinks,ps2pdf,bookmarks=true,bookmarksnumbered=true,plainpages=false]{hyperref} %avoid ``destination with the same identifier'' errors
+\RequirePackage{times,amsmath,amssymb,multirow}
 \RequirePackage{color,fullpage,boxedminipage,acronym,epsfig}
+\RequirePackage{psmisc}
+\RequirePackage{fancyvrb}
 
 % -- panstarrs definitions--
 \DeclareOption{panstarrs}{\input{panstarrs.def}}
+\DeclareOption{spec}{\input{spec.def}}
 
 % -- page layout options --
@@ -29,5 +34,5 @@
 \textheight=9.0in
 \textwidth=7.35in
-\headheight=12pt
+\headheight=15pt
 \headsep = 24pt
 \footskip=30pt
@@ -38,26 +43,57 @@
 \addtolength{\cftfignumwidth}{2em}
 
-% -- section numbering --
-\let\@section=\section \let\@subsection=\subsection
-\let\@subsubsection=\subsubsection
-\def\section{\renewcommand{\thefigure}{\thesection -\arabic{figure}} \setcounter{figure}{0} \@section}
-\def\subsection{\renewcommand{\thefigure}{\thesubsection -\arabic{figure}} \setcounter{figure}{0} \@subsection}
-\def\subsubsection{\renewcommand{\thefigure}{\thesubsubsection -\arabic{figure}} \setcounter{figure}{0} \@subsubsection}
-\def\paragraph{\@startsection{paragraph}{4}{\z@}%
-  {-3.5ex\@plus -1ex \@minus -.2ex}%
-  {1.5ex \@plus .2ex}%
-  {\normalsize\bf}}
-\def\subparagraph{\@startsection{subparagraph}{5}{\z@}%
-  {-3.5ex\@plus -1ex \@minus -.2ex}%
-  {1.5ex \@plus .2ex}%
-  {\normalsize\bf}}
-\def\subsubparagraph{\@startsection{subsubparagraph}{6}{\z@}%
-  {-3.5ex\@plus -1ex \@minus -.2ex}%
-  {1.5ex \@plus .2ex}%
-  {\normalsize\it}}
-\let\subsubsubsection=\paragraph
+%  % -- SRS section numbering / plain enumerate types --
+%  \let\@section=\section 
+%  \let\@subsection=\subsection
+%  \let\@subsubsection=\subsubsection
+%  
+%  \def\section{
+%  %  uncomment these to label figures by section number
+%  %  \renewcommand{\thefigure}{\thesection -\arabic{figure}} 
+%  %  \setcounter{figure}{0} 
+%    \@section
+%  }
+%  
+%  \def\subsection{
+%  %  uncomment these to label figures by section number
+%  %  \renewcommand{\thefigure}{\thesubsection -\arabic{figure}} 
+%  %  \setcounter{figure}{0} 
+%    \@subsection
+%  }
+%  
+%  \def\subsubsection{
+%  %  uncomment these to label figures by section number
+%  %  \renewcommand{\thefigure}{\thesubsubsection -\arabic{figure}} 
+%  %  \setcounter{figure}{0} 
+%    \@subsubsection
+%  }
+%  
+%  \def\paragraph{
+%    \@startsection{paragraph}{4}{\z@}%
+%      {-3.5ex\@plus -1ex \@minus -.2ex}%
+%      {1.5ex \@plus .2ex}%
+%      {\normalsize\bf}
+%  }
+%  
+%  \def\subparagraph{
+%    \@startsection{subparagraph}{5}{\z@}%
+%      {-3.5ex\@plus -1ex \@minus -.2ex}%
+%      {1.5ex \@plus .2ex}%
+%      {\normalsize\bf}
+%  }
+%  
+%  \def\subsubparagraph{
+%    \@startsection{subsubparagraph}{6}{\z@}%
+%      {-3.5ex\@plus -1ex \@minus -.2ex}%
+%      {1.5ex \@plus .2ex}%
+%      {\normalsize\it}
+%  } 
+%  
+%  \let\subsubsubsection=\paragraph
+%  \let\subsubsubsubsection=\subparagraph
+
 
 % -- section display --
-\setcounter{secnumdepth}{4} % lowest level at which counters are displayed
+\setcounter{secnumdepth}{5} % lowest level at which counters are displayed
 \setcounter{tocdepth}{3} % lowest level to be included in toc
 
@@ -71,4 +107,5 @@
 \newcommand\thesubtitle{} 
 \newcommand\thedistribution{Approved for Public Release -- Distribution is Unlimited}
+\newcommand\theaudience{panstarrs team} 
 
 \newcommand{\docnumber}[1]{\renewcommand\thedocnumber{#1} }
@@ -80,4 +117,28 @@
 \newcommand{\subtitle}[1]{ \renewcommand\thesubtitle{#1} }
 \newcommand{\distribution}[1]{ \renewcommand\thedistribution{#1} }
+\newcommand{\audience}[1]{ \renewcommand\theaudience{#1} }
+
+%%%%%%%%%%%%%%%%%%%% start of time code %%%%%%%%%%%%%%%%%%%% 
+%
+% Code for printing the time by Michael Doob <mdoob@cc.umanitoba.ca>
+%
+\newcount\hour \newcount\minute
+\hour=\time  \divide \hour by 60
+\minute=\time
+\loop \ifnum \minute > 59 \advance \minute by -60 \repeat
+\def\nowtwelve{\ifnum \hour<13 \number\hour:% 		% supresses leading 0's
+                      \ifnum \minute<10 0\fi%		% so add it it
+                      \number\minute
+                      \ifnum \hour<12 \ A.M.\else \ P.M.\fi
+	 \else \advance \hour by -12 \number\hour:% 	% supresses leading 0's
+                      \ifnum \minute<10 0\fi%		% add it in
+                      \number\minute \ P.M.\fi}
+\def\nowtwentyfour{\ifnum \hour<10 0\fi% 		% need a leading 0 
+		\number\hour:% 				% supresses leading 0's
+         	\ifnum \minute<10 0\fi% 		% add it in
+         	\number\minute}
+\def\now{\nowtwelve}
+%%%%%%%%%%%%%%%%%%%% end of time code %%%%%%%%%%%%%%%%%%%%
+
 
 % -- MAKETITLE --
@@ -101,64 +162,64 @@
 
 \def\@maketitle{
-  \pagenumbering{roman} 
-  \thispagestyle{empty} 
-  \unitlength 1.0in
-  \begin{picture}(0.0,0.0)(0.0,9.375)
-  \small
-
-  \put (7.50, 9.85){\makebox(0,0)[br]{\small      {\bf Pan-STARRS Document Control}}}
-  \put (7.50, 9.70){\makebox(0,0)[br]{\small      {\bf \thedocnumber-\theversion}}}
-
-  \put (4.006, 8.30){\line(1,0){0.1}} % put the macron on Manoa
-  \put (0.50, 8.10){\makebox(0,0)[bl]{\fontA UNIVERSITY OF HAWAII AT MANOA}}
-  \put (0.50, 7.88){\makebox(0,0)[bl]{\fontB Institute for Astrononmy}}
-
-  \put (0.50, 7.83){\line(1,0){6.5}}
-  \put (0.50, 7.63){\makebox(0,0)[bl]{\small      {\bf Pan-STARRS Project Management System}}}
-
-  \put (3.75, 5.25){\makebox(0,0)[bc]{\large {\bf \@title}}}
-  \put (3.75, 5.00){\makebox(0,0)[bc]{\large {\bf \thesubtitle}}}
-
-  \put (2.15, 4.75){\makebox(0,0)[l]{{\bf Grant Award No. }}}
-  \put (2.15, 4.57){\makebox(0,0)[l]{{\bf Prepared For    }}}
-  \put (2.15, 4.39){\makebox(0,0)[l]{{\bf Prepared By     }}}
-  \put (2.15, 4.21){\makebox(0,0)[l]{{\bf Document No.    }}}
-  \put (2.15, 4.03){\makebox(0,0)[l]{{\bf Document Date   }}}
-  \put (2.15, 3.85){\makebox(0,0)[l]{{\bf Revision        }}}
-
-  \put (3.75, 4.75){\makebox(0,0)[l]{{\bf : F29601-02-1-0268}}}
-  \put (3.75, 4.57){\makebox(0,0)[l]{{\bf : Pan-STARRS Team}}}
-  \put (3.75, 4.39){\makebox(0,0)[l]{{\bf : \@author}}}
-  \put (3.75, 4.21){\makebox(0,0)[l]{{\bf : \thedocnumber-\theversion}}}
-  \put (3.75, 4.03){\makebox(0,0)[l]{{\bf : \today}}}
-  \put (3.75, 3.85){\makebox(0,0)[l]{{\bf : \theversion}}}
-
-  \put (3.75, 2.50){\makebox(0,0)[c]{{\bf DISTRIBUTION STATEMENT}}}
-  \put (3.75, 2.30){\makebox(0,0)[c]{{\bf \thedistribution}}}
-
-  \put (3.75, 1.30){\makebox(0,0)[bc]{\scriptsize {\bf \copyright Institute for Astronomy, University of Hawaii}}}
-  \put (3.75, 1.15){\makebox(0,0)[bc]{\scriptsize {\bf 2680 Woodlawn Drive, Honolulu, Hawaii 96822}}}
-  \put (3.75, 1.00){\makebox(0,0)[bc]{\scriptsize {\bf An Equal Opportunity/Affirmative Action Institution}}}
-  \end{picture}
-
-  \pagebreak 
-  \unitlength 1.0in
-  \begin{picture}(0.0,0.0)(0.5,9.375)
-  \small
-
-  \put (1.00, 8.50){\makebox(0,0)[l]{Submitted By:}}
-  \put (1.00, 8.00){\line(1,0){5.5}}
-  \put (6.70, 8.00){\line(1,0){0.8}}
-  \put (1.00, 7.90){\makebox(0,0)[l]{[Insert Signature Block of Authorized Developer Representative]}}
-  \put (6.70, 7.90){\makebox(0,0)[l]{Date}}
-
-  \put (1.00, 7.00){\makebox(0,0)[l]{Approved By:}}
-  \put (1.00, 6.50){\line(1,0){5.5}}
-  \put (6.70, 6.50){\line(1,0){0.8}}
-  \put (1.00, 6.40){\makebox(0,0)[l]{[Insert Signature Block of Customer Developer Representative]}}
-  \put (6.70, 6.40){\makebox(0,0)[l]{Date}}
-
-  \end{picture}
-  \pagebreak 
+      \pagenumbering{roman} 
+      \thispagestyle{empty} 
+      \unitlength 1.0in
+      \begin{picture}(0.0,0.0)(0.0,9.375)
+      \small
+    
+      \put (7.50, 9.85){\makebox(0,0)[br]{\small      {\bf Pan-STARRS Document Control}}}
+      \put (7.50, 9.70){\makebox(0,0)[br]{\small      {\bf \thedocnumber-\theversion}}}
+    
+      \put (4.006, 8.30){\line(1,0){0.1}} % put the macron on Manoa
+      \put (0.50, 8.10){\makebox(0,0)[bl]{\fontA UNIVERSITY OF HAWAII AT MANOA}}
+      \put (0.50, 7.88){\makebox(0,0)[bl]{\fontB Institute for Astrononmy}}
+    
+      \put (0.50, 7.83){\line(1,0){6.5}}
+      \put (0.50, 7.63){\makebox(0,0)[bl]{\small      {\bf Pan-STARRS Project Management System}}}
+    
+      \put (3.75, 5.25){\makebox(0,0)[bc]{\large {\bf \@title}}}
+      \put (3.75, 5.00){\makebox(0,0)[bc]{\large {\bf \thesubtitle}}}
+    
+      \put (2.15, 4.75){\makebox(0,0)[l]{{\bf Coop. Agreement No. }}}
+      \put (2.15, 4.57){\makebox(0,0)[l]{{\bf Prepared For    }}}
+      \put (2.15, 4.39){\makebox(0,0)[l]{{\bf Prepared By     }}}
+      \put (2.15, 4.21){\makebox(0,0)[l]{{\bf Document No.    }}}
+      \put (2.15, 4.03){\makebox(0,0)[l]{{\bf Document Date   }}}
+      \put (2.15, 3.85){\makebox(0,0)[l]{{\bf Revision        }}}
+    
+      \put (3.75, 4.75){\makebox(0,0)[l]{{\bf : FA9451-06-2-0338}}}
+      \put (3.75, 4.57){\makebox(0,0)[l]{{\bf : \theaudience}}}
+      \put (3.75, 4.39){\makebox(0,0)[l]{{\bf : \@author}}}
+      \put (3.75, 4.21){\makebox(0,0)[l]{{\bf : \thedocnumber-\theversion}}}
+      \put (3.75, 4.03){\makebox(0,0)[l]{{\bf : \today}}}
+      \put (3.75, 3.85){\makebox(0,0)[l]{{\bf : \theversion}}}
+    
+      \put (3.75, 2.50){\makebox(0,0)[c]{{\bf DISTRIBUTION STATEMENT}}}
+      \put (3.75, 2.30){\makebox(0,0)[c]{{\bf \thedistribution}}}
+    
+      \put (3.75, 1.30){\makebox(0,0)[bc]{\footnotesize {\copyright Institute for Astronomy, University of Hawaii}}}
+      \put (3.75, 1.15){\makebox(0,0)[bc]{\footnotesize {2680 Woodlawn Drive, Honolulu, Hawaii 96822}}}
+      \put (3.75, 1.00){\makebox(0,0)[bc]{\footnotesize {An Equal Opportunity/Affirmative Action Institution}}}
+      \end{picture}
+    
+      \pagebreak 
+      \unitlength 1.0in
+      \begin{picture}(0.0,0.0)(0.5,9.375)
+      \small
+    
+      \put (1.00, 8.50){\makebox(0,0)[l]{Submitted By:}}
+      \put (1.00, 8.00){\line(1,0){5.5}}
+      \put (6.70, 8.00){\line(1,0){0.8}}
+      \put (1.00, 7.90){\makebox(0,0)[l]{[Insert Signature Block of Authorized Developer Representative]}}
+      \put (6.70, 7.90){\makebox(0,0)[l]{Date}}
+    
+      \put (1.00, 7.00){\makebox(0,0)[l]{Approved By:}}
+      \put (1.00, 6.50){\line(1,0){5.5}}
+      \put (6.70, 6.50){\line(1,0){0.8}}
+      \put (1.00, 6.40){\makebox(0,0)[l]{[Insert Signature Block of Customer Developer Representative]}}
+      \put (6.70, 6.40){\makebox(0,0)[l]{Date}}
+    
+      \end{picture}
+      \pagebreak 
 }               
 
@@ -174,5 +235,5 @@
 % Make verbatim use a \footnotesize font (to allow 110-character lines)
 \let\oldverbatim@font=\verbatim@font
-\def\verbatim@font{\oldverbatim@font\footnotesize}
+\def\verbatim@font{\oldverbatim@font\scriptsize}
 
 \def\RevisionsStart{
Index: branches/eam_branches/20091113/doc/latex/panstarrs.def
===================================================================
--- branches/eam_branches/20091113/doc/latex/panstarrs.def	(revision 26235)
+++ branches/eam_branches/20091113/doc/latex/panstarrs.def	(revision 26236)
@@ -6,6 +6,4 @@
 % LaTeX variables (cntl sequences) for entities significant to Pan-STARRS.
    \newcommand{\PS}{Pan-STARRS}
-   \newcommand{\pipelinename}{Image Processing Pipeline}
-   \newcommand{\thisdocument}{\PS/ \pipelinename\ Software Design Description}
    \newcommand\Object{\ensuremath{f}}                % an object
    \newcommand\ObjectSet{\ensuremath{\mathbf{f}}}    % a set of objects
@@ -27,4 +25,8 @@
    \newcommand\AngularPitch{\ensuremath{p_{\text{\scriptsize pixel}}}}   % angular pitch of a pixel (e.g. 0.3 arcsec)
 
+   \def\degree{\hbox{$^\circ$}}
+   \def\arcmin{\hbox{$^\prime$}}
+   \def\arcsec{\hbox{$^{\prime\prime}$}}
+
 %
 % Typsetting documentation
@@ -37,4 +39,5 @@
 % \begin{verbatim}...\end{verbatim} for longer blocks
 %
+
 \def\uncatcodespecials{\def\do##1{\catcode`##1=12}\dospecials}%
 {\catcode`\`=\active\gdef`{\relax\lq}}% this line inhibits Spanish 
@@ -44,5 +47,5 @@
      \spaceskip=0pt \xspaceskip=0pt % just in case...
      \catcode`\`=\active
-     \obeylines \uncatcodespecials \obeyspaces
+     \uncatcodespecials \obeyspaces
      \catcode`\{=1\catcode`\}=2
     }%
@@ -51,5 +54,5 @@
      \spaceskip=0pt \xspaceskip=0pt % just in case...
      \catcode`\`=\active
-     \obeylines \uncatcodespecials \obeyspaces
+     \uncatcodespecials \obeyspaces
     }%
 
@@ -60,9 +63,21 @@
 \def\CODE{\begingroup\SETUPC@DE\D@CODE}%
 
-\newcommand\note[1]{{\bf #1}}
-\newcommand\tbd[1]{\textbf{[{\color{red}#1}]}}
+\newcommand\note[1]{\textbf{\color{red}#1}}
+%\newcommand\tbd[1]{\textbf{\color{red}#1 (TBD)}}
+%\newcommand\tbr[1]{\textbf{\color{blue}#1 (TBR)}}
 \newcommand\TBD[1]{\par\tbd{#1}\par}
+\renewcommand\comment[1]{\footnote{{\color{red}#1}}}
 
 \newcommand{\file}[1]{\textit{#1}}%
+
+%
+% embedded software function prototypes and datatypes
+%
+
+\DefineVerbatimEnvironment%
+  {prototype}{Verbatim}{fontsize=\footnotesize}
+
+\DefineVerbatimEnvironment%
+  {datatype}{Verbatim}{fontsize=\footnotesize}
 
 %------------------------------------------------------------------------------
Index: branches/eam_branches/20091113/doc/latex/panstarrsl2h.def
===================================================================
--- branches/eam_branches/20091113/doc/latex/panstarrsl2h.def	(revision 26236)
+++ branches/eam_branches/20091113/doc/latex/panstarrsl2h.def	(revision 26236)
@@ -0,0 +1,79 @@
+
+\def\RevisionsStart{
+{ \Large \bf Revision History}
+\begin{center}
+\begin{tabular}{|p{1.25in}|p{1in}|p{4in}|}
+\hline
+{\bf Revision Number} & {\bf Release Date} & {\bf Description} \\
+\hline
+}
+\def\RevisionsEnd{
+\hline
+\end{tabular}
+\end{center}
+\pagebreak
+}
+
+\def\TBDsStart{
+{ \Large \bf TBD / TBR Listing}
+\begin{center}
+\begin{tabular}{|p{1in}|p{0.8in}|p{0.8in}|p{3.45in}|}
+\hline
+{\bf Section No.} & {\bf Page No.} & {\bf TBD/R No.} & {\bf Description} \\
+\hline
+}
+\def\TBDsEnd{
+\hline
+\end{tabular}
+\end{center}
+\pagebreak
+}
+
+\def\DocumentsInternalSection{
+\section{Referenced Documents}
+\subsection{Internal Documents}
+\begin{center}
+\begin{tabular}{|p{1.25in}|p{5in}|}
+\hline
+{\bf Reference} & {\bf Title} \\
+\hline}
+
+\def\DocumentsExternalSection{
+\hline
+\end{tabular}
+\end{center}
+\par
+\subsection{External Documents}
+\begin{center}
+\begin{tabular}{|p{1.25in}|p{5in}|}
+\hline
+{\bf Reference} & {\bf Title} \\
+\hline}
+
+\def\DocumentsInternal{
+{\large \bf Referenced Documents}\par
+\begin{center}
+\begin{tabular}{|p{1.25in}|p{5in}|}
+\multicolumn{1}{l}{\bf Internal Documents} \\
+\hline
+{\bf Reference} & {\bf Title} \\
+\hline}
+
+\def\DocumentsExternal{
+\hline
+\end{tabular}
+\end{center}
+\par
+\begin{center}
+\begin{tabular}{|p{1.25in}|p{5in}|}
+\multicolumn{1}{l}{\bf External Documents} \\
+\hline
+{\bf Reference} & {\bf Title} \\
+\hline}
+
+\def\DocumentsEnd{
+\hline
+\end{tabular}
+\end{center}
+\pagebreak }
+
Index: branches/eam_branches/20091113/doc/latex/psmisc.sty
===================================================================
--- branches/eam_branches/20091113/doc/latex/psmisc.sty	(revision 26236)
+++ branches/eam_branches/20091113/doc/latex/psmisc.sty	(revision 26236)
@@ -0,0 +1,287 @@
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%       ****************************************
+%       *              ENDNOTES                *
+%       ****************************************
+%
+%       ****************************************
+%       *           ENDNOTE MACROS             *
+%       ****************************************
+%
+
+\@definecounter{endnote}
+\def\theendnote{\arabic{endnote}}
+
+% Default definition
+\def\@makeenmark{\hbox{$^{\@theenmark}$}}
+
+\newdimen\endnotesep
+
+\def\endnote{\@ifnextchar[{\@xendnote}{\stepcounter
+   {endnote}\xdef\@theenmark{\theendnote}\@endnotemark\@endnotetext}}
+
+\def\@xendnote[#1]{\begingroup \c@endnote=#1\relax
+   \xdef\@theenmark{\theendnote}\endgroup
+   \@endnotemark\@endnotetext}
+
+%  Here begins endnote code that's really different from the footnote
+% code of LaTeX.
+
+\let\@doanenote=0
+\let\@endanenote=0
+
+\newwrite\@enotes
+\newif\if@enotesopen \global\@enotesopenfalse
+
+\def\@openenotes{\immediate\openout\@enotes=\jobname.ent\relax
+      \global\@enotesopentrue}
+
+%  The stuff with \next and \meaning is a trick from the TeXbook, 382,
+% there intended for setting verbatim text, but here used to avoid
+% macro expansion when the footnote text is written.  \next will have
+% the entire text of the footnote as one long line, which might well
+% overflow limits on output line length; the business with \newlinechar
+% makes every space become a newline in the \@enotes file, so that all
+% of the lines wind up being quite short.
+
+\long\def\@endnotetext#1{%
+     \if@enotesopen \else \@openenotes \fi
+     \immediate\write\@enotes{\@doanenote{\@theenmark}}%
+     \begingroup
+        \def\next{#1}%
+        \newlinechar='40
+        \immediate\write\@enotes{\meaning\next}%
+     \endgroup
+     \immediate\write\@enotes{\@endanenote}}
+
+% \addtoendnotes works the way the other endnote macros probably should
+% have, requiring the use of \protect for fragile commands.
+
+\long\def\addtoendnotes#1{%
+     \if@enotesopen \else \@openenotes \fi
+     \begingroup
+        \newlinechar='40
+        \let\protect\string
+        \immediate\write\@enotes{#1}%
+     \endgroup}
+
+%  End of unique endnote code
+
+\def\endnotemark{\@ifnextchar[{\@xendnotemark
+    }{\stepcounter{endnote}\xdef\@theenmark{\theendnote}\@endnotemark}}
+
+\def\@xendnotemark[#1]{\begingroup \c@endnote #1\relax
+   \xdef\@theenmark{\theendnote}\endgroup \@endnotemark}
+
+\def\@endnotemark{\leavevmode\ifhmode
+  \edef\@x@sf{\the\spacefactor}\fi \@makeenmark
+   \ifhmode\spacefactor\@x@sf\fi\relax}
+
+\def\endnotetext{\@ifnextchar
+    [{\@xendnotenext}{\xdef\@theenmark{\theendnote}\@endnotetext}}
+
+\def\@xendnotenext[#1]{\begingroup \c@endnote=#1\relax
+   \xdef\@theenmark{\theendnote}\endgroup \@endnotetext}
+
+
+%  \theendnotes actually prints out the endnotes.
+
+%  The user may want separate endnotes for each chapter, or a big
+% block of them at the end of the whole document.  As it stands,
+% either will work; you just say \theendnotes wherever you want the
+% endnotes so far to be inserted.  However, you must add
+% \setcounter{endnote}{0} after that if you want subsequent endnotes
+% to start numbering at 1 again.
+
+%  \enoteformat is provided so user can specify some special formatting
+% for the endnotes.  It needs to set up the paragraph parameters, start
+% the paragraph, and print the label.  The \leavemode stuff is to make
+% and undo a dummy paragraph, to get around the games \section*
+% plays with paragraph indenting.
+
+\def\notesname{Notes}% <------ JK
+\def\enoteheading{\section*{\notesname
+  \@mkboth{\uppercase{\notesname}}{\uppercase{\notesname}}}%
+     \leavevmode\par\vskip-\baselineskip}
+
+\def\enoteformat{\rightskip\z@ \leftskip\z@ \parindent=1.8em
+     \leavevmode\llap{\hbox{$^{\@theenmark}$}}}
+
+\def\enotesize{\footnotesize}
+
+% The definition of \ETC. is needed only for versions of TeX prior
+% to 2.992.  Those versions limited \meaning expansions to 1000
+% characters; in 2.992 and beyond there is no limit.  At Brandeis the
+% BIGLATEX program changed the code in the token_show procedure of
+% TeX to eliminate this problem, but most ``big'' versions of TeX
+% will not solve this problem.
+
+\def\theendnotes{
+% only try to open the endnotes file (\jobname.ent) if endnotes have been made
+  \if@enotesopen 
+   \immediate\closeout\@enotes 
+   \global\@enotesopenfalse
+   \begingroup
+   \makeatletter
+% the following is to save catcode of ``>'' and restore it in \@endanenote
+   \edef\@tempa{`\string >}%
+   \ifnum\catcode\@tempa=11\let\@ResetGT\relax% accepts also that > were active
+     \else\edef\@ResetGT{\noexpand\catcode\@tempa=\the\catcode\@tempa}%
+     \fi%
+   \catcode`>=12% char > will be read as char so force it to \catcode 12 --bg\edef\GOfrench{`\string @}% temp def futher correctly defined
+   \def\@doanenote##1##2>{\def\@theenmark{##1}\par\begingroup
+     \@ResetGT%\catcode`>=13
+     \edef\@currentlabel{\csname p@endnote\endcsname\@theenmark} %DW
+     \enoteformat}
+   \def\@endanenote{\par\endgroup}%
+   \def\ETC.{\errmessage{Some long endnotes will be truncated; %
+                            use BIGLATEX to avoid this}%
+   \def\ETC.{\relax}}
+   \enoteheading
+   \enotesize
+   \input{\jobname.ent}%
+   \endgroup
+  \else \fi
+}
+
+\def\endnotesection{
+\begingroup
+\parindent 0pt
+\parskip 2ex
+\def\enotesize{\normalsize}
+\theendnotes
+\endgroup
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%% TBD Generation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newread\@infile
+\newwrite\@tbdfile
+
+\newif\if@tbdfileopen \global\@tbdfileopenfalse
+
+\@definecounter{tbdcount}
+
+\def\thetbd{\arabic{tbdcount}}
+\def\thetbdsec{\thesection}
+\let\ttnl\relax
+
+\def\tbd#1{
+ \textbf{\color{red}#1 (TBD)}
+ \stepcounter{tbdcount}
+ \if@tbdfileopen \else \@opentbdfile \fi
+ \immediate\write\@tbdfile{\thetbdsec\ & \thepage\ & \thetbd\ & #1 \ttnl }%
+}
+
+\def\@opentbdfile{
+ \immediate
+ \openout
+ \@tbdfile=\jobname.tbd 
+ \global\@tbdfileopentrue
+}
+
+% command to add TBDs at end of file processing:
+\def\dumptbd{
+  % only try to open the file (\jobname.tbd) if tbds have been made
+  \if@tbdfileopen 
+    \immediate\closeout\@tbdfile 
+    \global\@tbdfileopenfalse
+    \def\ttnl{\tabularnewline \hline}
+    { \Large \bf TBD Listing}
+    \begin{center}
+    \begin{longtable}{|p{1in}|p{0.8in}|p{0.8in}|p{3.45in}|}
+    \hline
+    {\bf Section No.} & {\bf Page No.} & {\bf TBD No.} & {\bf Description} \\
+    \hline
+    \input{\jobname.tbd}
+    \end{longtable}
+    \end{center}
+  \else \fi
+}
+
+\def\inserttbd{
+  \openin\@infile=\jobname.tbd
+  \ifeof\@infile
+  \else
+    \immediate\closeout\@infile
+    \def\ttnl{\tabularnewline \hline}
+    { \Large \bf TBD Listing}
+    \begin{center}
+    \begin{longtable}{|p{1in}|p{0.8in}|p{0.8in}|p{3.45in}|}
+    \hline
+    {\bf Section No.} & {\bf Page No.} & {\bf TBD No.} & {\bf Description} \\
+    \hline
+    \input{\jobname.tbd}
+    \end{longtable}
+    \end{center}
+    \let\ttnl\relax
+  \fi
+}
+
+%%% TBR Generation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newread\@infile
+\newwrite\@tbrfile
+
+\newif\if@tbrfileopen \global\@tbrfileopenfalse
+
+\@definecounter{tbrcount}
+
+\def\thetbr{\arabic{tbrcount}}
+\let\ttnl\relax
+
+\def\tbr#1{\stepcounter{tbrcount}
+ \if@tbrfileopen \else \@opentbrfile \fi
+ \immediate\write\@tbrfile{\thetbdsec\ & \thepage\ & \thetbr\ & #1 \ttnl}%
+ \textbf{\color{blue}#1 (TBR)}}
+
+\def\@opentbrfile{
+ \immediate
+ \openout
+ \@tbrfile=\jobname.tbr 
+ \global\@tbrfileopentrue
+}
+
+% command to add TBRs at end of file processing:
+\def\dumptbr{
+  % only try to open the file (\jobname.tbr) if tbrs have been made
+  \if@tbrfileopen 
+    \immediate\closeout\@tbrfile 
+    \global\@tbrfileopenfalse
+    \def\ttnl{\tabularnewline \hline}
+    { \Large \bf TBR Listing}
+    \begin{center}
+    \begin{longtable}{|p{1in}|p{0.8in}|p{0.8in}|p{3.45in}|}
+    \hline
+    {\bf Section No.} & {\bf Page No.} & {\bf TBR No.} & {\bf Description} \\
+    \hline
+    \input{\jobname.tbr}
+    \end{longtable}
+    \end{center}
+  \else \fi
+}
+
+\def\inserttbr{
+  \openin\@infile=\jobname.tbr
+  \ifeof\@infile
+  \else
+    \immediate\closeout\@infile
+    \def\ttnl{\tabularnewline \hline}
+    { \Large \bf TBR Listing}
+    \begin{center}
+    \begin{longtable}{|p{1in}|p{0.8in}|p{0.8in}|p{3.45in}|}
+    \hline
+    {\bf Section No.} & {\bf Page No.} & {\bf TBR No.} & {\bf Description} \\
+    \hline
+    \input{\jobname.tbr}
+    \end{longtable}
+    \end{center}
+    \let\ttnl\relax
+  \fi
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Index: branches/eam_branches/20091113/doc/latex/psreport.def
===================================================================
--- branches/eam_branches/20091113/doc/latex/psreport.def	(revision 26235)
+++ branches/eam_branches/20091113/doc/latex/psreport.def	(revision 26236)
@@ -36,8 +36,13 @@
   \put (3.75, 5.00){\makebox(0,0)[bc]{\Large {\bf \@title}}}
 
-  \put (3.75, 4.70){\makebox(0,0)[bc]{\small      {\bf \@author}}}
-  \put (3.75, 4.53){\makebox(0,0)[bc]{\small      {\bf \thegroup}}}
-  \put (3.75, 4.36){\makebox(0,0)[bc]{\small      {\bf \theorganization}}}
-  \put (3.75, 4.19){\makebox(0,0)[bc]{\small      {\bf \today}}}
+%  \put (3.75, 4.70){\makebox(0,0)[bc]{\small      {\bf \@author}}}
+%  \put (3.75, 4.53){\makebox(0,0)[bc]{\small      {\bf \thegroup}}}
+%  \put (3.75, 4.36){\makebox(0,0)[bc]{\small      {\bf \theorganization}}}
+%  \put (3.75, 4.19){\makebox(0,0)[bc]{\small      {\bf \today}}}
+  \put (3.75, 4.70){\makebox(0,0)[bc]{\normalsize      {\bf \@author}}}
+  \put (3.75, 4.53){\makebox(0,0)[bc]{\normalsize      {\bf \thegroup}}}
+  \put (3.75, 4.36){\makebox(0,0)[bc]{\normalsize      {\bf \theorganization}}}
+  \put (3.75, 4.19){\makebox(0,0)[bc]{\normalsize      {\bf \today}}}
+
 
   \put (3.75, 1.26){\makebox(0,0)[bc]{\scriptsize {\bf \copyright Institute for Astronomy}}}
Index: branches/eam_branches/20091113/doc/latex/spec.def
===================================================================
--- branches/eam_branches/20091113/doc/latex/spec.def	(revision 26236)
+++ branches/eam_branches/20091113/doc/latex/spec.def	(revision 26236)
@@ -0,0 +1,103 @@
+
+% -- SRS section numbering / enumerate types --
+\let\@section=\section \let\@subsection=\subsection
+\let\@subsubsection=\subsubsection
+
+\def\section{
+  \setlength{\leftmargini}{2.5em} 
+  \renewcommand{\theenumi}{\thesection.\arabic{enumi}}
+  \renewcommand{\labelenumi}{\theenumi}
+
+  \setlength{\leftmarginii}{1.7em} 
+  \renewcommand{\theenumii}{.\arabic{enumii}}
+  \renewcommand{\labelenumii}{\thesection.\arabic{enumi}\theenumii}
+  \renewcommand{\thetbdsec}{\thesection}
+
+%  uncomment these to label figures by section number
+%  \renewcommand{\thefigure}{\thesection -\arabic{figure}} 
+%  \setcounter{figure}{0} 
+  \@section
+}
+
+\def\subsection{
+  \setlength{\leftmargini}{3.5em} 
+  \renewcommand{\theenumi}{\thesubsection.\arabic{enumi}}
+  \renewcommand{\labelenumi}{\theenumi}
+
+  \setlength{\leftmarginii}{1.7em} 
+  \renewcommand{\theenumii}{.\arabic{enumii}}
+  \renewcommand{\labelenumii}{\thesubsection.\arabic{enumi}\theenumii}
+  \renewcommand{\thetbdsec}{\thesubsection}
+
+%  uncomment these to label figures by section number
+%  \renewcommand{\thefigure}{\thesubsection -\arabic{figure}} 
+%  \setcounter{figure}{0} 
+  \@subsection
+}
+
+\def\subsubsection{
+  \setlength{\leftmargini}{4.5em} 
+  \renewcommand{\theenumi}{\thesubsubsection.\arabic{enumi}}
+  \renewcommand{\labelenumi}{\theenumi}
+
+  \setlength{\leftmarginii}{1.7em} 
+  \renewcommand{\theenumii}{.\arabic{enumii}}
+  \renewcommand{\labelenumii}{\thesubsubsection.\arabic{enumi}\theenumii}
+  \renewcommand{\thetbdsec}{\thesubsubsection}
+
+%  uncomment these to label figures by section number
+%  \renewcommand{\thefigure}{\thesubsubsection -\arabic{figure}} 
+%  \setcounter{figure}{0} 
+  \@subsubsection
+}
+
+\def\paragraph{
+  \setlength{\leftmargini}{5.5em} 
+  \renewcommand{\theenumi}{\theparagraph.\arabic{enumi}}
+  \renewcommand{\labelenumi}{\theenumi}
+
+  \setlength{\leftmarginii}{1.7em} 
+  \renewcommand{\theenumii}{.\arabic{enumii}}
+  \renewcommand{\labelenumii}{\theparagraph.\arabic{enumi}\theenumii}
+  \renewcommand{\thetbdsec}{\theparagraph}
+
+  \@startsection{paragraph}{4}{\z@}%
+    {-3.5ex\@plus -1ex \@minus -.2ex}%
+    {1.5ex \@plus .2ex}%
+    {\normalsize\bf}
+}
+
+\def\subparagraph{
+  \setlength{\leftmargini}{6.5em} 
+  \renewcommand{\theenumi}{\thesubparagraph.\arabic{enumi}}
+  \renewcommand{\labelenumi}{\theenumi}
+
+  \setlength{\leftmarginii}{1.7em} 
+  \renewcommand{\theenumii}{\thesubparagraph.\arabic{enumii}}
+  \renewcommand{\labelenumii}{\theenumii}
+  \renewcommand{\thetbdsec}{\thesubparagraph}
+
+  \@startsection{subparagraph}{5}{\z@}%
+    {-3.5ex\@plus -1ex \@minus -.2ex}%
+    {1.5ex \@plus .2ex}%
+    {\normalsize\bf}
+}
+
+\def\subsubparagraph{
+%  \setlength{\leftmargini}{2.5em} 
+%  \renewcommand{\theenumi}{\thesubsubparagraph.\arabic{enumi}}
+%  \renewcommand{\labelenumi}{\theenumi}
+
+%  \setlength{\leftmarginii}{2.5em} 
+%  \renewcommand{\theenumii}{\thesubsubparagraph.\arabic{enumi}.\arabic{enumii}}
+%  \renewcommand{\labelenumii}{\theenumii}
+
+  \@startsection{subsubparagraph}{6}{\z@}%
+    {-3.5ex\@plus -1ex \@minus -.2ex}%
+    {1.5ex \@plus .2ex}%
+    {\normalsize\it}
+} 
+
+\let\subsubsubsection=\paragraph
+\let\subsubsubsubsection=\subparagraph
+
Index: branches/eam_branches/20091113/doc/manual/Makefile
===================================================================
--- branches/eam_branches/20091113/doc/manual/Makefile	(revision 26236)
+++ branches/eam_branches/20091113/doc/manual/Makefile	(revision 26236)
@@ -0,0 +1,28 @@
+PDFLATEX = env TEXINPUTS=.:LaTeX:$(TEXINPUTS): pdflatex
+PSLATEX	 = env TEXINPUTS=.:LaTeX:$(TEXINPUTS): latex
+
+help:
+	@echo "USAGE: make (target)"
+	@echo "	 targets: manual all"
+
+manual: manual.pdf 
+all : manual
+
+%.pdf: %.tex
+	$(PSLATEX) $*.tex 
+	$(PSLATEX) $*.tex 
+	dvips -z -t letter -o $*.ps $*.dvi
+	ps2pdf $*.ps $*.pdf
+	thumbpdf --modes=dvips $*.pdf
+	$(PSLATEX) $*.tex 
+	dvips -z -t letter -o $*.ps $*.dvi
+	ps2pdf $*.ps $*.pdf
+	@rm -f $*.ps $*.dvi $*.aux $*.log $*.tbr $*.tbd $*.toc $*.tpm $*.lof body.tmp head.tmp
+
+clean :
+	$(RM) *.log *.dvi *.aux *.toc *.tbd *.tbr *.tpm *.lof *.out *~ core body.tmp head.tmp
+
+dist : clean
+	$(RM) *.pdf
+
+empty: clean
Index: branches/eam_branches/20091113/ippMonitor/def/chipProcessedImfile.d
===================================================================
--- branches/eam_branches/20091113/ippMonitor/def/chipProcessedImfile.d	(revision 26235)
+++ branches/eam_branches/20091113/ippMonitor/def/chipProcessedImfile.d	(revision 26236)
@@ -39,4 +39,5 @@
 FIELD rawExp.exp_time,       	   	  5, %.2f,   exp_time    
 FIELD rawExp.airmass,        	   	  5, %.4f,   airmass     
+FIELD chipProcessedImfile.quality,   	  5, %d,     quality     
 FIELD chipProcessedImfile.bg,             5, %.2f,   backgnd
 FIELD chipProcessedImfile.bg_stdev,       5, %.2f,   stdev    
Index: branches/eam_branches/20091113/ippScripts/scripts/dist_bundle.pl
===================================================================
--- branches/eam_branches/20091113/ippScripts/scripts/dist_bundle.pl	(revision 26235)
+++ branches/eam_branches/20091113/ippScripts/scripts/dist_bundle.pl	(revision 26236)
@@ -60,9 +60,9 @@
 # Parse the command-line arguments
 my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $clean);
-my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file);
+my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);
 my ($dbname, $save_temps, $verbose, $no_update, $logfile);
 
 GetOptions(
-           'results_file=s' => \$results_file,     # camera for evaluating file rules
+           'results_file=s' => \$results_file,     # ouptput file name for results
            'camera=s'       => \$camera,     # camera for evaluating file rules
            'stage=s'        => \$stage,      # raw, chip, warp, or diff
@@ -77,4 +77,5 @@
            'magicked'       => \$magicked,   # magicked state for this component
            'outdir=s'       => \$outdir,     # "directory" for outputs
+           'prefix=s'       => \$prefix,     # "prefix" to apply to filenames
            'clean'          => \$clean,      # create clean distribution
            'save-temps'     => \$save_temps, # Save temporary files?
@@ -276,5 +277,5 @@
     my $tbase = basename($path_base);
     $tbase .= ".$component" if $component;
-    $file_name = "$tbase.tgz";
+    $file_name = ($prefix ? $prefix : "") . "$tbase.tgz";
     my $tarfile = "$outdir/$file_name";
 
Index: branches/eam_branches/20091113/ippScripts/scripts/dist_make_fileset.pl
===================================================================
--- branches/eam_branches/20091113/ippScripts/scripts/dist_make_fileset.pl	(revision 26235)
+++ branches/eam_branches/20091113/ippScripts/scripts/dist_make_fileset.pl	(revision 26236)
@@ -40,5 +40,5 @@
 # Parse the command-line arguments
 my ($dist_id, $dist_dir, $target_id, $stage, $stage_id, $dest_id, $product_name, $ds_dbhost, $ds_dbname);
-my ($label, $dist_group, $filter);
+my ($label, $data_group, $filter);
 my ($dbname, $save_temps, $verbose, $no_update, $logfile);
 
@@ -52,5 +52,5 @@
            'product_name=s' => \$product_name,  # location of the data store directory for this product
            'label=s'        => \$label,
-           'dist_group=s'   => \$dist_group,
+           'data_group=s'   => \$data_group,
            'filter=s'       => \$filter,
            'ds_dbhost=s'    => \$ds_dbhost,  # database host for the datastore database
@@ -64,5 +64,5 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --dist_id --dist_dir --target_id --stage --stage_id --dist_group --filter --dest_id --ds_dbhost --ds_dbname",
+pod2usage( -msg => "Required options: --dist_id --dist_dir --target_id --stage --stage_id --data_group --filter --dest_id --ds_dbhost --ds_dbname",
            -exitval => 3) unless
     defined $dist_id and
@@ -71,5 +71,5 @@
     defined $stage and
     defined $stage_id and
-    defined $dist_group and
+    defined $data_group and
     defined $filter and
     defined $dest_id and
@@ -164,5 +164,5 @@
 
     $command .= " --ps0 $target_id --ps1 $stage --ps2 $stage_id --ps3 $prod_col_3";
-    $command .= " --ps4 $dist_group --ps5 $filter";
+    $command .= " --ps4 $data_group --ps5 $filter";
 
     $command .= " --dbname $ds_dbname --dbhost $ds_dbhost";
Index: branches/eam_branches/20091113/ippScripts/scripts/magic_tree.pl
===================================================================
--- branches/eam_branches/20091113/ippScripts/scripts/magic_tree.pl	(revision 26235)
+++ branches/eam_branches/20091113/ippScripts/scripts/magic_tree.pl	(revision 26236)
@@ -158,6 +158,6 @@
 
     # Relative coordinates of centre of the field
-    my $x = $naxis1 - $crpix1;
-    my $y = $naxis2 - $crpix2;
+    my $x = $naxis1/2 - $crpix1;
+    my $y = $naxis2/2 - $crpix2;
 
     # Coordinates on tangent plane
@@ -168,6 +168,14 @@
 
     # Coordinates on rotated celestial sphere
-    my $phi = atan2($eta,$xi) + pi/2;
-    my $theta = atan(180 / pi / sqrt($xi**2 + $eta**2));
+    my ($phi, $theta);
+    if ($xi == 0 and $eta == 0) {
+        $phi = 0;
+        $eta = 0;
+    } else {
+        $phi = atan2($eta,$xi) + pi/2;
+        my $denominator = sqrt($xi**2 + $eta**2);
+        &my_die("denominator is zero!!", $magic_id, $PS_EXIT_PROG_ERROR) if $denominator == 0;
+        $theta = atan(180 / pi / $denominator);
+    }
 
     # Coordinates on celestial sphere
Index: branches/eam_branches/20091113/ippTasks/ipphosts.mhpcc.config
===================================================================
--- branches/eam_branches/20091113/ippTasks/ipphosts.mhpcc.config	(revision 26235)
+++ branches/eam_branches/20091113/ippTasks/ipphosts.mhpcc.config	(revision 26236)
@@ -15,5 +15,6 @@
   sky08 STR  ipp047
   sky09 STR  ipp015
-  sky10 STR  ipp016
+#  sky10 STR  ipp016
+  sky10 STR  ipp042
   sky11 STR  ipp017
   sky12 STR  ipp018 
Index: branches/eam_branches/20091113/ippTasks/rcserver.pro
===================================================================
--- branches/eam_branches/20091113/ippTasks/rcserver.pro	(revision 26235)
+++ branches/eam_branches/20091113/ippTasks/rcserver.pro	(revision 26236)
@@ -80,4 +80,5 @@
     end
     add_poll_args run
+    add_poll_labels run
     command $run
   end
@@ -129,8 +130,7 @@
     book getword rcPendingFS $pageName stage -var STAGE
     book getword rcPendingFS $pageName stage_id -var STAGE_ID
-    book getword rcPendingFS $pageName dist_group -var DIST_GROUP
+    book getword rcPendingFS $pageName data_group -var DATA_GROUP
     book getword rcPendingFS $pageName filter -var FILTER
     book getword rcPendingFS $pageName dist_dir -var DIST_DIR
-#    book getword rcPendingFS $pageName clean -var CLEAN
     book getword rcPendingFS $pageName dest_id -var DEST_ID
     book getword rcPendingFS $pageName product_name -var PRODUCT_NAME
@@ -147,5 +147,5 @@
     book setword rcPendingFS $pageName pantaskState RUN
 
-    $run = dist_make_fileset.pl --dist_id $DIST_ID --target_id $TARGET_ID --stage $STAGE --stage_id $STAGE_ID --dist_group $DIST_GROUP --filter $FILTER --dest_id $DEST_ID --product_name $PRODUCT_NAME  --ds_dbhost $DS_DBHOST --ds_dbname $DS_DBNAME --dist_dir $DIST_DIR
+    $run = dist_make_fileset.pl --dist_id $DIST_ID --target_id $TARGET_ID --stage $STAGE --stage_id $STAGE_ID --data_group $DATA_GROUP --filter $FILTER --dest_id $DEST_ID --product_name $PRODUCT_NAME  --ds_dbhost $DS_DBHOST --ds_dbname $DS_DBNAME --dist_dir $DIST_DIR
 
     add_standard_args run
@@ -198,4 +198,5 @@
     end
     add_poll_args run
+    add_poll_labels run
     command $run
   end
Index: branches/eam_branches/20091113/ippTasks/site.mhpcc.pro
===================================================================
--- branches/eam_branches/20091113/ippTasks/site.mhpcc.pro	(revision 26235)
+++ branches/eam_branches/20091113/ippTasks/site.mhpcc.pro	(revision 26236)
@@ -10,5 +10,6 @@
   controller exit true
 
-  controller host add ipp014
+#  controller host add ipp014
+  controller host add ipp021
   controller host add ipp015
   controller host add ipp023
Index: branches/eam_branches/20091113/ippTools/configure.ac
===================================================================
--- branches/eam_branches/20091113/ippTools/configure.ac	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/configure.ac	(revision 26236)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.61)
 
-AC_INIT([ipptools], [1.1.56], [ipp-support@ifa.hawaii.edu])
+AC_INIT([ipptools], [1.1.57], [ipp-support@ifa.hawaii.edu])
 AC_CONFIG_SRCDIR([autogen.sh])
 
@@ -18,5 +18,5 @@
 PKG_CHECK_MODULES([PSLIB], [pslib >= 1.1.0])
 PKG_CHECK_MODULES([PSMODULES], [psmodules >= 1.1.0])
-PKG_CHECK_MODULES([IPPDB], [ippdb >= 1.1.56]) 
+PKG_CHECK_MODULES([IPPDB], [ippdb >= 1.1.57]) 
 
 PXTOOLS_CFLAGS="${PSLIB_CFLAGS=} ${PSMODULES_CFLAGS=} ${IPPDB_CFLAGS=}"
@@ -59,5 +59,5 @@
 
 IPPDB_VERSION=`$PKG_CONFIG --modversion ippdb`
-AC_DEFINE_UNQUOTED(IPPDB_VERSION, $IPPDB_VERSION, [Version of ippdb])
+AC_DEFINE_UNQUOTED(IPPDB_VERSION, ["$IPPDB_VERSION"], [Version of ippdb])
 
 AC_CONFIG_FILES([
Index: branches/eam_branches/20091113/ippTools/share/Makefile.am
===================================================================
--- branches/eam_branches/20091113/ippTools/share/Makefile.am	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/Makefile.am	(revision 26236)
@@ -138,4 +138,5 @@
      disttool_revertfileset.sql \
      disttool_toadvance.sql \
+     disttool_updateinterest.sql \
      disttool_updatercrun.sql \
      faketool_change_exp_state.sql \
@@ -247,6 +248,5 @@
      stacktool_definebyquery_insert_random_part1.sql \
      stacktool_definebyquery_insert_random_part2.sql \
-     stacktool_definebyquery_part1.sql \
-     stacktool_definebyquery_part2.sql \
+     stacktool_definebyquery_select.sql \
      stacktool_definebyquery_test.sql \
      stacktool_donecleanup.sql \
Index: branches/eam_branches/20091113/ippTools/share/chiptool_processedimfile.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/chiptool_processedimfile.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/chiptool_processedimfile.sql	(revision 26236)
@@ -10,4 +10,6 @@
     chipProcessedImfile.magicked,
     chipProcessedImfile.data_state,
+    chipProcessedImfile.fault,
+    chipProcessedImfile.quality,
     chipRun.state,
     chipRun.workdir,
Index: branches/eam_branches/20091113/ippTools/share/difftool_definewarpstack_part1.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/difftool_definewarpstack_part1.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/difftool_definewarpstack_part1.sql	(revision 26236)
@@ -25,4 +25,6 @@
     JOIN chipRun USING(chip_id)
     WHERE warp1 IS NOT NULL
+        AND warpRun.state = 'full'
+    -- warp where hook %s
 ) AS diffExp USING(exp_id, warp_id)
 WHERE
Index: branches/eam_branches/20091113/ippTools/share/difftool_inputskyfile.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/difftool_inputskyfile.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/difftool_inputskyfile.sql	(revision 26236)
@@ -27,15 +27,6 @@
     JOIN chipRun
         USING(chip_id)
-    JOIN chipProcessedImfile
-        USING(chip_id)
     JOIN rawExp
-        ON chipRun.exp_id = rawExp.exp_id
-    WHERE
-	-- diffRun.state = 'new' AND 
-        warpRun.state = 'full'
-        AND warpRun.state = 'full'
-        AND fakeRun.state = 'full'
-        AND camRun.state = 'full'
-        AND chipRun.state = 'full'
+        USING(exp_id)
         -- where hook %s
     UNION
@@ -67,14 +58,6 @@
     JOIN chipRun
         USING(chip_id)
-    JOIN chipProcessedImfile
-        USING(chip_id)
     JOIN rawExp
-        ON chipRun.exp_id = rawExp.exp_id
-    WHERE
-        -- diffRun.state = 'new' AND 
- 	warpRun.state = 'full'
-        AND fakeRun.state = 'full'
-        AND camRun.state = 'full'
-        AND chipRun.state = 'full'
+        USING(exp_id)
         -- where hook %s
     UNION
@@ -107,7 +90,5 @@
         USING(chip_id)
     JOIN rawExp
-        ON chipRun.exp_id = rawExp.exp_id
-    WHERE
-        (diffRun.state = 'new' or diffRun.state = 'full')
+        USING(exp_id)
         -- where hook %s
     UNION
@@ -140,7 +121,6 @@
         USING(chip_id)
     JOIN rawExp
-        ON chipRun.exp_id = rawExp.exp_id
-    WHERE
-        (diffRun.state = 'new' or diffRun.state = 'full')
+        USING(exp_id)
         -- where hook %s
     ) as Foo
+-- template where hook %s
Index: branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_camera.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_camera.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_camera.sql	(revision 26236)
@@ -15,7 +15,6 @@
     AND camRun.dist_group  = distTarget.dist_group
 JOIN rcInterest USING(target_id)
-LEFT JOIN distRun ON distRun.stage = 'camera' 
-    AND camRun.cam_id = distRun.stage_id
-    AND distRun.clean = distTarget.clean
+LEFT JOIN distRun ON camRun.cam_id = distRun.stage_id
+    AND distRun.target_id = distTarget.target_id
     -- JOIN hook %s
 WHERE distTarget.state = 'enabled'
Index: branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_chip.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_chip.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_chip.sql	(revision 26236)
@@ -14,7 +14,6 @@
     AND rawExp.filter = distTarget.filter
 JOIN rcInterest USING(target_id)
-LEFT JOIN distRun ON distRun.stage = 'chip' 
-    AND distRun.stage_id = chipRun.chip_id
-    AND distRun.clean = distTarget.clean
+LEFT JOIN distRun ON distRun.stage_id = chipRun.chip_id
+    AND distRun.target_id = distTarget.target_id
     -- JOIN hook %s
 WHERE distTarget.state = 'enabled'
Index: branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_diff.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_diff.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_diff.sql	(revision 26236)
@@ -16,9 +16,9 @@
 JOIN rawExp USING(exp_id)
 JOIN distTarget ON distTarget.stage = 'diff'
-    AND diffRun.dist_group = distTarget.dist_group
     AND distTarget.filter = rawExp.filter
+    AND distTarget.dist_group = diffRun.dist_group
 JOIN rcInterest USING(target_id)
-LEFT JOIN distRun ON distRun.stage = 'diff' AND (distRun.stage_id = diff_id)
-    AND distRun.clean = distTarget.clean
+LEFT JOIN distRun ON (distRun.stage_id = diff_id)
+                  AND distTarget.target_id = distRun.target_id
     -- JOIN hook %s
 WHERE  distTarget.state = 'enabled'
Index: branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_fake.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_fake.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_fake.sql	(revision 26236)
@@ -15,6 +15,6 @@
     AND rawExp.filter = distTarget.filter
 JOIN rcInterest USING(target_id)
-LEFT JOIN distRun ON distRun.stage = 'fake' AND (distRun.stage_id = fake_id)
-    AND distRun.clean = distTarget.clean
+LEFT JOIN distRun ON (distRun.stage_id = fake_id)
+    AND distRun.target_id = distTarget.target_id
 WHERE  distTarget.state = 'enabled'
     AND rcInterest.state = 'enabled'
Index: branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_raw.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_raw.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_raw.sql	(revision 26236)
@@ -13,6 +13,6 @@
     AND rawExp.filter = distTarget.filter
 JOIN rcInterest USING(target_id)
-LEFT JOIN distRun ON distRun.stage = 'raw' AND distRun.stage_id = exp_id
-    AND distRun.clean = distTarget.clean
+LEFT JOIN distRun ON distRun.stage_id = exp_id
+    AND distRun.target_id = distTarget.target_id
     -- JOIN hook for magicked stuff %s
 WHERE distTarget.state = 'enabled'
Index: branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_stack.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_stack.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_stack.sql	(revision 26236)
@@ -15,6 +15,6 @@
     AND stackRun.filter = distTarget.filter
 JOIN rcInterest USING(target_id)
-LEFT JOIN distRun ON distRun.stage = 'stack' AND (distRun.stage_id = stack_id)
-    AND distRun.clean = distTarget.clean
+LEFT JOIN distRun ON (distRun.stage_id = stack_id)
+    AND distRun.target_id = distTarget.target_id
     -- JOIN hook %s
 WHERE  distTarget.state = 'enabled'
Index: branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_warp.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_warp.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_definebyquery_warp.sql	(revision 26236)
@@ -17,6 +17,6 @@
     AND rawExp.filter = distTarget.filter
 JOIN rcInterest USING(target_id)
-LEFT JOIN distRun ON distRun.stage = 'warp' AND (distRun.stage_id = warp_id)
-    AND distRun.clean = distTarget.clean
+LEFT JOIN distRun ON (distRun.stage_id = warp_id)
+    AND distRun.target_id = distTarget.target_id
 WHERE  distTarget.state = 'enabled'
     AND rcInterest.state = 'enabled'
Index: branches/eam_branches/20091113/ippTools/share/disttool_pendingfileset.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_pendingfileset.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/disttool_pendingfileset.sql	(revision 26236)
@@ -5,5 +5,7 @@
     distRun.outdir as dist_dir,
     stage_id,
-    distTarget.dist_group,
+    -- we need to get data_group here but we don't have
+    -- the right tables joined. Perhaps we need to add that column to distRun
+    distRun.label as data_group,
     distTarget.filter,
     rcDestination.name AS product_name,
Index: branches/eam_branches/20091113/ippTools/share/disttool_updateinterest.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/disttool_updateinterest.sql	(revision 26236)
+++ branches/eam_branches/20091113/ippTools/share/disttool_updateinterest.sql	(revision 26236)
@@ -0,0 +1,4 @@
+UPDATE rcInterest 
+JOIN distTarget USING(target_id)
+JOIN rcDestination USING(dest_id)
+SET rcInterest.state = '%s'
Index: branches/eam_branches/20091113/ippTools/share/pstamptool_revertjob.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/pstamptool_revertjob.sql	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/share/pstamptool_revertjob.sql	(revision 26236)
@@ -4,4 +4,3 @@
 WHERE  pstampRequest.state = 'run'
     AND pstampJob.state = 'run'
-    # do not revert faults >= 10 those are faults due to requestor errors
-    AND pstampJob.fault < 10
+    -- fault clause goes here %s
Index: branches/eam_branches/20091113/ippTools/share/stacktool_definebyquery_part1.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/stacktool_definebyquery_part1.sql	(revision 26235)
+++ 	(revision )
@@ -1,31 +1,0 @@
--- This is the first part of the query to get a list of skycells with
--- warps to be stacked, along with the number of warps already in a
--- stack.  It needs to be completed by part 2 (see below).
-
-SELECT
-    skycell_id,
-    filter,
-    tess_id,
-    num_warp,
-    MAX(num_stack) AS num_stack
-FROM ((
-    -- Number of stack-ready warps as a function of skycell and filter
-    SELECT
-        skycell_id,
-        warpSkyfile.tess_id as tess_id,
-        rawExp.filter,
-        COUNT(warpSkyfile.skycell_id) AS num_warp -- number of warps that can be stacked
-    FROM warpRun
-    JOIN warpSkyfile USING(warp_id)
-    JOIN fakeRun USING(fake_id)
-    JOIN camRun USING(cam_id)
-    JOIN camProcessedExp USING(cam_id)
-    JOIN chipRun USING(chip_id)
-    JOIN rawExp USING(exp_id)
-    WHERE
-        warpRun.state = 'full'
-        AND warpSkyfile.fault = 0
-        AND warpSkyfile.quality = 0
-    -- Here should follow the SQL in stacktool_definebyquery_part2.sql,
-    -- after any additional WHERE conditions have been added
-
Index: branches/eam_branches/20091113/ippTools/share/stacktool_definebyquery_part2.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/stacktool_definebyquery_part2.sql	(revision 26235)
+++ 	(revision )
@@ -1,28 +1,0 @@
-
--- This is the second part of the query to get a list of skycells with
--- warps to be stacked, along with the number of warps already in a
--- stack.  It should follow part 1, which is in
--- stacktool_definebyquery_part1.sql
-
-    GROUP BY
-        skycell_id,
-        filter
-        ) AS warpsToStack
-        LEFT JOIN (
-    -- Number of stack inputs as a function of skycell and filter
-    SELECT
-        skycell_id,
-	stackRun.tess_id as stack_tess_id,
-        filter,
-        COUNT(stackInputSkyfile.warp_id) as num_stack -- number of warps in a stack
-    FROM stackRun
-        JOIN stackInputSkyfile USING(stack_id)
-    GROUP BY
-        stack_id
-        ) AS stackSizes
-    -- JOINing the warpsToStack and stackSizes tables
-        USING(skycell_id, filter)
-        )
-    GROUP BY
-        skycell_id,
-        filter
Index: branches/eam_branches/20091113/ippTools/share/stacktool_definebyquery_select.sql
===================================================================
--- branches/eam_branches/20091113/ippTools/share/stacktool_definebyquery_select.sql	(revision 26236)
+++ branches/eam_branches/20091113/ippTools/share/stacktool_definebyquery_select.sql	(revision 26236)
@@ -0,0 +1,52 @@
+-- This is a query to get a list of skycells with warps to be stacked,
+-- along with the number of warps already in a stack.
+
+SELECT
+    skycell_id,
+    filter,
+    tess_id,
+    num_warp,
+    MAX(num_stack) AS num_stack
+FROM ((
+    -- Number of stack-ready warps as a function of skycell and filter
+    SELECT
+        skycell_id,
+        warpSkyfile.tess_id as tess_id,
+        rawExp.filter,
+        COUNT(warpSkyfile.skycell_id) AS num_warp -- number of warps that can be stacked
+    FROM warpRun
+    JOIN warpSkyfile USING(warp_id)
+    JOIN fakeRun USING(fake_id)
+    JOIN camRun USING(cam_id)
+    JOIN camProcessedExp USING(cam_id)
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
+    WHERE
+        warpRun.state = 'full'
+        AND warpSkyfile.fault = 0
+        AND warpSkyfile.quality = 0
+    -- WHERE hook %s
+    GROUP BY
+        skycell_id,
+        filter
+    ) AS warpsToStack
+LEFT JOIN (
+    -- Number of stack inputs as a function of skycell and filter
+    SELECT
+        skycell_id,
+        stackRun.tess_id as stack_tess_id,
+        filter,
+        COUNT(stackInputSkyfile.warp_id) as num_stack -- number of warps in a stack
+    FROM stackRun
+    JOIN stackInputSkyfile USING(stack_id)
+    -- WHERE hook %s
+    GROUP BY
+        stack_id
+    ) AS stackSizes
+-- JOINing the warpsToStack and stackSizes tables
+    USING(skycell_id, filter)
+    )
+GROUP BY
+    skycell_id,
+    filter
+
Index: branches/eam_branches/20091113/ippTools/src/difftool.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/difftool.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/difftool.c	(revision 26236)
@@ -95,6 +95,6 @@
         MODECASE(DIFFTOOL_MODE_IMPORTRUN,             importrunMode);
         MODECASE(DIFFTOOL_MODE_TOCLEANEDSKYFILE,   tocleanedskyfileMode);
-	MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE,    topurgedskyfileMode);
-	MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE,  toscrubbedskyfileMode);
+        MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE,    topurgedskyfileMode);
+        MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE,  toscrubbedskyfileMode);
 
         default:
@@ -210,5 +210,5 @@
     PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
     PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
-    
+
     // Copy of my hacky work around from stacktool.c
     if ((state)&&(diff_id)) {
@@ -383,23 +383,19 @@
     }
 
-    psString whereClause = NULL;
+    psString whereClause = psStringCopy("");
     if (psListLength(where->list)) {
         whereClause = psDBGenerateWhereConditionSQL(where, NULL);
-        psStringPrepend(&whereClause, "\n AND ");
+        psStringPrepend(&whereClause, "\n WHERE ");
     }
     psFree(where);
 
     // Add condition to get only templates or only inputs
+    psString templateClause = psStringCopy("");
     {
-        psString templateClause = NULL;
         if (template) {
-            psStringAppend(&templateClause, " %s", " template != 0");
+            psStringAppend(&templateClause, "\n WHERE %s", " template != 0");
         } else if (input) {
-            psStringAppend(&templateClause, " %s", " template = 0");
-        }
-        if (templateClause) {
-            psStringAppend(&whereClause, "\n AND %s", templateClause);
-        }
-        psFree(templateClause);
+            psStringAppend(&templateClause, "\n WHERE %s", " template = 0");
+        }
     }
 
@@ -412,10 +408,12 @@
     }
 
-    if (!p_psDBRunQueryF(config->dbh, query, whereClause, whereClause, whereClause, whereClause)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
+    if (!p_psDBRunQueryF(config->dbh, query, whereClause, whereClause, whereClause, whereClause, templateClause)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        psFree(templateClause);
         psFree(whereClause);
         psFree(query);
         return false;
     }
+    psFree(templateClause);
     psFree(whereClause);
     psFree(query);
@@ -816,4 +814,5 @@
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where,  "-diff_id", "diffSkyfile.diff_id", "==");
+    PXOPT_COPY_STR(config->args, where,  "-skycell_id", "diffSkyfile.skycell_id", "==");
     PXOPT_COPY_STR(config->args, where,  "-label", "diffRun.label", "==");
     PXOPT_COPY_S16(config->args, where, "-fault",     "fault", "==");
@@ -914,5 +913,5 @@
     if (magicked) {
       char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64;
-      
+
       if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) {
         psError(PS_ERR_UNKNOWN, false,
@@ -923,5 +922,5 @@
     else {
       char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64;
-      
+
       if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) {
         psError(PS_ERR_UNKNOWN, false,
@@ -930,5 +929,5 @@
       }
     }
-    
+
     return true;
 }
@@ -948,5 +947,5 @@
   if (!p_psDBRunQueryF(config->dbh,query,state,label)) {
     psError(PS_ERR_UNKNOWN, false,
-	    "failed to change state for label %s", label);
+            "failed to change state for label %s", label);
     return(false);
   }
@@ -1138,14 +1137,18 @@
 
     psMetadata *expWhere = psMetadataAlloc();
-    psMetadata *warpWhere = psMetadataAlloc();
+    psMetadata *warp1Where = psMetadataAlloc(); // First set of restrictions on warp
+    psMetadata *warp2Where = psMetadataAlloc(); // Second set of restriction on warp
     psMetadata *stackWhere = psMetadataAlloc();
 
     PXOPT_COPY_S64(config->args, expWhere, "-exp_id", "exp_id", "==");
     PXOPT_COPY_STR(config->args, expWhere, "-filter", "filter", "==");
-    PXOPT_COPY_S64(config->args, warpWhere, "-warp_id", "warpRun.warp_id", "==");
-    PXOPT_COPY_STR(config->args, warpWhere, "-skycell_id", "warpSkyfile.skycell_id", "==");
-    PXOPT_COPY_STR(config->args, warpWhere, "-tess_id", "warpRun.tess_id", "==");
-    PXOPT_COPY_STR(config->args, warpWhere, "-warp_label", "warpRun.label", "==");
-    PXOPT_COPY_F32(config->args, warpWhere,  "-good_frac", "warpSkyfile.good_frac", ">=");
+    PXOPT_COPY_S64(config->args, warp1Where, "-warp_id", "warpRun.warp_id", "==");
+    PXOPT_COPY_STR(config->args, warp1Where, "-warp_label", "warpRun.label", "==");
+    PXOPT_COPY_STR(config->args, warp1Where, "-tess_id", "warpRun.tess_id", "==");
+    PXOPT_COPY_S64(config->args, warp2Where, "-warp_id", "warpRun.warp_id", "==");
+    PXOPT_COPY_STR(config->args, warp2Where, "-tess_id", "warpRun.tess_id", "==");
+    PXOPT_COPY_STR(config->args, warp2Where, "-skycell_id", "warpSkyfile.skycell_id", "==");
+    PXOPT_COPY_STR(config->args, warp2Where, "-warp_label", "warpRun.label", "==");
+    PXOPT_COPY_F32(config->args, warp2Where,  "-good_frac", "warpSkyfile.good_frac", ">=");
     PXOPT_COPY_STR(config->args, stackWhere, "-stack_label", "stackRun.label", "==");
 
@@ -1171,5 +1174,6 @@
     }
 
-    psString warpQuery = NULL;
+    psString warp1Query = NULL;
+    psString warp2Query = NULL;
     psString stackQuery = NULL;
     psString expQuery = NULL;
@@ -1183,17 +1187,20 @@
     }
     psFree(expWhere);
-    if (psListLength(warpWhere->list)) {
-        psString whereClause = psDBGenerateWhereConditionSQL(warpWhere, NULL);
-        psStringAppend(&warpQuery, "\n AND %s", whereClause);
+    if (psListLength(warp1Where->list)) {
+        psString whereClause = psDBGenerateWhereConditionSQL(warp1Where, NULL);
+        psStringAppend(&warp1Query, "\n AND %s", whereClause);
         psFree(whereClause);
     } else {
-        warpQuery = psStringCopy("\n");
-    }
-    psFree(warpWhere);
-
-    if (!available) {
-        // diff what's available, even if warp run has some faults and is incomplete
-        psStringAppend(&warpQuery, " AND warpRun.state = 'full'");
-    }
+        warp1Query = psStringCopy("\n");
+    }
+    psFree(warp1Where);
+    if (psListLength(warp2Where->list)) {
+        psString whereClause = psDBGenerateWhereConditionSQL(warp2Where, NULL);
+        psStringAppend(&warp2Query, "\n AND %s", whereClause);
+        psFree(whereClause);
+    } else {
+        warp2Query = psStringCopy("\n");
+    }
+    psFree(warp2Where);
 
     // don't queue for exposures that have already been diff'd unless requested
@@ -1214,5 +1221,5 @@
     psFree(stackWhere);
 
-    psTrace("difftool", 1, query, warpQuery, diffQuery, expQuery, stackQuery);
+    psTrace("difftool", 1, query, warp1Query, warp2Query, diffQuery, expQuery, stackQuery);
 
     if (!psDBTransaction(config->dbh)) {
@@ -1221,5 +1228,5 @@
     }
 
-    if (!p_psDBRunQueryF(config->dbh, query, warpQuery, expQuery, diffQuery)) {
+    if (!p_psDBRunQueryF(config->dbh, query, warp1Query, warp2Query, expQuery, diffQuery)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(query);
@@ -1281,4 +1288,5 @@
         return false;
     }
+    psFree(warp1Query);
     psFree(query);
     query = NULL;
@@ -1312,5 +1320,5 @@
         if (!p_psDBRunQuery(config->dbh, "DELETE FROM skycellsToDiff")) {
             psError(PS_ERR_UNKNOWN, false, "database error");
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1323,5 +1331,5 @@
         if (!mdok) {
             psError(PXTOOLS_ERR_PROG, false, "warp_id not found --- ignoring row %ld", i);
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1334,5 +1342,5 @@
         if (!mdok) {
             psError(PXTOOLS_ERR_PROG, false, "skycell_count not found");
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1345,5 +1353,5 @@
         if (!mdok) {
             psError(PXTOOLS_ERR_PROG, false, "tess_id not found");
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1356,5 +1364,5 @@
         if (!mdok) {
             psError(PXTOOLS_ERR_PROG, false, "filter not found");
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1364,7 +1372,7 @@
             return false;
         }
-        if (!p_psDBRunQueryF(config->dbh, skycell_query, stackQuery, warp_id, filter, warpQuery)) {
-            psError(PS_ERR_UNKNOWN, false, "database error");
-            psFree(warpQuery);
+        if (!p_psDBRunQueryF(config->dbh, skycell_query, stackQuery, warp_id, filter, warp2Query)) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1377,5 +1385,5 @@
 
         if (num == 0) {
-            psTrace("difftool", PS_LOG_INFO, "no skycells with stack found for %" PRId64, warp_id);
+            psTrace("difftool", PS_LOG_INFO, "no skycells with stack found for warp_id %" PRId64, warp_id);
             continue;
         }
@@ -1383,5 +1391,5 @@
         if (!available && (num != skycell_count)) {
             psTrace("difftool", PS_LOG_INFO, "%" PRId64 " skyfiles with stack found for warp_id %" PRId64
-                    " need %" PRId64, num, warp_id, skycell_count);
+                    " but need %" PRId64, num, warp_id, skycell_count);
             continue;
         }
@@ -1418,5 +1426,5 @@
         if (!p_psDBRunQuery(config->dbh, query)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1432,5 +1440,5 @@
         if (!p_psDBRunQuery(config->dbh, query)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1447,5 +1455,5 @@
             psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64,
                 run->diff_id);
-            psFree(warpQuery);
+            psFree(warp2Query);
             psFree(stackQuery);
             psFree(skycell_query);
@@ -1461,5 +1469,5 @@
     }
     psFree(output);
-    psFree(warpQuery);
+    psFree(warp2Query);
     psFree(stackQuery);
     psFree(skycell_query);
@@ -2062,5 +2070,5 @@
     return(false);
   }
-  
+
   return(true);
 }
Index: branches/eam_branches/20091113/ippTools/src/difftoolConfig.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/difftoolConfig.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/difftoolConfig.c	(revision 26236)
@@ -155,4 +155,5 @@
     psMetadata *revertdiffskyfileArgs = psMetadataAlloc();
     psMetadataAddS64(revertdiffskyfileArgs, PS_LIST_TAIL, "-diff_id", 0,            "search by diff ID", 0);
+    psMetadataAddStr(revertdiffskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell_id", NULL);
     psMetadataAddStr(revertdiffskyfileArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL);
     psMetadataAddS16(revertdiffskyfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
@@ -192,5 +193,5 @@
     psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-new-templates", 0, "also search for diffs with new template", false);
     psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-rerun", 0, "define new run even if one exists", false);
-    psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-available", 0, "define new run even if warpRun has some faults", false);
+    psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-available", 0, "define new run even if no stacks available for some skycells", false);
     psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
     psMetadataAddBool(definewarpstackArgs, PS_LIST_TAIL, "-pretend", 0, "list results but to not queue", false);
@@ -328,5 +329,5 @@
     PXOPT_ADD_MODE("-topurgedskyfile", "set skyfile as purged", DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileArgs);
     PXOPT_ADD_MODE("-toscrubbedskyfile", "set skyfile as scrubbed", DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileArgs);
-    
+
     if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
         psError(PS_ERR_UNKNOWN, true, "option parsing failed");
Index: branches/eam_branches/20091113/ippTools/src/disttool.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/disttool.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/disttool.c	(revision 26236)
@@ -52,5 +52,5 @@
 static bool definetargetMode(pxConfig *config);
 static bool updatetargetMode(pxConfig *config);
-static bool listtargetMode(pxConfig *config);
+static bool listtargetsMode(pxConfig *config);
 
 static bool definedestinationMode(pxConfig *config);
@@ -100,5 +100,5 @@
         MODECASE(DISTTOOL_MODE_DEFINETARGET, definetargetMode);
         MODECASE(DISTTOOL_MODE_UPDATETARGET, updatetargetMode);
-        MODECASE(DISTTOOL_MODE_LISTTARGET, listtargetMode);
+        MODECASE(DISTTOOL_MODE_LISTTARGETS, listtargetsMode);
         MODECASE(DISTTOOL_MODE_DEFINEDESTINATION, definedestinationMode);
         MODECASE(DISTTOOL_MODE_UPDATEDESTINATION, updatedestinationMode);
@@ -1311,5 +1311,5 @@
 }
 
-static bool listtargetMode(pxConfig *config)
+static bool listtargetsMode(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
@@ -1551,5 +1551,8 @@
     PXOPT_COPY_STR(config->args, where, "-dist_group", "dist_group", "LIKE");
     PXOPT_COPY_STR(config->args, where, "-filter", "filter", "LIKE");
-    PXOPT_COPY_STR(config->args, where, "-stage", "stage", "==");
+    // if stage is all don't add it to the query (match all stages)
+    if (stage && strcmp(stage, "all")) {
+        PXOPT_COPY_STR(config->args, where, "-stage", "stage", "==");
+    }
 
     psString query = pxDataGet("disttool_defineinterest.sql");
@@ -1611,4 +1614,7 @@
     PXOPT_COPY_S64(config->args, where, "-dest_id",   "dest_id", "==");
     PXOPT_COPY_S64(config->args, where, "-target_id", "target_id", "==");
+    PXOPT_COPY_STR(config->args, where, "-dest_name", "rcDestination.name", "LIKE");
+    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "LIKE");
+    PXOPT_COPY_STR(config->args, where, "-dist_group", "dist_group", "LIKE");
 
     PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
@@ -1618,6 +1624,5 @@
         return false;
     }
-    psString query = NULL;
-    psStringAppend(&query, "UPDATE rcInterest SET state = '%s'", state);
+    psString query = pxDataGet("disttool_updateinterest.sql");
 
     if (psListLength(where->list)) {
@@ -1633,5 +1638,5 @@
     psFree(where);
 
-    if (!p_psDBRunQuery(config->dbh, query)) {
+    if (!p_psDBRunQueryF(config->dbh, query, state)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(query);
@@ -1639,4 +1644,7 @@
     }
     psFree(query);
+
+    psS64 numUpdated = psDBAffectedRows(config->dbh);
+    printf("updated %" PRId64 " interests\n", numUpdated);
 
     return true;
Index: branches/eam_branches/20091113/ippTools/src/disttool.h
===================================================================
--- branches/eam_branches/20091113/ippTools/src/disttool.h	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/disttool.h	(revision 26236)
@@ -47,5 +47,5 @@
     DISTTOOL_MODE_DEFINETARGET,
     DISTTOOL_MODE_UPDATETARGET,
-    DISTTOOL_MODE_LISTTARGET,
+    DISTTOOL_MODE_LISTTARGETS,
     DISTTOOL_MODE_DEFINEINTEREST,
     DISTTOOL_MODE_UPDATEINTEREST,
Index: branches/eam_branches/20091113/ippTools/src/disttoolConfig.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/disttoolConfig.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/disttoolConfig.c	(revision 26236)
@@ -263,15 +263,15 @@
     psMetadataAddStr(updatetargetArgs, PS_LIST_TAIL, "-set_state", 0, "define new state", NULL);
 
-    // -listtarget
-    psMetadata *listtargetArgs = psMetadataAlloc();
-    psMetadataAddS64(listtargetArgs, PS_LIST_TAIL, "-target_id", 0, "list target with target_id", 0);
-    psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "-dist_group",  0, "list targets for dist_group", NULL);
-    psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "-filter",    0, "define filter", NULL);
-    psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "-stage",     0, "list targets for stage", NULL);
-    psMetadataAddBool(listtargetArgs, PS_LIST_TAIL,"-clean",     0, "list clean targets", false);
-    psMetadataAddBool(listtargetArgs, PS_LIST_TAIL,"-full",      0, "list full targets", false);
-    psMetadataAddStr(listtargetArgs, PS_LIST_TAIL, "-state",     0, "list targets in state", NULL);
-    psMetadataAddU64(listtargetArgs, PS_LIST_TAIL, "-limit",     0, "limit number of targets listed to N", 0);
-    psMetadataAddBool(listtargetArgs, PS_LIST_TAIL, "-simple",  0, "use the simple output format", false);
+    // -listtargets
+    psMetadata *listtargetsArgs = psMetadataAlloc();
+    psMetadataAddS64(listtargetsArgs, PS_LIST_TAIL, "-target_id", 0, "list target with target_id", 0);
+    psMetadataAddStr(listtargetsArgs, PS_LIST_TAIL, "-dist_group",  0, "list targets for dist_group", NULL);
+    psMetadataAddStr(listtargetsArgs, PS_LIST_TAIL, "-filter",    0, "define filter", NULL);
+    psMetadataAddStr(listtargetsArgs, PS_LIST_TAIL, "-stage",     0, "list targets for stage", NULL);
+    psMetadataAddBool(listtargetsArgs, PS_LIST_TAIL,"-clean",     0, "list clean targets", false);
+    psMetadataAddBool(listtargetsArgs, PS_LIST_TAIL,"-full",      0, "list full targets", false);
+    psMetadataAddStr(listtargetsArgs, PS_LIST_TAIL, "-state",     0, "list targets in state", NULL);
+    psMetadataAddU64(listtargetsArgs, PS_LIST_TAIL, "-limit",     0, "limit number of targets listed to N", 0);
+    psMetadataAddBool(listtargetsArgs, PS_LIST_TAIL, "-simple",  0, "use the simple output format", false);
 
     // -defineinterest
@@ -293,4 +293,7 @@
     psMetadataAddS64(updateinterestArgs, PS_LIST_TAIL, "-target_id", 0, "define target_id", 0);
     psMetadataAddStr(updateinterestArgs, PS_LIST_TAIL, "-set_state", 0, "define state (required)", NULL);
+    psMetadataAddStr(updateinterestArgs, PS_LIST_TAIL, "-filter",    0, "define filter (LIKE comparison)", NULL);
+    psMetadataAddStr(updateinterestArgs, PS_LIST_TAIL, "-dest_name",    0, "define destination name", NULL);
+    psMetadataAddStr(updateinterestArgs, PS_LIST_TAIL, "-dist_group",    0, "define distribution group", NULL);
 
     // -listinterests
@@ -337,5 +340,5 @@
     PXOPT_ADD_MODE("-definetarget",       "", DISTTOOL_MODE_DEFINETARGET, definetargetArgs);
     PXOPT_ADD_MODE("-updatetarget",       "", DISTTOOL_MODE_UPDATETARGET, updatetargetArgs);
-    PXOPT_ADD_MODE("-listtarget",         "", DISTTOOL_MODE_LISTTARGET, listtargetArgs);
+    PXOPT_ADD_MODE("-listtargets",         "", DISTTOOL_MODE_LISTTARGETS, listtargetsArgs);
 
     PXOPT_ADD_MODE("-defineinterest",     "", DISTTOOL_MODE_DEFINEINTEREST, defineinterestArgs);
Index: branches/eam_branches/20091113/ippTools/src/faketool.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/faketool.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/faketool.c	(revision 26236)
@@ -92,5 +92,5 @@
         MODECASE(FAKETOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
         MODECASE(FAKETOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
-	MODECASE(FAKETOOL_MODE_TOSCRUBBEDIMFILE,        toscrubbedimfileMode);
+        MODECASE(FAKETOOL_MODE_TOSCRUBBEDIMFILE,        toscrubbedimfileMode);
         MODECASE(FAKETOOL_MODE_EXPORTRUN,               exportrunMode);
         MODECASE(FAKETOOL_MODE_IMPORTRUN,               importrunMode);
@@ -123,4 +123,6 @@
 
     psMetadata *where = psMetadataAlloc();
+    PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
Index: branches/eam_branches/20091113/ippTools/src/faketoolConfig.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/faketoolConfig.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/faketoolConfig.c	(revision 26236)
@@ -47,4 +47,6 @@
     psMetadata *queueArgs = psMetadataAlloc();
     // XXX need to allow multiple exp_ids
+    psMetadataAddS64(queueArgs, PS_LIST_TAIL, "-cam_id",             0, "search by cam_id", 0);
+    psMetadataAddS64(queueArgs, PS_LIST_TAIL, "-chip_id",            0, "search by chip_id", 0);
     psMetadataAddS64(queueArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by exp_id", 0);
     psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-exp_name",  0,            "search by exp_name", NULL);
Index: branches/eam_branches/20091113/ippTools/src/magictool.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/magictool.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/magictool.c	(revision 26236)
@@ -580,5 +580,5 @@
 
     if (fault > 0) {
-        char *query = "UPDATE magicRun SET fault = %d, state = 'full' WHERE magic_id = %" PRId64;
+        char *query = "UPDATE magicRun SET fault = %d WHERE magic_id = %" PRId64;
         if (!p_psDBRunQueryF(config->dbh, query, fault, magic_id)) {
             psError(PS_ERR_UNKNOWN, false,
@@ -930,5 +930,5 @@
             psAbort("failed to lookup value for magic_id column");
         }
-        
+
         whereString = NULL;
         psStringAppend(&whereString, "\nAND (magic_id = %" PRId64 ")", magic_id);
Index: branches/eam_branches/20091113/ippTools/src/pstamptool.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/pstamptool.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/pstamptool.c	(revision 26236)
@@ -774,6 +774,16 @@
     PXOPT_COPY_S64(config->args, where, "-fault",  "fault", "==");
     PXOPT_COPY_S64(config->args, where, "-req_id_min",  "req_id", ">=");
+
     PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault",  false, false);
+
+    // By default only revert faults < 10 which are our "ipp exit codes"
+    // codes larger than that are the pstamp request interface.
+    // Don't fault those unless -fault waa provided
+    psString faultClause = "";
+    if (!fault) {
+        faultClause = " \nAND (pstampJob.fault < 10)";
+    }
 
     psString query = pxDataGet("pstamptool_revertjob.sql");
@@ -790,5 +800,5 @@
     psFree(where);
     
-    if (!p_psDBRunQuery(config->dbh, query)) {
+    if (!p_psDBRunQueryF(config->dbh, query, faultClause)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
Index: branches/eam_branches/20091113/ippTools/src/pxadmin.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/pxadmin.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/pxadmin.c	(revision 26236)
@@ -114,5 +114,5 @@
     psFree(query);
 
-    if (!insert_dbversion(config, PACKAGE_VERSION)) {
+    if (!insert_dbversion(config, IPPDB_VERSION)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set database version");
         return false;
@@ -155,5 +155,5 @@
     psFree(query);
 
-    if (!insert_dbversion(config, PACKAGE_VERSION)) {
+    if (!insert_dbversion(config, IPPDB_VERSION)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set database version");
         return false;
Index: branches/eam_branches/20091113/ippTools/src/stacktool.c
===================================================================
--- branches/eam_branches/20091113/ippTools/src/stacktool.c	(revision 26235)
+++ branches/eam_branches/20091113/ippTools/src/stacktool.c	(revision 26236)
@@ -150,5 +150,5 @@
     PXOPT_COPY_F32(config->args,  where, "-select_iq_m4_min",          "camProcessedExp.iq_m4", ">=");
     PXOPT_COPY_F32(config->args,  where, "-select_iq_m4_max",          "camProcessedExp.iq_m4", "<=");
-    
+
     PXOPT_COPY_STR(config->args,  where, "-select_exp_type",           "rawExp.exp_type", "==");
     PXOPT_COPY_F32(config->args,  where, "-select_good_frac_min",      "warpSkyfile.good_frac", ">=");
@@ -173,5 +173,5 @@
     }
 
-    psString select = pxDataGet("stacktool_definebyquery_part1.sql");
+    psString select = pxDataGet("stacktool_definebyquery_select.sql");
     if (!select) {
         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
@@ -179,18 +179,15 @@
     }
 
+    psString where1 = psStringCopy("");
     if (psListLength(where->list)) {
         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
-        psStringAppend(&select, " AND %s", whereClause);
+        psStringAppend(&where1, "\nAND %s", whereClause);
         psFree(whereClause);
     }
 
-    psString groupby = pxDataGet("stacktool_definebyquery_part2.sql");
-    if (!groupby) {
-        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-        psFree(where);
-        return false;
-    }
-    psStringAppend(&select, " %s", groupby);
-    psFree(groupby);
+    psString where2 = psStringCopy("");
+    if (label) {
+        psStringAppend(&where2, "\nWHERE stackRun.label = '%s'", label);
+    }
 
     // Restriction on aggregated quantities using HAVING
@@ -224,11 +221,14 @@
     psFree(having);
 
-    if (!p_psDBRunQuery(config->dbh, select)) {
+    if (!p_psDBRunQueryF(config->dbh, select, where1, where2)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(select);
-        psFree(where);
+        psFree(where1);
+        psFree(where2);
         return false;
     }
     psFree(select);
+    psFree(where1);
+    psFree(where2);
 
     psArray *output = p_psDBFetchResult(config->dbh);
Index: branches/eam_branches/20091113/psconfig/tagsets/ipp-2.9.dist
===================================================================
--- branches/eam_branches/20091113/psconfig/tagsets/ipp-2.9.dist	(revision 26235)
+++ branches/eam_branches/20091113/psconfig/tagsets/ipp-2.9.dist	(revision 26236)
@@ -69,4 +69,5 @@
   YNYYN  ippMonitor             ipp-2-9          -0
   YYYYY  DataStore              ipp-2-9          -0
+  YYYYY  DataStoreServer        ipp-2-9          -0
 
   YYYYY  ppTranslate            ipp-2-9          -0
Index: branches/eam_branches/20091113/psconfig/tagsets/ipp-2.9.perl
===================================================================
--- branches/eam_branches/20091113/psconfig/tagsets/ipp-2.9.perl	(revision 26235)
+++ branches/eam_branches/20091113/psconfig/tagsets/ipp-2.9.perl	(revision 26236)
@@ -31,5 +31,5 @@
   26    HTML::Parser                   HTML-Parser-3.56.tar.gz                  0
   27    Digest::MD5                    Digest-MD5-2.36.tar.gz                   0
-  28    Net::FTP                       libnet-1.19.tar.gz                       0
+  28    Net::FTP                       libnet-1.19.tar.gz                       0               n
   29    Compress::Zlib                 Compress-Zlib-2.003.tar.gz               0
   30    Locale::Maketext::Simple       Locale-Maketext-Simple-0.18.tar.gz       0
Index: branches/eam_branches/20091113/pstamp/scripts/pstamp_get_image_job.pl
===================================================================
--- branches/eam_branches/20091113/pstamp/scripts/pstamp_get_image_job.pl	(revision 26235)
+++ branches/eam_branches/20091113/pstamp/scripts/pstamp_get_image_job.pl	(revision 26236)
@@ -16,25 +16,18 @@
 use File::Basename;
 use Digest::MD5::File qw( file_md5_hex );
+use IPC::Cmd 0.36 qw( can_run run );
 
-use PS::IPP::Config qw($PS_EXIT_SUCCESS
-		       $PS_EXIT_UNKNOWN_ERROR
-		       $PS_EXIT_SYS_ERROR
-		       $PS_EXIT_CONFIG_ERROR
-		       $PS_EXIT_PROG_ERROR
-		       $PS_EXIT_DATA_ERROR
-		       $PS_EXIT_TIMEOUT_ERROR
-		       metadataLookupStr
-		       metadataLookupBool
-		       caturi
-		       );
+
+use PS::IPP::Config qw( :standard );
+
 my $product;
 my $fileset;
 
-my $uri;
-my $out_dir;
+my $output_base;
 
-my $verbose = 1;
+my $verbose;
 my $ipprc;
 my $dbname;
+my $dbserver;
 my $job_id;
 my $rownum;
@@ -47,7 +40,8 @@
         'job_id=s'        =>      \$job_id,
         'rownum=s'        =>      \$rownum,
-        'uri=s'           =>      \$uri,
-        'out_dir=s'       =>      \$out_dir,
+        'output_base=s'   =>      \$output_base,
         'dbname=s'        =>      \$dbname,
+        'dbserver=s'      =>      \$dbserver,
+        'verbose'         =>      \$verbose,
 ) or pod2usage(2);
 
@@ -55,78 +49,100 @@
 $err .= "--job_id is required\n" if (!$job_id);
 $err .= "--rownum is required\n" if (!$rownum);
-$err .= "--uri is required to specify the file list\n" if (!$uri);
-$err .= "--out_dir is required to specify the output fileset\n" if (!$out_dir);
+$err .= "--output_base is required to specify the output fileset\n" if (!$output_base);
 
-die $err if $err;
+my_die( $err, $PS_EXIT_PROG_ERROR) if $err;
 
-# collapse any multiple slashes in output_dir
-$out_dir = File::Spec->canonpath($out_dir);
+my $params_file = $output_base . ".mdc";
+if (! open(INPUT, "<$params_file") ) {
+    my_die("failed to open params file: $params_file", $PS_EXIT_UNKNOWN_ERROR);
+}
 
-my @path = split(/\//, $out_dir);
+my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
 
-my $nelem = @path;
-if ($nelem < 2) {
-    die("$out_dir is not a valid output fileset directory");
+my $data = $mdcParser->parse(join "", (<INPUT>)) or my_die("failed to parse metadata config doc", $PS_EXIT_UNKNOWN_ERROR);
+my $components = parse_md_list($data);
+my $n = scalar @$components;
+if ($n != 1) {
+    my_die("params file $params_file contains unexpected number of components: $n", $PS_EXIT_PROG_ERROR);
 }
-$fileset = $path[$nelem-1];
-$product = $path[$nelem-2];
-
-$_ = $out_dir;
-my ($ds_dir) = m%(.*)/$product/$fileset%;
+my $comp = $components->[0];
+my $stage = $comp->{stage};
+my $stage_id = $comp->{stage_id};
+my $component = $comp->{component};
+my $path_base = $comp->{path_base};
+my $camera = $comp->{camera};
+my $magicked = $comp->{magicked};
 
 if ($verbose) {
-    print STDERR "DS root:  $ds_dir\n";
-    print STDERR "Product:  $product\n";
-    print STDERR "Fileset:  $fileset\n";
-    print STDERR "Filelist: $uri\n";
+    print STDERR "\nstage is $stage\n";
+    print STDERR "stage_id is $stage_id\n";
+    print STDERR "path_base is $path_base\n";
+    print STDERR "path_base is $path_base\n";
+    print STDERR "CAMERA is $camera\n";
+    print STDERR "magicked is " . (defined $magicked ? $magicked : "undefined") . "\n";
 }
 
-
-if (!stat("$ds_dir/index.txt")) {
-    $err .= "Data Store not found at '$ds_dir'.\n"
+if (!$camera or !$path_base or !$component or !$stage_id or !$stage) {
+       my_die("failed to parse params from: $params_file", $PS_EXIT_UNKNOWN_ERROR);
 }
 
-show_usage("Invalid product '$product'.")
-    unless defined stat("$ds_dir/$product/index.txt");
+my $out_dir = dirname($output_base);
+my $prefix = basename($output_base) . "_";
+my $results_file = $output_base . ".bundle_results";
 
-if (! open(INPUT, "<$uri") ) {
-    die("failed to open file list: $uri");
+# Look for programs we need
+my $missing_tools;
+my $dist_bundle   = can_run('dist_bundle.pl') or (warn "Can't find dist_bundle.pl" and $missing_tools = 1);
+if ($missing_tools) {
+    warn("Can't find required tools.");
+    exit($PS_EXIT_CONFIG_ERROR);
 }
 
-my $reglist = "$out_dir/reglist";
-if (! open(REGLIST, ">$reglist$job_id") ) {
-    die("failed to open registration list: $reglist");
+{
+    my $command = "$dist_bundle --camera $camera --stage $stage --stage_id $stage_id";
+    $command .= " --component $component";
+    $command .= " --path_base $path_base --outdir $out_dir --results_file $results_file";
+    $command .= " --prefix $prefix";
+    $command .= " --magicked" if $magicked;
+    $command .= " --dbname $dbname" if $dbname;
+    $command .= " --verbose" if $verbose;
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        my_die("Unable to perform $command: $error_code", $error_code >> 8);
+    }
 }
 
-my @files;
-my $num = 0;
-while (<INPUT>) {
-    chomp;
-    my @fields = split /\|/;
-    my $pathname = shift @fields;
-    my $filetype = shift @fields;
-    my $class_id = shift @fields;
+if (! open(RESULTS, "<$results_file")) {
+    my_die("failed to open bundle results file: $results_file", $PS_EXIT_UNKNOWN_ERROR);
+}
 
-    ($pathname , my $filename) = resolvepath($pathname);
+my $file_name;
+my $bytes;
+my $md5sum;
+foreach my $line (<RESULTS>) {
+    chomp $line;
+    next if !$line;
+    next if $line =~ /bundleResults/;
+    last if $line =~ /END/;
 
-    if ($verbose) {
-        print STDERR "$pathname @fields\n";
+    my ($tag, $type, $val) = split " ", $line;
+    if ($tag eq "name") {
+        $file_name = $val;
+    } elsif ($tag eq "bytes") {
+        $bytes = $val;
+    } elsif ($tag eq "md5sum") {
+        $md5sum = $val;
+    } else {
+        my_die("unexpected tag: $tag  found in results file: $results_file", $PS_EXIT_PROG_ERROR);
     }
+}
 
-    $num++;
-    $filename = "${rownum}_${num}_$filename";
-    my $dest_path = "$out_dir/$filename";
-    if (! copy $pathname, "$dest_path" ) {
-        die("failed trying to copy $pathname to $out_dir");
-    }
+my $reglist = "$out_dir/reglist$job_id";
+if (! open(REGLIST, ">$reglist") ) {
+    my_die("failed to open registration list: $reglist", $PS_EXIT_UNKNOWN_ERROR);
+}
 
-    # XXX is pstamp always the right file type, if not where can we get the right one?
-    print REGLIST file_registration_line($filename, $dest_path, $filetype, $class_id);
-
-    foreach my $f (@fields) {
-        print REGLIST "$f|";
-    }
-    print REGLIST "\n";
-}
+print REGLIST "$file_name|$bytes|$md5sum|tgz|\n";
 
 close(REGLIST);
@@ -134,40 +150,9 @@
 exit 0;
 
-sub resolvepath {
-    my $pathname = $_[0];
+sub my_die {
+    my $msg = shift;
+    my $rc = shift;
 
-    # use the basename of the unresolved file as the name of the file
-    # in order to avoid nebulous name mangled paths in the datastore
-    my $file = basename($pathname);
-
-    my $slash = index($pathname, "/");
-    if ($slash != 0) {
-        if (!$ipprc) {
-            $ipprc = PS::IPP::Config->new();
-        }
-        $pathname = $ipprc->file_resolve($pathname);
-    }
-
-
-    return ($pathname, $file);
+    print STDERR $msg;
+    exit $rc ? $rc : $PS_EXIT_UNKNOWN_ERROR;
 }
-
-# XXX move this to a module so the code can be shared 
-sub file_registration_line {
-    my $filename = shift;
-    my $path     = shift;
-    my $filetype = shift;
-    my $chipname = shift;
-    $chipname = $chipname ? "$chipname|" : "";
-
-    if (-e $path) {
-        my @finfo = stat($path);
-        die "failed to stat $path" unless (@finfo);    # XXX clean up
-        my $bytes = $finfo[7];
-        my $md5sum = file_md5_hex($path);
-
-        return "$filename|$bytes|$md5sum|$filetype|$chipname";
-    } else {
-        die "$filename not found at $path";
-    }
-}
Index: branches/eam_branches/20091113/pstamp/scripts/pstamp_job_run.pl
===================================================================
--- branches/eam_branches/20091113/pstamp/scripts/pstamp_job_run.pl	(revision 26235)
+++ branches/eam_branches/20091113/pstamp/scripts/pstamp_job_run.pl	(revision 26236)
@@ -148,10 +148,10 @@
     }
 } elsif ($jobType eq "get_image") {
-    my_die( "get_image jobs not working right now", $job_id, $PS_EXIT_PROG_ERROR);
 
     my $uri = "";
-    my $command = "$pstamp_get_image_job --job_id $job_id --uri $uri --out_dir $outputBase --rownum $rownum";
+    my $command = "$pstamp_get_image_job --job_id $job_id --output_base $outputBase --rownum $rownum";
     $command .= " --dbname $dbname" if $dbname;
     $command .= " --dbserver $dbserver" if $dbserver;
+    $command .= " --verbose" if $verbose;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
Index: branches/eam_branches/20091113/pstamp/scripts/pstamp_parser_run.pl
===================================================================
--- branches/eam_branches/20091113/pstamp/scripts/pstamp_parser_run.pl	(revision 26235)
+++ branches/eam_branches/20091113/pstamp/scripts/pstamp_parser_run.pl	(revision 26236)
@@ -13,4 +13,5 @@
 use Getopt::Long qw( GetOptions );
 use File::Basename qw( basename dirname);
+use File::Copy;
 use POSIX qw( strftime );
 use Carp;
@@ -119,6 +120,6 @@
         unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR);
     }
-    if (! symlink $uri, $new_uri) {
-        my_die ("failed to link request file $uri to workdir $workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);
+    if (! copy $uri, $new_uri) {
+        my_die ("failed to copy request file $uri to workdir $workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);
     }
 }
Index: branches/eam_branches/20091113/pstamp/scripts/pstampparse.pl
===================================================================
--- branches/eam_branches/20091113/pstamp/scripts/pstampparse.pl	(revision 26235)
+++ branches/eam_branches/20091113/pstamp/scripts/pstampparse.pl	(revision 26236)
@@ -98,6 +98,6 @@
 
 # make sure the file contains what we are expecting
-
-# we shouldn't get here if this is the case so just die. No need to notify the client
+# This program shouldn't have been run if the request file is bogus.
+# No need to notify the client
 my_die("$request_file_name is not a PS1_PS_REQEST", $PS_EXIT_PROG_ERROR) if $extname ne "PS1_PS_REQUEST";
 my_die("REQ_NAME not found in $request_file_name", $PS_EXIT_PROG_ERROR)  if (!$req_name);
@@ -165,8 +165,7 @@
     # XXX: TODO: sanity check all parameters
 
-    # XXX: TODO: We shouldn't really just die in this loop.
-    # If we encounter an error for a particular row
-    # add a job with the proper fault code. If there is a db or config error we should probably just
-    # trash the request.
+    # If we encounter an error for a particular row add a job with the proper fault code.
+    # If we encounter an error in this loop we shouldn't really just die.
+    # We only do that now in the case of I/O or DB errors or the like.
 
     my $rownum   = $row->{ROWNUM};
@@ -236,10 +235,9 @@
     }
 
-    # collect rows with the same images of interest in a list so that they
-    # can be looked up together
+    # For "stamp" and "list_uri" jobs collect rows with the same images of interest in a list so that they
+    # can be looked up together.
     if (@rowList) {
         my $firstRow = $rowList[0];
-        # note order of these parameters matters
-        if (same_images_of_interest($firstRow, $row)) {
+        if (($firstRow->{JOB_TYPE} ne "get_image") and same_images_of_interest($firstRow, $row)) {
 
             # add this row to the list and move on
@@ -305,4 +303,5 @@
     my $have_skycells = shift;
     my $need_magic = shift;
+    my $mode = shift;
 
     my $num_jobs = 0;
@@ -395,4 +394,6 @@
         print ARGSLIST "$args\n";
         close ARGSLIST or my_die("failed to close $argslist", $PS_EXIT_UNKNOWN_ERROR);
+
+        write_params($output_base, $image);
 
         my $newState = "run";
@@ -476,9 +477,10 @@
         }
     } elsif ($job_type eq "get_image") {
-        print STDERR "get_image jobs not implemented yet" if $verbose;
-        foreach my $row (@$rowList) {
-            insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
-            $num_jobs++;
-        }
+        my $n = scalar @$rowList;
+
+        my_die( "error: unexpected number of rows for get_image request: $n", $PS_EXIT_PROG_ERROR) if $n != 1;
+
+        $num_jobs = queueGetImageJobs($firstRow, $imageList, $stage, $need_magic, $mode);
+
     } else {
         if (!$imageList or (scalar @$imageList eq 0)) {
@@ -582,7 +584,121 @@
             
             foreach my $row (@$rowList) {
-                $num_jobs += queueJobsForRow($row, $stage, $thisRun, $have_skycells, $need_magic);
+                $num_jobs += queueJobsForRow($row, $stage, $thisRun, $have_skycells, $need_magic, $mode);
             }
         }
+    }
+    return $num_jobs;
+}
+
+#        $num_jobs = queueGetImageJobs($firstRow, $imageList, $stage, $need_magic, $mode);
+sub queueGetImageJobs
+{
+    my $row = shift;
+    my $imageList = shift;
+    my $stage = shift;
+    my $need_magic = shift;
+    my $mode = shift;
+
+    my $num_jobs = 0;
+    my $rownum = $row->{ROWNUM};
+    my $option_mask = $row->{OPTION_MASK};
+
+    # For dist_bundle we need
+    #  --camera from $image
+    #  --stage 
+    #  --stage_id from $image
+    #  --component from $image
+    #  --path_base 
+    #  --outdir global to this script
+
+    # loop over images
+    my $job_num = 0;
+    foreach my $image (@$imageList) {
+        my $stage_id = $image->{stage_id};
+        my $component = $image->{component};
+
+        # skip faulted components for now. Should we even be here?
+        if ($image->{fault} > 0) {
+            printf STDERR "skipping faulted component for $stage $stage_id $component\n" if $verbose;
+            next;
+        }
+
+        $job_num++;
+
+        my $imagefile = $image->{image};
+        if (($stage ne "stack") and ($need_magic and !$image->{magicked})) {
+            # we only get here if req_type is (byid or byexp). For other types the test for magicked is performed
+            # in locate_images because it's much more efficient to do the test in the database.
+            # For these two modes we fall through to here in order to give feedback to the requestor as
+            # to why the request failed to queue jobs.
+            print STDERR "skipping non-magicked image $imagefile\n" if $verbose;
+            insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED);
+            $num_jobs++;
+
+            next;
+        }
+        my $exp_id = $image->{exp_id};
+            
+        my $output_base = "$out_dir/${rownum}_${job_num}";
+
+        write_params($output_base, $image);
+
+        my $newState = "run";
+        my $fault = 0;
+        my $dep_id;
+
+        if ($stage ne 'raw') {
+            my $run_state = $image->{state};
+            my $data_state = $image->{data_state};
+            $data_state = $run_state if $stage eq "stack";
+            if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or
+                ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) {
+                # image is gone and it's not coming back
+                $newState = 'stop';
+                $fault = $PSTAMP_GONE;
+            } elsif (($data_state ne 'full') or ($run_state ne 'full' )) {
+                # don't wait for update unless the caller asks us to
+                if (!($option_mask & $PSTAMP_WAIT_FOR_UPDATE)) {
+                    $newState = 'stop';
+                    $fault = $PSTAMP_NOT_AVAILABLE;
+                } else {
+                    # cause the image to be re-made
+                    # set up to queue an update run
+                    queue_update_run(\$newState, \$fault, \$dep_id, $image->{image_db}, 
+                        $run_state, $stage, $image->{stage_id}, $need_magic, $image->{label});
+                }
+            }
+        }
+
+        $num_jobs++;
+        my $command = "$pstamptool -addjob  -req_id $req_id -job_type $row->{JOB_TYPE}"
+                        . " -outputBase $output_base -rownum $rownum -state $newState -options $option_mask";
+        $command .= " -fault $fault" if $fault;
+        $command .= " -exp_id $exp_id" if $exp_id;
+        $command .= " -dep_id $dep_id" if $dep_id;
+
+        if ($mode eq "list_job") { 
+            # this is a debugging mode, just print the pstamptool that would have run
+            # this is sort of like the mode -noupdate that some other tools support
+            print "$command\n";
+        } elsif (!$no_update) {
+            # mode eq "queue_job"
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                run(command => $command, verbose => $verbose);
+            unless ($success) {
+                print STDERR @$stderr_buf;
+                # XXX TODO: now what? Should we mark the error state for the request?
+                # should we keep going for other uris? If so how do we report that some
+                # of the work that the request wanted isn't going to get done
+                my_die("failed to queue job for request $req_id", $PS_EXIT_UNKNOWN_ERROR);
+            }
+        } else {
+            print "skipping command: $command\n";
+        }
+    }
+    if ( $num_jobs == 0 ) {
+        print STDERR "no jobs for row $rownum\n" if $verbose;
+        insertFakeJobForRow($row, 1, $PSTAMP_NO_JOBS_QUEUED);
+        $num_jobs = 1;
     }
     return $num_jobs;
@@ -677,11 +793,11 @@
     return 0 if ($r1->{REQ_TYPE} ne $r2->{REQ_TYPE});
     return 0 if ($r1->{IMG_TYPE} ne $r2->{IMG_TYPE});
-    return 0 if ($r1->{ID} ne $r2->{ID});
-    return 0 if ($r1->{TESS_ID} ne $r2->{TESS_ID});
-    return 0 if ($r1->{REQFILT} ne $r2->{REQFILT});
-    return 0 if ($r1->{LABEL} ne $r2->{LABEL});
-    return 0 if ($r1->{MJD_MIN} ne $r2->{MJD_MAX});
-    return 0 if ($r1->{MJD_MAX} ne $r2->{MJD_MAX});
-    return 0 if ($r1->{inverse} ne $r2->{inverse});
+    return 0 if ($r1->{ID}       ne $r2->{ID});
+    return 0 if ($r1->{TESS_ID}  ne $r2->{TESS_ID});
+    return 0 if ($r1->{REQFILT}  ne $r2->{REQFILT});
+    return 0 if ($r1->{LABEL}    ne $r2->{LABEL});
+    return 0 if ($r1->{MJD_MIN}  ne $r2->{MJD_MAX});
+    return 0 if ($r1->{MJD_MAX}  ne $r2->{MJD_MAX});
+    return 0 if ($r1->{inverse}  ne $r2->{inverse});
 
     if (defined($r1->{COMPONENT})) {
@@ -759,4 +875,29 @@
 }
 
+sub write_params {
+    my $output_base = shift;
+    my $image = shift;
+
+    # write the contents of this "image" as a metadata config doc
+    # Simply treat all values as strings. This is ok since we are only going to
+    # read it from another perl script
+    my $mdc_file = "${output_base}.mdc";
+    open P, ">$mdc_file" or my_die("failed to open $mdc_file", $PS_EXIT_UNKNOWN_ERROR);
+
+    print P "params METADATA\n";
+
+    foreach my $key (keys %$image) {
+        my $value = $image->{$key};
+        if (defined $value) {
+            printf P "  %-20s STR     %s\n", $key, $value;
+        } else {
+            printf P "  %-20s STR     NULL\n", $key;
+        }
+    }
+
+    print P "END\n";
+    close P or my_die("failed to close $mdc_file", $PS_EXIT_UNKNOWN_ERROR);
+}
+
 sub my_die
 {
Index: branches/eam_branches/20091113/pstamp/src/pstampdump.c
===================================================================
--- branches/eam_branches/20091113/pstamp/src/pstampdump.c	(revision 26235)
+++ branches/eam_branches/20091113/pstamp/src/pstampdump.c	(revision 26236)
@@ -131,5 +131,5 @@
         }
         if (!simple) {
-            printf("ROW_%d METADATA\n", i);
+            printf("ROW_%d METADATA\n", i+1);
             printf("%s", str);
             printf("END\n");
Index: branches/eam_branches/20091113/pstamp/test/byskycell.txt
===================================================================
--- branches/eam_branches/20091113/pstamp/test/byskycell.txt	(revision 26235)
+++ branches/eam_branches/20091113/pstamp/test/byskycell.txt	(revision 26236)
@@ -1,5 +1,4 @@
 # Sample Postage stamp request description file
-# This can be parsed by the program pstamp_req_create to build a 
-# PS1_PSTAMP_REQUEST binary table
+# This can be parsed by the program pstamp_request_file to build a PS1_PSTAMP_REQUEST binary table
 
 # First line of data is for the extension header
@@ -7,5 +6,5 @@
 #
 # Note that value for REQ_NAME may be overriden by a command line
-# argument to pstamp_req_create.
+# argument to pstamp_request_create.
 # Blank and comment lines are ignored
 
Index: branches/eam_branches/20091113/pstamp/test/getimage.txt
===================================================================
--- branches/eam_branches/20091113/pstamp/test/getimage.txt	(revision 26236)
+++ branches/eam_branches/20091113/pstamp/test/getimage.txt	(revision 26236)
@@ -0,0 +1,27 @@
+# Sample Postage stamp request description file
+# This can be parsed by the program pstamp_request_file to build a PS1_PSTAMP_REQUEST binary table
+
+# First line of data is for the extension header
+# The order of keywords follows TABLE 6 of ICD
+#
+# Note that value for REQ_NAME may be overriden by a command line
+# argument to pstamp_request_create.
+# Blank and comment lines are ignored
+
+# REQ_NAME      EXTVER
+byskycell_test     1
+
+# subsequent lines define the rows in the table
+
+# If ROWNUM is set to zero, pstamp_request_file will set insert a value for each row beginning with 1
+# If a later input row reuses one of the automatically assigned values an error is reported.
+
+
+# ID    |     ROI Specification                   |  JOB Specification | Images of interest specification
+# ROWNUM CENTER_X         CENTER_Y         WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE    ID   TESS_ID COMPONENT    LABEL     REQFILT MJD_MIN MJD_MAX | COMMENT
+#
+# various looks at the location of SN candidate PS1-0905001
+#1       243.035580     55.128140          250   250      2        get_image       7        gpc1    byid     chip  20272         null   null  MD08.200905.v1   null    0      0    |
+2       243.035580     55.128140          250   250      2        get_image       3        gpc1    byid     warp  6323          null   skycell.078  MD08.200905.v1   null    0      0    |
+#3       243.035580     55.128140          250   250      2        get_image       3        gpc1    byid     diff  16880         null   null  MD08.200905.v1   null    0      0    |
+
Index: branches/eam_branches/20091113/pstamp/test/ps1-0811001.txt
===================================================================
--- branches/eam_branches/20091113/pstamp/test/ps1-0811001.txt	(revision 26236)
+++ branches/eam_branches/20091113/pstamp/test/ps1-0811001.txt	(revision 26236)
@@ -0,0 +1,26 @@
+# Sample Postage stamp request description file
+# This can be parsed by the program pstamp_request_file to build a PS1_PSTAMP_REQUEST binary table
+
+# First line of data is for the extension header
+# The order of keywords follows TABLE 6 of ICD
+#
+# Note that value for REQ_NAME may be overriden by a command line
+# argument to pstamp_request_create.
+# Blank and comment lines are ignored
+
+# REQ_NAME      EXTVER
+byskycell_test     1
+
+# subsequent lines define the rows in the table
+
+# If ROWNUM is set to zero, pstamp_request_file will set insert a value for each row beginning with 1
+# If a later input row reuses a value an error is preported
+
+# ID    |     ROI Specification                   |  JOB Specification | Images of interest specification
+# ROWNUM CENTER_X         CENTER_Y         WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE    ID   TESS_ID COMPONENT    LABEL  REQFILT MJD_MIN MJD_MAX | COMMENT
+#
+0         36.945000     -4.579750          250   250      2        stamp       1        gpc1    byskycell warp     null   MD01   skycell.069  null   g.00000    0      0    | PS1-0811001 g 
+0         36.945000     -4.579750          250   250      2        stamp       1        gpc1    byskycell warp     null   MD01   skycell.069  null   r.00000    0      0    | PS1-0811001 r
+0         36.945000     -4.579750          250   250      2        stamp       1        gpc1    byskycell warp     null   MD01   skycell.069  null   i.00000    0      0    | PS1-0811001 i
+0         36.945000     -4.579750          250   250      2        stamp       1        gpc1    byskycell warp     null   MD01   skycell.069  null   z.00000    0      0    | PS1-0811001 z
+0         36.945000     -4.579750          250   250      2        stamp       1        gpc1    byskycell warp     null   MD01   skycell.069  null   z.00000    0      0    | PS1-0811001 y
Index: branches/eam_branches/20091113/pstamp/test/ps1-0905001-all.txt
===================================================================
--- branches/eam_branches/20091113/pstamp/test/ps1-0905001-all.txt	(revision 26236)
+++ branches/eam_branches/20091113/pstamp/test/ps1-0905001-all.txt	(revision 26236)
@@ -0,0 +1,49 @@
+# Sample Postage stamp request description file
+# This can be parsed by the program pstamp_request_file to build a PS1_PSTAMP_REQUEST binary table
+
+# First line of data is for the extension header
+# The order of keywords follows TABLE 6 of ICD
+#
+# Note that value for REQ_NAME may be overriden by a command line
+# argument to pstamp_request_create.
+# Blank and comment lines are ignored
+
+# REQ_NAME      EXTVER
+byskycell_test     1
+
+# subsequent lines define the rows in the table
+
+# If ROWNUM is set to zero, pstamp_request_file will set insert a value for each row beginning with 1
+# If a later input row reuses one of the automatically assigned values an error is reported.
+
+
+# ID    |     ROI Specification                   |  JOB Specification | Images of interest specification
+# ROWNUM CENTER_X         CENTER_Y         WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE    ID   TESS_ID COMPONENT    LABEL     REQFILT MJD_MIN MJD_MAX | COMMENT
+#
+# various looks at the location of SN candidate PS1-0905001
+1         243.035580     55.128140          250   250      2        stamp       7        gpc1    byid     raw   70853         null   null       null        null    0      0    |PS1-0905001 r
+2         243.035580     55.128140          250   250      2        stamp       7        gpc1    byid     chip  20272         null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+
+# 3 and 4 will fail because the weight images was damaged by the destreaking
+# process
+3         243.035580     55.128140          250   250      2        stamp       7        gpc1    byid     warp  6323          null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+4         243.035580     55.128140          250   250      2        stamp       7        gpc1    byid     diff  16880         null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+# these will work
+103       243.035580     55.128140          250   250      2        stamp       3        gpc1    byid     warp  6323          null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+104       243.035580     55.128140          250   250      2        stamp       3        gpc1    byid     diff  16880         null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+
+5         243.035580     55.128140          250   250      2        stamp       7        gpc1    byid     stack 14032         null   null  null             null    0      0    |PS1-0905001 r
+
+6         243.035580     55.128140          250   250      2        stamp       1        gpc1    byexp    raw   o4973g0133o   null   null       null        null    0      0    |PS1-0905001 r
+7         243.035580     55.128140          250   250      2        stamp       1        gpc1    byexp    chip  o4973g0133o   null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+8         243.035580     55.128140          250   250      2        stamp       1        gpc1    byexp    warp  o4973g0133o   null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+9         243.035580     55.128140          250   250      2        stamp       1        gpc1    byexp    diff  o4973g0133o   null   null  MD08.200905.v1   null    0      0    |PS1-0905001 r
+
+
+# this should find warp 6323 givin the time cuts
+10        243.035580     55.128140          250   250      2        stamp       1        gpc1    bycoord  warp  null          null   null  MD08.200905.v1   null  54973.53543 54973.5368 |PS1-0905001 r
+
+11        243.035580     55.128140          250   250      2        stamp       1        gpc1    bydiff   chip  194350        null   null      null         null    0      0    |PS1-0905001 r
+12        243.035580     55.128140          250   250      2        stamp       1        gpc1    bydiff   warp  194350        null   null      null         null    0      0    |PS1-0905001 r
+13        243.035580     55.128140          250   250      2        stamp       1        gpc1    bydiff   diff  194350        null   null      null         null    0      0    |PS1-0905001 r
+
Index: branches/eam_branches/20091113/pstamp/test/ps1-0905001-diff.txt
===================================================================
--- branches/eam_branches/20091113/pstamp/test/ps1-0905001-diff.txt	(revision 26236)
+++ branches/eam_branches/20091113/pstamp/test/ps1-0905001-diff.txt	(revision 26236)
@@ -0,0 +1,22 @@
+# Sample Postage stamp request description file
+# This can be parsed by the program pstamp_request_file to build a PS1_PSTAMP_REQUEST binary table
+
+# First line of data is for the extension header
+# The order of keywords follows TABLE 6 of ICD
+#
+# Note that value for REQ_NAME may be overriden by a command line
+# argument to pstamp_request_create.
+# Blank and comment lines are ignored
+
+# REQ_NAME      EXTVER
+byskycell_test     1
+
+# subsequent lines define the rows in the table
+
+# If ROWNUM is set to zero, pstamp_request_file will set insert a value for each row beginning with 1
+# If a later input row reuses a value an error is preported
+
+# ID    |     ROI Specification                   |  JOB Specification | Images of interest specification
+# ROWNUM CENTER_X         CENTER_Y         WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE    ID   TESS_ID COMPONENT    LABEL  REQFILT MJD_MIN MJD_MAX | COMMENT
+#
+1         243.035580     55.128140          250   250      2        stamp       1        gpc1    byskycell diff     null   MD08   skycell.078  null   r.00000  54972    55000 | PS1-0905001 r
Index: branches/eam_branches/20091113/pstamp/test/ps1-0905001-warp.txt
===================================================================
--- branches/eam_branches/20091113/pstamp/test/ps1-0905001-warp.txt	(revision 26236)
+++ branches/eam_branches/20091113/pstamp/test/ps1-0905001-warp.txt	(revision 26236)
@@ -0,0 +1,26 @@
+# Sample Postage stamp request description file
+# This can be parsed by the program pstamp_request_file to build a PS1_PSTAMP_REQUEST binary table
+
+# First line of data is for the extension header
+# The order of keywords follows TABLE 6 of ICD
+#
+# Note that value for REQ_NAME may be overriden by a command line
+# argument to pstamp_request_create.
+# Blank and comment lines are ignored
+
+# REQ_NAME      EXTVER
+byskycell_test     1
+
+# subsequent lines define the rows in the table
+
+# If ROWNUM is set to zero, pstamp_request_file will set insert a value for each row beginning with 1
+# If a later input row reuses a value an error is preported
+
+# ID    |     ROI Specification                   |  JOB Specification | Images of interest specification
+# ROWNUM CENTER_X         CENTER_Y         WIDTH HEIGHT COORD_MASK JOB_TYPE OPTION_MASK PROJECT REQ_TYPE IMG_TYPE    ID   TESS_ID COMPONENT    LABEL  REQFILT MJD_MIN MJD_MAX | COMMENT
+#
+0         243.035580     55.128140          250   250      2        stamp       1        gpc1    byskycell warp     null   MD08   skycell.078  null   g.00000    0      0    | PS1-0905001 g 
+0         243.035580     55.128140          250   250      2        stamp       1        gpc1    byskycell warp     null   MD08   skycell.078  null   r.00000    0      0    | PS1-0905001 r
+0         243.035580     55.128140          250   250      2        stamp       1        gpc1    byskycell warp     null   MD08   skycell.078  null   i.00000    0      0    | PS1-0905001 i
+0         243.035580     55.128140          250   250      2        stamp       1        gpc1    byskycell warp     null   MD08   skycell.078  null   z.00000    0      0    | PS1-0905001 z
+0         243.035580     55.128140          250   250      2        stamp       1        gpc1    byskycell warp     null   MD08   skycell.078  null   z.00000    0      0    | PS1-0905001 y
