void writeUDIFResourceFile(AbstractFile* file, UDIFResourceFile* o) { writeUInt32(file, o->fUDIFSignature); writeUInt32(file, o->fUDIFVersion); writeUInt32(file, o->fUDIFHeaderSize); writeUInt32(file, o->fUDIFFlags); writeUInt64(file, o->fUDIFRunningDataForkOffset); writeUInt64(file, o->fUDIFDataForkOffset); writeUInt64(file, o->fUDIFDataForkLength); writeUInt64(file, o->fUDIFRsrcForkOffset); writeUInt64(file, o->fUDIFRsrcForkLength); writeUInt32(file, o->fUDIFSegmentNumber); writeUInt32(file, o->fUDIFSegmentCount); writeUDIFID(file, &(o->fUDIFSegmentID)); writeUDIFChecksum(file, &(o->fUDIFDataForkChecksum)); writeUInt64(file, o->fUDIFXMLOffset); writeUInt64(file, o->fUDIFXMLLength); ASSERT(file->write(file, &(o->reserved1), 0x78) == 0x78, "fwrite"); writeUDIFChecksum(file, &(o->fUDIFMasterChecksum)); writeUInt32(file, o->fUDIFImageVariant); writeUInt64(file, o->fUDIFSectorCount); writeUInt32(file, o->reserved2); writeUInt32(file, o->reserved3); writeUInt32(file, o->reserved4); }
uint32 HeaderInfo::write(std::ostream &rw) { writeUInt32(type, rw); writeUInt32(length, rw); // Write the packed version. rw.write((const char*)&this->packedVersion, sizeof(this->packedVersion)); return 3*sizeof(uint32); }
void writeUDIFChecksum(AbstractFile* file, UDIFChecksum* o) { int i; writeUInt32(file, o->type); writeUInt32(file, o->size); for(i = 0; i < o->size; i++) { writeUInt32(file, o->data[i]); } }
void CCMIAdapter::resetController() { PAGED_CODE(); DBGPRINT(("CCMIAdapter[%p]::resetController()", this)); writeUInt32(REG_INTHLDCLR, 0); #if OUT_CHANNEL == 1 writeUInt32(REG_FUNCTRL0, ADC_CH0 | (RST_CH0 | RST_CH1)); writeUInt32(REG_FUNCTRL0, ADC_CH0 & ~(RST_CH0 | RST_CH1)); #else writeUInt32(REG_FUNCTRL0, ADC_CH1 | (RST_CH0 | RST_CH1)); writeUInt32(REG_FUNCTRL0, ADC_CH1 & ~(RST_CH0 | RST_CH1)); #endif KeStallExecutionProcessor(100L); writeUInt32(REG_FUNCTRL0, 0); writeUInt32(REG_FUNCTRL1, 0); writeUInt32(REG_CHFORMAT, 0); writeUInt32(REG_MISCCTRL, EN_DBLDAC); #if OUT_CHANNEL == 1 setUInt32Bit(REG_MISCCTRL, XCHG_DAC); #endif setUInt32Bit(REG_FUNCTRL1, BREQ); writeMixer(0, 0); return; }
void QPAGenerator::generate() { writeHeader(); writeGMap(); writeBlock(QFontEngineQPA::GlyphBlock, QByteArray()); dev->seek(4); // position of header.lock writeUInt32(0); }
void BaseSerializedObj::writeUInt32Array(uint32_t array[], uint64_t s) { writeUInt64(s); uint64_t i = 0; while ( i!=s ) { writeUInt32(array[i]); i++; } }
void QPAGenerator::writeBlock(QFontEngineQPA::BlockTag tag, const QByteArray &data) { writeUInt16(tag); writeUInt16(0); // padding const int padSize = ((data.size() + 3) / 4) * 4 - data.size(); writeUInt32(data.size() + padSize); dev->write(data); for (int i = 0; i < padSize; ++i) writeUInt8(0); }
void BinaryOutput::writeString32(const char* s) { // Write the NULL and count it size_t len = strlen(s) + 1; writeUInt32((uint32)len); debugAssert(m_beginEndBits == 0); reserveBytes(len); System::memcpy(m_buffer + m_pos, s, len); m_pos += len; }
CString IClipboard::marshall(const IClipboard* clipboard) { assert(clipboard != NULL); CString data; std::vector<CString> formatData; formatData.resize(IClipboard::kNumFormats); // FIXME -- use current time clipboard->open(0); // compute size of marshalled data UInt32 size = 4; UInt32 numFormats = 0; for (UInt32 format = 0; format != IClipboard::kNumFormats; ++format) { if (clipboard->has(static_cast<IClipboard::EFormat>(format))) { ++numFormats; formatData[format] = clipboard->get(static_cast<IClipboard::EFormat>(format)); size += 4 + 4 + (UInt32)formatData[format].size(); } } // allocate space data.reserve(size); // marshall the data writeUInt32(&data, numFormats); for (UInt32 format = 0; format != IClipboard::kNumFormats; ++format) { if (clipboard->has(static_cast<IClipboard::EFormat>(format))) { writeUInt32(&data, format); writeUInt32(&data, (UInt32)formatData[format].size()); data += formatData[format]; } } clipboard->close(); return data; }
void QPAGenerator::writeGMap() { const quint16 glyphCount = fe->glyphCount(); writeUInt16(QFontEngineQPA::GMapBlock); writeUInt16(0); // padding writeUInt32(glyphCount * 4); QByteArray &buffer = dev->buffer(); const int numBytes = glyphCount * sizeof(quint32); qint64 pos = buffer.size(); buffer.resize(pos + numBytes); qMemSet(buffer.data() + pos, 0xff, numBytes); dev->seek(pos + numBytes); }
void ofxVideoGrabber::toggleRecord() { if(f == NULL) { setpriority(PRIO_PROCESS, 0, -20); char *buf = new char[PATH_MAX]; time_t t = time(0); tm now=*localtime(&t); strftime(buf, PATH_MAX-1, "/Users/chris/capture_video_%Y%m%d%H%M%S.ser", &now); ofLog(OF_LOG_NOTICE, buf); f = fopen(buf, "w"); writeString("LUCAM-RECORDER"); writeUInt32(0); // LuID (0 = unknown) writeUInt32(0); // ColorID (0 = MONO) writeUInt32(0); // LittleEndian (0 = Big endian) writeUInt32(width); // ImageWidth writeUInt32(height); // ImageHeight writeUInt32(bpp * 8); // PixelDepth writeUInt32(0); // FrameCount struct passwd *pwent = getpwuid(getuid()); sprintf(buf, "%s", pwent->pw_gecos); padString(buf, 40); writeString(buf); sprintf(buf, "%s", videoGrabber->getCameraModel()); padString(buf, 40); writeString(buf); sprintf(buf, "Lunt LS60THa"); padString(buf, 40); writeString(buf); writeUInt64(0); // DateTime writeUInt64(0); // DateTime_UTC writtenFrames = 0; } else { fseek(f, 38, SEEK_SET); writeUInt32(writtenFrames); fclose(f); f = NULL; setpriority(PRIO_PROCESS, 0, 0); } }
void DataOutputStream::writeUTF8(const TCHAR *string) { int sizeInBytes = 0; char *buffer = NULL; StringStorage storage(string); storage.toUTF8String(NULL, &sizeInBytes); buffer = new char[sizeInBytes]; storage.toUTF8String(buffer, &sizeInBytes); try { writeUInt32((unsigned int)sizeInBytes); writeFully(buffer, sizeInBytes); } catch (...) { delete[] buffer; throw; } delete[] buffer; }
STDMETHODIMP_(NTSTATUS) CCMIAdapter::activateMPU(ULONG* MPUBase) { PAGED_CODE(); DBGPRINT(("CCMIAdapter[%p]::activateMPU(%X)", this, MPUBase)); UInt32 LegacyCtrl; switch ((LONGLONG)MPUBase) { case 0x300: LegacyCtrl = UART_300; break; case 0x310: LegacyCtrl = UART_310; break; case 0x320: LegacyCtrl = UART_320; break; case 0x330: LegacyCtrl = UART_330; break; // UART_330 == 0 default: LegacyCtrl = 0xFFFFFFFF; break; } if (LegacyCtrl < 0xFFFFFFFF) { cm.MPUBase = MPUBase; setUInt32Bit(REG_FUNCTRL1, EN_UART); writeUInt32(REG_LEGACY, LegacyCtrl); return STATUS_SUCCESS; } return STATUS_UNSUCCESSFUL; }
uint32 NativeTexture::writeD3d(ostream &rw) { HeaderInfo header; header.build = version; uint32 writtenBytesReturn; if (platform != PLATFORM_D3D8 && platform != PLATFORM_D3D9) return 0; // Texture Native SKIP_HEADER(); // Struct { SKIP_HEADER(); bytesWritten += writeUInt32(platform, rw); bytesWritten += writeUInt32(filterFlags, rw); char buffer[32]; strncpy(buffer, name.c_str(), 32); rw.write(buffer, 32); strncpy(buffer, maskName.c_str(), 32); rw.write(buffer, 32); bytesWritten += 2*32; bytesWritten += writeUInt32(rasterFormat, rw); /* if(rasterFormat == RASTER_8888 && !hasAlpha || rasterFormat == RASTER_888 && hasAlpha) cout << "mismatch " << hex << rasterFormat << endl; */ if (platform == PLATFORM_D3D8) { bytesWritten += writeUInt32(hasAlpha, rw); } else { if (dxtCompression) { char fourcc[5] = "DXT0"; fourcc[3] += dxtCompression; rw.write(fourcc, 4); bytesWritten += 4; } else { // 0x15 or 0x16 bytesWritten += writeUInt32(0x16-hasAlpha, rw); } } bytesWritten += writeUInt16(width[0], rw); bytesWritten += writeUInt16(height[0], rw); bytesWritten += writeUInt8(depth, rw); bytesWritten += writeUInt8(mipmapCount, rw); bytesWritten += writeUInt8(0x4, rw); if (platform == PLATFORM_D3D8) bytesWritten += writeUInt8(dxtCompression, rw); else bytesWritten += writeUInt8( (dxtCompression ? 8 : 0) | hasAlpha, rw); /* Palette */ if (rasterFormat & RASTER_PAL8 || rasterFormat & RASTER_PAL4) { uint32 paletteSize = 1 << depth; rw.write(reinterpret_cast <char *> (palette), paletteSize*4*sizeof(uint8)); bytesWritten += paletteSize*4*sizeof(uint8); } /* Texels */ for (uint32 i = 0; i < mipmapCount; i++) { /* uint32 dataSize = width[i]*height[i]; if (!dxtCompression) dataSize *= depth/8; else if (dxtCompression == 1) dataSize /= 2; */ uint32 dataSize = dataSizes[i]; bytesWritten += writeUInt32(dataSize, rw); rw.write(reinterpret_cast <char *> (&texels[i][0]), dataSize*sizeof(uint8)); bytesWritten += dataSize*sizeof(uint8); } WRITE_HEADER(CHUNK_STRUCT); } bytesWritten += writtenBytesReturn; // Extension { SKIP_HEADER(); WRITE_HEADER(CHUNK_EXTENSION); } bytesWritten += writtenBytesReturn; WRITE_HEADER(CHUNK_TEXTURENATIVE); return bytesWritten; }
void DataOutputStream::writeInt32(INT32 x) { writeUInt32((UINT32)x); }
void BinaryOutput::writeString32(const char* s) { writeUInt32(strlen(s) + 1); writeString(s); }
void writeUDIFID(AbstractFile* file, UDIFID* o) { FLIPENDIAN(o->data4); writeUInt32(file, o->data4); FLIPENDIAN(o->data4); FLIPENDIAN(o->data3); writeUInt32(file, o->data3); FLIPENDIAN(o->data3); FLIPENDIAN(o->data2); writeUInt32(file, o->data2); FLIPENDIAN(o->data2); FLIPENDIAN(o->data1); writeUInt32(file, o->data1); FLIPENDIAN(o->data1); }
void QPAGenerator::writeTaggedQFixed(QFontEngineQPA::HeaderTag tag, QFixed value) { writeUInt16(tag); writeUInt16(sizeof(quint32)); writeUInt32(value.value()); }
void QPAGenerator::writeTaggedUInt32(QFontEngineQPA::HeaderTag tag, quint32 value) { writeUInt16(tag); writeUInt16(sizeof(value)); writeUInt32(value); }
STDMETHODIMP_(void) CCMIAdapter::setUInt32Bit(UInt8 reg, UInt32 flag) { writeUInt32(reg, readUInt32(reg) | flag); }
STDMETHODIMP_(void) CCMIAdapter::clearUInt32Bit(UInt8 reg, UInt32 flag) { writeUInt32(reg, readUInt32(reg) & ~flag); }
bool convertWOFFToSfnt(SharedBuffer* woff, Vector<char>& sfnt) { ASSERT_ARG(sfnt, sfnt.isEmpty()); size_t offset = 0; // Read the WOFF header. uint32_t signature; if (!readUInt32(woff, offset, signature) || signature != woffSignature) { ASSERT_NOT_REACHED(); return false; } uint32_t flavor; if (!readUInt32(woff, offset, flavor)) return false; uint32_t length; if (!readUInt32(woff, offset, length) || length != woff->size()) return false; uint16_t numTables; if (!readUInt16(woff, offset, numTables)) return false; if (!numTables || numTables > 0x0fff) return false; uint16_t reserved; if (!readUInt16(woff, offset, reserved) || reserved) return false; uint32_t totalSfntSize; if (!readUInt32(woff, offset, totalSfntSize)) return false; if (woff->size() - offset < sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t)) return false; offset += sizeof(uint16_t); // majorVersion offset += sizeof(uint16_t); // minorVersion offset += sizeof(uint32_t); // metaOffset offset += sizeof(uint32_t); // metaLength offset += sizeof(uint32_t); // metaOrigLength offset += sizeof(uint32_t); // privOffset offset += sizeof(uint32_t); // privLength // Check if the WOFF can supply as many tables as it claims it has. if (woff->size() - offset < numTables * 5 * sizeof(uint32_t)) return false; // Write the sfnt offset subtable. uint16_t entrySelector = 0; uint16_t searchRange = 1; while (searchRange < numTables >> 1) { entrySelector++; searchRange <<= 1; } searchRange <<= 4; uint16_t rangeShift = (numTables << 4) - searchRange; if (!writeUInt32(sfnt, flavor) || !writeUInt16(sfnt, numTables) || !writeUInt16(sfnt, searchRange) || !writeUInt16(sfnt, entrySelector) || !writeUInt16(sfnt, rangeShift)) return false; if (sfnt.size() > totalSfntSize) return false; if (totalSfntSize - sfnt.size() < numTables * 4 * sizeof(uint32_t)) return false; size_t sfntTableDirectoryCursor = sfnt.size(); sfnt.grow(sfnt.size() + numTables * 4 * sizeof(uint32_t)); // Process tables. for (uint16_t i = 0; i < numTables; ++i) { // Read a WOFF table directory entry. uint32_t tableTag; if (!readUInt32(woff, offset, tableTag)) return false; uint32_t tableOffset; if (!readUInt32(woff, offset, tableOffset)) return false; uint32_t tableCompLength; if (!readUInt32(woff, offset, tableCompLength)) return false; if (tableOffset > woff->size() || tableCompLength > woff->size() - tableOffset) return false; uint32_t tableOrigLength; if (!readUInt32(woff, offset, tableOrigLength) || tableCompLength > tableOrigLength) return false; if (tableOrigLength > totalSfntSize || sfnt.size() > totalSfntSize - tableOrigLength) return false; uint32_t tableOrigChecksum; if (!readUInt32(woff, offset, tableOrigChecksum)) return false; // Write an sfnt table directory entry. uint32_t* sfntTableDirectoryPtr = reinterpret_cast<uint32_t*>(sfnt.data() + sfntTableDirectoryCursor); *sfntTableDirectoryPtr++ = htonl(tableTag); *sfntTableDirectoryPtr++ = htonl(tableOrigChecksum); *sfntTableDirectoryPtr++ = htonl(sfnt.size()); *sfntTableDirectoryPtr++ = htonl(tableOrigLength); sfntTableDirectoryCursor += 4 * sizeof(uint32_t); if (tableCompLength == tableOrigLength) { // The table is not compressed. if (!sfnt.tryAppend(woff->data() + tableOffset, tableCompLength)) return false; } else { uLongf destLen = tableOrigLength; if (!sfnt.tryReserveCapacity(sfnt.size() + tableOrigLength)) return false; Bytef* dest = reinterpret_cast<Bytef*>(sfnt.end()); sfnt.grow(sfnt.size() + tableOrigLength); if (uncompress(dest, &destLen, reinterpret_cast<const Bytef*>(woff->data() + tableOffset), tableCompLength) != Z_OK) return false; if (destLen != tableOrigLength) return false; } // Pad to a multiple of 4 bytes. while (sfnt.size() % 4) sfnt.append(0); } return sfnt.size() == totalSfntSize; }