亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stream.c

?? cryptlib是功能強大的安全工具集。允許開發人員快速在自己的軟件中集成加密和認證服務。
?? C
?? 第 1 頁 / 共 3 頁
字號:
/****************************************************************************
*																			*
*							Stream I/O Functions							*
*						Copyright Peter Gutmann 1993-2003					*
*																			*
****************************************************************************/

#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#if defined( INC_ALL )
  #include "stream.h"
#elif defined( INC_CHILD )
  #include "stream.h"
#else
  #include "io/stream.h"
#endif /* Compiler-specific includes */

/* Prototypes for functions in str_file.c */

int fileRead( STREAM *stream, void *buffer, const int length );
int fileWrite( STREAM *stream, const void *buffer, const int length );
int fileFlush( STREAM *stream );
int fileSeek( STREAM *stream, const long position );

/****************************************************************************
*																			*
*								Utility Functions							*
*																			*
****************************************************************************/

/* Exit after saving a detailed error message.  This is used by the stream
   transport-layer code to provide more information to the caller than a
   basic error code */

int retExtStreamFn( STREAM *stream, const int status, const char *format, ... )
	{
#ifdef USE_TCP
	va_list argPtr;

	va_start( argPtr, format );
	vsnprintf( stream->errorMessage, MAX_ERRMSG_SIZE, format, argPtr );
	va_end( argPtr );
#endif /* USE_TCP */
	stream->status = status;
	assert( !cryptArgError( status ) );	/* Catch leaks */
	return( cryptArgError( status ) ? CRYPT_ERROR_FAILED : status );
	}

/* Refill a stream buffer from backing storage */

static int refillStream( STREAM *stream )
	{
	int status;

	assert( stream->type == STREAM_TYPE_FILE );

	/* If we've reached EOF we can't refill it */
	if( stream->flags & STREAM_FFLAG_EOF )
		{
		/* If partial reads are allowed, return an indication of how much 
		   data we got.  This only works once, after this the persistent 
		   error state will return an underflow error before we get to this
		   point */
		stream->status = CRYPT_ERROR_UNDERFLOW;
		return( ( stream->flags & STREAM_FLAG_PARTIALREAD ) ? \
				OK_SPECIAL : CRYPT_ERROR_UNDERFLOW );
		}

	/* If we've moved to a different place in the file, get new data into 
	   the buffer */
	if( ( stream->flags & STREAM_FFLAG_POSCHANGED ) && \
		!( stream->flags & STREAM_FFLAG_POSCHANGED_NOSKIP ) )
		{
		status = fileSeek( stream, stream->bufCount * stream->bufSize );
		if( cryptStatusError( status ) )
			{
			stream->status = status;
			return( status );
			}
		}

	/* Try and read more data into the stream buffer */
	status = fileRead( stream, stream->buffer, stream->bufSize );
	if( cryptStatusError( status ) )
		{
		stream->status = status;
		return( status );
		}
	if( status < stream->bufSize )
		{
		/* If we got less than we asked for, remember that we're at the end
		   of the file */
		stream->flags |= STREAM_FFLAG_EOF;
		if( status == 0 )
			{
			/* We ran out of input on an exact buffer boundary.  If partial 
			   reads are allowed, return an indication of how much data we 
			   got.  This only works once, after this the persistent error 
			   state will return an underflow error before we get to this 
			   point */
			stream->status = CRYPT_ERROR_UNDERFLOW;
			return( ( stream->flags & STREAM_FLAG_PARTIALREAD ) ? \
					OK_SPECIAL : CRYPT_ERROR_UNDERFLOW );
			}
		}

	/* We've refilled the stream buffer from the file, remember the 
	   details */
	if( !( stream->flags & STREAM_FFLAG_POSCHANGED ) )
		{
		stream->bufCount++;
		stream->bufPos = 0;
		}
	stream->bufEnd = status;
	stream->flags &= ~( STREAM_FFLAG_POSCHANGED | \
						STREAM_FFLAG_POSCHANGED_NOSKIP );

	return( CRYPT_OK );
	}

/* Empty a stream buffer to backing storage */

