#include "nc.h"#include <stdlib.h>#include <stdio.h>#include <string.h>#include <assert.h>#include "rnd.h"#include "ncx.h"Include dependency graph for v1hpg.c:

Go to the source code of this file.
Classes | |
| struct | v1hs |
Defines | |
| #define | X_SIZEOF_NC_TYPE X_SIZEOF_INT |
| #define | X_SIZEOF_NCTYPE X_SIZEOF_INT |
| #define | MIN(mm, nn) (((mm) < (nn)) ? (mm) : (nn)) |
Typedefs | |
| typedef v1hs | v1hs |
Functions | |
| static int | rel_v1hs (v1hs *gsp) |
| static int | fault_v1hs (v1hs *gsp, size_t extent) |
| static int | check_v1hs (v1hs *gsp, size_t nextread) |
| static int | v1h_put_size_t (v1hs *psp, const size_t *sp) |
| static int | v1h_get_size_t (v1hs *gsp, size_t *sp) |
| static int | v1h_put_nc_type (v1hs *psp, const nc_type *typep) |
| static int | v1h_get_nc_type (v1hs *gsp, nc_type *typep) |
| static int | v1h_put_NCtype (v1hs *psp, NCtype type) |
| static int | v1h_get_NCtype (v1hs *gsp, NCtype *typep) |
| static size_t | ncx_len_NC_string (const NC_string *ncstrp) |
| static int | v1h_put_NC_string (v1hs *psp, const NC_string *ncstrp) |
| static int | v1h_get_NC_string (v1hs *gsp, NC_string **ncstrpp) |
| static size_t | ncx_len_NC_dim (const NC_dim *dimp) |
| static int | v1h_put_NC_dim (v1hs *psp, const NC_dim *dimp) |
| static int | v1h_get_NC_dim (v1hs *gsp, NC_dim **dimpp) |
| static size_t | ncx_len_NC_dimarray (const NC_dimarray *ncap) |
| static int | v1h_put_NC_dimarray (v1hs *psp, const NC_dimarray *ncap) |
| static int | v1h_get_NC_dimarray (v1hs *gsp, NC_dimarray *ncap) |
| static size_t | ncx_len_NC_attr (const NC_attr *attrp) |
| static int | v1h_put_NC_attrV (v1hs *psp, const NC_attr *attrp) |
| static int | v1h_put_NC_attr (v1hs *psp, const NC_attr *attrp) |
| static int | v1h_get_NC_attrV (v1hs *gsp, NC_attr *attrp) |
| static int | v1h_get_NC_attr (v1hs *gsp, NC_attr **attrpp) |
| static size_t | ncx_len_NC_attrarray (const NC_attrarray *ncap) |
| static int | v1h_put_NC_attrarray (v1hs *psp, const NC_attrarray *ncap) |
| static int | v1h_get_NC_attrarray (v1hs *gsp, NC_attrarray *ncap) |
| static size_t | ncx_len_NC_var (const NC_var *varp, size_t sizeof_off_t) |
| static int | v1h_put_NC_var (v1hs *psp, const NC_var *varp) |
| static int | v1h_get_NC_var (v1hs *gsp, NC_var **varpp) |
| static size_t | ncx_len_NC_vararray (const NC_vararray *ncap, size_t sizeof_off_t) |
| static int | v1h_put_NC_vararray (v1hs *psp, const NC_vararray *ncap) |
| static int | v1h_get_NC_vararray (v1hs *gsp, NC_vararray *ncap) |
| static int | NC_computeshapes (NC *ncp) |
| static off_t | NC_var_unpadded_len (const NC_var *varp, const NC_dimarray *dims) |
| size_t | ncx_len_NC (const NC *ncp, size_t sizeof_off_t) |
| int | ncx_put_NC (const NC *ncp, void **xpp, off_t offset, size_t extent) |
| int | nc_get_NC (NC *ncp) |
Variables | |
| static const schar | ncmagic [] = {'C', 'D', 'F', 0x02} |
| static const schar | ncmagic1 [] = {'C', 'D', 'F', 0x01} |
|
|
|
|
|
Definition at line 153 of file v1hpg.c. Referenced by ncx_len_NC_attr(), and ncx_len_NC_var(). |
|
|
Definition at line 196 of file v1hpg.c. Referenced by ncx_len_NC_attrarray(), ncx_len_NC_dimarray(), and ncx_len_NC_vararray(). |
|
|
|
|
||||||||||||
|
Definition at line 115 of file v1hpg.c. References v1hs::end, ENOERR, fault_v1hs(), and v1hs::pos. Referenced by v1h_get_NC_attrV(), v1h_get_NC_string(), v1h_get_nc_type(), v1h_get_NC_var(), v1h_get_NCtype(), v1h_get_size_t(), v1h_put_NC_attrV(), v1h_put_NC_string(), v1h_put_nc_type(), v1h_put_NC_var(), v1h_put_NCtype(), and v1h_put_size_t(). 00116 { 00117 00118 #if 0 /* DEBUG */ 00119 fprintf(stderr, "nextread %lu, remaining %lu\n", 00120 (unsigned long)nextread, 00121 (unsigned long)((char *)gsp->end - (char *)gsp->pos)); 00122 #endif 00123 00124 if((char *)gsp->pos + nextread <= (char *)gsp->end) 00125 return ENOERR; 00126 return fault_v1hs(gsp, nextread); 00127 }
|
|
||||||||||||
|
Definition at line 82 of file v1hpg.c. References v1hs::base, v1hs::end, ENOERR, v1hs::extent, v1hs::flags, ncio::get, v1hs::nciop, v1hs::offset, v1hs::pos, and rel_v1hs(). Referenced by check_v1hs(), nc_get_NC(), and ncx_put_NC(). 00083 { 00084 int status; 00085 00086 if(gsp->base != NULL) 00087 { 00088 const ptrdiff_t incr = (char *)gsp->pos - (char *)gsp->base; 00089 status = rel_v1hs(gsp); 00090 if(status) 00091 return status; 00092 gsp->offset += incr; 00093 } 00094 00095 if(extent > gsp->extent) 00096 gsp->extent = extent; 00097 00098 status = gsp->nciop->get(gsp->nciop, 00099 gsp->offset, gsp->extent, 00100 gsp->flags, &gsp->base); 00101 if(status) 00102 return status; 00103 00104 gsp->pos = gsp->base; 00105 gsp->end = (char *)gsp->base + gsp->extent; 00106 00107 return ENOERR; 00108 }
|
|
|
Definition at line 1074 of file v1hpg.c. References NC_var::begin, NC::begin_rec, NC::begin_var, NC::dims, NC_var::dsizes, ENOERR, IS_RECVAR, NC_var::len, NC_var_shape(), NC_vararray::nelems, NC::recsize, NC_vararray::value, NC::vars, NC_var::xsz, and NC::xsz. Referenced by nc_get_NC(). 01075 { 01076 NC_var **vpp = (NC_var **)ncp->vars.value; 01077 NC_var *const *const end = &vpp[ncp->vars.nelems]; 01078 NC_var *first_var = NULL; /* first "non-record" var */ 01079 NC_var *first_rec = NULL; /* first "record" var */ 01080 int status; 01081 01082 ncp->begin_var = (off_t) ncp->xsz; 01083 ncp->begin_rec = (off_t) ncp->xsz; 01084 ncp->recsize = 0; 01085 01086 if(ncp->vars.nelems == 0) 01087 return(0); 01088 01089 for( /*NADA*/; vpp < end; vpp++) 01090 { 01091 status = NC_var_shape(*vpp, &ncp->dims); 01092 if(status != ENOERR) 01093 return(status); 01094 01095 if(IS_RECVAR(*vpp)) 01096 { 01097 if(first_rec == NULL) 01098 first_rec = *vpp; 01099 ncp->recsize += (*vpp)->len; 01100 } 01101 else 01102 { 01103 if(first_var == NULL) 01104 first_var = *vpp; 01105 /* 01106 * Overwritten each time thru. 01107 * Usually overwritten in first_rec != NULL clause below. 01108 */ 01109 ncp->begin_rec = (*vpp)->begin + (off_t)(*vpp)->len; 01110 } 01111 } 01112 01113 if(first_rec != NULL) 01114 { 01115 assert(ncp->begin_rec <= first_rec->begin); 01116 ncp->begin_rec = first_rec->begin; 01117 /* 01118 * for special case of exactly one record variable, pack value 01119 */ 01120 if(ncp->recsize == first_rec->len) 01121 ncp->recsize = *first_rec->dsizes * first_rec->xsz; 01122 } 01123 01124 if(first_var != NULL) 01125 { 01126 ncp->begin_var = first_var->begin; 01127 } 01128 else 01129 { 01130 ncp->begin_var = ncp->begin_rec; 01131 } 01132 01133 assert(ncp->begin_var > 0); 01134 assert(ncp->xsz <= (size_t)ncp->begin_var); 01135 assert(ncp->begin_rec > 0); 01136 assert(ncp->begin_var <= ncp->begin_rec); 01137 01138 return(ENOERR); 01139 }
|
|
|
Definition at line 1272 of file v1hpg.c. References NC::attrs, v1hs::base, NC::chunk, NC::dims, v1hs::end, ENOERR, v1hs::extent, fault_v1hs(), NC::flags, v1hs::flags, fSet, MIN_NC_XSZ, NC_64BIT_OFFSET, NC_computeshapes(), NC_ENOTNC, NC_set_numrecs, ncio_filesize(), NC::nciop, v1hs::nciop, ncmagic, ncx_get_size_t(), ncx_getn_schar_schar(), ncx_len_NC(), v1hs::offset, v1hs::pos, rel_v1hs(), ncio::sync, v1h_get_NC_attrarray(), v1h_get_NC_dimarray(), v1h_get_NC_vararray(), NC::vars, v1hs::version, and NC::xsz. Referenced by nc__open_mp(), nc_delete_mp(), and read_NC(). 01273 { 01274 int status; 01275 v1hs gs; /* the get stream */ 01276 01277 assert(ncp != NULL); 01278 01279 /* Initialize stream gs */ 01280 01281 gs.nciop = ncp->nciop; 01282 gs.offset = 0; /* beginning of file */ 01283 gs.extent = 0; 01284 gs.flags = 0; 01285 gs.version = 0; 01286 gs.base = NULL; 01287 gs.pos = gs.base; 01288 01289 { 01290 /* 01291 * Come up with a reasonable stream read size. 01292 */ 01293 off_t filesize; 01294 size_t extent = MIN_NC_XSZ; 01295 01296 extent = ncp->xsz; 01297 if(extent <= MIN_NC_XSZ) 01298 { 01299 status = ncio_filesize(ncp->nciop, &filesize); 01300 if(status) 01301 return status; 01302 /* first time read */ 01303 extent = ncp->chunk; 01304 /* Protection for when ncp->chunk is huge; 01305 * no need to read hugely. */ 01306 if(extent > 4096) 01307 extent = 4096; 01308 if(extent > filesize) 01309 extent = filesize; 01310 } 01311 else if(extent > ncp->chunk) 01312 { 01313 extent = ncp->chunk; 01314 } 01315 01316 /* 01317 * Invalidate the I/O buffers to force a read of the header 01318 * region. 01319 */ 01320 status = gs.nciop->sync(gs.nciop); 01321 if(status) 01322 return status; 01323 01324 status = fault_v1hs(&gs, extent); 01325 if(status) 01326 return status; 01327 } 01328 01329 /* get the header from the stream gs */ 01330 01331 { 01332 /* Get & check magic number */ 01333 schar magic[sizeof(ncmagic)]; 01334 (void) memset(magic, 0, sizeof(magic)); 01335 01336 status = ncx_getn_schar_schar( 01337 (const void **)(&gs.pos), sizeof(magic), magic); 01338 if(status != ENOERR) 01339 goto unwind_get; 01340 01341 if(memcmp(magic, ncmagic, sizeof(ncmagic)-1) != 0) 01342 { 01343 status = NC_ENOTNC; 01344 goto unwind_get; 01345 } 01346 /* Check version number in last byte of magic */ 01347 if (magic[sizeof(ncmagic)-1] == 0x1) { 01348 gs.version = 1; 01349 } else if (magic[sizeof(ncmagic)-1] == 0x2) { 01350 gs.version = 2; 01351 fSet(ncp->flags, NC_64BIT_OFFSET); 01352 /* Now we support version 2 file access on non-LFS systems -- rkr */ 01353 #if 0 01354 if (sizeof(off_t) != 8) { 01355 fprintf(stderr, "NETCDF WARNING: Version 2 file on 32-bit system.\n"); 01356 } 01357 #endif 01358 } else { 01359 status = NC_ENOTNC; 01360 goto unwind_get; 01361 } 01362 } 01363 01364 { 01365 size_t nrecs = 0; 01366 status = ncx_get_size_t((const void **)(&gs.pos), &nrecs); 01367 if(status != ENOERR) 01368 goto unwind_get; 01369 NC_set_numrecs(ncp, nrecs); 01370 } 01371 01372 assert((char *)gs.pos < (char *)gs.end); 01373 01374 status = v1h_get_NC_dimarray(&gs, &ncp->dims); 01375 if(status != ENOERR) 01376 goto unwind_get; 01377 01378 status = v1h_get_NC_attrarray(&gs, &ncp->attrs); 01379 if(status != ENOERR) 01380 goto unwind_get; 01381 01382 status = v1h_get_NC_vararray(&gs, &ncp->vars); 01383 if(status != ENOERR) 01384 goto unwind_get; 01385 01386 ncp->xsz = ncx_len_NC(ncp, (gs.version == 1) ? 4 : 8); 01387 01388 status = NC_computeshapes(ncp); 01389 if(status != ENOERR) 01390 goto unwind_get; 01391 01392 unwind_get: 01393 (void) rel_v1hs(&gs); 01394 return status; 01395 }
|
|
||||||||||||
|
Definition at line 1149 of file v1hpg.c. References IS_RECVAR, NC_var::ndims, product(), NC_var::shape, and NC_var::xsz. 01150 { 01151 size_t *shp; 01152 off_t product = 1; 01153 01154 if(varp->ndims != 0) { 01155 for(shp = varp->shape + varp->ndims -1; shp >= varp->shape; shp--) { 01156 if(!(shp == varp->shape && IS_RECVAR(varp))) 01157 product *= *shp; 01158 } 01159 } 01160 product = product * varp->xsz; 01161 return product; 01162 }
|
|
||||||||||||
|
Definition at line 1165 of file v1hpg.c. References NC::attrs, NC::dims, ncmagic, ncx_len_NC_attrarray(), ncx_len_NC_dimarray(), ncx_len_NC_vararray(), NC::vars, and X_SIZEOF_SIZE_T. Referenced by nc__create_mp(), NC_begins(), nc_get_NC(), and new_NC(). 01166 { 01167 size_t xlen = sizeof(ncmagic); 01168 01169 assert(ncp != NULL); 01170 01171 xlen += X_SIZEOF_SIZE_T; /* numrecs */ 01172 xlen += ncx_len_NC_dimarray(&ncp->dims); 01173 xlen += ncx_len_NC_attrarray(&ncp->attrs); 01174 xlen += ncx_len_NC_vararray(&ncp->vars, sizeof_off_t); 01175 01176 return xlen; 01177 }
|
|
|
Definition at line 526 of file v1hpg.c. References NC_attr::name, ncx_len_NC_string(), X_SIZEOF_NC_TYPE, X_SIZEOF_SIZE_T, and NC_attr::xsz. Referenced by ncx_len_NC_attrarray(). 00527 { 00528 size_t sz; 00529 00530 assert(attrp != NULL); 00531 00532 sz = ncx_len_NC_string(attrp->name); 00533 sz += X_SIZEOF_NC_TYPE; /* type */ 00534 sz += X_SIZEOF_SIZE_T; /* nelems */ 00535 sz += attrp->xsz; 00536 00537 return(sz); 00538 }
|
|
|
Definition at line 684 of file v1hpg.c. References ncx_len_NC_attr(), NC_attrarray::nelems, NC_attrarray::value, X_SIZEOF_NCTYPE, and X_SIZEOF_SIZE_T. Referenced by ncx_len_NC(), and ncx_len_NC_var(). 00685 { 00686 size_t xlen = X_SIZEOF_NCTYPE; /* type */ 00687 xlen += X_SIZEOF_SIZE_T; /* count */ 00688 if(ncap == NULL) 00689 return xlen; 00690 /* else */ 00691 { 00692 const NC_attr **app = (const NC_attr **)ncap->value; 00693 const NC_attr *const *const end = &app[ncap->nelems]; 00694 for( /*NADA*/; app < end; app++) 00695 { 00696 xlen += ncx_len_NC_attr(*app); 00697 } 00698 } 00699 return xlen; 00700 }
|
|
|
Definition at line 330 of file v1hpg.c. References NC_dim::name, ncx_len_NC_string(), and X_SIZEOF_SIZE_T. Referenced by ncx_len_NC_dimarray(). 00331 { 00332 size_t sz; 00333 00334 assert(dimp != NULL); 00335 00336 sz = ncx_len_NC_string(dimp->name); 00337 sz += X_SIZEOF_SIZE_T; 00338 00339 return(sz); 00340 }
|
|
|
Definition at line 395 of file v1hpg.c. References ncx_len_NC_dim(), NC_dimarray::nelems, NC_dimarray::value, X_SIZEOF_NCTYPE, and X_SIZEOF_SIZE_T. Referenced by ncx_len_NC(). 00396 { 00397 size_t xlen = X_SIZEOF_NCTYPE; /* type */ 00398 xlen += X_SIZEOF_SIZE_T; /* count */ 00399 if(ncap == NULL) 00400 return xlen; 00401 /* else */ 00402 { 00403 const NC_dim **dpp = (const NC_dim **)ncap->value; 00404 const NC_dim *const *const end = &dpp[ncap->nelems]; 00405 for( /*NADA*/; dpp < end; dpp++) 00406 { 00407 xlen += ncx_len_NC_dim(*dpp); 00408 } 00409 } 00410 return xlen; 00411 }
|
|
|
Definition at line 235 of file v1hpg.c. References _RNDUP, NC_string::nchars, X_ALIGN, and X_SIZEOF_SIZE_T. Referenced by ncx_len_NC_attr(), ncx_len_NC_dim(), and ncx_len_NC_var(). 00236 { 00237 size_t sz = X_SIZEOF_SIZE_T; /* nchars */ 00238 00239 assert(ncstrp != NULL); 00240 00241 if(ncstrp->nchars != 0) 00242 { 00243 #if 0 00244 assert(ncstrp->nchars % X_ALIGN == 0); 00245 sz += ncstrp->nchars; 00246 #else 00247 sz += _RNDUP(ncstrp->nchars, X_ALIGN); 00248 #endif 00249 } 00250 return sz; 00251 }
|
|
||||||||||||
|
Definition at line 812 of file v1hpg.c. References NC_var::attrs, NC_var::name, ncx_len_int, ncx_len_NC_attrarray(), ncx_len_NC_string(), NC_var::ndims, X_SIZEOF_NC_TYPE, and X_SIZEOF_SIZE_T. Referenced by ncx_len_NC_vararray(). 00813 { 00814 size_t sz; 00815 00816 assert(varp != NULL); 00817 assert(sizeof_off_t != 0); 00818 00819 sz = ncx_len_NC_string(varp->name); 00820 sz += X_SIZEOF_SIZE_T; /* ndims */ 00821 sz += ncx_len_int(varp->ndims); /* dimids */ 00822 sz += ncx_len_NC_attrarray(&varp->attrs); 00823 sz += X_SIZEOF_NC_TYPE; /* type */ 00824 sz += X_SIZEOF_SIZE_T; /* len */ 00825 sz += sizeof_off_t; /* begin */ 00826 00827 return(sz); 00828 }
|
|
||||||||||||
|
Definition at line 940 of file v1hpg.c. References ncx_len_NC_var(), NC_vararray::nelems, NC_vararray::value, X_SIZEOF_NCTYPE, and X_SIZEOF_SIZE_T. Referenced by ncx_len_NC(). 00941 { 00942 size_t xlen = X_SIZEOF_NCTYPE; /* type */ 00943 xlen += X_SIZEOF_SIZE_T; /* count */ 00944 if(ncap == NULL) 00945 return xlen; 00946 /* else */ 00947 { 00948 const NC_var **vpp = (const NC_var **)ncap->value; 00949 const NC_var *const *const end = &vpp[ncap->nelems]; 00950 for( /*NADA*/; vpp < end; vpp++) 00951 { 00952 xlen += ncx_len_NC_var(*vpp, sizeof_off_t); 00953 } 00954 } 00955 return xlen; 00956 }
|
|
||||||||||||||||||||
|
Definition at line 1181 of file v1hpg.c. References NC::attrs, v1hs::base, NC::chunk, NC::dims, v1hs::end, ENOERR, v1hs::extent, fault_v1hs(), NC::flags, v1hs::flags, MIN_NC_XSZ, NC_64BIT_OFFSET, NC_get_numrecs, NC::nciop, v1hs::nciop, ncmagic, ncmagic1, ncx_put_size_t(), ncx_putn_schar_schar(), v1hs::offset, v1hs::pos, rel_v1hs(), RGN_WRITE, v1h_put_NC_attrarray(), v1h_put_NC_dimarray(), v1h_put_NC_vararray(), NC::vars, v1hs::version, and NC::xsz. Referenced by nc__create_mp(), and write_NC(). 01182 { 01183 int status = ENOERR; 01184 v1hs ps; /* the get stream */ 01185 01186 assert(ncp != NULL); 01187 01188 /* Initialize stream ps */ 01189 01190 ps.nciop = ncp->nciop; 01191 ps.flags = RGN_WRITE; 01192 01193 if (ncp->flags & NC_64BIT_OFFSET) 01194 ps.version = 2; 01195 else 01196 ps.version = 1; 01197 01198 if(xpp == NULL) 01199 { 01200 /* 01201 * Come up with a reasonable stream read size. 01202 */ 01203 extent = ncp->xsz; 01204 if(extent <= MIN_NC_XSZ) 01205 { 01206 /* first time read */ 01207 extent = ncp->chunk; 01208 /* Protection for when ncp->chunk is huge; 01209 * no need to read hugely. */ 01210 if(extent > 4096) 01211 extent = 4096; 01212 } 01213 else if(extent > ncp->chunk) 01214 { 01215 extent = ncp->chunk; 01216 } 01217 01218 ps.offset = 0; 01219 ps.extent = extent; 01220 ps.base = NULL; 01221 ps.pos = ps.base; 01222 01223 status = fault_v1hs(&ps, extent); 01224 if(status) 01225 return status; 01226 } 01227 else 01228 { 01229 ps.offset = offset; 01230 ps.extent = extent; 01231 ps.base = *xpp; 01232 ps.pos = ps.base; 01233 ps.end = (char *)ps.base + ps.extent; 01234 } 01235 01236 if (ps.version == 2) 01237 status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic), ncmagic); 01238 else 01239 status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic1), ncmagic1); 01240 if(status != ENOERR) 01241 goto release; 01242 01243 { 01244 const size_t nrecs = NC_get_numrecs(ncp); 01245 status = ncx_put_size_t(&ps.pos, &nrecs); 01246 if(status != ENOERR) 01247 goto release; 01248 } 01249 01250 assert((char *)ps.pos < (char *)ps.end); 01251 01252 status = v1h_put_NC_dimarray(&ps, &ncp->dims); 01253 if(status != ENOERR) 01254 goto release; 01255 01256 status = v1h_put_NC_attrarray(&ps, &ncp->attrs); 01257 if(status != ENOERR) 01258 goto release; 01259 01260 status = v1h_put_NC_vararray(&ps, &ncp->vars); 01261 if(status != ENOERR) 01262 goto release; 01263 01264 release: 01265 (void) rel_v1hs(&ps); 01266 01267 return status; 01268 }
|
|
|
Definition at line 63 of file v1hpg.c. References v1hs::base, v1hs::end, ENOERR, v1hs::flags, v1hs::nciop, OFF_NONE, v1hs::offset, v1hs::pos, ncio::rel, RGN_MODIFIED, and RGN_WRITE. Referenced by fault_v1hs(), nc_get_NC(), and ncx_put_NC(). 00064 { 00065 int status; 00066 if(gsp->offset == OFF_NONE || gsp->base == NULL) 00067 return ENOERR; 00068 status = gsp->nciop->rel(gsp->nciop, gsp->offset, 00069 gsp->flags == RGN_WRITE ? RGN_MODIFIED : 0); 00070 gsp->end = NULL; 00071 gsp->pos = NULL; 00072 gsp->base = NULL; 00073 return status; 00074 }
|
|
||||||||||||
|
Definition at line 639 of file v1hpg.c. References ENOERR, free_NC_attr(), free_NC_string(), NC_ENOMEM, new_x_NC_attr(), type, v1h_get_NC_attrV(), v1h_get_NC_string(), v1h_get_nc_type(), and v1h_get_size_t(). Referenced by v1h_get_NC_attrarray(). 00640 { 00641 NC_string *strp; 00642 int status; 00643 nc_type type; 00644 size_t nelems; 00645 NC_attr *attrp; 00646 00647 status = v1h_get_NC_string(gsp, &strp); 00648 if(status != ENOERR) 00649 return status; 00650 00651 status = v1h_get_nc_type(gsp, &type); 00652 if(status != ENOERR) 00653 goto unwind_name; 00654 00655 status = v1h_get_size_t(gsp, &nelems); 00656 if(status != ENOERR) 00657 goto unwind_name; 00658 00659 attrp = new_x_NC_attr(strp, type, nelems); 00660 if(attrp == NULL) 00661 { 00662 status = NC_ENOMEM; 00663 goto unwind_name; 00664 } 00665 00666 status = v1h_get_NC_attrV(gsp, attrp); 00667 if(status != ENOERR) 00668 { 00669 free_NC_attr(attrp); /* frees strp */ 00670 return status; 00671 } 00672 00673 *attrpp = attrp; 00674 00675 return ENOERR; 00676 00677 unwind_name: 00678 free_NC_string(strp); 00679 return status; 00680 }
|
|
||||||||||||
|
Definition at line 758 of file v1hpg.c. References ENOERR, free_NC_attrarrayV(), NC_attrarray::nalloc, NC_ATTRIBUTE, NC_ENOMEM, NC_UNSPECIFIED, NC_attrarray::nelems, v1hs::pos, type, v1h_get_NC_attr(), v1h_get_NCtype(), v1h_get_size_t(), and NC_attrarray::value. Referenced by nc_get_NC(), and v1h_get_NC_var(). 00759 { 00760 int status; 00761 NCtype type = NC_UNSPECIFIED; 00762 00763 assert(gsp != NULL && gsp->pos != NULL); 00764 assert(ncap != NULL); 00765 assert(ncap->value == NULL); 00766 00767 status = v1h_get_NCtype(gsp, &type); 00768 if(status != ENOERR) 00769 return status; 00770 status = v1h_get_size_t(gsp, &ncap->nelems); 00771 if(status != ENOERR) 00772 return status; 00773 00774 if(ncap->nelems == 0) 00775 return ENOERR; 00776 /* else */ 00777 if(type != NC_ATTRIBUTE) 00778 return EINVAL; 00779 00780 ncap->value = (NC_attr **) malloc(ncap->nelems * sizeof(NC_attr *)); 00781 if(ncap->value == NULL) 00782 return NC_ENOMEM; 00783 ncap->nalloc = ncap->nelems; 00784 00785 { 00786 NC_attr **app = ncap->value; 00787 NC_attr *const *const end = &app[ncap->nelems]; 00788 for( /*NADA*/; app < end; app++) 00789 { 00790 status = v1h_get_NC_attr(gsp, app); 00791 if(status) 00792 { 00793 ncap->nelems = (size_t)(app - ncap->value); 00794 free_NC_attrarrayV(ncap); 00795 return status; 00796 } 00797 } 00798 } 00799 00800 return ENOERR; 00801 }
|
|
||||||||||||
|
Definition at line 609 of file v1hpg.c. References check_v1hs(), ENOERR, v1hs::extent, MIN, v1hs::pos, X_ALIGN, NC_attr::xsz, and NC_attr::xvalue. Referenced by v1h_get_NC_attr(). 00610 { 00611 int status; 00612 const size_t perchunk = gsp->extent; 00613 size_t remaining = attrp->xsz; 00614 void *value = attrp->xvalue; 00615 size_t nget; 00616 00617 assert(gsp->extent % X_ALIGN == 0); 00618 00619 do { 00620 nget = MIN(perchunk, remaining); 00621 00622 status = check_v1hs(gsp, nget); 00623 if(status != ENOERR) 00624 return status; 00625 00626 (void) memcpy(value, gsp->pos, nget); 00627 00628 gsp->pos = (void *)((char *)gsp->pos + nget); 00629 value = (void *)((char *)value + nget); 00630 remaining -= nget; 00631 00632 } while(remaining != 0); 00633 00634 return ENOERR; 00635 }
|
|
||||||||||||
|
Definition at line 360 of file v1hpg.c. References ENOERR, free_NC_dim(), free_NC_string(), NC_ENOMEM, new_x_NC_dim(), NC_dim::size, v1h_get_NC_string(), and v1h_get_size_t(). Referenced by v1h_get_NC_dimarray(). 00361 { 00362 int status; 00363 NC_string *ncstrp; 00364 NC_dim *dimp; 00365 00366 status = v1h_get_NC_string(gsp, &ncstrp); 00367 if(status != ENOERR) 00368 return status; 00369 00370 dimp = new_x_NC_dim(ncstrp); 00371 if(dimp == NULL) 00372 { 00373 status = NC_ENOMEM; 00374 goto unwind_name; 00375 } 00376 00377 status = v1h_get_size_t(gsp, &dimp->size); 00378 if(status != ENOERR) 00379 { 00380 free_NC_dim(dimp); /* frees name */ 00381 return status; 00382 } 00383 00384 *dimpp = dimp; 00385 00386 return ENOERR; 00387 00388 unwind_name: 00389 free_NC_string(ncstrp); 00390 return status; 00391 }
|
|
||||||||||||
|
Definition at line 469 of file v1hpg.c. References ENOERR, free_NC_dimarrayV(), NC_dimarray::nalloc, NC_DIMENSION, NC_ENOMEM, NC_UNSPECIFIED, NC_dimarray::nelems, v1hs::pos, type, v1h_get_NC_dim(), v1h_get_NCtype(), v1h_get_size_t(), and NC_dimarray::value. Referenced by nc_get_NC(). 00470 { 00471 int status; 00472 NCtype type = NC_UNSPECIFIED; 00473 00474 assert(gsp != NULL && gsp->pos != NULL); 00475 assert(ncap != NULL); 00476 assert(ncap->value == NULL); 00477 00478 status = v1h_get_NCtype(gsp, &type); 00479 if(status != ENOERR) 00480 return status; 00481 00482 status = v1h_get_size_t(gsp, &ncap->nelems); 00483 if(status != ENOERR) 00484 return status; 00485 00486 if(ncap->nelems == 0) 00487 return ENOERR; 00488 /* else */ 00489 if(type != NC_DIMENSION) 00490 return EINVAL; 00491 00492 ncap->value = (NC_dim **) malloc(ncap->nelems * sizeof(NC_dim *)); 00493 if(ncap->value == NULL) 00494 return NC_ENOMEM; 00495 ncap->nalloc = ncap->nelems; 00496 00497 { 00498 NC_dim **dpp = ncap->value; 00499 NC_dim *const *const end = &dpp[ncap->nelems]; 00500 for( /*NADA*/; dpp < end; dpp++) 00501 { 00502 status = v1h_get_NC_dim(gsp, dpp); 00503 if(status) 00504 { 00505 ncap->nelems = (size_t)(dpp - ncap->value); 00506 free_NC_dimarrayV(ncap); 00507 return status; 00508 } 00509 } 00510 } 00511 00512 return ENOERR; 00513 }
|
|
||||||||||||
|
Definition at line 278 of file v1hpg.c. References _RNDUP, check_v1hs(), NC_string::cp, ENOERR, free_NC_string(), NC_ENOMEM, NC_string::nchars, ncx_pad_getn_text(), new_NC_string(), v1hs::pos, v1h_get_size_t(), and X_ALIGN. Referenced by v1h_get_NC_attr(), v1h_get_NC_dim(), and v1h_get_NC_var(). 00279 { 00280 int status; 00281 size_t nchars = 0; 00282 NC_string *ncstrp; 00283 00284 status = v1h_get_size_t(gsp, &nchars); 00285 if(status != ENOERR) 00286 return status; 00287 00288 ncstrp = new_NC_string(nchars, NULL); 00289 if(ncstrp == NULL) 00290 { 00291 return NC_ENOMEM; 00292 } 00293 00294 00295 #if 0 00296 /* assert(ncstrp->nchars == nchars || ncstrp->nchars - nchars < X_ALIGN); */ 00297 assert(ncstrp->nchars % X_ALIGN == 0); 00298 status = check_v1hs(gsp, ncstrp->nchars); 00299 #else 00300 00301 status = check_v1hs(gsp, _RNDUP(ncstrp->nchars, X_ALIGN)); 00302 #endif 00303 if(status != ENOERR) 00304 goto unwind_alloc; 00305 00306 status = ncx_pad_getn_text((const void **)(&gsp->pos), 00307 nchars, ncstrp->cp); 00308 if(status != ENOERR) 00309 goto unwind_alloc; 00310 00311 *ncstrpp = ncstrp; 00312 00313 return ENOERR; 00314 00315 unwind_alloc: 00316 free_NC_string(ncstrp); 00317 return status; 00318 00319 }
|
|
||||||||||||
|
Definition at line 169 of file v1hpg.c. References check_v1hs(), ENOERR, NC_BYTE, NC_CHAR, NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT, ncx_get_int_int(), v1hs::pos, type, and X_SIZEOF_INT. Referenced by v1h_get_NC_attr(), and v1h_get_NC_var(). 00170 { 00171 int type = 0; 00172 int status = check_v1hs(gsp, X_SIZEOF_INT); 00173 if(status != ENOERR) 00174 return status; 00175 status = ncx_get_int_int(gsp->pos, &type); 00176 gsp->pos = (void *)((char *)gsp->pos + X_SIZEOF_INT); 00177 if(status != ENOERR) 00178 return status; 00179 00180 assert(type == NC_BYTE 00181 || type == NC_CHAR 00182 || type == NC_SHORT 00183 || type == NC_INT 00184 || type == NC_FLOAT 00185 || type == NC_DOUBLE); 00186 00187 /* else */ 00188 *typep = (nc_type) type; 00189 00190 return ENOERR; 00191 }
|
|
||||||||||||
|
Definition at line 876 of file v1hpg.c. References NC_var::attrs, NC_var::begin, check_v1hs(), NC_var::dimids, ENOERR, free_NC_string(), free_NC_var(), NC_var::len, NC_ENOMEM, ncx_get_off_t(), ncx_getn_int_int(), ncx_len_int, ndims, new_x_NC_var(), v1hs::pos, NC_var::type, v1h_get_NC_attrarray(), v1h_get_NC_string(), v1h_get_nc_type(), v1h_get_size_t(), and v1hs::version. Referenced by v1h_get_NC_vararray(). 00877 { 00878 NC_string *strp; 00879 int status; 00880 size_t ndims; 00881 NC_var *varp; 00882 00883 status = v1h_get_NC_string(gsp, &strp); 00884 if(status != ENOERR) 00885 return status; 00886 00887 status = v1h_get_size_t(gsp, &ndims); 00888 if(status != ENOERR) 00889 goto unwind_name; 00890 00891 varp = new_x_NC_var(strp, ndims); 00892 if(varp == NULL) 00893 { 00894 status = NC_ENOMEM; 00895 goto unwind_name; 00896 } 00897 00898 status = check_v1hs(gsp, ncx_len_int(ndims)); 00899 if(status != ENOERR) 00900 goto unwind_alloc; 00901 status = ncx_getn_int_int((const void **)(&gsp->pos), 00902 ndims, varp->dimids); 00903 if(status != ENOERR) 00904 goto unwind_alloc; 00905 00906 status = v1h_get_NC_attrarray(gsp, &varp->attrs); 00907 if(status != ENOERR) 00908 goto unwind_alloc; 00909 00910 status = v1h_get_nc_type(gsp, &varp->type); 00911 if(status != ENOERR) 00912 goto unwind_alloc; 00913 00914 status = v1h_get_size_t(gsp, &varp->len); 00915 if(status != ENOERR) 00916 goto unwind_alloc; 00917 00918 status = check_v1hs(gsp, gsp->version == 1 ? 4 : 8); 00919 if(status != ENOERR) 00920 goto unwind_alloc; 00921 status = ncx_get_off_t((const void **)&gsp->pos, 00922 &varp->begin, gsp->version == 1 ? 4 : 8); 00923 if(status != ENOERR) 00924 goto unwind_alloc; 00925 00926 *varpp = varp; 00927 return ENOERR; 00928 00929 unwind_alloc: 00930 free_NC_var(varp); /* frees name */ 00931 return status; 00932 00933 unwind_name: 00934 free_NC_string(strp); 00935 return status; 00936 }
|
|
||||||||||||
|
Definition at line 1014 of file v1hpg.c. References ENOERR, free_NC_vararrayV(), NC_vararray::nalloc, NC_ENOMEM, NC_UNSPECIFIED, NC_VARIABLE, NC_vararray::nelems, v1hs::pos, type, v1h_get_NC_var(), v1h_get_NCtype(), v1h_get_size_t(), and NC_vararray::value. Referenced by nc_get_NC(). 01015 { 01016 int status; 01017 NCtype type = NC_UNSPECIFIED; 01018 01019 assert(gsp != NULL && gsp->pos != NULL); 01020 assert(ncap != NULL); 01021 assert(ncap->value == NULL); 01022 01023 status = v1h_get_NCtype(gsp, &type); 01024 if(status != ENOERR) 01025 return status; 01026 01027 status = v1h_get_size_t(gsp, &ncap->nelems); 01028 if(status != ENOERR) 01029 return status; 01030 01031 if(ncap->nelems == 0) 01032 return ENOERR; 01033 /* else */ 01034 if(type != NC_VARIABLE) 01035 return EINVAL; 01036 01037 ncap->value = (NC_var **) malloc(ncap->nelems * sizeof(NC_var *)); 01038 if(ncap->value == NULL) 01039 return NC_ENOMEM; 01040 ncap->nalloc = ncap->nelems; 01041 01042 { 01043 NC_var **vpp = ncap->value; 01044 NC_var *const *const end = &vpp[ncap->nelems]; 01045 for( /*NADA*/; vpp < end; vpp++) 01046 { 01047 status = v1h_get_NC_var(gsp, vpp); 01048 if(status) 01049 { 01050 ncap->nelems = (size_t)(vpp - ncap->value); 01051 free_NC_vararrayV(ncap); 01052 return status; 01053 } 01054 } 01055 } 01056 01057 return ENOERR; 01058 }
|
|
||||||||||||
|
Definition at line 211 of file v1hpg.c. References check_v1hs(), ENOERR, ncx_get_int_int(), v1hs::pos, type, and X_SIZEOF_INT. Referenced by v1h_get_NC_attrarray(), v1h_get_NC_dimarray(), and v1h_get_NC_vararray(). 00212 { 00213 int type = 0; 00214 int status = check_v1hs(gsp, X_SIZEOF_INT); 00215 if(status != ENOERR) 00216 return status; 00217 status = ncx_get_int_int(gsp->pos, &type); 00218 gsp->pos = (void *)((char *)gsp->pos + X_SIZEOF_INT); 00219 if(status != ENOERR) 00220 return status; 00221 /* else */ 00222 *typep = (NCtype) type; 00223 return ENOERR; 00224 }
|
|
||||||||||||
|
Definition at line 142 of file v1hpg.c. References check_v1hs(), ENOERR, ncx_get_size_t(), v1hs::pos, and X_SIZEOF_SIZE_T. Referenced by v1h_get_NC_attr(), v1h_get_NC_attrarray(), v1h_get_NC_dim(), v1h_get_NC_dimarray(), v1h_get_NC_string(), v1h_get_NC_var(), and v1h_get_NC_vararray(). 00143 { 00144 int status = check_v1hs(gsp, X_SIZEOF_SIZE_T); 00145 if(status != ENOERR) 00146 return status; 00147 return ncx_get_size_t((const void **)(&gsp->pos), sp); 00148 }
|
|
||||||||||||
|
Definition at line 579 of file v1hpg.c. References ENOERR, NC_attr::name, NC_attr::nelems, NC_attr::type, v1h_put_NC_attrV(), v1h_put_NC_string(), v1h_put_nc_type(), and v1h_put_size_t(). Referenced by v1h_put_NC_attrarray(). 00580 { 00581 int status; 00582 00583 status = v1h_put_NC_string(psp, attrp->name); 00584 if(status != ENOERR) 00585 return status; 00586 00587 status = v1h_put_nc_type(psp, &attrp->type); 00588 if(status != ENOERR) 00589 return status; 00590 00591 status = v1h_put_size_t(psp, &attrp->nelems); 00592 if(status != ENOERR) 00593 return status; 00594 00595 status = v1h_put_NC_attrV(psp, attrp); 00596 if(status != ENOERR) 00597 return status; 00598 00599 return ENOERR; 00600 }
|
|
||||||||||||
|
Definition at line 704 of file v1hpg.c. References ENOERR, NC_ATTRIBUTE, NC_UNSPECIFIED, NC_attrarray::nelems, v1h_put_NC_attr(), v1h_put_NCtype(), v1h_put_size_t(), and NC_attrarray::value. Referenced by ncx_put_NC(), and v1h_put_NC_var(). 00705 { 00706 int status; 00707 00708 assert(psp != NULL); 00709 00710 if(ncap == NULL 00711 #if 1 00712 /* Backward: 00713 * This clause is for 'byte for byte' 00714 * backward compatibility. 00715 * Strickly speaking, it is 'bug for bug'. 00716 */ 00717 || ncap->nelems == 0 00718 #endif 00719 ) 00720 { 00721 /* 00722 * Handle empty netcdf 00723 */ 00724 const size_t nosz = 0; 00725 00726 status = v1h_put_NCtype(psp, NC_UNSPECIFIED); 00727 if(status != ENOERR) 00728 return status; 00729 status = v1h_put_size_t(psp, &nosz); 00730 if(status != ENOERR) 00731 return status; 00732 return ENOERR; 00733 } 00734 /* else */ 00735 00736 status = v1h_put_NCtype(psp, NC_ATTRIBUTE); 00737 if(status != ENOERR) 00738 return status; 00739 status = v1h_put_size_t(psp, &ncap->nelems); 00740 if(status != ENOERR) 00741 return status; 00742 00743 { 00744 const NC_attr **app = (const NC_attr **)ncap->value; 00745 const NC_attr *const *const end = &app[ncap->nelems]; 00746 for( /*NADA*/; app < end; app++) 00747 { 00748 status = v1h_put_NC_attr(psp, *app); 00749 if(status) 00750 return status; 00751 } 00752 } 00753 return ENOERR; 00754 }
|
|
||||||||||||
|
Definition at line 550 of file v1hpg.c. References check_v1hs(), ENOERR, v1hs::extent, MIN, v1hs::pos, X_ALIGN, NC_attr::xsz, and NC_attr::xvalue. Referenced by v1h_put_NC_attr(). 00551 { 00552 int status; 00553 const size_t perchunk = psp->extent; 00554 size_t remaining = attrp->xsz; 00555 void *value = attrp->xvalue; 00556 size_t nbytes; 00557 00558 assert(psp->extent % X_ALIGN == 0); 00559 00560 do { 00561 nbytes = MIN(perchunk, remaining); 00562 00563 status = check_v1hs(psp, nbytes); 00564 if(status != ENOERR) 00565 return status; 00566 00567 (void) memcpy(psp->pos, value, nbytes); 00568 00569 psp->pos = (void *)((char *)psp->pos + nbytes); 00570 value = (void *)((char *)value + nbytes); 00571 remaining -= nbytes; 00572 00573 } while(remaining != 0); 00574 00575 return ENOERR; 00576 }
|
|
||||||||||||
|
Definition at line 344 of file v1hpg.c. References ENOERR, NC_dim::name, NC_dim::size, v1h_put_NC_string(), and v1h_put_size_t(). Referenced by v1h_put_NC_dimarray(). 00345 { 00346 int status; 00347 00348 status = v1h_put_NC_string(psp, dimp->name); 00349 if(status != ENOERR) 00350 return status; 00351 00352 status = v1h_put_size_t(psp, &dimp->size); 00353 if(status != ENOERR) 00354 return status; 00355 00356 return ENOERR; 00357 }
|
|
||||||||||||
|
Definition at line 415 of file v1hpg.c. References ENOERR, NC_DIMENSION, NC_UNSPECIFIED, NC_dimarray::nelems, v1h_put_NC_dim(), v1h_put_NCtype(), v1h_put_size_t(), and NC_dimarray::value. Referenced by ncx_put_NC(). 00416 { 00417 int status; 00418 00419 assert(psp != NULL); 00420 00421 if(ncap == NULL 00422 #if 1 00423 /* Backward: 00424 * This clause is for 'byte for byte' 00425 * backward compatibility. 00426 * Strickly speaking, it is 'bug for bug'. 00427 */ 00428 || ncap->nelems == 0 00429 #endif 00430 ) 00431 { 00432 /* 00433 * Handle empty netcdf 00434 */ 00435 const size_t nosz = 0; 00436 00437 status = v1h_put_NCtype(psp, NC_UNSPECIFIED); 00438 if(status != ENOERR) 00439 return status; 00440 status = v1h_put_size_t(psp, &nosz); 00441 if(status != ENOERR) 00442 return status; 00443 return ENOERR; 00444 } 00445 /* else */ 00446 00447 status = v1h_put_NCtype(psp, NC_DIMENSION); 00448 if(status != ENOERR) 00449 return status; 00450 status = v1h_put_size_t(psp, &ncap->nelems); 00451 if(status != ENOERR) 00452 return status; 00453 00454 { 00455 const NC_dim **dpp = (const NC_dim **)ncap->value; 00456 const NC_dim *const *const end = &dpp[ncap->nelems]; 00457 for( /*NADA*/; dpp < end; dpp++) 00458 { 00459 status = v1h_put_NC_dim(psp, *dpp); 00460 if(status) 00461 return status; 00462 } 00463 } 00464 return ENOERR; 00465 }
|
|
||||||||||||
|
Definition at line 255 of file v1hpg.c. References _RNDUP, check_v1hs(), NC_string::cp, ENOERR, NC_string::nchars, ncx_pad_putn_text(), v1hs::pos, v1h_put_size_t(), and X_ALIGN. Referenced by v1h_put_NC_attr(), v1h_put_NC_dim(), and v1h_put_NC_var(). 00256 { 00257 int status; 00258 00259 #if 0 00260 assert(ncstrp->nchars % X_ALIGN == 0); 00261 #endif 00262 00263 status = v1h_put_size_t(psp, &ncstrp->nchars); 00264 if(status != ENOERR) 00265 return status; 00266 status = check_v1hs(psp, _RNDUP(ncstrp->nchars, X_ALIGN)); 00267 if(status != ENOERR) 00268 return status; 00269 status = ncx_pad_putn_text(&psp->pos, ncstrp->nchars, ncstrp->cp); 00270 if(status != ENOERR) 00271 return status; 00272 00273 return ENOERR; 00274 }
|
|
||||||||||||
|
Definition at line 156 of file v1hpg.c. References check_v1hs(), ENOERR, ncx_put_int_int(), v1hs::pos, and X_SIZEOF_INT. Referenced by v1h_put_NC_attr(), and v1h_put_NC_var(). 00157 { 00158 const int itype = (int) *typep; 00159 int status = check_v1hs(psp, X_SIZEOF_INT); 00160 if(status != ENOERR) 00161 return status; 00162 status = ncx_put_int_int(psp->pos, &itype); 00163 psp->pos = (void *)((char *)psp->pos + X_SIZEOF_INT); 00164 return status; 00165 }
|
|
||||||||||||
|
Definition at line 832 of file v1hpg.c. References NC_var::attrs, NC_var::begin, check_v1hs(), NC_var::dimids, ENOERR, NC_var::len, NC_var::name, ncx_len_int, ncx_put_off_t(), ncx_putn_int_int(), NC_var::ndims, v1hs::pos, NC_var::type, v1h_put_NC_attrarray(), v1h_put_NC_string(), v1h_put_nc_type(), v1h_put_size_t(), and v1hs::version. Referenced by v1h_put_NC_vararray(). 00833 { 00834 int status; 00835 00836 status = v1h_put_NC_string(psp, varp->name); 00837 if(status != ENOERR) 00838 return status; 00839 00840 status = v1h_put_size_t(psp, &varp->ndims); 00841 if(status != ENOERR) 00842 return status; 00843 00844 status = check_v1hs(psp, ncx_len_int(varp->ndims)); 00845 if(status != ENOERR) 00846 return status; 00847 status = ncx_putn_int_int(&psp->pos, 00848 varp->ndims, varp->dimids); 00849 if(status != ENOERR) 00850 return status; 00851 00852 status = v1h_put_NC_attrarray(psp, &varp->attrs); 00853 if(status != ENOERR) 00854 return status; 00855 00856 status = v1h_put_nc_type(psp, &varp->type); 00857 if(status != ENOERR) 00858 return status; 00859 00860 status = v1h_put_size_t(psp, &varp->len); 00861 if(status != ENOERR) 00862 return status; 00863 00864 status = check_v1hs(psp, psp->version == 1 ? 4 : 8); 00865 if(status != ENOERR) 00866 return status; 00867 status = ncx_put_off_t(&psp->pos, &varp->begin, psp->version == 1 ? 4 : 8); 00868 if(status != ENOERR) 00869 return status; 00870 00871 return ENOERR; 00872 }
|
|
||||||||||||
|
Definition at line 960 of file v1hpg.c. References ENOERR, NC_UNSPECIFIED, NC_VARIABLE, NC_vararray::nelems, v1h_put_NC_var(), v1h_put_NCtype(), v1h_put_size_t(), and NC_vararray::value. Referenced by ncx_put_NC(). 00961 { 00962 int status; 00963 00964 assert(psp != NULL); 00965 00966 if(ncap == NULL 00967 #if 1 00968 /* Backward: 00969 * This clause is for 'byte for byte' 00970 * backward compatibility. 00971 * Strickly speaking, it is 'bug for bug'. 00972 */ 00973 || ncap->nelems == 0 00974 #endif 00975 ) 00976 { 00977 /* 00978 * Handle empty netcdf 00979 */ 00980 const size_t nosz = 0; 00981 00982 status = v1h_put_NCtype(psp, NC_UNSPECIFIED); 00983 if(status != ENOERR) 00984 return status; 00985 status = v1h_put_size_t(psp, &nosz); 00986 if(status != ENOERR) 00987 return status; 00988 return ENOERR; 00989 } 00990 /* else */ 00991 00992 status = v1h_put_NCtype(psp, NC_VARIABLE); 00993 if(status != ENOERR) 00994 return status; 00995 status = v1h_put_size_t(psp, &ncap->nelems); 00996 if(status != ENOERR) 00997 return status; 00998 00999 { 01000 const NC_var **vpp = (const NC_var **)ncap->value; 01001 const NC_var *const *const end = &vpp[ncap->nelems]; 01002 for( /*NADA*/; vpp < end; vpp++) 01003 { 01004 status = v1h_put_NC_var(psp, *vpp); 01005 if(status) 01006 return status; 01007 } 01008 } 01009 return ENOERR; 01010 }
|
|
||||||||||||
|
Definition at line 199 of file v1hpg.c. References check_v1hs(), ENOERR, ncx_put_int_int(), v1hs::pos, and X_SIZEOF_INT. Referenced by v1h_put_NC_attrarray(), v1h_put_NC_dimarray(), and v1h_put_NC_vararray(). 00200 { 00201 const int itype = (int) type; 00202 int status = check_v1hs(psp, X_SIZEOF_INT); 00203 if(status != ENOERR) 00204 return status; 00205 status = ncx_put_int_int(psp->pos, &itype); 00206 psp->pos = (void *)((char *)psp->pos + X_SIZEOF_INT); 00207 return status; 00208 }
|
|
||||||||||||
|
Definition at line 132 of file v1hpg.c. References check_v1hs(), ENOERR, ncx_put_size_t(), v1hs::pos, and X_SIZEOF_SIZE_T. Referenced by v1h_put_NC_attr(), v1h_put_NC_attrarray(), v1h_put_NC_dim(), v1h_put_NC_dimarray(), v1h_put_NC_string(), v1h_put_NC_var(), and v1h_put_NC_vararray(). 00133 { 00134 int status = check_v1hs(psp, X_SIZEOF_SIZE_T); 00135 if(status != ENOERR) 00136 return status; 00137 return ncx_put_size_t(&psp->pos, sp); 00138 }
|
|
|
Definition at line 34 of file v1hpg.c. Referenced by nc_get_NC(), ncx_len_NC(), and ncx_put_NC(). |
|
|
Definition at line 35 of file v1hpg.c. Referenced by ncx_put_NC(). |
1.4.4