12static int applycontrols(NCZ_FILE_INFO_T* zinfo);
 
   26ncz_create_dataset(NC_FILE_INFO_T* file, NC_GRP_INFO_T* root, NClist* controls)
 
   29    NCZ_FILE_INFO_T* zinfo = NULL;
 
   30    NCZ_GRP_INFO_T* zgrp = NULL;
 
   36    ZTRACE(3,
"file=%s root=%s controls=%s",file->hdr.name,root->hdr.name,(controls?nczprint_env(controls):
"null"));
 
   38    nc = (NC*)file->controller;
 
   41    if (!(zinfo = calloc(1, 
sizeof(NCZ_FILE_INFO_T))))
 
   43    file->format_file_info = zinfo;
 
   44    zinfo->common.file = file;
 
   47    if (!(zgrp = calloc(1, 
sizeof(NCZ_GRP_INFO_T))))
 
   49    root->format_grp_info = zgrp;
 
   50    zgrp->common.file = file;
 
   54    zinfo->common.file = file;
 
   56    if((zinfo->controllist=nclistclone(controls,1)) == NULL)
 
   60    zinfo->zarr.zarr_version = atoi(ZARRVERSION);
 
   61    sscanf(NCZARRVERSION,
"%lu.%lu.%lu",
 
   62       &zinfo->zarr.nczarr_version.major,
 
   63       &zinfo->zarr.nczarr_version.minor,
 
   64       &zinfo->zarr.nczarr_version.release);
 
   66    zinfo->default_maxstrlen = NCZ_MAXSTR_DEFAULT;
 
   69    if((stat = applycontrols(zinfo))) 
goto done;
 
   72    if((stat = ncuriparse(nc->path,&uri))) 
goto done;
 
   74    if((stat = NC_authsetup(&zinfo->auth, uri)))
 
   79    if((stat = nczmap_create(zinfo->controls.mapimpl,nc->path,nc->mode,zinfo->controls.flags,NULL,&zinfo->map)))
 
   86    return ZUNTRACE(stat);
 
   98ncz_open_dataset(NC_FILE_INFO_T* file, NClist* controls)
 
  102    NC_GRP_INFO_T* root = NULL;
 
  104    void* content = NULL;
 
  106    NCZ_FILE_INFO_T* zinfo = NULL;
 
  108    NClist* modeargs = NULL;
 
  109    char* nczarr_version = NULL;
 
  110    char* zarr_format = NULL;
 
  112    ZTRACE(3,
"file=%s controls=%s",file->hdr.name,(controls?nczprint_envv(controls):
"null"));
 
  115    nc = (NC*)file->controller;
 
  118    root = file->root_grp;
 
  119    assert(root != NULL && root->hdr.sort == NCGRP);
 
  122    if (!(file->format_file_info = calloc(1, 
sizeof(NCZ_FILE_INFO_T))))
 
  124    zinfo = file->format_file_info;
 
  128    zinfo->common.file = file;
 
  130    if((zinfo->controllist=nclistclone(controls,1)) == NULL)
 
  132    zinfo->default_maxstrlen = NCZ_MAXSTR_DEFAULT;
 
  135    if (!(root->format_grp_info = calloc(1, 
sizeof(NCZ_GRP_INFO_T))))
 
  137    ((NCZ_GRP_INFO_T*)root->format_grp_info)->common.file = file;
 
  140    if((stat = applycontrols(zinfo))) 
goto done;
 
  143    if((stat = nczmap_open(zinfo->controls.mapimpl,nc->path,mode,zinfo->controls.flags,NULL,&zinfo->map)))
 
  147    if((stat = ncz_read_superblock(file,&nczarr_version,&zarr_format))) 
goto done;
 
  149    if(nczarr_version == NULL) 
 
  150        nczarr_version = strdup(NCZARRVERSION);
 
  151    if(zarr_format == NULL) 
 
  152       zarr_format = strdup(ZARRVERSION);
 
  154    if(sscanf(zarr_format,
"%d",&zinfo->zarr.zarr_version)!=1)
 
  156    if(sscanf(nczarr_version,
"%lu.%lu.%lu",
 
  157            &zinfo->zarr.nczarr_version.major,
 
  158            &zinfo->zarr.nczarr_version.minor,
 
  159            &zinfo->zarr.nczarr_version.release) == 0)
 
  163    if((stat = ncuriparse(nc->path,&uri))) 
goto done;
 
  165    if((stat = NC_authsetup(&zinfo->auth, uri)))
 
  170    nullfree(zarr_format);
 
  171    nullfree(nczarr_version);
 
  173    nclistfreeall(modeargs);
 
  174    if(json) NCJreclaim(json);
 
  176    return ZUNTRACE(stat);
 
  190NCZ_isnetcdf4(
struct NC_FILE_INFO* h5)
 
  210NCZ_get_libversion(
unsigned long* majorp, 
unsigned long* minorp,
unsigned long* releasep)
 
  212    unsigned long m0,m1,m2;
 
  213    sscanf(NCZARRVERSION,
"%lu.%lu.%lu",&m0,&m1,&m2);
 
  214    if(majorp) *majorp = m0;
 
  215    if(minorp) *minorp = m1;
 
  216    if(releasep) *releasep = m2;
 
  232NCZ_get_superblock(NC_FILE_INFO_T* file, 
int* superblockp)
 
  234    NCZ_FILE_INFO_T* zinfo = file->format_file_info;
 
  235    if(superblockp) *superblockp = zinfo->zarr.nczarr_version.major;
 
  243controllookup(NClist* controls, 
const char* key)
 
  246    for(i=0;i<nclistlength(controls);i+=2) {
 
  247        const char* p = (
char*)nclistget(controls,i);
 
  248    if(strcasecmp(key,p)==0) {
 
  249        return (
const char*)nclistget(controls,i+1);
 
  257applycontrols(NCZ_FILE_INFO_T* zinfo)
 
  261    const char* value = NULL;
 
  262    NClist* modelist = nclistnew();
 
  263    size64_t noflags = 0; 
 
  265    if((value = controllookup(zinfo->controllist,
"mode")) != NULL) {
 
  266    if((stat = NCZ_comma_parse(value,modelist))) 
goto done;
 
  269    zinfo->controls.mapimpl = NCZM_DEFAULT;
 
  270    zinfo->controls.flags |= FLAG_XARRAYDIMS; 
 
  271    for(i=0;i<nclistlength(modelist);i++) {
 
  272        const char* p = nclistget(modelist,i);
 
  273    if(strcasecmp(p,PUREZARRCONTROL)==0)
 
  274        zinfo->controls.flags |= (FLAG_PUREZARR);
 
  275    else if(strcasecmp(p,XARRAYCONTROL)==0)
 
  276        zinfo->controls.flags |= FLAG_PUREZARR;
 
  277    else if(strcasecmp(p,NOXARRAYCONTROL)==0)
 
  278        noflags |= FLAG_XARRAYDIMS;
 
  279    else if(strcasecmp(p,
"zip")==0) zinfo->controls.mapimpl = NCZM_ZIP;
 
  280    else if(strcasecmp(p,
"file")==0) zinfo->controls.mapimpl = NCZM_FILE;
 
  281    else if(strcasecmp(p,
"s3")==0) zinfo->controls.mapimpl = NCZM_S3;
 
  285    zinfo->controls.flags &= (~noflags);
 
  288    if((value = controllookup(zinfo->controllist,
"log")) != NULL) {
 
  289    zinfo->controls.flags |= FLAG_LOGGING;
 
  290        ncsetloglevel(NCLOGNOTE);
 
  292    if((value = controllookup(zinfo->controllist,
"show")) != NULL) {
 
  293    if(strcasecmp(value,
"fetch")==0)
 
  294        zinfo->controls.flags |= FLAG_SHOWFETCH;
 
  297    nclistfreeall(modelist);
 
#define NC_ENDIAN_BIG
In HDF5 files you can set the endianness of variables with nc_def_var_endian().
#define NC_ENOMEM
Memory allocation (malloc) failure.
#define NC_ENCZARR
Error at NCZarr layer.
#define NC_ENDIAN_LITTLE
In HDF5 files you can set the endianness of variables with nc_def_var_endian().
#define NC_NOERR
No Error.