Index: /trunk/Ohana/src/imregister/imreg/ConfigPID.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/ConfigPID.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/ConfigPID.c	(revision 74)
@@ -1,3 +1,4 @@
-# include ".h"
+# include "imregister.h"
+# include "imreg.h"
 
 static char *PIDMaster = (char *) NULL;
@@ -77,2 +78,8 @@
   return (TRUE);
 }
+
+int Shutdown (int status) {
+
+  RemovePID ();
+  exit (status);
+}
Index: /trunk/Ohana/src/imregister/imreg/SetSignals.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/SetSignals.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/SetSignals.c	(revision 74)
@@ -1,3 +1,4 @@
-# include "controller.h"
+# include "imregister.h"
+# include "imreg.h"
 
 void SIG_DIE (int sig) {
@@ -109,5 +110,5 @@
   if (!LoadPID (pidfile, &pid, username, machine)) {
     fprintf (stderr, "imstatreg is not running\n");
-    exit (0);
+    exit (2);
   }
 
Index: /trunk/Ohana/src/imregister/imreg/args.imregister.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/args.imregister.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/args.imregister.c	(revision 74)
@@ -20,4 +20,10 @@
     remove_argument (N, &argc, argv);
     NoReg = TRUE;
+  }
+
+  NeedType = FALSE;
+  if (N = get_argument (argc, argv, "-needtype")) {
+    remove_argument (N, &argc, argv);
+    NeedType = TRUE;
   }
 
Index: /trunk/Ohana/src/imregister/imreg/args.imsearch.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/args.imsearch.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/args.imsearch.c	(revision 74)
@@ -29,11 +29,11 @@
   /* image type (dark, flat, bias, etc) */
   criteria.TypeSelect = FALSE;
