本文整理汇总了C++中readInternal函数的典型用法代码示例。如果您正苦于以下问题:C++ readInternal函数的具体用法?C++ readInternal怎么用?C++ readInternal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readInternal函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WDT_CHECK
// TODO: consider refactoring this to return error code
void WdtSocket::readEncryptionSettingsOnce(int timeoutMs) {
if (!encryptionParams_.isSet() || encryptionSettingsRead_) {
return;
}
WDT_CHECK(!encryptionParams_.getSecret().empty());
int numRead = readInternal(buf_, 1, timeoutMs, true);
if (numRead != 1) {
LOG(ERROR) << "Failed to read encryption settings " << numRead << " "
<< port_;
return;
}
if (buf_[0] != Protocol::ENCRYPTION_CMD) {
LOG(ERROR) << "Expected to read ENCRYPTION_CMD(e), but got " << buf_[0];
readErrorCode_ = UNEXPECTED_CMD_ERROR;
return;
}
int toRead = Protocol::kMaxEncryption - 1; // already read 1 byte for cmd
numRead = readInternal(buf_, toRead,
threadCtx_.getOptions().read_timeout_millis, true);
if (numRead != toRead) {
LOG(ERROR) << "Failed to read encryption settings " << numRead << " "
<< toRead << " " << port_;
readErrorCode_ = SOCKET_READ_ERROR;
return;
}
int64_t off = 0;
EncryptionType encryptionType;
std::string iv;
if (!Protocol::decodeEncryptionSettings(buf_, off, Protocol::kMaxEncryption,
encryptionType, iv)) {
LOG(ERROR) << "Failed to decode encryption settings";
readErrorCode_ = PROTOCOL_ERROR;
return;
}
if (encryptionType != encryptionParams_.getType()) {
LOG(ERROR) << "Encryption type mismatch "
<< encryptionTypeToStr(encryptionType) << " "
<< encryptionTypeToStr(encryptionParams_.getType());
readErrorCode_ = PROTOCOL_ERROR;
return;
}
if (!decryptor_.start(encryptionParams_, iv)) {
readErrorCode_ = ENCRYPTION_ERROR;
return;
}
LOG(INFO) << "Successfully read encryption settings " << port_ << " "
<< encryptionTypeToStr(encryptionType);
encryptionSettingsRead_ = true;
}
示例2: ALOGV
void NuCachedSource2::onRead(const sp<AMessage> &msg) {
ALOGV("onRead");
int64_t offset;
CHECK(msg->findInt64("offset", &offset));
void *data;
CHECK(msg->findPointer("data", &data));
size_t size;
CHECK(msg->findSize("size", &size));
ssize_t result = readInternal(offset, data, size);
if (result == -EAGAIN) {
msg->post(50000);
return;
}
Mutex::Autolock autoLock(mLock);
if (mDisconnecting) {
mCondition.signal();
return;
}
CHECK(mAsyncResult == NULL);
mAsyncResult = new AMessage;
mAsyncResult->setInt32("result", result);
mCondition.signal();
}
示例3: ASSERT
void FileReader::readAsDataURL(Blob* blob, ExceptionState& exceptionState)
{
ASSERT(blob);
WTF_LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", utf8BlobUUID(blob).data(), utf8FilePath(blob).data());
readInternal(blob, FileReaderLoader::ReadAsDataURL, exceptionState);
}
示例4: WDT_CHECK_GT
int WdtSocket::readWithTimeout(char *buf, int nbyte, int timeoutMs,
bool tryFull) {
WDT_CHECK_GT(nbyte, 0);
if (readErrorCode_ != OK && readErrorCode_ != WDT_TIMEOUT) {
WLOG(ERROR) << "Socket read failed before, not trying to read again "
<< port_;
return -1;
}
readErrorCode_ = OK;
int numRead = 0;
readEncryptionSettingsOnce(timeoutMs);
if (supportUnencryptedPeer_ && readErrorCode_ == UNEXPECTED_CMD_ERROR) {
WLOG(WARNING)
<< "Turning off encryption since the other side does not support "
"encryption "
<< port_;
readErrorCode_ = OK;
buf[0] = buf_[0];
numRead = 1;
// also turn off encryption
encryptionParams_.erase();
} else if (readErrorCode_ != OK) {
return -1;
}
if (nbyte == numRead) {
return nbyte;
}
bool encrypt = encryptionParams_.isSet();
int ret = readInternal(buf + numRead, nbyte - numRead, timeoutMs, tryFull);
if (ret >= 0) {
numRead += ret;
} else {
return (numRead > 0 ? numRead : -1);
}
if (!encrypt) {
return numRead;
}
int numDecrypted = 0;
if (ctxSaveOffset_ >= 0) {
if (ctxSaveOffset_ <= numRead) {
if (!decryptor_.decrypt(buf, ctxSaveOffset_, buf)) {
readErrorCode_ = ENCRYPTION_ERROR;
return -1;
}
decryptor_.saveContext();
numDecrypted = ctxSaveOffset_;
ctxSaveOffset_ = CTX_SAVED;
} else {
ctxSaveOffset_ -= numRead;
}
}
// have to decrypt data
if (!decryptor_.decrypt((buf + numDecrypted), (numRead - numDecrypted),
(buf + numDecrypted))) {
readErrorCode_ = ENCRYPTION_ERROR;
return -1;
}
return numRead;
}
示例5: LOG
void FileReader::readAsArrayBuffer(Blob* blob, ExceptionCode& ec)
{
if (!blob)
return;
LOG(FileAPI, "FileReader: reading as array buffer: %s %s\n", blob->url().string().utf8().data(), blob->isFile() ? static_cast<File*>(blob)->path().utf8().data() : "");
readInternal(blob, FileReaderLoader::ReadAsArrayBuffer, ec);
}
示例6: LOG
void FileReader::readAsDataURL(Blob* blob, ExceptionCode& ec)
{
if (!blob)
return;
LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", blob->url().string().utf8().data(), is<File>(*blob) ? downcast<File>(*blob).path().utf8().data() : "");
readInternal(blob, FileReaderLoader::ReadAsDataURL, ec);
}
示例7: LOG
void FileReader::readAsDataURL(Blob* blob, ExceptionCode& ec)
{
if (!blob)
return;
LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", utf8BlobURL(blob).data(), utf8FilePath(blob).data());
readInternal(blob, FileReaderLoader::ReadAsDataURL, ec);
}
示例8: return
int
LSM9DS1_G::readY()
{
int data = 0;
if (readInternal(AG_GYR_Y_H, AG_GYR_Y_L, &data)) {
_y = data;
}
// Decode Gyroscope y-axis [mdps measurement unit]
return (g_lsb_sentivity * _y);
}
示例9: Q_ASSERT
KoFilter::ConversionStatus XlsxXmlDocumentReader::read(MSOOXML::MsooXmlReaderContext* context)
{
m_context = dynamic_cast<XlsxXmlDocumentReaderContext*>(context);
Q_ASSERT(m_context);
const KoFilter::ConversionStatus result = readInternal();
m_context = 0;
if (result == KoFilter::OK)
return KoFilter::OK;
return result;
}
示例10: LOG
void FileReader::readAsDataURL(Blob* blob)
{
if (!blob)
return;
LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", blob->url().string().utf8().data(), blob->isFile() ? static_cast<File*>(blob)->path().utf8().data() : "");
m_fileType = blob->type();
readInternal(blob, ReadFileAsDataURL);
}
示例11: WTF_LOG
void FileReader::readAsDataURL(Blob* blob, ExceptionState& exceptionState)
{
if (!blob) {
exceptionState.throwTypeError("The argument is not a Blob.");
return;
}
WTF_LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", utf8BlobUUID(blob).data(), utf8FilePath(blob).data());
readInternal(blob, FileReaderLoader::ReadAsDataURL, exceptionState);
}
示例12: Q_ASSERT
KoFilter::ConversionStatus XlsxXmlCommentsReader::read(MSOOXML::MsooXmlReaderContext* context)
{
m_context = dynamic_cast<XlsxXmlCommentsReaderContext*>(context);
Q_ASSERT(m_context);
m_colorIndices = m_context->colorIndices;
m_themes = m_context->themes;
const KoFilter::ConversionStatus result = readInternal();
m_context = 0;
if (result == KoFilter::OK)
return KoFilter::OK;
return result;
}
示例13: sectorSize
bool X86AtaDevice::read(uint64_t address, uint16_t *buf, size_t sectors)
{
if (sectors == 0) return false;
if (sectors > 10) {
size_t const bufIncr = sectorSize() / sizeof(uint16_t);
bool success = true;
for (size_t offset = 0; offset < sectors; offset += 10) {
size_t const bufOffset = bufIncr * offset;
size_t sectorsToRead = sectors - offset < 10 ? sectors - offset : 10;
success = readInternal(address + offset, buf + bufOffset, sectorsToRead);
if (!success) {
break;
}
}
return success;
} else {
return readInternal(address, buf, sectors);
}
}
示例14: Q_ASSERT
KoFilter::ConversionStatus XlsxXmlCommentsReader::read(MSOOXML::MsooXmlReaderContext* context)
{
m_context = dynamic_cast<XlsxXmlCommentsReaderContext*>(context);
Q_ASSERT(m_context);
m_colorIndices = m_context->colorIndices;
m_themes = m_context->themes;
const KoFilter::ConversionStatus result = readInternal();
m_context = 0;
if (result != KoFilter::OK) {
kWarning() << "Failure reading the comments";
}
// We're not going to fail reading the whole file because the comments cannot be read
return KoFilter::OK;
}