当前位置: 首页>>代码示例>>C++>>正文


C++ CFBooleanGetValue函数代码示例

本文整理汇总了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);
	}
}
开发者ID:aosm,项目名称:Startup,代码行数:60,代码来源:register_mach_bootstrap_servers.c

示例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;
}
开发者ID:JGiola,项目名称:swift-corelibs-foundation,代码行数:32,代码来源:CFXMLPreferencesDomain.c

示例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);
}
开发者ID:Brainiarc7,项目名称:pbis,代码行数:31,代码来源:kim_os_preferences.c

示例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;
}
开发者ID:dtrebilco,项目名称:PreMulAlpha,代码行数:7,代码来源:OpenGLApp.cpp

示例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;
}
开发者ID:4justinstewart,项目名称:Polity,代码行数:35,代码来源:TSICTString.c

示例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);
	}
}
开发者ID:K0smas,项目名称:SDMMobileDevice,代码行数:27,代码来源:syslog.c

示例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 "";
}
开发者ID:PoppySeedPlehzr,项目名称:osquery,代码行数:25,代码来源:diskarbitration.cpp

示例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
}
开发者ID:dygg,项目名称:SuperPNG,代码行数:34,代码来源:SuperPNG_InUI_ADM.cpp

示例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);
	}
}
开发者ID:11020156,项目名称:SampleCode,代码行数:32,代码来源:CASettingsStorage.cpp

示例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;
}
开发者ID:PoppySeedPlehzr,项目名称:osquery,代码行数:25,代码来源:iokit.cpp

示例11: GetDictionaryBoolean

static bool GetDictionaryBoolean(CFDictionaryRef d, const void *key)
{
    CFBooleanRef ref = (CFBooleanRef) CFDictionaryGetValue(d, key);
    if(ref)
        return CFBooleanGetValue(ref);
    return false;
}
开发者ID:CyberSys,项目名称:darkplaces,代码行数:7,代码来源:vid_agl.c

示例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;
}
开发者ID:NSOiO,项目名称:freequartz,代码行数:36,代码来源:CGDefaults.c

示例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;
}
开发者ID:Apple-FOSS-Mirror,项目名称:libsecurity_keychain,代码行数:35,代码来源:SecKey.cpp

示例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);
}
开发者ID:naota,项目名称:diskdev_cmds,代码行数:32,代码来源:nofsutil.c

示例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));

}
开发者ID:bu2,项目名称:networkpx,代码行数:58,代码来源:visualize-archived-object.c


注:本文中的CFBooleanGetValue函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。