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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? stream.c

?? cryptlib是功能強大的安全工具集。允許開發(fā)人員快速在自己的軟件中集成加密和認(rèn)證服務(wù)。
?? 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 ) ) )
		{

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品一区二区三区影院| 国产视频一区在线观看| 久久爱www久久做| 国产精品看片你懂得| 欧美一区二区三区不卡| 一本大道久久a久久精二百| 精品中文字幕一区二区| 一区二区三区日韩在线观看| 久久精品亚洲精品国产欧美kt∨ | 91精品国产免费久久综合| 99久久免费精品高清特色大片| 精品一区二区免费| 日韩精品久久理论片| 亚洲欧美另类久久久精品2019| 久久久久久久久久美女| 91精品国产综合久久精品性色| 色综合久久久久综合体| 国产成人免费视频| 久久国内精品自在自线400部| 亚洲一区在线看| 最新高清无码专区| 亚洲国产高清aⅴ视频| 久久综合九色综合欧美就去吻| 91精品久久久久久蜜臀| 欧美在线观看一二区| 日本韩国欧美在线| 91丝袜美腿高跟国产极品老师| 国产成a人亚洲| 国产精品一二三| 经典三级在线一区| 久久99精品久久久久久久久久久久 | 精品亚洲porn| 日本欧美久久久久免费播放网| 夜夜夜精品看看| 久久er99精品| 蜜臀av性久久久久蜜臀aⅴ| 丝袜亚洲另类欧美| 天堂蜜桃一区二区三区| 天天av天天翘天天综合网色鬼国产 | 九色|91porny| 精品无人码麻豆乱码1区2区| 国产在线麻豆精品观看| 国产一区二区三区电影在线观看 | 中文字幕中文字幕一区二区| 国产欧美一区视频| 国产欧美综合在线观看第十页| 久久午夜免费电影| 久久精子c满五个校花| 日本一区二区在线不卡| 亚洲国产精品高清| 日韩理论片一区二区| 亚洲欧美欧美一区二区三区| 亚洲日本一区二区| 亚洲成人黄色影院| 蜜臀久久久99精品久久久久久| 久久成人麻豆午夜电影| 国产一区二区三区综合| www.久久精品| 欧美日韩一区二区三区免费看| 91麻豆精品国产91久久久久久久久| 欧美变态凌虐bdsm| 国产精品午夜久久| 一区二区三区小说| 欧美午夜免费电影| 制服丝袜激情欧洲亚洲| 精品国产精品网麻豆系列| 日本一区二区三区免费乱视频| 中文字幕日韩精品一区| 亚洲国产一区二区三区| 男人的天堂久久精品| 国产jizzjizz一区二区| 91高清视频在线| 欧美电视剧免费全集观看| 国产精品―色哟哟| 亚洲国产精品尤物yw在线观看| 老司机免费视频一区二区三区| 国产jizzjizz一区二区| 欧美色图12p| 国产视频一区二区在线观看| 亚洲一区二区三区视频在线播放| 九九国产精品视频| 在线精品观看国产| 久久影音资源网| 亚洲精品高清在线| 精品一区二区三区免费视频| eeuss影院一区二区三区| 欧美日韩一区二区在线视频| 精品国产乱码久久久久久影片| 亚洲精品视频在线看| 国产一区二区三区蝌蚪| 欧美色图免费看| 国产精品久久久久桃色tv| 日本美女一区二区| 色综合色狠狠综合色| 26uuu欧美日本| 性做久久久久久| www.日韩在线| 精品伦理精品一区| 亚洲午夜免费电影| 成人黄色免费短视频| 欧美一级欧美三级在线观看| 亚洲免费观看高清完整版在线| 精品制服美女久久| 欧美精品xxxxbbbb| 一区二区三区在线不卡| 丁香亚洲综合激情啪啪综合| 日韩一区二区电影| 亚洲国产综合91精品麻豆| aaa欧美色吧激情视频| 久久综合九色欧美综合狠狠| 视频在线观看一区| 国产精品福利影院| 成人天堂资源www在线| 亚洲欧美乱综合| 欧美一区二区三区婷婷月色 | 亚洲福利一二三区| 日韩一区二区三区四区五区六区| 日本不卡一区二区| 日本久久一区二区| 美女国产一区二区三区| 日韩免费电影网站| 成人黄色电影在线| 亚洲精品日日夜夜| 日韩欧美美女一区二区三区| 成人激情av网| 免费在线看成人av| 国产精品电影一区二区| 91麻豆文化传媒在线观看| 亚洲成人激情自拍| 日韩一区二区三区免费观看| 国产高清在线精品| 婷婷久久综合九色综合绿巨人| 欧美亚一区二区| 国产麻豆视频一区二区| 欧美极品少妇xxxxⅹ高跟鞋| 91高清视频在线| 成人精品视频一区| 国产一区二区三区高清播放| 国产三级久久久| 色综合久久中文字幕| 日韩电影在线看| 国产欧美在线观看一区| 成人免费视频caoporn| 一区二区三区四区五区视频在线观看| 色欧美片视频在线观看在线视频| 亚洲第一久久影院| 欧美日本一道本| 免费视频最近日韩| 国产亚洲一区二区三区| 911精品产国品一二三产区| 91视频观看视频| 人人狠狠综合久久亚洲| 夜夜嗨av一区二区三区中文字幕| 欧美变态凌虐bdsm| 精品国产一区二区三区不卡| 欧美精品一区二区三| 在线成人免费视频| 在线观看91av| 性久久久久久久久| 久久久三级国产网站| 亚洲欧美日韩在线| 国产真实乱偷精品视频免| 成人午夜免费电影| 91麻豆高清视频| 精品国产1区二区| 免费欧美在线视频| 久久一区二区视频| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 国产福利91精品| 日韩一区欧美一区| 欧美久久久久久蜜桃| 精品一区精品二区高清| 国产欧美一区视频| 欧美日韩一区久久| 国产成人精品影视| 亚洲国产日韩一区二区| 欧美精品一区二区三区很污很色的 | 久久久久青草大香线综合精品| 91在线免费播放| 水蜜桃久久夜色精品一区的特点| 久久亚洲欧美国产精品乐播 | 91在线一区二区三区| 日韩二区三区四区| 日本一区二区三区免费乱视频 | 国产在线国偷精品产拍免费yy | 亚洲摸摸操操av| 欧美tickling挠脚心丨vk| 99久久综合精品| 麻豆久久久久久| 亚洲天堂福利av| 国产偷国产偷亚洲高清人白洁 | 精品国产乱码久久久久久影片| 91女人视频在线观看| 激情综合色播激情啊| 一区二区成人在线| 中文字幕成人av| 欧美成人性战久久| 欧洲精品在线观看| 国产成人精品一区二区三区网站观看| 亚洲.国产.中文慕字在线|