source: XIOS3/trunk/extern/src_netcdf4/ocbytes.h @ 2385

Last change on this file since 2385 was 409, checked in by ymipsl, 12 years ago

Add improved nectdf internal library src

YM

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
2   See the COPYRIGHT file for more information. */
3
4#ifndef OCBYTES_H
5#define OCBYTES_H 1
6
7typedef struct OCbytes {
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} OCbytes;
13
14#if defined(_CPLUSPLUS_) || defined(__CPLUSPLUS__) || defined(__CPLUSPLUS)
15#define EXTERNC extern "C"
16#else
17#define EXTERNC extern
18#endif
19
20EXTERNC OCbytes* ocbytesnew(void);
21EXTERNC void ocbytesfree(OCbytes*);
22EXTERNC int ocbytessetalloc(OCbytes*,unsigned int);
23EXTERNC int ocbytessetlength(OCbytes*,unsigned int);
24EXTERNC int ocbytesfill(OCbytes*, char fill);
25
26/* Produce a duplicate of the contents*/
27EXTERNC char* ocbytesdup(OCbytes*);
28/* Extract the contents and leave buffer empty */
29EXTERNC char* ocbytesextract(OCbytes*);
30
31/* Return the ith byte; -1 if no such index */
32EXTERNC int ocbytesget(OCbytes*,unsigned int);
33/* Set the ith byte */
34EXTERNC int ocbytesset(OCbytes*,unsigned int,char);
35
36/* Append one byte */
37EXTERNC int ocbytesappend(OCbytes*,char); /* Add at Tail */
38/* Append n bytes */
39EXTERNC int ocbytesappendn(OCbytes*,void*,unsigned int); /* Add at Tail */
40
41/* Concatenate a null-terminated string to the end of the buffer */
42EXTERNC int ocbytescat(OCbytes*,char*);
43/* Set the contents of the buffer; mark the buffer as non-extendible */
44EXTERNC int ocbytessetcontents(OCbytes*, char*, unsigned int);
45
46/* Following are always "in-lined"*/
47#define ocbyteslength(bb) ((bb)?(bb)->length:0U)
48#define ocbytesalloc(bb) ((bb)?(bb)->alloc:0U)
49#define ocbytescontents(bb) ((bb && bb->content)?(bb)->content:(char*)"")
50#define ocbytesextend(bb,len) ocbytessetalloc((bb),(len)+(bb->alloc))
51#define ocbytesclear(bb) ((bb)?(bb)->length=0:0U)
52#define ocbytesavail(bb,n) ((bb)?((bb)->alloc - (bb)->length) >= (n):0U)
53
54#endif /*OCBYTES_H*/
Note: See TracBrowser for help on using the repository browser.