-  criteria.Type = T_NONE;
+  criteria.Type = T_UNDEF;
   if (N = get_argument (argc, argv, "-type")) {
     remove_argument (N, &argc, argv);
-    for (i = 0; (i < NTYPE) && (criteria.Type == T_NONE); i++) {
+    for (i = 0; (i < NTYPE) && (criteria.Type == T_UNDEF); i++) {
       if (!strncasecmp (argv[N], typename[i], strlen(argv[N]))) criteria.Type = i;
     }
-    if (criteria.Type == T_NONE) {
+    if (criteria.Type == T_UNDEF) {
       fprintf (stderr, "ERROR: invalid image type %s\n", argv[N]);
       exit (1);
@@ -251,9 +251,9 @@
       output.modify_type = TRUE;
       remove_argument (N, &argc, argv);
-      output.type == T_NONE;
-      for (i = 0; (i < NTYPE) && (output.type == T_NONE); i++) {
+      output.type == T_UNDEF;
+      for (i = 0; (i < NTYPE) && (output.type == T_UNDEF); i++) {
 	if (!strncasecmp (argv[N], typename[i], strlen(argv[N]))) output.type = i;
       }
-      if (output.type == T_NONE) {
+      if (output.type == T_UNDEF) {
 	fprintf (stderr, "ERROR: invalid image type %s\n", argv[N]);
 	exit (1);
Index: /trunk/Ohana/src/imregister/imreg/iminfo.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/iminfo.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/iminfo.c	(revision 74)
@@ -36,5 +36,5 @@
   Naxes = 2; 
   extend = FALSE;
-  image[0].mode = MODE_SINGLE;
+  image[0].mode = M_SINGLE;
   image[0].flag = 0;
   image[0].ccd  = 0;
@@ -45,16 +45,16 @@
   if (extend) { /* MEF file */
     fits_scan (&header, "NEXTEND",  "%d", 1, &Nextend);
-    image[0].mode = MODE_MEF;
+    image[0].mode = M_MEF;
     image[0].ccd  = Nextend;
   } 
   if (Naxes == 3) { /* data cube */
     fits_scan (&header, "NAXIS3",  "%d", 1, &Nextend);
-    image[0].mode = MODE_CUBE;
+    image[0].mode = M_CUBE;
     image[0].ccd  = Nextend;
     dtime = (float *)&image[0].junk[0];
     fits_scan (&header, "SEQTIME", "%f", 1, dtime);
   }
-  if (SingleIsSplit && (image[0].mode == MODE_SINGLE)) {
-    image[0].mode = MODE_SPLIT;
+  if (SingleIsSplit && (image[0].mode == M_SINGLE)) {
+    image[0].mode = M_SPLIT;
     image[0].ccd  = MatchCCDNameHeader (&header);
   }
@@ -64,19 +64,23 @@
   fits_scan (&header, ImagetypeKeyword,  "%s", 1, &Imagetype);
 
-  image[0].type = TYPE_NONE;
+  image[0].type = T_NONE;
   if (!strcasecmp (Imagetype, "OBJECT")) {
-    image[0].type = TYPE_OBJECT;
+    image[0].type = T_OBJECT;
   }
   if (!strcasecmp (Imagetype, "DARK")) {
-    image[0].type = TYPE_DARK;
+    image[0].type = T_DARK;
   }
   if (!strcasecmp (Imagetype, "BIAS")) {
-    image[0].type = TYPE_BIAS;
+    image[0].type = T_BIAS;
   }
   if (!strcasecmp (Imagetype, "FLAT")) {
-    image[0].type = TYPE_FLAT;
+    image[0].type = T_FLAT;
   }
   if (!strcasecmp (Imagetype, "SKYFLAT")) {
-    image[0].type = TYPE_FLAT;
+    image[0].type = T_FLAT;
+  }
+  if (NeedType && (image[0].type == T_NONE)) {
+    fprintf (stderr, "ERROR: skipping unknown image type\n");
+    exit (1);
   }
 
Index: /trunk/Ohana/src/imregister/imreg/imregclient.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/imregclient.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/imregclient.c	(revision 74)
@@ -18,6 +18,6 @@
   /* get stats file (has sky, bias, etc) */
   switch (image[0].mode) {
-  case MODE_MEF:
-  case MODE_SPLIT:
+  case M_MEF:
+  case M_SPLIT:
     f = fopen (statfile, "r");
     if (f == (FILE *) NULL) {
@@ -30,5 +30,5 @@
     Nentry = 1;
     break;
-  case MODE_SINGLE:
+  case M_SINGLE:
     f = fopen (statfile, "r");
     if (f == (FILE *) NULL) {
@@ -40,5 +40,5 @@
     Nentry = 1;
     break;
-  case MODE_CUBE:
+  case M_CUBE:
     f = fopen (statfile, "r");
     if (f == (FILE *) NULL) {
Index: /trunk/Ohana/src/imregister/imreg/modify.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/modify.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/modify.c	(revision 74)
@@ -34,5 +34,5 @@
 
     if (output.mef2split) {
-      if (image[i].mode == MODE_MEF) {
+      if (image[i].mode == M_MEF) {
 	root = filerootname (image[i].filename);
 	ext = fileextname (image[i].filename);
@@ -41,5 +41,5 @@
 	snprintf (image[i].pathname, 128, "%s/%s", path, root);
 	snprintf (image[i].filename, 64,  "%s%02d.%s", root, image[i].ccd, ext);
-	image[i].mode = MODE_SPLIT;
+	image[i].mode = M_SPLIT;
 	free (root);
 	free (ext);
@@ -49,5 +49,5 @@
 
     if (output.split2mef) {
-      if (image[i].mode == MODE_SPLIT) {
+      if (image[i].mode == M_SPLIT) {
 	ext  = fileextname (image[i].filename);
 	root = filebasename (image[i].pathname);
@@ -56,5 +56,5 @@
 	snprintf (image[i].pathname, 128, "%s", path);
 	snprintf (image[i].filename, 64,  "%s.%s", root, ext);
-	image[i].mode = MODE_MEF;
+	image[i].mode = M_MEF;
 	free (root);
 	free (ext);
Index: /trunk/Ohana/src/imregister/imreg/output.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/output.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/output.c	(revision 74)
@@ -178,5 +178,5 @@
   char ccdstr[64];  
   int i, j;
-  char *pmode, *ptype, *timestr, *root, *path;
+  char *modestr, *typestr, *timestr, *root, *path;
 
   /* print the selected entries */
@@ -185,18 +185,7 @@
     i = match[j];
 
-    if ((image[i].mode < 0) || (image[i].mode >= NMODE)) 
-      pmode = modename[0];
-    else
-      pmode = modename[(int)image[i].mode];
-
-    if ((image[i].type < 0) || (image[i].type >= NTYPE)) 
-      ptype = typename[0];
-    else
-      ptype = typename[(int)image[i].type];
-
-    if (RegTimeMode) 
-      timestr = sec_to_date (image[i].regtime);
-    else
-      timestr = sec_to_date (image[i].obstime);
+    modestr = ((image[i].mode < 0) || (image[i].mode >= NMODE)) ? modename[0] : modename[(int)image[i].mode];
+    typestr = ((image[i].type < 0) || (image[i].type >= NTYPE)) ? typename[0] : typename[(int)image[i].type];
+    timestr = RegTimeMode ? sec_to_date (image[i].regtime) : sec_to_date (image[i].obstime);
 
     if (CCDSeq) {
@@ -214,19 +203,19 @@
 
       /* do i want ccdstr? add a dot? 654321o.ccd00.ext */
-      if (image[i].mode == MODE_MEF) {
-	fprintf (stdout, "%s/%s %s/%s%02d %s %s\n", image[i].pathname, image[i].filename, root, root, image[i].ccd, ccdstr, pmode);
-      }
-
-      if (image[i].mode == MODE_SPLIT) {
+      if (image[i].mode == M_MEF) {
+	fprintf (stdout, "%s/%s %s/%s%02d %s %s\n", image[i].pathname, image[i].filename, root, root, image[i].ccd, ccdstr, modestr);
+      }
+
+      if (image[i].mode == M_SPLIT) {
 	path = basename (image[i].pathname);
 	fprintf (stdout, "%s/%s %s/%s %s %s\n", image[i].pathname, image[i].filename, path, root, ccdstr, "SPLIT");
       }
 
-      if ((image[i].mode == MODE_SINGLE) || (image[i].mode == MODE_CUBE)) {
-	fprintf (stdout, "%s/%s %s 0 %s\n", image[i].pathname, image[i].filename, root, pmode);
+      if ((image[i].mode == M_SINGLE) || (image[i].mode == M_CUBE)) {
+	fprintf (stdout, "%s/%s %s 0 %s\n", image[i].pathname, image[i].filename, root, modestr);
       }
     } else {
       /* this is somewhat poor: I have predefined a subset of value, and I can't guarantee that 'filter' has no spaces */
-      fprintf (stdout, "%5d %6s %6s %s  ", i, ptype, pmode, ccdstr);
+      fprintf (stdout, "%5d %6s %6s %s  ", i, typestr, modestr, ccdstr);
       fprintf (stdout, "%s %s  ", image[i].pathname, image[i].filename);
       fprintf (stdout, "%s %f %s %f %f %f\n", image[i].filter, image[i].exptime, 
Index: /trunk/Ohana/src/imregister/imreg/submit.c
===================================================================
--- /trunk/Ohana/src/imregister/imreg/submit.c	(revision 73)
+++ /trunk/Ohana/src/imregister/imreg/submit.c	(revision 74)
@@ -17,10 +17,10 @@
   */
 
-  if (image[0].mode == MODE_MEF) {
+  if (image[0].mode == M_MEF) {
     for (i = 0; i < image[0].ccd; i++) {
       root = filerootname (image[0].filename);
       sprintf (line, "%s/%s %s/%s%s %s %s", image[0].pathname, image[0].filename, root, root, ccdn[i], ccds[i], "MEF");
       if (!WriteFIFO (ImstatFifo, line)) return (FALSE);
-      if (image[0].type == TYPE_OBJECT) {
+      if (image[0].type == T_OBJECT) {
 	if (!WriteFIFO (PtolemyFifo, line)) return (FALSE);
       }
@@ -28,28 +28,28 @@
   } 
 
-  if (image[0].mode == MODE_SINGLE) {
+  if (image[0].mode == M_SINGLE) {
     root = filerootname (image[0].filename);
     sprintf (line, "%s/%s %s %02d %s", image[0].pathname, image[0].filename, root, 0, "SINGLE");
     if (!WriteFIFO (ImstatFifo, line)) return (FALSE);
-    if (image[0].type == TYPE_OBJECT) {
+    if (image[0].type == T_OBJECT) {
       if (!WriteFIFO (PtolemyFifo, line)) return (FALSE);
     }
   } 
 
-  if (image[0].mode == MODE_CUBE) {
+  if (image[0].mode == M_CUBE) {
     root = filerootname (image[0].filename);
     sprintf (line, "%s/%s %s %02d %s", image[0].pathname, image[0].filename, root, 0, "CUBE");
     if (!WriteFIFO (ImstatFifo, line)) return (FALSE);
-    if (image[0].type == TYPE_OBJECT) {
+    if (image[0].type == T_OBJECT) {
       if (!WriteFIFO (PtolemyFifo, line)) return (FALSE);
     }
   } 
 
-  if (image[0].mode == MODE_SPLIT) {
+  if (image[0].mode == M_SPLIT) {
     path = basename (image[0].pathname);
     root = filerootname (image[0].filename);
     sprintf (line, "%s/%s %s/%s %02d %s", image[0].pathname, image[0].filename, path, root, image[0].ccd, "SPLIT");
     if (!WriteFIFO (ImstatFifo, line)) return (FALSE);
-    if (image[0].type == TYPE_OBJECT) {
+    if (image[0].type == T_OBJECT) {
       if (!WriteFIFO (PtolemyFifo, line)) return (FALSE);
     }
