Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed Nov 2, 2023
1 parent 6fa44d3 commit 102ba4a
Show file tree
Hide file tree
Showing 19 changed files with 581 additions and 295 deletions.
7 changes: 6 additions & 1 deletion include/ncjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ and do the command:

#define NCJ_NSORTS 8

/* Dump/text/unparse flags */
#define NCJFLAG_NONE 0
#define NCJFLAG_INDENTED 1


/* Define a struct to store primitive values as unquoted
strings. The sort will provide more info. Do not bother with
a union since the amount of saved space is minimal.
Expand Down Expand Up @@ -119,7 +124,7 @@ OPTEXPORT int NCJclone(const NCjson* json, NCjson** clonep);
/* dump NCjson* object to output file */
OPTEXPORT void NCJdump(const NCjson* json, unsigned flags, FILE*);
/* convert NCjson* object to output string */
OPTEXPORT const char* NCJtotext(const NCjson* json);
OPTEXPORT const char* NCJtotext(const NCjson* json, unsigned flags);
#endif

#if defined(__cplusplus)
Expand Down
27 changes: 22 additions & 5 deletions include/netcdf_filter_build.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/* Version of the NCZ_codec_t structure */
#define NCZ_CODEC_CLASS_VER 1

/* Version of the NCZ_codec_env_t structure */
#define NCZ_CODEC_ENV_VER 1

/* List of the kinds of NCZ_codec_t formats */
#define NCZ_CODEC_HDF5 1 /* HDF5 <-> Codec converter */

Expand Down Expand Up @@ -94,8 +97,9 @@ void (*NCZ_codec_finalize)(void);
* Convert a JSON representation to an HDF5 representation. Invoked when a NumCodec JSON Codec is extracted
from Zarr metadata.
int (*NCZ_codec_to_hdf5)(const char* codec, int* nparamsp, unsigned** paramsp);
int (*NCZ_codec_to_hdf5)(void* codec_env, const char* codec, int* nparamsp, unsigned** paramsp);
@param codec_env -- (in) extra environmental information
@param codec -- (in) ptr to JSON string representing the codec.
@param nparamsp -- (out) store the length of the converted HDF5 unsigned vector
@param paramsp -- (out) store a pointer to the converted HDF5 unsigned vector;
Expand All @@ -105,8 +109,9 @@ int (*NCZ_codec_to_hdf5)(const char* codec, int* nparamsp, unsigned** paramsp);
* Convert an HDF5 vector of visible parameters to a JSON representation.
int (*NCZ_hdf5_to_codec)(size_t nparams, const unsigned* params, char** codecp);
int (*NCZ_hdf5_to_codec)(void* codec_env, size_t nparams, const unsigned* params, char** codecp);
@param codec_env -- (in) extra environmental information
@param nparams -- (in) the length of the HDF5 unsigned vector
@param params -- (in) pointer to the HDF5 unsigned vector.
@param codecp -- (out) store the string representation of the codec; caller must free.
Expand All @@ -127,15 +132,27 @@ int (*NCZ_modify_parameters)(int ncid, int varid, size_t* vnparamsp, unsigned**
* Convert an HDF5 vector of visible parameters to a JSON representation.
int (*NCZ_hdf5_to_codec)(size_t nparams, const unsigned* params, char** codecp);
int (*NCZ_hdf5_to_codec)(void* codec_env, size_t nparams, const unsigned* params, char** codecp);
@param codec_env -- (in) extra environmental information
@param nparams -- (in) the length of the HDF5 unsigned vector
@param params -- (in) pointer to the HDF5 unsigned vector.
@param codecp -- (out) store the string representation of the codec; caller must free.
@return -- a netcdf-c error code.
*/

/*
The following struct is passed to all NCZ_codec_t functions
to provide extra environmental information.
*/
typedef struct NCZ_codec_env_t {
int codec_env_version;
int zarrformat;
} NCZ_codec_env_t;

#define NCZ_CODEC_ENV_EMPTY {NCZ_CODEC_ENV_VER, 0}

/*
The struct that provides the necessary filter info.
The combination of version + sort uniquely determines
Expand All @@ -149,8 +166,8 @@ typedef struct NCZ_codec_t {
unsigned int hdf5id; /* corresponding hdf5 id */
void (*NCZ_codec_initialize)(void);
void (*NCZ_codec_finalize)(void);
int (*NCZ_codec_to_hdf5)(const char* codec, size_t* nparamsp, unsigned** paramsp);
int (*NCZ_hdf5_to_codec)(size_t nparams, const unsigned* params, char** codecp);
int (*NCZ_codec_to_hdf5)(void* codec_env, const char* codec, size_t* nparamsp, unsigned** paramsp);
int (*NCZ_hdf5_to_codec)(void* codec_env, size_t nparams, const unsigned* params, char** codecp);
int (*NCZ_modify_parameters)(int ncid, int varid, size_t* vnparamsp, unsigned** vparamsp, size_t* wnparamsp, unsigned** wparamsp);
} NCZ_codec_t;

Expand Down
6 changes: 2 additions & 4 deletions libdispatch/ncjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,16 +1099,14 @@ bytesappendc(NCJbuf* bufp, const char c)
OPTSTATIC void
NCJdump(const NCjson* json, unsigned flags, FILE* out)
{
char* text = NULL;
(void)NCJunparse(json,0,&text);
const char* text = NCJtotext(json,flags);
if(out == NULL) out = stderr;
fprintf(out,"%s\n",text);
fflush(out);
nullfree(text);
}

OPTSTATIC const char*
NCJtotext(const NCjson* json)
NCJtotext(const NCjson* json, unsigned flags)
{
static char outtext[4096];
char* text = NULL;
Expand Down
Loading

0 comments on commit 102ba4a

Please sign in to comment.