當前位置: 首頁>>代碼示例>>C++>>正文


C++ CFReadStreamClose函數代碼示例

本文整理匯總了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;
    }
}
開發者ID:refaqtor,項目名稱:sourcegear_veracity_clone,代碼行數:31,代碼來源:sg_sync_client_vtable__http__cfnetwork.c

示例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);
    }
}
開發者ID:alfintatorkace,項目名稱:osx-10.9-opensource,代碼行數:33,代碼來源:asynchttp.c

示例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);
}
開發者ID:harlanlewis,項目名稱:webkit,代碼行數:30,代碼來源:SocketStreamHandleCFNet.cpp

示例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);
	}
}
開發者ID:ChaseJohnson,項目名稱:LogKext,代碼行數:34,代碼來源:logKextDaemon.cpp

示例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;
}
開發者ID:525828027,項目名稱:networkpx,代碼行數:35,代碼來源:GPExtensions.c

示例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;
}
開發者ID:Blue-Rocket,項目名稱:WebApiClient,代碼行數:60,代碼來源:WebApiClientDigestUtils.c

示例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();
    }
開發者ID:DampKeg,項目名稱:DampKeg,代碼行數:31,代碼來源:TCPStream_CFNetwork.cpp

示例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);
}
開發者ID:BankKit,項目名稱:juesheng,代碼行數:30,代碼來源:CFFTPSample.c

示例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;
    }
}
開發者ID:0x0B501E7E,項目名稱:pjproject,代碼行數:8,代碼來源:activesock.c

示例10: closeAndRelease

void closeAndRelease(CFReadStreamRef readStream, CFURLRef fileURL) {
    if (readStream) {
        CFReadStreamClose(readStream);
        CFRelease(readStream);
    }
    if (fileURL) {
        CFRelease(fileURL);
    }
}
開發者ID:tudormunteanu,項目名稱:FileMD5Hash,代碼行數:9,代碼來源:FileMD5Hash.c

示例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;
}
開發者ID:acekiller,項目名稱:FreeStreamer,代碼行數:12,代碼來源:http_stream.cpp

示例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;
}
開發者ID:jeff-jenness,項目名稱:webkit,代碼行數:12,代碼來源:FormDataStreamCFNet.cpp

示例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;
    }
}
開發者ID:Czerrr,項目名稱:ISeeBrowser,代碼行數:13,代碼來源:FormDataStreamCFNet.cpp

示例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;
  }
}
開發者ID:CaptainPopetastic,項目名稱:libetpan,代碼行數:13,代碼來源:mailstream_cfstream.c

示例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;
}
開發者ID:JeremyAgost,項目名稱:SDMMobileDevice,代碼行數:14,代碼來源:dev.c


注:本文中的CFReadStreamClose函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。