OSErr
XPFIODevice::getRegistryProperty (REG_ENTRY_TYPE entry, char *key, char *value)
{
	value[0] = 0;

#ifdef __MACH__

	CFStringRef cfKey = CFStringCreateWithCString (NULL, key, kCFStringEncodingASCII);
	CFTypeRef cfValue = IORegistryEntryCreateCFProperty (entry, cfKey, NULL, 0);
 
	if (!cfValue) return -1;
	if (CFGetTypeID (cfValue) == CFDataGetTypeID ()) {
		memcpy (value, CFDataGetBytePtr ((CFDataRef) cfValue), CFDataGetLength ((CFDataRef) cfValue));
		value [CFDataGetLength ((CFDataRef) cfValue)] = 0;
		CFRelease (cfValue);
	}
	return noErr;

#else

	RegPropertyValueSize propSize;
	OSErr err = RegistryPropertyGetSize (entry, key, &propSize);
	if (err == noErr) {
		RegistryPropertyGet (entry, key, value, &propSize);
		value[propSize] = '\0';
	}
	return err;
	
#endif
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Store an error value and text string into the registry.
 */
void
PublishInitFailureMsg(									/* Initialization failure		*/
		OSStatus				errorStatus,			/* Writes this value and this	*/
		ConstStr255Param		messageText				/* text into the name registry	*/
	)
{
		OSStatus				status;
		RegPropertyValueSize	size;
		Str255					work;
		SInt32					failureCode;

		Trace(PublishInitFailureMsg);

		PStrCopy(work, (messageText == NULL) ? "\pUnknown reason" : messageText);
		if (work[0] > 254) work[0] = 254;
		work[++work[0]] = 0;							/* C string terminator			*/
		failureCode = errorStatus;

		/*
		 * Does the property currently exist - if so, exit so as we only want the first.
		 */
		status = RegistryPropertyGetSize(		/* returns noErr if the property exists	*/
					&GLOBAL.deviceEntry,
					kDriverFailTextPropertyName,
					&size
				);
		if (status != noErr) {
			status = RegistryPropertyCreate(	/* Make a new property					*/
						&GLOBAL.deviceEntry,					/* RegEntryID			*/
						kDriverFailTextPropertyName,				/* Property name		*/
						(RegPropertyValue *) &work[1],			/* -> Property contents	*/
						work[0]									/* Property size		*/
					);
			CheckStatus(status, "PublishInitFailureMsg - RegistryPropertyCreate");
		} else
		{
			status = RegistryPropertySet(		&GLOBAL.deviceEntry,
												kDriverFailTextPropertyName,
												(RegPropertyValue *) &work[1],
												work[0]	);
		}
		status = RegistryPropertyGetSize(		/* returns noErr if the property exists	*/
					&GLOBAL.deviceEntry,
					kDriverFailCodePropertyName,
					&size
				);
		if (status != noErr) {
			status = RegistryPropertyCreate(	/* Make a new property					*/
						&GLOBAL.deviceEntry,					/* RegEntryID			*/
						kDriverFailCodePropertyName,				/* Property name		*/
						(RegPropertyValue *) &failureCode,			/* -> Property contents	*/
						sizeof(SInt32)								/* Property size		*/
					);
			CheckStatus(status, "PublishInitFailureMsg - RegistryPropertyCreate (2)");
		} else
		{
			status = RegistryPropertySet(	&GLOBAL.deviceEntry,
											kDriverFailCodePropertyName,
											(RegPropertyValue *) &failureCode,
											sizeof(SInt32)	);
		}
}