本文整理匯總了C++中CFReadStreamClose函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFReadStreamClose函數的具體用法?C++ CFReadStreamClose怎麽用?C++ CFReadStreamClose使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFReadStreamClose函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: perform_request__file
static void perform_request__file(
SG_context* pCtx,
CFHTTPMessageRef myRequest,
CFHTTPMessageRef* pmyResponse,
SG_pathname* pPath,
SG_bool b_progress
)
{
CFReadStreamRef myReadStream = NULL;
CFHTTPMessageRef myResponse = NULL;
SG_ERR_CHECK( send_request(pCtx, myRequest, &myReadStream) );
SG_ERR_CHECK( read_entire_stream__file(pCtx, myReadStream, pPath, &myResponse, b_progress) );
*pmyResponse = myResponse;
myResponse = NULL;
fail:
if (myReadStream)
{
CFReadStreamClose(myReadStream);
CFRelease(myReadStream);
myReadStream = NULL;
}
if (myResponse)
{
CFRelease(myResponse);
myResponse = NULL;
}
}
示例2: asynchttp_complete
static void asynchttp_complete(asynchttp_t *http) {
secdebug("http", "http: %p", http);
/* Shutdown streams and timer, we're about to invoke our client callback. */
if (http->stream) {
CFReadStreamSetClient(http->stream, kCFStreamEventNone, NULL, NULL);
CFReadStreamSetDispatchQueue(http->stream, NULL);
CFReadStreamClose(http->stream);
CFReleaseNull(http->stream);
}
if (http->timer) {
dispatch_source_cancel(http->timer);
dispatch_release_null(http->timer);
}
if (http->completed) {
/* This should probably move to our clients. */
CFTimeInterval maxAge = NULL_TIME;
if (http->response) {
CFStringRef cacheControl = CFHTTPMessageCopyHeaderFieldValue(
http->response, CFSTR("cache-control"));
if (cacheControl) {
CFStringRef maxAgeValue = copyParseMaxAge(cacheControl);
CFRelease(cacheControl);
if (maxAgeValue) {
secdebug("http", "http header max-age: %@", maxAgeValue);
maxAge = CFStringGetDoubleValue(maxAgeValue);
CFRelease(maxAgeValue);
}
}
}
http->completed(http, maxAge);
}
}
示例3: LOG
void SocketStreamHandle::platformClose()
{
LOG(Network, "SocketStreamHandle %p platformClose", this);
if (m_pacRunLoopSource)
removePACRunLoopSource();
ASSERT(!m_readStream == !m_writeStream);
if (!m_readStream) {
if (m_connectingSubstate == New || m_connectingSubstate == ExecutingPACFile)
m_client->didCloseSocketStream(this);
return;
}
#if PLATFORM(WIN)
CFReadStreamUnscheduleFromRunLoop(m_readStream.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
CFWriteStreamUnscheduleFromRunLoop(m_writeStream.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
#else
CFReadStreamUnscheduleFromRunLoop(m_readStream.get(), CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
CFWriteStreamUnscheduleFromRunLoop(m_writeStream.get(), CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
#endif
CFReadStreamClose(m_readStream.get());
CFWriteStreamClose(m_writeStream.get());
m_readStream = 0;
m_writeStream = 0;
m_client->didCloseSocketStream(this);
}
示例4: updateKeymap
void updateKeymap()
{
CFReadStreamRef readStream;
if (!fileExists(CFSTR(KEYMAP_PATH)))
{
stamp_file(CFSTR("Error: Keymap file is missing"));
keymap = NULL;
return;
}
readStream = CFReadStreamCreateWithFile(kCFAllocatorDefault,CFURLCreateWithFileSystemPath(kCFAllocatorDefault,CFSTR(KEYMAP_PATH),kCFURLPOSIXPathStyle,false));
if (!readStream||!(CFReadStreamOpen(readStream)))
{
stamp_file(CFSTR("Error: Can't open keymap file"));
keymap = NULL;
return;
}
keymap = (CFDictionaryRef)CFPropertyListCreateFromStream(kCFAllocatorDefault,readStream,0,kCFPropertyListImmutable,NULL,NULL);
CFReadStreamClose(readStream);
if (!keymap)
{
stamp_file(CFSTR("Error: Can't read keymap file"));
return;
}
Boolean validKey;
showMods = (CFPreferencesGetAppBooleanValue(CFSTR("Mods"),PREF_DOMAIN,&validKey))?kCFBooleanTrue:kCFBooleanFalse;
if (!validKey)
{
showMods = kCFBooleanTrue;
CFPreferencesSetAppValue(CFSTR("Mods"),showMods,PREF_DOMAIN);
}
}
示例5: GPPropertyListCopyLocalizableStringsDictionary
extern CFDictionaryRef GPPropertyListCopyLocalizableStringsDictionary(CFURLRef fileURL) {
CFReadStreamRef stream = CFReadStreamCreateWithFile(NULL, fileURL);
if (stream == NULL)
return NULL;
if (!CFReadStreamOpen(stream)) {
CFRelease(stream);
return NULL;
}
CFDictionaryRef dict = CFPropertyListCreateFromStream(NULL, stream, 0, kCFPropertyListImmutable, NULL, NULL);
CFReadStreamClose(stream);
CFRelease(stream);
if (dict == NULL)
return NULL;
if (CFGetTypeID(dict) != CFDictionaryGetTypeID()) {
CFRelease(dict);
return NULL;
}
CFDictionaryRef localizedStringsDict = CFDictionaryGetValue(dict, CFSTR("Localizations"));
if (localizedStringsDict == NULL || CFGetTypeID(localizedStringsDict) != CFDictionaryGetTypeID()) {
CFRelease(dict);
return NULL;
}
CFIndex langCount = CFDictionaryGetCount(localizedStringsDict);
CFStringRef keys[langCount]; // assume we don't have 4000 languages :p
CFDictionaryGetKeysAndValues(localizedStringsDict, (const void**)keys, NULL);
CFArrayCallBacks languagesCallbacks = {0, NULL, NULL, NULL, &CFEqual};
CFArrayRef languages = CFArrayCreate(NULL, (const void**)keys, langCount, &languagesCallbacks);
CFArrayRef preferedLanguages = CFBundleCopyPreferredLocalizationsFromArray(languages);
CFDictionaryRef retval = CFRetain(CFDictionaryGetValue(localizedStringsDict, CFArrayGetValueAtIndex(preferedLanguages, 0)));
CFRelease(languages);
CFRelease(preferedLanguages);
CFRelease(dict);
return retval;
}
示例6: WebApiClientMD5DigestCreateWithFilePath
CFDataRef WebApiClientMD5DigestCreateWithFilePath(CFStringRef filePath, size_t bufferSize) {
// Declare needed variables
CFDataRef result = NULL;
CFReadStreamRef readStream = NULL;
// Get the file URL
CFURLRef fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)filePath, kCFURLPOSIXPathStyle, (Boolean)false);
if ( fileURL ) {
// Create and open the read stream
readStream = CFReadStreamCreateWithFile(kCFAllocatorDefault, fileURL);
if ( readStream ) {
Boolean didSucceed = CFReadStreamOpen(readStream);
if ( didSucceed ) {
// Initialize the hash object
CC_MD5_CTX hashObject;
CC_MD5_Init(&hashObject);
// Make sure chunkSizeForReadingData is valid
if ( bufferSize < 1 ) {
bufferSize = FileHashDefaultChunkSizeForReadingData;
}
// Feed the data to the hash object
bool hasMoreData = true;
while ( hasMoreData ) {
uint8_t buffer[bufferSize];
CFIndex readBytesCount = CFReadStreamRead(readStream, (UInt8 *)buffer, (CFIndex)sizeof(buffer));
if ( readBytesCount == -1 ) break;
if ( readBytesCount == 0 ) {
hasMoreData = false;
continue;
}
CC_MD5_Update(&hashObject, (const void *)buffer, (CC_LONG)readBytesCount);
}
// Check if the read operation succeeded
didSucceed = !hasMoreData;
// Compute the hash digest
unsigned char digest[CC_MD5_DIGEST_LENGTH];
CC_MD5_Final(digest, &hashObject);
// Abort if the read operation failed
if ( didSucceed ) {
result = CFDataCreate(kCFAllocatorDefault, digest, CC_MD5_DIGEST_LENGTH);
}
}
}
}
if ( readStream ) {
CFReadStreamClose(readStream);
CFRelease(readStream);
}
if ( fileURL ) {
CFRelease(fileURL);
}
return result;
}
示例7: SSLClose
void TCPStream_CFNetwork::close()
{
if (state == Stream::State::Closed) {
return;
}
state = Stream::State::Closed;
if (secureLayerContext != nullptr) {
SSLClose(secureLayerContext);
}
if (inputStream != nullptr) {
CFReadStreamUnscheduleFromRunLoop(inputStream, CFRunLoopGetMain(), kCFRunLoopDefaultMode);
CFReadStreamClose(inputStream);
CFRelease(inputStream);
inputStream = nullptr;
}
if (outputStream != nullptr) {
CFWriteStreamClose(outputStream);
CFRelease(outputStream);
outputStream= nullptr;
}
if (secureLayerContext != nullptr) {
CFRelease(secureLayerContext);
secureLayerContext = nullptr;
}
handleClosedEvent();
}
示例8: MyStreamInfoDestroy
/* MyStreamInfoDestroy destroys a MyStreamInfo 'object', cleaning up any resources that it owns. */
static void
MyStreamInfoDestroy(MyStreamInfo * info)
{
assert(info != NULL);
if (info->readStream) {
CFReadStreamUnscheduleFromRunLoop(info->readStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
(void) CFReadStreamSetClient(info->readStream, kCFStreamEventNone, NULL, NULL);
/* CFReadStreamClose terminates the stream. */
CFReadStreamClose(info->readStream);
CFRelease(info->readStream);
}
if (info->writeStream) {
CFWriteStreamUnscheduleFromRunLoop(info->writeStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
(void) CFWriteStreamSetClient(info->writeStream, kCFStreamEventNone, NULL, NULL);
/* CFWriteStreamClose terminates the stream. */
CFWriteStreamClose(info->writeStream);
CFRelease(info->writeStream);
}
if (info->proxyDict) {
CFRelease(info->proxyDict); // see discussion of <rdar://problem/3745574> below
}
free(info);
}
示例9: activesock_destroy_iphone_os_stream
static void activesock_destroy_iphone_os_stream(pj_activesock_t *asock)
{
if (asock->readStream) {
CFReadStreamClose(asock->readStream);
CFRelease(asock->readStream);
asock->readStream = NULL;
}
}
示例10: closeAndRelease
void closeAndRelease(CFReadStreamRef readStream, CFURLRef fileURL) {
if (readStream) {
CFReadStreamClose(readStream);
CFRelease(readStream);
}
if (fileURL) {
CFRelease(fileURL);
}
}
示例11: CFReadStreamSetClient
void HTTP_Stream::close()
{
/* The stream has been already closed */
if (!m_readStream) {
return;
}
CFReadStreamSetClient(m_readStream, 0, NULL, NULL);
setScheduledInRunLoop(false);
CFReadStreamClose(m_readStream);
CFRelease(m_readStream), m_readStream = 0;
}
示例12: closeCurrentStream
static void closeCurrentStream(FormStreamFields* form)
{
if (form->currentStream) {
CFReadStreamClose(form->currentStream);
CFReadStreamSetClient(form->currentStream, kCFStreamEventNone, 0, 0);
CFRelease(form->currentStream);
form->currentStream = 0;
form->currentStreamRangeLength = BlobDataItem::toEndOfFile;
}
form->currentData = nullptr;
}
示例13: closeCurrentStream
static void closeCurrentStream(FormStreamFields *form)
{
if (form->currentStream) {
CFReadStreamClose(form->currentStream);
CFReadStreamSetClient(form->currentStream, kCFStreamEventNone, NULL, NULL);
CFRelease(form->currentStream);
form->currentStream = NULL;
}
if (form->currentData) {
fastFree(form->currentData);
form->currentData = 0;
}
}
示例14: cfstream_data_close
static void cfstream_data_close(struct mailstream_cfstream_data * cfstream_data)
{
if (cfstream_data->writeStream != NULL) {
CFWriteStreamClose(cfstream_data->writeStream);
CFRelease(cfstream_data->writeStream);
cfstream_data->writeStream = NULL;
}
if (cfstream_data->readStream != NULL) {
CFReadStreamClose(cfstream_data->readStream);
CFRelease(cfstream_data->readStream);
cfstream_data->readStream = NULL;
}
}
示例15: copy_disk_app_identifier
CFStringRef copy_disk_app_identifier(CFURLRef disk_app_url) {
CFURLRef plist_url = CFURLCreateCopyAppendingPathComponent(NULL, disk_app_url, CFSTR("Info.plist"), false);
CFReadStreamRef plist_stream = CFReadStreamCreateWithFile(NULL, plist_url);
CFReadStreamOpen(plist_stream);
CFPropertyListRef plist = CFPropertyListCreateWithStream(NULL, plist_stream, 0, kCFPropertyListImmutable, NULL, NULL);
CFStringRef bundle_identifier = CFRetain(CFDictionaryGetValue(plist, CFSTR("CFBundleIdentifier")));
CFReadStreamClose(plist_stream);
CFRelease(plist_url);
CFRelease(plist_stream);
CFRelease(plist);
return bundle_identifier;
}