int main() { A a; auto aData = ExtractData(a);//aData -> int std::cout << typeid(aData).name() << std::endl; B b; auto bData = ExtractData(b);//bData -> float std::cout << typeid(bData).name() << std::endl; return 0; }
char* CNWNXResources::OnRequest(char *gameObject, char* Request, char* Parameters){ int nBehavior; char ResRef[20]; int nDataLen; void * vData = ExtractData( &nBehavior, ResRef, &nDataLen, (unsigned char*)Parameters ); NWRes * resE = AddToResTable( ResRef, nBehavior ); if( resE == NULL ){ strcpy( Parameters, "0 " ); return NULL; } switch( atoi( Request ) ){ case 0: break; case 1: break; case 2: break; case 3: break; case 4: resE->vPtr = nwnx_malloc( nDataLen+1 ); strcpy( (char*)resE->vPtr, (char*)vData ); resE->Data = nDataLen; break; default: break; } return NULL; }
void XaLibWs::Setup() { LOG.Write("INF",__FILE__,__FUNCTION__,__LINE__,"Ws Setup"); ReqType=HTTP.GetHttpParam("ReqType"); Encoding=HTTP.GetHttpParam("Encoding"); Encryption=HTTP.GetHttpParam("Encryption"); ConsumerId=HTTP.GetHttpParam("ConsumerId"); ResType=HTTP.GetHttpParam("ResType"); ResLang=HTTP.GetHttpParam("ResLang"); Data=HTTP.GetHttpParam("Data"); CheckRequired(); /* * Encrypted - Encoded */ if (Encryption=="yes") { LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested Encrypted"); if (Encoding=="no") { LOG.Write("ERR", __FILE__,__FUNCTION__,__LINE__,"WS Requested Encrypted But No Encoded"); throw 107; } else { LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested Encrypted And Encoded"); GetEncodedData(); GetConsumer(); GetDecryptedData(); } /* * No Encrypted - Encoded */ } else if(Encryption=="no" && Encoding=="B64") { LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested No Encrypted And Encoded"); GetEncodedData(); GetConsumer(); /* * No Encrypted - No Encoded */ } else if (Encryption=="no" && Encoding=="no") { LOG.Write("INF", __FILE__,__FUNCTION__,__LINE__,"WS Requested No Encrypted And No Encoded"); GetConsumer(); } ExtractData(); if (SETTINGS["WsEnableLog"]=="yes") { AddRequestLog(); } };
/*---------------------------------------------------------------------------- GetEventKeyDataParameter Extract the keyData parameter data from an apple event ---------------------------------------------------------------------------*/ void AECoreClass::GetEventKeyDataParameter(const AppleEvent *appleEvent, DescType requestedType, AEDesc *data) { StAEDesc keyData; OSErr err = AEGetKeyDesc(appleEvent, keyAEData, requestedType, &keyData); ThrowIfOSErr(err); ExtractData(&keyData, data); }
void NewEditor::Update(float gameTime, BoundingBox* box) { //Gather the Data to create the level ExtractData(); //Check if the level is ready to be created if(GetComplete()) m_pSubmit->Update(gameTime, box); //Update text boxes for(int c = 0; c < m_pTextBox.size(); c++) m_pTextBox[c]->Update(gameTime, box); }
TEST(RelativePositionSummerTest, TwoDirectionsOneDim) { auto positions = std::list<pos> { {1,1} }; List list_ref {positions}; auto command = Command::TestAdvancedTermCollector<1>{}; auto summer = Manipulator::RelPosSummer<1>{&command}; summer.ForAll(list_ref.begin(), list_ref.end()); auto result = command.ExtractData(); auto expected = Command::TestAdvancedTermCollector<1>::container_type{}; expected.insert( { { {{2}} }, 1} ); EXPECT_PRED_FORMAT2(UnitTest::ContainerCompare, expected, result); }
TEST(RelativePositionSummerTest, TwoTermsThreeDims) { auto positions = std::list<pos> { {1}, {2} }; List list_ref {positions}; auto command = Command::TestSimpleTermCollector<3>{}; auto summer = Manipulator::RelPosSummer<3>{&command}; summer.ForAll(list_ref.begin(), list_ref.end()); auto result = command.ExtractData(); auto expected_result = Command::TestSimpleTermCollector<3>::container_type { { {{1,0,0}}, {{2,0,0}} }, { {{0,1,0}}, {{0,2,0}} }, { {{0,0,1}}, {{0,0,2}} } }; EXPECT_EQ(expected_result, result); }
JNIEXPORT jbyteArray JNICALL Java_com_google_code_jdde_ddeml_DdeAPI_ClientTransaction (JNIEnv *env, jclass cls, jint idInst, jbyteArray jpData, jint hConv, jstring jhszItem, jint wFmt, jint wType, jint dwTimeout, jobject $dwResult) { HSZ hszItem = UtilCreateStringHandle(env, idInst, jhszItem); HDDEDATA pData = NULL; DWORD dwResult = 0; if (jpData != NULL) { jsize cb = env->GetArrayLength(jpData); jbyte *pSrc = env->GetByteArrayElements(jpData, 0); pData = DdeCreateDataHandle(idInst, (LPBYTE) pSrc, cb, 0, hszItem, wFmt, 0); env->ReleaseByteArrayElements(jpData, pSrc, 0); } HDDEDATA hddeData = DdeClientTransaction( (LPBYTE) pData, 0xFFFFFFFF, (HCONV) hConv, hszItem, wFmt, wType, dwTimeout, &dwResult ); if (pData != NULL) { DdeFreeDataHandle(pData); } UtilFreeStringHandle(idInst, hszItem); if ($dwResult != NULL) { SetObjectInPointer(env, $dwResult, NewInteger(env, dwResult)); } if (hddeData == NULL) { return NULL; } else if (wType == XTYP_REQUEST) { jbyteArray result = ExtractData(env, hddeData); DdeFreeDataHandle(hddeData); return result; } return env->NewByteArray(0); }
//-----------------------------------------------------------------------------------------// //--------------------------------DRAW NEW POINT TO THE GRAPHS-----------------------------// //-----------------------------------------------------------------------------------------// void RealTimePlotWindow::dataAvaible(QByteArray ext) { double przelicznik = 6103515625;//prescaler value double memory = 2; QVector<measurementData> data = ExtractData(ext);//extract data from dialogwinndow quint16 newDataSize = data.size(); QVector<double> key(newDataSize); QVector<double> ax(newDataSize); QVector<double> ay(newDataSize); QVector<double> az(newDataSize); QVector<double> gx(newDataSize); QVector<double> gy(newDataSize); QVector<double> gz(newDataSize); double keyPrescaler =0; keyPrescaler = keyCounter / 200; // qDebug()<<"znacznik"; for(double i = 0; i<newDataSize; i++) { key[i] = (double)keyPrescaler + (i/200); // key[i] = (double)keyCounter; ax[i] = ((double)data.at(i).ax.as_word)*przelicznik/100000000000; ay[i] = ((double)data.at(i).ay.as_word)*(-1)*przelicznik/100000000000; az[i] = ((double)data.at(i).az.as_word)*(-1)*przelicznik/100000000000; gx[i] = ((double)data.at(i).gx.as_word)*przelicznik/100000000000; gy[i] = ((double)data.at(i).gy.as_word)*(-1)*przelicznik/100000000000; gz[i] = ((double)data.at(i).gz.as_word)*(-1)*przelicznik/100000000000; } if((newDataSize>0)&(triger == true))//get instValues 5 times per secound(depend of timmer interval) { (*instValues)[0] = ax[0]; (*instValues)[1] = ay[0]; (*instValues)[2] = az[0]; (*instValues)[3] = gx[0]; (*instValues)[4] = gy[0]; (*instValues)[5] = gz[0]; triger = false; instValWindow->setInstValues(instValues); } // add new data to graphs ui->accPlot->graph(0)->addData(key, ax); ui->accPlot->graph(1)->addData(key, ay); ui->accPlot->graph(2)->addData(key, az); ui->gyroPlot->graph(0)->addData(key, gx); ui->gyroPlot->graph(1)->addData(key, gy); ui->gyroPlot->graph(2)->addData(key, gz); // remove data of lines that's outside visible range: ui->accPlot->graph(0)->removeDataBefore(keyPrescaler-memory); ui->accPlot->graph(1)->removeDataBefore(keyPrescaler-memory); ui->accPlot->graph(2)->removeDataBefore(keyPrescaler-memory); // qDebug()<<"znacznik 4\n"; // rescale value (vertical) axis to fit the current data: ui->accPlot->graph(0)->rescaleValueAxis(); ui->accPlot->graph(1)->rescaleValueAxis(true); ui->accPlot->graph(2)->rescaleValueAxis(true); // make key axis range scroll with the data (at a constant range size of 8): ui->accPlot->xAxis->setRange(keyPrescaler, memory, Qt::AlignRight); ui->accPlot->replot(); // remove data of lines that's outside visible range: ui->gyroPlot->graph(0)->removeDataBefore(keyPrescaler-memory); ui->gyroPlot->graph(1)->removeDataBefore(keyPrescaler-memory); ui->gyroPlot->graph(2)->removeDataBefore(keyPrescaler-memory); // rescale value (vertical) axis to fit the current data: ui->gyroPlot->graph(0)->rescaleValueAxis(); ui->gyroPlot->graph(1)->rescaleValueAxis(true); ui->gyroPlot->graph(2)->rescaleValueAxis(true); // make key axis range scroll with the data (at a constant range size of 8): ui->gyroPlot->xAxis->setRange(keyPrescaler, memory, Qt::AlignRight); ui->gyroPlot->replot(); keyCounter += newDataSize; MPS += newDataSize; qDebug()<<"keyCounter:"<<keyCounter; }
void CFile::TryConvertIncbin() { std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" }; int incbinType = -1; for (int i = 0; i < 6; i++) { if (CheckIdentifier(idents[i])) { incbinType = i; break; } } if (incbinType == -1) return; int size = 1 << (incbinType / 2); bool isSigned = ((incbinType % 2) == 0); long oldPos = m_pos; long oldLineNum = m_lineNum; m_pos += idents[incbinType].length(); SkipWhitespace(); if (m_buffer[m_pos] != '(') { m_pos = oldPos; m_lineNum = oldLineNum; return; } m_pos++; SkipWhitespace(); if (m_buffer[m_pos] != '"') RaiseError("expected double quote"); m_pos++; int startPos = m_pos; while (m_buffer[m_pos] != '"') { if (m_buffer[m_pos] == 0) { if (m_pos >= m_size) RaiseError("unexpected EOF in path string"); else RaiseError("unexpected null character in path string"); } if (m_buffer[m_pos] == '\r' || m_buffer[m_pos] == '\n') RaiseError("unexpected end of line character in path string"); if (m_buffer[m_pos] == '\\') RaiseError("unexpected escape in path string"); m_pos++; } std::string path(&m_buffer[startPos], m_pos - startPos); m_pos++; SkipWhitespace(); if (m_buffer[m_pos] != ')') RaiseError("expected ')'"); m_pos++; std::printf("{"); int fileSize; std::unique_ptr<unsigned char[]> buffer = ReadWholeFile(path, fileSize); if ((fileSize % size) != 0) RaiseError("Size %d doesn't evenly divide file size %d.\n", size, fileSize); int count = fileSize / size; int offset = 0; for (int i = 0; i < count; i++) { int data = ExtractData(buffer, offset, size); offset += size; if (isSigned) std::printf("%d,", data); else std::printf("%uu,", data); } std::printf("}"); }
bool getExtractionData(const Game *g, Search &search, ExtractMap &map) { SearchMap searchMap; const int *needList = getNeedList(g); if (!needList) { fprintf(stderr, "ERROR: No entry need list available\n"); return false; } if (!setupSearch(g, needList, search, searchMap)) return false; // Process the data search Search::ResultList results; search.search(results); if (results.empty()) { fprintf(stderr, "ERROR: Couldn't find any required data\n"); return false; } ExtractMap temporaryExtractMap; for (const int *entry = needList; *entry != -1; ++entry) { typedef std::pair<SearchMap::const_iterator, SearchMap::const_iterator> KeyRange; KeyRange idRange = searchMap.equal_range(*entry); for (Search::ResultList::const_iterator i = results.begin(); i != results.end(); ++i) { for (SearchMap::const_iterator j = idRange.first; j != idRange.second; ++j) { if (j->second.hint == i->data) temporaryExtractMap.insert(ExtractMapEntry(*entry, ExtractData(j->second, i->offset))); } } } // Free up some memory results.clear(); searchMap.clear(); bool result = true; for (const int *entry = needList; *entry != -1; ++entry) { MatchList possibleMatches = filterPlatformMatches(g, temporaryExtractMap.equal_range(*entry)); if (possibleMatches.empty()) { fprintf(stderr, "ERROR: No entry found for id %d/%s\n", *entry, getIdString(*entry)); result = false; continue; } if (isLangSpecific(*entry)) { for (int i = 0; i < 3; ++i) { if (g->lang[i] == -1) continue; MatchList langMatches = filterLanguageMatches(g->lang[i], possibleMatches); MatchList::const_iterator bestMatch = filterOutBestMatch(langMatches); if (bestMatch == langMatches.end()) { // TODO: Add nice language name to output message. fprintf(stderr, "ERROR: No entry found for id %d/%s for language %d\n", *entry, getIdString(*entry), g->lang[i]); result = false; continue; } #ifdef DEBUG_EXTRACTION_TABLES if (((*bestMatch)->second.desc.platform != kPlatformUnknown && (*bestMatch)->second.desc.platform != g->platform)) printf("%s: %.8X %.8X %d %d\n", getIdString(*entry), (*bestMatch)->second.desc.hint.size, (*bestMatch)->second.desc.hint.byteSum, (*bestMatch)->second.desc.lang, (*bestMatch)->second.desc.platform); #endif map.insert(**bestMatch); } } else { MatchList::const_iterator bestMatch = filterOutBestMatch(possibleMatches); if (bestMatch == possibleMatches.end()) { fprintf(stderr, "ERROR: No entry found for id %d/%s\n", *entry, getIdString(*entry)); result = false; continue; } #ifdef DEBUG_EXTRACTION_TABLES if (((*bestMatch)->second.desc.platform != kPlatformUnknown && (*bestMatch)->second.desc.platform != g->platform)) printf("%s: %.8X %.8X %d %d\n", getIdString(*entry), (*bestMatch)->second.desc.hint.size, (*bestMatch)->second.desc.hint.byteSum, (*bestMatch)->second.desc.lang, (*bestMatch)->second.desc.platform); #endif map.insert(**bestMatch); } } return result; }
int CMFTRecord::ExtractFile(BYTE *puchMFTBuffer, DWORD dwLen, bool bExcludeData) { if (m_dwMaxMFTRecSize > dwLen) return ERROR_INVALID_PARAMETER; if (!puchMFTBuffer) return ERROR_INVALID_PARAMETER; NTFS_MFT_FILE ntfsMFT; NTFS_ATTRIBUTE ntfsAttr; BYTE *puchTmp = 0; BYTE *uchTmpData = 0; DWORD dwTmpDataLen; int nRet; m_pMFTRecord = puchMFTBuffer; m_dwCurPos = 0; if (m_puchFileData) delete m_puchFileData; m_puchFileData = 0; m_dwFileDataSz = 0; // read the record header in MFT table memcpy(&ntfsMFT, &m_pMFTRecord[m_dwCurPos], sizeof (NTFS_MFT_FILE)); if (memcmp(ntfsMFT.szSignature, "FILE", 4)) return ERROR_INVALID_PARAMETER; // not the right signature m_bInUse = (ntfsMFT.wFlags & 0x01); //0x01 Record is in use //0x02 Record is a directory //m_dwCurPos = (ntfsMFT.wFixupOffset + ntfsMFT.wFixupSize*2); m_dwCurPos = ntfsMFT.wAttribOffset; do { // extract the attribute header memset(&ntfsAttr, '\0', sizeof (NTFS_ATTRIBUTE)); memcpy(&ntfsAttr, &m_pMFTRecord[m_dwCurPos], sizeof (NTFS_ATTRIBUTE)); switch (ntfsAttr.dwType) // extract the attribute data { // here I haven't implemented the processing of all the attributes. // I have implemented attributes necessary for file & file data extraction case 0://UNUSED break; case 0x10: //STANDARD_INFORMATION nRet = ExtractData(ntfsAttr, uchTmpData, dwTmpDataLen); if (nRet) return nRet; memcpy(&m_attrStandard, uchTmpData, sizeof (ATTR_STANDARD)); delete uchTmpData; uchTmpData = 0; dwTmpDataLen = 0; break; case 0x30: //FILE_NAME nRet = ExtractData(ntfsAttr, uchTmpData, dwTmpDataLen); if (nRet) return nRet; memcpy(&m_attrFilename, uchTmpData, dwTmpDataLen); delete uchTmpData; uchTmpData = 0; dwTmpDataLen = 0; break; case 0x40: //OBJECT_ID break; case 0x50: //SECURITY_DESCRIPTOR break; case 0x60: //VOLUME_NAME break; case 0x64: printf("64 jeeeee!!!! \n"); break; case 0x70: //VOLUME_INFORMATION break; case 0x80: //DATA if (!bExcludeData) { nRet = ExtractData(ntfsAttr, uchTmpData, dwTmpDataLen); if (nRet) return nRet; if (!m_puchFileData) { m_dwFileDataSz = dwTmpDataLen; m_puchFileData = new BYTE[dwTmpDataLen]; memcpy(m_puchFileData, uchTmpData, dwTmpDataLen); } else { puchTmp = new BYTE[m_dwFileDataSz + dwTmpDataLen]; memcpy(puchTmp, m_puchFileData, m_dwFileDataSz); memcpy(puchTmp + m_dwFileDataSz, uchTmpData, dwTmpDataLen); m_dwFileDataSz += dwTmpDataLen; delete m_puchFileData; m_puchFileData = puchTmp; } delete uchTmpData; uchTmpData = 0; dwTmpDataLen = 0; } break; case 0x90: //INDEX_ROOT case 0xa0: //INDEX_ALLOCATION // todo: not implemented to read the index mapped records return ERROR_SUCCESS; continue; break; case 0xb0: //BITMAP break; case 0xc0: //REPARSE_POINT break; case 0xd0: //EA_INFORMATION break; case 0xe0: //EA break; case 0xf0: //PROPERTY_SET break; case 0x100: //LOGGED_UTILITY_STREAM break; case 0x1000: //FIRST_USER_DEFINED_ATTRIBUTE break; case 0xFFFFFFFF: // END if (uchTmpData) delete uchTmpData; uchTmpData = 0; dwTmpDataLen = 0; return ERROR_SUCCESS; default: return ERROR_SUCCESS; break; }; m_dwCurPos += ntfsAttr.dwFullLength; // go to the next location of attribute } while (ntfsAttr.dwFullLength && (m_dwCurPos < 1024)); if (uchTmpData) delete uchTmpData; uchTmpData = 0; dwTmpDataLen = 0; return ERROR_SUCCESS; }
vector<CLogModel*> CHistoryItemLogParser::ParseLog(long& lPosition, long lLength, char* pBuffer) { map<long long,string> mapHostMacDict; string strFormatLog; stringstream strErrorMess; int iZbxServerId, iValueType, iMaintenance; string strHost, strKey_, strHostName, strIfAddress, strZbIpAddress, strSerialNumber; string strTemp; string strValue; HostInfo tagHostInfo; long long lItemId, lClock, lHostId, lServerId; vector<CLogModel*> vtHistoryItemModelPtr; while (lPosition < lLength) { // ResetHostInfo(tagHostInfo); // Init database fields lClock = iZbxServerId = lHostId = lItemId = iValueType = lServerId = iMaintenance = 0; strKey_ = strValue = strHost = strHostName = strIfAddress = strZbIpAddress = strSerialNumber = ""; CLogModel* pLogModel = RegisterModel(); //Parse Clock lClock = ParseLong((const char*)pBuffer, lPosition, lLength); //Parse ServerId iZbxServerId = ParseInt((const char*)pBuffer, lPosition, lLength); //Parse HostId lHostId = ParseLong((const char*)pBuffer, lPosition, lLength); // Calculate ServerId lServerId = ((lHostId - 10000) * 256) + iZbxServerId; //Parse Hostname strTemp = GetBlock((const char*)pBuffer, lPosition, lLength); if(strTemp.compare("") != 0) { strHostName = strTemp; strHostName = CUtilities::ReplaceBlockBracket(strHostName); strHost = strHostName; } //Parse zb IP Address strTemp = GetBlock((const char*)pBuffer, lPosition, lLength); if(strTemp.compare("") != 0) { strIfAddress = strTemp; strIfAddress = CUtilities::ReplaceBlockBracket(strIfAddress); strZbIpAddress = strIfAddress; } //Parse Maintenance Status iMaintenance = ParseInt((const char*)pBuffer, lPosition, lLength); //Parse ItemId lItemId = ParseLong((const char*)pBuffer, lPosition, lLength); //Parse Key_ strKey_ = GetItemKey((const char*)pBuffer, lPosition, lLength); //Parse Value Type iValueType = ParseInt((const char*)pBuffer, lPosition, lLength); //Parse Value if (strKey_.compare(SYSTEM_INFO) == 0 || strKey_.compare(VB_SYSTEM_INFO) == 0 || strKey_.compare(OS_INFO) == 0) { try { //ParseSystemInfo((const char*)pBuffer, lPosition, lLength, lServerId, mapHostMacDict, tagHostInfo); strValue = GetValueBlock((const char*)pBuffer, lPosition, lLength); } catch(exception& ex) { strErrorMess << ex.what() << " " << __FILE__ << " " << __LINE__; strFormatLog = CUtilities::FormatLog(ERROR_MSG, "CHistoryItemLogParser", "ParseLog", strErrorMess.str()); CUtilities::WriteErrorLog(strFormatLog); } } else if (strKey_.compare(SDK_READ_TEXT) == 0 || strKey_.compare(SDK_READ_TEXT_LINUX) == 0) { strTemp = GetToken((const char*)pBuffer, lPosition, lLength); if (strTemp.compare("") != 0) { strValue = strTemp; strSerialNumber = strValue; strSerialNumber.erase(std::find_if(tagHostInfo.strSerialNumber.rbegin(), tagHostInfo.strSerialNumber.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), tagHostInfo.strSerialNumber.end()); } } else strValue = GetItemValue((const char*)pBuffer, lPosition, lLength); CHistoryItemModel *pHistoryItemModel = dynamic_cast<CHistoryItemModel*>(pLogModel); pHistoryItemModel->SetItemId(lItemId); pHistoryItemModel->SetKey_(strKey_); pHistoryItemModel->SetValueType(iValueType); pHistoryItemModel->SetValue(strValue); pHistoryItemModel->SetServerId(lServerId); pHistoryItemModel->SetZabbixServerId(iZbxServerId); pHistoryItemModel->SetHostId(lHostId); pHistoryItemModel->SetSerialNumber(strSerialNumber); pHistoryItemModel->SetHost(strHost); pHistoryItemModel->SetHostName(strHostName); pHistoryItemModel->SetZbIpAddress(strZbIpAddress); pHistoryItemModel->SetMaintenance(iMaintenance); pHistoryItemModel->SetClock(lClock); if (ExtractData(pHistoryItemModel)) { vtHistoryItemModelPtr.push_back(pHistoryItemModel); } else { delete pHistoryItemModel; } } return vtHistoryItemModelPtr; }