static int emptyStream( STREAM *stream, const BOOLEAN forcedFlush )
	{
	int status = CRYPT_OK;

	assert( stream->type == STREAM_TYPE_FILE );

	/* If the stream position has been changed, this can only have been from 
	   a rewind of the stream, in which case we move back to the start of 
	   the file */
	if( stream->flags & STREAM_FFLAG_POSCHANGED )
		{
		status = fileSeek( stream, 0 );
		if( cryptStatusError( status ) )
			{
			stream->status = status;
			return( status );
			}
		}

	/* Try and write the data to the stream's backing storage */
	status = fileWrite( stream, stream->buffer, stream->bufPos );
	if( cryptStatusError( status ) )
		{
		stream->status = status;
		return( status );
		}

	/* Reset the position-changed flag and, if we've written another buffer 
	   full of data, remember the details.  If it's a forced flush we leave
	   everything as is, to remember the last write position in the file */
	stream->flags &= ~STREAM_FFLAG_POSCHANGED;
	if( !forcedFlush )
		{
		stream->bufCount++;
		stream->bufPos = 0;
		}

	return( CRYPT_OK );
	}

/****************************************************************************
*																			*
*							Read/Write Functions							*
*																			*
****************************************************************************/

/* Read data from a stream */

int sgetc( STREAM *stream )
	{
	assert( isWritePtr( stream, sizeof( STREAM ) ) );
	assert( stream->type == STREAM_TYPE_MEMORY || \
			stream->type == STREAM_TYPE_FILE );
	assert( stream->bufPos >= 0 && stream->bufPos <= stream->bufEnd );
	assert( isReadPtr( stream->buffer, stream->bufSize ) );

	/* Check that the input parameters are in order */
	if( !isWritePtr( stream, sizeof( STREAM ) ) )
		{
		assert( NOTREACHED );
		return( CRYPT_ERROR_READ );
		}
	if( stream->bufPos < 0 || stream->bufPos > stream->bufEnd )
		{
		assert( NOTREACHED );
		return( sSetError( stream, CRYPT_ERROR_READ ) );
		}

	/* If there's a problem with the stream, don't try to do anything */
	if( cryptStatusError( stream->status ) )
		return( stream->status );

	switch( stream->type )
		{
		case  STREAM_TYPE_MEMORY:
			assert( !( stream->flags & ~STREAM_FLAG_MASK ) );

			/* Read the data from the stream buffer */
			if( stream->bufPos >= stream->bufEnd )
				{
				stream->status = CRYPT_ERROR_UNDERFLOW;
				return( CRYPT_ERROR_UNDERFLOW );
				}
			return( stream->buffer[ stream->bufPos++ ] );

		case STREAM_TYPE_FILE:
			assert( !( stream->flags & ~STREAM_FFLAG_MASK ) );

			/* Read the data from the file */
			if( stream->bufPos >= stream->bufEnd || \
				( stream->flags & STREAM_FFLAG_POSCHANGED ) )
				{
				int status = refillStream( stream );
				if( cryptStatusError( status ) )
					return( ( status == OK_SPECIAL ) ? 0 : status );
				}
			return( stream->buffer[ stream->bufPos++ ] );
		}

	assert( NOTREACHED );
	return( CRYPT_ERROR_READ );		/* Get rid of compiler warning */
	}

