Index: trunk/pois/src/poisParseConfig.c
===================================================================
--- trunk/pois/src/poisParseConfig.c	(revision 3805)
+++ trunk/pois/src/poisParseConfig.c	(revision 5717)
@@ -4,8 +4,8 @@
 #include "pois.h"
 
-static void help(void)
+void help(void)
 {
     fprintf (stderr, "POIS: Pan-STARRS (or Pricey's) Optimal Image Subtraction\n"
-	     "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b BAD] [-B BG] [-o N] [-n NSTAMPS] [-i ITER] [-r REJ] REF IN OUT\n"
+	     "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b B1 B2] [-B BG] [-o N] [-n NSTAMPS] [-S STAMPS] [-i ITER] [-r REJ] [-m] REF IN OUT\n"
 	     "where\n"
 	     "\t-h         Help (this info)\n"
@@ -14,10 +14,13 @@
 	     "\t-t T       Threshold for stamps on reference image (0)\n"
 	     "\t-s S1 S2   Saturation level for reference (S1) and input (S2) (50000)\n"
-	     "\t-b BAD     Bad level for both images (0)\n"
+	     "\t-b B1 B2   Bad level for both images (0)\n"
 	     "\t-B BG      Level to add to background to get above zero (0)\n"
 	     "\t-o ORDER   Order of spatial variations in the kernel (0)\n"
 	     "\t-n NSTAMPS Number of stamps in each dimension (5)\n"
+	     "\t-S STAMPS  File from which to read stamps\n"
+	     "\t-R         Reverse the sense of the subtraction (REF - IN)\n"
 	     "\t-i ITER    Number of rejection iterations (10)\n"
 	     "\t-r REJ     Rejection level in standard deviations (2.5)\n"
+	     "\t-m         Output mask frame (OUT.mask)\n"
 	     "\tREF        Reference image\n"
 	     "\tIN         Input image (to be matched to REF)\n"
@@ -26,7 +29,17 @@
 }
 
-poisConfig *restrict poisConfigAlloc(void)
+poisConfig *poisParseConfig(int argc, // Number of command-line arguments
+			    char **argv // Command-line arguments
+    )
 {
-    poisConfig *config = (poisConfig *) psAlloc(sizeof(poisConfig));
+    poisConfig *config;			// Configuration values
+
+    /* Variables for getopt */
+    int opt;   /* Option, from getopt */
+    extern char *optarg;   /* Argument accompanying switch */
+    extern int optind;   /* getopt variables */
+
+    /* Initialise configuration */
+    config = (poisConfig *) psAlloc(sizeof(poisConfig));
     config->verbose = 0;
     config->refFile = NULL;
@@ -39,5 +52,6 @@
     config->refSat = 60000.0;
     config->inSat = 60000.0;
-    config->bad = 0.0;
+    config->refBad = 0.0;
+    config->inBad = 0.0;
     config->background = 0.0;
     config->spatialOrder = 0;
@@ -47,24 +61,10 @@
     config->sigmaRej = 2.5;
     config->penalty = 0.0;
-
-    return config;
-}
-
-
-poisConfig *poisParseConfig(int argc, // Number of command-line arguments
-			    char **argv // Command-line arguments
-    )
-{
-    poisConfig *config  = poisConfigAlloc(); // Configuration values
-
-    /* Variables for getopt */
-    int opt;   /* Option, from getopt */
-    extern char *optarg;   /* Argument accompanying switch */
-    extern int optind;   /* getopt variables */
-
-    /* Initialise configuration */
+    config->stampFile = NULL;
+    config->reverse = false;
+    config->mask = false;
 
     /* Parse command-line arguments using getopt */
-    while ((opt = getopt(argc, argv, "hvk:f:q:t:s:o:b:B:n:i:r:p:")) != -1) {
+    while ((opt = getopt(argc, argv, "hvRmk:f:q:t:s:o:b:B:n:i:r:p:S:")) != -1) {
         switch (opt) {
 	  case 'h':
@@ -115,8 +115,13 @@
 	    break;
 	  case 'b':
-	    if (sscanf(optarg, "%f", &config->bad) != 1) {
-		help();
+            if ((sscanf(argv[optind-1], "%f", &config->refBad) != 1) ||
+                (sscanf(argv[optind++], "%f", &config->inBad) != 1)) {
+                /*
+                  Note: incrementing optind, so I can read more than
+                  one parameter.
+                */
+                help();
                 exit(EXIT_FAILURE);
-	    }
+            }
 	    break;
 	  case 'B':
@@ -151,4 +156,14 @@
             }
 	    break;
+	  case 'S':
+	    config->stampFile = argv[optind-1];
+	    config->threshold = -INFINITY;
+	    break;
+	  case 'R':
+	    config->reverse = true;
+	    break;
+	  case 'm':
+            config->mask = true;
+            break;
 	  default:
 	    help();
