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


C++ CFURLCreateWithString函数代码示例

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


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

示例1: InitializeCustomToolbarItem

//-----------------------------------------------------------------------------
//	InitializeCustomToolbarItem
//-----------------------------------------------------------------------------
//	This is called after our item has been constructed. We are called here so
//	that we can pull parameters out of the Carbon Event that is passed into the
//	HIObjectCreate call.
//
static OSStatus
InitializeCustomToolbarItem( CustomToolbarItem* inItem, EventRef inEvent )
{
	CFTypeRef		data;
	IconRef			iconRef;
	
	if ( GetEventParameter( inEvent, kEventParamToolbarItemConfigData, typeCFTypeRef, NULL,
			sizeof( CFTypeRef ), NULL, &data ) == noErr )
	{
		if ( CFGetTypeID( data ) == CFStringGetTypeID() )
			inItem->url = CFURLCreateWithString( NULL, (CFStringRef)data, NULL );
		else
			inItem->url = (CFURLRef)CFRetain( data );
	}
	else
	{
		inItem->url = CFURLCreateWithString( NULL, CFSTR( "http://www.apple.com" ), NULL );
	}

	HIToolbarItemSetLabel( inItem->toolbarItem, CFSTR( "URL Item" ) );
	
	if ( GetIconRef( kOnSystemDisk, kSystemIconsCreator, kGenericURLIcon, &iconRef ) == noErr )
	{
		HIToolbarItemSetIconRef( inItem->toolbarItem, iconRef );
		ReleaseIconRef( iconRef );
	}
	
	HIToolbarItemSetHelpText( inItem->toolbarItem, CFURLGetString( inItem->url ), NULL );
	
	return noErr;
}
开发者ID:fruitsamples,项目名称:CarbonToolbar,代码行数:38,代码来源:CustomToolbarItem.c

示例2: ASSERT

CFErrorRef ResourceError::cfError() const
{
    if (m_isNull) {
        ASSERT(!m_platformError);
        return 0;
    }

    if (!m_platformError) {
        RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));

        if (!m_localizedDescription.isEmpty()) {
            RetainPtr<CFStringRef> localizedDescriptionString(AdoptCF, m_localizedDescription.createCFString());
            CFDictionarySetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey, localizedDescriptionString.get());
        }

        if (!m_failingURL.isEmpty()) {
            RetainPtr<CFStringRef> failingURLString(AdoptCF, m_failingURL.createCFString());
            CFDictionarySetValue(userInfo.get(), failingURLStringKey, failingURLString.get());
            RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithString(0, failingURLString.get(), 0));
            CFDictionarySetValue(userInfo.get(), failingURLKey, url.get());
        }

#if PLATFORM(WIN)
        if (m_certificate)
            wkSetSSLPeerCertificateData(userInfo.get(), m_certificate.get());
#endif
        
        RetainPtr<CFStringRef> domainString(AdoptCF, m_domain.createCFString());
        m_platformError.adoptCF(CFErrorCreate(0, domainString.get(), m_errorCode, userInfo.get()));
    }

    return m_platformError.get();
}
开发者ID:gobihun,项目名称:webkit,代码行数:33,代码来源:ResourceErrorCF.cpp

示例3: CFURLCreateWithString

 URL::URL( CFStringRef value )
 {
     if( value != NULL && CFGetTypeID( value ) == CFStringGetTypeID() )
     {
         this->_cfObject = CFURLCreateWithString( static_cast< CFAllocatorRef >( NULL ), value, NULL );
     }
 }
开发者ID:siraj,项目名称:CFPP,代码行数:7,代码来源:CFPP-URL.cpp

示例4: LoadBundle

CFBundleRef LoadBundle(const char* lpBundlePath)
{
	if(lpBundlePath == NULL)
	{
		return NULL;
	}
	
	CFStringRef bundlePath = CFStringCreateWithCString(kCFAllocatorSystemDefault, lpBundlePath, CFStringGetSystemEncoding());
	if(NULL == bundlePath)
	{
		return NULL;
	}
	
	CFURLRef bundleURL = CFURLCreateWithString(kCFAllocatorSystemDefault, bundlePath, NULL);
	if(NULL == bundleURL)
	{
		return NULL;
	}
#endif
	
	// 2.get bundle ref
	CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorSystemDefault, bundleURL);
	CFRelease(bundleURL);
	
	if(NULL != bundleRef)
	{
	}

	return bundleRef;
}
开发者ID:andreasgal,项目名称:openh264,代码行数:30,代码来源:load_bundle_functions.cpp

