本文整理汇总了C++中OSString::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ OSString::getLength方法的具体用法?C++ OSString::getLength怎么用?C++ OSString::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSString
的用法示例。
在下文中一共展示了OSString::getLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: withCString
OSString * ACPIBacklightPanel::getACPIPath(IOACPIPlatformDevice * acpiDevice)
{
OSString * separator = OSString::withCStringNoCopy(".");
OSArray * array = OSArray::withCapacity(10);
char devicePath[512];
bzero(devicePath, sizeof(devicePath));
IOACPIPlatformDevice * parent = acpiDevice;
IORegistryIterator * iter = IORegistryIterator::iterateOver(acpiDevice, gIOACPIPlane, kIORegistryIterateParents | kIORegistryIterateRecursively);
if (iter)
{
do {
array->setObject(parent->copyName(gIOACPIPlane));
array->setObject(separator);
parent = OSDynamicCast(IOACPIPlatformDevice, iter->getNextObject());
} while (parent);
iter->release();
int offset = 0;
OSString * str = OSDynamicCast(OSString, array->getLastObject());
for (int i = array->getCount()-2; ((i>=0) || ((offset + str->getLength()) > sizeof(devicePath))) ; i--)
{
str = OSDynamicCast(OSString, array->getObject(i));
strncpy(devicePath + offset, str->getCStringNoCopy(), str->getLength());
offset += str->getLength();
}
}
return OSString::withCString(devicePath);
}
示例2: KINFO
/* read the <partition#> sector on the root address for label and size */
void net_habitue_device_SC101::partitionCompletion(void *parameter, IOReturn status, UInt64 actualByteCount)
{
if (status != kIOReturnSuccess || actualByteCount != sizeof(psan_get_response_partition_t))
{
KINFO("partition lookup on %s failed", getID()->getCStringNoCopy());
return;
}
IOBufferMemoryDescriptor *buffer = (IOBufferMemoryDescriptor *)parameter;
psan_get_response_partition_t *part = (psan_get_response_partition_t *)buffer->getBytesNoCopy();
OSString *id = getID();
for (UInt32 i = 0; i < actualByteCount / sizeof(psan_get_response_partition_t); i++, part++)
{
KDEBUG("cmp %s", part->id);
if (strncmp(part->id, id->getCStringNoCopy(), id->getLength() + 1) != 0)
continue;
KDEBUG("Matched!");
OSString *label = OSString::withCString(part->label);
if (label)
{
setProperty(gSC101DeviceLabelKey, label);
label->release();
}
OSNumber *size = OSNumber::withNumber(getUInt48(part->sector_size) << 9, 64);
if (size)
{
setProperty(gSC101DeviceSizeKey, size);
size->release();
}
if (1) // TODO(iwade) determine minimum fields needed
{
_mediaStateAttached = true;
_mediaStateChanged = true;
}
break;
}
}
示例3: addTachometerSensors
bool SuperIOMonitor::addTachometerSensors(OSDictionary *configuration)
{
HWSensorsDebugLog("adding tachometer sensors...");
for (int i = 0; i < tachometerSensorsLimit(); i++) {
OSString* name = NULL;
char key[7];
snprintf(key, 7, "FANIN%X", i);
name = OSDynamicCast(OSString, configuration->getObject(key));
UInt64 nameLength = name ? name->getLength() : 0;
if (readTachometer(i) > 10 || nameLength > 0)
if (!addTachometer(i, (nameLength > 0 ? name->getCStringNoCopy() : 0)))
HWSensorsWarningLog("error adding tachometer sensor %d", i);
}
return true;
}
示例4: binarySerialize
bool OSSerialize::binarySerialize(const OSMetaClassBase *o)
{
OSDictionary * dict;
OSArray * array;
OSSet * set;
OSNumber * num;
OSSymbol * sym;
OSString * str;
OSData * ldata;
OSBoolean * boo;
unsigned int tagIdx;
uint32_t i, key;
size_t len;
bool ok;
tagIdx = tags->getNextIndexOfObject(o, 0);
// does it exist?
if (-1U != tagIdx)
{
key = (kOSSerializeObject | tagIdx);
if (endCollection)
{
endCollection = false;
key |= kOSSerializeEndCollecton;
}
ok = addBinary(&key, sizeof(key));
return (ok);
}
if ((dict = OSDynamicCast(OSDictionary, o)))
{
key = (kOSSerializeDictionary | dict->count);
ok = addBinaryObject(o, key, NULL, 0);
for (i = 0; ok && (i < dict->count);)
{
const OSSymbol * dictKey;
const OSMetaClassBase * dictValue;
const OSMetaClassBase * nvalue = 0;
dictKey = dict->dictionary[i].key;
dictValue = dict->dictionary[i].value;
i++;
if (editor)
{
dictValue = nvalue = (*editor)(editRef, this, dict, dictKey, dictValue);
if (!dictValue) dictValue = dict;
}
ok = binarySerialize(dictKey);
if (!ok) break;
endCollection = (i == dict->count);
ok = binarySerialize(dictValue);
if (!ok) ok = dictValue->serialize(this);
if (nvalue) nvalue->release();
// if (!ok) ok = binarySerialize(kOSBooleanFalse);
}
}
else if ((array = OSDynamicCast(OSArray, o)))
{
key = (kOSSerializeArray | array->count);
ok = addBinaryObject(o, key, NULL, 0);
for (i = 0; ok && (i < array->count);)
{
i++;
endCollection = (i == array->count);
ok = binarySerialize(array->array[i-1]);
if (!ok) ok = array->array[i-1]->serialize(this);
// if (!ok) ok = binarySerialize(kOSBooleanFalse);
}
}
else if ((set = OSDynamicCast(OSSet, o)))
{
key = (kOSSerializeSet | set->members->count);
ok = addBinaryObject(o, key, NULL, 0);
for (i = 0; ok && (i < set->members->count);)
{
i++;
endCollection = (i == set->members->count);
ok = binarySerialize(set->members->array[i-1]);
if (!ok) ok = set->members->array[i-1]->serialize(this);
// if (!ok) ok = binarySerialize(kOSBooleanFalse);
}
}
else if ((num = OSDynamicCast(OSNumber, o)))
{
key = (kOSSerializeNumber | num->size);
ok = addBinaryObject(o, key, &num->value, sizeof(num->value));
}
else if ((boo = OSDynamicCast(OSBoolean, o)))
{
key = (kOSSerializeBoolean | (kOSBooleanTrue == boo));
ok = addBinaryObject(o, key, NULL, 0);
}
else if ((sym = OSDynamicCast(OSSymbol, o)))
{
len = (sym->getLength() + 1);
key = (kOSSerializeSymbol | len);
ok = addBinaryObject(o, key, sym->getCStringNoCopy(), len);
}
else if ((str = OSDynamicCast(OSString, o)))
//.........这里部分代码省略.........
示例5: getModelName
bool PC8739x::start(IOService * provider)
{
DebugLog("starting...");
if (!super::start(provider))
return false;
InfoLog("found NSC %s, revision 0x%x", getModelName(), revision);
OSDictionary* configuration = OSDynamicCast(OSDictionary, getProperty("Sensors Configuration"));
UInt32 adr =
(listenPortByte(NSC_MEM) & 0xff) +
((listenPortByte(NSC_MEM + 1) << 8) & 0xff00) +
((listenPortByte(NSC_MEM + 2) & 0xff) << 16) +
((listenPortByte(NSC_MEM + 3) & 0xff) << 24);
IOPhysicalAddress bar = (IOPhysicalAddress)(adr & ~0xf);
if(IOMemoryDescriptor *theDescriptor = IOMemoryDescriptor::withPhysicalAddress(bar, 0x200, kIODirectionOutIn))
if(mmio = theDescriptor->map()){
mmioBase = (volatile UInt8 *)mmio->getVirtualAddress();
}
else {
WarningLog("MCHBAR failed to map");
return false;
}
// Heatsink
if (!addSensor(KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 2))
WarningLog("error adding heatsink temperature sensor");
// Northbridge
if (!addSensor(KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 0))
WarningLog("error adding system temperature sensor");
// DIMM
if (!addSensor(KEY_DIMM_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 1))
WarningLog("error adding DIMM temperature sensor");
// AUX
if (!addSensor(KEY_AMBIENT_TEMPERATURE, TYPE_SP78, 2, kSuperIOTemperatureSensor, 3))
WarningLog("error adding AUX temperature sensor");
// Tachometers
// for (int i = 0; i < 5; i++) { //only one
OSString* name = 0;
int i=0;
if (configuration) {
char key[7];
snprintf(key, 7, "FANIN%X", i);
name = OSDynamicCast(OSString, configuration->getObject(key));
}
UInt32 nameLength = name ? name->getLength() : 0;
if (readTachometer(i) > 10 || nameLength > 0)
if (!addTachometer(i, (nameLength > 0 ? name->getCStringNoCopy() : 0)))
WarningLog("error adding tachometer sensor %d", i);
// }
return true;
}
示例6: start
bool SMBIOSResolver::start(IOService * provider)
{
if( super::start(provider) != true ) return false; // Oh no
if( IOService::getResourceService()->getProperty("SMBIOS-Resolver") ) return false; // We should exist only once
if( !IOService::getResourceService()->getProperty("SMBIOS") ) return false; // AppleSMBIOS.kext didn´t start we bail out
IOService * iosRoot = getServiceRoot();
if( !iosRoot ) return false; // Unable to get IOServiceRoot
int doVerbose = 0;
// PE_parse_boot_arg("smbios", &doVerbose); // bootarg SMBIOS=1 will give a verbose output to log (when I find something verbose worth outputting)
// Dictionary from plist
OSDictionary * hwDict = OSDynamicCast( OSDictionary, getProperty("Override"));
// /rom/version
IORegistryEntry * dtROMNode = fromPath("/rom", gIODTPlane);
if( dtROMNode )
{
OSString * romVersion = OSDynamicCast( OSString, hwDict->getObject("rom-version"));
if(romVersion->getLength() > 0) dtROMNode->setProperty("version", OSData::withBytes(romVersion->getCStringNoCopy(), romVersion->getLength() + 1) );
dtROMNode->release();
}
else
{
return false; // No /rom node in IODeviceTree plane
}
// root entries
OSObject * dictString = 0;
dictString = hwDict->getObject("manufacturer");
if(dictString)
{
OSString * rootManufacturer = OSDynamicCast( OSString, dictString);
if(rootManufacturer->getLength() > 1) iosRoot->setProperty("manufacturer", OSData::withBytes(rootManufacturer->getCStringNoCopy(), rootManufacturer->getLength() + 1) );
}
dictString = hwDict->getObject("system-type");
if(dictString)
{
OSData * systemType = OSDynamicCast( OSData, dictString);
if(systemType) iosRoot->setProperty("system-type", systemType );
}
dictString = hwDict->getObject("compatible");
if(dictString)
{
OSString * rootCompatible = OSDynamicCast( OSString, dictString);
if(rootCompatible->getLength() > 1) iosRoot->setProperty("compatible", OSData::withBytes(rootCompatible->getCStringNoCopy(), rootCompatible->getLength() + 1) );
}
dictString = hwDict->getObject("product-name");
if(dictString)
{
OSString * rootProductName = OSDynamicCast( OSString, dictString);
if(rootProductName->getLength() > 1) iosRoot->setProperty("product-name", OSData::withBytes(rootProductName->getCStringNoCopy(), rootProductName->getLength() + 1) );
}
dictString = hwDict->getObject("model");
if(dictString)
{
OSString * rootModel = OSDynamicCast( OSString, dictString);
if(rootModel->getLength() > 1)
{
iosRoot->setProperty("model", OSData::withBytes(rootModel->getCStringNoCopy(), rootModel->getLength() + 1) );
iosRoot->setName(rootModel->getCStringNoCopy());
}
}
dictString = hwDict->getObject("version");
if(dictString)
{
OSString * rootVersion = OSDynamicCast( OSString, dictString);
if(rootVersion->getLength() > 1) iosRoot->setProperty("version", OSData::withBytes(rootVersion->getCStringNoCopy(), rootVersion->getLength() + 1) );
}
dictString = hwDict->getObject("board-id");
if(dictString)
{
OSString * rootBoardId = OSDynamicCast( OSString, dictString);
if(rootBoardId->getLength() > 1) iosRoot->setProperty("board-id", OSData::withBytes(rootBoardId->getCStringNoCopy(), rootBoardId->getLength() + 1) );
}
dictString = hwDict->getObject("serial-number");
if(dictString)
{
OSString * rootSerial = OSDynamicCast( OSString, dictString);
if(rootSerial->getLength() > 1)
{
UInt8 length = rootSerial->getLength();
const char *serialNumberString = rootSerial->getCStringNoCopy();
// The serial-number property in the IORegistry is a 43-byte data object.
// Bytes 0 through 2 are the last three bytes of the serial number string.
// Bytes 11 through 20, inclusive, are the serial number string itself.
// All other bytes are '\0'.
OSData * data = OSData::withCapacity(43);
if (data)
{
//.........这里部分代码省略.........