/* * Function: EAPOLClientProfileCreatePropertyList * * Purpose: * Create an "external" format for a profile. * * Returns: * NULL if the profile could not be externalized, non-NULL otherwise. */ CFPropertyListRef EAPOLClientProfileCreatePropertyList(EAPOLClientProfileRef profile) { CFMutableDictionaryRef dict; CFStringRef profileID; dict = EAPOLClientProfileCreateDictAndProfileID(profile, &profileID); if (dict == NULL) { return (NULL); } CFDictionarySetValue(dict, kProfileKeyProfileID, profileID); return ((CFPropertyListRef)dict); }
STATIC CFDictionaryRef export_profiles(EAPOLClientConfigurationRef cfg) { int count; CFMutableDictionaryRef dict; int i; const void * * values; count = CFDictionaryGetCount(cfg->profiles); dict = CFDictionaryCreateMutable(NULL, count, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); if (count == 0) { /* return empty dict */ goto done; } values = (const void * *)malloc(sizeof(*values) * count); CFDictionaryGetKeysAndValues(cfg->profiles, NULL, values); for (i = 0; i < count; i++) { EAPOLClientProfileRef profile = (EAPOLClientProfileRef)values[i]; CFDictionaryRef profile_dict; CFStringRef profileID; profile_dict = EAPOLClientProfileCreateDictAndProfileID(profile, &profileID); if (profile_dict == NULL) { /* error, return NULL */ my_CFRelease(&dict); break; } CFDictionarySetValue(dict, profileID, profile_dict); CFRelease(profile_dict); CFRelease(profileID); } free(values); done: return (dict); }