您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CFArrayCreateMutable函数代码示例

51自学网 2021-06-01 19:58:18
  C++
这篇教程C++ CFArrayCreateMutable函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CFArrayCreateMutable函数的典型用法代码示例。如果您正苦于以下问题:C++ CFArrayCreateMutable函数的具体用法?C++ CFArrayCreateMutable怎么用?C++ CFArrayCreateMutable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CFArrayCreateMutable函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ST_ID3v1_copyGenres

ST_FUNC CFArrayRef ST_ID3v1_copyGenres(void) {    CFMutableArrayRef rv = CFArrayCreateMutable(kCFAllocatorDefault,                                                ID3v1GenreMax + 1,                                                &kCFTypeArrayCallBacks);    CFStringRef tmp;    int i;    if(rv) {        for(i = 0; i <= ID3v1GenreMax; ++i) {            tmp = CFStringCreateWithCString(kCFAllocatorDefault, id3_genres[i],                                            kCFStringEncodingISOLatin1);            if(tmp) {                CFArrayAppendValue(rv, tmp);                CFRelease(tmp);            }            else {                CFRelease(rv);                return NULL;            }        }    }    return (CFArrayRef)rv;}
开发者ID:ljsebald,项目名称:SonatinaTag,代码行数:24,


示例2: Alloc

/***************************************************************************** * Alloc * -  * Functionas as both +[alloc] and -[init] for the plugin. Add any  * initalization of member variables here. *****************************************************************************/static BonjourUserEventsPlugin* Alloc(CFUUIDRef factoryID){	BonjourUserEventsPlugin* plugin = malloc(sizeof(BonjourUserEventsPlugin));		plugin->_UserEventAgentInterface = &UserEventAgentInterfaceFtbl;	plugin->_pluginContext = NULL;			if (factoryID) 	{		plugin->_factoryID = (CFUUIDRef)CFRetain(factoryID);		CFPlugInAddInstanceForFactory(factoryID);	}		plugin->_refCount = 1;	plugin->_tokenToBrowserMap = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kNetBrowserInfoDictionaryValueCallbacks);	plugin->_browsers = CFDictionaryCreateMutable(NULL, 0, &kNetBrowserInfoDictionaryKeyCallbacks, &kCFTypeDictionaryValueCallBacks);	plugin->_onAddEvents = CFDictionaryCreateMutable(NULL, 0, &kNetBrowserInfoDictionaryKeyCallbacks, &kCFTypeDictionaryValueCallBacks);	plugin->_onRemoveEvents = CFDictionaryCreateMutable(NULL, 0, &kNetBrowserInfoDictionaryKeyCallbacks, &kCFTypeDictionaryValueCallBacks);	plugin->_whileServiceExist = CFDictionaryCreateMutable(NULL, 0, &kNetBrowserInfoDictionaryKeyCallbacks, &kCFTypeDictionaryValueCallBacks);		plugin->_timers = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);		return plugin;}
开发者ID:benvanik,项目名称:mDNSResponder,代码行数:30,


示例3: GetSize

//============================================================================//		NCFArray::GetObject : Get the object.//----------------------------------------------------------------------------NCFObject NCFArray::GetObject(void) const{	NCFObject		theObject, theValue;	NIndex			n, numItems;	// Get the state we need	numItems = GetSize();		if (!theObject.SetObject(CFArrayCreateMutable(kCFAllocatorNano, numItems, &kCFTypeArrayCallBacks)))		return(theObject);	// Get the object	for (n = 0; n < numItems; n++)		{		theValue = NMacTarget::ConvertObjectToCF(GetValue(n));		if (theValue.IsValid())			CFArrayAppendValue(theObject, (CFTypeRef) theValue);		}	return(theObject);}
开发者ID:refnum,项目名称:nano,代码行数:27,


示例4: apple_joypad_init

// RetroArch joypad driver:static bool apple_joypad_init(void){#ifdef OSX    CFMutableArrayRef matcher;        if (!g_hid_manager)    {        g_hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);                matcher = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);        append_matching_dictionary(matcher, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);        append_matching_dictionary(matcher, kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);                IOHIDManagerSetDeviceMatchingMultiple(g_hid_manager, matcher);        CFRelease(matcher);                IOHIDManagerRegisterDeviceMatchingCallback(g_hid_manager, hid_manager_device_attached, 0);        IOHIDManagerScheduleWithRunLoop(g_hid_manager, CFRunLoopGetMain(), kCFRunLoopCommonModes);                IOHIDManagerOpen(g_hid_manager, kIOHIDOptionsTypeNone);    }#endif   return true;}
开发者ID:DerrrekWang,项目名称:RetroArch,代码行数:25,


示例5: __CFLocaleCopyUEnumerationAsArray

