本文整理汇总了C++中OSData::appendByte方法的典型用法代码示例。如果您正苦于以下问题:C++ OSData::appendByte方法的具体用法?C++ OSData::appendByte怎么用?C++ OSData::appendByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSData
的用法示例。
在下文中一共展示了OSData::appendByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cast
OSObject* FileNVRAM::cast(const OSSymbol* key, OSObject* obj)
{
const char* legacy[] = {
"boot-args",
"boot-script",
};
OSString* str = OSDynamicCast(OSString, key);
if (str)
{
for (int i = 0; i < sizeof(legacy)/sizeof(char*); i++)
{
if (str->isEqualTo(legacy[i]))
{
LOG(NOTICE, "Found legacy key %s\n", str->getCStringNoCopy());
// add null char, convert to OSString
OSData* data = OSDynamicCast(OSData, obj);
if (data)
{
data->appendByte(0x00, 1);
return OSString::withCString((const char*)data->getBytesNoCopy());
}
}
}
}
return obj;
}
示例2: init
bool FakeSMC::init(OSDictionary *properties)
{
if (!super::init(properties))
return false;
IOLog("FakeSMC v%s Copyright %d netkas, slice, usr-sse2, kozlek, navi, THe KiNG, RehabMan. All rights reserved.\n", HWSENSORS_VERSION_STRING, HWSENSORS_LASTYEAR);
if (IORegistryEntry *efi = IORegistryEntry::fromPath("/efi", gIODTPlane)) {
if (OSData *vendor = OSDynamicCast(OSData, efi->getProperty("firmware-vendor"))) { // firmware-vendor is in EFI node
OSData *buffer = OSData::withCapacity(128);
const unsigned char* data = static_cast<const unsigned char*>(vendor->getBytesNoCopy());
for (unsigned int index = 0; index < vendor->getLength(); index += 2) {
buffer->appendByte(data[index], 1);
}
OSString *name = OSString::withCString(static_cast<const char *>(buffer->getBytesNoCopy()));
setProperty(kFakeSMCFirmwareVendor, name);
//OSSafeRelease(vendor);
//OSSafeRelease(name);
OSSafeRelease(buffer);
}
OSSafeRelease(efi);
}
return true;
}
示例3: setDataProperty
void SMBPackedStrings::setDataProperty( IORegistryEntry * entry,
const char * key,
UInt8 index ) const
{
UInt8 length;
const char * string = SMBPackedStrings::stringAtIndex(index, &length);
if (length)
{
OSData * data = OSData::withCapacity(length + 1);
if (data)
{
data->appendBytes(string, length);
data->appendByte('\0', 1);
entry->setProperty(key, data);
data->release();
}
}
}
示例4: init
bool FakeSMC::init(OSDictionary *dictionary)
{
if (!super::init(dictionary))
return false;
IOLog("HWSensors v%s Copyright %d netkas, slice, usr-sse2, kozlek, navi, THe KiNG, RehabMan. All rights reserved.\n", HWSENSORS_VERSION_STRING, HWSENSORS_LASTYEAR);
//HWSensorsInfoLog("Opensource SMC device emulator. Copyright 2009 netkas. All rights reserved.");
if (!(smcDevice = new FakeSMCDevice)) {
HWSensorsInfoLog("failed to create SMC device");
return false;
}
if (!setOemProperties(this)) {
// Another try after 200 ms spin
IOSleep(200);
setOemProperties(this);
}
if (!getProperty(kOEMInfoProduct) || !getProperty(kOEMInfoManufacturer)) {
HWSensorsErrorLog("failed to obtain OEM vendor & product information from DMI");
// Try to obtain OEM info from Clover EFI
if (IORegistryEntry* platformNode = fromPath("/efi/platform", gIODTPlane)) {
if (OSData *data = OSDynamicCast(OSData, platformNode->getProperty("OEMVendor"))) {
if (OSString *vendor = OSString::withCString((char*)data->getBytesNoCopy())) {
if (OSString *manufacturer = getManufacturerNameFromOEMName(vendor)) {
this->setProperty(kOEMInfoManufacturer, manufacturer);
//OSSafeReleaseNULL(manufacturer);
}
//OSSafeReleaseNULL(vendor);
}
//OSSafeReleaseNULL(data);
}
if (OSData *data = OSDynamicCast(OSData, platformNode->getProperty("OEMBoard"))) {
if (OSString *product = OSString::withCString((char*)data->getBytesNoCopy())) {
this->setProperty(kOEMInfoProduct, product);
//OSSafeReleaseNULL(product);
}
//OSSafeReleaseNULL(data);
}
}
else {
HWSensorsErrorLog("failed to get OEM info from Clover EFI, specific platform profiles will be unavailable");
}
}
if (IORegistryEntry *efi = IORegistryEntry::fromPath("/efi", gIODTPlane)) {
if (OSData *vendor = OSDynamicCast(OSData, efi->getProperty("firmware-vendor"))) { // firmware-vendor is in EFI node
OSData *buffer = OSData::withCapacity(128);
const unsigned char* data = static_cast<const unsigned char*>(vendor->getBytesNoCopy());
for (unsigned int index = 0; index < vendor->getLength(); index += 2) {
buffer->appendByte(data[index], 1);
}
OSString *name = OSString::withCString(static_cast<const char *>(buffer->getBytesNoCopy()));
setProperty(kFakeSMCFirmwareVendor, name);
//OSSafeRelease(vendor);
//OSSafeRelease(name);
OSSafeRelease(buffer);
}
OSSafeRelease(efi);
}
return true;
}