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


C++ CFStringGetCStringPtr函数代码示例

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


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

示例1: iSCSIKernelGetSessionIdForTargetIQN

/*! Looks up the session identifier associated with a particular target name.
 *  @param targetIQN the IQN name of the target (e.q., iqn.2015-01.com.example)
 *  @return sessionId the session identifier. */
SID iSCSIKernelGetSessionIdForTargetIQN(CFStringRef targetIQN)
{
    if(!targetIQN)
        return kiSCSIInvalidSessionId;
    
    const UInt32 expOutputCnt = 1;
    UInt64 output[expOutputCnt];
    UInt32 outputCnt = expOutputCnt;

    kern_return_t result = IOConnectCallMethod(
        connection,
        kiSCSIGetSessionIdForTargetIQN,0,0,
        (const void*)CFStringGetCStringPtr(targetIQN,kCFStringEncodingASCII),
        CFStringGetLength(targetIQN)+1,
        output,&outputCnt,0,0);
    
    if(result == kIOReturnSuccess && outputCnt == expOutputCnt)
        return (SID)output[0];
    
    return kiSCSIInvalidSessionId;
}
开发者ID:anvena,项目名称:iSCSIInitiator,代码行数:24,代码来源:iSCSIKernelInterface.c

示例2: stransport_error

int stransport_error(OSStatus ret)
{
	CFStringRef message;

	if (ret == noErr || ret == errSSLClosedGraceful) {
		giterr_clear();
		return 0;
	}

#if !TARGET_OS_IPHONE
	message = SecCopyErrorMessageString(ret, NULL);
	GITERR_CHECK_ALLOC(message);

	giterr_set(GITERR_NET, "SecureTransport error: %s", CFStringGetCStringPtr(message, kCFStringEncodingUTF8));
	CFRelease(message);
#else
    giterr_set(GITERR_NET, "SecureTransport error: OSStatus %d", (unsigned int)ret);
#endif

	return -1;
}
开发者ID:Angolier,项目名称:sonic-pi,代码行数:21,代码来源:stransport_stream.c

示例3: AEDescCreateUTF8Text

OSErr AEDescCreateUTF8Text(CFStringRef string, AEDesc* outDescPtr)
{
	OSErr err = noErr;
	CFStringEncoding kEncoding = kCFStringEncodingUTF8;
	DescType resultType = typeUTF8Text;
	const char *constBuff = CFStringGetCStringPtr(string, kEncoding);
	if (constBuff == NULL) {
		char *buffer;
		CFIndex charLen = CFStringGetLength(string);
		CFIndex maxLen = CFStringGetMaximumSizeForEncoding(charLen, kEncoding)+1; // +1 is for null termination.
		buffer = malloc(sizeof(char)*maxLen);
		CFStringGetCString(string, buffer, maxLen, kEncoding);
		err = AECreateDesc(resultType, buffer, strlen(buffer), outDescPtr);
		free(buffer);
	}
	else {
		err=AECreateDesc(resultType, constBuff, strlen(constBuff), outDescPtr);
	}
	
	return err;
}
开发者ID:tkurita,项目名称:AEUtils,代码行数:21,代码来源:AEUtils.c

示例4: outOfSpace

bool outOfSpace(CFStringRef pathName)
{
	Boolean			validKey;
	unsigned int	minMeg;
	struct statfs	fileSys;
	
	minMeg = CFPreferencesGetAppIntegerValue(MINMEG_PREF_KEY,PREF_DOMAIN,&validKey);
	if (!validKey)
	{
		minMeg = DEFAULT_MEG;
		CFPreferencesSetAppValue(MINMEG_PREF_KEY,CFNumberCreate(kCFAllocatorDefault,kCFNumberIntType,&minMeg),PREF_DOMAIN);
	}

	if (statfs(CFStringGetCStringPtr(pathName,CFStringGetFastestEncoding(pathName)),&fileSys))
		return false;

	if ((fileSys.f_bsize/1024)*(fileSys.f_bavail/1024) < minMeg)
		return true;
		
	return false;
}
开发者ID:CiaccoDavide,项目名称:logKext,代码行数:21,代码来源:logKextDaemon.cpp

示例5: Q_UNUSED

