15#include "nc4internal.h"
16#include "nc4dispatch.h"
34 NC_GRP_INFO_T *grp, *g;
39 LOG((2,
"nc_inq_ncid: ncid 0x%x name %s", ncid, name));
49 NC_FILE_INFO_T* file = grp->nc4_info;
50 *grp_ncid = file->controller->ext_ncid | file->root_grp->hdr.id;
59 g = (NC_GRP_INFO_T*)ncindexlookup(grp->children,norm_name);
63 *grp_ncid = grp->nc4_info->controller->ext_ncid | g->hdr.id;
86 NC_GRP_INFO_T *grp, *g;
91 LOG((2,
"nc_inq_grps: ncid 0x%x", ncid));
99 for(
size_t i=0;i<ncindexsize(grp->children);i++)
101 g = (NC_GRP_INFO_T*)ncindexith(grp->children,i);
102 if(g == NULL)
continue;
108 *ncids = g->hdr.id | g->nc4_info->controller->ext_ncid;
138 LOG((2,
"nc_inq_grpname: ncid 0x%x", ncid));
147 strcpy(name, grp->hdr.name);
171 int g,
id = ncid, parent_id, *gid;
179 if (!(name = malloc((
size_t)(g + 1) * (
NC_MAX_NAME + 1) + 1)))
181 if (!(gid = malloc((
size_t)(g + 1) *
sizeof(
int))))
189 strcpy(name, NC_GROUP_NAME);
193 for (i = 1; i < g && !ret; i++)
197 for (i = g - 1; !ret && i >= 0 && !ret; i--)
201 strcat(name, grp_name);
208 *lenp = strlen(name);
211 if (!ret && full_name)
212 strcpy(full_name, name);
241 LOG((2,
"nc_inq_grp_parent: ncid 0x%x", ncid));
252 *parent_ncid = grp->nc4_info->controller->ext_ncid | grp->parent->hdr.id;
280 char *cp, *full_name_cpy;
293 if (!(full_name_cpy = strdup(full_name)))
297 if (!(cp = strtok(full_name_cpy,
"/")))
312 for (; cp; id1 = id2)
319 cp = strtok(NULL,
"/");
352 LOG((2,
"nc_inq_varids: ncid 0x%x", ncid));
361 for (
size_t i=0; i < ncindexsize(grp->vars); i++)
363 var = (NC_VAR_INFO_T*)ncindexith(grp->vars,i);
366 varids[num_vars] = var->hdr.id;
391 const int *ia = (
const int *)a;
392 const int *ib = (
const int *)b;
414 NC_GRP_INFO_T *grp, *g;
420 LOG((2,
"nc_inq_dimids: ncid 0x%x include_parents: %d", ncid,
429 num = ncindexcount(grp->dim);
430 if (include_parents) {
431 for (g = grp->parent; g; g = g->parent)
432 num += ncindexcount(g->dim);
441 for(
size_t i=0;i<ncindexsize(grp->dim);i++) {
442 dim = (NC_DIM_INFO_T*)ncindexith(grp->dim,i);
443 if(dim == NULL)
continue;
444 dimids[n++] = dim->hdr.id;
449 for (g = grp->parent; g; g = g->parent) {
450 for(
size_t i=0;i<ncindexsize(g->dim);i++) {
451 dim = (NC_DIM_INFO_T*)ncindexith(g->dim,i);
452 if(dim == NULL)
continue;
453 dimids[n++] = dim->hdr.id;
456 qsort(dimids, (
size_t)num,
sizeof(
int),
int_cmp);
int NC4_inq_grp_parent(int ncid, int *parent_ncid)
int NC4_inq_ncid(int ncid, const char *name, int *grp_ncid)
int int_cmp(const void *a, const void *b)
int NC4_inq_grpname(int ncid, char *name)
int NC4_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents)
int NC4_inq_grpname_full(int ncid, size_t *lenp, char *full_name)
int NC4_inq_grps(int ncid, int *numgrps, int *ncids)
int NC4_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid)
int NC4_inq_varids(int ncid, int *nvars, int *varids)
int nc4_check_name(const char *name, char *norm_name)
int nc4_find_grp_h5(int ncid, NC_GRP_INFO_T **grp, NC_FILE_INFO_T **h5)
#define NC_ENOGRP
No group found.
#define NC_ENOMEM
Memory allocation (malloc) failure.
#define NC_EINVAL
Invalid Argument.
#define NC_MAX_NAME
Maximum for classic library.
#define NC_NOERR
No Error.