~ubuntu-branches/ubuntu/edgy/ncbi-tools6/edgy

« back to all changes in this revision

Viewing changes to connect/ncbibuf.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2005-09-27 15:38:20 UTC
  • mfrom: (1.1.3 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050927153820-1t1sta0qirjpxaar
Tags: 6.1.20050429-1ubuntu1
GL/GLU Transition

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef NCBIBUF__H
2
 
#define NCBIBUF__H
3
 
 
4
 
/*  $Id: ncbibuf.h,v 6.5 1999/08/17 22:30:22 vakatov Exp $
5
 
 * ==========================================================================
6
 
 *
7
 
 *                            PUBLIC DOMAIN NOTICE
8
 
 *               National Center for Biotechnology Information
9
 
 *
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.
16
 
 *
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
23
 
 *  purpose.
24
 
 *
25
 
 *  Please cite the author in any work or product based on this material.
26
 
 *
27
 
 * ==========================================================================
28
 
 *
29
 
 * Author:  Denis Vakatov
30
 
 *
31
 
 * File Description:
32
 
 *   Memory-resident FIFO storage area (to be used e.g. in I/O buffering)
33
 
 *
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
41
 
 *       for MSWIN DLL.
42
 
 *
43
 
 * --------------------------------------------------------------------------
44
 
 * $Log: ncbibuf.h,v $
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
48
 
 *
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.
54
 
 *
55
 
 * ==========================================================================
56
 
 */
57
 
 
58
 
#include <ncbilcl.h>
59
 
#include <ncbistd.h>
60
 
 
61
 
 
62
 
#undef NLM_EXTERN
63
 
#ifdef NLM_IMPORT
64
 
#define NLM_EXTERN NLM_IMPORT
65
 
#else
66
 
#define NLM_EXTERN extern
67
 
#endif
68
 
 
69
 
#ifdef __cplusplus
70
 
extern "C" {
71
 
#endif
72
 
 
73
 
#define BUF               Nlm_BUF
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
81
 
 
82
 
 
83
 
/* handle of a buffer (see "ncbi_buffer.[ch]") */
84
 
struct BUF_tag;
85
 
typedef struct BUF_tag* BUF;
86
 
 
87
 
 
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
92
 
 */
93
 
NLM_EXTERN Nlm_Uint4 BUF_SetChunkSize(BUF* pBuf, Nlm_Uint4 chunk_size);
94
 
 
95
 
 
96
 
/* Return the number of bytes stored in "buf".
97
 
 * NOTE: return 0 if "buf" == NULL
98
 
 */
99
 
NLM_EXTERN Nlm_Uint4 BUF_Size(BUF buf);
100
 
 
101
 
 
102
 
/* Add new data to the end of "*pBuf" (to be read last).
103
 
 * NOTE:  if "*pBuf" == NULL then create it
104
 
 */
105
 
NLM_EXTERN Nlm_Boolean BUF_Write(BUF* pBuf, const void* data, Nlm_Uint4 size);
106
 
 
107
 
 
108
 
/* Write the data to the very beginning of "*pBuf" (to be read first).
109
 
 * NOTE:  if "*pBuf" == NULL then create it
110
 
 */
111
 
NLM_EXTERN Nlm_Boolean BUF_PushBack(BUF* pBuf,
112
 
                                    const void* data, Nlm_Uint4 size);
113
 
 
114
 
 
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
118
 
 *        and return 0.
119
 
 */
120
 
NLM_EXTERN Nlm_Uint4 BUF_Peek(BUF buf, void* data, Nlm_Uint4 size);
121
 
 
122
 
 
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)
128
 
 */
129
 
NLM_EXTERN Nlm_Uint4 BUF_Read(BUF buf, void* data, Nlm_Uint4 size);
130
 
 
131
 
 
132
 
/* Destroy all internal data;  return NULL
133
 
 * NOTE: do nothing if "buf" == NULL
134
 
 */
135
 
NLM_EXTERN BUF BUF_Destroy(BUF buf);
136
 
 
137
 
 
138
 
#ifdef __cplusplus
139
 
}
140
 
#endif
141
 
 
142
 
#undef NLM_EXTERN
143
 
#ifdef NLM_EXPORT
144
 
#define NLM_EXTERN NLM_EXPORT
145
 
#else
146
 
#define NLM_EXTERN
147
 
#endif
148
 
 
149
 
#endif /* NCBIBUF__H */