1 /*********************************************************************
2  *   Copyright 2018, UCAR/Unidata
3  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
4  *   $Id$
5  *   $Header$
6  *********************************************************************/
7 
8 /*
9  * In order to use any of the netcdf_XXX.h files, it is necessary
10  * to include netcdf.h followed by any netcdf_XXX.h files.
11  * Various things (like EXTERNL) are defined in netcdf.h
12  * to make them available for use by the netcdf_XXX.h files.
13 */
14 
15 #ifndef NCAUX_H
16 #define NCAUX_H
17 
18 #define NCAUX_ALIGN_C 0
19 #define NCAUX_ALIGN_UNIFORM 1
20 
21 #if defined(__cplusplus)
22 extern "C" {
23 #endif
24 
25 
26 /**
27 Reclaim the output tree of data from a call
28 to e.g. nc_get_vara or the input to e.g. nc_put_vara.
29 This recursively walks the top-level instances to
30 reclaim any nested data such as vlen or strings or such.
31 
32 Assumes it is passed a pointer to count instances of xtype.
33 Reclaims any nested data.
34 WARNING: does not reclaim the top-level memory because
35 we do not know how it was allocated.
36 Should work for any netcdf format.
37 */
38 
39 EXTERNL int ncaux_reclaim_data(int ncid, int xtype, void* memory, size_t count);
40 
41 
42 EXTERNL int ncaux_begin_compound(int ncid, const char *name, int alignmode, void** tag);
43 
44 EXTERNL int ncaux_end_compound(void* tag, nc_type* typeid);
45 
46 EXTERNL int ncaux_abort_compound(void* tag);
47 
48 EXTERNL int ncaux_add_field(void* tag,  const char *name, nc_type field_type,
49 			   int ndims, const int* dimsizes);
50 
51 /* Takes any type */
52 EXTERNL size_t ncaux_type_alignment(int xtype, int ncid);
53 
54 /* Takes type classes only */
55 EXTERNL size_t ncaux_class_alignment(int ncclass);
56 
57 /**************************************************/
58 /* Capture the id and parameters for a filter
59    using the HDF5 unsigned int format
60 */
61 typedef struct NC_H5_Filterspec {
62     unsigned int filterid; /**< ID for arbitrary filter. */
63     size_t nparams;        /**< nparams for arbitrary filter. */
64     unsigned int* params;  /**< Params for arbitrary filter. */
65 } NC_H5_Filterspec;
66 
67 EXTERNL int ncaux_h5filterspec_parse(const char* txt, unsigned int* idp, size_t* nparamsp, unsigned int** paramsp);
68 EXTERNL int ncaux_h5filterspec_parselist(const char* txt0, int* formatp, size_t* nspecsp, struct NC_H5_Filterspec*** vectorp);
69 EXTERNL void ncaux_h5filterspec_free(struct NC_H5_Filterspec* f);
70 EXTERNL void ncaux_h5filterspec_fix8(unsigned char* mem, int decode);
71 
72 /* Wrappers to export selected functions from libnetcdf */
73 
74 EXTERNL int ncaux_readfile(const char* filename, size_t* sizep, void** content);
75 EXTERNL int ncaux_writefile(const char* filename, size_t size, void* content);
76 
77 #if defined(__cplusplus)
78 }
79 #endif
80 
81 #endif /*NCAUX_H*/
82 
83