4
/* $Id: ncbibuf.h,v 6.5 1999/08/17 22:30:22 vakatov Exp $
5
* ==========================================================================
8
* National Center for Biotechnology Information
10
* This software/database is a "United States Government Work" under the
11
* terms of the United States Copyright Act. It was written as part of
12
* the author's official duties as a United States Government employee and
13
* thus cannot be copyrighted. This software/database is freely available
14
* to the public for use. The National Library of Medicine and the U.S.
15
* Government have not placed any restriction on its use or reproduction.
17
* Although all reasonable efforts have been taken to ensure the accuracy
18
* and reliability of the software and data, the NLM and the U.S.
19
* Government do not and cannot warrant the performance or results that
20
* may be obtained by using this software or data. The NLM and the U.S.
21
* Government disclaim all warranties, express or implied, including
22
* warranties of performance, merchantability or fitness for any particular
25
* Please cite the author in any work or product based on this material.
27
* ==========================================================================
29
* Author: Denis Vakatov
32
* Memory-resident FIFO storage area (to be used e.g. in I/O buffering)
34
* This is just a back-compatibility interface("Nlm_*") to the real
35
* BUF API located in "ncbi_buffer.[ch]".
36
* Unlike the "real" BUF API, this API uses:
37
* a) "Nlm_" name prefix for structures, types and functions;
38
* b) "Nlm_*" fixed size integer types like "Nlm_Uint4";
39
* c) "Nlm_Boolean" rather than a native "int" for the boolean type;
40
* d) [MSWIN] "NLM_EXTERN" rather than just "extern" to ease the compilation
43
* --------------------------------------------------------------------------
45
* Revision 6.5 1999/08/17 22:30:22 vakatov
46
* Use "Nlm_BUF" to avoid name clash with "BUF" in "ncbi_buffer.h" when
47
* compiling with MipsPro IRIX compiler
49
* Revision 6.4 1999/08/17 19:47:25 vakatov
50
* Moved all real code from NCBIBUF to NCBI_BUFFER; the code has been cleaned
51
* from the NCBI C toolkit specific types and API calls.
52
* NCBIBUF module still exists for the backward compatibility -- it
53
* provides old NCBI-wise interface.
55
* ==========================================================================
64
#define NLM_EXTERN NLM_IMPORT
66
#define NLM_EXTERN extern
74
#define BUF_SetChunkSize Nlm_BUF_SetChunkSize
75
#define BUF_Size Nlm_BUF_Size
76
#define BUF_Write Nlm_BUF_Write
77
#define BUF_Peek Nlm_BUF_Peek
78
#define BUF_Read Nlm_BUF_Read
79
#define BUF_PushBack Nlm_BUF_PushBack
80
#define BUF_Destroy Nlm_BUF_Destroy
83
/* handle of a buffer (see "ncbi_buffer.[ch]") */
85
typedef struct BUF_tag* BUF;
88
/* Set minimal size of the buffer memory chunk.
89
* Return the actually set chunk size on success; zero on error
90
* NOTE: if "*pBuf" == NULL then create it
91
* if "chunk_size" is passed 0 then set it to BUF_DEF_CHUNK_SIZE
93
NLM_EXTERN Nlm_Uint4 BUF_SetChunkSize(BUF* pBuf, Nlm_Uint4 chunk_size);
96
/* Return the number of bytes stored in "buf".
97
* NOTE: return 0 if "buf" == NULL
99
NLM_EXTERN Nlm_Uint4 BUF_Size(BUF buf);
102
/* Add new data to the end of "*pBuf" (to be read last).
103
* NOTE: if "*pBuf" == NULL then create it
105
NLM_EXTERN Nlm_Boolean BUF_Write(BUF* pBuf, const void* data, Nlm_Uint4 size);
108
/* Write the data to the very beginning of "*pBuf" (to be read first).
109
* NOTE: if "*pBuf" == NULL then create it
111
NLM_EXTERN Nlm_Boolean BUF_PushBack(BUF* pBuf,
112
const void* data, Nlm_Uint4 size);
115
/* Copy up to "size" bytes stored in "buf" to "data".
116
* Return the # of copied bytes(can be less than "size").
117
* NOTE: "buf" and "data" can be NULL; in both cases, do nothing
120
NLM_EXTERN Nlm_Uint4 BUF_Peek(BUF buf, void* data, Nlm_Uint4 size);
123
/* Copy up to "size" bytes stored in "buf" to "data" and remove
124
* copied data from the "buf".
125
* Return the # of copied-and/or-removed bytes(can be less than "size")
126
* NOTE: if "buf" == NULL then do nothing and return 0
127
* if "data" == NULL then do not copy data anywhere(still, remove it)
129
NLM_EXTERN Nlm_Uint4 BUF_Read(BUF buf, void* data, Nlm_Uint4 size);
132
/* Destroy all internal data; return NULL
133
* NOTE: do nothing if "buf" == NULL
135
NLM_EXTERN BUF BUF_Destroy(BUF buf);
144
#define NLM_EXTERN NLM_EXPORT
149
#endif /* NCBIBUF__H */