nsresult nsMsgSearchValidityTable::ValidateTerms (nsISupportsArray *searchTerms) { nsresult err = NS_OK; PRUint32 count; NS_ENSURE_ARG(searchTerms); searchTerms->Count(&count); for (PRUint32 i = 0; i < count; i++) { nsCOMPtr<nsIMsgSearchTerm> pTerm; searchTerms->QueryElementAt(i, NS_GET_IID(nsIMsgSearchTerm), (void **)getter_AddRefs(pTerm)); nsIMsgSearchTerm *iTerm = pTerm; nsMsgSearchTerm *term = static_cast<nsMsgSearchTerm *>(iTerm); // XP_ASSERT(term->IsValid()); bool enabled; bool available; GetEnabled(term->m_attribute, term->m_operator, &enabled); GetAvailable(term->m_attribute, term->m_operator, &available); if (!enabled || !available) { bool validNotShown; GetValidButNotShown(term->m_attribute, term->m_operator, &validNotShown); if (!validNotShown) err = NS_MSG_ERROR_INVALID_SEARCH_SCOPE; } } return err; }
size_type StreamChild::Read(void* pData, size_type nSize) { if(mnAccessFlags) // If open... { // We have a potential problem here with respect to multi-threaded // access to the parent. With multi-threaded usage of mpStreamParent // it's possible that a second thread could alter the position of // the parent stream between the SetPosition and Read calls below. if(mpStreamParent->SetPosition((off_type)(mnPositionParent + mnPosition))) { size_type nAvailable(GetAvailable()); if (nAvailable < nSize) // allow read to end of our range { nSize = nAvailable; } if(mpStreamParent->Read(pData, nSize) == nSize) { mnPosition += nSize; return nSize; } } } return kSizeTypeError; }
nsresult nsMsgSearchValidityTable::ValidateTerms(nsIArray *searchTerms) { nsresult rv = NS_OK; uint32_t count; NS_ENSURE_ARG_POINTER(searchTerms); searchTerms->GetLength(&count); for (uint32_t i = 0; i < count; i++) { nsCOMPtr<nsIMsgSearchTerm> pTerm = do_QueryElementAt(searchTerms, i); nsIMsgSearchTerm *iTerm = pTerm; nsMsgSearchTerm *term = static_cast<nsMsgSearchTerm *>(iTerm); // XP_ASSERT(term->IsValid()); bool enabled; bool available; rv = GetEnabled(term->m_attribute, term->m_operator, &enabled); NS_ENSURE_SUCCESS(rv, rv); rv = GetAvailable(term->m_attribute, term->m_operator, &available); NS_ENSURE_SUCCESS(rv, rv); if (!enabled || !available) { bool validNotShown; rv = GetValidButNotShown(term->m_attribute, term->m_operator, &validNotShown); NS_ENSURE_SUCCESS(rv, rv); if (!validNotShown) return NS_MSG_ERROR_INVALID_SEARCH_SCOPE; } } return rv; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Operand* ScopedExpressionTable::Get(Instruction* instr) { Expression expr = valNumber_->CreateExpession(instr); unsigned valNumb = GetValueNumber(expr, instr->GetDestinationOp()); if(auto availInstr = GetAvailable(valNumb)) { return availInstr; } else return nullptr; }
nsresult nsMsgSearchValidityTable::GetNumAvailAttribs(int32_t *aResult) { m_numAvailAttribs = 0; for (int i = 0; i < nsMsgSearchAttrib::kNumMsgSearchAttributes; i++) for (int j = 0; j < nsMsgSearchOp::kNumMsgSearchOperators; j++) { bool available; GetAvailable(i, j, &available); if (available) { m_numAvailAttribs++; break; } } *aResult = m_numAvailAttribs; return NS_OK; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Operand* ScopedExpressionTable::GetOrInsert(Instruction* instr) { DebugValidator::IsNotNull(instr); Expression expr = valNumber_->CreateExpession(instr); unsigned valNumb = GetValueNumber(expr, instr->GetDestinationOp()); // Try to get an available instruction with this value number. if(auto availInstr = GetAvailable(valNumb)) { return availInstr; } // Make this instruction available for further queries. InsertAvailable(valNumb, instr->GetDestinationOp()); return nullptr; }
nglString nuiTCPClient::GetDesc() const { nuiNetworkHost source(0, 0, nuiNetworkHost::eTCP); nuiNetworkHost dest(0, 0, nuiNetworkHost::eTCP); GetLocalHost(source); GetDistantHost(dest); uint32 S = source.GetIP(); uint32 D = dest.GetIP(); uint8* s = (uint8*)&S; uint8* d = (uint8*)&D; nglString str; str.CFormat("%5d: %s - from %d.%d.%d.%d:%d --> %d.%d.%d.%d:%d | i:%d / o:%d / a:%d / r:%lld / s:%lld| pool: %p%s [ %s ]", GetSocket(), IsNonBlocking() ? "NoBlock" : "Block ", s[0], s[1], s[2], s[3], ntohs(source.GetPort()), d[0], d[1], d[2], d[3], ntohs(dest.GetPort()), (int)mIn.GetSize(), (int)mOut.GetSize(), GetAvailable(), mReceived, mSent, mpPool, (mpAutoPool?" (auto)":""), mName.GetChars()); return str; }
STDMETHODIMP CStreamSwitcherPassThru::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) { CallPeerSeeking(GetAvailable(pEarliest, pLatest)); }
/*---------------------------------------------------------------------- | NPT_InputStream::Load +---------------------------------------------------------------------*/ NPT_Result NPT_InputStream::Load(NPT_DataBuffer& buffer, NPT_Size max_read /* = 0 */) { NPT_Result result; NPT_Size total_bytes_read; // reset the buffer buffer.SetDataSize(0); // try to get the stream size NPT_Size size; if (NPT_SUCCEEDED(GetSize(size))) { // make sure we don't read more than max_read if (max_read && max_read < size) size = max_read; } else { size = max_read; } // pre-allocate the buffer if (size) NPT_CHECK(buffer.Reserve(size)); // read the data from the file total_bytes_read = 0; do { NPT_Size available = 0; NPT_Size bytes_to_read; NPT_Size bytes_read; NPT_Byte* data; // check if we know how much data is available result = GetAvailable(available); if (NPT_SUCCEEDED(result) && available) { // we know how much is available bytes_to_read = available; } else { bytes_to_read = NPT_INPUT_STREAM_LOAD_DEFAULT_READ_CHUNK; } // make sure we don't read more than what was asked if (size != 0 && total_bytes_read+bytes_to_read>size) { bytes_to_read = size-total_bytes_read; } // stop if we've read everything if (bytes_to_read == 0) break; // ensure that the buffer has enough space NPT_CHECK(buffer.Reserve(total_bytes_read+bytes_to_read)); // read the data data = buffer.UseData()+total_bytes_read; result = Read((void*)data, bytes_to_read, &bytes_read); if (NPT_SUCCEEDED(result) && bytes_read != 0) { total_bytes_read += bytes_read; buffer.SetDataSize(total_bytes_read); } } while(NPT_SUCCEEDED(result) && (size==0 || total_bytes_read < size)); if (result == NPT_ERROR_EOS) { return NPT_SUCCESS; } else { return result; } }