2  * Copyright (c) 2016 Apple Inc. All Rights Reserved. 
   4  * @APPLE_LICENSE_HEADER_START@ 
   6  * This file contains Original Code and/or Modifications of Original Code 
   7  * as defined in and that are subject to the Apple Public Source License 
   8  * Version 2.0 (the 'License'). You may not use this file except in 
   9  * compliance with the License. Please obtain a copy of the License at 
  10  * http://www.opensource.apple.com/apsl/ and read it before using this 
  13  * The Original Code and all software distributed under the License are 
  14  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  15  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  16  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  17  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  18  * Please see the License for the specific language governing rights and 
  19  * limitations under the License. 
  21  * @APPLE_LICENSE_HEADER_END@ 
  24 #include "SecADWrapper.h" 
  26 #if TARGET_OS_EMBEDDED 
  27 #include <AggregateDictionary/ADClient.h> 
  29 static typeof(ADClientAddValueForScalarKey
) *soft_ADClientAddValueForScalarKey 
= NULL
; 
  30 static typeof(ADClientClearScalarKey
) *soft_ADClientClearScalarKey 
= NULL
; 
  31 static typeof(ADClientSetValueForScalarKey
) *soft_ADClientSetValueForScalarKey 
= NULL
; 
  32 static typeof(ADClientPushValueForDistributionKey
) *soft_ADClientPushValueForDistributionKey 
= NULL
; 
  37     static dispatch_once_t onceToken
; 
  38     static CFBundleRef bundle 
= NULL
; 
  39     dispatch_once(&onceToken
, ^{ 
  41         CFURLRef url 
= CFURLCreateWithFileSystemPath(kCFAllocatorDefault
, CFSTR("/System/Library/PrivateFrameworks/AggregateDictionary.framework"), kCFURLPOSIXPathStyle
, true); 
  45         bundle 
= CFBundleCreate(kCFAllocatorDefault
, url
); 
  50         soft_ADClientClearScalarKey 
= CFBundleGetFunctionPointerForName(bundle
, CFSTR("ADClientClearScalarKey")); 
  51         soft_ADClientSetValueForScalarKey 
= CFBundleGetFunctionPointerForName(bundle
, CFSTR("ADClientSetValueForScalarKey")); 
  52         soft_ADClientAddValueForScalarKey 
= CFBundleGetFunctionPointerForName(bundle
, CFSTR("ADClientAddValueForScalarKey")); 
  53         soft_ADClientPushValueForDistributionKey 
= CFBundleGetFunctionPointerForName(bundle
, CFSTR("ADClientPushValueForDistributionKey")); 
  55         if (soft_ADClientClearScalarKey 
== NULL 
|| 
  56             soft_ADClientSetValueForScalarKey 
== NULL 
|| 
  57             soft_ADClientAddValueForScalarKey 
== NULL 
|| 
  58             soft_ADClientPushValueForDistributionKey 
== NULL
) 
  64     return bundle 
!= NULL
; 
  68 SecADClearScalarKey(CFStringRef key
) 
  71         soft_ADClientClearScalarKey(key
); 
  75 SecADSetValueForScalarKey(CFStringRef key
, int64_t value
) 
  78         soft_ADClientSetValueForScalarKey(key
, value
); 
  82 SecADAddValueForScalarKey(CFStringRef key
, int64_t value
) 
  85         soft_ADClientAddValueForScalarKey(key
, value
); 
  89 SecADClientPushValueForDistributionKey(CFStringRef key
, int64_t value
) 
  92         soft_ADClientPushValueForDistributionKey(key
, value
);