Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
	}
}
Ejemplo n.º 3
0
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;
	}
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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);
}