void be_attribute::GenerateVirtual ( be_Source& source, const DDS_StdString& className ) { ostream & os = source.Stream(); be_Tab tab(source); DDS_StdString responsibility = NameToString(name()); if (fieldType) { // PURE VIRTUAL GET ATTRIBUTE os << tab << "virtual " << GetSignature(AT_Declaration, className); os << " = 0;" << nl; // PURE VIRTUAL SET ATTRIBUTE if (!readonly()) { os << tab << "virtual " << SetSignature(AT_Declaration, className, pbtrue); os << " = 0;" << nl; } } }
void be_attribute::Generate (be_ClientImplementation & source) { GenerateGetStub (source); if (!readonly ()) { GenerateSetStub (source); } }
static inline bool readonly(const std::string &path) { int rv; struct statvfs st; rv = ::statvfs(path.c_str(),&st); if(STATVFS_FAILED(rv)) return false; return readonly(st); }
void KHeap::expand( uint32_t new_size ) { // Sanity check. ASSERT(new_size>end_address()-start_address()); // Get the nearest following page boundary. if( (new_size&0xFFFFF000)!=0 ) { new_size &= 0xFFFFF000; new_size += 0x1000; } // Make sure we are not overreaching ourselves. ASSERT( start_address()+new_size<=max_address()); // This should always be on a page boundary. uint32_t old_size=end_address()-start_address(); uint32_t i=old_size; while( i<new_size ) { paging.alloc_frame( paging.get_page(start_address()+i, true, paging.kernel_directory), supervisor(), !readonly() ); i += 0x1000 /* page size */; } end_address( start_address()+new_size ); }
void be_attribute::GenerateImpureRequestCall(be_ClientImplementation& source) { be_AttStubGenerator getStub ( enclosingScope, getOpKey, LocalName (), GetSignature (AT_Implementation, InterfaceBasename (), pbfalse), fieldType, FALSE ); getStub.Generate(source); if (!readonly()) { DDS_StdString setArg ("_nval_"); DDS_StdString setSignature = SetSignature ( AT_Implementation, InterfaceBasename(), FALSE, setArg ); be_AttStubGenerator setStub ( enclosingScope, setOpKey, LocalName(), setSignature, fieldType, pbtrue ); setStub.Generate(source); } }
//------------------------------------------------------------------------------------- bool TelnetHandler::processCommand() { if(command_.size() == 0) { sendNewLine(); return true; } if(state_ == TELNET_STATE_PASSWD) { if(command_ == pTelnetServer_->passwd()) { state_ = (TELNET_STATE)pTelnetServer_->deflayer(); std::string s = getWelcome(); pEndPoint_->send(s.c_str(), s.size()); command_ = ""; sendEnter(); sendNewLine(); return true; } else { command_ = ""; sendNewLine(); return true; } } bool logcmd = true; //for(int i=0; i<(int)historyCommand_.size(); ++i) { //if(historyCommand_[i] == command_) //{ // logcmd = false; // break; //} } if(logcmd) { historyCommand_.push_back(command_); historyCommandCheck(); historyCommandIndex_ = historyCommand_.size() - 1; } std::string cmd = command_; command_ = ""; if(cmd == ":python") { if(pTelnetServer_->pScript() == NULL) return true; state_ = TELNET_STATE_PYTHON; sendNewLine(); return true; } else if(cmd == ":help") { std::string str = help(); pEndPoint_->send(str.c_str(), str.size()); sendNewLine(); return true; } else if(cmd == ":root") { sendNewLine(); state_ = TELNET_STATE_ROOT; return true; } else if(cmd == ":quit") { state_ = TELNET_STATE_QUIT; pTelnetServer_->closeHandler((*pEndPoint_), this); return false; } else if(cmd.find(":cprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":cprofile"), strlen(":cprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetCProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } else if(cmd.find(":pyprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":pyprofile"), strlen(":pyprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetPyProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } else if(cmd.find(":eventprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":eventprofile"), strlen(":eventprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetEventProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } else if(cmd.find(":networkprofile") == 0) { uint32 timelen = 10; cmd.erase(cmd.find(":networkprofile"), strlen(":networkprofile")); if(cmd.size() > 0) { try { KBEngine::StringConv::str2value(timelen, cmd.c_str()); } catch(...) { timelen = 10; } if(timelen < 1 || timelen > 999999999) timelen = 10; } std::string str = fmt::format("Waiting for {} secs.\r\n", timelen); pEndPoint_->send(str.c_str(), str.size()); std::string profileName = KBEngine::StringConv::val2str(KBEngine::genUUID64()); if(pProfileHandler_) pProfileHandler_->destroy(); pProfileHandler_ = new TelnetNetworkProfileHandler(this, *pTelnetServer_->pNetworkInterface(), timelen, profileName, pEndPoint_->addr()); readonly(); return false; } if(state_ == TELNET_STATE_PYTHON) { processPythonCommand(cmd); } sendNewLine(); return true; }
//############################################################################## //############################################################################## std::string BerkeleyDBCXXDb::get_record(record_type type, const std::string& key) const { RANGE_LOG_TIMED_FUNCTION(); std::string fullkey = key_name(type, key); auto txn = current_txn_.lock(); if(txn) { std::string data; if(txn->get_record(type, key, data)) { return data; } } auto lck = boost::dynamic_pointer_cast<BerkeleyDBCXXLock>(this->read_lock(type, key)); DbTxn * dbtxn = BerkeleyDBCXXLockTxnGetter(lck).txn(); Dbt dbkey { (void*) fullkey.c_str(), (uint32_t) fullkey.size() }; size_t bufsize = 131072; std::unique_ptr<char[]> buf { nullptr }; Dbt dbdata; int dbrval = 0; do { if(buf) { LOG(debug0, "resizing_record_buffer") << bufsize; } buf = std::unique_ptr<char[]>(new char[bufsize]); if(!buf) { std::stringstream s; s << "Unable to allocate buffer of size: " << bufsize; THROW_STACK(DatabaseEnvironmentException(s.str())); } dbdata = Dbt(buf.get(), bufsize); dbdata.set_ulen(bufsize); dbdata.set_flags(DB_DBT_USERMEM); bufsize *= 2; int flags = lck->readonly() ? 0 : DB_RMW; try { dbrval = inst_->get(dbtxn, &dbkey, &dbdata, flags); } catch (DbException &e) { if(e.get_errno() == DB_BUFFER_SMALL) { continue; } THROW_STACK(DatabaseEnvironmentException(std::string("Unable to read record") + e.what())); } catch (std::exception &e) { THROW_STACK(DatabaseEnvironmentException(std::string("Unable to read record") + e.what())); } } while(dbrval == DB_BUFFER_SMALL); switch(dbrval) { case 0: break; case DB_NOTFOUND: return std::string(); case DB_BUFFER_SMALL: THROW_STACK(DatabaseEnvironmentException("The requested item could not be returned due to undersized buffer.")); break; case DB_LOCK_DEADLOCK: THROW_STACK(DatabaseEnvironmentException("A transactional database environment operation was selected to resolve a deadlock.")); break; case DB_LOCK_NOTGRANTED: THROW_STACK(DatabaseEnvironmentException("unable to grant a lock in the allowed time.")); break; case DB_REP_HANDLE_DEAD: THROW_STACK(DatabaseEnvironmentException("Dead handle")); break; default: LOG(error, "unknown dbrval") << dbrval; } std::string rval { (char *) dbdata.get_data(), dbdata.get_size() }; return rval; }