// Image load callback - inserts the probes. void ImgLoad(IMG img, void *v) { // Called every time a new image is loaded if ( (IMG_Name(img).find("libncurses.so") != string::npos) || (IMG_Name(img).find("LIBNCURSES.SO") != string::npos) || (IMG_Name(img).find("LIBNCURSES.so") != string::npos) ) { RTN rtngetch = RTN_FindByName(img, "getch"); if (RTN_Valid(rtngetch) && RTN_IsSafeForProbedReplacement(rtngetch)) { OutFile << CurrentTime() << "Inserting probe for getch at " << RTN_Address(rtngetch) << endl; OutFile.flush(); AFUNPTR fptr = (RTN_ReplaceProbed(rtngetch, AFUNPTR(mygetch))); fptrgetch = (int (*)())fptr; } RTN rtnmvgetch = RTN_FindByName(img, "mvgetch"); if (RTN_Valid(rtnmvgetch) && RTN_IsSafeForProbedReplacement(rtnmvgetch)) { OutFile << CurrentTime() << "Inserting probe for mvgetch at " << RTN_Address(rtnmvgetch) << endl; OutFile.flush(); AFUNPTR fptr = (RTN_ReplaceProbed(rtnmvgetch, AFUNPTR(mymvgetch))); fptrmvgetch = (int (*)(int, int))fptr; } } // finished instrumentation }
int main(int argc, char const *argv[]) { char texto[200],nombre[200]; double start, end,seconds; start=CurrentTime(); char *t1,*t2,*t3; char *resp; int i; system("clear"); FILE *archivo1=NULL,*archivo2=NULL; resp=strstr( argv[2], ".txt" ); if(resp==NULL){ error(3); } if(argc==3&&strcmp(argv[1],"-FILE")==0){ if((archivo1=fopen(argv[2],"r"))==NULL){ error(1); } do{ fscanf(archivo1,"%[^\n\r]\n|\r",texto); t1=strtok(texto,"\t"); t2=strtok(NULL,"\t"); sprintf(nombre, "./MainHaus -FILES %s %s",t1,t2); printf("%s-%s\n", t1,t2); for (i = 0; i < 31; ++i) { system(nombre); anilizaerror(); } t3=strtok(t1,"."); sprintf(nombre, "%s",t3); t3 = strtok(t2,"."); sprintf(nombre, "%s_%s.out",nombre,t3); if((archivo2=fopen(nombre,"r"))==NULL){ error(1); } for (i = 0; i <31; ++i) { fscanf(archivo2,"%[^\n]\n",texto); vector[i]=atof(strtok(texto,"\t")); } calculo(); guardar_archivo(); printf("\n"); }while(!feof(archivo1)); fclose(archivo1); }else{error(2);} end=CurrentTime(); seconds=(end-start); printf("Segundos: %.5f\tReloj de computadora:%.10f\n",seconds,seconds/(double)CLOCKS_PER_SEC); return 0; }
TEST_F(TestDownloader, WaitShouldWait) { const std::string data(CHUNK_SIZE, '$'); FakeSource src(data, CHUNK_DELAY, CHUNK_NUMBER); Queue q; Downloader dl(src, q); ptime t1(CurrentTime()); dl.Start(); dl.Wait(); ptime t2(CurrentTime()); ASSERT_GE(t2, t1 + millisec(CHUNK_DELAY * CHUNK_NUMBER) ); }
/* ** A "local" function of KeepState(). Enters #name# marked with #seqNo# into ** the state file (global) #journalPath#. Used to keep a log of all writes ** performed by the memory. Returns 1 if successful, else 0. */ static int EnterInJournal(const char *name, double seqNo) { char journalRec[MAX_RECORD_SIZE]; double now; memset(journalRec, 0, sizeof(journalRec)); now = CurrentTime(); if(sprintf(journalRec,"%10.0f %64s", seqNo, name) < 2) { FAIL1("EnterInJournal: write failed, errno %d\n", errno); } if(!WriteState(journalPath, journalFileSize, KEEP_A_LONG_TIME, now, journalRec, strlen(journalRec))) { FAIL("EnterInJournal: write state failed\n"); } return(1); }
/* ** A "local" function of ProcessRequest(). Searches through the registration ** file for unexpired objects that match #filter#. Returns a malloc'ed string ** of the matching objects. */ static char * DoSearch(const char *filter) { unsigned long expiration; char expirationImage[15 + 1]; unsigned long now; const char *object; const char *registration; char *returnValue; now = (unsigned long)CurrentTime(); returnValue = strdup(""); for(rewind(registrationFile); (registration = ReadRegistration()) != NULL;) { (void)GETWORD(expirationImage, registration, &object); expiration = atol(expirationImage); if((expiration == ETERNAL) || (expiration > now)) { object++; /* Skip space after expiration. */ if(MatchFilter(object, filter)) { returnValue = REALLOC(returnValue, strlen(returnValue) + strlen(object) + 1); strcat(returnValue, object); } } } return returnValue; }
/* ** A "local" function of ProcessRequest(). Implements the MEMORY_CLEAN service ** by deleting all files in the memory directory that have not been accessed ** within the past #idle# seconds. Returns 1 if successful, else 0. */ static int DoClean(unsigned long idle) { struct dirent *entry; DIR *directory; time_t expiration; char filePath[255 + 1]; struct stat fileStat; char *namePlace; directory = opendir(memoryDir); if(directory == NULL) { FAIL1("DoClean: unable to open directory %s\n", memoryDir); } expiration = (time_t)CurrentTime() - (time_t)idle; SAFESTRCPY(filePath, memoryDir); namePlace = filePath + strlen(filePath); while((entry = readdir(directory)) != NULL) { strcpy(namePlace, entry->d_name); if(stat(filePath, &fileStat) != 0) { WARN1("DoClean: unable to state file %s\n", filePath); } else if(fileStat.st_mtime < expiration) { LOG2("DoClean: deleting %s, last modified %d\n", filePath, fileStat.st_mtime); (void)unlink(filePath); } } (void)closedir(directory); return(1); }
/* ** A "local" function of main(). Deletes from the registration file all ** objects that have an expiration time which has already passed. */ static void CompressRegistrations(void) { size_t bytesCompressed = 0; unsigned long expiration; char expirationImage[15 + 1]; const char *ignored; unsigned long now; size_t recordLen; const char *registration; now = (unsigned long)CurrentTime(); for(rewind(registrationFile); (registration = ReadRegistration()) != NULL;) { (void)GETWORD(expirationImage, registration, &ignored); expiration = atol(expirationImage); recordLen = strlen(registration) + 1; if((expiration != ETERNAL) && (expiration <= now)) { bytesCompressed += recordLen; } else if(bytesCompressed > 0) { /* Move this record forward to the end of the still-current objects. */ fseek(registrationFile, -(recordLen + bytesCompressed), SEEK_CUR); fprintf(registrationFile, "%s\n", registration); fseek(registrationFile, bytesCompressed, SEEK_CUR); } } /* Truncate any records that we've moved. */ if(bytesCompressed > 0) { fseek(registrationFile, -bytesCompressed, SEEK_CUR); ftruncate(fileno(registrationFile), ftell(registrationFile)); } }
//Construct Response Header char *constructHeader(char* FilePath) { FILE *fp; fp=fopen(FilePath+1,"r"); if(fp==NULL) return NULL; else { char *header =malloc(sizeof(char)*BUF_SIZE); memset(header,0,sizeof(char)*BUF_SIZE); strcpy(header,"HTTP/1.1 200 OK\nConnection: close\nDate: "); char *time = CurrentTime(); strcat(header,time); strcat(header,"Last-Modified: "); char *modtime = LastModified(FilePath); strcat(header,modtime); strcat(header,"Content-Length: "); int leng = Length(FilePath); char len[32]; sprintf(len,"%d",leng); strcat(header,len); strcat(header,"\nContent-Type: "); char *type = FileType(FilePath); strcat(header,type); strcat(header,"\r\n\r\n"); return header; free(header); } fclose(fp); }
struct IntuiMessage *alloc_intuimessage(struct Window *w, struct IntuitionBase *IntuitionBase) { struct IntuiMessage *imsg; imsg = AllocIntuiMessage(w); if (imsg) { if (w) { if (w->IDCMPFlags & IDCMP_DELTAMOVE) { struct IIHData *iihd = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; imsg->MouseX = iihd->DeltaMouseX; imsg->MouseY = iihd->DeltaMouseY; } else { imsg->MouseX = w->MouseX; imsg->MouseY = w->MouseY; } } CurrentTime(&imsg->Seconds, &imsg->Micros); } return imsg; }
//This function reset timer according to first PCB in timer queue int ResetTimer(){ MEMORY_MAPPED_IO mmio; //for hardware interface int SleepTime; //when timer queue is not empty if (timerQueue->Element_Number > 0){ //calculate sleep time SleepTime = timerQueue->First_Element->PCB->WakeUpTime - CurrentTime(); //set timer only if it's positive if (SleepTime > 0){ mmio.Mode = Z502Start; mmio.Field1 = SleepTime; // You pick the time units mmio.Field2 = mmio.Field3 = 0; MEM_WRITE(Z502Timer, &mmio); //if success, return 1 return 1; } else{ //if sleep time is negative, return 0 return 0; } } else{ //if timer queue empty, return -1 return -1; } }
PeerInterface::PeerInterface(const PeerID & peer_id, Uint32 num_chunks) : peer_id(peer_id),pieces(num_chunks) { stats.interested = false; stats.am_interested = false; stats.choked = true; stats.interested = false; stats.am_interested = false; stats.download_rate = 0; stats.upload_rate = 0; stats.perc_of_file = 0; stats.snubbed = false; stats.dht_support = false; stats.fast_extensions = false; stats.extension_protocol = false; stats.bytes_downloaded = stats.bytes_uploaded = 0; stats.aca_score = 0.0; stats.has_upload_slot = false; stats.num_up_requests = stats.num_down_requests = 0; stats.encrypted = false; stats.local = false; stats.max_request_queue = 0; stats.time_choked = CurrentTime(); stats.time_unchoked = 0; stats.partial_seed = false; killed = false; paused = false; }
// returns false if there were no timers bool TIMEOUT::CheckTimers(LARGE_INTEGER& ret) { LARGE_INTEGER now = CurrentTime(); TIMEOUT *t; if (!g_Timeouts.Head()) return false; ret.QuadPart = 0LL; while (1) { t = g_Timeouts.Head(); if (!t) return true; if (t->Expires.QuadPart > now.QuadPart) break; t->DoTimeout(); } // calculate the timeout ret.QuadPart = t->Expires.QuadPart - now.QuadPart; return true; }
status_t TAPEReader::GetNextChunk(void* oCookie, const void** oChunkBuffer, size_t* oChunkSize, media_header* oMediaHeader) { int64 aOutSize; // check whether song is finished or not if (mReadPosTotal - mReadPos + mPlayPos >= mDataSize) return B_ERROR; // reading data if (mPlayPos >= mReadPos ) ReadBlocks(); // passing data if (mReadPos-mPlayPos >= BUFFER_SIZE) aOutSize = BUFFER_SIZE; else aOutSize = mReadPos-mPlayPos; *oChunkBuffer = &mDecodedData[mPlayPos]; mPlayPos += aOutSize; // passing info *oChunkSize = aOutSize; oMediaHeader->start_time = CurrentTime(); oMediaHeader->file_pos = mPlayPos; return B_OK; }
void Logger::fillFileBuffer(std::string &outputBuffer, const std::string &tag, const std::string &msg, const char *funcName, const char *sourceFile, unsigned int lineNum) { // Old format if (!isHTML) { if (!tag.empty()) outputBuffer = "[" + tag + "] "; else outputBuffer = "[NOTAG] "; if (sourceFile != NULL) { outputBuffer += sourceFile; outputBuffer += " "; } if (funcName != NULL && lineNum != 0) { outputBuffer += funcName; outputBuffer += ":"; // Convert int to char outputBuffer += std::to_string(lineNum); } outputBuffer += ": "; outputBuffer += msg; outputBuffer += "\n"; } else { outputBuffer = "<tr>"; if (!tag.empty()) outputBuffer += "<td>" + tag + "</td>"; else outputBuffer = "<td>NOTAG</td>"; outputBuffer += "<td>" + CurrentTime() + "</td>"; if (sourceFile != NULL) { outputBuffer += "<td>"; outputBuffer += sourceFile; outputBuffer += "</td>"; } if (funcName != NULL && lineNum != 0) { outputBuffer += "<td>"; outputBuffer += funcName; outputBuffer += ":"; // Convert int to char outputBuffer += std::to_string(lineNum); outputBuffer += "</td>"; } outputBuffer += "<td>"; outputBuffer += msg; outputBuffer += "</td></tr>"; } }
NTSTATUS LpxTdiIoCallDriver( IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp, IN PIO_STATUS_BLOCK IoStatusBlock, IN PKEVENT Event, IN PLARGE_INTEGER TimeOut ) { NTSTATUS ntStatus; NTSTATUS wait_status; // LARGE_INTEGER timeout; // // set a expire time to IRP. // LPX takes whole charge of IRP completion. // LPX will measure time-out. // Do not wait with time-out here. // BSOD may occur if you do. // // added by hootch 02092004 if(TimeOut) SET_IRP_EXPTIME(Irp, CurrentTime().QuadPart + TimeOut->QuadPart); else SET_IRP_EXPTIME(Irp, 0); Irp->Tail.Overlay.DriverContext[2] = (PVOID)0; LtDebugPrint(2, ("[LpxTdi] Irp->Tail.Overlay.DriverContext[2] == %p\n", Irp->Tail.Overlay.DriverContext[2])); ntStatus = IoCallDriver( DeviceObject, Irp ); if(ntStatus == STATUS_PENDING) { if(Event) { wait_status = KeWaitForSingleObject( Event, Executive, KernelMode, FALSE, NULL ); if(wait_status != STATUS_SUCCESS) { LtDebugPrint(1, ("[LpxTdi] LpxTdiIoCallDriver: Wait for event Failed.\n")); return STATUS_CONNECTION_DISCONNECTED; // STATUS_TIMEOUT; } } else { return ntStatus; } } ntStatus = IoStatusBlock->Status; return ntStatus; }
//------------------------------------------------------------------- // TempFileName::GenerateRandomName //------------------------------------------------------------------- String TempFileName::GenerateRandomName() { if( !s_lLastNumber ) // Initialize random sequence s_lLastNumber = CurrentTime().long_unix(); return String::str_format("temp%lx", s_lLastNumber++); }
BOOL WINAPI myCryptHashData(HCRYPTHASH hHash, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags) { FILE *fd = fopen("C:\\CryptoBlock32.txt", "a"); std::string mytime = CurrentTime(); fprintf(fd, "%s myCryptHashData(%x,%p,%x,%x)\n", mytime.c_str(), hHash, pbData, dwDataLen, dwFlags); fclose(fd); return Real_CryptHashData(hHash, pbData, dwDataLen, dwFlags); }
BOOL WINAPI myCryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash) { FILE *fd = fopen("C:\\CryptoBlock32.txt", "a"); std::string mytime = CurrentTime(); fprintf(fd, "%s myCryptCreateHash(%x,%x,%x,%x,%p)\n", mytime.c_str(), hProv, Algid, hKey, dwFlags, phHash); fclose(fd); return Real_CryptCreateHash(hProv, Algid, hKey,dwFlags, phHash); }
int mymq_close(mqd_t __mqdes) { OutFile << CurrentTime() << "mymq_close called " << endl; OutFile.flush(); int res = fptrmq_close(__mqdes); return res; }
int mymq_send(mqd_t __mqdes, const CHAR_PTR __msg_ptr, size_t __msg_len, unsigned __msg_prio) { OutFile << CurrentTime() << "mymq_send called " << endl; OutFile.flush(); int res = fptrmq_send(__mqdes, __msg_ptr, __msg_len, __msg_prio); return res; }
ssize_t mymq_timedreceive(mqd_t __mqdes, CHAR_PTR __msg_ptr, size_t __msg_len, UNSIGNED_PTR __msg_prio, const STRUCT_TIMESPEC_PTR __abs_timeout) { OutFile << CurrentTime() << "mymq_timedreceive called " << endl; OutFile.flush(); ssize_t res = fptrmq_timedreceive( __mqdes, __msg_ptr, __msg_len, __msg_prio, __abs_timeout); return res; }
ssize_t mymq_receive(mqd_t __mqdes, CHAR_PTR __msg_ptr, size_t __msg_len, UNSIGNED_PTR __msg_prio) { OutFile << CurrentTime() << "mymq_receive called " << endl; OutFile.flush(); ssize_t res = fptrmq_receive( __mqdes, __msg_ptr, __msg_len, __msg_prio); return res; }
mqd_t mymq_open(const CHAR_PTR __name, int __oflag) { OutFile << CurrentTime() << "mymq_open called " << endl; OutFile.flush(); mqd_t res = fptrmq_open(__name, __oflag); return res; }
int mygetch(void) { OutFile << CurrentTime() << "mygetch called " << endl; OutFile.flush(); int res = fptrgetch(); return res; }
int mymvgetch(int y, int x) { OutFile << CurrentTime() << "mymvgetch called " << endl; OutFile.flush(); int res = fptrmvgetch(y, x); return res; }
BOOL WINAPI myCryptDecrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen) { FILE *fd = fopen("C:\\CryptoBlock32.txt", "a"); std::string mytime = CurrentTime(); fprintf(fd, "%s myCryptDecrypt(%x,%x,%x,%x,%p,%p)\n", mytime.c_str(), hKey, hHash, Final, dwFlags, pbData, pdwDataLen); fclose(fd); return Real_CryptDecrypt(hKey, hHash, Final, dwFlags, pbData, pdwDataLen); }
BOOL WINAPI myCryptAcquireContext(HCRYPTPROV *phProv, LPCTSTR pszContainer, LPCTSTR pszProvider, DWORD dwProvType, DWORD dwFlags) { FILE *fd = fopen("C:\\CryptoBlock32.txt", "a"); std::string mytime = CurrentTime(); fprintf(fd, "%s myCryptAcquireContext(%p,%s,%s,%x,%x)\n", mytime.c_str(), phProv, pszContainer, pszProvider, dwProvType, dwFlags); fclose(fd); return Real_CryptAcquireContext(phProv, pszContainer, pszProvider, dwProvType, dwFlags); }
int myclock_nanosleep(clockid_t __clock_id, int __flags, const STRUCT_TIMESPEC_PTR __rqtp, STRUCT_TIMESPEC_PTR __rmtp) { OutFile << CurrentTime() << "myclock_nanosleep called " << endl; OutFile.flush(); int res = fptrclock_nanosleep(__clock_id, __flags, __rqtp, __rmtp); return res; }
int mymq_timedsend(mqd_t __mqdes, const CHAR_PTR __msg_ptr, size_t __msg_len, unsigned __msg_prio, const STRUCT_TIMESPEC_PTR __abs_timeout) { OutFile << CurrentTime() << "mymq_timedsend called " << endl; OutFile.flush(); int res = fptrmq_timedsend(__mqdes, __msg_ptr, __msg_len, __msg_prio, __abs_timeout); return res; }
void MusicPlayer::UpdateDuration(qint64 time) { int duration=this->duration/1000; QTime TotalTime((duration/3600)%60, (duration/60)%60, duration%60, (duration*1000)%1000); QTime CurrentTime((time/3600)%60, (time/60)%60, time%60, (time*1000)%1000); QString temp = CurrentTime.toString("mm:ss") + " / " + TotalTime.toString("mm:ss"); ui->duration_label->setText(temp); }