PATH 
ADC Home > Documentation > Hardware > Device Managers and Drivers > PCI Card Services > Designing PCI Cards and Drivers for Power Macintosh Computers


  

RegistryEntrySearch

Another kind of iteration call, RegistryEntrySearch, retrieves the next name entry in the Name Registry that has a specified matching property.

OSStatus RegistryEntrySearch(
                     RegEntryIter *cookie,
                     RegEntryIterationOp relationship,
                     RegEntryID *foundEntry,
                     Boolean *done,
                     const RegPropertyName *propertyName,
                     const void *propertyValue,
                     RegPropertyValueSize propertySize);
--> cookie
Pointer to the iterator used by iterate and search routines.
--> relationship
The search direction (values defined in Data Structures and Constants).
<-- foundEntry
Pointer to the ID of the next name entry found.
<-- done
Pointer to the search result. A value of true means searching is completed.
--> propertyName
Pointer to name of property to be matched.
--> propertyValue
Pointer to value of property to be matched.
--> propertySize
Size of property to be matched.
DESCRIPTION

RegistryEntrySearch searches for a name entry with a property that matches certain criteria and returns the RegEntryID value that identifies that entry in foundEntry, or true in done if all matching name entries have been found.

RegistryEntrySearch returns only entries with properties that simultaneously match the values of propertyName, propertyValue, and propertySize. If the propertyValue pointer is null or propertySize is 0, then any property value is considered a match.

EXECUTION CONTEXT

RegistryEntrySearch may be called from any execution level.

RESULT CODES
noErr 0 No error
paramErr -50 Bad parameter
CODE SAMPLE

Listing 10-4 shows code that uses RegistryEntrySearch to count the number of SCSI interface devices for a given parent device.

Listing 10-4 Using RegistryEntrySearch

OSStatus
FindSCSIDevices(
    constRegEntryID        *parentEntry,
    int                     *numberOfSCSIDevices
    )
{
    RegEntryIter            cookie;
    RegEntryID              SCSIEntry;
    RegEntryIterationOp     iterOp;
    Boolean                 done;
    OSStatus                err = noErr;

    #define kSCSIDeviceType     "scsi"

    RegistryEntryIDInit(&SCSIEntry);
    *numberOfSCSIDevices = 0;

    err = RegistryEntryIterateCreate(&cookie);
    if(err != noErr)
        return err;

    /*
    * Reset iterator to point to the parent entry
    */
    err=RegistryEntryIterateSet(&cookie, parentEntry);

    if (err == noErr){
        /*
        * Search all descendants of the parent device.
        */
        iterOp = kRegIterDescendants;
        do {
            err = RegistryEntrySearch(&cookie, iterOp, &SCSIEntry, &done,
                    "device_type", kSCSIDeviceType, sizeof(kSCSIDeviceType));

            if (!done && err == noErr){
                *numberOfSCSIDevices +=1;
                RegistryEntryIDDispose(&SCSIEntry);
            }
            iterOp = kRegIterContinue;

        } while (!done && err == noErr);
    }
    RegistryEntryIterateDispose(&cookie);
    return err;
}

© 1999 Apple Computer, Inc. – (Last Updated 26 March 99)