static CFArrayRef __CFLocaleCopyUEnumerationAsArray(UEnumeration *enumer, UErrorCode *icuErr) {    const UChar *next = NULL;    int32_t len = 0;    CFMutableArrayRef working = NULL;    if (U_SUCCESS(*icuErr)) {        working = CFArrayCreateMutable(kCFAllocatorSystemDefault, 0, &kCFTypeArrayCallBacks);    }    while ((next = uenum_unext(enumer, &len, icuErr)) && U_SUCCESS(*icuErr)) {        CFStringRef string = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (const UniChar *)next, (CFIndex) len);        CFArrayAppendValue(working, string);        CFRelease(string);    }    if (*icuErr == U_INDEX_OUTOFBOUNDS_ERROR) {        *icuErr = U_ZERO_ERROR;      // Temp: Work around bug (ICU 5220) in ucurr enumerator    }    CFArrayRef result = NULL;    if (U_SUCCESS(*icuErr)) {        result = CFArrayCreateCopy(kCFAllocatorSystemDefault, working);    }    if (working != NULL) {        CFRelease(working);    }    return result;}
开发者ID:AbhinavBansal,项目名称:opencflite,代码行数:24,


示例6: MakeUserDataRec

OpenUserDataRec::OpenUserDataRec( wxFileDialog* d){    m_dialog = d;    m_controlAdded = false;    m_saveMode = m_dialog->HasFdFlag(wxFD_SAVE);    m_defaultLocation = m_dialog->GetDirectory();    MakeUserDataRec(m_dialog->GetWildcard());    m_currentfilter = m_dialog->GetFilterIndex();    m_menuitems = NULL;    size_t numFilters = m_extensions.GetCount();    if (numFilters)    {        m_menuitems = CFArrayCreateMutable( kCFAllocatorDefault ,                                         numFilters , &kCFTypeArrayCallBacks ) ;        for ( size_t i = 0 ; i < numFilters ; ++i )        {            CFArrayAppendValue( m_menuitems , (CFStringRef) wxCFStringRef( m_name[i] ) ) ;        }    }    m_lastRight = m_lastBottom = 0;}
开发者ID:0ryuO,项目名称:dolphin-avsync,代码行数:24,


示例7: jsUndefined

JSValue UserObjectImp::callAsFunction(ExecState *exec){    JSValue result = jsUndefined();    JSUserObject* jsThisObj = KJSValueToJSObject(exec->hostThisValue().toThisObject(exec), exec);    if (jsThisObj) {        CFIndex argCount = exec->argumentCount();        CFArrayCallBacks arrayCallBacks;        JSTypeGetCFArrayCallBacks(&arrayCallBacks);        CFMutableArrayRef jsArgs = CFArrayCreateMutable(0, 0, &arrayCallBacks);        if (jsArgs) {            for (CFIndex i = 0; i < argCount; i++) {                JSUserObject* jsArg = KJSValueToJSObject(exec->argument(i), exec);                CFArrayAppendValue(jsArgs, (void*)jsArg);                jsArg->Release();            }        }        JSUserObject* jsResult;        { // scope            JSGlueAPICallback apiCallback(exec);            // getCallData should have guarded against a NULL fJSUserObject.            assert(fJSUserObject);            jsResult = fJSUserObject->CallFunction(jsThisObj, jsArgs);        }        if (jsResult) {            result = JSObjectKJSValue(jsResult);            jsResult->Release();        }        ReleaseCFType(jsArgs);        jsThisObj->Release();    }    return result;}
开发者ID:NewDreamUser2,项目名称:webkit-webcl,代码行数:36,


示例8: setInterfaceEAPOLConfiguration

/* * Function: setInterfaceEAPOLConfiguration * Purpose: *   Set the EAPOL configuration for the particular interface in the *   cfg->sc_prefs and add the SCNetworkInterfaceRef to cfg->sc_changed_if. *   That allows saveInterfaceEAPOLConfiguration() to know which interfaces *   were changed when it commits the changes to the writable prefs. */STATIC BooleansetInterfaceEAPOLConfiguration(EAPOLClientConfigurationRef cfg, 			       SCNetworkInterfaceRef net_if,			       CFDictionaryRef dict){    CFRange	r;    Boolean	ret;    ret = SCNetworkInterfaceSetExtendedConfiguration(net_if, kEAPOL, dict);    if (ret == FALSE) {	return (ret);    }    /* keep track of which SCNetworkInterfaceRef's were changed */    if (cfg->sc_changed_if == NULL) {	cfg->sc_changed_if = CFArrayCreateMutable(NULL, 0, 						  &kCFTypeArrayCallBacks);    }    r.location = 0;    r.length = CFArrayGetCount(cfg->sc_changed_if);    if (CFArrayContainsValue(cfg->sc_changed_if, r, net_if) == FALSE) {	CFArrayAppendValue(cfg->sc_changed_if, net_if);    }    return (TRUE);}
开发者ID:aosm,项目名称:eap8021x,代码行数:32,


示例9: iohidmanager_hid_manager_set_device_matching

static int iohidmanager_hid_manager_set_device_matching(      iohidmanager_hid_t *hid){   CFMutableArrayRef matcher = CFArrayCreateMutable(kCFAllocatorDefault, 0,         &kCFTypeArrayCallBacks);   if (!matcher)      return -1;   iohidmanager_hid_append_matching_dictionary(matcher,         kHIDPage_GenericDesktop,         kHIDUsage_GD_Joystick);   iohidmanager_hid_append_matching_dictionary(matcher,         kHIDPage_GenericDesktop,         kHIDUsage_GD_GamePad);   IOHIDManagerSetDeviceMatchingMultiple(hid->ptr, matcher);   IOHIDManagerRegisterDeviceMatchingCallback(hid->ptr,         iohidmanager_hid_device_add, 0);   CFRelease(matcher);   return 0;}
开发者ID:Monroe88,项目名称:RetroArch,代码行数:24,


示例10: History

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	Name:	MyPDEGetSummaryText	Input Parameters:		context			:	The plugins context		titleArray 		:	an array to store the title of the summary text		summaryArray		:	an array to store the summary text			Output Parameters:		titleArray 		:	updated with this plugins summary text title		summaryArray		:	updated with this plugins summary text		err			:	returns the error status	Description:		Returns the status/state of the plugin in textual form	Change History (most recent first):~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/static OSStatus MyPDEGetSummaryText(PMPDEContext	context,                         CFArrayRef 		*titleArray,                        CFArrayRef		*summaryArray){	OSStatus err = noErr;        CFMutableArrayRef theTitleArray = NULL;		// Init CF strings        CFMutableArrayRef theSummaryArray = NULL;        CFStringRef titleStringRef = NULL;        CFStringRef summaryStringRef = NULL;	PageSetupPDEOnlyContextPtr myContext = NULL;	// Pointer to global data block.        DebugMessage("PageSetupPDE MyPDEGetSummaryText called/n");            myContext = (PageSetupPDEOnlyContextPtr) context;	*titleArray = NULL;        *summaryArray = NULL;	if (myContext != NULL)        {		//  NOTE: if the second parameter to CFArrayCreateMutable 		//		  is not 0 then the array is a FIXED size		theTitleArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);		theSummaryArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);    		if ((theTitleArray != NULL) && (theSummaryArray != NULL))		{		    SInt16	theControlValue = -1;		    titleStringRef = CopyLocalizedStringFromPlugin(					    CFSTR(" Print Title Text"),					    CFSTR("Summary Title"),					    myContext->theBundleRef);		    theControlValue = GetControlValue(myContext->thePrintTitleControlRef);		    switch (theControlValue)		    {			    case 0:				    summaryStringRef = CopyLocalizedStringFromPlugin(					    CFSTR(" No"),					    CFSTR("Summary Text"),					    myContext->theBundleRef);				    break;    			    case 1:				    summaryStringRef = CopyLocalizedStringFromPlugin(					    CFSTR(" Yes"),					    CFSTR("Summary Text"),					    myContext->theBundleRef);				    break;		    }		    if(titleStringRef && summaryStringRef){			CFArrayAppendValue(theTitleArray, titleStringRef);			CFArrayAppendValue(theSummaryArray, summaryStringRef);		    }else			err = memFullErr;		}else{			err = memFullErr;		}	}else            err = kPMInvalidPDEContext;        // we release these because we've added them already to the title and summary array        // or we don't need them because there was an error        if (titleStringRef)                CFRelease(titleStringRef);        if (summaryStringRef)                CFRelease(summaryStringRef);                // update the data passed in.        if(!err){            *titleArray = theTitleArray;            *summaryArray = theSummaryArray;        }else{            if (theTitleArray)                    CFRelease(theTitleArray);            if (theSummaryArray)                    CFRelease(theSummaryArray);        }        	DebugPrintErr(err, "PageSetupPDE Error from MyPDEGetSummaryText returned %d/n");	return (err);//.........这里部分代码省略.........
开发者ID:fruitsamples,项目名称:App,代码行数:101,


示例11: CreateCFArrayFromAEDescList

static OSStatus CreateCFArrayFromAEDescList(	const AEDescList *	descList, 	CFArrayRef *		itemsPtr)	// This routine's input is an AEDescList that contains replies 	// from the "properties of every login item" event.  Each element 	// of the list is an AERecord with two important properties, 	// "path" and "hidden".  This routine creates a CFArray that 	// corresponds to this list.  Each element of the CFArray 	// contains two properties, kLIAEURL and 	// kLIAEHidden, that are derived from the corresponding 	// AERecord properties.	//	// On entry, descList must not be NULL	// On entry,  itemsPtr must not be NULL	// On entry, *itemsPtr must be NULL	// On success, *itemsPtr will be a valid CFArray	// On error, *itemsPtr will be NULL{	OSStatus			err;	CFMutableArrayRef	result;	long				itemCount;	long				itemIndex;	AEKeyword			junkKeyword;	DescType			junkType;	Size				junkSize;		assert( itemsPtr != NULL);	assert(*itemsPtr == NULL);	result = NULL;		// Create a place for the result.	    err = noErr;    result = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);    if (result == NULL) {        err = coreFoundationUnknownErr;    }		// For each element in the descriptor list...		if (err == noErr) {		err = AECountItems(descList, &itemCount);	}	if (err == noErr) {		for (itemIndex = 1; itemIndex <= itemCount; itemIndex++) {		  if (itemIndex == 4) {			  int notused = 0;				notused++;			}			AERecord 			thisItem;			UInt8 				thisPath[1024];			Size				thisPathSize;			FSRef				thisItemRef;			CFURLRef			thisItemURL;			Boolean				thisItemHidden;			CFDictionaryRef		thisItemDict;						thisItem = kAENull;			thisItemURL = NULL;			thisItemDict = NULL;						// Get this element's AERecord.						err = AEGetNthDesc(descList, itemIndex, typeAERecord, &junkKeyword, &thisItem);			if (err != noErr) {			  err = noErr;				continue;			}			// Extract the path and create a CFURL.			if (err == noErr) {				err = AEGetKeyPtr(					&thisItem, 					propPath, 					typeUTF8Text, 					&junkType, 					thisPath, 					sizeof(thisPath) - 1, 		// to ensure that we can always add null terminator					&thisPathSize				);			}						if (err == noErr) {				thisPath[thisPathSize] = 0;								err = FSPathMakeRef(thisPath, &thisItemRef, NULL);								if (err == noErr) {					thisItemURL = CFURLCreateFromFSRef(NULL, &thisItemRef);				} else {					err = noErr;			// swallow error and create an imprecise URL										thisItemURL = CFURLCreateFromFileSystemRepresentation(						NULL,						thisPath,						thisPathSize,//.........这里部分代码省略.........
开发者ID:AntoineTurmel,项目名称:nightingale-hacking,代码行数:101,


示例12: IOCreatePlugInInterfaceForService

kern_return_tIOCreatePlugInInterfaceForService(io_service_t service,                CFUUIDRef pluginType, CFUUIDRef interfaceType,                IOCFPlugInInterface *** theInterface, SInt32 * theScore){    CFDictionaryRef	plist = 0;    CFArrayRef		plists;    CFArrayRef		factories;    CFMutableArrayRef	candidates;    CFMutableArrayRef	scores;    CFIndex		index;    CFIndex		insert;    CFUUIDRef		factoryID;    kern_return_t	kr;    SInt32		score;    IOCFPlugInInterface **	interface;    Boolean		haveOne;    kr = IOFindPlugIns( service, pluginType,                        &factories, &plists );    if( KERN_SUCCESS != kr) {        if (factories) CFRelease(factories);        if (plists) CFRelease(plists);        return( kr );    }    if ((KERN_SUCCESS != kr)        || (factories == NULL)        || (0 == CFArrayGetCount(factories))) {//        printf("No factories for type/n");        if (factories) CFRelease(factories);        if (plists) CFRelease(plists);        return( kIOReturnUnsupported );    }    candidates = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL);    scores = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL);    // allocate and Probe all    if (candidates && scores) {        CFIndex numfactories = CFArrayGetCount(factories);        for ( index = 0; index < numfactories; index++ ) {            IUnknownVTbl **				iunknown;                factoryID = (CFUUIDRef) CFArrayGetValueAtIndex(factories, index);            iunknown = (IUnknownVTbl **)                CFPlugInInstanceCreate(NULL, factoryID, pluginType);            if (!iunknown) {    //            printf("Failed to create instance (link error?)/n");                continue;            }            (*iunknown)->QueryInterface(iunknown, CFUUIDGetUUIDBytes(interfaceType),                                (LPVOID *)&interface);                // Now we are done with IUnknown interface            (*iunknown)->Release(iunknown);                if (!interface) {    //            printf("Failed to get interface./n");                continue;            }            if (plists)                plist = (CFDictionaryRef) CFArrayGetValueAtIndex( plists, index );            score = 0;   // from property table            kr = (*interface)->Probe(interface, plist, service, &score);                if (kIOReturnSuccess == kr) {                CFIndex numscores = CFArrayGetCount(scores);                for (insert = 0; insert < numscores; insert++) {                    if (score > (SInt32) ((intptr_t) CFArrayGetValueAtIndex(scores, insert)))                        break;                }                CFArrayInsertValueAtIndex(candidates, insert, (void *) interface);                CFArrayInsertValueAtIndex(scores, insert, (void *) (intptr_t) score);            } else                (*interface)->Release(interface);        }    }    // Start in score order    CFIndex candidatecount = CFArrayGetCount(candidates);    for (haveOne = false, index = 0;         index < candidatecount;         index++) {        Boolean freeIt;        if (plists)            plist = (CFDictionaryRef) CFArrayGetValueAtIndex(plists, index );        interface = (IOCFPlugInInterface **)            CFArrayGetValueAtIndex(candidates, index );        if (!haveOne) {            haveOne = (kIOReturnSuccess == (*interface)->Start(interface, plist, service));            freeIt = !haveOne;            if (haveOne) {                *theInterface = interface;                *theScore = (SInt32) (intptr_t)		    CFArrayGetValueAtIndex(scores, index );            }        } else//.........这里部分代码省略.........
开发者ID:StrongZhu,项目名称:IOKitUser,代码行数:101,


示例13: KJSValueToCFTypeInternal

//.........这里部分代码省略.........                        temp = temp->next;                    }                    ObjectImpList imps;                    imps.next = inImps;                    imps.imp = imp;//[...] HACK since we do not have access to the class info we use class name instead#if 0                    if (object->inherits(&ArrayInstanceImp::info))#else                    if (object->className() == "Array")#endif                    {                        isArray = true;                        JSGlueGlobalObject* globalObject = static_cast<JSGlueGlobalObject*>(exec->dynamicGlobalObject());                        if (globalObject && (globalObject->Flags() & kJSFlagConvertAssociativeArray)) {                            PropertyNameArray propNames(exec);                            object->getPropertyNames(exec, propNames);                            PropertyNameArray::const_iterator iter = propNames.begin();                            PropertyNameArray::const_iterator end = propNames.end();                            while(iter != end && isArray)                            {                                Identifier propName = *iter;                                UString ustr = propName.ustring();                                const UniChar* uniChars = (const UniChar*)ustr.characters();                                int size = ustr.length();                                while (size--) {                                    if (uniChars[size] < '0' || uniChars[size] > '9') {                                        isArray = false;                                        break;                                    }                                }                                iter++;                            }                        }                    }                    if (isArray)                    {                        // This is an KJS array                        unsigned int length = object->get(exec, Identifier(exec, "length")).toUInt32(exec);                        result = CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks);                        if (result)                        {                            for (unsigned i = 0; i < length; i++)                            {                                CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, i), exec, &imps);                                CFArrayAppendValue((CFMutableArrayRef)result, cfValue);                                ReleaseCFType(cfValue);                            }                        }                    }                    else                    {                        // Not an array, just treat it like a dictionary which contains (property name, property value) pairs                        PropertyNameArray propNames(exec);                        object->getPropertyNames(exec, propNames);                        {                            result = CFDictionaryCreateMutable(0,                                                               0,                                                               &kCFTypeDictionaryKeyCallBacks,                                                               &kCFTypeDictionaryValueCallBacks);                            if (result)                            {                                PropertyNameArray::const_iterator iter = propNames.begin();                                PropertyNameArray::const_iterator end = propNames.end();                                while(iter != end)                                {                                    Identifier propName = *iter;                                    if (object->hasProperty(exec, propName))                                    {                                        CFStringRef cfKey = IdentifierToCFString(propName);                                        CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, propName), exec, &imps);                                        if (cfKey && cfValue)                                        {                                            CFDictionaryAddValue((CFMutableDictionaryRef)result, cfKey, cfValue);                                        }                                        ReleaseCFType(cfKey);                                        ReleaseCFType(cfValue);                                    }                                    iter++;                                }                            }                        }                    }                }                return result;            }    if (inValue.isUndefinedOrNull())        {            result = RetainCFType(GetCFNull());            return result;        }    ASSERT_NOT_REACHED();    return 0;}
开发者ID:achellies,项目名称:WinCEWebKit,代码行数:101,


示例14: _CFPreferencesCreateDomainList

__private_extern__ CFArrayRef  _CFPreferencesCreateDomainList(CFStringRef  userName, CFStringRef  hostName) {    CFAllocatorRef prefAlloc = __CFPreferencesAllocator();    CFArrayRef  domains;    CFMutableArrayRef  marray;    CFStringRef  *cachedDomainKeys;    CFPreferencesDomainRef *cachedDomains;    SInt32 idx, cnt;    CFStringRef  suffix;    UInt32 suffixLen;    CFURLRef prefDir = _preferencesDirectoryForUserHost(userName, hostName);        if (!prefDir) {        return NULL;    }    if (hostName == kCFPreferencesAnyHost) {        suffix = CFStringCreateWithCString(prefAlloc, ".plist", kCFStringEncodingASCII);    } else if (hostName == kCFPreferencesCurrentHost) {        CFStringRef hostID = _CFPreferencesGetByHostIdentifierString();        suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostID);    } else {        suffix = CFStringCreateWithFormat(prefAlloc, NULL, CFSTR(".%@.plist"), hostName);   // sketchy - this allows someone to create a domain list for an arbitrary hostname.    }    suffixLen = CFStringGetLength(suffix);        domains = (CFArrayRef)CFURLCreatePropertyFromResource(prefAlloc, prefDir, kCFURLFileDirectoryContents, NULL);    CFRelease(prefDir);    if (domains){        marray = CFArrayCreateMutableCopy(prefAlloc, 0, domains);        CFRelease(domains);    } else {        marray = CFArrayCreateMutable(prefAlloc, 0, & kCFTypeArrayCallBacks);    }    for (idx = CFArrayGetCount(marray)-1; idx >= 0; idx --) {        CFURLRef  url = (CFURLRef)CFArrayGetValueAtIndex(marray, idx);        CFStringRef string = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);        if (!CFStringHasSuffix(string, suffix)) {            CFArrayRemoveValueAtIndex(marray, idx);        } else {            CFStringRef  dom = CFStringCreateWithSubstring(prefAlloc, string, CFRangeMake(0, CFStringGetLength(string) - suffixLen));            if (CFEqual(dom, CFSTR(".GlobalPreferences"))) {                CFArraySetValueAtIndex(marray, idx, kCFPreferencesAnyApplication);            } else {                CFArraySetValueAtIndex(marray, idx, dom);            }            CFRelease(dom);        }        CFRelease(string);    }    CFRelease(suffix);        // Now add any domains added in the cache; delete any that have been deleted in the cache    __CFSpinLock(&domainCacheLock);    if (!domainCache) {        __CFSpinUnlock(&domainCacheLock);        return marray;    }    cnt = CFDictionaryGetCount(domainCache);    cachedDomainKeys = (CFStringRef *)CFAllocatorAllocate(prefAlloc, 2 * cnt * sizeof(CFStringRef), 0);    cachedDomains = (CFPreferencesDomainRef *)(cachedDomainKeys + cnt);    CFDictionaryGetKeysAndValues(domainCache, (const void **)cachedDomainKeys, (const void **)cachedDomains);    __CFSpinUnlock(&domainCacheLock);    suffix = _CFPreferencesCachePrefixForUserHost(userName, hostName);    suffixLen = CFStringGetLength(suffix);        for (idx = 0; idx < cnt; idx ++) {        CFStringRef  domainKey = cachedDomainKeys[idx];        CFPreferencesDomainRef domain = cachedDomains[idx];        CFStringRef  domainName;        CFIndex keyCount = 0;                if (!CFStringHasPrefix(domainKey, suffix)) continue;        domainName = CFStringCreateWithSubstring(prefAlloc, domainKey, CFRangeMake(suffixLen, CFStringGetLength(domainKey) - suffixLen));        if (CFEqual(domainName, CFSTR("*"))) {            CFRelease(domainName);            domainName = (CFStringRef)CFRetain(kCFPreferencesAnyApplication);        } else if (CFEqual(domainName, kCFPreferencesCurrentApplication)) {            CFRelease(domainName);            domainName = (CFStringRef)CFRetain(_CFProcessNameString());        }        CFDictionaryRef d = _CFPreferencesDomainDeepCopyDictionary(domain);        keyCount = d ? CFDictionaryGetCount(d) : 0;        if (keyCount) CFRelease(d);        if (keyCount == 0) {            // Domain was deleted            SInt32 firstIndexOfValue = CFArrayGetFirstIndexOfValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName);            if (0 <= firstIndexOfValue) {                CFArrayRemoveValueAtIndex(marray, firstIndexOfValue);            }        } else if (!CFArrayContainsValue(marray, CFRangeMake(0, CFArrayGetCount(marray)), domainName)) {            CFArrayAppendValue(marray, domainName);        }        CFRelease(domainName);    }    CFRelease(suffix);    CFAllocatorDeallocate(prefAlloc, cachedDomainKeys);    return marray;}
开发者ID:CoherentLabs,项目名称:CoherentWebCoreDependencies,代码行数:97,


示例15: proxy_configuration_update

__private_extern__CF_RETURNS_RETAINED CFDictionaryRefproxy_configuration_update(CFDictionaryRef	defaultProxy,			   CFDictionaryRef	services,			   CFArrayRef		serviceOrder,			   CFDictionaryRef	servicesInfo){	CFIndex			i;	CFMutableDictionaryRef	myDefault;	Boolean			myOrderAdded	= FALSE;	CFMutableDictionaryRef	newProxy	= NULL;	CFIndex			n_proxies;	CFDictionaryRef		proxy;	CFMutableArrayRef	proxies;	// establish full list of proxies	proxies = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);	// collect (and add) any "supplemental" proxy configurations	add_supplemental_proxies(proxies, services, serviceOrder);	// add the "default" proxy	add_default_proxy(proxies, defaultProxy, &myOrderAdded);	// sort proxies, cleanup	n_proxies = CFArrayGetCount(proxies);	if (n_proxies > 1) {		CFArraySortValues(proxies, CFRangeMake(0, n_proxies), compareDomain, NULL);	}	// cleanup	for (i = n_proxies - 1; i >= 0; i--) {		proxy = CFArrayGetValueAtIndex(proxies, i);		if ((i > 0) &&		    !CFDictionaryContainsKey(proxy, kSCPropNetProxiesSupplementalMatchDomain)) {			// remove non-supplemental proxy			CFArrayRemoveValueAtIndex(proxies, i);			n_proxies--;			continue;		}		newProxy = CFDictionaryCreateMutableCopy(NULL, 0, proxy);		CFDictionaryRemoveValue(newProxy, PROXY_MATCH_ORDER_KEY);		CFDictionaryRemoveValue(newProxy, ORDER_KEY);		CFArraySetValueAtIndex(proxies, i, newProxy);		CFRelease(newProxy);	}	// update the default proxy	myDefault = CFDictionaryCreateMutableCopy(NULL,						  0,						  CFArrayGetValueAtIndex(proxies, 0));	if (myOrderAdded && (n_proxies > 1)) {		CFDictionaryRef	proxy;		proxy = CFArrayGetValueAtIndex(proxies, 1);		if (CFDictionaryContainsKey(proxy, kSCPropNetProxiesSupplementalMatchDomain)) {			// if not a supplemental "default" proxy (a match domain name is			// present)			CFDictionaryRemoveValue(myDefault, PROXY_MATCH_ORDER_KEY);		}	}	CFArraySetValueAtIndex(proxies, 0, myDefault);	CFRelease(myDefault);	// establish proxy configuration	if (n_proxies > 0) {		CFDictionaryRef		app_layer;		CFDictionaryRef		scoped;		CFArrayRef		serviceOrderAll;		Boolean			skip		= FALSE;		CFArrayRef		supplemental;		proxy = CFArrayGetValueAtIndex(proxies, 0);		if (!CFDictionaryContainsKey(proxy, kSCPropNetProxiesSupplementalMatchDomain)) {			// if we have "a" default (non-supplemental) proxy			newProxy = CFDictionaryCreateMutableCopy(NULL, 0, proxy);			CFDictionaryRemoveValue(newProxy, kSCPropNetProxiesSupplementalMatchDomains);			CFDictionaryRemoveValue(newProxy, kSCPropNetProxiesSupplementalMatchOrders);			skip = TRUE;		} else {			newProxy = CFDictionaryCreateMutable(NULL,							     0,							     &kCFTypeDictionaryKeyCallBacks,							     &kCFTypeDictionaryValueCallBacks);		}		serviceOrderAll = service_order_copy_all(services, serviceOrder);		// collect (and add) any "supplemental" proxy configurations		supplemental = copy_supplemental_proxies(proxies, skip);//.........这里部分代码省略.........
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:101,


示例16: rb_keychain_find

static VALUE rb_keychain_find(int argc, VALUE *argv, VALUE self){  VALUE kind;  VALUE attributes;  VALUE first_or_all;  rb_scan_args(argc, argv, "2:", &first_or_all, &kind, &attributes);  Check_Type(first_or_all, T_SYMBOL);  Check_Type(kind, T_STRING);    CFMutableDictionaryRef query = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);  CFDictionarySetValue(query, kSecReturnAttributes, kCFBooleanTrue);  CFDictionarySetValue(query, kSecReturnRef, kCFBooleanTrue);    if(rb_to_id(first_or_all) == rb_intern("all")){    CFDictionarySetValue(query, kSecMatchLimit, kSecMatchLimitAll);  }  rb_add_value_to_cf_dictionary(query, kSecClass, kind);  if(!NIL_P(attributes)){    Check_Type(attributes, T_HASH);    VALUE rb_keychains = rb_hash_aref(attributes, ID2SYM(rb_intern("keychains")));    if(!NIL_P(rb_keychains)){      Check_Type(rb_keychains, T_ARRAY);      CFMutableArrayRef searchArray = CFArrayCreateMutable(NULL, RARRAY_LEN(rb_keychains), &kCFTypeArrayCallBacks);      for(int index=0; index < RARRAY_LEN(rb_keychains); index++){        SecKeychainRef keychain = NULL;        Data_Get_Struct(RARRAY_PTR(rb_keychains)[index], struct OpaqueSecKeychainRef, keychain);        CFArrayAppendValue(searchArray, keychain);      }      CFDictionarySetValue(query, kSecMatchSearchList,searchArray);      CFRelease(searchArray);    }      VALUE limit = rb_hash_aref(attributes, ID2SYM(rb_intern("limit")));    if(!NIL_P(limit)){      Check_Type(limit, T_FIXNUM);      long c_limit = FIX2LONG(limit);      CFNumberRef cf_limit = CFNumberCreate(NULL, kCFNumberLongType, &c_limit);      CFDictionarySetValue(query, kSecMatchLimit, cf_limit);      CFRelease(cf_limit);    }    VALUE conditions = rb_hash_aref(attributes, ID2SYM(rb_intern("conditions")));        if(!NIL_P(conditions)){      Check_Type(conditions, T_HASH);      VALUE rQuery = Data_Wrap_Struct(rb_cPointerWrapper, NULL, NULL, query);      rb_block_call(conditions, rb_intern("each"), 0, NULL, RUBY_METHOD_FUNC(add_conditions_to_query), rQuery);    }  }  CFDictionaryRef result;  OSStatus status = SecItemCopyMatching(query, (CFTypeRef*)&result);  CFRelease(query);  VALUE rb_item = rb_ary_new2(0);  switch(status){    case errSecItemNotFound:       break;    default:    CheckOSStatusOrRaise(status);    if(CFArrayGetTypeID() == CFGetTypeID(result)){      CFArrayRef result_array = (CFArrayRef)result;      for(CFIndex i = 0; i < CFArrayGetCount(result_array); i++){        rb_ary_push(rb_item,rb_keychain_item_from_sec_dictionary(CFArrayGetValueAtIndex(result_array,i)));      }    }    else{      rb_ary_push(rb_item, rb_keychain_item_from_sec_dictionary(result));    }    CFRelease(result);  }  if(rb_to_id(first_or_all) == rb_intern("first")){    return rb_ary_entry(rb_item,0);  }  else{    return rb_item;  }}
开发者ID:fcheung,项目名称:keychain_c,代码行数:87,


示例17: AddCommands

Boolean AddCommands( SRRecognizer inSpeechRecognizer, SRLanguageModel inCommandsLangaugeModel, CFArrayRef inCommandNamesArray ){    // Dictionary keys for Commands Data property list    #define	kCommandsDataPlacementHintKey			"PlacementHint"			// value type is: CFNumberRef        #define	kPlacementHintWhereverNumValue			0        #define	kPlacementHintProcessNumValue			1					// you must also provide the PSN using kCommandsDataProcessPSNHighKey & kCommandsDataProcessPSNLowKey        #define	kPlacementHintFirstNumValue				2        #define	kPlacementHintMiddleNumValue			3        #define	kPlacementHintLastNumValue				4    #define	kCommandsDataProcessPSNHighKey			"ProcessPSNHigh"		// value type is: CFNumberRef    #define	kCommandsDataProcessPSNLowKey			"ProcessPSNLow"			// value type is: CFNumberRef    #define	kCommandsDataDisplayOrderKey				"DisplayOrder"			// value type is: CFNumberRef  - the order in which recognizers from the same client process should be displayed.    #define	kCommandsDataCmdInfoArrayKey				"CommandInfoArray"		// value type is: CFArrayRef of CFDictionaryRef values        #define	kCommandInfoNameKey						"Text"        #define	kCommandInfoChildrenKey					"Children"    Boolean	successfullyAddCommands = false;        if (inCommandNamesArray) {            CFIndex	numOfCommands = CFArrayGetCount( inCommandNamesArray );        CFMutableArrayRef	theSectionArray = CFArrayCreateMutable( NULL, 0, &kCFTypeArrayCallBacks );                // Erase any existing commands in the language model before we begin adding the given list of commands        if (SREmptyLanguageObject( inCommandsLangaugeModel ) == noErr && theSectionArray) {                    CFIndex	i;            char 	theCSringBuffer[100];            successfullyAddCommands = true;            for (i = 0; i < numOfCommands; i++) {                                CFStringRef	theCommandName = CFArrayGetValueAtIndex(inCommandNamesArray, i);                if (theCommandName && CFStringGetCString( theCommandName, theCSringBuffer, 100, kCFStringEncodingMacRoman )) {                                        if (SRAddText( inCommandsLangaugeModel, theCSringBuffer, strlen(theCSringBuffer), i) == noErr) {                            CFStringRef 	keys[1];                        CFTypeRef		values[1];                        CFDictionaryRef theItemDict;                                                keys[0] 	= CFSTR( kCommandInfoNameKey );                        values[0] 	= theCommandName;                                                // Make CDDictionary our keys and values.                        theItemDict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 1, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);                                                // Add to command array                        if (theItemDict) {                            CFArrayAppendValue( theSectionArray, theItemDict );                            CFRelease( theItemDict );  // We release our hold on the dictionary object and let the array own it now.                        }                        else                            successfullyAddCommands = false;                    }                    else                        successfullyAddCommands = false;                                        if (! successfullyAddCommands)                        break;                }            }                //            // Create the XML data that contains the commands to display and give this data to the            // recognizer object to display in the Speech Commands window.            //            {                CFIndex				numOfParams = 4;                CFStringRef 		keys[numOfParams];                CFTypeRef			values[numOfParams];                CFDictionaryRef 	theItemDict;                SInt32				placementHint = 1;	// 1 = show only when this app is front process                ProcessSerialNumber	thisAppsPSN;                                thisAppsPSN.highLongOfPSN = 0;                thisAppsPSN.lowLongOfPSN = 0;                        GetCurrentProcess( &thisAppsPSN );                            keys[0] 	= CFSTR( kCommandsDataPlacementHintKey );                keys[1] 	= CFSTR( kCommandsDataCmdInfoArrayKey );                keys[2] 	= CFSTR( kCommandsDataProcessPSNHighKey );                keys[3] 	= CFSTR( kCommandsDataProcessPSNLowKey );                values[0] 	= CFNumberCreate(NULL, kCFNumberSInt32Type, &placementHint);                values[1] 	= theSectionArray;                values[2] 	= CFNumberCreate(NULL, kCFNumberSInt32Type, &(thisAppsPSN.highLongOfPSN));                values[3] 	= CFNumberCreate(NULL, kCFNumberSInt32Type, &(thisAppsPSN.lowLongOfPSN));                                    // Make CDDictionary of our keys and values.                theItemDict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, numOfParams, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);                if (theItemDict) {                                    // Convert CFDictionary object to XML representation                    CFDataRef dictData = CFPropertyListCreateXMLData(NULL, theItemDict);                    if (dictData) {                    	// Set command list in our SRRecognizer object, causing the Speech Commands window to update.                        (void)SRSetProperty (inSpeechRecognizer, 'cdpl', CFDataGetBytePtr(dictData), CFDataGetLength(dictData));//.........这里部分代码省略.........
开发者ID:arnelh,项目名称:Examples,代码行数:101,


示例18: do_dictSetKey

__private_extern__voiddo_dictSetKey(int argc, char **argv){	CFMutableArrayRef	array		= NULL;	Boolean			doArray		= FALSE;	Boolean			doBoolean	= FALSE;	Boolean			doData		= FALSE;	Boolean			doNumeric	= FALSE;	CFStringRef		key;	CFMutableDictionaryRef	newValue;	CFTypeRef		val		= NULL;	if (value == NULL) {		SCPrint(TRUE, stdout, CFSTR("d.add: dictionary must be initialized./n"));		return;	}	if (!isA_CFDictionary(value)) {		SCPrint(TRUE, stdout, CFSTR("d.add: data (fetched from configuration server) is not a dictionary./n"));		return;	}	key = CFStringCreateWithCString(NULL, argv[0], kCFStringEncodingUTF8);	argv++; argc--;	while (argc > 0) {		if (strcmp(argv[0], "*") == 0) {			/* if array requested */			doArray = TRUE;		} else if (strcmp(argv[0], "-") == 0) {			/* if string values requested */		} else if (strcmp(argv[0], "?") == 0) {			/* if boolean values requested */			doBoolean = TRUE;		} else if (strcmp(argv[0], "%") == 0) {			/* if [hex] data values requested */			doData = TRUE;		} else if (strcmp(argv[0], "#") == 0) {			/* if numeric values requested */			doNumeric = TRUE;		} else {			/* it's not a special flag */			break;		}		argv++; argc--;	}	if (argc > 1) {		doArray = TRUE;	} else if (!doArray && (argc == 0)) {		SCPrint(TRUE, stdout, CFSTR("d.add: no values./n"));		CFRelease(key);		return;	}	if (doArray) {		array = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);	}	while (argc > 0) {		if (doBoolean) {			if         ((strcasecmp(argv[0], "true") == 0) ||				    (strcasecmp(argv[0], "t"   ) == 0) ||				    (strcasecmp(argv[0], "yes" ) == 0) ||				    (strcasecmp(argv[0], "y"   ) == 0) ||				    (strcmp    (argv[0], "1"   ) == 0)) {				val = CFRetain(kCFBooleanTrue);			} else if ((strcasecmp(argv[0], "false") == 0) ||				   (strcasecmp(argv[0], "f"    ) == 0) ||				   (strcasecmp(argv[0], "no"   ) == 0) ||				   (strcasecmp(argv[0], "n"    ) == 0) ||				   (strcmp    (argv[0], "0"    ) == 0)) {				val = CFRetain(kCFBooleanFalse);			} else {				SCPrint(TRUE, stdout, CFSTR("d.add: invalid data./n"));				if (doArray) CFRelease(array);				CFRelease(key);				return;			}		} else if (doData) {			uint8_t			*bytes;			CFMutableDataRef	data;			int			i;			int			j;			int			n;			n = strlen(argv[0]);			if ((n % 2) == 1) {				SCPrint(TRUE, stdout, CFSTR("d.add: not enough bytes./n"));				if (doArray) CFRelease(array);				CFRelease(key);				return;			}			data = CFDataCreateMutable(NULL, (n / 2));			CFDataSetLength(data, (n / 2));			bytes = (uint8_t *)CFDataGetBytePtr(data);			for (i = 0, j = 0; i < n; i += 2, j++) {//.........这里部分代码省略.........
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:101,


示例19: APCreateDictionaryForLicenseData

CFDictionaryRef APCreateDictionaryForLicenseData(CFDataRef data){    if (!rsaKey->n || !rsaKey->e)        return NULL;        // Make the property list from the data    CFStringRef errorString = NULL;    CFPropertyListRef propertyList;    propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, data, kCFPropertyListMutableContainers, &errorString);    if (errorString || CFDictionaryGetTypeID() != CFGetTypeID(propertyList) || !CFPropertyListIsValid(propertyList, kCFPropertyListXMLFormat_v1_0)) {        if (propertyList)            CFRelease(propertyList);        return NULL;    }        // Load the signature    CFMutableDictionaryRef licenseDictionary = (CFMutableDictionaryRef)propertyList;    if (!CFDictionaryContainsKey(licenseDictionary, CFSTR("Signature"))) {        CFRelease(licenseDictionary);        return NULL;    }        CFDataRef sigData = CFDictionaryGetValue(licenseDictionary, CFSTR("Signature"));	CFIndex sigDataLength = CFDataGetLength(sigData);	UInt8 sigBytes[sigDataLength];    CFDataGetBytes(sigData, CFRangeMake(0, sigDataLength), sigBytes);    CFDictionaryRemoveValue(licenseDictionary, CFSTR("Signature"));        // Decrypt the signature	int checkDigestMaxSize = RSA_size(rsaKey)-11;    unsigned char checkDigest[checkDigestMaxSize];    if (RSA_public_decrypt((int) sigDataLength, sigBytes, checkDigest, rsaKey, RSA_PKCS1_PADDING) != SHA_DIGEST_LENGTH) {        CFRelease(licenseDictionary);        return NULL;    }        // Get the license hash    CFMutableStringRef hashCheck = CFStringCreateMutable(kCFAllocatorDefault,0);    int hashIndex;    for (hashIndex = 0; hashIndex < SHA_DIGEST_LENGTH; hashIndex++)        CFStringAppendFormat(hashCheck, nil, CFSTR("%02x"), checkDigest[hashIndex]);    APSetHash(hashCheck);    CFRelease(hashCheck);        if (blacklist && (CFArrayContainsValue(blacklist, CFRangeMake(0, CFArrayGetCount(blacklist)), hash) == true))        return NULL;        // Get the number of elements    CFIndex count = CFDictionaryGetCount(licenseDictionary);    // Load the keys and build up the key array    CFMutableArrayRef keyArray = CFArrayCreateMutable(kCFAllocatorDefault, count, NULL);    CFStringRef keys[count];    CFDictionaryGetKeysAndValues(licenseDictionary, (const void**)&keys, NULL);    int i;    for (i = 0; i < count; i++)        CFArrayAppendValue(keyArray, keys[i]);        // Sort the array    int context = kCFCompareCaseInsensitive;    CFArraySortValues(keyArray, CFRangeMake(0, count), (CFComparatorFunction)CFStringCompare, &context);        // Setup up the hash context    SHA_CTX ctx;    SHA1_Init(&ctx);    // Convert into UTF8 strings    for (i = 0; i < count; i++)    {        char *valueBytes;        CFIndex valueLengthAsUTF8;        CFStringRef key = CFArrayGetValueAtIndex(keyArray, i);        CFStringRef value = CFDictionaryGetValue(licenseDictionary, key);                // Account for the null terminator        valueLengthAsUTF8 = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value), kCFStringEncodingUTF8) + 1;        valueBytes = (char *)malloc(valueLengthAsUTF8);        CFStringGetCString(value, valueBytes, valueLengthAsUTF8, kCFStringEncodingUTF8);        SHA1_Update(&ctx, valueBytes, strlen(valueBytes));        free(valueBytes);    }    unsigned char digest[SHA_DIGEST_LENGTH];    SHA1_Final(digest, &ctx);        if (keyArray != NULL)        CFRelease(keyArray);        // Check if the signature is a match        for (i = 0; i < SHA_DIGEST_LENGTH; i++) {        if (checkDigest[i] ^ digest[i]) {            CFRelease(licenseDictionary);            return NULL;        }    }        // If it's a match, we return the dictionary; otherwise, we never reach this    return licenseDictionary;}
开发者ID:samdeane,项目名称:AquaticPrime,代码行数:96,


示例20: IOHIDManagerSetDeviceMatchingMultiple

void *_ykusb_open_device(int vendor_id, int *product_ids, size_t pids_len){	void *yk = NULL;	int rc = YK_ENOKEY;	size_t i;	IOHIDManagerSetDeviceMatchingMultiple( ykosxManager, NULL );	CFSetRef devSet = IOHIDManagerCopyDevices( ykosxManager );	if ( devSet ) {		CFMutableArrayRef array = CFArrayCreateMutable( kCFAllocatorDefault, 0, NULL );		CFSetApplyFunction( devSet, _ykosx_CopyToCFArray, array );		CFIndex cnt = CFArrayGetCount( array );		CFIndex i;		for(i = 0; i < cnt; i++) {			IOHIDDeviceRef dev = (IOHIDDeviceRef)CFArrayGetValueAtIndex( array, i );			long devVendorId = _ykosx_getIntProperty( dev, CFSTR( kIOHIDVendorIDKey ));			if(devVendorId == vendor_id) {				long devProductId = _ykosx_getIntProperty( dev, CFSTR( kIOHIDProductIDKey ));				size_t j;				for(j = 0; j < pids_len; j++) {					if(product_ids[j] == devProductId) {						if(yk == NULL) {							yk = dev;							break;						} else {							rc = YK_EMORETHANONE;							break;						}					}				}			}			if(rc == YK_EMORETHANONE) {				yk = NULL;				break;			}		}		if(rc != YK_EMORETHANONE) {			rc = YK_ENOKEY;		}		/* this is a workaround for a memory leak in IOHIDManagerCopyDevices() in 10.8 */		IOHIDManagerScheduleWithRunLoop( ykosxManager, CFRunLoopGetCurrent( ), kCFRunLoopDefaultMode );		IOHIDManagerUnscheduleFromRunLoop( ykosxManager, CFRunLoopGetCurrent( ), kCFRunLoopDefaultMode );		CFRelease( array );		CFRelease( devSet );	}	if (yk) {		CFRetain(yk);		_ykusb_IOReturn = IOHIDDeviceOpen( yk, 0L );		if ( _ykusb_IOReturn != kIOReturnSuccess ) {			CFRelease(yk);			rc = YK_EUSBERR;			goto error;		}		return yk;	}error:	yk_errno = rc;	return 0;}
开发者ID:bradfa,项目名称:yubikey-personalization,代码行数:74,


示例21: SecPathBuilderInit

static void SecPathBuilderInit(SecPathBuilderRef builder,	CFArrayRef certificates, CFArrayRef anchors, bool anchorsOnly,    CFArrayRef policies, CFAbsoluteTime verifyTime,    SecPathBuilderCompleted completed, const void *context) {    secdebug("alloc", "%p", builder);	CFAllocatorRef allocator = kCFAllocatorDefault;	builder->nextParentSource = 1;	builder->considerPartials = false;    builder->canAccessNetwork = true;    builder->anchorSources = CFArrayCreateMutable(allocator, 0, NULL);    builder->parentSources = CFArrayCreateMutable(allocator, 0, NULL);    builder->allPaths = CFSetCreateMutable(allocator, 0,		&kCFTypeSetCallBacks);    builder->partialPaths = CFArrayCreateMutable(allocator, 0, NULL);    builder->rejectedPaths = CFArrayCreateMutable(allocator, 0, NULL);    builder->candidatePaths = CFArrayCreateMutable(allocator, 0, NULL);    builder->partialIX = 0;    /* Init the policy verification context. */    SecPVCInit(&builder->path, builder, policies, verifyTime);	builder->bestPath = NULL;	builder->bestPathIsEV = false;	builder->rejectScore = 0;	/* Let's create all the certificate sources we might want to use. */	builder->certificateSource =		SecMemoryCertificateSourceCreate(certificates);	if (anchors)		builder->anchorSource = SecMemoryCertificateSourceCreate(anchors);	else		builder->anchorSource = NULL;	/* We always search certificateSource for parents since it includes the	   leaf itself and it might be self signed. */	CFArrayAppendValue(builder->parentSources, builder->certificateSource);	if (builder->anchorSource) {		CFArrayAppendValue(builder->anchorSources, builder->anchorSource);	}	CFArrayAppendValue(builder->parentSources, &kSecItemCertificateSource);    if (anchorsOnly) {        /* Add the system and user anchor certificate db to the search list           if we don't explicitly trust them. */        CFArrayAppendValue(builder->parentSources, &kSecSystemAnchorSource);        CFArrayAppendValue(builder->parentSources, &kSecUserAnchorSource);    } else {        /* Only add the system and user anchor certificate db to the           anchorSources if we are supposed to trust them. */        CFArrayAppendValue(builder->anchorSources, &kSecSystemAnchorSource);        CFArrayAppendValue(builder->anchorSources, &kSecUserAnchorSource);    }    CFArrayAppendValue(builder->parentSources, &kSecCAIssuerSource);	/* Now let's get the leaf cert and turn it into a path. */	SecCertificateRef leaf =		(SecCertificateRef)CFArrayGetValueAtIndex(certificates, 0);	SecCertificatePathRef path = SecCertificatePathCreate(NULL, leaf);	CFSetAddValue(builder->allPaths, path);	CFArrayAppendValue(builder->partialPaths, path);    if (SecPathBuilderIsAnchor(builder, leaf)) {        SecCertificatePathSetIsAnchored(path);        CFArrayAppendValue(builder->candidatePaths, path);    }    SecPathBuilderLeafCertificateChecks(builder, path);	CFRelease(path);    builder->activations = 0;    builder->state = SecPathBuilderGetNext;    builder->completed = completed;    builder->context = context;}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:73,


示例22: main

intmain(int argc, char **argv){	CFDictionaryRef		entities;	CFStringRef		key;	CFDictionaryRef		newProxy	= NULL;	CFStringRef		pattern;	CFMutableArrayRef	patterns;	CFStringRef		primary		= NULL;	CFMutableDictionaryRef	primary_proxy	= NULL;	CFArrayRef		service_order	= NULL;	CFMutableDictionaryRef	service_state_dict;	CFDictionaryRef		setup_global_ipv4;	CFDictionaryRef		state_global_ipv4;	SCDynamicStoreRef	store;	_sc_log     = FALSE;	_sc_verbose = (argc > 1) ? TRUE : FALSE;	store = SCDynamicStoreCreate(NULL, CFSTR("TEST"), NULL, NULL);	// get IPv4, IPv6, and Proxies entities	patterns = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);	pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,							      kSCDynamicStoreDomainState,							      kSCCompAnyRegex,							      kSCEntNetIPv4);	CFArrayAppendValue(patterns, pattern);	CFRelease(pattern);	pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,							      kSCDynamicStoreDomainState,							      kSCCompAnyRegex,							      kSCEntNetIPv6);	CFArrayAppendValue(patterns, pattern);	CFRelease(pattern);	pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,							      kSCDynamicStoreDomainSetup,							      kSCCompAnyRegex,							      kSCEntNetProxies);	CFArrayAppendValue(patterns, pattern);	CFRelease(pattern);	pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,							      kSCDynamicStoreDomainState,							      kSCCompAnyRegex,							      kSCEntNetProxies);	CFArrayAppendValue(patterns, pattern);	CFRelease(pattern);	entities = SCDynamicStoreCopyMultiple(store, NULL, patterns);	CFRelease(patterns);	service_state_dict = CFDictionaryCreateMutable(NULL,						       0,						       &kCFTypeDictionaryKeyCallBacks,						       &kCFTypeDictionaryValueCallBacks);	CFDictionaryApplyFunction(entities, split, service_state_dict);	CFRelease(entities);	// get primary service ID	key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,							 kSCDynamicStoreDomainState,							 kSCEntNetIPv4);	state_global_ipv4 = SCDynamicStoreCopyValue(store, key);	CFRelease(key);	if (state_global_ipv4 != NULL) {		primary = CFDictionaryGetValue(state_global_ipv4, kSCDynamicStorePropNetPrimaryService);		if (primary != NULL) {			CFDictionaryRef	service_dict;			// get proxy configuration for primary service			service_dict = CFDictionaryGetValue(service_state_dict, primary);			if (service_dict != NULL) {				CFDictionaryRef	service_proxy;				service_proxy = CFDictionaryGetValue(service_dict, kSCEntNetProxies);				if (service_proxy != NULL) {					primary_proxy = CFDictionaryCreateMutableCopy(NULL, 0, service_proxy);					CFDictionaryRemoveValue(primary_proxy, kSCPropInterfaceName);				}			}		}	}	// get serviceOrder	key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,							 kSCDynamicStoreDomainSetup,							 kSCEntNetIPv4);	setup_global_ipv4 = SCDynamicStoreCopyValue(store, key);	CFRelease(key);	if (setup_global_ipv4 != NULL) {		service_order = CFDictionaryGetValue(setup_global_ipv4, kSCPropNetServiceOrder);	}	// update proxy configuration	proxy_configuration_init(CFBundleGetMainBundle());	newProxy = proxy_configuration_update(primary_proxy,					      service_state_dict,					      service_order,					      NULL);	if (newProxy != NULL) {		SCPrint(TRUE, stdout, CFSTR("%@/n"), newProxy);//.........这里部分代码省略.........
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:101,


示例23: main

int main(int argc, char **argv) {	int i;		if (argc <= 1) {		// TODO: Man page?		fprintf(stderr, "Usage: abquery <name>/n"						"The <name> parameter accepts similarities: /"dan fer/" matches /"D
C++ CFArrayGetCount函数代码示例
C++ CFArrayCreate函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。