IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 17, 2016, 5:00:44 PM (10 years ago)
Author:
eugene
Message:

mods for gcat, catname; add catid to get cpt info more easily

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/catname.c

    r39457 r39602  
    11# include "dvoshell.h"
     2int gcat_listnames (SkyList *skylist, HostTable *table, int ShowFile, int ShowHost, int ShowBackup, int ShowFlags, int ShowCoords, int ShowID);
    23
    34int catname (int argc, char **argv) {
    45 
    5   int i, N;
    6   struct stat filestat;
     6  int N;
    77
     8  int ShowCoords = FALSE;
     9  if ((N = get_argument (argc, argv, "-coords"))) {
     10    remove_argument (N, &argc, argv);
     11    ShowCoords = TRUE;
     12  }
     13  int ShowID = FALSE;
     14  if ((N = get_argument (argc, argv, "-catid"))) {
     15    remove_argument (N, &argc, argv);
     16    ShowID = TRUE;
     17  }
     18  int ShowFile = FALSE;
     19  if ((N = get_argument (argc, argv, "-file"))) {
     20    remove_argument (N, &argc, argv);
     21    ShowFile = TRUE;
     22  }
    823  int ShowHost = FALSE;
    924  if ((N = get_argument (argc, argv, "-host"))) {
     
    1631    ShowBackup = TRUE;
    1732  }
    18   int FullName = FALSE;
    19   if ((N = get_argument (argc, argv, "-full-name"))) {
    20     remove_argument (N, &argc, argv);
    21     FullName = TRUE;
    22   }
    2333  int ShowFlags = FALSE;
    2434  if ((N = get_argument (argc, argv, "-flags"))) {
     
    2636    ShowFlags = TRUE;
    2737  }
    28   int PARALLEL = FALSE;
    29   if ((N = get_argument (argc, argv, "-parallel"))) {
    30     remove_argument (N, &argc, argv);
    31     PARALLEL = TRUE;
    32   }
    3338
    3439  if (argc != 2) {
    35     gprint (GP_ERR, "USAGE: catname name [-host] [-backup] [-flags]\n");
     40    gprint (GP_ERR, "USAGE: catname name [-host] [-backup] [-flags] [-file] [-coords] [-catid]\n");
    3641    return (FALSE);
    3742  }
    3843
     44  /* load sky from correct table */
    3945  char *CATDIR = GetCATDIR();
    4046  if (!CATDIR) {
     
    4753    return FALSE;
    4854  }
    49   HostTable *table = HostTableLoad (CATDIR, sky->hosts);
    50   if (!table) {
    51     gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
    52     return FALSE;
    53   }   
     55  HostTable *table = NULL; 
     56  if (HostTableExists (CATDIR, sky->hosts)) {
     57    table = HostTableLoad (CATDIR, sky->hosts);
     58    if (!table) {
     59      gprint (GP_ERR, "ERROR: failure reading Host Table %s for parallel database %s\n", sky->hosts, CATDIR);
     60      return FALSE;
     61    }   
     62  }
     63
    5464  SkyList *skylist = SkyListByName (sky, argv[1]);
    5565
    56   // prepare to handle interrupt signals
    57   struct sigaction *old_sigaction = SetInterrupt();
    58 
    59   for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) {
    60     char *filename = NULL;
    61     if (PARALLEL) {
    62       SkyRegion *region = skylist[0].regions[i];
    63       int hostID = (region->hostFlags & DATA_USE_BCK) ? region->backupID : region->hostID;
    64       int index = table->index[hostID];
    65    
    66       char hostfile[1024];
    67       snprintf (hostfile, 1024, "%s/%s.cpt", table->hosts[index].pathname, region->name);
    68       filename = hostfile;
    69     } else {
    70       filename = skylist[0].filename[i];
    71     }
    72 
    73     gprint (GP_ERR, "%3d %s", i, skylist[0].regions[i][0].name);
    74     if (stat (filename, &filestat) != -1) {
    75       gprint (GP_ERR, " +");
    76     } else {
    77       gprint (GP_ERR, " -");
    78     }
    79     if (ShowHost) {
    80       gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].hostID);
    81     } else {
    82       gprint (GP_ERR, "     ");
    83     }
    84     if (FullName) {
    85       gprint (GP_ERR, "  %s", filename);
    86     }
    87     if (ShowBackup) {
    88       gprint (GP_ERR, "  %3d", skylist[0].regions[i][0].backupID);
    89     } else {
    90       gprint (GP_ERR, "     ");
    91     }
    92     if (ShowFlags) {
    93       gprint (GP_ERR, "  0x%04x", skylist[0].regions[i][0].hostFlags);
    94     } else {
    95       gprint (GP_ERR, "        ");
    96     }
    97     gprint (GP_ERR, "\n");
    98     set_str_variable ("CATNAME", filename);
    99   }
    100   ClearInterrupt (old_sigaction);
     66  gcat_listnames (skylist, table, ShowFile, ShowHost, ShowBackup, ShowFlags, ShowCoords, ShowID);
     67  SkyListFree (skylist);
    10168
    10269  return (TRUE);
    103   SkyListFree (skylist);
    10470}
Note: See TracChangeset for help on using the changeset viewer.