示例5: LaunchBrowser

bool LaunchBrowser(const char* url)
{
#ifdef WIN32
  int r =  (int)ShellExecuteA(0, "open", url, "", "", 1);
  return (r > 32);

#else 

#ifdef MACOSX

  CFStringRef strurl =                //CFSTR("http://www.amju.com"); // TODO HACK 
    CFStringCreateWithBytes(
    0, 
    (const unsigned char*)url, 
    strlen(url),
    kCFStringEncodingMacRoman,
    false);

  CFURLRef cfurl = CFURLCreateWithString(0, strurl, 0);
  OSStatus ret = LSOpenCFURLRef(cfurl, 0);

std::cout << "Launch URL: " << CFStringGetCStringPtr(strurl, kCFStringEncodingMacRoman) << "\n";
std::cout << "Launch result: " << ret << "\n";

  // TODO deal with ret
  return true;

#else
  // Not implemented for this platform
  return false;
#endif
#endif

}
开发者ID:jason-amju,项目名称:amju-scp,代码行数:34,代码来源:Launcher.cpp

示例6: CreateURLFromReferral

/*
 * Given a Dfs Referral string create a CFURL. Remember referral have a file
 * syntax
 * 
 * Example: "/smb-win2003.apple.com/DfsRoot/DfsLink1"
 */
CFURLRef CreateURLFromReferral(CFStringRef inStr)
{
	CFURLRef ct_url = NULL;
	CFMutableStringRef urlString = CFStringCreateMutableCopy(NULL, 0, CFSTR("smb:/"));
	CFStringRef escapeStr = inStr;
	
    /* 
     * CreateStringByAddingPercentEscapesUTF8() will either create a new string
     * or return the original with ref count incremented. Either way we have to
     * call CFRelease on the returned string 
     */
	CreateStringByAddingPercentEscapesUTF8(&escapeStr, NULL, NULL, FALSE);

	if (urlString) {
		CFStringAppend(urlString, escapeStr);
		ct_url = CFURLCreateWithString(kCFAllocatorDefault, urlString, NULL);
		CFRelease(urlString);	/* We create it now release it */
	}
    
	if (!ct_url) {
		LogCFString(inStr, "creating url failed", __FUNCTION__, __LINE__);
	}
    
    if (escapeStr) {
        CFRelease(escapeStr);
    }
   
	return ct_url;
}
开发者ID:aosm,项目名称:smb,代码行数:35,代码来源:parse_url.c

示例7: cfstring

void CWebKitActiveScroller::SetURL(const cdstring& urltxt)
{
	MyCFString cfstring(urltxt, kCFStringEncodingUTF8);
	CFURLRef url = CFURLCreateWithString( NULL, cfstring, NULL );
	URLToWebView(mViewRef, url);
	CFRelease(url);
}
开发者ID:gpreviato,项目名称:Mulberry-Mail,代码行数:7,代码来源:CWebKitActiveScroller.cpp

示例8: execview_pretty_command

/*
 * Return a pretty command, on some OS's we might do something
 * different than just display the command.
 *
 * free_ret - whether or not to free the return value
 */
