本文整理匯總了C++中CFArrayAppendValue函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFArrayAppendValue函數的具體用法?C++ CFArrayAppendValue怎麽用?C++ CFArrayAppendValue使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFArrayAppendValue函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CFArrayInsertValueAtIndex
bool CACFArray::InsertCFType(UInt32 inIndex, const CFTypeRef inItem)
{
bool theAnswer = false;
if((mCFArray != NULL) && mMutable)
{
if(inIndex < GetNumberItems())
{
CFArrayInsertValueAtIndex(mCFArray, inIndex, inItem);
}
else
{
CFArrayAppendValue(mCFArray, inItem);
}
theAnswer = true;
}
return theAnswer;
}
示例2: InstallLoginLogoutNotifiers
int InstallLoginLogoutNotifiers(CFRunLoopSourceRef* RunloopSourceReturned)
{
SCDynamicStoreContext DynamicStoreContext = { 0, NULL, NULL, NULL, NULL };
SCDynamicStoreRef DynamicStoreCommunicationMechanism = NULL;
CFStringRef KeyRepresentingConsoleUserNameChange = NULL;
CFMutableArrayRef ArrayOfNotificationKeys;
Boolean Result;
*RunloopSourceReturned = NULL;
DynamicStoreCommunicationMechanism = SCDynamicStoreCreate(NULL, CFSTR("logKext"), LoginLogoutCallBackFunction, &DynamicStoreContext);
if (DynamicStoreCommunicationMechanism == NULL)
return(-1); //unable to create dynamic store.
KeyRepresentingConsoleUserNameChange = SCDynamicStoreKeyCreateConsoleUser(NULL);
if (KeyRepresentingConsoleUserNameChange == NULL)
{
CFRelease(DynamicStoreCommunicationMechanism);
return(-2);
}
ArrayOfNotificationKeys = CFArrayCreateMutable(NULL, (CFIndex)1, &kCFTypeArrayCallBacks);
if (ArrayOfNotificationKeys == NULL)
{
CFRelease(DynamicStoreCommunicationMechanism);
CFRelease(KeyRepresentingConsoleUserNameChange);
return(-3);
}
CFArrayAppendValue(ArrayOfNotificationKeys, KeyRepresentingConsoleUserNameChange);
Result = SCDynamicStoreSetNotificationKeys(DynamicStoreCommunicationMechanism, ArrayOfNotificationKeys, NULL);
CFRelease(ArrayOfNotificationKeys);
CFRelease(KeyRepresentingConsoleUserNameChange);
if (Result == FALSE) //unable to add keys to dynamic store.
{
CFRelease(DynamicStoreCommunicationMechanism);
return(-4);
}
*RunloopSourceReturned = SCDynamicStoreCreateRunLoopSource(NULL, DynamicStoreCommunicationMechanism, (CFIndex) 0);
return(0);
}
示例3: pam_select_credential
CUI_EXPORT int
pam_select_credential(pam_handle_t *pamh, int flags)
{
int rc;
CUIControllerRef controller = NULL;
CFDictionaryRef attributes = NULL;
CFDictionaryRef credAttributes = NULL;
CFMutableArrayRef creds = NULL;
CUICredentialRef selectedCred = NULL;
char *user = NULL, *pass = NULL;
__block CFIndex defaultCredentialIndex = kCFNotFound;
controller = CUIControllerCreate(kCFAllocatorDefault, kCUIUsageScenarioLogin, kCUIUsageFlagsConsole);
if (controller == NULL) {
rc = PAM_SERVICE_ERR;
goto cleanup;
}
CUIControllerSetContext(controller, pamh);
creds = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
if (creds == NULL) {
rc = PAM_BUF_ERR;
goto cleanup;
}
rc = _PAMSetTargetNameWithService(pamh, controller);
if (rc != PAM_SUCCESS)
goto cleanup;
rc = _PAMCreateAttributesFromHandle(pamh, &attributes);
if (rc == PAM_BUF_ERR)
goto cleanup;
else if (attributes)
CUIControllerSetAttributes(controller, attributes);
CUIControllerEnumerateCredentials(controller, ^(CUICredentialRef cred, Boolean isDefault, CFErrorRef err) {
if (cred) {
if (isDefault)
defaultCredentialIndex = CFArrayGetCount(creds);
CFArrayAppendValue(creds, cred);
}
});
示例4: iohidmanager_hid_append_matching_dictionary
static void iohidmanager_hid_append_matching_dictionary(
CFMutableArrayRef array,
uint32_t page, uint32_t use)
{
CFMutableDictionaryRef matcher = CFDictionaryCreateMutable(
kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFNumberRef pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
CFNumberRef usen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &use);
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsagePageKey), pagen);
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsageKey), usen);
CFArrayAppendValue(array, matcher);
CFRelease(pagen);
CFRelease(usen);
CFRelease(matcher);
}
示例5: main
int main(int argc, char **argv)
{
bool quiet = false;
int arg;
while ((arg = getopt(argc, argv, "qh")) != -1) {
switch (arg) {
case 'q':
quiet = true;
break;
case 'h':
usage(argv);
}
}
unsigned numCerts = argc - optind;
if(numCerts == 0) {
usage(argv);
}
CFMutableArrayRef certArray = CFArrayCreateMutable(NULL, 0,
&kCFTypeArrayCallBacks);
for(int dex=optind; dex<argc; dex++) {
SecCertificateRef certRef = certFromFile(argv[dex]);
if(certRef == NULL) {
exit(1);
}
CFArrayAppendValue(certArray, certRef);
CFRelease(certRef);
}
OSStatus ortn;
SecPolicyRef policyRef = NULL;
ortn = SecPolicyCopy(CSSM_CERT_X_509v3, &CSSMOID_APPLE_TP_SSL, &policyRef);
if(ortn) {
cssmPerror("SecPolicyCopy", ortn);
exit(1);
}
int ourRtn = doTest(certArray, policyRef, quiet);
CFRelease(policyRef);
CFRelease(certArray);
return ourRtn;
}
示例6: diff_mungeHelper
void diff_mungeHelper(CFStringRef token, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash, CFMutableStringRef chars) {
#define diff_UniCharMax (~(UniChar)0x00)
CFIndex hash;
if (CFDictionaryGetValueIfPresent(tokenHash, token, (const void **)&hash)) {
const UniChar hashChar = (UniChar)hash;
CFStringAppendCharacters(chars, &hashChar, 1);
} else {
CFArrayAppendValue(tokenArray, token);
hash = CFArrayGetCount(tokenArray) - 1;
check_string(hash <= diff_UniCharMax, "Hash value has exceeded UniCharMax!");
CFDictionaryAddValue(tokenHash, token, (void *)hash);
const UniChar hashChar = (UniChar)hash;
CFStringAppendCharacters(chars, &hashChar, 1);
}
#undef diff_UniCharMax
}
示例7: AddEventDictionary
void AddEventDictionary(CFDictionaryRef eventDict, CFMutableDictionaryRef allEventsDictionary, NetBrowserInfo* key)
{
CFMutableArrayRef eventsForBrowser = (CFMutableArrayRef)CFDictionaryGetValue(allEventsDictionary, key);
if (!eventsForBrowser) // We have no events for this browser yet, lets add him.
{
eventsForBrowser = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
CFDictionarySetValue(allEventsDictionary, key, eventsForBrowser);
asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s:%s creating a new array", sPluginIdentifier, __FUNCTION__);
}
else
{
asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s:%s Incrementing refcount", sPluginIdentifier, __FUNCTION__);
CFRetain(eventsForBrowser);
}
CFArrayAppendValue(eventsForBrowser, eventDict);
CFRelease(eventsForBrowser);
}
示例8: EAPOLClientConfigurationCopyLoginWindowProfiles
/*
* Function: EAPOLClientConfigurationCopyLoginWindowProfiles
*
* Purpose:
* Return the list of profiles configured for LoginWindow mode on the
* specified BSD network interface (e.g. "en0", "en1").
*
* Returns:
* NULL if no profiles are defined, non-NULL non-empty array of profiles
* otherwise.
*/
CFArrayRef /* of EAPOLClientProfileRef */
EAPOLClientConfigurationCopyLoginWindowProfiles(EAPOLClientConfigurationRef cfg,
CFStringRef if_name)
{
int count;
int i;
CFDictionaryRef dict;
CFArrayRef profile_ids;
CFMutableArrayRef ret_profiles = NULL;
dict = get_eapol_configuration(get_sc_prefs(cfg), if_name, NULL);
if (dict == NULL) {
goto done;
}
profile_ids = CFDictionaryGetValue(dict, kLoginWindowProfileIDs);
if (isA_CFArray(profile_ids) == NULL) {
goto done;
}
count = CFArrayGetCount(profile_ids);
if (count == 0) {
goto done;
}
ret_profiles = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks);
for (i = 0; i < count; i++) {
CFStringRef profileID;
EAPOLClientProfileRef profile;
profileID = (CFStringRef)CFArrayGetValueAtIndex(profile_ids, i);
if (isA_CFString(profileID) == NULL) {
continue;
}
profile = EAPOLClientConfigurationGetProfileWithID(cfg, profileID);
if (profile != NULL) {
CFArrayAppendValue(ret_profiles, profile);
}
}
if (CFArrayGetCount(ret_profiles) == 0) {
my_CFRelease(&ret_profiles);
}
done:
return (ret_profiles);
}
示例9: dsConvertAuthAuthorityToCFDict
bool
CAuthAuthority::AddValue( const char *inAuthAuthorityStr )
{
bool added = false;
CFMutableDictionaryRef aaDict = dsConvertAuthAuthorityToCFDict( inAuthAuthorityStr );
if ( aaDict != NULL )
{
if ( mValueArray == NULL )
mValueArray = CFArrayCreateMutable( kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks );
if ( mValueArray != NULL ) {
CFArrayAppendValue( mValueArray, aaDict );
added = true;
}
CFRelease( aaDict );
}
return added;
}
示例10: RbMIDIReadProc
// The callback function that we'll eventually supply to MIDIInputPortCreate
static void RbMIDIReadProc(const MIDIPacketList* packetList, void* readProcRefCon, void* srcConnRefCon)
{
if( pthread_mutex_lock(&mutex) != 0 )
{
// uh oh
// Not much we can do
return;
}
MIDIPacket* current_packet = (MIDIPacket*) packetList->packet;
unsigned int j;
for( j = 0; j < packetList->numPackets; ++j )
{
RbMIDIPacket* rb_packet = (RbMIDIPacket*) malloc( sizeof(RbMIDIPacket) );
if( rb_packet == NULL )
{
fprintf(stderr, "Failed to allocate memory for RbMIDIPacket!\n");
abort();
}
rb_packet->timeStamp = current_packet->timeStamp;
rb_packet->length = current_packet->length;
size_t size = sizeof(Byte) * rb_packet->length;
rb_packet->data = (Byte*) malloc( size );
if( rb_packet->data == NULL )
{
fprintf(stderr, "Failed to allocate memory for RbMIDIPacket data!\n");
abort();
}
memcpy(rb_packet->data, current_packet->data, size);
CFArrayAppendValue(midi_data, rb_packet);
current_packet = MIDIPacketNext(current_packet);
}
pthread_mutex_unlock(&mutex);
}
示例11: decode
bool decode(ArgumentDecoder* decoder, RetainPtr<CFArrayRef>& result)
{
uint64_t size;
if (!decoder->decodeUInt64(size))
return false;
RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
for (size_t i = 0; i < size; ++i) {
RetainPtr<CFTypeRef> element;
if (!decode(decoder, element))
return false;
CFArrayAppendValue(array.get(), element.get());
}
result.adoptCF(array.leakRef());
return true;
}
示例12: url
void ResourceRequest::doUpdatePlatformRequest()
{
CFMutableURLRequestRef cfRequest;
RetainPtr<CFURLRef> url(AdoptCF, ResourceRequest::url().createCFURL());
RetainPtr<CFURLRef> firstPartyForCookies(AdoptCF, ResourceRequest::firstPartyForCookies().createCFURL());
if (m_cfRequest) {
cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get());
CFURLRequestSetURL(cfRequest, url.get());
CFURLRequestSetMainDocumentURL(cfRequest, firstPartyForCookies.get());
CFURLRequestSetCachePolicy(cfRequest, (CFURLRequestCachePolicy)cachePolicy());
CFURLRequestSetTimeoutInterval(cfRequest, timeoutInterval());
} else {
cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), firstPartyForCookies.get());
}
RetainPtr<CFStringRef> requestMethod(AdoptCF, httpMethod().createCFString());
CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod.get());
addHeadersFromHashMap(cfRequest, httpHeaderFields());
WebCore::setHTTPBody(cfRequest, httpBody());
CFURLRequestSetShouldHandleHTTPCookies(cfRequest, allowHTTPCookies());
unsigned fallbackCount = m_responseContentDispositionEncodingFallbackArray.size();
RetainPtr<CFMutableArrayRef> encodingFallbacks(AdoptCF, CFArrayCreateMutable(kCFAllocatorDefault, fallbackCount, 0));
for (unsigned i = 0; i != fallbackCount; ++i) {
RetainPtr<CFStringRef> encodingName(AdoptCF, m_responseContentDispositionEncodingFallbackArray[i].createCFString());
CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding(encodingName.get());
if (encoding != kCFStringEncodingInvalidId)
CFArrayAppendValue(encodingFallbacks.get(), reinterpret_cast<const void*>(encoding));
}
setContentDispositionEncodingFallbackArray(cfRequest, encodingFallbacks.get());
if (m_cfRequest) {
RetainPtr<CFHTTPCookieStorageRef> cookieStorage(AdoptCF, CFURLRequestCopyHTTPCookieStorage(m_cfRequest.get()));
if (cookieStorage)
CFURLRequestSetHTTPCookieStorage(cfRequest, cookieStorage.get());
CFURLRequestSetHTTPCookieStorageAcceptPolicy(cfRequest, CFURLRequestGetHTTPCookieStorageAcceptPolicy(m_cfRequest.get()));
CFURLRequestSetSSLProperties(cfRequest, CFURLRequestGetSSLProperties(m_cfRequest.get()));
}
m_cfRequest.adoptCF(cfRequest);
}
示例13: find_top_level
/**************************************************************************
* find_top_level
*/
static CFIndex find_top_level(IOHIDDeviceRef hid_device, CFMutableArrayRef main_elements)
{
CFArrayRef elements;
CFIndex total = 0;
TRACE("hid_device %s\n", debugstr_device(hid_device));
if (!hid_device)
return 0;
elements = IOHIDDeviceCopyMatchingElements(hid_device, NULL, 0);
if (elements)
{
CFIndex i, count = CFArrayGetCount(elements);
for (i = 0; i < count; i++)
{
IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i);
int type = IOHIDElementGetType(element);
TRACE("element %s\n", debugstr_element(element));
/* Check for top-level gaming device collections */
if (type == kIOHIDElementTypeCollection && IOHIDElementGetParent(element) == 0)
{
int usage_page = IOHIDElementGetUsagePage(element);
int usage = IOHIDElementGetUsage(element);
if (usage_page == kHIDPage_GenericDesktop &&
(usage == kHIDUsage_GD_Joystick || usage == kHIDUsage_GD_GamePad))
{
CFArrayAppendValue(main_elements, element);
total++;
}
}
}
CFRelease(elements);
}
TRACE("-> total %d\n", (int)total);
return total;
}
示例14: CMSDecoderCopyAllCerts
/*
* Obtain an array of all of the certificates in a message. Elements of the
* returned array are SecCertificateRefs. The caller must CFRelease the returned
* array.
* This cannot be called until after CMSDecoderFinalizeMessage() is called.
*/
OSStatus CMSDecoderCopyAllCerts(
CMSDecoderRef cmsDecoder,
CFArrayRef *certs) /* RETURNED */
{
if((cmsDecoder == NULL) || (certs == NULL)) {
return errSecParam;
}
if(cmsDecoder->decState != DS_Final) {
return errSecParam;
}
if(cmsDecoder->signedData == NULL) {
/* message wasn't signed */
*certs = NULL;
return errSecSuccess;
}
/* NULL_terminated array of CSSM_DATA ptrs */
CSSM_DATA_PTR *cssmCerts = SecCmsSignedDataGetCertificateList(cmsDecoder->signedData);
if((cssmCerts == NULL) || (*cssmCerts == NULL)) {
*certs = NULL;
return errSecSuccess;
}
CFMutableArrayRef allCerts = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
CSSM_DATA_PTR *cssmCert;
for(cssmCert=cssmCerts; *cssmCert!=NULL; cssmCert++) {
OSStatus ortn;
SecCertificateRef cfCert;
ortn = SecCertificateCreateFromData(*cssmCert,
CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_DER,
&cfCert);
if(ortn) {
CFRelease(allCerts);
return ortn;
}
CFArrayAppendValue(allCerts, cfCert);
/* the array holds the only needed refcount */
CFRelease(cfCert);
}
*certs = allCerts;
return errSecSuccess;
}
示例15: decodeCertificateChain
static bool decodeCertificateChain(Decoder& decoder, RetainPtr<CFArrayRef>& certificateChain)
{
uint64_t size;
if (!decoder.decode(size))
return false;
auto array = adoptCF(CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
for (size_t i = 0; i < size; ++i) {
RetainPtr<CFDataRef> data;
if (!decodeCFData(decoder, data))
return false;
auto certificate = adoptCF(SecCertificateCreateWithData(0, data.get()));
CFArrayAppendValue(array.get(), certificate.get());
}
certificateChain = WTFMove(array);
return true;
}