1 void printPlist(OSObject * plist, UInt32 indent = 0) {
2 const OSMetaClass * typeID;
3 OSCollectionIterator * iterator;
9 IOLog("error! null plist\n");
13 typeID = OSTypeIDInst(plist);
15 if (typeID == OSTypeID(OSDictionary)) {
18 OSDictionary * dict = OSDynamicCast(OSDictionary, plist);
19 iterator = OSCollectionIterator::withCollection(dict);
20 while ( (key = OSDynamicCast(OSString, iterator->getNextObject())) ) {
21 for (i = 0; i < indent + 4; i++) {
24 IOLog("%s = ", key->getCStringNoCopy());
25 value = dict->getObject(key);
26 printPlist(value, indent + 4);
29 for (i = 0; i < indent; i++) {
34 } else if (typeID == OSTypeID(OSArray)) {
38 OSArray * array = OSDynamicCast(OSArray, plist);
39 iterator = OSCollectionIterator::withCollection(array);
40 while ( (value = iterator->getNextObject()) ) {
41 for (i = 0; i < indent + 4; i++) {
44 printPlist(value, indent + 4);
47 for (i = 0; i < indent; i++) {
52 } else if (typeID == OSTypeID(OSString) || typeID == OSTypeID(OSSymbol)) {
54 OSString * string = OSDynamicCast(OSString, plist);
55 IOLog("\"%s\"\n", string->getCStringNoCopy());
57 } else if (typeID == OSTypeID(OSNumber)) {
59 OSNumber * number = OSDynamicCast(OSNumber, plist);
60 UInt32 numberValue = number->unsigned32BitValue();
61 IOLog("0x%lx (%ld base 10)\n", numberValue, numberValue);
63 } else if (typeID == OSTypeID(OSBoolean)) {
65 OSBoolean * boolObj = OSDynamicCast(OSBoolean, plist);
66 IOLog("%s\n", boolObj->isTrue() ? "true" : "false");
68 } else if (typeID == OSTypeID(OSData)) {
70 IOLog("(binary data)\n");
74 IOLog("(object of class %s)\n", plist->getMetaClass()->getClassName());