char *
execview_pretty_command(MCAP_CMD_S *mc_cmd, int *free_ret)
{
    char *str;
    int rv_to_free = 0;

    if(free_ret)
      *free_ret = rv_to_free;

    if(!mc_cmd)
      return NULL;

    str = mc_cmd->command;

#ifdef _WINDOWS
    if(*str == '*' || (*str == '\"' && str[1] == '*')){
	if(!strncmp(str + ((*str == '\"') ? 2 : 1), "DDE*", 4))
	  str = cpystr("via app already running");
	else if(!strncmp(str + ((*str == '\"') ? 2 : 1),"ShellEx*",8))
	  str = cpystr("via Explorer defined app");
	else
	  str = cpystr("via Windows-specific method");

	rv_to_free = 1;
    }
#elif	OSX_TARGET
    if(mc_cmd->special_handling){
	CFStringRef str_ref = NULL, kind_str_ref = NULL;
	CFURLRef url_ref;
	char buf[256];

	if((str_ref = CFStringCreateWithCString(NULL, mc_cmd->command,
					 kCFStringEncodingASCII)) == NULL)
	  return "";

	if((url_ref = CFURLCreateWithString(NULL, str_ref, NULL)) == NULL)
	  return "";

	if(LSCopyDisplayNameForURL(url_ref, &kind_str_ref) != noErr)
	  return "";

	if(CFStringGetCString(kind_str_ref, buf, (CFIndex)255,
			      kCFStringEncodingASCII) == false)
	  return "";

	buf[255] = '\0';
	str = cpystr(buf);
	rv_to_free = 1;
	if(kind_str_ref)
	  CFRelease(kind_str_ref);
    }
#else
    /* always pretty */
#endif

    if(free_ret)
      *free_ret = rv_to_free;

    return(str);
}
开发者ID:RsrchBoy,项目名称:dpkg-alpine,代码行数:66,代码来源:execview.c

示例9: createGetURL

/* Create a URI suitable for use in an http GET request, will return NULL if
   the length would exceed 255 bytes. */
static CFURLRef createGetURL(CFURLRef responder, CFDataRef request) {
    CFURLRef getURL = NULL;
    CFMutableDataRef base64Request = NULL;
    CFStringRef base64RequestString = NULL;
    CFStringRef peRequest = NULL;
    CFIndex base64Len;

    base64Len = SecBase64Encode(NULL, CFDataGetLength(request), NULL, 0);
    /* Don't bother doing all the work below if we know the end result will
       exceed 255 bytes (minus one for the '/' separator makes 254). */
    if (base64Len + CFURLGetBytes(responder, NULL, 0) > 254)
        return NULL;

    require(base64Request = CFDataCreateMutable(kCFAllocatorDefault,
        base64Len), errOut);
    CFDataSetLength(base64Request, base64Len);
    SecBase64Encode(CFDataGetBytePtr(request), CFDataGetLength(request),
        (char *)CFDataGetMutableBytePtr(base64Request), base64Len);
    require(base64RequestString = CFStringCreateWithBytes(kCFAllocatorDefault,
        CFDataGetBytePtr(base64Request), base64Len, kCFStringEncodingUTF8,
        false), errOut);
    require(peRequest = CFURLCreateStringByAddingPercentEscapes(
        kCFAllocatorDefault, base64RequestString, NULL, CFSTR("+/="),
        kCFStringEncodingUTF8), errOut);
#if 1
    CFStringRef urlString = CFURLGetString(responder);
    CFStringRef fullURL;
    if (CFStringHasSuffix(urlString, CFSTR("/"))) {
        fullURL = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
            CFSTR("%@%@"), urlString, peRequest);
    } else {
        fullURL = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
            CFSTR("%@/%@"), urlString, peRequest);
    }
    getURL = CFURLCreateWithString(kCFAllocatorDefault, fullURL, NULL);
    CFRelease(fullURL);
#else
    getURL = CFURLCreateWithString(kCFAllocatorDefault, peRequest, responder);
#endif

errOut:
    CFReleaseSafe(base64Request);
    CFReleaseSafe(base64RequestString);
    CFReleaseSafe(peRequest);

    return getURL;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:49,代码来源:asynchttp.c

示例10: FetchIPAddress

static void FetchIPAddress()
{
	if(publicIPState == IPStateFetching)
		return;

	publicIPState = IPStateFetching;

	const UInt8 bodyBytes[] = {0};
	CFDataRef body = CFDataCreate(kCFAllocatorDefault, bodyBytes, 0);

	CFURLRef url = CFURLCreateWithString(kCFAllocatorDefault, CFSTR("http://icanhazip.com"), NULL);
	CFHTTPMessageRef request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), url, kCFHTTPVersion1_1);
	CFHTTPMessageSetBody(request, body);

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

	// Apple suggests the NSURLSession API instead of CFReadStreamCreateForHTTPRequest,
	// But obviously that doesn't really work here

	CFReadStreamRef stream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request);

