Index: trunk/Ohana/src/opihi/dvo/catname.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/catname.c	(revision 39457)
+++ trunk/Ohana/src/opihi/dvo/catname.c	(revision 39602)
@@ -1,9 +1,24 @@
 # include "dvoshell.h"
+int gcat_listnames (SkyList *skylist, HostTable *table, int ShowFile, int ShowHost, int ShowBackup, int ShowFlags, int ShowCoords, int ShowID);
 
 int catname (int argc, char **argv) {
   
-  int i, N;
-  struct stat filestat;
+  int N;
 
+  int ShowCoords = FALSE;
+  if ((N = get_argument (argc, argv, "-coords"))) {
+    remove_argument (N, &argc, argv);
+    ShowCoords = TRUE;
+  }
+  int ShowID = FALSE;
+  if ((N = get_argument (argc, argv, "-catid"))) {
+    remove_argument (N, &argc, argv);
+    ShowID = TRUE;
+  }
+  int ShowFile = FALSE;
+  if ((N = get_argument (argc, argv, "-file"))) {
+    remove_argument (N, &argc, argv);
+    ShowFile = TRUE;
+  }
   int ShowHost = FALSE;
   if ((N = get_argument (argc, argv, "-host"))) {
@@ -16,9 +31,4 @@
     ShowBackup = TRUE;
   }
-  int FullName = FALSE;
-  if ((N = get_argument (argc, argv, "-full-name"))) {
-    remove_argument (N, &argc, argv);
-    FullName = TRUE;
-  }
   int ShowFlags = FALSE;
   if ((N = get_argument (argc, argv, "-flags"))) {
@@ -26,15 +36,11 @@
     ShowFlags = TRUE;
   }
-  int PARALLEL = FALSE;
-  if ((N = get_argument (argc, argv, "-parallel"))) {
-    remove_argument (N, &argc, argv);
-    PARALLEL = TRUE;
-  }
 
   if (argc != 2) {
-    gprint (GP_ERR, "USAGE: catname name [-host] [-backup] [-flags]\n");
+    gprint (GP_ERR, "USAGE: catname name [-host] [-backup] [-flags] [-file] [-coords] [-catid]\n");
     return (FALSE);
   }
 
+  /* load sky from correct table */
   char *CATDIR = GetCATDIR();
   if (!CATDIR) {
@@ -47,58 +53,18 @@
     return FALSE;
   }
-  HostTable *table = HostTableLoad (CATDIR, sky->hosts);
-  if (!table) {
-    gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
-    return FALSE;
-  }    
+  HostTable *table = NULL;  
+  if (HostTableExists (CATDIR, sky->hosts)) {
+    table = HostTableLoad (CATDIR, sky->hosts);
+    if (!table) {
+      gprint (GP_ERR, "ERROR: failure reading Host Table %s for parallel database %s\n", sky->hosts, CATDIR);
+      return FALSE;
+    }    
+  }
+
   SkyList *skylist = SkyListByName (sky, argv[1]);
 
-  // prepare to handle interrupt signals
-  struct sigaction *old_sigaction = SetInterrupt();
-
-  for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
-    char *filename = NULL;
-    if (PARALLEL) {
-      SkyRegion *region = skylist[0].regions[i];
-      int hostID = (region->hostFlags & DATA_USE_BCK) ? region->backupID : region->hostID;
-      int index = table->index[hostID];
-    
-      char hostfile[1024];
-      snprintf (hostfile, 1024, "%s/%s.cpt", table->hosts[index].pathname, region->name);
-      filename = hostfile;
-    } else {
-      filename = skylist[0].filename[i];
-    }
-
-    gprint (GP_ERR, "%3d %s", i, skylist[0].regions[i][0].name);
-    if (stat (filename, &filestat) != -1) {
-      gprint (GP_ERR, " +");
-    } else {
-      gprint (GP_ERR, " -");
-    } 
-    if (ShowHost) {
-      gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].hostID);
-    } else {
-      gprint (GP_ERR, "     ");
-    }
-    if (FullName) {
-      gprint (GP_ERR, "  %s", filename);
-    }
-    if (ShowBackup) {
-      gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].backupID);
-    } else {
-      gprint (GP_ERR, "     ");
-    }
-    if (ShowFlags) {
-      gprint (GP_ERR, "  0x%04x", skylist[0].regions[i][0].hostFlags);
-    } else {
-      gprint (GP_ERR, "        ");
-    }
-    gprint (GP_ERR, "\n");
-    set_str_variable ("CATNAME", filename);
-  }
-  ClearInterrupt (old_sigaction);
+  gcat_listnames (skylist, table, ShowFile, ShowHost, ShowBackup, ShowFlags, ShowCoords, ShowID);
+  SkyListFree (skylist);
 
   return (TRUE);
-  SkyListFree (skylist);
 }
