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

📄 bsetbuf.cpp

📁 CBASE v1.01 采用Borland公司TC++编写的数据库管理源程序库
💻 CPP
字号:
/*	Copyright (c) 1989 Citadel	*/
/*	   All Rights Reserved    	*/

/* #ident	"@(#)bsetbuf.c	1.4 - 90/06/20" */

/* ansi headers */
#include <errno.h>
/*#include <stddef.h>*/

/* local headers */
#include "blkio_.h"

/*man---------------------------------------------------------------------------
NAME
     bsetbuf - assign buffering to a block file

SYNOPSIS
     #include <blkio.h>

     int bsetbuf(bp, buf)
     BLKFILE *bp;
     void *buf;

DESCRIPTION
     The bsetbuf function causes the storage area pointed to by buf to
     be used by the block file associated with BLKFILE pointer bp
     instead of an automatically allocated buffer area.  If buf is the
     NULL pointer, bp will be completely unbuffered.  Otherwise, it
     must point to a storage area of size no less than

          header size + block size * buffer count

     bsetbuf may be called at any time after opening the block file,
     before and after it is read or written; the buffers are flushed
     before installing the new buffer area.

     bsetbuf will fail if one or more of the following is true:

     [EINVAL]       bp is not a valid BLKFILE pointer.
     [BENBUF]       bp is unbuffered and buf is not the NULL
                    pointer.
     [BENOPEN]      bp is not open.

SEE ALSO
     bopen, bsetvbuf.

DIAGNOSTICS
     Upon successful completion, a value of 0 is returned.  Otherwise,
     a value of -1 is returned, and errno set to indicate the error.

NOTES
     A common source of error is allocating buffer space as an
     automatic variable in a code block, and then failing to close the
     block file in the same block.

------------------------------------------------------------------------------*/
int bsetbuf(BLKFILE *bp, void *buf)
{
	/* validate arguments */
	if (!b_valid(bp)) {
		errno = EINVAL;
		return -1;
	}
	if ((bp->bufcnt == 0) && (buf != NULL)) {
		errno = BENBUF;
		return -1;
	}

	if (buf == NULL) {
		return bsetvbuf(bp, buf, bp->blksize, (size_t)0);
	}

	return bsetvbuf(bp, buf, bp->blksize, bp->bufcnt);
}

⌨️ 快捷键说明

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