本文整理匯總了C++中CFBooleanGetValue函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFBooleanGetValue函數的具體用法?C++ CFBooleanGetValue怎麽用?C++ CFBooleanGetValue使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFBooleanGetValue函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: handleConfigFile
static void handleConfigFile(const char *file)
{
bool on_demand = true, is_kunc = false;
uid_t u = getuid();
struct passwd *pwe;
char usr[4096];
char serv_name[4096];
char serv_cmd[4096];
CFPropertyListRef plist = CreateMyPropertyListFromFile(file);
if (u == 0)
u = geteuid();
if (plist) {
if (CFDictionaryContainsKey(plist, CFSTR("Username"))) {
const void *v = CFDictionaryGetValue(plist, CFSTR("Username"));
if (v) CFStringGetCString(v, usr, sizeof(usr), kCFStringEncodingUTF8);
else goto out;
if ((pwe = getpwnam(usr))) {
u = pwe->pw_uid;
} else {
fprintf(stderr, "%s: user not found\n", argv0);
goto out;
}
}
if (CFDictionaryContainsKey(plist, CFSTR("OnDemand"))) {
const void *v = CFDictionaryGetValue(plist, CFSTR("OnDemand"));
if (v)
on_demand = CFBooleanGetValue(v);
else goto out;
}
if (CFDictionaryContainsKey(plist, CFSTR("ServiceName"))) {
const void *v = CFDictionaryGetValue(plist, CFSTR("ServiceName"));
if (v) CFStringGetCString(v, serv_name, sizeof(serv_name), kCFStringEncodingUTF8);
else goto out;
}
if (CFDictionaryContainsKey(plist, CFSTR("Command"))) {
const void *v = CFDictionaryGetValue(plist, CFSTR("Command"));
if (v) CFStringGetCString(v, serv_cmd, sizeof(serv_cmd), kCFStringEncodingUTF8);
else goto out;
}
if (CFDictionaryContainsKey(plist, CFSTR("isKUNCServer"))) {
const void *v = CFDictionaryGetValue(plist, CFSTR("isKUNCServer"));
if (v && CFBooleanGetValue(v)) is_kunc = true;
else goto out;
}
regServ(u, on_demand, is_kunc, serv_name, serv_cmd);
goto out_good;
out:
fprintf(stdout, "%s: failed to register: %s\n", argv0, file);
out_good:
CFRelease(plist);
} else {
fprintf(stderr, "%s: no plist was returned for: %s\n", argv0, file);
}
}
示例2: _createDirectory
// Asssumes caller already knows the directory doesn't exist.
static Boolean _createDirectory(CFURLRef dirURL, Boolean worldReadable) {
CFAllocatorRef alloc = __CFPreferencesAllocator();
CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(alloc, dirURL);
CFBooleanRef val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, parentURL, kCFURLFileExists, NULL);
Boolean parentExists = (val && CFBooleanGetValue(val));
SInt32 mode;
Boolean result;
if (val) CFRelease(val);
if (!parentExists) {
CFStringRef path = CFURLCopyPath(parentURL);
if (!CFEqual(path, CFSTR("/"))) {
_createDirectory(parentURL, worldReadable);
val = (CFBooleanRef) CFURLCreatePropertyFromResource(alloc, parentURL, kCFURLFileExists, NULL);
parentExists = (val && CFBooleanGetValue(val));
if (val) CFRelease(val);
}
CFRelease(path);
}
if (parentURL) CFRelease(parentURL);
if (!parentExists) return false;
#if TARGET_OS_OSX || TARGET_OS_LINUX
mode = worldReadable ? S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH : S_IRWXU;
#else
mode = 0666;
#endif
result = CFURLWriteDataAndPropertiesToResource(dirURL, (CFDataRef)dirURL, URLPropertyDictForPOSIXMode(mode), NULL);
URLPropertyDictRelease();
return result;
}
示例3: kim_os_preferences_get_boolean_for_key
kim_error kim_os_preferences_get_boolean_for_key (kim_preference_key in_key,
kim_boolean in_hardcoded_default,
kim_boolean *out_boolean)
{
kim_error err = KIM_NO_ERROR;
CFBooleanRef value = NULL;
if (!err && !out_boolean) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_preferences_copy_value (in_key, CFBooleanGetTypeID (),
(CFPropertyListRef *) &value);
}
if (!err && !value) {
err = kim_os_preferences_copy_value_compat (in_key, CFBooleanGetTypeID (),
(CFPropertyListRef *) &value);
}
if (!err) {
if (value) {
*out_boolean = CFBooleanGetValue (value);
} else {
*out_boolean = in_hardcoded_default;
}
}
if (value) { CFRelease (value); }
return check_error (err);
}
示例4: GetDictionaryBoolean
Boolean GetDictionaryBoolean(CFDictionaryRef theDict, const void *key){
Boolean value = false;
CFBooleanRef boolRef = (CFBooleanRef) CFDictionaryGetValue(theDict, key);
if (boolRef != NULL) value = CFBooleanGetValue(boolRef);
return value;
}
示例5: TSICTStringCreateWithObjectAndFormat
TStringIRep* TSICTStringCreateWithObjectAndFormat(CFTypeRef object, TSITStringFormat format)
{
if (object == NULL) {
return TSICTStringCreateNullWithFormat(format);
}
CFRetain(object);
CFTypeID cfType = CFGetTypeID(object);
TStringIRep* rep = NULL;
if (cfType == kCFDataTypeID) {
rep = TSICTStringCreateWithDataOfTypeAndFormat(object, kTSITStringTagString, format);
} else if (cfType == kCFStringTypeID) {
rep = TSICTStringCreateWithStringAndFormat(object, format);
} else if (cfType == kCFNumberTypeID) {
rep = TSICTStringCreateWithNumberAndFormat(object, format);
} else if (cfType == kCFBooleanTypeID) {
if (CFBooleanGetValue(object)) {
rep = TSICTStringCreateTrueWithFormat(format);
} else {
rep = TSICTStringCreateFalseWithFormat(format);
}
} else if (cfType == kCFNullTypeID) {
rep = TSICTStringCreateNullWithFormat(format);
} else if (cfType == kCFArrayTypeID) {
rep = TSICTStringCreateWithArrayAndFormat(object, format);
} else if (cfType == kCFDictionaryTypeID) {
rep = TSICTStringCreateWithDictionaryAndFormat(object, format);
} else {
rep = TSICTStringCreateInvalidWithFormat(format);
}
CFRelease(object);
return rep;
}
示例6: EnableExtendedLogging
void EnableExtendedLogging(SDMMD_AMDeviceRef device)
{
sdmmd_return_t result = SDMMD_AMDeviceConnect(device);
if (SDM_MD_CallSuccessful(result)) {
result = SDMMD_AMDeviceStartSession(device);
if (SDM_MD_CallSuccessful(result)) {
CFTypeRef value = SDMMD_AMDeviceCopyValue(device, CFSTR(AMSVC_MOBILE_DEBUG), CFSTR(kEnableLockdownExtendedLogging));
if (CFGetTypeID(value) == CFBooleanGetTypeID()) {
if (!CFBooleanGetValue(value)) {
result = SDMMD_AMDeviceSetValue(device, CFSTR(AMSVC_MOBILE_DEBUG), CFSTR(kEnableLockdownExtendedLogging), kCFBooleanTrue);
if (SDM_MD_CallSuccessful(result)) {
printf("Enabling extended logging...\n");
}
}
else {
printf("Extended logging already enabled.\n");
}
}
else {
PrintCFType(value);
}
CFSafeRelease(value);
}
SDMMD_AMDeviceStopSession(device);
SDMMD_AMDeviceDisconnect(device);
}
}
示例7: stringFromCFAbsoluteTime
std::string DiskArbitrationEventPublisher::getProperty(
const CFStringRef& property, const CFDictionaryRef& dict) {
CFTypeRef value = (CFTypeRef)CFDictionaryGetValue(dict, property);
if (value == nullptr) {
return "";
}
if (CFStringCompare(property, CFSTR(kDAAppearanceTime_), kNilOptions) ==
kCFCompareEqualTo) {
return stringFromCFAbsoluteTime((CFDataRef)value);
}
if (CFGetTypeID(value) == CFNumberGetTypeID()) {
return stringFromCFNumber((CFDataRef)value,
CFNumberGetType((CFNumberRef)value));
} else if (CFGetTypeID(value) == CFStringGetTypeID()) {
return stringFromCFString((CFStringRef)value);
} else if (CFGetTypeID(value) == CFBooleanGetTypeID()) {
return (CFBooleanGetValue((CFBooleanRef)value)) ? "1" : "0";
} else if (CFGetTypeID(value) == CFUUIDGetTypeID()) {
return stringFromCFString(
CFUUIDCreateString(kCFAllocatorDefault, (CFUUIDRef)value));
}
return "";
}
示例8: GetImportPrefs
static void GetImportPrefs()
{
#if TARGET_API_MAC_CARBON
CFStringRef prefs_id = CFStringCreateWithCString(NULL, SUPERPNG_PREFS_ID, kCFStringEncodingASCII);
CFStringRef alpha_id = CFStringCreateWithCString(NULL, SUPERPNG_PREFS_ALPHA, kCFStringEncodingASCII);
CFStringRef mult_id = CFStringCreateWithCString(NULL, SUPERPNG_PREFS_MULT, kCFStringEncodingASCII);
CFPropertyListRef alphaMode_val = CFPreferencesCopyAppValue(alpha_id, prefs_id);
CFPropertyListRef mult_val = CFPreferencesCopyAppValue(mult_id, prefs_id);
if(alphaMode_val)
{
char alphaMode_char;
if( CFNumberGetValue((CFNumberRef)alphaMode_val, kCFNumberCharType, &alphaMode_char) )
g_alpha = (DialogAlpha)alphaMode_char;
CFRelease(alphaMode_val);
}
if(mult_val)
{
g_mult = CFBooleanGetValue((CFBooleanRef)mult_val);
CFRelease(mult_val);
}
CFRelease(alpha_id);
CFRelease(mult_id);
CFRelease(prefs_id);
#endif
}
示例9: CopyCFTypeValue
void CASettingsStorage::CopyBoolValue(CFStringRef inKey, bool& outValue, bool inDefaultValue) const
{
// initialize the return value
outValue = inDefaultValue;
// get the raw value
CFTypeRef theValue = NULL;
CopyCFTypeValue(inKey, theValue, NULL);
// for this type, NULL is an invalid value
if(theValue != NULL)
{
// bools can be made from either CFBooleans or CFNumbers
if(CFGetTypeID(theValue) == CFBooleanGetTypeID())
{
// get the return value from the CF object
outValue = CFBooleanGetValue(static_cast<CFBooleanRef>(theValue));
}
else if(CFGetTypeID(theValue) == CFNumberGetTypeID())
{
// get the numeric value
SInt32 theNumericValue = 0;
CFNumberGetValue(static_cast<CFNumberRef>(theValue), kCFNumberSInt32Type, &theNumericValue);
// non-zero indicates true
outValue = theNumericValue != 0;
}
// release the value since we aren't returning it
CFRelease(theValue);
}
}
示例10: getIOKitProperty
std::string getIOKitProperty(const CFMutableDictionaryRef& details,
const std::string& key) {
std::string value;
// Get a property from the device.
auto cfkey = CFStringCreateWithCString(
kCFAllocatorDefault, key.c_str(), kCFStringEncodingUTF8);
auto property = CFDictionaryGetValue(details, cfkey);
CFRelease(cfkey);
// Several supported ways of parsing IOKit-encoded data.
if (property) {
if (CFGetTypeID(property) == CFNumberGetTypeID()) {
value = stringFromCFNumber((CFDataRef)property);
} else if (CFGetTypeID(property) == CFStringGetTypeID()) {
value = stringFromCFString((CFStringRef)property);
} else if (CFGetTypeID(property) == CFDataGetTypeID()) {
value = stringFromCFData((CFDataRef)property);
} else if (CFGetTypeID(property) == CFBooleanGetTypeID()) {
value = (CFBooleanGetValue((CFBooleanRef)property)) ? "1" : "0";
}
}
return value;
}
示例11: GetDictionaryBoolean
static bool GetDictionaryBoolean(CFDictionaryRef d, const void *key)
{
CFBooleanRef ref = (CFBooleanRef) CFDictionaryGetValue(d, key);
if(ref)
return CFBooleanGetValue(ref);
return false;
}
示例12: getBool
//////////////////////////////////////////////////////////////////////////
//Boolean
//////////////////////////////////////////////////////////////////////////
Boolean
getBool(CFTypeRef preference, Boolean* boolean)
{
Boolean ret = FALSE;
if (!preference)
return FALSE;
if (CFGetTypeID(preference) == CFBooleanGetTypeID()) {
ret = TRUE;
*boolean = CFBooleanGetValue((CFBooleanRef) preference);
}
else if (CFGetTypeID(preference) == CFStringGetTypeID()) {
if (!CFStringCompare((CFStringRef)preference, Yes, kCFCompareCaseInsensitive)) {
ret = TRUE;
*boolean = TRUE;
}
else if (!CFStringCompare((CFStringRef)preference, No, kCFCompareCaseInsensitive)) {
ret = TRUE;
*boolean = FALSE;
}
else if (!CFStringCompare((CFStringRef)preference, True, kCFCompareCaseInsensitive)) {
ret = TRUE;
*boolean = TRUE;
}
else if (!CFStringCompare((CFStringRef)preference, False, kCFCompareCaseInsensitive)) {
ret = TRUE;
*boolean = FALSE;
}
}
return ret;
}
示例13: ScanDictionaryForParameters
static OSStatus ScanDictionaryForParameters(CFDictionaryRef parameters, void* attributePointers[])
{
int i;
for (i = 0; i < kNumberOfAttributes; ++i)
{
// see if the corresponding tag exists in the dictionary
CFTypeRef value = CFDictionaryGetValue(parameters, *(gAttributes[i].name));
if (value != NULL)
{
switch (gAttributes[i].type)
{
case kStringType:
// just return the value
*(CFTypeRef*) attributePointers[i] = value;
break;
case kBooleanType:
{
CFBooleanRef bRef = (CFBooleanRef) value;
*(bool*) attributePointers[i] = CFBooleanGetValue(bRef);
}
break;
case kIntegerType:
{
CFNumberRef nRef = (CFNumberRef) value;
CFNumberGetValue(nRef, kCFNumberSInt32Type, attributePointers[i]);
}
break;
}
}
}
return noErr;
}
示例14: disk_appeared_cb
static void
disk_appeared_cb(DADiskRef disk, void *ctx)
{
CFDictionaryRef description = NULL;
CFBooleanRef mountable;
CFStringRef content = NULL;
if (!ctx || !disk) return;
description = DADiskCopyDescription(disk);
if (!description) return;
mountable = CFDictionaryGetValue(description, kDADiskDescriptionVolumeMountableKey);
if (!mountable) goto out;
content = CFDictionaryGetValue(description, kDADiskDescriptionMediaContentKey);
if (!content) goto out;
if (CFBooleanGetValue(mountable) &&
CFStringCompare(content, CFSTR("53746F72-6167-11AA-AA11-00306543ECAC"),
kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
CFStringCompare(content, CFSTR("426F6F74-0000-11AA-AA11-00306543ECAC"),
kCFCompareCaseInsensitive) != kCFCompareEqualTo) {
/* The disk is marked mountable and isn't CoreStorage or Apple_Boot,
* which means that it actually is mountable (since we lie and mark
* CoreStorage disks as mountable). */
*((bool *)ctx) = true;
}
out:
if (description)
CFRelease(description);
}
示例15: printObj
static void printObj(CFPropertyListRef obj, struct printContext* c) {
CFTypeID typeID = CFGetTypeID(obj);
if (typeID == _CFKeyedArchiverUIDGetTypeID()) {
unsigned uid = _CFKeyedArchiverUIDGetValue(obj);
CFPropertyListRef refObj = CFArrayGetValueAtIndex(c->objs, uid);
if (CFEqual(refObj, CFSTR("$null")))
printf("nil");
else if (c->refCount[uid] > 1 && isComplexObj(refObj))
printf("{CF$UID = %u;}", uid);
else
printObj(refObj, c);
} else if (typeID == CFArrayGetTypeID()) {
printf("(\n");
++ c->tabs;
CFArrayApplyFunction(obj, CFRangeMake(0, CFArrayGetCount(obj)), (CFArrayApplierFunction)&printObjAsArrayEntry, c);
-- c->tabs;
for (unsigned i = 0; i < c->tabs; ++ i)
printf("\t");
printf(")");
} else if (typeID == CFDictionaryGetTypeID()) {
CFStringRef className = CFDictionaryGetValue(obj, CFSTR("$classname"));
if (className != NULL)
printObjAsClassName(className);
else {
printf("{\n");
++ c->tabs;
CFIndex dictCount = CFDictionaryGetCount(obj);
struct dictionarySorterContext sc;
sc.keys = malloc(sizeof(CFStringRef)*dictCount);
sc.values = malloc(sizeof(CFPropertyListRef)*dictCount);
unsigned* mapping = malloc(sizeof(unsigned)*dictCount);
for (unsigned i = 0; i < dictCount; ++ i)
mapping[i] = i;
CFDictionaryGetKeysAndValues(obj, (const void**)sc.keys, sc.values);
qsort_r(mapping, dictCount, sizeof(unsigned), &sc, (int(*)(void*,const void*,const void*))&dictionaryComparer);
for (unsigned i = 0; i < dictCount; ++ i)
printObjAsDictionaryEntry(sc.keys[mapping[i]], sc.values[mapping[i]], c);
free(mapping);
free(sc.keys);
free(sc.values);
-- c->tabs;
for (unsigned i = 0; i < c->tabs; ++ i)
printf("\t");
printf("}");
}
} else if (typeID == CFDataGetTypeID())
printObjAsData(obj);
else if (typeID == CFNumberGetTypeID())
printObjAsNumber(obj);
else if (typeID == CFStringGetTypeID())
printObjAsString(obj);
else if (typeID == CFBooleanGetTypeID())
printf(CFBooleanGetValue(obj) ? "true" : "false");
else if (typeID == CFDateGetTypeID())
printf("/*date*/ %0.09g", CFDateGetAbsoluteTime(obj));
}