//! Get the serial number for a HID device
QString pjrc_rawhid::getserial(int num) {
    Q_UNUSED(num);

    QMutexLocker locker(m_readMutex);
    Q_UNUSED(locker);

    if (!device_open || unplugged)
        return "";

    CFTypeRef serialnum = IOHIDDeviceGetProperty(dev, CFSTR(kIOHIDSerialNumberKey));
    if(serialnum && CFGetTypeID(serialnum) == CFStringGetTypeID())
    {
        //Note: I'm not sure it will always succeed if encoded as MacRoman but that
        //is a superset of UTF8 so I think this is fine
        CFStringRef str = (CFStringRef)serialnum;
        const char * buf = CFStringGetCStringPtr(str, kCFStringEncodingMacRoman);
        return QString(buf);
    }

    return QString("Error");
}
开发者ID:Crash1,项目名称:TauLabs,代码行数:22,代码来源:pjrc_rawhid_mac.cpp

示例6: while

vector<string> DeckLinkController::getDeviceNameList()  {
	vector<string> nameList;
	int deviceIndex = 0;
	
	while (deviceIndex < deviceList.size()) {
		CFStringRef cfStrName;
		
		// Get the name of this device
		if (deviceList[deviceIndex]->GetDisplayName(&cfStrName) == S_OK) {
			nameList.push_back(string(CFStringGetCStringPtr(cfStrName, kCFStringEncodingMacRoman)));
			CFRelease(cfStrName);
		}
		else {
			nameList.push_back("DeckLink");
		}
		
		deviceIndex++;
	}
	
	return nameList;
}
开发者ID:shks,项目名称:DoubleFishEyeGrabber,代码行数:21,代码来源:DeckLinkController.cpp

示例7: SecPolicyCreateSSL

/* new in 10.6 */
SecPolicyRef
SecPolicyCreateSSL(Boolean server, CFStringRef hostname)
{
    // return a SecPolicyRef object for the SSL policy, given hostname and client options
    SecPolicyRef policy = nil;
    SecPolicySearchRef policySearch = nil;
    OSStatus status = SecPolicySearchCreate(CSSM_CERT_X_509v3, &CSSMOID_APPLE_TP_SSL, NULL, &policySearch);
    if (!status) {
        status = SecPolicySearchCopyNext(policySearch, &policy);
    }
    if (!status && policy) {
        // set options for client-side or server-side policy evaluation
		char *strbuf = NULL;
		const char *hostnamestr = NULL;
		if (hostname) {
			CFIndex strbuflen = 0;
			hostnamestr = CFStringGetCStringPtr(hostname, kCFStringEncodingUTF8);
			if (hostnamestr == NULL) {
				strbuflen = CFStringGetLength(hostname)*6;
				strbuf = (char *)malloc(strbuflen+1);
				if (CFStringGetCString(hostname, strbuf, strbuflen, kCFStringEncodingUTF8)) {
					hostnamestr = strbuf;
				}
			}
		}
        uint32 hostnamelen = (hostnamestr) ? strlen(hostnamestr) : 0;
        uint32 flags = (!server) ? CSSM_APPLE_TP_SSL_CLIENT : 0;
        CSSM_APPLE_TP_SSL_OPTIONS opts = {CSSM_APPLE_TP_SSL_OPTS_VERSION, hostnamelen, hostnamestr, flags};
        CSSM_DATA data = {sizeof(opts), (uint8*)&opts};
        SecPolicySetValue(policy, &data);
		
		if (strbuf) {
			free(strbuf);
		}
    }
	if (policySearch) {
		CFRelease(policySearch);
	}
    return policy;
}
开发者ID:phinze,项目名称:libsecurity_keychain,代码行数:41,代码来源:SecPolicy.cpp

示例8: mount_developer_image

