您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CFStringCreateWithFormat函数代码示例

51自学网 2021-06-01 19:59:16
  C++
这篇教程C++ CFStringCreateWithFormat函数代码示例写得很实用,希望能帮到您。

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

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

示例1: copy_device_support_path

CFStringRef copy_device_support_path(AMDeviceRef device) {    CFStringRef version = AMDeviceCopyValue(device, 0, CFSTR("ProductVersion"));    CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));    const char* home = getenv("HOME");    CFStringRef path;    bool found = false;    path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/Library/Developer/Xcode/iOS DeviceSupport/%@ (%@)"), home, version, build);    found = path_exists(path);    if (!found)    {        path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s/Library/Developer/Xcode/iOS DeviceSupport/%@"), home, version);        found = path_exists(path);    }    if (!found)    {        path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/%@"), version);        found = path_exists(path);    }    if (!found)    {        path = CFStringCreateWithFormat(NULL, NULL, CFSTR("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/%@ (%@)"), version, build);        found = path_exists(path);    }    if (!found)    {        path = CFSTR("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/Latest");        found = path_exists(path);    }    CFRelease(version);    CFRelease(build);    if (!found)    {        CFRelease(path);        printf("[ !! ] Unable to locate DeviceSupport directory./n");        exit(1);    }    return path;}
开发者ID:seamountain,项目名称:fruitstrap,代码行数:42,


示例2: addUString

void addUString(CFMutableDictionaryRef dest, CFStringRef key, const UniChar* value){  if (!value) {    return;  }    assert(dest);    CFStringRef strValue = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%S"), value);    assert(strValue);    CFDictionaryAddValue( dest, key, strValue );    CFRelease(strValue);}
开发者ID:huaqli,项目名称:clover,代码行数:11,


示例3: TraceKeyClassItem

static voidTraceKeyClassItem(void *token, CFStringRef keyclass, CFStringRef name, int64_t num){    CFStringRef key = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.%@"), keyclass, name);    if (key) {	num = SecBucket2Significant(num);	AddKeyValuePairToKeychainLoggingTransaction(token, key, num);	CFReleaseNull(key);    }}
开发者ID:darlinghq,项目名称:darling-security,代码行数:11,


示例4: CFStringCreateWithFormat

CFStringRef MonkeysAudioDecoder::CreateSourceFormatDescription() const{	if(!IsOpen())		return nullptr;	return CFStringCreateWithFormat(kCFAllocatorDefault, 									nullptr, 									CFSTR("Monkey's Audio, %u channels, %u Hz"), 									mSourceFormat.mChannelsPerFrame, 									static_cast<unsigned int>(mSourceFormat.mSampleRate));}
开发者ID:MisterRogersHaus,项目名称:SFBAudioEngine,代码行数:11,


示例5: __CFLocaleCopyDescription

static CFStringRef __CFLocaleCopyDescription(CFTypeRef cf) {    CFLocaleRef locale = (CFLocaleRef)cf;    const char *type = NULL;    switch (__CFLocaleGetType(locale)) {    case __kCFLocaleOrdinary: type = "ordinary"; break;    case __kCFLocaleSystem: type = "system"; break;    case __kCFLocaleUser: type = "user"; break;    case __kCFLocaleCustom: type = "custom"; break;    }    return CFStringCreateWithFormat(CFGetAllocator(locale), NULL, CFSTR("<CFLocale %p [%p]>{type = %s, identifier = '%@'}"), cf, CFGetAllocator(locale), type, locale->_identifier);}
开发者ID:AbhinavBansal,项目名称:opencflite,代码行数:11,


示例6: cli_print_info_dict

static void cli_print_info_dict (const void *key,                                 const void *value,                                 void *context){  CFStringRef entry = CFStringCreateWithFormat(NULL, NULL,    CFSTR("%@:/n  %@"), key, value);  if (entry) {    CFShow(entry);    CFRelease(entry);  }}
开发者ID:Zabrane,项目名称:fsevent_watch,代码行数:11,


示例7: CFStringCreateWithFormat

CFStringRef OggSpeexDecoder::CreateSourceFormatDescription() const{	if(!IsOpen())		return NULL;	return CFStringCreateWithFormat(kCFAllocatorDefault, 									NULL, 									CFSTR("Ogg Speex, %u channels, %u Hz"), 									mSourceFormat.mChannelsPerFrame, 									static_cast<unsigned int>(mSourceFormat.mSampleRate));}
开发者ID:hjzc,项目名称:SFBAudioEngine,代码行数:11,


示例8: __DAFileSystemCopyDescription

static CFStringRef __DAFileSystemCopyDescription( CFTypeRef object ){    DAFileSystemRef filesystem = ( DAFileSystemRef ) object;    return CFStringCreateWithFormat( kCFAllocatorDefault,                                     NULL,                                     CFSTR( "<DAFileSystem %p [%p]>{id = %@}" ),                                     object,                                     CFGetAllocator( object ),                                     filesystem->_id );}
开发者ID:alexzhang2015,项目名称:osx-10.9,代码行数:11,


示例9: DoSaveAsPDF

// this code originates from the NavServices sample code in the CarbonLib SDKOSStatus DoSaveAsPDF(WindowRef w, void *ourDataP){    OSStatus 			err = noErr;    static NavEventUPP	gNavEventProc = NULL;		// event proc for our Nav Dialogs     NavDialogCreationOptions	dialogOptions;    if(!gNavEventProc){        gNavEventProc = NewNavEventUPP(NavEventProc);        if(!gNavEventProc)            err = memFullErr;    }    if(!err && (( err = NavGetDefaultDialogCreationOptions( &dialogOptions )) == noErr ))    {	OurSaveDialogData *dialogDataP = NULL;	CFStringRef	tempString;	CopyWindowTitleAsCFString(w, &tempString);        dialogOptions.saveFileName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,                                                 kFileTypePDFCFStr, tempString);		CFRelease(tempString);		// make the dialog modal to our parent doc, AKA sheets        dialogOptions.parentWindow = w;	dialogOptions.modality = kWindowModalityWindowModal;		dialogDataP = (OurSaveDialogData *)malloc(sizeof(OurSaveDialogData));	if(dialogDataP){	    dialogDataP->dialogRef = NULL;	    dialogDataP->parentWindow = w;	    dialogDataP->documentDataP = ourDataP;	    err = NavCreatePutFileDialog(&dialogOptions, kFileTypePDF, kFileCreator,						    gNavEventProc, dialogDataP,						    &dialogDataP->dialogRef);	    if (!err && dialogDataP->dialogRef != NULL)	    {		err = NavDialogRun( dialogDataP->dialogRef );		if (err != noErr)		{		    NavDialogDispose( dialogDataP->dialogRef );		    dialogDataP->dialogRef = NULL;		    free(dialogDataP);		}	    }	}else	    err = memFullErr;       	     	if ( dialogOptions.saveFileName != NULL )	    CFRelease( dialogOptions.saveFileName );    }    return err;}
开发者ID:arnelh,项目名称:Examples,代码行数:54,


示例10: CFCopyDescription

// definition: produces a normally non-NULL debugging description of the objectCFStringRef CFCopyDescription(CFTypeRef cf) {#if defined(DEBUG)    if (NULL == cf) HALT;#endif    __CFGenericAssertIsCF(cf);    if (NULL != __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyDebugDesc) {        CFStringRef result;        result = __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->copyDebugDesc(cf);        if (NULL != result) return result;    }    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("<%s %p [%p]>"), __CFRuntimeClassTable[__CFGenericTypeID_inline(cf)]->className, cf, CFGetAllocator(cf));}
开发者ID:NathanLi,项目名称:freequartz,代码行数:13,


示例11: odkerb_get_fabricated_im_handle

intodkerb_get_fabricated_im_handle(ODRecordRef userRecord, CFStringRef allegedShortName, CFStringRef realm, char im_handle[], size_t im_handle_size){    int retval = -1;    CFArrayRef cfShortNames = NULL;    CFStringRef cfIMHandle = NULL;    CFErrorRef cfError = NULL;    CFStringRef shortName = allegedShortName;    ODKERB_PARAM_ASSERT(allegedShortName != NULL);    ODKERB_PARAM_ASSERT(realm != NULL);    ODKERB_PARAM_ASSERT(im_handle != 0);    ODKERB_PARAM_ASSERT(im_handle_size > 0);    *im_handle = '/0';    if (userRecord != NULL) {        /* attempt to get the primary short name from the user record */        cfShortNames = ODRecordCopyValues(userRecord, kODAttributeTypeRecordName, &cfError);        if (cfShortNames == NULL || cfError != NULL) {            ODKERB_LOG_CFERROR(LOG_DEBUG, "Unable to find the short names", cfError);            /* ignore this error, use the passed in allegedShortName parameter */        }        else if (CFArrayGetCount(cfShortNames) == 0) {            ODKERB_LOG_CFSTRING(LOG_DEBUG, "Unable to find the short names", allegedShortName);            /* ignore this error, use the passed in allegedShortName parameter */        }        else {            CFStringRef cfShortName = CFArrayGetValueAtIndex(cfShortNames, 0);            assert(cfShortName != 0);            shortName = cfShortName;        }    }    cfIMHandle = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@@%@"), shortName, realm);    if (cfIMHandle == NULL) {        ODKERB_LOG_ERRNO(LOG_ERR, ENOMEM);        goto failure;    }    if (CFStringGetCString(cfIMHandle, im_handle, im_handle_size-1, kCFStringEncodingUTF8) == FALSE)        goto failure;    retval = 0;failure:    CF_SAFE_RELEASE(cfError);    CF_SAFE_RELEASE(cfIMHandle);    CF_SAFE_RELEASE(cfShortNames);    return retval;}
开发者ID:aosm,项目名称:ChatServer,代码行数:53,


示例12: __CFNumberCopyFormattingDescription

static CFStringRef __CFNumberCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef formatOptions) {    CFNumberRef number = (CFNumberRef)cf;    CFNumberType type = __CFNumberGetType(number);    if (__CFNumberTypeTable[type].floatBit) {        return _CFNumberCopyFormattingDescriptionAsFloat64(number);    }    CFSInt128Struct i;    __CFNumberGetValue(number, kCFNumberSInt128Type, &i);    char buffer[128];    __CFSInt128Format(buffer, &i, false);    return CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%s"), buffer);}
开发者ID:DmitrySkiba,项目名称:itoa-cleancf,代码行数:12,


示例13: GetSignedIntegerBEDataAsString

CFStringRef GetSignedIntegerBEDataAsString(QTPropertyValuePtr keyValuePtr, ByteCount propValueSizeUsed){	require (propValueSizeUsed != 0, NULLVALUEPTR);		SInt32 *keyValAsInt = (SInt32 *)keyValuePtr;	return (CFStringCreateWithFormat( NULL, NULL,										CFSTR("%#.*x"),										propValueSizeUsed, 										*keyValAsInt));NULLVALUEPTR:	return nil;}
开发者ID:fruitsamples,项目名称:QTMetaData,代码行数:12,


示例14: CFStringCreateWithFormat

// ---------------------------------void USys::openURL(const char *url) {    CFStringRef urlString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), url);    if (urlString) {        CFURLRef pathRef = CFURLCreateWithString(NULL, urlString, NULL);        if (pathRef) {            //OSStatus err = LSOpenCFURLRef( pathRef, NULL );            CFRelease(pathRef);        }        CFRelease(urlString);    }}
开发者ID:PyYoshi,项目名称:PeerCastIM-Mod,代码行数:13,


示例15: stamp_file

void stamp_file(CFStringRef inStamp){	time_t the_time;	char timeBuf[32]={0};	time(&the_time);	ctime_r(&the_time, timeBuf);	char* newlin=strchr(timeBuf, '/n');	if (newlin)		*newlin=0;	CFStringRef stamp = CFStringCreateWithFormat(kCFAllocatorDefault,NULL,CFSTR("/n![%@ : %s]/n"),inStamp,timeBuf);	write_buffer(stamp);}
开发者ID:ChaseJohnson,项目名称:LogKext,代码行数:12,


示例16: copy_device_support_path

CFStringRef copy_device_support_path(AMDeviceRef device) {    CFStringRef version = AMDeviceCopyValue(device, 0, CFSTR("ProductVersion"));    CFStringRef build = AMDeviceCopyValue(device, 0, CFSTR("BuildVersion"));    CFStringRef path_with_build = CFStringCreateWithFormat(NULL, NULL, CFSTR("/Developer/Platforms/iPhoneOS.platform/DeviceSupport/%@ (%@)"), version, build);    CFStringRef path_without_build = CFStringCreateWithFormat(NULL, NULL, CFSTR("/Developer/Platforms/iPhoneOS.platform/DeviceSupport/%@"), version);    CFRelease(version);    CFRelease(build);    // they tack the build number on for beta builds    // there is almost certainly a better way of doing this    if (path_exists(path_with_build)) {        CFRelease(path_without_build);        return path_with_build;    } else if (path_exists(path_without_build)) {        CFRelease(path_with_build);        return path_without_build;    } else {        printf("[ !! ] Unable to locate DeviceSupport directory./n");        exit(1);    }}
开发者ID:MaksimKovalyov,项目名称:fruitstrap,代码行数:21,


示例17: __copyProtocolTemplate

__private_extern__ CFDictionaryRef__copyProtocolTemplate(CFStringRef      interfaceType,		       CFStringRef      childInterfaceType,		       CFStringRef      protocolType){	CFDictionaryRef interface       = NULL;	CFDictionaryRef protocol	= NULL;	CFDictionaryRef protocols;	CFDictionaryRef templates;	templates = __copyTemplates();	if (templates == NULL) {		return NULL;	}	protocols = CFDictionaryGetValue(templates, CFSTR("Protocol"));	if (!isA_CFDictionary(protocols)) {		CFRelease(templates);		return NULL;	}	if (childInterfaceType == NULL) {		interface = CFDictionaryGetValue(protocols, interfaceType);	} else {		CFStringRef     expandedType;		if (CFStringFind(childInterfaceType, CFSTR("."), 0).location != kCFNotFound) {			// if "vendor" type			childInterfaceType = CFSTR("*");		}		expandedType = CFStringCreateWithFormat(NULL,							NULL,							CFSTR("%@-%@"),							interfaceType,							childInterfaceType);		interface = CFDictionaryGetValue(protocols, expandedType);		CFRelease(expandedType);	}	if (isA_CFDictionary(interface)) {		protocol = CFDictionaryGetValue(interface, protocolType);		if (isA_CFDictionary(protocol)) {			CFRetain(protocol);		} else {			protocol = NULL;		}	}	CFRelease(templates);	return protocol;}
开发者ID:010001111,项目名称:darling,代码行数:53,


示例18: SDMMD_PathToDeviceSupport

CFStringRef SDMMD_PathToDeviceSupport(SDMMD_AMDeviceRef device){	CFStringRef dev_support_path = NULL;	if (device) {		SDMMD_AMDeviceConnect(device);		SDMMD_AMDeviceStartSession(device);		CFStringRef full_os_version = SDMMD_AMDeviceCopyValue(device, NULL, CFSTR(kProductVersion));		CFStringRef os_version = CFStringCreateWithSubstring(kCFAllocatorDefault, full_os_version, CFRangeMake(0, 3));		CFSafeRelease(full_os_version);		CFStringRef build_version = SDMMD_AMDeviceCopyValue(device, NULL, CFSTR(kBuildVersion));		SDMMD_AMDeviceStopSession(device);		SDMMD_AMDeviceDisconnect(device);		if (os_version && build_version) {			CFStringRef sdk_path = SDMMD_CopyDeviceSupportPathFromXCRUN();			CFStringRef device_support = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@/DeviceSupport/%@"), sdk_path, os_version);			char *device_support_cstr = SDMCFStringGetString(device_support);			bool isDir = false;			bool file_exists = FileExistsAtPathIsDir(device_support_cstr, &isDir);			if (file_exists && isDir) {				dev_support_path = CFStringCreateCopy(kCFAllocatorDefault, device_support);			}			else {				CFStringRef device_support_build = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ (%@)"), device_support, build_version);				char *device_support_build_cstr = SDMCFStringGetString(device_support_build);				file_exists = FileExistsAtPathIsDir(device_support_build_cstr, &isDir);				if (file_exists && isDir) {					dev_support_path = CFStringCreateCopy(kCFAllocatorDefault, device_support_build);				}				Safe(free, device_support_build_cstr);				CFSafeRelease(device_support_build);			}			Safe(free, device_support_cstr);			CFSafeRelease(sdk_path);			CFSafeRelease(device_support);		}		CFSafeRelease(os_version);		CFSafeRelease(build_version);	}	return dev_support_path;}
开发者ID:ThanosSiopoudis,项目名称:SDMMobileDevice,代码行数:40,


示例19: my_CFDictionarySetIPAddressAsArrayValue

PRIVATE_EXTERN voidmy_CFDictionarySetIPAddressAsArrayValue(CFMutableDictionaryRef dict,					CFStringRef prop,					struct in_addr ip_addr){    CFStringRef		str;    str = CFStringCreateWithFormat(NULL, NULL, CFSTR(IP_FORMAT),				   IP_LIST(&ip_addr));    my_CFDictionarySetTypeAsArrayValue(dict, prop, str);    CFRelease(str);    return;}
开发者ID:aosm,项目名称:bootp,代码行数:13,


示例20: SecOTRSessionCopyDescription

static CF_RETURNS_RETAINED CFStringRef SecOTRSessionCopyDescription(CFTypeRef cf) {    SecOTRSessionRef session = (SecOTRSessionRef)cf;    return CFStringCreateWithFormat(kCFAllocatorDefault,NULL,CFSTR("<%s %s%s%s%s %d:%d %s%s>"),                                    SecOTRAuthStateString(session->_state),                                    session->_me ? "F" : "-",                                    session->_them ? "P" : "-",                                    session->_receivedDHMessage ? "D" : "-",                                    session->_receivedDHKeyMessage ? "K" : "-",                                    session->_keyID,                                    session->_theirKeyID,                                    session->_theirPreviousKey ? "P" : "-",                                    session->_theirKey ? "T" : "-");}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:13,


示例21: CFStringCreateWithCString

 // // open_mach_port() // // Opens the mach communication port. // void Monitor::open_mach_port() {     // XXX_PCB:  this is quite skanky, using CF from here. we expect to be called at the earliest when a GC thread is registered.     CFStringRef format = CFStringCreateWithCString(NULL, "com.apple.auto.%d", kCFStringEncodingUTF8);     CFStringRef name = CFStringCreateWithFormat(NULL, NULL, format, getpid());     CFRelease(format);     CFMessagePortContext context = { 0, this, NULL, NULL, NULL };     _request_port = CFMessagePortCreateLocal(NULL, name, receive_request, &context, NULL);     CFRelease(name);     CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(NULL, _request_port, 0);     CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);     CFRelease(source);     CFRunLoopRun(); }
开发者ID:Sophrinix,项目名称:iphone-macruby,代码行数:18,


示例22: ST_ID3v2_TextFrame_createString

ST_FUNC CFStringRef ST_ID3v2_TextFrame_createString(const ST_TextFrame *f) {    static const CFStringRef fmt = CFSTR("{ text='%@' }");    CFStringRef text, rv;    if(!f)        return NULL;    text = ST_ID3v2_TextFrame_copyText(f);    rv = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, fmt, text);    CFRelease(text);    return rv;}
开发者ID:ljsebald,项目名称:SonatinaTag,代码行数:13,


示例23: __CFMessagePortCopyDescription

static CFStringRef __CFMessagePortCopyDescription(CFTypeRef cf) {    CFMessagePortRef ms = (CFMessagePortRef)cf;    CFStringRef result;    const char *locked;    CFStringRef contextDesc = NULL;    locked = ms->_lock ? "Yes" : "No";    if (!__CFMessagePortIsRemote(ms)) {	if (NULL != ms->_context.info && NULL != ms->_context.copyDescription) {	    contextDesc = ms->_context.copyDescription(ms->_context.info);	}	if (NULL == contextDesc) {	    contextDesc = CFStringCreateWithFormat(CFGetAllocator(ms), NULL, CFSTR("<CFMessagePort context %p>"), ms->_context.info);	}	result = CFStringCreateWithFormat(CFGetAllocator(ms), NULL, CFSTR("<CFMessagePort %p [%p]>{locked = %s, valid = %s, remote = %s, name = %@}"), cf, CFGetAllocator(ms), locked, (__CFMessagePortIsValid(ms) ? "Yes" : "No"), (__CFMessagePortIsRemote(ms) ? "Yes" : "No"), ms->_name);    } else {	result = CFStringCreateWithFormat(CFGetAllocator(ms), NULL, CFSTR("<CFMessagePort %p [%p]>{locked = %s, valid = %s, remote = %s, name = %@, source = %p, callout = %p, context = %@}"), cf, CFGetAllocator(ms), locked, (__CFMessagePortIsValid(ms) ? "Yes" : "No"), (__CFMessagePortIsRemote(ms) ? "Yes" : "No"), ms->_name, ms->_source, ms->_callout, (NULL != contextDesc ? contextDesc : CFSTR("<no description>")));    }    if (NULL != contextDesc) {	CFRelease(contextDesc);    }    return result;}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:22,


示例24: SDMMD_AMDeviceSecureInstallApplication

sdmmd_return_t SDMMD_AMDeviceSecureInstallApplication(SDMMD_AMConnectionRef conn, SDMMD_AMDeviceRef device, CFURLRef path, CFDictionaryRef options, CallBack installCallback, void *unknown){	sdmmd_return_t result = kAMDSuccess;	SDMMD_AMConnectionRef connection = NULL;	bool hasConnection = (conn ? true : false);	if (device) {		result = SDMMD_AMDeviceSecureStartService(device, CFSTR(AMSVC_INSTALLATION_PROXY), NULL, &connection);		if (result == 0) {			hasConnection = true;		}		else {			printf("%s: Was unable to start the install service on the device 0x%x./n", __FUNCTION__, result);		}	}	if (hasConnection) {		CFStringRef lastComp = CFURLCopyLastPathComponent(path);		if (CFStringGetLength(lastComp) == 0) {			CFSafeRelease(lastComp);			CFURLRef pathURL = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, path);			lastComp = CFURLCopyLastPathComponent(pathURL);			CFSafeRelease(pathURL);		}		if (lastComp) {			CFStringRef format = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("PublicStaging/%@"), lastComp);			if (format) {				char *appName = SDMCFStringGetString(format);				printf("%s: Attempting install of %s./n", __FUNCTION__, appName);				result = SDMMD_perform_command(connection, CFSTR("Install"), 0, installCallback, 4, unknown, CFSTR("PackagePath"), format, CFSTR("ClientOptions"), options);				if (result) {					printf("%s: Old style of install failed for (%s)./n", __FUNCTION__, appName);				}				Safe(free, appName);			}			else {				printf("%s: Unable to create CFString!/n", __FUNCTION__);			}			CFSafeRelease(format);		}		else {			char *lastCompString = SDMCFStringGetString(lastComp);			printf("%s: Could not copy last path component from url %s./n", __FUNCTION__, lastCompString);			Safe(free, lastCompString);		}		CFSafeRelease(lastComp);	}	CFSafeRelease(connection);	char *pathString = SDMCFURLGetString(path);	printf("%s: Installation of package %s returned 0x%x./n", __FUNCTION__, pathString, result);	Safe(free, pathString);	return result;}
开发者ID:K0smas,项目名称:SDMMobileDevice,代码行数:51,


示例25: OnData

static void OnData(CFSocketRef socket, CFSocketCallBackType type, CFDataRef address, const void *value, void *info) {    switch (type) {        case kCFSocketDataCallBack:            CFDataRef data(reinterpret_cast<CFDataRef>(value));            Client *client(reinterpret_cast<Client *>(info));            if (client->message_ == NULL)                client->message_ = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, TRUE);            if (!CFHTTPMessageAppendBytes(client->message_, CFDataGetBytePtr(data), CFDataGetLength(data)))                CFLog(kCFLogLevelError, CFSTR("CFHTTPMessageAppendBytes()"));            else if (CFHTTPMessageIsHeaderComplete(client->message_)) {                CFURLRef url(CFHTTPMessageCopyRequestURL(client->message_));                Boolean absolute;                CFStringRef path(CFURLCopyStrictPath(url, &absolute));                CFRelease(client->message_);                CFStringRef code(CFURLCreateStringByReplacingPercentEscapes(kCFAllocatorDefault, path, CFSTR("")));                CFRelease(path);                JSStringRef script(JSStringCreateWithCFString(code));                CFRelease(code);                JSValueRef result(JSEvaluateScript(CYGetJSContext(), script, NULL, NULL, 0, NULL));                JSStringRelease(script);                CFHTTPMessageRef response(CFHTTPMessageCreateResponse(kCFAllocatorDefault, 200, NULL, kCFHTTPVersion1_1));                CFHTTPMessageSetHeaderFieldValue(response, CFSTR("Content-Type"), CFSTR("application/json; charset=utf-8"));                CFStringRef json(CYCopyJSONString(CYGetJSContext(), result, NULL));                CFDataRef body(CFStringCreateExternalRepresentation(kCFAllocatorDefault, json, kCFStringEncodingUTF8, NULL));                CFRelease(json);                CFStringRef length(CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%u"), CFDataGetLength(body)));                CFHTTPMessageSetHeaderFieldValue(response, CFSTR("Content-Length"), length);                CFRelease(length);                CFHTTPMessageSetBody(response, body);                CFRelease(body);                CFDataRef serialized(CFHTTPMessageCopySerializedMessage(response));                CFRelease(response);                CFSocketSendData(socket, NULL, serialized, 0);                CFRelease(serialized);                CFRelease(url);            }        break;    }}
开发者ID:simpzan,项目名称:cycript,代码行数:51,


示例26: __security_debug

void __security_debug(CFStringRef scope, const char *function,    const char *file, int line, CFStringRef format, ...){#if !defined(NDEBUG)	pthread_once(&__security_debug_once, __security_debug_init);	/* Scope NULL is always enabled. */	if (scope) {		/* Check if the scope is enabled. */		if (scopeSet) {			if (negate == CFSetContainsValue(scopeSet, scope)) {				return;			}		} else if (!negate) {			return;		}	}#endif	va_list args;	va_start(args, format);	CFStringRef message = CFStringCreateWithFormatAndArguments(		kCFAllocatorDefault, NULL, format, args);	va_end(args);	time_t now = time(NULL);	char *date = ctime(&now);	date[19] = '/0';	CFStringRef logStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,		CFSTR("%s %@ %s %@/n"), date + 4,        scope ? scope : CFSTR(""), function, message);	CFShow(logStr);    char logMsg[4096];    if (CFStringGetCString(logStr, logMsg, sizeof(logMsg), kCFStringEncodingUTF8)) {        char scopeStr[MAX_SCOPE_LENGTH + 1];        aslmsg msg = asl_new(ASL_TYPE_MSG);        if (scope) {            if (CFStringGetCString(scope, scopeStr, sizeof(scopeStr),                                   kCFStringEncodingUTF8)) {                asl_set(msg, ASL_KEY_FACILITY, scopeStr);            }            asl_set(msg, ASL_KEY_LEVEL, ASL_STRING_INFO);        } else {            asl_set(msg, ASL_KEY_LEVEL, ASL_STRING_ERR);        }        asl_set(msg, ASL_KEY_MSG, logMsg);        asl_send(NULL, msg);        asl_free(msg);    }	CFRelease(logStr);	CFRelease(message);}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:51,


示例27: copy_certificate_labels

static CFArrayRefcopy_certificate_labels(CFArrayRef certs, CFStringRef cert_label,			CFArrayRef * ret_identities){    CFMutableArrayRef 	cert_labels = NULL;    CFMutableArrayRef	certs_filtered = NULL;    int			count;    int			i;    CFRange		r;    count = CFArrayGetCount(certs);    cert_labels = CFArrayCreateMutable(NULL, count + 1, &kCFTypeArrayCallBacks);    /* add the first element which is reserved to mean no cert is selected */    CFArrayAppendValue(cert_labels, cert_label);    r.location = 0;    r.length = 1;    certs_filtered = CFArrayCreateMutable(NULL, count, &kCFTypeArrayCallBacks);    for (i = 0; i < count; i++) {	SecCertificateRef	cert = NULL;	SecIdentityRef		identity;	CFStringRef		str = NULL;	identity = (SecIdentityRef)CFArrayGetValueAtIndex(certs, i);	SecIdentityCopyCertificate(identity, &cert);	if (cert != NULL) {	    str = SecCertificateCopyShortDescription(NULL, cert, NULL);	    CFRelease(cert);	}	if (str != NULL) {	    int		instance;	    CFStringRef	new_str;	    for (instance = 2, new_str = CFRetain(str); 		 CFArrayContainsValue(cert_labels, r, new_str); instance++) {		CFRelease(new_str);		new_str		    = CFStringCreateWithFormat(NULL, NULL,					       CFSTR("%@ (%d)"), str,					       instance);	    }	    CFArrayAppendValue(cert_labels, new_str);	    r.length++;	    CFRelease(new_str);	    CFRelease(str);	    CFArrayAppendValue(certs_filtered, identity);	}    }    *ret_identities = certs_filtered;    return (cert_labels);}
开发者ID:carriercomm,项目名称:osx-2,代码行数:51,


示例28: DisplayTagAndString

/* * DisplayTagAndString displays the tag and then the str or "(not found)" * if str is NULL. */static void DisplayTagAndString(    CFStringRef tag,	// input: the tag    CFStringRef str)	// input: the CFString{    CFStringRef displayStr;    UInt8 *buffer;    CFRange range;    CFIndex bytesToConvert;    CFIndex bytesConverted;    if ( str != NULL )    {        displayStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("/t%@: /"%@/""), tag, str);    }    else    {        displayStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("/t%@: (not found)"), tag);    }    require(displayStr != NULL, CFStringCreateWithFormat);    range = CFRangeMake(0, CFStringGetLength(displayStr));    CFStringGetBytes(displayStr, range, kCFStringEncodingUTF8, 0, false, NULL, 0, &bytesToConvert);    buffer = malloc(bytesToConvert + 1);    require(buffer != NULL, malloc_buffer);    CFStringGetBytes(displayStr, range, kCFStringEncodingUTF8, 0, false, buffer, bytesToConvert, &bytesConverted);    buffer[bytesConverted] = '/0';    fprintf(stdout, "%s/n", buffer);    free(buffer);malloc_buffer:    CF_RELEASE_CLEAR(displayStr);CFStringCreateWithFormat:    return;}
开发者ID:kuolei,项目名称:CocoaSampleCode,代码行数:42,


示例29: test_engine_views

// Add 1000 items on each device.  Then delete 1000 items on each device.static void test_engine_views(void) {    __block int iteration=0;    __block int objectix=0;    __block CFMutableArrayRef objectNames = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);    const size_t itemDataSize = 1024;    const int peerCount = 4;    const int edgeCount = peerCount * (peerCount - 1);    const int itemsPerPeer = 1000;    const int itemsPerIteration = 100;    const int itemChunkCount = (itemsPerPeer / itemsPerIteration);    const int deleteIteration = edgeCount * (itemChunkCount + 30);    const int idleIteration = 616; //deleteIteration + edgeCount * (itemChunkCount + 10);        CFMutableDataRef itemData = CFDataCreateMutable(kCFAllocatorDefault, itemDataSize);    CFDataSetLength(itemData, itemDataSize);    const char *name = "engine_views";    //const char *test_directive    //const char *test_reason    CFIndex version = 0;    bool(^pre)(SOSTestDeviceRef source, SOSTestDeviceRef dest) = ^bool(SOSTestDeviceRef source, SOSTestDeviceRef dest) {        bool result = false;        if (iteration <= edgeCount * itemChunkCount) {            if (iteration % (peerCount - 1) == 0) {                for (int j = 0; j < itemsPerIteration; ++j) {                    CFStringRef name = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@-pre-%d"), SOSTestDeviceGetID(source), objectix++);                    CFArrayAppendValue(objectNames, name);                    SOSTestDeviceAddGenericItemWithData(source, name, name, itemData);                    CFReleaseNull(name);                }            }            result = true;        } else if (iteration == deleteIteration) {            //diag("deletion starting");        } else if (deleteIteration < iteration && iteration <= deleteIteration + edgeCount * itemChunkCount) {            if (iteration % (peerCount - 1) == 0) {                for (int j = 0; j < itemsPerIteration; ++j) {                    CFStringRef name = CFArrayGetValueAtIndex(objectNames, --objectix);                    SOSTestDeviceAddGenericItemTombstone(source, name, name);                }                result = true;            }        } else if (idleIteration == iteration) {            //diag("idle starting");        } else if (617 == iteration) {            //diag("interesting");        }        iteration++;        return result || iteration < deleteIteration;    };
开发者ID:darlinghq,项目名称:darling-security,代码行数:51,



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


C++ CFStringGetBytes函数代码示例
C++ CFStringCreateWithBytes函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。