Index: /trunk/Ohana/src/imregister/detrend/args.detsearch.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/args.detsearch.c	(revision 8)
+++ /trunk/Ohana/src/imregister/detrend/args.detsearch.c	(revision 9)
@@ -160,4 +160,11 @@
     remove_argument (N, &argc, argv);
     base.LabelSelect = TRUE;
+  }
+  base.NameSelect = FALSE;
+  if (N = get_argument (argc, argv, "-name")) {
+    remove_argument (N, &argc, argv);
+    base.Name = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+    base.NameSelect = TRUE;
   }
 
Index: /trunk/Ohana/src/imregister/detrend/criteria.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/criteria.c	(revision 8)
+++ /trunk/Ohana/src/imregister/detrend/criteria.c	(revision 9)
@@ -21,4 +21,5 @@
     if (criteria[i].EntrySelect  && (image[0].Nentry          != criteria[i].Entry))  continue;
     if (criteria[i].LabelSelect  && (strcasecmp (image[0].label, criteria[i].Label))) continue;
+    if (criteria[i].NameSelect   && (strstr (image[0].filename, criteria[i].Name) == (char *) NULL)) continue;
 
     if (criteria[i].TimeSelect   && (image[0].tstart           > criteria[i].tstop))   continue;
Index: /trunk/Ohana/src/imregister/detrend/output.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/output.c	(revision 8)
+++ /trunk/Ohana/src/imregister/detrend/output.c	(revision 9)
@@ -49,5 +49,4 @@
 
 int DumpFitsTable (char *filename, DetReg *detdata, Match *match, int Nmatch) {
-# define NL 453
   
   Header header, theader;
@@ -56,5 +55,5 @@
   DetReg *newdata;
   FILE *f;
-  char *startstr, *stopstr, *regstr, line[NL], key[33];
+  char *startstr, *stopstr, *regstr, *line, key[33];
   char *filtstr, *typestr, *ccdstr, *datestr, *p;
   int i;
@@ -105,16 +104,16 @@
   fits_modify (&theader, "TNULL12", "%s", 1, "");
 
-  fits_modify (&theader, "TBNA1",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA2",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA3",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA4",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA5",  "%lf", 1, (float) -2);
-  fits_modify (&theader, "TBNA6",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA7",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA8",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA9",  "%d", 1, -2);
-  fits_modify (&theader, "TBNA10", "%d", 1, -2);
-  fits_modify (&theader, "TBNA11", "%s", 1, "NA");
-  fits_modify (&theader, "TBNA12", "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN1",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN2",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN3",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN4",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN5",  "%lf", 1, (float) -2);
+  fits_modify (&theader, "TBNAN6",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN7",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN8",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN9",  "%d", 1, -2);
+  fits_modify (&theader, "TBNAN10", "%d", 1, -2);
+  fits_modify (&theader, "TBNAN11", "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN12", "%s", 1, "NA");
 
   /* create table, add data values */
@@ -142,10 +141,12 @@
     filtstr  = filterhash[newdata[0].filter];
     ccdstr   = ccds[newdata[0].ccd];
-    snprintf (line, NL, "%32s%20s%20s%20s%7.1f%10s%10s%7s%3d%3d%64s%256s",
-	      key, startstr, stopstr, regstr, newdata[0].exptime,
-	      typestr, filtstr, ccdstr,
-	      newdata[0].Nentry, newdata[0].Norder, 
-	      newdata[0].label, newdata[0].filename);
+
+    line = fits_table_print (&table, key, startstr, stopstr, regstr, 
+			     newdata[0].exptime, typestr, filtstr, ccdstr,
+			     newdata[0].Nentry, newdata[0].Norder, 
+			     newdata[0].label, newdata[0].filename);
+
     fits_add_rows (&table, line, 1, strlen(line));
+    free (line);
     free (startstr);
     free (stopstr);
Index: /trunk/Ohana/src/imregister/include/detrend.h
===================================================================
--- /trunk/Ohana/src/imregister/include/detrend.h	(revision 8)
+++ /trunk/Ohana/src/imregister/include/detrend.h	(revision 9)
@@ -24,4 +24,5 @@
   int EntrySelect;   int Entry;
   int LabelSelect;   char *Label;
+  int NameSelect;    char *Name;
   int ExptimeSelect; float Exptime;
   int TimeSelect;    unsigned long tstart, tstop;
