The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/libsa/printPlist

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 void printPlist(OSObject * plist, UInt32 indent = 0) {
    2     const OSMetaClass * typeID;
    3     OSCollectionIterator * iterator;
    4     OSString * key;
    5     OSObject * value;
    6     unsigned int i;
    7 
    8     if (!plist) {
    9         IOLog("error! null plist\n");
   10         return;
   11     }
   12 
   13     typeID = OSTypeIDInst(plist);
   14 
   15     if (typeID ==  OSTypeID(OSDictionary)) {
   16 
   17         IOLog("{\n");
   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++) {
   22                 IOLog(" ");
   23             }
   24             IOLog("%s = ", key->getCStringNoCopy());
   25             value = dict->getObject(key);
   26             printPlist(value, indent + 4);
   27         }
   28 
   29         for (i = 0; i < indent; i++) {
   30             IOLog(" ");
   31         }
   32         IOLog("}\n");
   33 
   34     } else if (typeID == OSTypeID(OSArray)) {
   35 
   36         IOLog("(\n");
   37 
   38         OSArray * array = OSDynamicCast(OSArray, plist);
   39         iterator = OSCollectionIterator::withCollection(array);
   40         while ( (value = iterator->getNextObject()) ) {
   41             for (i = 0; i < indent + 4; i++) {
   42                 IOLog(" ");
   43             }
   44             printPlist(value, indent + 4);
   45         }
   46 
   47         for (i = 0; i < indent; i++) {
   48             IOLog(" ");
   49         }
   50         IOLog(")\n");
   51 
   52     } else if (typeID == OSTypeID(OSString) || typeID == OSTypeID(OSSymbol)) {
   53 
   54         OSString * string = OSDynamicCast(OSString, plist);
   55         IOLog("\"%s\"\n", string->getCStringNoCopy());
   56 
   57     } else if (typeID == OSTypeID(OSNumber)) {
   58 
   59         OSNumber * number = OSDynamicCast(OSNumber, plist);
   60         UInt32 numberValue = number->unsigned32BitValue();
   61         IOLog("0x%lx (%ld base 10)\n", numberValue, numberValue);
   62 
   63     } else if (typeID == OSTypeID(OSBoolean)) {
   64 
   65         OSBoolean * boolObj = OSDynamicCast(OSBoolean, plist);
   66         IOLog("%s\n", boolObj->isTrue() ? "true" : "false");
   67 
   68     } else if (typeID == OSTypeID(OSData)) {
   69 
   70         IOLog("(binary data)\n");
   71 
   72     } else {
   73 
   74         IOLog("(object of class %s)\n", plist->getMetaClass()->getClassName());
   75 
   76     }
   77 
   78     IODelay(150000);
   79     return;
   80 }

Cache object: c18ede10ed61c5b86d7ea06492529d40


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.