double WorkingCaptureDataBase::GetDeltaT(const double& testTime) { if ((*currCapturedData)[0].IsEmpty()) lastMetricTime = testTime; UnitIndex timeConv(uTime); (*currCapturedData)[0] += timeConv.MetricToUser(testTime); double deltaT = testTime - lastMetricTime; lastMetricTime = testTime; return deltaT; }
int main(int ac, char **av) { int flags = 0; int uflag = 0; int aflag = 0; uint16 spoolObj = (uint16)-1; char *historyFileName = NULL; LoadDiabloConfig(ac, av); FileAry = calloc(sizeof(char *), FileMax); { int i; for (i = 1; i < ac; ++i) { char *ptr = av[i]; if (*ptr != '-') { if (FileIdx == FileMax) { FileMax = FileMax * 2; FileAry = realloc(FileAry, sizeof(char *) * FileMax); } FileAry[FileIdx++] = ptr; continue; } ptr += 2; switch(ptr[-1]) { case 'a': aflag = 1; break; case 'C': if (*ptr == 0) ++i; break; case 'd': DebugOpt = (*ptr) ? strtol(ptr, NULL, 0) : strtol(av[++i], NULL, 0); break; case 'e': UnExpireOpt = 1; break; case 'F': historyFileName = (*ptr) ? ptr : av[++i]; break; case 'f': flags |= HGF_FAST | HGF_NOSEARCH; break; case 'h': NewHSize = bsizetol((*ptr) ? ptr : av[++i]); if ((NewHSize ^ (NewHSize - 1)) != (NewHSize << 1) - 1) { fprintf(stderr, "specified history size is not a power of 2\n"); exit(1); } break; case 'n': ForReal = 0; break; case 'Q': RequeueOpt = 1; break; case 'q': QuietOpt = 1; break; case 'S': spoolObj = (*ptr) ? strtol(ptr, NULL, 10) : strtol(av[++i], NULL, 10); break; case 't': if (*ptr == 'b') { ptr++; GmtStart = timeConv(*ptr ? ptr : av[++i]); } else if (*ptr == 'e') { ptr++; GmtEnd = timeConv(*ptr ? ptr : av[++i]); } else { fprintf(stderr, "Invalid option: %s\n", &ptr[-2]); Usage(); } break; case 'u': uflag = 1; break; case 'V': PrintVersion(); break; case 'v': VerboseOpt = (*ptr) ? strtol(ptr, NULL, 0) : 1; break; default: Usage(); } } } if (!UnExpireOpt && !aflag && FileIdx == 0 && spoolObj == (uint16)-1) Usage(); if (flags & HGF_FAST || UnExpireOpt) { struct stat st; if (historyFileName == NULL) { fprintf(stderr, "You cannot run fastmode/unexpire without specifying a filename!\n"); exit(1); } if (stat(historyFileName, &st) == 0 && uflag == 0) { fprintf(stderr, "-f history files may not previously exist unless you also specify -u\n"); fprintf(stderr, "WARNING! -f -u is NOT suggested!\n"); exit(1); } if (uflag) flags &= ~HGF_NOSEARCH; } if (VerboseOpt) { if (GmtStart != 0 && GmtEnd != 0) printf("Scanning directories from D.%08x to D.%08x\n", GmtStart, GmtEnd); else if (GmtStart == 0 && GmtEnd != 0) printf("Scanning directories from earliest to D.%08x\n", GmtEnd); else if (GmtStart != 0 && GmtEnd == 0) printf("Scanning directories from D.%08x to latest\n", GmtStart); } if (UnExpireOpt) { hisfd = open(historyFileName, O_RDWR); if (hisfd == -1) { fprintf(stderr, "Unable to open history (%s): %s\n", historyFileName, strerror(errno)); exit(1); } } LoadSpoolCtl(0, 1); if (RequeueOpt) { ForReal = 0; QuietOpt = 1; } else { /* * historyFileName can be NULL and causes the default dhistory path * to be used. */ HistoryOpen(historyFileName, flags); } { int i; for (i = 0; i < FileIdx; ++i) { struct stat st; if (VerboseOpt > 1) printf("Check: %s\n", FileAry[i]); if (stat(FileAry[i], &st) == 0) { if (S_ISDIR(st.st_mode)) { int gmt; if (sscanf(FileAry[i], "D.%x", &gmt) == 1) { ScanSpoolDirectory(FileAry[i], gmt, spoolObj); } else { fprintf(stderr, "Illegal path format for dir: %s\n", FileAry[i]); } } else { int gmt; int iter; if (sscanf(FileAry[i], "D.%x/B.%x", &gmt, &iter) == 2) { ScanSpoolFile(FileAry[i], gmt, iter, spoolObj); } else { fprintf(stderr, "Illegal path format for file: %s\n", FileAry[i]); } } } else { printf("Unable to stat: %s (%s)\n", FileAry[i], strerror(errno)); } } } if (aflag || spoolObj != (uint16)-1) { ScanSpoolObject(spoolObj); } printf("diload: %d/%d entries loaded (%d duplicate)\n", LoadCount, LoadCount + LoadDupCount, LoadDupCount); if (!RequeueOpt) { int r = HistoryClose(); if (r == RCOK) return(0); else return(1); } return(0); /* not reached */ }