int sread( STREAM *stream, void *buffer, const int length )
	{
	int status;

	assert( isWritePtr( stream, sizeof( STREAM ) ) );
	assert( stream->type == STREAM_TYPE_MEMORY || \
			stream->type == STREAM_TYPE_FILE || \
			stream->type == STREAM_TYPE_NETWORK );
	assert( stream->bufPos >= 0 && stream->bufPos <= stream->bufEnd );
	assert( stream->type == STREAM_TYPE_NETWORK || \
			isReadPtr( stream->buffer, stream->bufSize ) );
	assert( isWritePtr( buffer, length ) );
	assert( length > 0 );

	/* Check that the input parameters are in order */
	if( !isWritePtr( stream, sizeof( STREAM ) ) )
		{
		assert( NOTREACHED );
		return( CRYPT_ERROR_READ );
		}
	if( stream->bufPos < 0 || stream->bufPos > stream->bufEnd || \
		!isWritePtr( buffer, length ) )
		{
		assert( NOTREACHED );
		return( sSetError( stream, CRYPT_ERROR_READ ) );
		}

	/* If there's a problem with the stream, don't try to do anything */
	if( cryptStatusError( stream->status ) )
		return( stream->status );

	switch( stream->type )
		{
		case  STREAM_TYPE_MEMORY:
			assert( !( stream->flags & ~STREAM_FLAG_MASK ) );

			/* Read the data from the stream buffer */
			if( stream->bufPos + length > stream->bufEnd )
				{
				memset( buffer, 0, length );	/* Clear the output buffer */
				stream->status = CRYPT_ERROR_UNDERFLOW;
				return( CRYPT_ERROR_UNDERFLOW );
				}
			memcpy( buffer, stream->buffer + stream->bufPos, length );
			stream->bufPos += length;

			return( CRYPT_OK );

		case STREAM_TYPE_FILE:
			{
			BYTE *bufPtr = buffer;
			int dataLength = length, bytesCopied = 0;

			assert( !( stream->flags & ~STREAM_FFLAG_MASK ) );

			/* Read the data from the file */
			while( dataLength > 0 )
				{
				int bytesToCopy;

				/* If the stream buffer is empty, try and refill it */
				if( stream->bufPos >= stream->bufEnd || \
					( stream->flags & STREAM_FFLAG_POSCHANGED ) )
					{
					status = refillStream( stream );
					if( cryptStatusError( status ) )
						return( ( status == OK_SPECIAL ) ? \
								bytesCopied : status );
					}

				/* Copy as much data as we can out of the stream buffer */
				bytesToCopy = min( dataLength, \
								   stream->bufEnd - stream->bufPos );
				memcpy( bufPtr, stream->buffer + stream->bufPos, 
						bytesToCopy );
				stream->bufPos += bytesToCopy;
				bufPtr += bytesToCopy;
				bytesCopied += bytesToCopy;
				dataLength -= bytesToCopy;
				}

			/* Usually reads are atomic so we just return an all-OK 
			   indicator, however if we're performing partial reads we need
			   to return an exact byte count */
			return( ( stream->flags & STREAM_FLAG_PARTIALREAD ) ? \
					bytesCopied : CRYPT_OK );
			}

#ifdef USE_TCP
		case STREAM_TYPE_NETWORK:
			assert( !( stream->flags & ~STREAM_NFLAG_MASK ) );
			assert( stream->readFunction != NULL );
			assert( ( stream->flags & STREAM_NFLAG_ISSERVER ) || \
					stream->host != NULL || \
					stream->netSocket != CRYPT_ERROR );
			assert( stream->timeout >= 0 && stream->timeout <= 300 );

			/* Read the data from the network.  Reads are normally atomic, 
			   but when doing bulk data transfers can be restarted after
			   a timeout */
			status = stream->readFunction( stream, buffer, length );
			if( cryptStatusError( status ) )
				{
				if( status != CRYPT_ERROR_COMPLETE )
					return( status );

				/* If we get a CRYPT_ERROR_COMPLETE status this means that
				   the other side has closed the connection.  This status is 
				   returned when there are intermediate protocol layers such 
				   as HTTP or tunnelling over a cryptlib session involved.
				   When this occurs we update the stream state and map the 
				   status to a standard read error.  The exact code to 
				   return here is a bit uncertain, it isn't specifically a 
				   read error because either the other side is allowed to 
				   close the connection after it's said its bit (and so it's 
				   not a read error), or it has to perform a 
				   cryptographically protected close (in which case any 
				   non-OK status indicates a problem).  The most sensible 
				   status is probably a read error */
				sioctl( stream, STREAM_IOCTL_CONNSTATE, NULL, FALSE );
				return( CRYPT_ERROR_READ );
				}
			if( status < length && \
				!( stream->flags & ( STREAM_FLAG_PARTIALREAD | \
									 STREAM_NFLAG_ENCAPS ) ) )
				{
				/* If we didn't read all of the data and partial reads 
				   aren't allowed, report a read timeout */
				retExtStream( stream, CRYPT_ERROR_TIMEOUT,
							  "Read timed out with %d of %d bytes read",
							  status, length );
				}
			return( status );
#endif /* USE_TCP */
		}

	assert( NOTREACHED );
	return( CRYPT_ERROR_READ );		/* Get rid of compiler warning */
	}

