⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgpioutilities.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
字号:
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.

	$Id: pgpIOUtilities.c,v 1.4 2002/08/06 20:10:34 dallen Exp $
____________________________________________________________________________*/
/*
 * pgpIOUtilities.c -- Sample code for using PGPIO
 */
#include "pgpPFLConfig.h"
#include "pgpPFLErrors.h"
#include "pgpMem.h"
#include "pgpIOUtilities.h"


/*____________________________________________________________________________
	Copy bytes from one I/O to another using supplied buffer. 
____________________________________________________________________________*/
	PGPError
PGPCopyIOUsingBuffer(
	PGPIORef	fromIO,
	PGPFileOffset numBytes,
	PGPIORef	toIO,
	void *		buffer,
	PGPSize		bufferSize )
{
	PGPFileOffset remaining;
	PGPError	err	= kPGPError_NoErr;
	
	remaining	= numBytes;
	while ( remaining != 0 )
	{	
		PGPSize count;
		
		// Minimum here of 64 bit and 32 bit will be 32 -wjb
		count	= (PGPSize)pgpMin( remaining, bufferSize );
		err	= PGPIORead( fromIO, count, buffer, NULL);
		if ( IsPGPError( err ) )
			break;
		
		err	= PGPIOWrite( toIO, count, buffer );
		if ( IsPGPError( err ) )
			break;
		
		remaining	-= count;
	}
	
	return( err );
}

/*____________________________________________________________________________
	Copy bytes from one I/O to another. 
	Caller will want to call PGPIOSetPos to set file mark first.
____________________________________________________________________________*/
	PGPError
PGPCopyIO(
	PGPIORef	fromIO,
	PGPFileOffset	numBytes,
	PGPIORef	toIO )
{
	void *			buffer	= NULL;
	PGPSize			bufferSize;
	PGPError		err	= kPGPError_NoErr;
	
	/* a reasonable cross-platform size */
	#define kBufferSize		( 32UL * 1024UL )
	
	// Minimum of 64 bit and 32 bit will be 32 bits -wjb
	bufferSize	= (PGPSize)pgpMin( numBytes, kBufferSize );
	buffer		= PGPNewData( PGPIOGetMemoryMgr( fromIO ), bufferSize, 0);
	if ( IsntNull( buffer ) )
	{
		err	= PGPCopyIOUsingBuffer( fromIO, numBytes, toIO,
				buffer, bufferSize );
			
		PGPFreeData( buffer );
	}
	else
	{
		err	= kPGPError_OutOfMemory;
	}
	return( err );
}


/*__Editor_settings____

	Local Variables:
	tab-width: 4
	End:
	vi: ts=4 sw=4
	vim: si
_____________________*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -