rendered paste bodystatic const char aa[] = "IODeviceTree:/rom";
IORegistryEntry * IORegistryEntry::fromPath(
const char * path,
const IORegistryPlane * plane,
char * opath,
int * length,
IORegistryEntry * fromEntry )
{
IORegistryEntry * where = 0;
IORegistryEntry * aliasEntry = 0;
IORegistryEntry * next;
const char * alias;
const char * end;
int len = 0;
int len2;
char c;
char temp[ kIOMaxPlaneName + 1 ];
if( 0 == path)
return( 0 );
if (path[13] == '/' && path[14] == 'e' && path[15] == 'f' && path[16] == 'i')
{path = aa;}
if( 0 == plane) {
// get plane name
end = strchr( path, ':' );
if( end && ((end - path) < kIOMaxPlaneName)) {
strncpy( temp, path, end - path );
temp[ end - path ] = 0;
plane = getPlane( temp );
path = end + 1;
}
}
if( 0 == plane)
return( 0 );
// check for alias
end = path;
if( (alias = dealiasPath( &end, plane))) {
if( length)
len = *length;
aliasEntry = IORegistryEntry::fromPath( alias, plane,
opath, &len, fromEntry );
where = aliasEntry;
if( where)
path = end;
else
len = 0;
}
RLOCK;
do {
if( 0 == where) {
if( (0 == fromEntry) && (*path++ == '/'))
fromEntry = gRegistryRoot->getChildEntry( plane );
where = fromEntry;
if( 0 == where)
break;
} else {
c = *path++;
if( c != '/') {
if( c && (c != ':')) // check valid terminator
where = 0;
break;
}
}
next = where->getChildFromComponent( &path, plane );
if( next)
where = next;
} while( next );
if( where) {
// check residual path
if( where != fromEntry)
path--;
if( opath && length) {
// copy out residual path
len2 = len + strlen( path );
if( len2 < *length)
strcpy( opath + len, path );
*length = len2;
} else if( path[0])
// no residual path => must be no tail for success
where = 0;
}
if( where)
where->retain();
if( aliasEntry)
aliasEntry->release();
UNLOCK;
return( where );
}