- OSString * string;
- OSCollection * collection;
- OSIterator * iter = 0;
- bool result = false;
-
- if( (collection = OSDynamicCast( OSCollection, names))) {
- iter = OSCollectionIterator::withCollection( collection );
- string = 0;
- } else
- string = OSDynamicCast( OSString, names);
-
- do {
- if( string)
- result = compareName( string, matched );
-
- } while( (false == result)
- && iter && (string = OSDynamicCast( OSString, iter->getNextObject())));
-
- if( iter)
- iter->release();
-
- return( result);
-}
-
-
-bool IORegistryEntry::getPath( char * path, int * length,
- const IORegistryPlane * plane ) const
-{
- OSArray * stack;
- IORegistryEntry * root;
- const IORegistryEntry * entry;
- const IORegistryEntry * parent;
- const OSSymbol * alias;
- int index;
- int len, maxLength, compLen, aliasLen;
- char * nextComp;
- bool ok;
-
- if( !path || !length || !plane)
- return( false);
-
- len = 0;
- maxLength = *length - 2;
- nextComp = path;
-
- len = plane->nameKey->getLength();
- if( len >= maxLength)
- return( false);
- strlcpy( nextComp, plane->nameKey->getCStringNoCopy(), len + 1);
- nextComp[ len++ ] = ':';
- nextComp += len;
-
- if( (alias = hasAlias( plane ))) {
- aliasLen = alias->getLength();
- len += aliasLen;
- ok = (maxLength > len);
- *length = len;
- if( ok)
- strlcpy( nextComp, alias->getCStringNoCopy(), aliasLen + 1);
- return( ok );
- }
-
- stack = OSArray::withCapacity( getDepth( plane ));
- if (!stack) return( false);
-
- RLOCK;
-
- parent = entry = this;
- root = gRegistryRoot->getChildEntry( plane );
- while (parent && (parent != root))
- {
- // stop below root
- entry = parent;
- parent = entry->getParentEntry( plane );
- stack->setObject( (OSObject *) entry );
- }
-
- ok = (0 != parent);
- if (ok)
- {
- index = stack->getCount();
- if( 0 == index) {
-
- *nextComp++ = '/';
- *nextComp = 0;
- len++;
-
- } else while( ok && ((--index) >= 0)) {
-
- entry = (IORegistryEntry *) stack->getObject((unsigned int) index );
- assert( entry );
-
- if( (alias = entry->hasAlias( plane ))) {
- len = plane->nameKey->getLength() + 1;
- nextComp = path + len;
-
- compLen = alias->getLength();
- ok = (maxLength > (len + compLen));
- if( ok)
- strlcpy( nextComp, alias->getCStringNoCopy(), compLen + 1);
- } else {
- compLen = maxLength - len;
- ok = entry->getPathComponent( nextComp + 1, &compLen, plane );
-
- if( ok && compLen) {
- compLen++;
- *nextComp = '/';
- }
- }
-
- if( ok) {
- len += compLen;
- nextComp += compLen;
- }
- }
- *length = len;
- }
- UNLOCK;
- stack->release();
-
- return( ok );
-}
-
-bool IORegistryEntry::getPathComponent( char * path, int * length,
- const IORegistryPlane * plane ) const
-{
- int len, locLen, maxLength;
- const char * compName;
- const char * loc;
- bool ok;
-
- maxLength = *length;
-
- compName = getName( plane );
- len = strlen( compName );
- if( (loc = getLocation( plane )))
- locLen = 1 + strlen( loc );
- else
- locLen = 0;
-
- ok = ((len + locLen + 1) < maxLength);
- if( ok) {
- strlcpy( path, compName, len + 1 );
- if( loc) {
- path += len;
- len += locLen;
- *path++ = '@';
- strlcpy( path, loc, locLen );
- }
- *length = len;
- }
-
- return( ok );
-}
-
-const char * IORegistryEntry::matchPathLocation( const char * cmp,
- const IORegistryPlane * plane )
-{
- const char * str;
- const char * result = 0;
- u_quad_t num1, num2;
- char lastPathChar, lastLocationChar;
-
- str = getLocation( plane );
- if( str) {
- lastPathChar = cmp[0];
- lastLocationChar = str[0];