bool FormatParaProperty::operator== (FormatParaProperty &rhs) { DWord numDataBytes; if ((numDataBytes = getNumDataBytes ()) != rhs.getNumDataBytes ()) return false; writeToArray (); rhs.writeToArray (); return memcmp (m_data + sizeof (m_numDataBytes), rhs.m_data + sizeof (m_numDataBytes), numDataBytes) == 0; }
/* This function will parse the input from the trace file and call the proper function @param char* line - a line that will be parsed @return void */ void parseLine (char * line){ fprintf(stdout, "%s\n", line); char* token = strtok(line, " "); if (token == NULL){ return; } char * endPtr; // Read Command: READ LBA SIZE if (strcmp(token, "READ") == 0){ //Get the lba token = strtok(NULL, " "); if (token == NULL){ errorMsgParse(); } int lba = strtol(token, &endPtr, 10); if (token == endPtr) { errorMsgParse(); } //Get the size of the read token = strtok(NULL, " "); if (token == NULL){ errorMsgParse(); } int readSize = strtol(token, &endPtr, 10); if (token == endPtr) { errorMsgParse(); } if (token == NULL){ errorMsgParse(); } //The command should end here token = strtok(NULL, " "); if (token != NULL){ errorMsgParse(); } readFromArray(lba,readSize); } // Write command: WRITE LBA SIZE VALUE else if (strcmp(token, "WRITE") == 0){ //Get the lba token = strtok(NULL, " "); if (token == NULL){ errorMsgParse(); } int lba = strtol(token, &endPtr, 10); if (token == endPtr) { errorMsgParse(14); } //Get the size of the write token = strtok(NULL, " "); if (token == NULL){ errorMsgParse(); } int writeSize = strtol(token, &endPtr, 10); if (token == endPtr) { errorMsgParse(); } //Get the value to write token = strtok(NULL, " "); if (token == NULL){ errorMsgParse(); } int value = atoi(token); char buff[BLOCK_SIZE]; int i; for(i = 0; i < 256; i++){ ((int *)buff)[i] = value; } //The command should end here token = strtok(NULL, " "); if (token != NULL){ errorMsgParse(); } writeToArray(lba, writeSize, buff); } //Fail command: FAIL DISK# else if (strcmp(token, "FAIL") == 0){ //Get the disk that failed token = strtok(NULL, " "); if (token == NULL){ errorMsgParse(); } int disk = strtol(token, &endPtr, 10); if (token == endPtr) { errorMsgParse(); } //The command should end here token = strtok(NULL, " "); if (token != NULL){ errorMsgParse(); } failDisk(disk); } //Recover command: RECOVER DISK# else if (strcmp(token, "RECOVER") == 0){ //Gert the disk to recover token = strtok(NULL, " "); if (token == NULL){ errorMsgParse(); } int disk = strtol(token, &endPtr, 10); if (token == endPtr) { errorMsgParse(); } //The command should end here token = strtok(NULL, " "); if (token != NULL){ errorMsgParse(); } recoverDisk(disk); } // End command: END else if (strcmp(token, "END") == 0){ //There should be no other arguments with end token = strtok(NULL, " "); if (token != NULL){ errorMsgParse(); } endProgram(); } else if (strcmp(token, "") == 0){ } else{ errorMsgParse(); } }