本文整理汇总了C++中OSString::release方法的典型用法代码示例。如果您正苦于以下问题:C++ OSString::release方法的具体用法?C++ OSString::release怎么用?C++ OSString::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSString
的用法示例。
在下文中一共展示了OSString::release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: previouslySerialized
bool OSSerialize::previouslySerialized(const OSMetaClassBase *o)
{
char temp[16];
OSString *tagString;
if (binary) return (binarySerialize(o));
// look it up
tagString = (OSString *)tags->getObject((const OSSymbol *) o);
// xx-review: no error checking here for addString calls!
// does it exist?
if (tagString) {
addString("<reference IDREF=\"");
addString(tagString->getCStringNoCopy());
addString("\"/>");
return true;
}
// build a tag
snprintf(temp, sizeof(temp), "%u", tag++);
tagString = OSString::withCString(temp);
// add to tag dictionary
tags->setObject((const OSSymbol *) o, tagString);// XXX check return
tagString->release();
return false;
}
示例2: sizeof
bool
IOFWUserAsyncStreamListener::serialize(OSSerialize *s) const
{
if (s->previouslySerialized(this))
return true ;
char temp[256] ;
if ( fFlags )
{
snprintf(temp+strlen(temp), sizeof(temp), ", flags:") ;
}
else
{
snprintf(temp+strlen(temp), sizeof(temp), ", no flags") ;
}
OSString* string = OSString::withCString(temp) ;
if (!string)
return false ;
bool result = string->serialize(s) ;
string->release() ;
return result ;
}
示例3: setProperty
bool FileNVRAM::setProperty(const OSSymbol *aKey, OSObject *anObject)
{
// Verify permissions.
if (IOUserClient::clientHasPrivilege(current_task(), kIOClientPrivilegeAdministrator) != kIOReturnSuccess)
{
// Not priveleged!
return false;
}
// Check for SIP configuration variables.
if ((strncmp("csr-data", aKey->getCStringNoCopy(), 8) == 0) || (strncmp("csr-active-config", aKey->getCStringNoCopy(), 17) == 0))
{
// We have a match so first verify the entitlements.
if (IOUserClient::copyClientEntitlement(current_task(), "com.apple.private.iokit.nvram-csr") == NULL)
{
LOG(INFO, "setProperty(%s, (%s) %p) failed (not entitled)\n", aKey->getCStringNoCopy(), anObject->getMetaClass()->getClassName(), anObject);
// Not entitled!
return false;
}
}
OSSerialize *s = OSSerialize::withCapacity(1000);
if (anObject->serialize(s))
{
LOG(INFO, "setProperty(%s, (%s) %s) called\n", aKey->getCStringNoCopy(), anObject->getMetaClass()->getClassName(), s->text());
}
else
{
LOG(INFO, "setProperty(%s, (%s) %p) called\n", aKey->getCStringNoCopy(), anObject->getMetaClass()->getClassName(), anObject);
}
s->release();
// Check for special FileNVRAM properties:
if (strncmp(FILE_NVRAM_GUID ":", aKey->getCStringNoCopy(), MIN(aKey->getLength(), strlen(FILE_NVRAM_GUID ":"))) == 0)
{
unsigned long bytes = aKey->getLength() - strlen(FILE_NVRAM_GUID ":") + 1;
// Found GUID
char* newKey = (char*)IOMalloc(bytes);
snprintf(newKey, bytes+1, "%s", &(aKey->getCStringNoCopy()[strlen(FILE_NVRAM_GUID ":")]));
// Send d
OSString* str = OSString::withCString(newKey);
handleSetting(str, anObject, this);
str->release();
IOFree(newKey, bytes);
}
bool stat = IOService::setProperty(aKey, cast(aKey, anObject));
if (mInitComplete)
{
sync();
}
return stat;
}
示例4: registerNVRAMController
void IOPlatformExpert::registerNVRAMController(IONVRAMController * caller)
{
OSData * data;
IORegistryEntry * entry;
OSString * string = 0;
uuid_string_t uuid;
entry = IORegistryEntry::fromPath( "/efi/platform", gIODTPlane );
if ( entry )
{
data = OSDynamicCast( OSData, entry->getProperty( "system-id" ) );
if ( data && data->getLength( ) == 16 )
{
SHA1_CTX context;
uint8_t digest[ SHA_DIGEST_LENGTH ];
const uuid_t space = { 0x2A, 0x06, 0x19, 0x90, 0xD3, 0x8D, 0x44, 0x40, 0xA1, 0x39, 0xC4, 0x97, 0x70, 0x37, 0x65, 0xAC };
SHA1Init( &context );
SHA1Update( &context, space, sizeof( space ) );
SHA1Update( &context, data->getBytesNoCopy( ), data->getLength( ) );
SHA1Final( digest, &context );
digest[ 6 ] = ( digest[ 6 ] & 0x0F ) | 0x50;
digest[ 8 ] = ( digest[ 8 ] & 0x3F ) | 0x80;
uuid_unparse( digest, uuid );
string = OSString::withCString( uuid );
}
entry->release( );
}
if ( string == 0 )
{
entry = IORegistryEntry::fromPath( "/options", gIODTPlane );
if ( entry )
{
data = OSDynamicCast( OSData, entry->getProperty( "platform-uuid" ) );
if ( data && data->getLength( ) == sizeof( uuid_t ) )
{
uuid_unparse( ( uint8_t * ) data->getBytesNoCopy( ), uuid );
string = OSString::withCString( uuid );
}
entry->release( );
}
}
if ( string )
{
getProvider( )->setProperty( kIOPlatformUUIDKey, string );
publishResource( kIOPlatformUUIDKey, string );
string->release( );
}
publishResource("IONVRAM");
}
示例5: setStringInDict
static void setStringInDict(OSDictionary* dict, const char* key, const char* value)
{
OSString* str = OSString::withCStringNoCopy(value);
if (str)
{
dict->setObject(key, str);
str->release();
}
}
示例6: start
bool IOPlatformExpert::start( IOService * provider )
{
IORangeAllocator * physicalRanges;
OSData * busFrequency;
if (!super::start(provider))
return false;
// Register the presence or lack thereof a system
// PCI address mapper with the IOMapper class
#if 1
IORegistryEntry * regEntry = IORegistryEntry::fromPath("/u3/dart", gIODTPlane);
if (!regEntry)
regEntry = IORegistryEntry::fromPath("/dart", gIODTPlane);
if (regEntry) {
int debugFlags;
if (!PE_parse_boot_arg("dart", &debugFlags) || debugFlags)
setProperty(kIOPlatformMapperPresentKey, kOSBooleanTrue);
regEntry->release();
}
#endif
IOMapper::setMapperRequired(0 != getProperty(kIOPlatformMapperPresentKey));
gIOInterruptControllers = OSDictionary::withCapacity(1);
gIOInterruptControllersLock = IOLockAlloc();
// Correct the bus frequency in the device tree.
busFrequency = OSData::withBytesNoCopy((void *)&gPEClockFrequencyInfo.bus_clock_rate_hz, 4);
provider->setProperty("clock-frequency", busFrequency);
busFrequency->release();
gPlatformInterruptControllerName = (OSSymbol *)OSSymbol::withCStringNoCopy("IOPlatformInterruptController");
physicalRanges = IORangeAllocator::withRange(0xffffffff, 1, 16,
IORangeAllocator::kLocking);
assert(physicalRanges);
setProperty("Platform Memory Ranges", physicalRanges);
setPlatform( this );
gIOPlatform = this;
PMInstantiatePowerDomains();
// Parse the serial-number data and publish a user-readable string
OSData* mydata = (OSData*) (provider->getProperty("serial-number"));
if (mydata != NULL) {
OSString *serNoString = createSystemSerialNumberString(mydata);
if (serNoString != NULL) {
provider->setProperty(kIOPlatformSerialNumberKey, serNoString);
serNoString->release();
}
}
return( configure(provider) );
}
示例7: withCString
OSString* Xbox360ControllerClass::newProductString() const
{
OSString *retString = getDeviceString(GetOwnerProvider(this)->GetProductStringIndex());
if (retString->isEqualTo("Controller")) {
retString->release();
return OSString::withCString("Xbox 360 Wired Controller");
} else {
return retString;
}
}
示例8:
OSString *OSString::withStringOfLength(const char *cString, size_t length)
{
OSString *me = new OSString;
if (me && !me->initWithStringOfLength(cString, length)) {
me->release();
return 0;
}
return me;
}
示例9: if
void net_habitue_device_SC101::diskCompletion(void *parameter, IOReturn status, UInt64 actualByteCount)
{
if (status != kIOReturnSuccess || actualByteCount != sizeof(psan_get_response_disk_t))
{
KINFO("disk query on %s failed", getID()->getCStringNoCopy());
return;
}
IOBufferMemoryDescriptor *buffer = (IOBufferMemoryDescriptor *)parameter;
psan_get_response_disk_t *disk = (psan_get_response_disk_t *)buffer->getBytesNoCopy();
OSData *partNumber = OSData::withBytes(disk->part_number, sizeof(disk->part_number));
if (partNumber)
{
OSString *resourceFile = NULL;
if (partNumber->isEqualTo(kSC101PartNumber, sizeof(kSC101PartNumber)))
resourceFile = OSString::withCString("SC101.icns");
else if (partNumber->isEqualTo(kSC101TPartNumber, sizeof(kSC101TPartNumber)))
resourceFile = OSString::withCString("SC101T.icns");
if (resourceFile)
{
setIcon(resourceFile);
resourceFile->release();
}
setProperty(gSC101DevicePartNumberKey, partNumber);
partNumber->release();
}
OSString *version = OSString::withCString(disk->version);
if (version)
{
setProperty(gSC101DeviceVersionKey, version);
version->release();
}
partition(disk->partitions);
}
示例10: OSDynamicCast
OSDictionary * AppleLVMVolume::propsFromHeader(AppleLVMVolumeOnDisk * lve)
{
OSString * errmsg = 0;
OSDictionary * lvProps = OSDynamicCast(OSDictionary, OSUnserializeXML(lve->plist, &errmsg));
if (!lvProps) {
if (errmsg) {
IOLog("AppleLVMVolume::propsFromHeader - XML parsing failed with %s\n", errmsg->getCStringNoCopy());
errmsg->release();
}
return NULL;
}
return lvProps;
}
示例11: setStringProperty
void SMBPackedStrings::setStringProperty( IORegistryEntry * entry,
const char * key,
UInt8 index ) const
{
UInt8 length;
const char * string = SMBPackedStrings::stringAtIndex(index, &length);
if (length)
{
OSString * strObj = OSString::withCString(string);
if (strObj)
{
entry->setProperty(key, strObj);
strObj->release();
}
}
}
示例12: 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;
}
}
示例13: DbgLog
IOService * DellWMIController::probe(IOService *provider, SInt32 *score )
{
IOService * ret = NULL;
OSObject * obj;
OSString * name;
IOACPIPlatformDevice *dev;
do
{
DbgLog("%s: Probe()\n", this->getName());
if (!super::probe(provider, score))
continue;
dev = OSDynamicCast(IOACPIPlatformDevice, provider);
if (NULL == dev)
continue;
dev->evaluateObject("_UID", &obj);
name = OSDynamicCast(OSString, obj);
if (NULL == name)
continue;
DbgLog("%s: Probe(%s)\n", this->getName(), name->getCStringNoCopy());
if (name->isEqualTo("DELLWMI"))
{
DbgLog("%s: Probe(OK)\n", this->getName());
*score +=20;
ret = this;
}
name->release();
}
while (false);
return (ret);
}
示例14: assert
OSDictionary * AppleLVMVolume::getVolumeProperties(void)
{
// make a copy
assert(lvProps);
OSDictionary * props = OSDictionary::withDictionary(lvProps, lvProps->getCount() + 2);
if (!props) return NULL;
// not from header
OSString * status = NULL;
if (isPublished()) {
status = OSString::withCString(kAppleRAIDStatusOnline);
} else {
status = OSString::withCString(kAppleRAIDStatusOffline);
}
if (status) {
props->setObject(kAppleLVMVolumeStatusKey, status);
status->release();
}
props->setObject(kIOBSDNameKey, getDiskName());
return props;
}
示例15: OSDynamicCast
bool
net_lundman_zfs_zvol_device::attach(IOService* provider)
{
OSDictionary *protocolCharacteristics = 0;
OSDictionary *deviceCharacteristics = 0;
OSDictionary *storageFeatures = 0;
OSBoolean *unmapFeature = 0;
OSString *dataString = 0;
OSNumber *dataNumber = 0;
if (super::attach(provider) == false)
return (false);
m_provider = OSDynamicCast(net_lundman_zfs_zvol, provider);
if (m_provider == NULL)
return (false);
/*
* We want to set some additional properties for ZVOLs, in
* particular, "Virtual Device", and type "File"
* (or is Internal better?)
*
* Finally "Generic" type.
*
* These properties are defined in *protocol* characteristics
*/
protocolCharacteristics = OSDictionary::withCapacity(3);
if (!protocolCharacteristics) {
IOLog("failed to create dict for protocolCharacteristics.\n");
return (true);
}
dataString = OSString::withCString(
kIOPropertyPhysicalInterconnectTypeVirtual);
if (!dataString) {
IOLog("could not create interconnect type string\n");
return (true);
}
protocolCharacteristics->setObject(
kIOPropertyPhysicalInterconnectTypeKey, dataString);
dataString->release();
dataString = 0;
dataString = OSString::withCString(kIOPropertyInterconnectFileKey);
if (!dataString) {
IOLog("could not create interconnect location string\n");
return (true);
}
protocolCharacteristics->setObject(
kIOPropertyPhysicalInterconnectLocationKey, dataString);
dataString->release();
dataString = 0;
setProperty(kIOPropertyProtocolCharacteristicsKey,
protocolCharacteristics);
protocolCharacteristics->release();
protocolCharacteristics = 0;
/*
* We want to set some additional properties for ZVOLs, in
* particular, physical block size (volblocksize) of the
* underlying ZVOL, and 'logical' block size presented by
* the virtual disk. Also set physical bytes per sector.
*
* These properties are defined in *device* characteristics
*/
deviceCharacteristics = OSDictionary::withCapacity(3);
if (!deviceCharacteristics) {
IOLog("failed to create dict for deviceCharacteristics.\n");
return (true);
}
/* Set logical block size to ZVOL_BSIZE (512b) */
dataNumber = OSNumber::withNumber(ZVOL_BSIZE,
8 * sizeof (ZVOL_BSIZE));
deviceCharacteristics->setObject(kIOPropertyLogicalBlockSizeKey,
dataNumber);
dprintf("logicalBlockSize %llu\n",
dataNumber->unsigned64BitValue());
dataNumber->release();
dataNumber = 0;
/* Set physical block size to match volblocksize property */
dataNumber = OSNumber::withNumber(zv->zv_volblocksize,
8 * sizeof (zv->zv_volblocksize));
deviceCharacteristics->setObject(kIOPropertyPhysicalBlockSizeKey,
dataNumber);
dprintf("physicalBlockSize %llu\n",
//.........这里部分代码省略.........