sdmmd_return_t SDMMD_ServiceReceiveMessage(SocketConnection handle, CFPropertyListRef *data) { CFDataRef dataBuffer = NULL; sdmmd_return_t result; *data = NULL; CFErrorRef error = NULL; result = SDMMD_ServiceReceive(handle, &dataBuffer); if (result == kAMDSuccess) { // ServiceReceive success does not guarantee that valid data is available if (dataBuffer) { // CFPropertyListCreateWithData will return NULL if data is invalid format *data = CFPropertyListCreateWithData(kCFAllocatorDefault, dataBuffer, kCFPropertyListImmutable, NULL, &error); } if (*data == NULL) { // Could not parse received data result = kAMDInvalidResponseError; } } CFSafeRelease(dataBuffer); // Return an empty dictionary if a receive OR parse failure occurred if (result != kAMDSuccess) { *data = CFDictionaryCreateMutable(kCFAllocatorDefault, 0x0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } return result; }
sdmmd_return_t SDMMD_ServiceReceiveMessage(SocketConnection handle, CFPropertyListRef *data) { CFDataRef dataBuffer = NULL; if (SDM_MD_CallSuccessful(SDMMD_ServiceReceive(handle, &dataBuffer))) { if (dataBuffer && CFDataGetLength(dataBuffer)) { *data = CFPropertyListCreateWithData(0, dataBuffer, kCFPropertyListImmutable, NULL, NULL); } else { *data = CFDictionaryCreateMutable(kCFAllocatorDefault, 0x0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } return kAMDSuccess; } else { return kAMDNotConnectedError; } }
sdmmd_return_t SDMMD_ServiceReceiveStream(SocketConnection handle, CFPropertyListRef *data) { CFDataRef dataBuffer = NULL; if (SDM_MD_CallSuccessful(SDMMD_ServiceReceive(handle, &dataBuffer))) { if (dataBuffer && CFDataGetLength(dataBuffer)) { CFReadStreamRef read = CFReadStreamCreateWithBytesNoCopy(kCFAllocatorDefault, CFDataGetBytePtr(dataBuffer), CFDataGetLength(dataBuffer), kCFAllocatorNull); CFReadStreamOpen(read); *data = CFPropertyListCreateWithStream(kCFAllocatorDefault, read, CFDataGetLength(dataBuffer), 0x2, 0, NULL); CFReadStreamClose(read); if (read) CFRelease(read); } return kAMDSuccess; } else { return kAMDNotConnectedError; } }
sdmmd_return_t SDMMD_ServiceReceiveMessage(SocketConnection handle, CFPropertyListRef *data) { CFDataRef dataBuffer = NULL; sdmmd_return_t result; result = SDMMD_ServiceReceive(handle, &dataBuffer); if (result == kAMDSuccess) { if (dataBuffer && CFDataGetLength(dataBuffer)) { *data = CFPropertyListCreateWithData(kCFAllocatorDefault, dataBuffer, kCFPropertyListImmutable, NULL, NULL); } else { *data = CFDictionaryCreateMutable(kCFAllocatorDefault, 0x0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); result = kAMDInvalidResponseError; } } return result; }
sdmmd_return_t SDMMD_ServiceReceiveStream(SocketConnection handle, CFPropertyListRef *data) { CFDataRef dataBuffer = NULL; sdmmd_return_t result = SDMMD_ServiceReceive(handle, &dataBuffer); CheckErrorAndReturn(result); if (dataBuffer && CFDataGetLength(dataBuffer)) { CFReadStreamRef read = CFReadStreamCreateWithBytesNoCopy(kCFAllocatorDefault, CFDataGetBytePtr(dataBuffer), CFDataGetLength(dataBuffer), kCFAllocatorNull); CFReadStreamOpen(read); *data = CFPropertyListCreateWithStream(kCFAllocatorDefault, read, CFDataGetLength(dataBuffer), kCFPropertyListMutableContainersAndLeaves, NULL, NULL); CFReadStreamClose(read); CFSafeRelease(read); } result = kAMDSuccess; CFSafeRelease(dataBuffer); ExitLabelAndReturn(result); }