/* Write data to a stream */

int sputc( STREAM *stream, const int ch )
	{
	assert( isWritePtr( stream, sizeof( STREAM ) ) );
	assert( stream->type == STREAM_TYPE_NULL || \
			stream->type == STREAM_TYPE_MEMORY || \
			stream->type == STREAM_TYPE_FILE );
	assert( stream->type == STREAM_TYPE_NULL || \
			isWritePtr( stream->buffer, stream->bufSize ) );
	assert( stream->type == STREAM_TYPE_NULL || \
			stream->bufPos >= 0 && stream->bufPos <= stream->bufSize );
	assert( !( stream->flags & STREAM_FLAG_READONLY ) );

	/* Check that the input parameters are in order */
	if( !isWritePtr( stream, sizeof( STREAM ) ) )
		{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费人成精品欧美精品| 成人爽a毛片一区二区免费| 久久99精品久久久久久国产越南| 国产精品高潮呻吟久久| 亚洲美女淫视频| 蜜桃av一区二区在线观看| 国产欧美日产一区| 视频一区中文字幕| 天天综合色天天综合| 国产在线日韩欧美| 奇米精品一区二区三区在线观看一 | 国产精品亚洲第一| 美日韩一区二区| 91偷拍与自偷拍精品| 日韩午夜激情视频| 亚洲摸摸操操av| 自拍偷自拍亚洲精品播放| 日韩国产欧美在线播放| 日韩高清不卡在线| 91在线视频免费91| 国产婷婷色一区二区三区四区 | 91麻豆国产在线观看| 91精品国产色综合久久久蜜香臀| 欧美日韩国产综合视频在线观看 | 岛国av在线一区| 8x福利精品第一导航| 亚洲欧美自拍偷拍| 久久99久久99精品免视看婷婷| 精品在线播放免费| 麻豆精品视频在线观看视频| 蜜桃久久精品一区二区| 欧美最猛黑人xxxxx猛交| 欧美激情中文字幕一区二区| 免费观看在线色综合| 国产剧情一区二区| 日韩一区二区三区四区五区六区| 欧美岛国在线观看| 久久久亚洲精品一区二区三区 | 欧美人体做爰大胆视频| 亚洲欧美另类小说视频| 成人av资源在线观看| 欧美精品一区二区久久婷婷| 久久国产成人午夜av影院| 欧美日韩另类一区| 亚洲国产aⅴ天堂久久| 欧美天堂亚洲电影院在线播放| 51精品国自产在线| 亚洲第一成年网| 欧美午夜免费电影| 亚洲一区在线免费观看| 欧美专区亚洲专区| 天堂成人免费av电影一区| 欧美无砖砖区免费| 亚洲风情在线资源站| 国产在线一区二区综合免费视频| 92国产精品观看| 日韩欧美国产午夜精品| 日韩va欧美va亚洲va久久| 福利一区福利二区| 国产精品理论在线观看| 琪琪久久久久日韩精品| 国产乱理伦片在线观看夜一区| 国产+成+人+亚洲欧洲自线| 国产亚洲欧美在线| 不卡在线视频中文字幕| 专区另类欧美日韩| 欧美影视一区在线| 日本午夜一本久久久综合| 91丨porny丨蝌蚪视频| 一区二区激情视频| 日韩三级.com| 国产成人av在线影院| 亚洲欧美另类久久久精品2019| 国产精品一区二区三区四区| 欧美丝袜自拍制服另类| 久久久蜜桃精品| 99在线精品免费| 亚洲影视在线播放| 粉嫩aⅴ一区二区三区四区五区 | 国产精品一区久久久久| 欧美久久婷婷综合色| 另类小说色综合网站| 国产精品久久久久aaaa樱花| 欧美美女bb生活片| 亚洲一区二区三区视频在线播放 | 久久久99精品免费观看不卡| 99精品国产视频| 免费精品视频在线| 亚洲免费观看视频| 91猫先生在线| 紧缚奴在线一区二区三区| 亚洲婷婷综合久久一本伊一区| 九色综合狠狠综合久久| 亚洲欧美一区二区久久| 成人免费视频视频| 午夜久久久久久| 久久久久久久久久久久久久久99| 久久电影网电视剧免费观看| 亚洲精品免费视频| 精品欧美久久久| 不卡的电影网站| 日本不卡一区二区三区| 国产亚洲制服色| 欧美日韩国产一区二区三区地区| 亚洲国产精品一区二区久久| 欧美专区在线观看一区| 国产精品亚洲成人| 蜜臂av日日欢夜夜爽一区| 日韩一区二区电影在线| 91丝袜美女网| 成人激情视频网站| 精品在线亚洲视频| 日本亚洲三级在线| 亚洲va国产天堂va久久en| 亚洲欧美日韩在线播放| 国产三级一区二区| 久久综合视频网| 成人精品国产免费网站| 国产一区二区导航在线播放| 欧美激情一区三区| 久久久久99精品国产片| 欧美军同video69gay| 欧美亚洲动漫制服丝袜| 奇米在线7777在线精品| 亚洲电影一级黄| 亚洲一区二区在线免费看| 亚洲精品日韩一| 一区二区三区四区在线| 一区二区三区四区国产精品| 中文字幕综合网| 亚洲欧美一区二区三区孕妇| 亚洲精品伦理在线| 一区二区三区鲁丝不卡| 亚洲综合图片区| 久久精子c满五个校花| 久久精品夜夜夜夜久久| 国产日韩欧美综合在线| 91福利区一区二区三区| 日本精品视频一区二区| 色老汉av一区二区三区| 在线亚洲精品福利网址导航| 在线日韩一区二区| 91精品福利在线一区二区三区| 成人污视频在线观看| 五月婷婷久久丁香| 麻豆视频观看网址久久| 精彩视频一区二区三区| 成人午夜视频在线观看| 不卡一二三区首页| 9人人澡人人爽人人精品| 91精品办公室少妇高潮对白| 国产伦精品一区二区三区视频青涩| 亚洲一区二区精品视频| 奇米影视一区二区三区| 国产伦精品一区二区三区视频青涩| 一区二区三区在线视频播放| 日本不卡视频在线| 国产激情视频一区二区三区欧美| 亚洲欧美在线aaa| 亚洲成a人片在线不卡一二三区| 国产精品三级av在线播放| 国产农村妇女毛片精品久久麻豆 | 精品国产免费视频| 欧美精品黑人性xxxx| 欧美成人a在线| 国产精品无人区| 日韩经典一区二区| 国产91在线|亚洲| 欧美在线色视频| 久久精品日韩一区二区三区| 亚洲人成网站在线| 国产麻豆精品视频| 在线亚洲人成电影网站色www| 成人av网站在线观看| 制服丝袜在线91| 欧美精品1区2区| 中文字幕在线观看不卡视频| 国产日产精品1区| 天堂成人免费av电影一区| 成人精品免费看| 日韩欧美成人午夜| 一区二区三区精品在线观看| 国产美女精品在线| 粉嫩av一区二区三区在线播放| 国产精华液一区二区三区| 欧美久久久久久久久中文字幕| 欧美精品18+| 亚洲乱码国产乱码精品精的特点| 亚洲欧美激情视频在线观看一区二区三区 | 亚洲.国产.中文慕字在线| 国产精品狼人久久影院观看方式| 欧美成人艳星乳罩| 一区二区欧美国产| 99精品在线观看视频| 久久一夜天堂av一区二区三区| 久久精品人人做| 日本成人在线一区| 欧美乱妇23p| 亚洲自拍偷拍九九九| 99久久99久久免费精品蜜臀|