#pragma clang diagnostic pop

	CFRelease(body);
	CFRelease(url);
	CFRelease(request);

	CFMutableDataRef responseData = CFDataCreateMutable(kCFAllocatorDefault, 17);
	CFStreamClientContext context = { 0, responseData, NULL, NULL, NULL };

	if(!CFReadStreamSetClient(stream, kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable | kCFStreamEventEndEncountered | kCFStreamEventErrorOccurred, &IPStreamCallback, &context))
	{
		CFRelease(stream);

		publicIPState = IPStateInvalid;
		return;
	}

	// Add to the run loop and open the stream
	CFReadStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);

	if(!CFReadStreamOpen(stream))
	{
		CFReadStreamSetClient(stream, 0, NULL, NULL);
		CFReadStreamUnscheduleFromRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
		CFRelease(stream);

		publicIPState = IPStateInvalid;
		return;
	}


	// Run the run loop
	do {
		CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0, TRUE);
	} while(publicIPState == IPStateFetching);
}
开发者ID:JustSid,项目名称:extip,代码行数:58,代码来源:server.c

示例11: impExpImportParseFileExten

/*
 * Parse file extension and attempt to map it to format and type. Returns true
 * on success.
 */
bool impExpImportParseFileExten(
	CFStringRef			fstr,
	SecExternalFormat   *inputFormat,   // RETURNED
	SecExternalItemType	*itemType)		// RETURNED
{
	if(fstr == NULL) {
		/* nothing to work with */
		return false;
	}
	if(CFStringHasSuffix(fstr, CFSTR(".cer")) ||
	   CFStringHasSuffix(fstr, CFSTR(".crt"))) {
		*inputFormat = kSecFormatX509Cert;
		*itemType = kSecItemTypeCertificate;
		SecImpInferDbg("Inferring kSecFormatX509Cert from file name");
		return true;
	}
	if(CFStringHasSuffix(fstr, CFSTR(".p12")) ||
	   CFStringHasSuffix(fstr, CFSTR(".pfx"))) {
		*inputFormat = kSecFormatPKCS12;
		*itemType = kSecItemTypeAggregate;
		SecImpInferDbg("Inferring kSecFormatPKCS12 from file name");
		return true;
	}

	/* Get extension, look for key indicators as substrings */
	CFURLRef url = CFURLCreateWithString(NULL, fstr, NULL);
	if(url == NULL) {
		SecImpInferDbg("impExpImportParseFileExten: error creating URL");
		return false;
	}
	CFStringRef exten = CFURLCopyPathExtension(url);
	CFRelease(url);
	if(exten == NULL) {
		/* no extension, app probably passed in only an extension */
		exten = fstr;
		CFRetain(exten);
	}
	bool ortn = false;
	CFRange cfr;
	cfr = CFStringFind(exten, CFSTR("p7"), kCFCompareCaseInsensitive);
	if(cfr.length != 0) {
		*inputFormat = kSecFormatPKCS7;
		*itemType = kSecItemTypeAggregate;
		SecImpInferDbg("Inferring kSecFormatPKCS7 from file name");
		ortn = true;
	}
	if(!ortn) {
		cfr = CFStringFind(exten, CFSTR("p8"), kCFCompareCaseInsensitive);
		if(cfr.length != 0) {
			*inputFormat = kSecFormatWrappedPKCS8;
			*itemType = kSecItemTypePrivateKey;
			SecImpInferDbg("Inferring kSecFormatPKCS8 from file name");
			ortn = true;
		}
	}
	CFRelease(exten);
	return ortn;
}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:62,代码来源:SecImportExportUtils.cpp

示例12: WebKit_win32_NATIVE

JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(CFURLCreateWithString)
	(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2)
{
	jintLong rc = 0;
	WebKit_win32_NATIVE_ENTER(env, that, CFURLCreateWithString_FUNC);
	rc = (jintLong)CFURLCreateWithString((CFAllocatorRef)arg0, (CFStringRef)arg1, (CFURLRef)arg2);
	WebKit_win32_NATIVE_EXIT(env, that, CFURLCreateWithString_FUNC);
	return rc;
}
开发者ID:HendrikPeilke,项目名称:eclipse.platform.swt,代码行数:9,代码来源:webkit_win32.cpp

示例13: loadKernelExtension

void loadKernelExtension() {
  // Check if the kernel extension package is installed.
  auto results = SQL::selectAllFrom(
      "package_receipts", "path", EQUALS, kKernelPackageReceipt);
  if (results.size() == 0) {
    // The kernel package is not installed.
    return;
  }

  // Find the panic log file for the last panic if we are booting out of panic.
  results =
      SQL::SQL(
          "SELECT f.path AS path FROM (SELECT * FROM nvram WHERE name like "
          "'%panic%') AS nv JOIN (SELECT * FROM file WHERE "
          "directory='/Library/Logs/DiagnosticReports/' AND path like "
          "'%/Kernel%' ORDER BY ctime DESC LIMIT 1) as f;")
          .rows();

  // If a panic exists, check if it was caused by the osquery extension.
  if (results.size() == 1) {
    std::string panic_content;
    if (readFile(results[0]["path"], panic_content).ok()) {
      auto rx = xp::sregex::compile(kKernelBundleRegex);
      xp::smatch matches;
      // If so, write a blacklist file that prevents future load attempts.
      if (xp::regex_search(panic_content, matches, rx)) {
        LOG(ERROR) << "Panic was caused by osquery kernel extension";
        writeTextFile(kBlockingFile, "");
      }
    }
  }

  // Check if the kernel extension is manually (or set from crash) blocked.
  results = SQL::selectAllFrom("file", "path", EQUALS, kBlockingFile);
  if (FLAGS_disable_kernel) {
    LOG(INFO) << "Kernel extension is disabled";
    return;
  } else if (results.size() > 0) {
    LOG(WARNING) << "Kernel extension disabled by file";
    return;
  }

  CFURLRef urls[1];
  CFArrayRef directoryArray;

  urls[0] = CFURLCreateWithString(nullptr, kKernelExtensionDirectory, nullptr);

  directoryArray =
      CFArrayCreate(nullptr, (const void**)urls, 1, &kCFTypeArrayCallBacks);
  if (KextManagerLoadKextWithIdentifier(kKernelBundleId, directoryArray) !=
      kOSReturnSuccess) {
    VLOG(1) << "Could not autoload kernel extension";
  } else {
    VLOG(1) << "Autoloaded osquery kernel extension";
  }
  CFRelease(directoryArray);
}
开发者ID:wxsBSD,项目名称:osquery,代码行数:57,代码来源:kernel_util.cpp

示例14: CFURLCreateWithString

CFURLRef Caching_Stream::createFileURLWithPath(CFStringRef path)
{
    CFURLRef regularUrl = CFURLCreateWithString(kCFAllocatorDefault, path, NULL);
    
    CFURLRef fileUrl = CFURLCreateFilePathURL(kCFAllocatorDefault, regularUrl, NULL);
    
    CFRelease(regularUrl);
    
    return fileUrl;
}
开发者ID:mps,项目名称:FreeStreamer,代码行数:10,代码来源:caching_stream.cpp

示例15: LL_WARNS

// Open a URL with the user's default web browser.
// Must begin with protocol identifier.
void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url, bool async)
{
	// I'm fairly certain that this is all legitimate under Apple's currently supported APIs.
	
	bool found = false;
	S32 i;
	for (i = 0; i < gURLProtocolWhitelistCount; i++)
	{
		if (escaped_url.find(gURLProtocolWhitelist[i]) != std::string::npos)
		{
			found = true;
			break;
		}
	}

	if (!found)
	{
		LL_WARNS() << "spawn_web_browser called for url with protocol not on whitelist: " << escaped_url << LL_ENDL;
		return;
	}

	S32 result = 0;
	CFURLRef urlRef = NULL;

	LL_INFOS() << "Opening URL " << escaped_url << LL_ENDL;

	CFStringRef	stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8);
	if (stringRef)
	{
		// This will succeed if the string is a full URL, including the http://
		// Note that URLs specified this way need to be properly percent-escaped.
		urlRef = CFURLCreateWithString(NULL, stringRef, NULL);

		// Don't use CRURLCreateWithFileSystemPath -- only want valid URLs

		CFRelease(stringRef);
	}

	if (urlRef)
	{
		result = LSOpenCFURLRef(urlRef, NULL);

		if (result != noErr)
		{
			LL_INFOS() << "Error " << result << " on open." << LL_ENDL;
		}

		CFRelease(urlRef);
	}
	else
	{
		LL_INFOS() << "Error: couldn't create URL." << LL_ENDL;
	}
}
开发者ID:gabeharms,项目名称:firestorm,代码行数:56,代码来源:llwindowmacosx.cpp


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