void mount_developer_image(AMDeviceRef device) {
    CFStringRef ds_path = copy_device_support_path(device);
    CFStringRef image_path = copy_developer_disk_image_path(device);
    CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.signature"), image_path);
    CFRelease(ds_path);

    if (verbose) {
        printf("Device support path: ");
        fflush(stdout);
        CFShow(ds_path);
        printf("Developer disk image: ");
        fflush(stdout);
        CFShow(image_path);
    }

    FILE* sig = fopen(CFStringGetCStringPtr(sig_path, kCFStringEncodingMacRoman), "rb");
    void *sig_buf = malloc(128);
    assert(fread(sig_buf, 1, 128, sig) == 128);
    fclose(sig);
    CFDataRef sig_data = CFDataCreateWithBytesNoCopy(NULL, sig_buf, 128, NULL);
    CFRelease(sig_path);

    CFTypeRef keys[] = { CFSTR("ImageSignature"), CFSTR("ImageType") };
    CFTypeRef values[] = { sig_data, CFSTR("Developer") };
    CFDictionaryRef options = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CFRelease(sig_data);

    int result = AMDeviceMountImage(device, image_path, options, &mount_callback, 0);
    if (result == 0) {
        printf("[ 95%%] Developer disk image mounted successfully\n");
    } else if (result == 0xe8000076 /* already mounted */) {
        printf("[ 95%%] Developer disk image already mounted\n");
    } else {
        printf("[ !! ] Unable to mount developer disk image. (%x)\n", result);
        exit(1);
    }

    CFRelease(image_path);
    CFRelease(options);
}
开发者ID:ccastleb,项目名称:fruitstrap,代码行数:40,代码来源:fruitstrap.c

示例9: SCDynamicStoreCreate

/* return AD realm if it exists */
const char *get_ad_realm ( struct auth_request *auth_request )
{
	const char *out_realm = NULL;

	SCDynamicStoreRef store = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("dovecot.digest.auth"), NULL, NULL);
	if ( store ) {
		CFDictionaryRef dict = SCDynamicStoreCopyValue(store, CFSTR("com.apple.opendirectoryd.ActiveDirectory"));
		if (dict) {
			CFStringRef domain = CFDictionaryGetValue(dict, CFSTR("DomainNameFlat"));
			if (domain) {
				const char *ad_realm = CFStringGetCStringPtr(domain, kCFStringEncodingUTF8);
				if (ad_realm) {
					auth_request_log_info(auth_request, "digest-md5", "ad realm: %s", ad_realm);
					out_realm = t_strdup(ad_realm);
				}
			}
			CFRelease(dict);
		}
		CFRelease(store);
	}
	return( out_realm );
}
开发者ID:unofficial-opensource-apple,项目名称:dovecot,代码行数:23,代码来源:mech-digest-md5.c

示例10: ios_open_from_bundle

static FILE* ios_open_from_bundle(const char path[], const char* perm) {
    // Get a reference to the main bundle
    CFBundleRef mainBundle = CFBundleGetMainBundle();

    // Get a reference to the file's URL
    CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8);
    CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL);
    if (!imageURL) {
        return nullptr;
    }

    // Convert the URL reference into a string reference
    CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathStyle);

    // Get the system encoding method
    CFStringEncoding encodingMethod = CFStringGetSystemEncoding();

    // Convert the string reference into a C string
    const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod);

    return fopen(finalPath, perm);
}
开发者ID:03050903,项目名称:skia,代码行数:22,代码来源:SkOSFile_stdio.cpp

示例11: CFURLCreateFromFSRef

/**
 * Get the location for global or user-local support files.
 * @return NULL if it could not be determined
 */
char *Bgetsupportdir(int global)
{
    char *dir = NULL;
    
#ifdef __APPLE__
	FSRef ref;
	CFStringRef str;
	CFURLRef base;
	const char *s;
	
	if (FSFindFolder(global ? kLocalDomain : kUserDomain,
					 kApplicationSupportFolderType,
					 kDontCreateFolder, &ref) < 0) return NULL;

	base = CFURLCreateFromFSRef(NULL, &ref);
	if (!base) {
        return NULL;
    }
    
	str = CFURLCopyFileSystemPath(base, kCFURLPOSIXPathStyle);
	CFRelease(base);
	if (!str) {
        return NULL;
    }
    
	s = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
	if (s) {
        dir = strdup(s);
    }
	CFRelease(str);

#else
    if (!global) {
        dir = Bgethomedir();
    }
#endif
    
	return dir;
}
开发者ID:Hendricks266,项目名称:jfbuild,代码行数:43,代码来源:compat.c

示例12: switch

