예제 #1
0
static OSStatus WorkaroundNetworkPrefsBug(CFDictionaryRef *entitiesDictPtr)
	// If this is an Ethernet interface and LCPEchoEnabled is false, 
	// set it to true.  This works around what I think is a bug in 
	// the Network preferences panel <rdar://problem/3182846> where the 
	// LCPEchoEnabled flag is mysteriously set to false for PCI Ethernet 
	// interfaces.
{
	OSStatus 	err;
	CFStringRef hardwarePath[2];
	CFStringRef lcpPath[2];
	CFStringRef	hardwareStr;
	CFNumberRef lcpValue;
	long		enabled;
	
	hardwarePath[0] = kSCEntNetInterface;
	hardwarePath[1] = kSCPropNetInterfaceHardware;

	lcpPath[0] = kSCEntNetPPP;
	lcpPath[1] = kSCPropNetPPPLCPEchoEnabled;
	
	hardwareStr = NULL;			// just to make debugging easier
	lcpValue = NULL;
	
	err = noErr;
	if (    CFQDictionaryGetValueAtPath(*entitiesDictPtr, (const void **) hardwarePath, 2, (const void **) &hardwareStr) == noErr
		 && CFEqual(hardwareStr, kSCEntNetEthernet)
		 && CFQDictionaryGetValueAtPath(*entitiesDictPtr, (const void **) lcpPath, 2, (const void **) &lcpValue) == noErr
		 && CFNumberGetValue(lcpValue, kCFNumberLongType, &enabled)
		 && (enabled == 0) ) {
		CFMutableDictionaryRef 	newDict;
		CFNumberRef 			numRef;
		
		if ( ! gRunQuiet ) {
			fprintf(stderr, "Applied workaround\n");
		}
		
		numRef = NULL;
		newDict = CFDictionaryCreateMutableCopy(NULL, 0, *entitiesDictPtr);
		err = CFQError(newDict);
		if (err == noErr) {
			enabled = true;
			numRef = CFNumberCreate(NULL, kCFNumberLongType, &enabled);
			err = CFQError(numRef);
		}
		if (err == noErr) {
			err = CFQDictionarySetValueAtPath(newDict, (const void **) lcpPath, 2, numRef);
		}
		if (err == noErr) {
			CFQRelease(*entitiesDictPtr);
			*entitiesDictPtr = newDict;
			newDict = NULL;
		}
		
		CFQRelease(newDict);
		CFQRelease(numRef);
	}

	return err;	
}
예제 #2
0
파일: MoreCFQ.c 프로젝트: paullalonde/B
extern pascal OSStatus CFQBundleCreateFromFrameworkName(CFStringRef frameworkName, 
														CFBundleRef *bundlePtr)
	// See comment in header.
{
	OSStatus 	err;
	FSRef 		frameworksFolderRef;
	CFURLRef	baseURL;
	CFURLRef	bundleURL;
	
	assert(frameworkName != NULL);
	assert( bundlePtr != NULL);
	assert(*bundlePtr == NULL);
	
	*bundlePtr = NULL;
	
	baseURL = NULL;
	bundleURL = NULL;
	
	// Find the frameworks folder and create a URL for it.
	
	err = FSFindFolder(kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef);
	if (err == noErr) {
		baseURL = CFURLCreateFromFSRef(kCFAllocatorSystemDefault, &frameworksFolderRef);
		err = CFQError(baseURL);
	}
	
	// Append the name of the framework to the URL.
	
	if (err == noErr) {
		bundleURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault, baseURL, frameworkName, false);
		err = CFQError(bundleURL);
	}
	
	// Create a bundle based on that URL and load the bundle into memory.
	
	if (err == noErr) {
		*bundlePtr = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
		err = CFQError(*bundlePtr);
	}
	if (err == noErr) {
	    err = CFQErrorBoolean( CFBundleLoadExecutable( *bundlePtr ) );
	}

	// Clean up.
	
	if (err != noErr) {
		CFQRelease(*bundlePtr);
		*bundlePtr = NULL;
	}
	CFQRelease(bundleURL);
	CFQRelease(baseURL);
	
	assert( (err == noErr) == (*bundlePtr != NULL) );
	
	return err;
}
예제 #3
0
	extern pascal OSStatus MoreAToSCopySymbolNamesUsingDyld(ItemCount 		count, 
															MoreAToSAddr 	addresses[],
															MoreAToSSymInfo symbols[])
	{
		OSStatus 	err;
		ItemCount 	index;
		
		assert(addresses != NULL);
		assert(symbols != NULL);
		
		err = noErr;
		for (index = 0; index < count; index++) {
			const char * 		thisSymbol;
			const char * 		cleanSymbol;
			unsigned int 		thisSymbolOffset;
			Boolean      		thisSymbolPublic;
			CFStringRef	 		thisSymbolStr;
			MoreAToSSymbolType	thisSymbolType;
			
			thisSymbolStr = NULL;
			
			thisSymbol = NULL;
			if (addresses[index] != NULL) {		// NULL is never a useful symbol
				thisSymbol = GetFunctionName( (unsigned int) addresses[index], &thisSymbolOffset, &thisSymbolPublic);
			}
			if (thisSymbol != NULL) {
			
				// Mach-O symbols virtually always start with '_'.  If there's one there, 
				// let's strip it.
				
				if (thisSymbol[0] == '_') {
					cleanSymbol = &thisSymbol[1];
				} else {
					cleanSymbol = thisSymbol;
				}
				thisSymbolStr = CFStringCreateWithCString(NULL, cleanSymbol, kCFStringEncodingASCII);
				err = CFQError(thisSymbolStr);
				
				if (thisSymbolPublic) {
					thisSymbolType = kMoreAToSDyldPubliSymbol;
				} else {
					thisSymbolType = kMoreAToSDyldPrivateSymbol;
				}
				
				if (err == noErr) {	
					ReplaceSymbolIfBetter(&symbols[index], thisSymbolType, thisSymbolStr, (UInt32) thisSymbolOffset);
				}
			}
			
			CFQRelease(thisSymbolStr);
			free( (void *) thisSymbol);
			
			if (err != noErr) {
				break;
			}
		}
		
		return err;
	}
예제 #4
0
파일: MoreCFQ.c 프로젝트: paullalonde/B
extern pascal OSStatus CFQPropertyListCreateFromXMLFSRef(const FSRef *xmlFile, CFPropertyListMutabilityOptions options, CFPropertyListRef *result)
	// See comment in header.
{
	OSStatus  err;
	CFURLRef  xmlURL;
	
	assert(xmlFile != NULL);
	assert( result != NULL);
	assert(*result == NULL);
	
	xmlURL = CFURLCreateFromFSRef(NULL, xmlFile);
	err = CFQError(xmlURL);
	if (err == noErr) {
		err = CFQPropertyListCreateFromXMLCFURL(xmlURL, options, result);
	}
	
	CFQRelease(xmlURL);
	
	assert( (err == noErr) == (*result != NULL) );

	return err;
}