source: XIOS/dev/branch_openmp/extern/src_netcdf4/ncbytes.h @ 1501

Last change on this file since 1501 was 409, checked in by ymipsl, 11 years ago

Add improved nectdf internal library src

YM

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
2   See the COPYRIGHT file for more information. */
3
4#ifndef NCBYTES_H
5#define NCBYTES_H 1
6
7typedef struct NCbytes {
8  int nonextendible; /* 1 => fail if an attempt is made to extend this buffer*/
9  unsigned int alloc;
10  unsigned int length;
11  char* content;
12} NCbytes;
13
14#if defined(_CPLUSPLUS_) || defined(__CPLUSPLUS__) || defined(__CPLUSPLUS)
15#define EXTERNC extern "C"
16#else
17#define EXTERNC extern
18#endif
19
20EXTERNC NCbytes* ncbytesnew(void);
21EXTERNC void ncbytesfree(NCbytes*);
22EXTERNC int ncbytessetalloc(NCbytes*,unsigned int);
23EXTERNC int ncbytessetlength(NCbytes*,unsigned int);
24EXTERNC int ncbytesfill(NCbytes*, char fill);
25
26/* Produce a duplicate of the contents*/
27EXTERNC char* ncbytesdup(NCbytes*);
28/* Extract the contents and leave buffer empty */
29EXTERNC char* ncbytesextract(NCbytes*);
30
31/* Return the ith byte; -1 if no such index */
32EXTERNC int ncbytesget(NCbytes*,unsigned int);
33/* Set the ith byte */
34EXTERNC int ncbytesset(NCbytes*,unsigned int,char);
35
36/* Append one byte */
37EXTERNC int ncbytesappend(NCbytes*,char); /* Add at Tail */
38/* Append n bytes */
39EXTERNC int ncbytesappendn(NCbytes*,void*,unsigned int); /* Add at Tail */
40
41/* Null terminate the byte string without extending its length (for debugging) */
42EXTERNC int ncbytesnull(NCbytes*);
43
44/* Concatenate a null-terminated string to the end of the buffer */
45EXTERNC int ncbytescat(NCbytes*,char*);
46
47/* Set the contents of the buffer; mark the buffer as non-extendible */
48EXTERNC int ncbytessetcontents(NCbytes*, char*, unsigned int);
49
50/* Following are always "in-lined"*/
51#define ncbyteslength(bb) ((bb)?(bb)->length:0U)
52#define ncbytesalloc(bb) ((bb)?(bb)->alloc:0U)
53#define ncbytescontents(bb) ((bb && bb->content)?(bb)->content:(char*)"")
54#define ncbytesextend(bb,len) ncbytessetalloc((bb),(len)+(bb->alloc))
55#define ncbytesclear(bb) ((bb)?(bb)->length=0:0U)
56#define ncbytesavail(bb,n) ((bb)?((bb)->alloc - (bb)->length) >= (n):0U)
57
58#endif /*NCBYTES_H*/
Note: See TracBrowser for help on using the repository browser.