extern pascal OSStatus CFQDictionaryRemoveValueAtPathArray(CFMutableDictionaryRef dict, CFArrayRef path) // See comment in header. { OSStatus err; CFTypeRef * pathElements; assert( dict != NULL); assert( path != NULL); err = PathArrayHelper(path, &pathElements); if (err == noErr) { err = CFQDictionaryRemoveValueAtPath(dict, pathElements, CFArrayGetCount(path)); } if (pathElements != NULL) { free(pathElements); } return err; }
static OSStatus CompareGlobalEntities(CFStringRef newSet, CFStringRef defSet) // A routine to compare global entities, taking care to ignore // certain entities that aren't relevant. This is used by the // CompareSets routine. // // This is godawful code but it's only test code and I don't have time to // make it more elegant at this point. { OSStatus err; CFArrayRef newProtocols; CFArrayRef defProtocols; CFArrayRef newValues; CFArrayRef defValues; CFDictionaryRef newDict; CFDictionaryRef defDict; CFMutableDictionaryRef newMutableDict; CFMutableDictionaryRef defMutableDict; CFStringRef serviceOrderPath[2]; newProtocols = NULL; defProtocols = NULL; newValues = NULL; defValues = NULL; newDict = NULL; defDict = NULL; newMutableDict = NULL; defMutableDict = NULL; // Create two mutable dictionaries, ones for the new entities and the // other for the def entities. err = MoreSCCopyEntities(newSet, NULL, &newProtocols, &newValues); if (err == noErr) { err = MoreSCCopyEntities(defSet, NULL, &defProtocols, &defValues); } if (err == noErr) { err = CFQDictionaryCreateWithArrayOfKeysAndValues(newProtocols, newValues, &newDict); } if (err == noErr) { err = CFQDictionaryCreateWithArrayOfKeysAndValues(defProtocols, defValues, &defDict); } if (err == noErr) { newMutableDict = CFDictionaryCreateMutableCopy(NULL, 0, newDict); if (newMutableDict == NULL) { err = coreFoundationUnknownErr; } } if (err == noErr) { defMutableDict = CFDictionaryCreateMutableCopy(NULL, 0, defDict); if (defMutableDict == NULL) { err = coreFoundationUnknownErr; } } // Remove the elementsl at "IPv4/ServiceOrder" because they will never // compare equal because they contain different service IDs. serviceOrderPath[0] = kSCEntNetIPv4; serviceOrderPath[1] = kSCPropNetServiceOrder; if (err == noErr) { err = CFQDictionaryRemoveValueAtPath(newMutableDict, (const void **) serviceOrderPath, 2); } if (err == noErr) { err = CFQDictionaryRemoveValueAtPath(defMutableDict, (const void **) serviceOrderPath, 2); } // Now compare the dictionaries. if (err == noErr) { if ( ! CFEqual(newMutableDict, defMutableDict) ) { fprintf(stderr, "*** Global entities don't match\n"); PrintPropertyList(newMutableDict); PrintPropertyList(defMutableDict); err = -1; } } CFQRelease(newProtocols); CFQRelease(defProtocols); CFQRelease(newValues); CFQRelease(defValues); CFQRelease(newDict); CFQRelease(defDict); CFQRelease(newMutableDict); CFQRelease(defMutableDict); return err; }