int FileSystem::addInformationToFile() {//Обозначаем переменные string FileName; int InformationCount;//Кол-во добавляемой информации, int CountLength=8; int resultCode = 1; int lenCritical = 48; int CntCritical = 2 ^ 16; //int BlockNf, SegmNf, BlockNs, SegmNs; //Номер блока , номер сегмента FileDescriptor AddFile; FileDescriptor NextFile; //FileDescriptor LastFile; int ResultCount; int freeSpace; //кол-во свободных блоков перед следующим файлом int RecordNumber,NextRecordNumber; //Номер изменяемой записи, номер следующей записи int i; //Счетчик //Собствено функция cout << "Введите имя файла" << endl; cin >> FileName; if (getRecordNumber(FileName)==0)//Проверка ввода имени return(1); cout << "Введите кол-во добавляемой информации" << endl; cin >> InformationCount; InformationCount=InformationCount/512+1; AddFile = getRecord(FileName); if ((AddFile.descriptorType) == "0010000000000000") //!!!!!!!в дескрипторе число блоков сделал интом!!!!!! return(1); RecordNumber=getRecordNumber(FileName); NextRecordNumber=RecordNumber+1; NextFile=getRecord(NextRecordNumber); if ((toInt(AddFile.firstBlockNumber) + AddFile.blockCount + InformationCount) > (toInt(NextFile.firstBlockNumber))) { //LastFile=AddFile; //LastFile.blockCount+=InformationCount; AddFile.blockCount+=InformationCount; for(i=217;((getRecord(i).fileType)=="");i--) //LastFile.firstBlockNumber=toString((toInt(getRecord(i).firstBlockNumber)+getRecord(i).blockCount+1),8); AddFile.firstBlockNumber=toString((toInt(getRecord(i).firstBlockNumber)+getRecord(i).blockCount+1),8); deleteRecord(FileName); //writeRecord(LastFile); writeRecord(AddFile); resultCode=0; } else { AddFile.blockCount=(AddFile.blockCount+InformationCount); deleteRecord(FileName); writeRecord(AddFile,RecordNumber); resultCode=0; } return(resultCode); };
int ScripMasterDataRequest::serialize(char *buf) { int bytes = 0; UNSIGNED_INTEGER tmp = 0; UNSIGNED_SHORT tmpShort = 0; UNSIGNED_CHARACTER tmpChar = 0; UNSIGNED_LONG tmpLong = 0; bytes = sizeof(UNSIGNED_SHORT); // Leave 2 bytes for packet size // Put category of command SERIALIZE_8(tmpChar, (UNSIGNED_CHARACTER)(CMD::CommandCategory_SEND_SCRIP_MASTER_DATA), buf, bytes); //Command Category // Put fields of this class SERIALIZE_8(tmpChar, getScripMasterDataRequestType(), buf, bytes); SERIALIZE_32(tmp, getClientId(), buf, bytes); SERIALIZE_64(tmpLong, getRecordNumber(), buf, bytes); SERIALIZE_64(tmpLong, getSecurityId(), buf, bytes); SERIALIZE_64(tmpLong, getSymbolId(), buf, bytes); SERIALIZE_16(tmpShort, getExchangeId(), buf, bytes); memcpy(buf + bytes, getSymbol(), SYMBOL_SIZE); bytes += SYMBOL_SIZE; memcpy(buf + bytes, getSeries(), SERIES_SIZE); bytes += SERIES_SIZE; memcpy(buf + bytes, getMarketName(), SERIES_SIZE); bytes += MARKET_NAME_SIZE; SERIALIZE_8(tmpChar, getOptionType(), buf, bytes); SERIALIZE_8(tmpChar, getOptionMode(), buf, bytes); SERIALIZE_8(tmpChar, getSecurityType(), buf, bytes); SERIALIZE_64(tmpLong, getStrikePrice(), buf, bytes); SERIALIZE_32(tmp, getExpiryYearMon(), buf, bytes); SERIALIZE_32(tmp, getExpiryDate(), buf, bytes); SERIALIZE_32(tmp, getNumberOfRecords(), buf, bytes); memcpy(buf + bytes, getSymbolAlias(), SYMBOL_ALIAS_SIZE); bytes += SYMBOL_ALIAS_SIZE; UNSIGNED_SHORT dummyBytes = 0; // Put size as the first field after deducting 2 bytes reserved for size SERIALIZE_16(tmpShort, (UNSIGNED_SHORT)(bytes-sizeof(UNSIGNED_SHORT)), buf, dummyBytes); return bytes; }
void ScripMasterDataRequest::dump() { std::cout << "ScripMasterDataRequest dump : " << std::endl; std::cout << getScripMasterDataRequestType() << std::endl; std::cout << getClientId() << std::endl; std::cout << getRecordNumber() << std::endl; std::cout << getSecurityId() << std::endl; std::cout << getSymbolId() << std::endl; std::cout << getExchangeId() << std::endl; std::cout << getSymbol() << std::endl; std::cout << getSeries() << std::endl; std::cout << getMarketName() << std::endl; std::cout << getOptionType() << std::endl; std::cout << getOptionMode() << std::endl; std::cout << getSecurityType() << std::endl; std::cout << getStrikePrice() << std::endl; std::cout << getExpiryYearMon() << std::endl; std::cout << getExpiryDate() << std::endl; std::cout << getNumberOfRecords() << std::endl; std::cout << getSymbolAlias() << std::endl; std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" << std::endl; }