bool DuplicateDetectLayer(int depth) { const int bufferSize = 128; double m0Dups = 0; double m2Dups = 0; double m4Dups = 0; double fDups = 0; double writeTime = 0; std::vector<uint64_t> values; values.resize(bufferSize); Timer t; uint64_t count = 0; bool dups = false; std::unordered_map<uint64_t, uint8_t> map; uint64_t removed0 = 0, removed2 = 0; for (int x = 0; x < kNumBuckets; x++) { t.StartTimer(); FILE *f = fopen(GetFileName(depth, x), "r"); if (f == 0) continue; map.clear(); count = 0; uint64_t numRead; while ((numRead = fread(&values[0], sizeof(uint64_t), bufferSize, f)) > 0) { for (int x = 0; x < numRead; x++) map[values[x]>>5] = values[x]&0x1F; count++; } fclose(f); m0Dups += t.EndTimer(); //printf("Read %llu states from depth %d bucket %d [%s]\n", count, depth, x, GetFileName(depth, x)); t.StartTimer(); f = fopen(GetFileName(depth-2, x), "r"); if (f != 0) { while ((numRead = fread(&values[0], sizeof(uint64_t), bufferSize, f)) > 0) { for (int x = 0; x < numRead; x++) { //printf("Looking for duplicate %d %llu\n", x, next); auto loc = map.find(values[x]>>5); if (loc != map.end()) { //printf("Removing duplicate %d %llu\n", x, loc->first); removed0++; map.erase(loc); } } } fclose(f); } m2Dups += t.EndTimer(); t.StartTimer(); f = fopen(GetFileName(depth-4, x), "r"); if (f != 0) { while ((numRead = fread(&values[0], sizeof(uint64_t), bufferSize, f)) > 0) { for (int x = 0; x < numRead; x++) { auto loc = map.find(values[x]>>5); if (loc != map.end()) { removed2++; map.erase(loc); } } } fclose(f); } m4Dups += t.EndTimer(); t.StartTimer(); f = fopen(GetFileName(depth-1, x), "r"); if (f != 0) { while ((numRead = fread(&values[0], sizeof(uint64_t), bufferSize, f)) > 0) { for (int x = 0; x < numRead; x++) { auto loc = map.find(values[x]>>5); if (loc != map.end()) { //printf("Found duplicate!\n"); dups = true; } } } fclose(f); } fDups += t.EndTimer(); t.StartTimer(); count = 0; f = fopen(GetFileName(depth, x), "w"); if (f == 0) { printf("Error with %s\n", GetFileName(depth, x)); exit(0); } values.resize(0); for (auto val : map) { //if (val.second) { values.push_back((val.first<<5)|(val.second)); count++; //printf("%2d): Writing %llu %llu\n", depth, x, val.first); if (values.size() >= bufferSize) { fwrite(&(values[0]), sizeof(uint64_t), values.size(), f); values.resize(0); } } } if (values.size() > 0) fwrite(&(values[0]), sizeof(uint64_t), values.size(), f); //printf("Wrote %llu states to depth %d bucket %d [%s]\n", count, depth, x, GetFileName(depth, x)); fclose(f); writeTime += t.EndTimer(); } printf("%1.2f dup vs 0, %1.2f dup vs -2, %1.2f dup vs -4, %1.2f dup vs other frontier, %1.2f write; %llu dups at -2, %llu at -4\n", m0Dups, m2Dups, m4Dups, fDups, writeTime, removed0, removed2); return dups; }
//--------------------------------------------------------------------------- void CSendImageShack::Send() { // check Netlib if( !hNetlibUser ) { //PrintError(1,TRUE); return; } if (!m_pszFileName) { m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ); } if (!m_pszContentType) GetContentType(); // create new boundary MFDR_Reset(); // initialize the netlib request ZeroMemory(&m_nlhr, sizeof(m_nlhr)); m_nlhr.cbSize = sizeof(m_nlhr); m_nlhr.requestType = REQUEST_POST; m_nlhr.flags = NLHRF_HTTP11; //NLHRF_DUMPASTEXT; m_nlhr.szUrl = "http://www.imageshack.us/upload_api.php"; m_nlhr.headersCount = 6; { //NETLIBHTTPHEADER start m_nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*m_nlhr.headersCount); m_nlhr.headers[0].szName = "Referer"; m_nlhr.headers[0].szValue = "http://www.imageshack.us/upload_api.php"; m_nlhr.headers[1].szName = "Connection"; m_nlhr.headers[1].szValue = "Keep-alive"; m_nlhr.headers[2].szName = "AcceptLanguage"; m_nlhr.headers[2].szValue = "en-us, pt-br"; m_nlhr.headers[3].szName = "Host"; m_nlhr.headers[3].szValue = "imageshack.us"; m_nlhr.headers[4].szName = "User-Agent"; m_nlhr.headers[4].szValue = __USER_AGENT_STRING; //szAgent; /; //nlhr.headers[x].szName = "Authorization"; //nlhr.headers[x].szValue = auth; //Basic base-64-authorization //$header .= "Content-type: multipart/form-data; boundary=" . part::getBoundary() . "\r\n"; mir_snprintf(m_nlheader_ContentType, SIZEOF(m_nlheader_ContentType), "multipart/form-data; boundary=%s", m_MFDRboundary); m_nlhr.headers[m_nlhr.headersCount-1].szName = "Content-Type"; m_nlhr.headers[m_nlhr.headersCount-1].szValue = m_nlheader_ContentType; } //NETLIBHTTPHEADER end //POST DATA file-header, init DATA with MultipartFormDataRequest //$params[] = new filepart('fileupload', $file, basename($file), $contentType, 'iso-8859-1'); //($this->sendStart($h);) AppendToData("--"); AppendToData(m_MFDRboundary); AppendToData("\r\n"); //($this->sendDispositionHeader($h);) AppendToData("Content-Disposition: form-data; name=\""); AppendToData("fileupload"); AppendToData("\"; filename=\""); AppendToData(m_pszFileName); AppendToData("\""); AppendToData("\r\n"); //($this->sendContentTypeHeader($h);) AppendToData("Content-Type: "); AppendToData(m_pszContentType); AppendToData("; charset="); AppendToData("iso-8859-1"); //($this->sendEndOfHeader($h);) AppendToData("\r\n"); AppendToData("\r\n"); //Now we add the file binary ($this->sendData($h)) FILE * fileId = _tfsopen(m_pszFile, _T("rb"), _SH_DENYWR ); if( !fileId) { //PrintError(1,TRUE); return; } fseek(fileId, NULL, SEEK_END); size_t lenFile = ftell(fileId); size_t sizeDest = sizeof(char)*(m_nlhr.dataLength + lenFile + 1); m_nlhr.pData = (char *) mir_realloc(m_nlhr.pData, sizeDest); fseek(fileId, NULL, SEEK_SET ); int i; int ch = fgetc( fileId ); for( i=0; (i < (int)lenFile ) && ( feof( fileId ) == 0 ); i++ ) { m_nlhr.pData[m_nlhr.dataLength+i] = (char)ch; ch = fgetc( fileId ); } m_nlhr.pData[sizeDest-1] = 0; //NULL Termination for binary data m_nlhr.dataLength = (int)sizeDest - 1; fclose(fileId); //($this->sendEnd($h);) AppendToData("\r\n"); //POST DATA footer (for "optimage", 1) //POST DATA footer (for "optsize", optsize) //POST DATA footer (for "tags", tags) //POST DATA footer (for "rembar", "yes" : "no") //POST DATA footer (for "public", "yes" : "no") //POST DATA footer (for "cookie", cookie) //POST DATA footer (for "key", DEVKEY_IMAGESHACK) //($this->sendStart($h);) AppendToData("--"); AppendToData(m_MFDRboundary); AppendToData("\r\n"); //($this->sendDispositionHeader($h);) AppendToData("Content-Disposition: form-data; name=\""); AppendToData("key"); AppendToData("\""); //($this->sendTransferEncodingHeader($h); ) AppendToData("\r\n"); AppendToData("Content-Transfer-Encoding: "); AppendToData("8bit"); //??"binary" //($this->sendEndOfHeader($h);) AppendToData("\r\n"); AppendToData("\r\n"); //($this->sendData($h);) AppendToData(DEVKEY_IMAGESHACK); //($this->sendEnd($h);) AppendToData("\r\n"); //POST DATA Exit //$postdata = "--" . part::getBoundary() . "--\r\n"; AppendToData("--"); AppendToData(m_MFDRboundary); AppendToData("--\r\n"); //start upload thread if (m_SendSync) { m_bFreeOnExit = FALSE; SendThread(); return; } m_bFreeOnExit = TRUE; mir_forkthread(&CSendImageShack::SendThreadWrapper, this); }
void FileTabs::InsertFile(int ix, const WString &file, Image img, bool make_active) { String s = file.ToString(); TabBar::InsertKey(ix, file, GetFileName(s), img, GetFileGroup(s), make_active); }
int KString::QSortFunctionFileNumeric(const void* p1, const void* p2) { return QSortFunctionNumeric(GetFileName(*(KString*)p1), GetFileName(*(KString*)p2)); }
/** * Displays the popup menu with all of the appropriate menu items enabled. * @param pt The location where the menu should be displayed. */ void MaterialTreeView::PopupMenu(CPoint* pt) { //Determine the type of object clicked on CTreeCtrl& tree = GetTreeCtrl(); UINT test; HTREEITEM item = tree.HitTest( *pt, &test ); if ( item == NULL || !(test & TVHT_ONITEM) ) return; ClientToScreen (pt); CMenu FloatingMenu; VERIFY(FloatingMenu.LoadMenu(IDR_ME_MATERIALTREE_POPUP)); CMenu* pPopupMenu = FloatingMenu.GetSubMenu (0); DWORD itemType = tree.GetItemData(item); //Enable/Disable based on the state MaterialDoc* pDoc = materialDocManager->GetCurrentMaterialDoc(); //Apply Changes if(pDoc && pDoc->applyWaiting) { pPopupMenu->EnableMenuItem(ID_POPUP_APPLYMATERIAL, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_APPLYMATERIAL, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } //Apply File idStr filename; if(GetFileName(item, filename)) { if(materialDocManager->DoesFileNeedApply(filename.c_str())) pPopupMenu->EnableMenuItem(ID_POPUP_APPLYFILE, MF_BYCOMMAND | MF_ENABLED); else pPopupMenu->EnableMenuItem(ID_POPUP_APPLYFILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_APPLYFILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } //Apply All if(materialDocManager->DoesAnyNeedApply()) { pPopupMenu->EnableMenuItem(ID_POPUP_APPLYALL, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_APPLYALL, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } //Save Material if(pDoc && pDoc->modified) { pPopupMenu->EnableMenuItem(ID_POPUP_SAVEMATERIAL, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_SAVEMATERIAL, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } //Save File if(GetFileName(item, filename)) { if(materialDocManager->IsFileModified(filename.c_str())) pPopupMenu->EnableMenuItem(ID_POPUP_SAVEFILE, MF_BYCOMMAND | MF_ENABLED); else pPopupMenu->EnableMenuItem(ID_POPUP_SAVEFILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_SAVEFILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } //Save All if(materialDocManager->IsAnyModified()) { pPopupMenu->EnableMenuItem(ID_POPUP_SAVEALL, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_SAVEALL, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } if(itemType == TYPE_MATERIAL || itemType == TYPE_MATERIAL_FOLDER) { pPopupMenu->EnableMenuItem(ID_POPUP_RENAMEMATERIAL, MF_BYCOMMAND | MF_ENABLED); pPopupMenu->EnableMenuItem(ID_POPUP_DELETEMATERIAL, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_RENAMEMATERIAL, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); pPopupMenu->EnableMenuItem(ID_POPUP_DELETEMATERIAL, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } if(itemType == TYPE_FILE || itemType == TYPE_MATERIAL_FOLDER || itemType == TYPE_MATERIAL) { pPopupMenu->EnableMenuItem(ID_POPUP_ADDMATERIAL, MF_BYCOMMAND | MF_ENABLED); pPopupMenu->EnableMenuItem(ID_POPUP_ADDFOLDER, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_ADDMATERIAL, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); pPopupMenu->EnableMenuItem(ID_POPUP_ADDFOLDER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } if(itemType == TYPE_MATERIAL) { pPopupMenu->EnableMenuItem(ID_POPUP_CUT, MF_BYCOMMAND | MF_ENABLED); pPopupMenu->EnableMenuItem(ID_POPUP_COPY, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_CUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); pPopupMenu->EnableMenuItem(ID_POPUP_COPY, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } if((itemType == TYPE_MATERIAL || itemType == TYPE_FILE || itemType == TYPE_MATERIAL_FOLDER) && materialDocManager->IsCopyMaterial()) { pPopupMenu->EnableMenuItem(ID_POPUP_PASTE, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_PASTE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } if(itemType == TYPE_MATERIAL || itemType == TYPE_FILE || itemType == TYPE_MATERIAL_FOLDER) { pPopupMenu->EnableMenuItem(ID_POPUP_RELOADFILE, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_POPUP_RELOADFILE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } pPopupMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt->x, pt->y, &GetTreeCtrl()); }
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) { wxString sep = wxFileName().GetPathSeparator(); wxString fullFileName = GetFileName(); wxTreeItemId id = GetId(); KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) Pgm().App().GetTopWindow(); switch( GetType() ) { case TREE_PROJECT: break; case TREE_DIRECTORY: m_parent->Toggle( id ); break; case TREE_SCHEMA: if( fullFileName == frame->SchFileName() ) { // the project's schematic is opened using the *.kiface as part of this process. frame->RunEeschema( fullFileName ); } else { // schematics not part of the project are opened in a separate process. frame->Execute( m_parent, EESCHEMA_EXE, fullFileName ); } break; case TREE_LEGACY_PCB: case TREE_SEXP_PCB: if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() ) { // the project's BOARD is opened using the *.kiface as part of this process. frame->RunPcbNew( fullFileName ); } else { // boards not part of the project are opened in a separate process. frame->Execute( m_parent, PCBNEW_EXE, fullFileName ); } break; case TREE_GERBER: frame->Execute( m_parent, GERBVIEW_EXE, fullFileName ); break; case TREE_PDF: AddDelimiterString( fullFileName ); OpenPDF( fullFileName ); break; case TREE_NET: frame->Execute( m_parent, CVPCB_EXE, fullFileName ); break; case TREE_TXT: { wxString editorname = Pgm().GetEditorName(); if( !editorname.IsEmpty() ) frame->Execute( m_parent, editorname, fullFileName ); } break; case TREE_PAGE_LAYOUT_DESCR: frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName ); break; default: AddDelimiterString( fullFileName ); OpenFile( fullFileName ); break; } }
void CSpacePortal::OnRequestStartObject(int64 SourceID,ePipeline& RequestInfo){ int64 EventID = RequestInfo.PopInt(); ePipeline* ObjectInfo = (ePipeline*)RequestInfo.GetData(0); ePipeline* ExePipe = (ePipeline*)RequestInfo.GetData(1); CObjectData Object(*ObjectInfo); ePipeline AddrData = Object.m_Address; assert(Object.m_ID != 0); //Checks whether the specified object addresses is valid SpaceAddress Address = FindChildSpace(AddrData,Object.m_Fingerprint); if (!Address.IsValid()) { CLinker Requester; GetLinker(SourceID,Requester); if (Requester.IsValid()) { CMsg FeedbackMsg(MSG_TASK_FEEDBACK,NULL,EventID); ePipeline& Letter = FeedbackMsg.GetLetter(); ExePipe->SetID(RETURN_ERROR); ExePipe->GetLabel() = Format1024(_T("Error: object address invalid")); Letter.PushPipe(*ExePipe); Requester().PushMsgToSend(FeedbackMsg); } return; } //Need to open the corresponding DLL object in advance, in order to determine the type of executer //CSpace Space(Address.ParentID,Address.ChildID); AddrData = Object.m_Address; tstring FilePath = SpacePath2FileAddress(AddrData); tstring ObjectName = GetFileName(Object.m_Name); //不含扩展名 FilePath += _T("\\")+ObjectName; FilePath += _T("\\")+Object.m_Name; Dll_Object TempDll(Object.m_ID,FilePath); if (!TempDll.IsValid()) { int32 error = ::GetLastError(); ExePipe->SetID(RETURN_ERROR); ExePipe->GetLabel() = Format1024(_T("Load object fail: <%s>"),FilePath.c_str()); CLinker Requester; GetLinker(SourceID,Requester); if (Requester.IsValid()) { CMsg FeedbackMsg(MSG_TASK_FEEDBACK,NULL,EventID); ePipeline& Letter = FeedbackMsg.GetLetter(); Letter.PushPipe(*ExePipe); Requester().PushMsgToSend(FeedbackMsg); } return ; } DLL_TYPE DllType = TempDll.GetDllType(); tstring ExecuterFile; switch (DllType) { case DLL_VC6: { ExecuterFile = _T("EXE_VC6.EXE"); } break; case DLL_VC6D: { ExecuterFile = _T("EXE_VC6D.EXE"); } break; case DLL_VC10: { ExecuterFile = _T("EXE_VC10.EXE"); } break; case DLL_VC10D: { ExecuterFile = _T("EXE_VC10D.EXE"); } break; default: { ExePipe->GetLabel() = Format1024(_T("Error: dll type not support:%d"),(int)DllType); ExePipe->SetID(RETURN_ERROR); CLinker Requester; GetLinker(SourceID,Requester); if (Requester.IsValid()) { CMsg FeedbackMsg(MSG_TASK_FEEDBACK,NULL,EventID); ePipeline& Letter = FeedbackMsg.GetLetter(); Letter.PushPipe(*ExePipe); Requester().PushMsgToSend(FeedbackMsg); } return; } } //start a executer int64 ExeSourceID = Object.m_ID; //ExecuterID is equal to the external object instance ID bool ret = StartExecuter(ExeSourceID,ExecuterFile); if (!ret) { ExePipe->GetLabel() = Format1024(_T("Error: Executer start fail.")); ExePipe->SetID(RETURN_ERROR); CLinker Requester; GetLinker(SourceID,Requester); if (Requester.IsValid()) { CMsg FeedbackMsg(MSG_TASK_FEEDBACK,NULL,EventID); ePipeline& Letter = FeedbackMsg.GetLetter(); Letter.PushPipe(*ExePipe); Requester().PushMsgToSend(FeedbackMsg); } return; } RegisterExecuterUser(SourceID,ExeSourceID); CLinker ExecuterLinker; GetLinker(ExeSourceID,ExecuterLinker); //Register a start external object event PushExecuterEvent(ExeSourceID,SourceID,EventID); WriteLogDB(_T("Start Object Event:%I64ld"),EventID); //send execute msg CMsg NewMsg(MSG_OBJECT_START,NULL,EventID); ePipeline& NewLetter = NewMsg.GetLetter(); NewLetter.PushString(FilePath); NewLetter.PushPipe(*ExePipe); ExecuterLinker().PushMsgToSend(NewMsg); };
BOOL CFileFind::IsDots() const /****************************/ { CString strFileName = GetFileName(); return( strFileName == _T(".") || strFileName == _T("..") ); }
bool plWin32StreamingSound::LoadSound( bool is3D ) { if( fFailed ) return false; if( !plgAudioSys::Active() || fDSoundBuffer ) return false; if( fPriority > plgAudioSys::GetPriorityCutoff() ) return false; // Don't set the failed flag, just return // Debug flag #1 if( is3D && fChannelSelect > 0 && plgAudioSys::IsDebugFlagSet( plgAudioSys::kDisableRightSelect ) ) { // Force a fail fFailed = true; return false; } plSoundBuffer::ELoadReturnVal retVal = IPreLoadBuffer(true); if(retVal == plSoundBuffer::kPending) return true; if( retVal == plSoundBuffer::kError ) { plString str = plFormat("Unable to open streaming source {}", fDataBufferKey->GetName()); IPrintDbgMessage( str.c_str(), true ); fFailed = true; return false; } SetProperty( kPropIs3DSound, is3D ); plWAVHeader header = fDataStream->GetHeader(); uint32_t bufferSize = (uint32_t)(fBufferLengthInSecs * header.fAvgBytesPerSec); // Debug flag #2 if( is3D && fChannelSelect == 0 && header.fNumChannels > 1 && plgAudioSys::IsDebugFlagSet( plgAudioSys::kDisableLeftSelect ) ) { // Force a fail fFailed = true; return false; } // Actually create the buffer now (always looping) fDSoundBuffer = new plDSoundBuffer( bufferSize, header, is3D, IsPropertySet(kPropLooping), false, true ); if( !fDSoundBuffer->IsValid() ) { fDataStream->Close(); delete fDataStream; fDataStream = nil; delete fDSoundBuffer; fDSoundBuffer = nil; plString str = plFormat("Can't create sound buffer for {}.wav. This could happen if the wav file is a stereo file." " Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", GetFileName()); IPrintDbgMessage(str.c_str(), true); fFailed = true; return false; } fTotalBytes = (uint32_t)bufferSize; plProfile_NewMem(MemSounds, fTotalBytes); plSoundBuffer *buffer = (plSoundBuffer *)fDataBufferKey->ObjectIsLoaded(); if(!buffer) return false; bool setupSource = true; if(!buffer->GetData() || fStartPos) { if(fStartPos && fStartPos <= fDataStream->NumBytesLeft()) { fDataStream->SetPosition(fStartPos); plStatusLog::AddLineS("syncaudio.log", "startpos %d", fStartPos); } // if we get here we are not starting from the beginning of the sound. We still have an audio loaded and need to pick up where we left off if(!fDSoundBuffer->SetupStreamingSource(fDataStream)) { setupSource = false; } } else { // this sound is starting from the beginning. Get the data and start it. if(!fDSoundBuffer->SetupStreamingSource(buffer->GetData(), buffer->GetAsyncLoadLength())) { setupSource = false; } } if(!setupSource) { fDataStream->Close(); delete fDataStream; fDataStream = nil; delete fDSoundBuffer; fDSoundBuffer = nil; plStatusLog::AddLineS("audio.log", "Could not play streaming sound, no voices left %s", GetKeyName().c_str()); return false; } FreeSoundData(); IRefreshEAXSettings( true ); // Debug info plString dbg = plFormat(" Streaming {}.", fSrcFilename); IPrintDbgMessage(dbg.c_str()); plStatusLog::AddLineS( "audioTimes.log", 0xffffffff, "Streaming %4.2f secs of %s", fDataStream->GetLengthInSecs(), GetKey()->GetUoid().GetObjectName().c_str() ); // Get pertinent info SetLength( (float)fDataStream->GetLengthInSecs() ); // Set up our deswizzler, if necessary delete fDeswizzler; if( fDataStream->GetHeader().fNumChannels != header.fNumChannels ) fDeswizzler = new plSoundDeswizzler( (uint32_t)(fBufferLengthInSecs * fDataStream->GetHeader().fAvgBytesPerSec), (uint8_t)(fDataStream->GetHeader().fNumChannels), header.fBitsPerSample / 8 ); else fDeswizzler = nil; // LEAVE THE WAV FILE OPEN! (We *are* streaming, after all :) return true; }
Resource *RCFile::GetRes() { int type; int val = 0; std::wstring name; ResourceId id; bool done = false; Resource *rv = NULL; while (!done && !AtEof()) { done= true; if (!IsNumber() && GetToken()->IsKeyword()) { type = GetToken()->GetKeyword(); name = GetToken()->GetString(); if (type >= Lexer::ACCELERATORS) { if (type != Lexer::STRINGTABLE && type != Lexer::LANGUAGE) { NextToken(); if (GetToken()->IsKeyword() && GetToken()->GetKeyword() >= Lexer::ACCELERATORS) { id.SetName(name); type = GetToken()->GetKeyword(); name = GetToken()->GetString(); } else if (GetToken()->IsIdentifier()) { id.SetName(name); type = -1; name =CvtString(GetToken()->GetId()); } else if (IsNumber()) { type = -2; val = GetNumber(); } else { throw new std::runtime_error("Expected resource type"); } if (type != -2) NextToken(); } else { NextToken(); } } else { throw new std::runtime_error("Expected resource identifier"); } } else { id.ReadRC(*this); if (GetToken()->IsKeyword()) { type = GetToken()->GetKeyword(); name = GetToken()->GetString(); } else if (GetToken()->IsIdentifier()) { type = -1; name = CvtString(GetToken()->GetId()); } else if (IsNumber()) { type = -2; val = GetNumber(); } else { throw new std::runtime_error("Expected resource type"); } if (type != -2) NextToken(); } ResourceInfo info(language); info.SetFlags(ResourceInfo::Moveable | ResourceInfo::Discardable); rv = NULL; switch (type) { case -1: for (int i=0 ; i < name.size(); i++) name[i] = toupper(name[i]); rv = new GenericResource(ResourceId(name), id, info); break; case -2: rv = new GenericResource(ResourceId(val), id, info); break; case Lexer::ACCELERATORS: rv = new Accelerators(id, info); break; case Lexer::TBITMAP: rv = new Bitmap(id, info); break; case Lexer::CURSOR: rv = new GroupCursor(id, info); break; case Lexer::DIALOG: rv = new Dialog(id, info, false); break; case Lexer::DIALOGEX: rv = new Dialog(id, info, true); break; case Lexer::DLGINCLUDE: rv = new DlgInclude(id, info); break; case Lexer::FONT: rv = new Font(id, info); break; case Lexer::ICON: rv = new GroupIcon(id, info); break; case Lexer::MENU: rv = new Menu(id, info, false); break; case Lexer::MENUEX: rv = new Menu(id, info, true); break; case Lexer::RCDATA: rv = new RCData(id, info); break; case Lexer::VERSIONINFO: rv = new VersionInfo(id, info); break; case Lexer::MESSAGETABLE: rv = new MessageTable(id, info); break; case Lexer::STRINGTABLE: rv = new StringTable(info); rv->ReadRC(*this); delete rv; rv = NULL; done = false; break; case Lexer::LANGUAGE: { language = GetNumber(); SkipComma(); language |= GetNumber() << 10; NeedEol(); done = false; break; } case Lexer::RCINCLUDE: { std::string name = GetFileName(); pp.IncludeFile(name); } break; default: throw new std::runtime_error("Invalid resource type"); break; } if (rv) rv->ReadRC(*this); } return rv; }
const Aws::String& S3FileRequest::GetKeyName() const { return m_keyName.length() ? m_keyName : GetFileName(); }
//////////////////////////////////////////////////////////////////////////////// // //> Name: GetFileMetaData // // Type: Function // // Description: Determines type of file and calls type-specific meta data program. // // Inputs: Ptr to pathname, current device id, meta-data struct location // // Outputs: RETCODE (0 if MetaData found, -1 if not) // // Notes: none //< //////////////////////////////////////////////////////////////////////////////// RETCODE _reentrant GetFileMetaData(INT PackedPathNameAddress, INT btCurrentDevice, FILE_META_DATA *MetaData) { RETCODE rtn = META_DATA_FOUND; WORD wExtension; WORD iStrLen; INT i; int CurrentFolder; _packed BYTE * pcFilePathName = (_packed BYTE*)PackedPathNameAddress; // check if path + filename will fit in unpacked buffer iStrLen= packed_strlen(pcFilePathName); if(iStrLen>(MAX_FILENAME_LENGTH-1)) return META_DATA_NOT_FOUND; // clear out the artist field if(MetaData->wTitle) *MetaData->wTitle = 0; if(MetaData->wArtist) *MetaData->wArtist = 0; // clear out the album field if(MetaData->wAlbum) *MetaData->wAlbum = 0; #ifdef USE_PLAYLIST3 // clear out the genre field if(MetaData->wGenre) *MetaData->wGenre = 0; // clear out the genre field if(MetaData->wYear) *MetaData->wYear = 0; #endif // Clear the genre byte MetaData->btGenre = (BYTE)0; #ifdef SYNC_LYRICS // Init. Lyric's Data Buffer SysCallFunction(RSRC_LYRICS_API_CODEBANK,LyricsInit,0,0,0); #endif #ifdef JPEG_ALBUM_ART // Initialize the APIC values SysCallFunction(RSRC_APIC_FRAME_CODEBANK, ApicInit, 0, 0, NULL); #endif if(iStrLen > 4) { // Use C Speed client Increase call // Defines are in SysSpeed.inc. Sysspeed.h is generated SysSpeedIncrease(SPEED_MAX, SPEED_CLIENT_METADATA); //find the '.' while(iStrLen--) { wExtension = packed_get(pcFilePathName,iStrLen); if(wExtension=='.') break; } if(iStrLen) { for(i=0;i<3;i++) { packed_set((void*)&wExtension,i,packed_get(pcFilePathName,++iStrLen)); } // Search file path/name for "." -- get the extension // Call Decoder Specific MetaData routine for file extension found. //pcExtString should point to ".mp3" or ".wma", etc #ifdef AUDIBLE g_AudibleFlags.bits.IsAudibleFile = FALSE; #endif switch(wExtension) { case 0x33504d: //"MP3" rtn = SysCallFunction(RSRC_MP3_METADATA_CODEBANK,GetMp3MetaData,(INT)pcFilePathName,btCurrentDevice,(void*)MetaData); #ifdef USE_PLAYLIST3 g_unicode = 0; MetaData->dwStartPos = 0; #endif break; case 0x414D57: //"WMA" #ifdef USE_PLAYLIST3 #ifdef JPEG_ALBUM_ART bPicOnlyFlag = TRUE; #endif #endif rtn = SysCallFunction(RSRC_WMA_METADATA_CODEBANK,GetWmaMetaData,(INT)pcFilePathName,btCurrentDevice,(void*)MetaData); #ifdef USE_PLAYLIST3 g_unicode = 1; MetaData->dwStartPos = 0; #endif break; case 0x564157: //"WAV" rtn = SysCallFunction(RSRC_WAV_METADATA_CODEBANK,GetWavMetaData,(INT)pcFilePathName,btCurrentDevice,(void*)MetaData); #ifdef USE_PLAYLIST3 g_unicode = 1; MetaData->dwStartPos = 0; #endif break; #ifdef MOTION_VIDEO case 0x564d53: // "SMV" rtn = SysCallFunction(RSRC_SMV_METADATA_CODEBANK,GetSMVMetaData,(INT)pcFilePathName,btCurrentDevice,(void*)MetaData); #ifdef USE_PLAYLIST3 g_unicode = 1; MetaData->dwStartPos = 0; #endif break; #endif #ifdef AUDIBLE case 0x004141: //"AA " LoadAudibleMetadataResource(RSRC_AUDIBLE_METADATA_Y, RSRC_TYPE_DATA, (_lc_u_e_AUDIBLE_METADATA_Y-_lc_u_b_AUDIBLE_METADATA_Y)*3, (int)_lc_u_b_AUDIBLE_METADATA_Y, TARGET_MEM_Y); rtn = SysCallFunction(RSRC_AUDIBLE_METADATA_P,GetAudibleMetaData,(INT)pcFilePathName,btCurrentDevice,(void*)MetaData); if ( rtn == META_DATA_FOUND ) g_AudibleFlags.bits.IsAudibleFile = TRUE; break; #endif default: rtn = META_DATA_NOT_FOUND; break; } } if(!strlen(MetaData->wTitle)){ //if the string length is zero then check if LFN or SFN is present. //!!HACK!! Following LFN will work only for current track. //Ideally, a SFN should be passed to playlists and long filename for that file should be returned. #ifdef USE_PLAYLIST1 if(SysCallFunction(RSRC_PLAYLIST_CODEBANK,Playlist_LFNGetFileName,g_iInternalTrack,0,(void*)MetaData->wTitle) >0 ) //is there a LFN #else #ifdef USE_PLAYLIST2 if(SysCallFunction(RSRC_PLAYLIST_CODEBANK,Playlist_GetLFN,TYPE_FILE,(INT) g_CurrentTrack.pFileEntry,(INT*)MetaData->wTitle) == PLAYLIST_SUCCESS) //is there a LFN #else #ifdef USE_PLAYLIST3 if (1) #else #ifdef USE_PLAYLIST5 { PL5_PL_QITEM * tmp; int recordnum; LONG fastkey; tmp = g_PL5_PL_queue.pos + g_PL5_Playback.currentplay; recordnum = tmp->file.iRecordNum; fastkey = (tmp->folder + tmp->depth - 1)->record.lFastKey; if(SysCallFunction(RSRC_PLAYLIST_CODEBANK,Playlist_GetLFN,(INT)(&fastkey), recordnum,(INT*)MetaData->wTitle) == PLAYLIST_SUCCESS) // is there a LFN #endif #endif #endif #endif // #ifdef USE_PLAYLIST1 { } else //no long file name so we must diplay the short one { GetFileName(MetaData,pcFilePathName); #ifdef USE_PLAYLIST3 g_unicode = 1; #endif } #ifdef USE_PLAYLIST5 } #endif } TrimString(MetaData->wArtist); TrimString(MetaData->wTitle); TrimString(MetaData->wAlbum); #ifdef USE_PLAYLIST3 TrimString(MetaData->wGenre); TrimString(MetaData->wYear); #endif // C Speed client free call SysSpeedClockFree(SPEED_CLIENT_METADATA); // free the shared speed resource } else rtn = META_DATA_NOT_FOUND; return rtn; }
// // Submit the log file to the log database // void Submit(const char *message) { char time[32]; Clock::Time::GetStr(time); // Copy the log to the server char path[256]; Utils::Sprintf(path, 256, "\\\\Server\\DarkReign\\Logs\\%s %s %s.log", message, time, Hardware::OS::GetUser()); // Replace ':' with '.' char *ptr = path; while (ptr && *ptr) { ptr = Utils::Strchr(ptr, ':'); if (ptr) { *(ptr++) = '.'; } } File::Copy(GetFileName(), path, TRUE); //MessageBox(NULL, message, "Unimplemented", MB_OK | MB_ICONINFORMATION | MB_TASKMODAL); /* WSADATA WSOCK_data; SOCKET WSOCK_socket; SOCKADDR_IN dst; // Start Winsock 1.1 (its all we need) if (WSAStartup(MAKEWORD(1, 1), &WSOCK_data) != 0) { return; } // Create socket if ((WSOCK_socket = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_ERROR) { WSACleanup(); return; } // Form address dst.sin_family = AF_INET; dst.sin_port = htons(25); dst.sin_addr.s_addr = inet_addr("206.17.227.140"); // Connect to the mail server if (connect(WSOCK_socket, (PSOCKADDR) &dst, sizeof (SOCKADDR_IN)) == SOCKET_ERROR) { // Could not make a connection return; } // Send mail send(WSOCK_socket, "HELO\n", 5, 0); send(WSOCK_socket, "MAIL FROM: [email protected]\n", 29, 0); send(WSOCK_socket, "RCPT TO: [email protected]\n", 37, 0); send(WSOCK_socket, "DATA\n", 5, 0); send(WSOCK_socket, "TO: Dark Reign II Logs\n", 23, 0); send(WSOCK_socket, "SUBJECT: ERROR MESSAGE\n", 23, 0); send(WSOCK_socket, "user text\n", 10, 0); send(WSOCK_socket, "log file\n", 9, 0); send(WSOCK_socket, ".\n", 2, 0); send(WSOCK_socket, "QUIT\n", 5, 0); // Close the socket close(WSOCK_socket); // Shutdown winsock WSACleanup(); */ }
void ScannerSub::Error(LPSTR str){ nErrorCount++; fprintf(lpLogFP, "%s(%d):(Scanner)%s \n", GetFileName().c_str(), GetScanline(), str); }
bool SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveDirName, bool secureMode) { if (!param) { return false; } std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName)); if (!pspFileSystem.GetFileInfo(dirPath).exists) pspFileSystem.MkDir(dirPath); u8* cryptedData = 0; int cryptedSize = 0; u8 cryptedHash[0x10]; memset(cryptedHash,0,0x10); // Encrypt save. // TODO: Is this the correct difference between MAKEDATA and MAKEDATASECURE? if (param->dataBuf != 0 && g_Config.bEncryptSave && secureMode) { cryptedSize = param->dataSize; if(cryptedSize == 0 || (SceSize)cryptedSize > param->dataBufSize) cryptedSize = param->dataBufSize; // fallback, should never use this u8 *data_ = param->dataBuf; int aligned_len = align16(cryptedSize); cryptedData = new u8[aligned_len + 0x10]; memcpy(cryptedData, data_, cryptedSize); int decryptMode = 1; if(param->key[0] != 0) { decryptMode = (GetSDKMainVersion(sceKernelGetCompiledSdkVersion()) >= 4 ? 5 : 3); } if(EncryptData(decryptMode, cryptedData, &cryptedSize, &aligned_len, cryptedHash, ((param->key[0] != 0)?param->key:0)) == 0) { } else { ERROR_LOG(HLE,"Save encryption failed. This save won't work on real PSP"); delete[] cryptedData; cryptedData = 0; } } // SAVE PARAM.SFO ParamSFOData sfoFile; std::string sfopath = dirPath+"/" + SFO_FILENAME; PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfopath); if(sfoInfo.exists) // Read old sfo if exist { u8 *sfoData = new u8[(size_t)sfoInfo.size]; size_t sfoSize = (size_t)sfoInfo.size; if(ReadPSPFile(sfopath,&sfoData,sfoSize, NULL)) { sfoFile.ReadSFO(sfoData,sfoSize); delete[] sfoData; } } // Update values sfoFile.SetValue("TITLE",param->sfoParam.title,128); sfoFile.SetValue("SAVEDATA_TITLE",param->sfoParam.savedataTitle,128); sfoFile.SetValue("SAVEDATA_DETAIL",param->sfoParam.detail,1024); sfoFile.SetValue("PARENTAL_LEVEL",param->sfoParam.parentalLevel,4); sfoFile.SetValue("CATEGORY","MS",4); sfoFile.SetValue("SAVEDATA_DIRECTORY", GetSaveDir(param, saveDirName), 64); // For each file, 13 bytes for filename, 16 bytes for file hash (0 in PPSSPP), 3 byte for padding if (secureMode) { const int FILE_LIST_ITEM_SIZE = 13 + 16 + 3; const int FILE_LIST_COUNT_MAX = 99; const int FILE_LIST_TOTAL_SIZE = FILE_LIST_ITEM_SIZE * FILE_LIST_COUNT_MAX; u32 tmpDataSize = 0; u8 *tmpDataOrig = sfoFile.GetValueData("SAVEDATA_FILE_LIST", &tmpDataSize); u8 *tmpData = new u8[FILE_LIST_TOTAL_SIZE]; if (tmpDataOrig != NULL) memcpy(tmpData, tmpDataOrig, tmpDataSize > FILE_LIST_TOTAL_SIZE ? FILE_LIST_TOTAL_SIZE : tmpDataSize); else memset(tmpData, 0, FILE_LIST_TOTAL_SIZE); if (param->dataBuf != 0) { char *fName = (char*)tmpData; for(int i = 0; i < FILE_LIST_COUNT_MAX; i++) { if(fName[0] == 0) break; // End of list if(strncmp(fName,GetFileName(param).c_str(),20) == 0) break; fName += FILE_LIST_ITEM_SIZE; } if (fName + 13 <= (char*)tmpData + FILE_LIST_TOTAL_SIZE) snprintf(fName, 13, "%s",GetFileName(param).c_str()); if (fName + 13 + 16 <= (char*)tmpData + FILE_LIST_TOTAL_SIZE) memcpy(fName+13, cryptedHash, 16); } sfoFile.SetValue("SAVEDATA_FILE_LIST", tmpData, FILE_LIST_TOTAL_SIZE, FILE_LIST_TOTAL_SIZE); delete[] tmpData; } // Init param with 0. This will be used to detect crypted save or not on loading u8 *tmpData = new u8[128]; memset(tmpData, 0, 128); sfoFile.SetValue("SAVEDATA_PARAMS", tmpData, 128, 128); delete[] tmpData; u8 *sfoData; size_t sfoSize; sfoFile.WriteSFO(&sfoData,&sfoSize); // Calc SFO hash for PSP. if(cryptedData != 0) { int offset = sfoFile.GetDataOffset(sfoData,"SAVEDATA_PARAMS"); if(offset >= 0) UpdateHash(sfoData, (int)sfoSize, offset, (param->key[0] ? 3 : 1)); } WritePSPFile(sfopath, sfoData, (SceSize)sfoSize); delete[] sfoData; if(param->dataBuf != 0) // Can launch save without save data in mode 13 { std::string filePath = dirPath+"/"+GetFileName(param); u8 *data_ = 0; SceSize saveSize = 0; if(cryptedData == 0) // Save decrypted data { saveSize = param->dataSize; if(saveSize == 0 || saveSize > param->dataBufSize) saveSize = param->dataBufSize; // fallback, should never use this data_ = param->dataBuf; } else { data_ = cryptedData; saveSize = cryptedSize; } INFO_LOG(HLE,"Saving file with size %u in %s",saveSize,filePath.c_str()); // copy back save name in request strncpy(param->saveName, saveDirName.c_str(), 20); if (!WritePSPFile(filePath, data_, saveSize)) { ERROR_LOG(HLE,"Error writing file %s",filePath.c_str()); if(cryptedData != 0) { delete[] cryptedData; } return false; } delete[] cryptedData; } // SAVE ICON0 if (param->icon0FileData.buf.Valid()) { std::string icon0path = dirPath + "/" + ICON0_FILENAME; WritePSPFile(icon0path, param->icon0FileData.buf, param->icon0FileData.bufSize); } // SAVE ICON1 if (param->icon1FileData.buf.Valid()) { std::string icon1path = dirPath + "/" + ICON1_FILENAME; WritePSPFile(icon1path, param->icon1FileData.buf, param->icon1FileData.bufSize); } // SAVE PIC1 if (param->pic1FileData.buf.Valid()) { std::string pic1path = dirPath + "/" + PIC1_FILENAME; WritePSPFile(pic1path, param->pic1FileData.buf, param->pic1FileData.bufSize); } // Save SND if (param->snd0FileData.buf.Valid()) { std::string snd0path = dirPath + "/" + SND0_FILENAME; WritePSPFile(snd0path, param->snd0FileData.buf, param->snd0FileData.bufSize); } return true; }
/* ================= idDeclTable::Parse ================= */ bool idDeclTable::Parse( const char *text, const int textLength ) { idLexer src; idToken token; float v; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); snap = false; clamp = false; values.Clear(); while ( 1 ) { if ( !src.ReadToken( &token ) ) { break; } if ( token == "}" ) { break; } if ( token.Icmp( "snap" ) == 0 ) { snap = true; } else if ( token.Icmp( "clamp" ) == 0 ) { clamp = true; } else if ( token.Icmp( "{" ) == 0 ) { while ( 1 ) { bool errorFlag; v = src.ParseFloat( &errorFlag ); if ( errorFlag ) { // we got something non-numeric MakeDefault(); return false; } values.Append( v ); src.ReadToken( &token ); if ( token == "}" ) { break; } if ( token == "," ) { continue; } src.Warning( "expected comma or brace" ); MakeDefault(); return false; } } else { src.Warning( "unknown token '%s'", token.c_str() ); MakeDefault(); return false; } } // copy the 0 element to the end, so lerping doesn't // need to worry about the wrap case float val = values[0]; // template bug requires this to not be in the Append()? values.Append( val ); return true; }
bool SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveDirName, int saveId, bool secureMode) { if (!param) { return false; } u8 *data_ = param->dataBuf; std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName)); if (saveId >= 0 && saveNameListDataCount > 0) // if user selection, use it { if (saveDataList[saveId].size == 0) // don't read no existing file { return false; } } std::string filePath = dirPath+"/"+GetFileName(param); s64 readSize; INFO_LOG(HLE,"Loading file with size %u in %s",param->dataBufSize,filePath.c_str()); u8* saveData = 0; int saveSize = -1; if (!ReadPSPFile(filePath, &saveData, saveSize, &readSize)) { ERROR_LOG(HLE,"Error reading file %s",filePath.c_str()); return false; } saveSize = (int)readSize; // copy back save name in request strncpy(param->saveName, saveDirName.c_str(), 20); ParamSFOData sfoFile; std::string sfopath = dirPath+"/" + SFO_FILENAME; PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfopath); if(sfoInfo.exists) // Read sfo { u8 *sfoData = new u8[(size_t)sfoInfo.size]; size_t sfoSize = (size_t)sfoInfo.size; if(ReadPSPFile(sfopath,&sfoData,sfoSize, NULL)) { sfoFile.ReadSFO(sfoData,sfoSize); // copy back info in request strncpy(param->sfoParam.title,sfoFile.GetValueString("TITLE").c_str(),128); strncpy(param->sfoParam.savedataTitle,sfoFile.GetValueString("SAVEDATA_TITLE").c_str(),128); strncpy(param->sfoParam.detail,sfoFile.GetValueString("SAVEDATA_DETAIL").c_str(),1024); param->sfoParam.parentalLevel = sfoFile.GetValueInt("PARENTAL_LEVEL"); } delete[] sfoData; } // Don't know what it is, but PSP always respond this and this unlock some game param->bind = 1021; bool isCrypted = IsSaveEncrypted(param, saveDirName) && secureMode; bool saveDone = false; if(isCrypted)// Try to decrypt { int align_len = align16(saveSize); u8* data_base = new u8[align_len]; u8* cryptKey = new u8[0x10]; memset(cryptKey,0,0x10); if(param->key[0] != 0) { memcpy(cryptKey, param->key, 0x10); } memset(data_base + saveSize, 0, align_len - saveSize); memcpy(data_base, saveData, saveSize); int decryptMode = 1; if(param->key[0] != 0) { decryptMode = (GetSDKMainVersion(sceKernelGetCompiledSdkVersion()) >= 4 ? 5 : 3); } if(DecryptSave(decryptMode, data_base, &saveSize, &align_len, ((param->key[0] != 0)?cryptKey:0)) == 0) { memcpy(data_, data_base, saveSize); saveDone = true; } delete[] data_base; delete[] cryptKey; } if(!saveDone) // not crypted or decrypt fail { memcpy(data_, saveData, saveSize); } param->dataSize = (SceSize)saveSize; delete[] saveData; return true; }
UINT CSafeFile::Read(void* lpBuf, UINT nCount) { if (GetPosition() + nCount > GetLength()) AfxThrowFileException(CFileException::endOfFile, 0, GetFileName()); return CFile::Read(lpBuf, nCount); }
const char *DTEDDataset::_GetProjectionRef() { // get xml and aux SR first const char* pszPrj = GDALPamDataset::_GetProjectionRef(); const char* pszVertDatum; if(pszPrj && strlen(pszPrj) > 0) return pszPrj; if (pszProjection && strlen(pszProjection) > 0) return pszProjection; pszPrj = GetMetadataItem( "DTED_HorizontalDatum"); if (EQUAL(pszPrj, "WGS84")) { pszVertDatum = GetMetadataItem("DTED_VerticalDatum"); if (EQUAL(pszVertDatum, "MSL") && CPLTestBool( CPLGetConfigOption("REPORT_COMPD_CS", "NO") ) ) { return "COMPD_CS[\"WGS 84 + EGM96 geoid height\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\",6378137,298.257223563, AUTHORITY[\"EPSG\",\"7030\"]], AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\",0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\",0.0174532925199433, AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST], AUTHORITY[\"EPSG\",\"4326\"]], VERT_CS[\"EGM96 geoid height\", VERT_DATUM[\"EGM96 geoid\",2005, AUTHORITY[\"EPSG\",\"5171\"]], UNIT[\"metre\",1, AUTHORITY[\"EPSG\",\"9001\"]], AXIS[\"Up\",UP], AUTHORITY[\"EPSG\",\"5773\"]]]"; } else { return SRS_WKT_WGS84_LAT_LONG; } } else if (EQUAL(pszPrj, "WGS72")) { static bool bWarned = false; if (!bWarned) { bWarned = true; CPLError( CE_Warning, CPLE_AppDefined, "The DTED file %s indicates WGS72 as horizontal datum. \n" "As this is outdated nowadays, you should contact your data producer to get data georeferenced in WGS84.\n" "In some cases, WGS72 is a wrong indication and the georeferencing is really WGS84. In that case\n" "you might consider doing 'gdal_translate -of DTED -mo \"DTED_HorizontalDatum=WGS84\" src.dtX dst.dtX' to\n" "fix the DTED file.\n" "No more warnings will be issued in this session about this operation.", GetFileName() ); } return "GEOGCS[\"WGS 72\",DATUM[\"WGS_1972\",SPHEROID[\"WGS 72\",6378135,298.26]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4322\"]]"; } else { static bool bWarned = false; if (!bWarned) { bWarned = true; CPLError( CE_Warning, CPLE_AppDefined, "The DTED file %s indicates %s as horizontal datum, which is not recognized by the DTED driver. \n" "The DTED driver is going to consider it as WGS84.\n" "No more warnings will be issued in this session about this operation.", GetFileName(), pszPrj ); } return SRS_WKT_WGS84_LAT_LONG; } }
UINT CSafeMemFile::Read(void* lpBuf, UINT nCount) { if (m_nPosition + nCount > m_nFileSize) AfxThrowFileException(CFileException::endOfFile, 0, GetFileName()); return CMemFile::Read(lpBuf, nCount); }
AFILE *makefp(DEBFILE *pdf, ULONG mid, ULONG instaddr, UCHAR *fname) { uchar *cp = NULL; uint segbase; uchar *srcbuf; uint Nlines; uint Tlines; SEL srcsel; SEL offsel; ushort srcseglen; ushort *offtab; AFILE *fp; int ftype; int OffsetTableBufSize; char FileNameBuffer[CCHMAXPATH]; char FileSpecBuffer[CCHMAXPATH]; UCHAR FileNameLength; LNOTAB *pLnoTabEntry; int sfi; MODULE *pModule; CSECT *pCsect; UCHAR *pFileName; UCHAR *fn; BOOL found; ULONG junk; int lno; if( fname ) { /***************************************************************************/ /* - if fname is specified, then the view is to be build using the source */ /* file name supplied by the user as in the case of getfile. */ /* - we need to find an sfi to associate with the file. */ /* - build a length-prefixed z-string from the supplied name. */ /***************************************************************************/ fn = strrchr(fname, '\\'); fn = (fn) ? (fn + 1) : fname ; pFileName = Talloc( strlen(fn) + 2 ); *pFileName = (UCHAR)strlen(fn); strcpy( pFileName+1, fn ); found = FALSE; for( sfi=mid=0, pdf = pnode->ExeStruct; pdf != NULL; pdf=pdf->next ) { mid = MapSourceFileToMidSfi( pFileName, &sfi, pdf ); if( mid && sfi ) { found = TRUE; memset(FileNameBuffer, 0, sizeof(FileNameBuffer) ); strcpy(FileNameBuffer+1, fname ); FileNameBuffer[0] = (UCHAR)strlen(fname); break; } } Tfree( pFileName ); if( found == FALSE ) return(NULL); instaddr = DBMapLno(mid, 0, sfi, &junk , pdf ); DBMapInstAddr(instaddr, &pLnoTabEntry, pdf); lno = 0; if( pLnoTabEntry ) lno = pLnoTabEntry->lno; } else { /***************************************************************************/ /* - we're going to build the view from an instruction address. */ /***************************************************************************/ if ( pdf->SrcOrAsm == SOURCE_LEVEL ) { mid = DBMapInstAddr(instaddr, &pLnoTabEntry, pdf); lno = sfi = 0; if( pLnoTabEntry ) { lno = pLnoTabEntry->lno; sfi = pLnoTabEntry->sfi; } if( (pLnoTabEntry != NULL) && (sfi != 0) ) { memset(FileNameBuffer, 0, sizeof(FileNameBuffer) ); cp = GetFileName( mid, sfi ); if( cp ) strcpy(FileNameBuffer, cp); } } } if(ftype) { findsrc(FileNameBuffer+1,FileSpecBuffer+1,sizeof(FileSpecBuffer) ); FileSpecBuffer[0] = (UCHAR)strlen(FileSpecBuffer+1); memcpy(FileNameBuffer,FileSpecBuffer,sizeof(FileSpecBuffer)); } FileNameLength = FileNameBuffer[0]; fp = (AFILE*) Talloc(SizeOfAFILE(FileNameLength)); memcpy( fp->filename, FileNameBuffer, FileNameLength+1); /****************************************************************************/ /* - allocate 64k for the source buffer. */ /* - allocate 20k for the offset buffer. */ /* - load source file into a buffer and define: */ /* - srcsel = source buffer selector. */ /* - offsel = offset buffer selector. */ /* - 0 = number of lines to skip at the beginning of the file. */ /* - srcseglen = source buffer bytes actually used by the load. */ /* - Nlines = number of source lines in the buffer. */ /* - Tlines = number of source lines in the entire file. */ /* - reallocate the source buffer to size really needed. */ /****************************************************************************/ Nlines = srcsel = offsel = 0; if( !DosAllocSeg(0,(PSEL)&srcsel,0) && !DosAllocSeg(20*1024,(PSEL)&offsel, 0) ) { LoadSource( fp->filename+1, (UCHAR *)Sel2Flat(srcsel), (USHORT *)Sel2Flat(offsel), 0, &srcseglen, &Nlines, &Tlines); if( Nlines ) DosReallocSeg(srcseglen, srcsel); } /****************************************************************************/ /* - now, define the view structure. */ /****************************************************************************/ fp->shower = showA; fp->pdf = pdf; fp->mid = mid; fp->sfi = sfi; fp->mseg = segbase; fp->Tlines = Tlines; /* number of lines in file. */ fp->Nlines = Nlines; /* number of lines in source buffer. */ fp->Nbias = 0; /* number of lines skipped in source.*/ fp->topline = 1; /* init to 1st line in the file. */ fp->csrline = lno; /* " " */ fp->hotline = lno; /* " " */ fp->hotaddr = instaddr; fp->skipcols = 0; /* columns skipped on left. */ fp->Nshown = 0; fp->topoff = instaddr; fp->csr.row = 0; fp->csr.col = 0; fp->csr.mode = CSR_NORMAL; fp->sview = NOSRC; /* assume no source disassembler view*/ fp->flags = ASM_VIEW_NEW; if( Nlines ) { srcbuf = (uchar*)Sel2Flat(srcsel); fp->source = srcbuf; /**************************************************************************/ /* Allocate the offtab[] buffer to hold Nlines + 1 offsets. We add the 1 */ /* so that we can make the offset table indices line up with the */ /* source line numbers. */ /**************************************************************************/ OffsetTableBufSize = (Nlines+1)*sizeof(USHORT); offtab = (USHORT*) Talloc(OffsetTableBufSize); memcpy(offtab + 1, (uchar*)Sel2Flat(offsel), Nlines*sizeof(USHORT) ); fp->offtab = offtab; fp->flags = 0; /* clear asm flag. */ if( Tlines > Nlines ) /* does compressed source exceed 64k?*/ fp->flags |= AF_HUGE; /* mark afile with huge file flag */ fp->shower = showC; /* display source */ fp->sview = MIXEDN; /* assume no source disassembler view*/ /* Flag all text lines for which a (line #, offset) pair exists. */ pModule = GetModuleWithAddr( instaddr, pdf ); if( pModule ) { for(pCsect = pModule->pCsects; pCsect != NULL; pCsect=pCsect->next ) { int NumEntries; NumEntries = pCsect->NumEntries; pLnoTabEntry = pCsect->pLnoTab; if( (pLnoTabEntry != NULL) && ( NumEntries > 0 ) ) { for( ; NumEntries; pLnoTabEntry++, NumEntries-- ) { if( pLnoTabEntry->sfi == sfi ) { int lno; lno = pLnoTabEntry->lno; if( (lno != 0) && (lno <= Nlines) ) { *(srcbuf + offtab[lno] - 1) |= LINE_OK; } } } } } } MarkLineBRKs( fp ); /* mark the active breakpoints */ } if( offsel ) /* if there was an offset segment */ DosFreeSeg(offsel); /* allocated then free it up */ if( !Nlines && srcsel ) /* if there was no source then */ DosFreeSeg(srcsel); /* free up the temp source buffer */ return( fp ); }
uint8 CSafeMemFile::ReadUInt8() { if (m_nPosition + sizeof(uint8) > m_nFileSize) AfxThrowFileException(CFileException::endOfFile, 0, GetFileName()); return *(m_lpBuffer + m_nPosition++); }
void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr, const char* const* aFormatNames, int32_t aWidth, int32_t aHeight, const nsAString& aStatus) { nsXPIDLString fileStr; GetFileName(fileStr); NS_ConvertASCIItoUTF16 typeStr(aTypeStr); nsXPIDLString title; if (mStringBundle) { // if we got a valid size (not all media have a size) if (aWidth != 0 && aHeight != 0) { nsAutoString widthStr; nsAutoString heightStr; widthStr.AppendInt(aWidth); heightStr.AppendInt(aHeight); // If we got a filename, display it if (!fileStr.IsEmpty()) { const PRUnichar *formatStrings[4] = {fileStr.get(), typeStr.get(), widthStr.get(), heightStr.get()}; NS_ConvertASCIItoUTF16 fmtName(aFormatNames[eWithDimAndFile]); mStringBundle->FormatStringFromName(fmtName.get(), formatStrings, 4, getter_Copies(title)); } else { const PRUnichar *formatStrings[3] = {typeStr.get(), widthStr.get(), heightStr.get()}; NS_ConvertASCIItoUTF16 fmtName(aFormatNames[eWithDim]); mStringBundle->FormatStringFromName(fmtName.get(), formatStrings, 3, getter_Copies(title)); } } else { // If we got a filename, display it if (!fileStr.IsEmpty()) { const PRUnichar *formatStrings[2] = {fileStr.get(), typeStr.get()}; NS_ConvertASCIItoUTF16 fmtName(aFormatNames[eWithFile]); mStringBundle->FormatStringFromName(fmtName.get(), formatStrings, 2, getter_Copies(title)); } else { const PRUnichar *formatStrings[1] = {typeStr.get()}; NS_ConvertASCIItoUTF16 fmtName(aFormatNames[eWithNoInfo]); mStringBundle->FormatStringFromName(fmtName.get(), formatStrings, 1, getter_Copies(title)); } } } // set it on the document if (aStatus.IsEmpty()) { SetTitle(title); } else { nsXPIDLString titleWithStatus; const nsPromiseFlatString& status = PromiseFlatString(aStatus); const PRUnichar *formatStrings[2] = {title.get(), status.get()}; NS_NAMED_LITERAL_STRING(fmtName, "TitleWithStatus"); mStringBundle->FormatStringFromName(fmtName.get(), formatStrings, 2, getter_Copies(titleWithStatus)); SetTitle(titleWithStatus); } }
/* ================ idDeclEntityDef::Parse ================ */ bool idDeclEntityDef::Parse( const char *text, const int textLength ) { idLexer src; idToken token, token2; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); src.SetFlags( DECL_LEXER_FLAGS ); src.SkipUntilString( "{" ); while (1) { if ( !src.ReadToken( &token ) ) { break; } if ( !token.Icmp( "}" ) ) { break; } if ( token.type != TT_STRING ) { src.Warning( "Expected quoted string, but found '%s'", token.c_str() ); MakeDefault(); return false; } if ( !src.ReadToken( &token2 ) ) { src.Warning( "Unexpected end of file" ); MakeDefault(); return false; } if ( dict.FindKey( token ) ) { src.Warning( "'%s' already defined", token.c_str() ); } dict.Set( token, token2 ); } // we always automatically set a "classname" key to our name dict.Set( "classname", GetName() ); // "inherit" keys will cause all values from another entityDef to be copied into this one // if they don't conflict. We can't have circular recursions, because each entityDef will // never be parsed mroe than once // find all of the dicts first, because copying inherited values will modify the dict idList<const idDeclEntityDef *> defList; while ( 1 ) { const idKeyValue *kv; kv = dict.MatchPrefix( "inherit", NULL ); if ( !kv ) { break; } const idDeclEntityDef *copy = static_cast<const idDeclEntityDef *>( declManager->FindType( DECL_ENTITYDEF, kv->GetValue(), false ) ); if ( !copy ) { src.Warning( "Unknown entityDef '%s' inherited by '%s'", kv->GetValue().c_str(), GetName() ); } else { defList.Append( copy ); } // delete this key/value pair dict.Delete( kv->GetKey() ); } // now copy over the inherited key / value pairs for ( int i = 0 ; i < defList.Num() ; i++ ) { dict.SetDefaults( &defList[ i ]->dict ); } // precache all referenced media // do this as long as we arent in modview if ( !( com_editors & (EDITOR_RADIANT|EDITOR_AAS) ) ) { game->CacheDictionaryMedia( &dict ); } return true; }
/** * Handles the end of a drag copy/move when the user releases the left mouse button. */ void MaterialTreeView::OnLButtonUp(UINT nFlags, CPoint point) { CTreeCtrl& tree = GetTreeCtrl(); if( bDragging ) { //Release mouse capture ReleaseCapture(); //Delete the drag image dragImage->DragLeave(GetDesktopWindow()); dragImage->EndDrag(); bDragging = false; delete dragImage; UINT flags; HTREEITEM item = tree.HitTest(point, &flags); if(item && (TVHT_ONITEM & flags)) { DWORD itemType = tree.GetItemData(item); if(itemType == TYPE_MATERIAL) //Backup one if a file is selected item = tree.GetParentItem(item); //Make sure we aren't dragging to the same place HTREEITEM dragItemParent = tree.GetParentItem(dragItem); if(dragItemParent != item) { idStr dragFile; GetFileName(dragItem, dragFile); idStr filename; GetFileName(item, filename); //Move within a file copy across files if(!dragFile.Icmp(filename)) { materialDocManager->CopyMaterial(materialDocManager->GetCurrentMaterialDoc(), true); } else { materialDocManager->CopyMaterial(materialDocManager->GetCurrentMaterialDoc(), false); } //Generate the name idStr materialName = GetMediaPath(item, itemType); idStr copyName = materialDocManager->GetCopyMaterialName(); idStr copyMaterialName; copyName.ExtractFileName(copyMaterialName); materialName += "/" + copyMaterialName; //If the material name already exists add numbers until we don't find it materialName = materialDocManager->GetUniqueMaterialName(materialName); //Paste materialDocManager->PasteMaterial(materialName, filename); } } } CTreeView::OnLButtonUp(nFlags, point); }
void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr, nsIChannel* aChannel, const char* const* aFormatNames, int32_t aWidth, int32_t aHeight, const nsAString& aStatus) { nsAutoString fileStr; GetFileName(fileStr, aChannel); NS_ConvertASCIItoUTF16 typeStr(aTypeStr); nsAutoString title; if (mStringBundle) { // if we got a valid size (not all media have a size) if (aWidth != 0 && aHeight != 0) { nsAutoString widthStr; nsAutoString heightStr; widthStr.AppendInt(aWidth); heightStr.AppendInt(aHeight); // If we got a filename, display it if (!fileStr.IsEmpty()) { const char16_t *formatStrings[4] = {fileStr.get(), typeStr.get(), widthStr.get(), heightStr.get()}; mStringBundle->FormatStringFromName(aFormatNames[eWithDimAndFile], formatStrings, 4, title); } else { const char16_t *formatStrings[3] = {typeStr.get(), widthStr.get(), heightStr.get()}; mStringBundle->FormatStringFromName(aFormatNames[eWithDim], formatStrings, 3, title); } } else { // If we got a filename, display it if (!fileStr.IsEmpty()) { const char16_t *formatStrings[2] = {fileStr.get(), typeStr.get()}; mStringBundle->FormatStringFromName(aFormatNames[eWithFile], formatStrings, 2, title); } else { const char16_t *formatStrings[1] = {typeStr.get()}; mStringBundle->FormatStringFromName(aFormatNames[eWithNoInfo], formatStrings, 1, title); } } } // set it on the document if (aStatus.IsEmpty()) { IgnoredErrorResult ignored; SetTitle(title, ignored); } else { nsAutoString titleWithStatus; const nsPromiseFlatString& status = PromiseFlatString(aStatus); const char16_t *formatStrings[2] = {title.get(), status.get()}; mStringBundle->FormatStringFromName("TitleWithStatus", formatStrings, 2, titleWithStatus); IgnoredErrorResult ignored; SetTitle(titleWithStatus, ignored); } }
globle int SaveFactsCommand( void *theEnv) { char *fileName; int numArgs, saveCode = LOCAL_SAVE; char *argument; DATA_OBJECT theValue; struct expr *theList = NULL; /*============================================*/ /* Check for the correct number of arguments. */ /*============================================*/ if ((numArgs = EnvArgCountCheck(theEnv,"save-facts",AT_LEAST,1)) == -1) return(FALSE); /*=================================================*/ /* Get the file name to which facts will be saved. */ /*=================================================*/ if ((fileName = GetFileName(theEnv,"save-facts",1)) == NULL) return(FALSE); /*=============================================================*/ /* If specified, the second argument to save-facts indicates */ /* whether just facts local to the current module or all facts */ /* visible to the current module will be saved. */ /*=============================================================*/ if (numArgs > 1) { if (EnvArgTypeCheck(theEnv,"save-facts",2,SYMBOL,&theValue) == FALSE) return(FALSE); argument = DOToString(theValue); if (strcmp(argument,"local") == 0) { saveCode = LOCAL_SAVE; } else if (strcmp(argument,"visible") == 0) { saveCode = VISIBLE_SAVE; } else { ExpectedTypeError1(theEnv,"save-facts",2,"symbol with value local or visible"); return(FALSE); } } /*======================================================*/ /* Subsequent arguments indicate that only those facts */ /* associated with the specified deftemplates should be */ /* saved to the file. */ /*======================================================*/ if (numArgs > 2) theList = GetFirstArgument()->nextArg->nextArg; /*====================================*/ /* Call the SaveFacts driver routine. */ /*====================================*/ if (EnvSaveFacts(theEnv,fileName,saveCode,theList) == FALSE) { return(FALSE); } return(TRUE); }
void ReadParameters() { char *Line, *Keyword, *Token, *Name; unsigned int i; ProblemFileName = PiFileName = InputTourFileName = OutputTourFileName = TourFileName = 0; CandidateFiles = MergeTourFiles = 0; AscentCandidates = 50; BackboneTrials = 0; Backtracking = 0; CandidateSetSymmetric = 0; CandidateSetType = ALPHA; Crossover = ERXT; DelaunayPartitioning = 0; DelaunayPure = 0; Excess = -1; ExtraCandidates = 0; ExtraCandidateSetSymmetric = 0; ExtraCandidateSetType = QUADRANT; Gain23Used = 1; GainCriterionUsed = 1; InitialPeriod = -1; InitialStepSize = 0; InitialTourAlgorithm = WALK; InitialTourFraction = 1.0; KarpPartitioning = 0; KCenterPartitioning = 0; KMeansPartitioning = 0; Kicks = 1; KickType = 0; MaxBreadth = INT_MAX; MaxCandidates = 5; MaxPopulationSize = 0; MaxSwaps = -1; MaxTrials = -1; MoorePartitioning = 0; MoveType = 5; NonsequentialMoveType = -1; Optimum = MINUS_INFINITY; PatchingA = 1; PatchingC = 0; PatchingAExtended = 0; PatchingARestricted = 0; PatchingCExtended = 0; PatchingCRestricted = 0; Precision = 100; RestrictedSearch = 1; RohePartitioning = 0; Runs = 0; Seed = 1; SierpinskiPartitioning = 0; StopAtOptimum = 1; Subgradient = 1; SubproblemBorders = 0; SubproblemsCompressed = 0; SubproblemSize = 0; SubsequentMoveType = 0; SubsequentPatching = 1; TimeLimit = DBL_MAX; TraceLevel = 1; if (ParameterFileName) { if (!(ParameterFile = fopen(ParameterFileName, "r"))) eprintf("Cannot open PARAMETER_FILE: \"%s\"", ParameterFileName); printff("PARAMETER_FILE = %s\n", ParameterFileName); } else { while (1) { printff("PARAMETER_FILE = "); if (!(ParameterFileName = GetFileName(ReadLine(stdin)))) { do { printff("PROBLEM_FILE = "); ProblemFileName = GetFileName(ReadLine(stdin)); } while (!ProblemFileName); return; } else if (!(ParameterFile = fopen(ParameterFileName, "r"))) printff("Cannot open \"%s\". Please try again.\n", ParameterFileName); else break; } } while ((Line = ReadLine(ParameterFile))) { if (!(Keyword = strtok(Line, Delimiters))) continue; if (Keyword[0] == '#') continue; for (i = 0; i < strlen(Keyword); i++) Keyword[i] = (char) toupper(Keyword[i]); if (!strcmp(Keyword, "ASCENT_CANDIDATES")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &AscentCandidates)) eprintf("ASCENT_CANDIDATES: integer expected"); if (AscentCandidates < 2) eprintf("ASCENT_CANDIDATES: >= 2 expected"); } else if (!strcmp(Keyword, "BACKBONE_TRIALS")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &BackboneTrials)) eprintf("BACKBONE_TRIALS: integer expected"); if (BackboneTrials < 0) eprintf("BACKBONE_TRIALS: non-negative integer expected"); } else if (!strcmp(Keyword, "BACKTRACKING")) { if (!ReadYesOrNo(&Backtracking)) eprintf("BACKTRACKING: YES or NO expected"); } else if (!strcmp(Keyword, "CANDIDATE_FILE")) { if (!(Name = GetFileName(0))) eprintf("CANDIDATE_FILE: string expected"); if (CandidateFiles == 0) { assert(CandidateFileName = (char **) malloc(sizeof(char *))); CandidateFileName[CandidateFiles++] = Name; } else { int i; for (i = 0; i < CandidateFiles; i++) if (!strcmp(Name, CandidateFileName[i])) break; if (i == CandidateFiles) { assert(CandidateFileName = (char **) realloc(CandidateFileName, (CandidateFiles + 1) * sizeof(char *))); CandidateFileName[CandidateFiles++] = Name; } } } else if (!strcmp(Keyword, "CANDIDATE_SET_TYPE")) { if (!(Token = strtok(0, Delimiters))) eprintf("%s", "CANDIDATE_SET_TYPE: " "ALPHA, DELAUNAY, NEAREST-NEIGHBOR, " "or QUADRANT expected"); for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "ALPHA", strlen(Token))) CandidateSetType = ALPHA; else if (!strncmp(Token, "DELAUNAY", strlen(Token))) { CandidateSetType = DELAUNAY; } else if (!strncmp(Token, "NEAREST-NEIGHBOR", strlen(Token))) CandidateSetType = NN; else if (!strncmp(Token, "QUADRANT", strlen(Token))) CandidateSetType = QUADRANT; else eprintf("%s", "CANDIDATE_SET_TYPE: " "ALPHA, DELAUNAY, NEAREST-NEIGHBOR, " "or QUADRANT expected"); if (CandidateSetType == DELAUNAY) { if ((Token = strtok(0, Delimiters))) { for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (strncmp(Token, "PURE", strlen(Token))) eprintf("%s", "CANDIDATE_SET_TYPE (DELAUNAY): " "PURE or no token expected"); DelaunayPure = 1; } } } else if (!strcmp(Keyword, "COMMENT")) continue; else if (!strcmp(Keyword, "EOF")) break; else if (!strcmp(Keyword, "EXCESS")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%lf", &Excess)) eprintf("EXCESS: real expected"); if (Excess < 0) eprintf("EXCESS: non-negeative real expected"); } else if (!strcmp(Keyword, "EXTRA_CANDIDATES")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &ExtraCandidates)) eprintf("EXTRA_CANDIDATES: integer expected"); if (ExtraCandidates < 0) eprintf("EXTRA_CANDIDATES: non-negative integer expected"); if ((Token = strtok(0, Delimiters))) { for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (strncmp(Token, "SYMMETRIC", strlen(Token))) eprintf ("(EXTRA_CANDIDATES) Illegal SYMMETRIC specification"); ExtraCandidateSetSymmetric = 1; } } else if (!strcmp(Keyword, "EXTRA_CANDIDATE_SET_TYPE")) { if (!(Token = strtok(0, Delimiters))) eprintf("%s", "EXTRA_CANDIDATE_SET_TYPE: " "NEAREST-NEIGHBOR, or QUADRANT expected"); for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "NEAREST-NEIGHBOR", strlen(Token))) ExtraCandidateSetType = NN; else if (!strncmp(Token, "QUADRANT", strlen(Token))) ExtraCandidateSetType = QUADRANT; else eprintf("%s", "EXTRA_CANDIDATE_SET_TYPE: " "NEAREST-NEIGHBOR or QUADRANT expected"); } else if (!strcmp(Keyword, "GAIN23")) { if (!ReadYesOrNo(&Gain23Used)) eprintf("GAIN23: YES or NO expected"); } else if (!strcmp(Keyword, "GAIN_CRITERION")) { if (!ReadYesOrNo(&GainCriterionUsed)) eprintf("GAIN_CRITERION: YES or NO expected"); } else if (!strcmp(Keyword, "INITIAL_PERIOD")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &InitialPeriod)) eprintf("INITIAL_PERIOD: integer expected"); if (InitialPeriod < 0) eprintf("INITIAL_PERIOD: non-negative integer expected"); } else if (!strcmp(Keyword, "INITIAL_STEP_SIZE")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &InitialStepSize)) eprintf("INITIAL_STEP_SIZE: integer expected"); if (InitialStepSize <= 0) eprintf("INITIAL_STEP_SIZE: positive integer expected"); } else if (!strcmp(Keyword, "INITIAL_TOUR_ALGORITHM")) { if (!(Token = strtok(0, Delimiters))) eprintf("INITIAL_TOUR_ALGORITHM: " "BORUVKA, GREEDY, MOORE, NEAREST-NEIGHBOR,\n" "QUICK-BORUVKA, SIERPINSKI, or WALK expected"); for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "BORUVKA", strlen(Token))) InitialTourAlgorithm = BORUVKA; else if (!strncmp(Token, "GREEDY", strlen(Token))) InitialTourAlgorithm = GREEDY; else if (!strncmp(Token, "MOORE", strlen(Token))) InitialTourAlgorithm = MOORE; else if (!strncmp(Token, "NEAREST-NEIGHBOR", strlen(Token))) InitialTourAlgorithm = NEAREST_NEIGHBOR; else if (!strncmp(Token, "QUICK-BORUVKA", strlen(Token))) InitialTourAlgorithm = QUICK_BORUVKA; else if (!strncmp(Token, "SIERPINSKI", strlen(Token))) InitialTourAlgorithm = SIERPINSKI; else if (!strncmp(Token, "WALK", strlen(Token))) InitialTourAlgorithm = WALK; else eprintf("INITIAL_TOUR_ALGORITHM: " "BORUVKA, GREEDY, MOORE, NEAREST-NEIGHBOR,\n" "QUICK-BORUVKA, SIERPINSKI or WALK expected"); } else if (!strcmp(Keyword, "INITIAL_TOUR_FILE")) { if (!(InitialTourFileName = GetFileName(0))) eprintf("INITIAL_TOUR_FILE: string expected"); } else if (!strcmp(Keyword, "INITIAL_TOUR_FRACTION")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%lf", &InitialTourFraction)) eprintf("INITIAL_TOUR_FRACTION: real expected"); if (InitialTourFraction < 0 || InitialTourFraction > 1) eprintf("INITIAL_TOUR_FRACTION: >= 0 or <= 1 expected"); } else if (!strcmp(Keyword, "INPUT_TOUR_FILE")) { if (!(InputTourFileName = GetFileName(0))) eprintf("INPUT_TOUR_FILE: string expected"); } else if (!strcmp(Keyword, "KICK_TYPE")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &KickType)) eprintf("KICK_TYPE: integer expected"); if (KickType != 0 && KickType < 4) eprintf("KICK_TYPE: integer >= 4 expected"); } else if (!strcmp(Keyword, "KICKS")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &Kicks)) eprintf("KICKS: integer expected"); if (Kicks < 0) eprintf("KICKS: non-negative integer expected"); } else if (!strcmp(Keyword, "MAX_BREADTH")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &MaxBreadth)) eprintf("MAX_BREADTH: integer expected"); if (MaxBreadth < 0) eprintf("MAX_BREADTH: non-negative integer expected"); } else if (!strcmp(Keyword, "MAX_CANDIDATES")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &MaxCandidates)) eprintf("MAX_CANDIDATES: integer expected"); if (MaxCandidates < 0) eprintf("MAX_CANDIDATES: non-negative integer expected"); if ((Token = strtok(0, Delimiters))) { for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "SYMMETRIC", strlen(Token))) CandidateSetSymmetric = 1; else eprintf ("(MAX_CANDIDATES) Illegal SYMMETRIC specification"); } } else if (!strcmp(Keyword, "MAX_SWAPS")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &MaxSwaps)) eprintf("MAX_SWAPS: integer expected"); if (MaxSwaps < 0) eprintf("MAX_SWAPS: non-negative integer expected"); } else if (!strcmp(Keyword, "MAX_TRIALS")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &MaxTrials)) eprintf("MAX_TRIALS: integer expected"); if (MaxTrials < 0) eprintf("MAX_TRIALS: non-negative integer expected"); } else if (!strcmp(Keyword, "MERGE_TOUR_FILE")) { if (!(Name = GetFileName(0))) eprintf("MERGE_TOUR_FILE: string expected"); if (MergeTourFiles == 0) { assert(MergeTourFileName = (char **) malloc(sizeof(char *))); MergeTourFileName[MergeTourFiles++] = Name; } else { int i; for (i = 0; i < MergeTourFiles; i++) if (!strcmp(Name, MergeTourFileName[i])) break; if (i == MergeTourFiles) { assert(MergeTourFileName = (char **) realloc(MergeTourFileName, (MergeTourFiles + 1) * sizeof(char *))); MergeTourFileName[MergeTourFiles++] = Name; } } } else if (!strcmp(Keyword, "MOVE_TYPE")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &MoveType)) eprintf("MOVE_TYPE: integer expected"); if (MoveType < 2) eprintf("MOVE_TYPE: >= 2 expected"); } else if (!strcmp(Keyword, "NONSEQUENTIAL_MOVE_TYPE")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &NonsequentialMoveType)) eprintf("NONSEQUENTIAL_MOVE_TYPE: integer expected"); if (NonsequentialMoveType < 4) eprintf("NONSEQUENTIAL_MOVE_TYPE: >= 4 expected"); } else if (!strcmp(Keyword, "OPTIMUM")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, GainInputFormat, &Optimum)) eprintf("OPTIMUM: integer expected"); } else if (!strcmp(Keyword, "OUTPUT_TOUR_FILE")) { if (!(OutputTourFileName = GetFileName(0))) eprintf("OUTPUT_TOUR_FILE: string expected"); } else if (!strcmp(Keyword, "PATCHING_A")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &PatchingA)) eprintf("PATCHING_A: integer expected"); if (PatchingA < 0) eprintf("PATCHING_A: non-negative integer expected"); if ((Token = strtok(0, Delimiters))) { for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "RESTRICTED", strlen(Token))) PatchingARestricted = 1; else if (!strncmp(Token, "EXTENDED", strlen(Token))) PatchingAExtended = 1; else eprintf("%s", "(PATCHING_A) " "Illegal RESTRICTED or EXTENDED specification"); } } else if (!strcmp(Keyword, "PATCHING_C")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &PatchingC)) eprintf("PATCHING_C: integer expected"); if (PatchingC < 0) eprintf("PATCHING_C: non-negative integer expected"); if ((Token = strtok(0, Delimiters))) { for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "RESTRICTED", strlen(Token))) PatchingCRestricted = 1; else if (!strncmp(Token, "EXTENDED", strlen(Token))) PatchingCExtended = 1; else eprintf("%s", "(PATCHING_C) ", "Illegal RESTRICTED or EXTENDED specification"); } } else if (!strcmp(Keyword, "PI_FILE")) { if (!(PiFileName = GetFileName(0))) eprintf("PI_FILE: string expected"); } else if (!strcmp(Keyword, "POPULATION_SIZE")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &MaxPopulationSize)) eprintf("POPULATION_SIZE: integer expected"); } else if (!strcmp(Keyword, "PRECISION")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &Precision)) eprintf("PRECISION: integer expected"); } else if (!strcmp(Keyword, "PROBLEM_FILE")) { if (!(ProblemFileName = GetFileName(0))) eprintf("PROBLEM_FILE: string expected"); } else if (!strcmp(Keyword, "RESTRICTED_SEARCH")) { if (!ReadYesOrNo(&RestrictedSearch)) eprintf("RESTRICTED_SEARCH: YES or NO expected"); } else if (!strcmp(Keyword, "RUNS")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &Runs)) eprintf("RUNS: integer expected"); if (Runs <= 0) eprintf("RUNS: positive integer expected"); } else if (!strcmp(Keyword, "SEED")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%u", &Seed)) eprintf("SEED: integer expected"); } else if (!strcmp(Keyword, "STOP_AT_OPTIMUM")) { if (!ReadYesOrNo(&StopAtOptimum)) eprintf("STOP_AT_OPTIMUM: YES or NO expected"); } else if (!strcmp(Keyword, "SUBGRADIENT")) { if (!ReadYesOrNo(&Subgradient)) eprintf("SUBGRADIENT: YES or NO expected"); } else if (!strcmp(Keyword, "SUBPROBLEM_TOUR_FILE")) { if (!(SubproblemTourFileName = GetFileName(0))) eprintf("SUBPROBLEM_TOUR_FILE: string expected"); } else if (!strcmp(Keyword, "SUBPROBLEM_SIZE")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &SubproblemSize)) eprintf("SUBPROBLEM_SIZE: integer expected"); if (SubproblemSize < 3) eprintf("SUBPROBLEM_SIZE: >= 3 expected"); if ((Token = strtok(0, Delimiters))) { for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "DELAUNAY", strlen(Token))) DelaunayPartitioning = 1; else if (!strncmp(Token, "KARP", max(strlen(Token), 2))) KarpPartitioning = 1; else if (!strncmp(Token, "K-CENTER", max(strlen(Token), 3))) KCenterPartitioning = 1; else if (!strncmp(Token, "K-MEANS", max(strlen(Token), 3))) KMeansPartitioning = 1; else if (!strncmp(Token, "MOORE", strlen(Token))) MoorePartitioning = 1; else if (!strncmp(Token, "ROHE", strlen(Token))) RohePartitioning = 1; else if (!strncmp(Token, "SIERPINSKI", strlen(Token))) SierpinskiPartitioning = 1; else if (!strncmp(Token, "BORDERS", strlen(Token))) SubproblemBorders = 1; else if (!strncmp(Token, "COMPRESSED", strlen(Token))) SubproblemsCompressed = 1; else eprintf ("(SUBPROBLEM_SIZE) Illegal DELAUNAY, KARP, K-CENTER, " "K-MEANS, MOORE, ROHE,\n SIERPINSKI, " "BORDERS or COMPRESSED specification"); while ((Token = strtok(0, Delimiters))) { for (i = 0; i < strlen(Token); i++) Token[i] = (char) toupper(Token[i]); if (!strncmp(Token, "BORDERS", strlen(Token))) SubproblemBorders = 1; else if (!strncmp(Token, "COMPRESSED", strlen(Token))) SubproblemsCompressed = 1; else eprintf ("(SUBPROBLEM_SIZE) Illegal BORDERS or " "COMPRESSED specification"); } } } else if (!strcmp(Keyword, "SUBSEQUENT_MOVE_TYPE")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &SubsequentMoveType)) eprintf("SUBSEQUENT_MOVE_TYPE: integer expected"); if (SubsequentMoveType != 0 && SubsequentMoveType < 2) eprintf("SUBSEQUENT_MOVE_TYPE: 0 or >= 2 expected"); } else if (!strcmp(Keyword, "SUBSEQUENT_PATCHING")) { if (!ReadYesOrNo(&SubsequentPatching)) eprintf("SUBSEQUENT_PATCHING: YES or NO expected"); } else if (!strcmp(Keyword, "TIME_LIMIT")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%lf", &TimeLimit)) eprintf("TIME_LIMIT: real expected"); if (TimeLimit < 0) eprintf("TIME_LIMIT: >= 0 expected"); } else if (!strcmp(Keyword, "TOUR_FILE")) { if (!(TourFileName = GetFileName(0))) eprintf("TOUR_FILE: string expected"); } else if (!strcmp(Keyword, "TRACE_LEVEL")) { if (!(Token = strtok(0, Delimiters)) || !sscanf(Token, "%d", &TraceLevel)) eprintf("TRACE_LEVEL: integer expected"); } else eprintf("Unknown keyword: %s", Keyword); if ((Token = strtok(0, Delimiters)) && Token[0] != '#') eprintf("Junk at end of line: %s", Token); } if (!ProblemFileName) eprintf("Problem file name is missing"); if (SubproblemSize == 0 && SubproblemTourFileName != 0) eprintf("SUBPROBLEM_SIZE specification is missing"); if (SubproblemSize > 0 && SubproblemTourFileName == 0) eprintf("SUBPROBLEM_TOUR_FILE specification is missing"); fclose(ParameterFile); free(LastLine); LastLine = 0; }
void FileTabs::RenameFile(const WString &from, const WString &to, Image icon) { int n = FindKey(from); if (n >= 0) Set(n, to, GetFileName(to.ToString()), IsNull(icon) ? NativePathIcon(to.ToString()) : icon); }
DialogSaveScreenshot::~DialogSaveScreenshot() { QSettings settings; settings.setValue("ScreenShot/LastSavedFile", GetFileName()); delete ui; }