本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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);
}
示例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 );
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}