static bool DumpResource( WResDirWindow wind, WResFileID handle, uint_16 os ) /***************************************************************************/ { bool error; char resname[15]; char typename[20]; WResTypeInfo *type; WResResInfo *res; WResLangInfo *lang; type = WResGetTypeInfo( wind ); res = WResGetResInfo( wind ); lang = WResGetLangInfo( wind ); if( CmdLineParms.Type != NULL ) { if( !WResIDCmp( CmdLineParms.Type, &(type->TypeName) ) ) { return( false ); } } if( CmdLineParms.Name != NULL ) { if( !WResIDCmp( CmdLineParms.Name, &(res->ResName) ) ) { return( false ); } } ConvertIDToStr( &(res->ResName), resname, 15 ); ConvertTypeIDToStr( &(type->TypeName), typename, 20 ); fprintf( stdout, "%-20.20s %-15.15s 0x%04X 0x%02X ", typename, resname, (int)lang->lang.lang, (int)lang->lang.sublang ); PrintUint16Flags( lang->MemoryFlags, MemFlagsOnList, MemFlagsOffList, 53 ); if( CmdLineParms.DumpContents ) { error = DumpContents( type, res, lang, handle, os ); if( error ) { return( true ); } } return( false ); }
static int DoDump(const std::string& in_filename, yasm::SourceManager& source_mgr, yasm::Diagnostic& diags) { yasm::FileManager file_mgr; // open the input file or STDIN (for filename of "-") if (in_filename == "-") { source_mgr.createMainFileIDForMemBuffer(llvm::MemoryBuffer::getSTDIN()); } else { const yasm::FileEntry* in = file_mgr.getFile(in_filename); if (!in) { diags.Report(yasm::SourceLocation(), yasm::diag::err_file_open) << in_filename; } source_mgr.createMainFileID(in, yasm::SourceLocation()); } const llvm::MemoryBuffer* in_file = source_mgr.getBuffer(source_mgr.getMainFileID()); yasm::SourceLocation sloc = source_mgr.getLocForStartOfFile(source_mgr.getMainFileID()); std::auto_ptr<yasm::ObjectFormatModule> objfmt_module(0); std::string arch_keyword, machine; if (!objfmt_keyword.empty()) { objfmt_keyword = llvm::LowercaseString(objfmt_keyword); if (!yasm::isModule<yasm::ObjectFormatModule>(objfmt_keyword)) { diags.Report(sloc, yasm::diag::err_unrecognized_object_format) << objfmt_keyword; return EXIT_FAILURE; } // Object format forced by user objfmt_module = yasm::LoadModule<yasm::ObjectFormatModule>(objfmt_keyword); if (objfmt_module.get() == 0) { diags.Report(sloc, yasm::diag::fatal_module_load) << "object format" << objfmt_keyword; return EXIT_FAILURE; } if (!objfmt_module->Taste(*in_file, &arch_keyword, &machine)) { diags.Report(sloc, yasm::diag::err_unrecognized_object_file) << objfmt_module->getKeyword(); return EXIT_FAILURE; } } else { // Need to loop through available object formats, and taste each one yasm::ModuleNames list = yasm::getModules<yasm::ObjectFormatModule>(); yasm::ModuleNames::iterator i=list.begin(), end=list.end(); for (; i != end; ++i) { objfmt_module = yasm::LoadModule<yasm::ObjectFormatModule>(*i); if (objfmt_module->Taste(*in_file, &arch_keyword, &machine)) break; } if (i == end) { diags.Report(sloc, yasm::diag::err_unrecognized_file_format); return EXIT_FAILURE; } } std::auto_ptr<yasm::ArchModule> arch_module = yasm::LoadModule<yasm::ArchModule>(arch_keyword); if (arch_module.get() == 0) { diags.Report(sloc, yasm::diag::fatal_module_load) << "architecture" << arch_keyword; return EXIT_FAILURE; } std::auto_ptr<yasm::Arch> arch = arch_module->Create(); if (!arch->setMachine(machine)) { diags.Report(sloc, yasm::diag::fatal_module_combo) << "machine" << machine << "architecture" << arch_module->getKeyword(); return EXIT_FAILURE; } yasm::Object object("", in_filename, arch.get()); if (!objfmt_module->isOkObject(object)) { diags.Report(sloc, yasm::diag::fatal_objfmt_machine_mismatch) << objfmt_module->getKeyword() << arch_module->getKeyword() << arch->getMachine(); return EXIT_FAILURE; } std::auto_ptr<yasm::ObjectFormat> objfmt = objfmt_module->Create(object); if (!objfmt->Read(source_mgr, diags)) return EXIT_FAILURE; llvm::outs() << in_filename << ": file format " << objfmt_module->getKeyword() << "\n\n"; if (show_section_headers) DumpSectionHeaders(object); if (show_symbols) DumpSymbols(object); if (show_relocs) DumpRelocs(object); if (show_contents) DumpContents(object); return EXIT_SUCCESS; }
nsresult nsMsgFolderCache::OpenMDB(const nsACString& dbName, PRBool exists) { nsresult ret=NS_OK; nsCOMPtr<nsIMdbFactory> mdbFactory; GetMDBFactory(getter_AddRefs(mdbFactory)); if (mdbFactory) { ret = mdbFactory->MakeEnv(nsnull, &m_mdbEnv); if (NS_SUCCEEDED(ret)) { nsIMdbThumb *thumb = nsnull; nsIMdbHeap* dbHeap = 0; mdb_bool dbFrozen = mdbBool_kFalse; // not readonly, we want modifiable if (m_mdbEnv) m_mdbEnv->SetAutoClear(PR_TRUE); if (exists) { mdbOpenPolicy inOpenPolicy; mdb_bool canOpen; mdbYarn outFormatVersion; nsIMdbFile* oldFile = 0; ret = mdbFactory->OpenOldFile(m_mdbEnv, dbHeap, nsCString(dbName).get(), dbFrozen, &oldFile); if ( oldFile ) { if (NS_SUCCEEDED(ret)) { ret = mdbFactory->CanOpenFilePort(m_mdbEnv, oldFile, // file to investigate &canOpen, &outFormatVersion); if (NS_SUCCEEDED(ret) && canOpen) { inOpenPolicy.mOpenPolicy_ScopePlan.mScopeStringSet_Count = 0; inOpenPolicy.mOpenPolicy_MinMemory = 0; inOpenPolicy.mOpenPolicy_MaxLazy = 0; ret = mdbFactory->OpenFileStore(m_mdbEnv, NULL, oldFile, &inOpenPolicy, &thumb); } else ret = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE; } NS_RELEASE(oldFile); // always release our file ref, store has own } } if (NS_SUCCEEDED(ret) && thumb) { mdb_count outTotal; // total somethings to do in operation mdb_count outCurrent; // subportion of total completed so far mdb_bool outDone = PR_FALSE; // is operation finished? mdb_bool outBroken; // is operation irreparably dead and broken? do { ret = thumb->DoMore(m_mdbEnv, &outTotal, &outCurrent, &outDone, &outBroken); if (ret != 0) {// mork isn't really doing NS errors yet. outDone = PR_TRUE; break; } } while (NS_SUCCEEDED(ret) && !outBroken && !outDone); // m_mdbEnv->ClearErrors(); // ### temporary... if (NS_SUCCEEDED(ret) && outDone) { ret = mdbFactory->ThumbToOpenStore(m_mdbEnv, thumb, &m_mdbStore); if (NS_SUCCEEDED(ret) && m_mdbStore) ret = InitExistingDB(); } #ifdef DEBUG_bienvenu1 DumpContents(); #endif } else // ### need error code saying why open file store failed { nsIMdbFile* newFile = 0; ret = mdbFactory->CreateNewFile(m_mdbEnv, dbHeap, nsCString(dbName).get(), &newFile); if ( newFile ) { if (NS_SUCCEEDED(ret)) { mdbOpenPolicy inOpenPolicy; inOpenPolicy.mOpenPolicy_ScopePlan.mScopeStringSet_Count = 0; inOpenPolicy.mOpenPolicy_MinMemory = 0; inOpenPolicy.mOpenPolicy_MaxLazy = 0; ret = mdbFactory->CreateNewFileStore(m_mdbEnv, dbHeap, newFile, &inOpenPolicy, &m_mdbStore); if (NS_SUCCEEDED(ret)) ret = InitNewDB(); } NS_RELEASE(newFile); // always release our file ref, store has own } } NS_IF_RELEASE(thumb); } } return ret; }