Changeset 39602 for trunk/Ohana/src/opihi/dvo/catname.c
- Timestamp:
- Jun 17, 2016, 5:00:44 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/catname.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/catname.c
r39457 r39602 1 1 # include "dvoshell.h" 2 int gcat_listnames (SkyList *skylist, HostTable *table, int ShowFile, int ShowHost, int ShowBackup, int ShowFlags, int ShowCoords, int ShowID); 2 3 3 4 int catname (int argc, char **argv) { 4 5 5 int i, N; 6 struct stat filestat; 6 int N; 7 7 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 } 8 23 int ShowHost = FALSE; 9 24 if ((N = get_argument (argc, argv, "-host"))) { … … 16 31 ShowBackup = TRUE; 17 32 } 18 int FullName = FALSE;19 if ((N = get_argument (argc, argv, "-full-name"))) {20 remove_argument (N, &argc, argv);21 FullName = TRUE;22 }23 33 int ShowFlags = FALSE; 24 34 if ((N = get_argument (argc, argv, "-flags"))) { … … 26 36 ShowFlags = TRUE; 27 37 } 28 int PARALLEL = FALSE;29 if ((N = get_argument (argc, argv, "-parallel"))) {30 remove_argument (N, &argc, argv);31 PARALLEL = TRUE;32 }33 38 34 39 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"); 36 41 return (FALSE); 37 42 } 38 43 44 /* load sky from correct table */ 39 45 char *CATDIR = GetCATDIR(); 40 46 if (!CATDIR) { … … 47 53 return FALSE; 48 54 } 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 54 64 SkyList *skylist = SkyListByName (sky, argv[1]); 55 65 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); 101 68 102 69 return (TRUE); 103 SkyListFree (skylist);104 70 }
Note:
See TracChangeset
for help on using the changeset viewer.