const void *subsurface_get_conf(char *name, pref_type_t type)
{
	CFStringRef dict_entry;

	/* if no settings exist, we return the value for FALSE */
	if (!propertyList)
		return NULL;

	switch (type) {
	case PREF_BOOL:
		dict_entry = CFDictionaryGetValue(propertyList, CFSTR_VAR(name));
		if (dict_entry && ! CFStringCompare(CFSTR("1"), dict_entry, 0))
			return (void *) 1;
		else
			return NULL;
	case PREF_STRING:
		return CFStringGetCStringPtr(CFDictionaryGetValue(propertyList,
						CFSTR_VAR(name)), kCFStringEncodingMacRoman);
	}
	/* we shouldn't get here, but having this line makes the compiler happy */
	return NULL;
}
开发者ID:vavincavent,项目名称:subsurface,代码行数:22,代码来源:macos.c

示例13: PrintSpeedForDisc

static IOReturn
PrintSpeedForDisc ( io_object_t opticalMedia )
{
	
	IOReturn				error 		= kIOReturnError;
	CFMutableDictionaryRef	properties 	= NULL;
	CFStringRef				bsdNode		= NULL;
	const char *			bsdName		= NULL;
	
	error = IORegistryEntryCreateCFProperties ( opticalMedia,
												&properties,
												kCFAllocatorDefault,
												kNilOptions );
	require ( ( error == kIOReturnSuccess ), ErrorExit );
	
	bsdNode = ( CFStringRef ) CFDictionaryGetValue ( properties, CFSTR ( kIOBSDNameKey ) );
	require ( ( bsdNode != NULL ), ReleaseProperties );
	
	bsdName = CFStringGetCStringPtr ( bsdNode, CFStringGetSystemEncoding ( ) );
	require ( ( bsdName != NULL ), ReleaseProperties );
	
	error = PrintSpeedForBSDNode ( bsdName );
	require ( ( error == kIOReturnSuccess ), ReleaseProperties );
	
	
ReleaseProperties:
	
	
	require_quiet ( ( properties != NULL ), ErrorExit );
	CFRelease ( properties );
	properties = NULL;
	
	
ErrorExit:
	
	
	return error;
	
}
开发者ID:unofficial-opensource-apple,项目名称:IOSCSIArchitectureModelFamily,代码行数:39,代码来源:OpticalMediaSpeed.c

示例14: cfstring2cstring

static char *
cfstring2cstring(CFStringRef string)
{
    CFIndex len;
    char *str;

    str = (char *) CFStringGetCStringPtr(string, kCFStringEncodingUTF8);
    if (str)
        return strdup(str);

    len = CFStringGetLength(string);
    len = 1 + CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8);
    str = malloc(len);
    if (str == NULL)
        return NULL;

    if (!CFStringGetCString (string, str, len, kCFStringEncodingUTF8)) {
        free (str);
        return NULL;
    }
    return str;
}
开发者ID:SimonWilkinson,项目名称:heimdal,代码行数:22,代码来源:config_file.c

示例15: ST_ID3v1_setYearStr

ST_FUNC ST_Error ST_ID3v1_setYearStr(ST_ID3v1 *tag, CFStringRef s) {
    char *prev = tag->year;
    const char *str;
    char tmp[5];

    /* Make sure they aren't doing anything screwy */
    if(!tag || tag->base.type != ST_TagType_ID3v1)
        return ST_Error_InvalidArgument;
    else if(CFStringGetLength(s) != 4)
        return ST_Error_InvalidArgument;

    if(!s) {
        free(tag->year);
        tag->year = NULL;
        return ST_Error_None;
    }

    /* Grab the ISO-8859-1 representation of the string */
    if(!(str = CFStringGetCStringPtr(s, kCFStringEncodingISOLatin1))) {
        if(!CFStringGetCString(s, tmp, 5, kCFStringEncodingISOLatin1))
            return ST_Error_InvalidEncoding;

        str = tmp;
    }

    /* One last sanity check... */
    if(strlen(str) != 4 || (!is_8859digit(str[0]) || !is_8859digit(str[1]) ||
                            !is_8859digit(str[2]) || !is_8859digit(str[3])))
        return ST_Error_InvalidArgument;

    /* Copy it in */
    if((tag->year = strdup(str))) {
        free(prev);
        return ST_Error_None;
    }

    tag->year = prev;
    return ST_Error_errno;
}
开发者ID:ljsebald,项目名称:SonatinaTag,代码行数:39,代码来源:ID3v1.c


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