/*
- * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
class IORegistryPlane : public OSObject {
friend class IORegistryEntry;
- OSDeclareAbstractStructors(IORegistryPlane)
+ OSDeclareAbstractStructors(IORegistryPlane);
const OSSymbol * nameKey;
const OSSymbol * keys[kNumSetIndex];
if (nameKey) {
nameKey->release();
}
- plane = 0;
+ plane = NULL;
}
return plane;
void
IORegistryEntry::setPropertyTable( OSDictionary * dict )
{
+ PLOCK;
if (dict) {
dict->retain();
}
}
fPropertyTable = dict;
+ PUNLOCK;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
{ \
OSObject * obj = getProperty( aKey ); \
\
- if ( (0 == obj) && plane && (options & kIORegistryIterateRecursively) ) { \
+ if ( (NULL == obj) && plane && (options & kIORegistryIterateRecursively) ) { \
IORegistryEntry * entry = (IORegistryEntry *) this; \
IORegistryIterator * iter; \
iter = IORegistryIterator::iterateOver( entry, plane, options ); \
\
if(iter) { \
- while ( (0 == obj) && (entry = iter->getNextObject()) ) { \
+ while ( (NULL == obj) && (entry = iter->getNextObject()) ) { \
obj = entry->getProperty( aKey ); \
} \
iter->release(); \
{ \
OSObject * obj = copyProperty( aKey ); \
\
- if ( (0 == obj) && plane && (options & kIORegistryIterateRecursively) ) { \
+ if ( (NULL == obj) && plane && (options & kIORegistryIterateRecursively) ) { \
IORegistryEntry * entry = (IORegistryEntry *) this; \
IORegistryIterator * iter; \
iter = IORegistryIterator::iterateOver( entry, plane, options ); \
\
if(iter) { \
- while ( (0 == obj) && (entry = iter->getNextObject()) ) { \
+ while ( (NULL == obj) && (entry = iter->getNextObject()) ) { \
obj = entry->copyProperty( aKey ); \
} \
iter->release(); \
OSObject * prior;
if (index >= kIORegistryEntryIndexedPropertyCount) {
- return 0;
+ return NULL;
}
array = atomic_load_explicit(&reserved->fIndexedProperties, memory_order_acquire);
if (!array) {
array = IONew(OSObject *, kIORegistryEntryIndexedPropertyCount);
if (!array) {
- return 0;
+ return NULL;
}
bzero(array, kIORegistryEntryIndexedPropertyCount * sizeof(array[0]));
if (!OSCompareAndSwapPtr(NULL, array, &reserved->fIndexedProperties)) {
}
}
if (!reserved->fIndexedProperties) {
- return 0;
+ return NULL;
}
prior = reserved->fIndexedProperties[index];
IORegistryEntry::getIndexedProperty(uint32_t index) const
{
if (index >= kIORegistryEntryIndexedPropertyCount) {
- return 0;
+ return NULL;
}
if (!reserved->fIndexedProperties) {
- return 0;
+ return NULL;
}
return reserved->fIndexedProperties[index];
const char *
IORegistryEntry::getName( const IORegistryPlane * plane ) const
{
- OSSymbol * sym = 0;
+ OSSymbol * sym = NULL;
RLOCK;
if (plane) {
IORegistryEntry::copyName(
const IORegistryPlane * plane ) const
{
- OSSymbol * sym = 0;
+ OSSymbol * sym = NULL;
RLOCK;
if (plane) {
IORegistryEntry::copyLocation(
const IORegistryPlane * plane ) const
{
- OSSymbol * sym = 0;
+ OSSymbol * sym = NULL;
RLOCK;
if (plane) {
IORegistryEntry::getLocation( const IORegistryPlane * plane ) const
{
const OSSymbol * sym = copyLocation( plane );
- const char * result = 0;
+ const char * result = NULL;
if (sym) {
result = sym->getCStringNoCopy();
}
}
+void
+IORegistryEntry::setName( const OSString * name,
+ const IORegistryPlane * plane )
+{
+ const OSSymbol * sym = OSSymbol::withString( name );
+ if (sym) {
+ setName( sym, plane );
+ sym->release();
+ }
+}
+
void
IORegistryEntry::setLocation( const OSSymbol * location,
const IORegistryPlane * plane )
{
OSString * string;
OSCollection * collection;
- OSIterator * iter = 0;
+ OSIterator * iter = NULL;
bool result = false;
if ((collection = OSDynamicCast( OSCollection, names))) {
iter = OSCollectionIterator::withCollection( collection );
- string = 0;
+ string = NULL;
} else {
string = OSDynamicCast( OSString, names);
}
stack->setObject((OSObject *) entry );
}
- ok = (0 != parent);
+ ok = (NULL != parent);
if (ok) {
index = stack->getCount();
if (0 == index) {
const IORegistryPlane * plane )
{
const char * str;
- const char * result = 0;
+ const char * result = NULL;
u_quad_t num1, num2;
char lastPathChar, lastLocationChar;
IORegistryEntry::getChildFromComponent( const char ** opath,
const IORegistryPlane * plane )
{
- IORegistryEntry * entry = 0;
+ IORegistryEntry * entry = NULL;
OSArray * set;
unsigned int index;
const char * path;
- const char * cmp = 0;
+ const char * cmp = NULL;
char c;
size_t len;
const char * str;
IORegistryEntry * entry;
IORegistryEntry * entry2;
const OSSymbol * key;
- const OSSymbol * bestKey = 0;
+ const OSSymbol * bestKey = NULL;
OSIterator * iter;
OSData * data;
const char * path = "/aliases";
IORegistryEntry * entry;
OSData * data;
const char * path = *opath;
- const char * rpath = 0;
+ const char * rpath = NULL;
const char * end;
char c;
char temp[kIOMaxPlaneName + 1];
int * length,
IORegistryEntry * fromEntry )
{
- IORegistryEntry * where = 0;
- IORegistryEntry * aliasEntry = 0;
+ IORegistryEntry * where = NULL;
+ IORegistryEntry * aliasEntry = NULL;
IORegistryEntry * next;
const char * alias;
const char * end;
char c;
char temp[kIOMaxPlaneName + 1];
- if (0 == path) {
- return 0;
+ if (NULL == path) {
+ return NULL;
}
- if (0 == plane) {
+ if (NULL == plane) {
// get plane name
end = strchr( path, ':' );
if (end && ((end - path) < kIOMaxPlaneName)) {
path = end + 1;
}
}
- if (0 == plane) {
- return 0;
+ if (NULL == plane) {
+ return NULL;
}
// check for alias
RLOCK;
do {
- if (0 == where) {
- if ((0 == fromEntry) && (*path++ == '/')) {
+ if (NULL == where) {
+ if ((NULL == fromEntry) && (*path++ == '/')) {
fromEntry = gRegistryRoot->getChildEntry( plane );
}
where = fromEntry;
- if (0 == where) {
+ if (NULL == where) {
break;
}
} else {
c = *path++;
if (c != '/') {
if (c && (c != ':')) { // check valid terminator
- where = 0;
+ where = NULL;
}
break;
}
*length = (len + len2);
} else if (path[0]) {
// no residual path => must be no tail for success
- where = 0;
+ where = NULL;
}
}
}
} else {
links = OSArray::withObjects((const OSObject **) &to, 1, 1 );
- result = (links != 0);
+ result = (links != NULL);
if (result) {
result = registryTable()->setObject( plane->keys[relation],
links );
return (OSArray *) registryTable()->getObject(
plane->keys[kParentSetIndex]);
} else {
- return 0;
+ return NULL;
}
}
OSIterator * iter;
if (!plane) {
- return 0;
+ return NULL;
}
RLOCK;
links = getParentSetReference( plane );
- if (0 == links) {
+ if (NULL == links) {
links = OSArray::withCapacity( 1 );
} else {
links = OSArray::withArray( links, links->getCount());
IORegistryEntry *
IORegistryEntry::copyParentEntry( const IORegistryPlane * plane ) const
{
- IORegistryEntry * entry = 0;
+ IORegistryEntry * entry = NULL;
OSArray * links;
RLOCK;
return (OSArray *) registryTable()->getObject(
plane->keys[kChildSetIndex]);
} else {
- return 0;
+ return NULL;
}
}
OSIterator * iter;
if (!plane) {
- return 0;
+ return NULL;
}
RLOCK;
links = getChildSetReference( plane );
- if (0 == links) {
+ if (NULL == links) {
links = OSArray::withCapacity( 1 );
} else {
links = OSArray::withArray( links, links->getCount());
IORegistryEntry::copyChildEntry(
const IORegistryPlane * plane ) const
{
- IORegistryEntry * entry = 0;
+ IORegistryEntry * entry = NULL;
OSArray * links;
RLOCK;
RLOCK;
if (plane) {
- ret = (0 != getParentSetReference( plane ));
+ ret = (NULL != getParentSetReference( plane ));
} else {
// Check to see if this is in any plane. If it is in a plane
// then the registryTable will contain a key with the ParentLinks
IORegistryIterator * regIter;
regIter = IORegistryIterator::iterateOver( this, plane, true );
- if (0 == regIter) {
+ if (NULL == regIter) {
return;
}
all = regIter->iterateAll();
{
IORegistryIterator * create;
- if (0 == root) {
- return 0;
+ if (NULL == root) {
+ return NULL;
}
- if (0 == plane) {
- return 0;
+ if (NULL == plane) {
+ return NULL;
}
create = new IORegistryIterator;
create->options = options & ~kIORegistryIteratorInvalidFlag;
} else {
create->release();
- create = 0;
+ create = NULL;
}
}
return create;
assert( where);
if (where) {
- where->iter = 0;
+ where->iter = NULL;
where->next = prev;
where->current = prev->current;
plane = enterPlane;
if (where->iter) {
where->iter->release();
- where->iter = 0;
+ where->iter = NULL;
if (where->current) {// && (where != &start))
where->current->release();
}
if (done) {
done->release();
- done = 0;
+ done = NULL;
}
where->current = root;
IORegistryEntry *
IORegistryIterator::getNextObjectFlat( void )
{
- IORegistryEntry * next = 0;
- OSArray * links = 0;
+ IORegistryEntry * next = NULL;
+ OSArray * links = NULL;
RLOCK;
- if ((0 == where->iter)) {
+ if ((NULL == where->iter)) {
// just entered - create new iter
if (isValid()
&& where->current
do{
next = getNextObjectFlat();
- } while ((0 == next) && exitEntry());
+ } while ((NULL == next) && exitEntry());
if (next) {
- if (0 == done) {
+ if (NULL == done) {
done = OSOrderedSet::withCapacity( 10 );
}
if (done->setObject((OSObject *) next)) {
if (isValid()) {
return where->current;
} else {
- return 0;
+ return NULL;
}
}