1 /* Copyright 2018-2018 University Corporation for Atmospheric 2 Research/Unidata. */ 3 /** 4 * @file 5 * @internal This header file contains macros, types and prototypes 6 * used to build and manipulate the netCDF metadata model. 7 * 8 * @author Ed Hartnett, Dennis Heimbigner, Ward Fisher 9 */ 10 11 #ifndef _NC4INTERNAL_ 12 #define _NC4INTERNAL_ 13 #include "netcdf.h" 14 15 #include "config.h" 16 #include <stdio.h> 17 #include <stdlib.h> 18 #include <ctype.h> 19 #include <string.h> 20 21 #include "ncdimscale.h" 22 #include "nc_logging.h" 23 #include "ncindex.h" 24 #include "nc_provenance.h" 25 26 27 #include "netcdf_f.h" 28 #include "netcdf_mem.h" 29 #include "netcdf_filter.h" 30 #ifdef USE_PARALLEL 31 #include "netcdf_par.h" 32 #endif /* USE_PARALLEL */ 33 34 /* Always needed */ 35 #include "nc.h" 36 37 /** The file ID is stored in the first two bytes of ncid. */ 38 #define FILE_ID_MASK (0xffff0000) 39 40 /** The group ID is stored in the last two bytes of ncid. */ 41 #define GRP_ID_MASK (0x0000ffff) 42 43 /** File and group IDs are each 16 bits of the ncid. */ 44 #define ID_SHIFT (16) 45 46 /* typedef enum {GET, PUT} NC_PG_T; */ 47 /** These are the different objects that can be in our hash-lists. */ 48 typedef enum {NCNAT, NCVAR, NCDIM, NCATT, NCTYP, NCFLD, NCGRP} NC_SORT; 49 50 /** The netCDF V2 error code. */ 51 #define NC_V2_ERR (-1) 52 53 /** The name of the root group. */ 54 #define NC_GROUP_NAME "/" 55 56 /** One mega-byte. */ 57 #define MEGABYTE 1048576 58 59 /** The HDF5 ID for the szip filter. */ 60 #define HDF5_FILTER_SZIP 4 61 62 #define X_SCHAR_MIN (-128) /**< Minimum signed char value. */ 63 #define X_SCHAR_MAX 127 /**< Maximum signed char value. */ 64 #define X_UCHAR_MAX 255U /**< Maximum unsigned char value. */ 65 #define X_SHORT_MIN (-32768) /**< Minimum short value. */ 66 #define X_SHRT_MIN X_SHORT_MIN /**< This alias is compatible with limits.h. */ 67 #define X_SHORT_MAX 32767 /**< Maximum short value. */ 68 #define X_SHRT_MAX X_SHORT_MAX /**< This alias is compatible with limits.h. */ 69 #define X_USHORT_MAX 65535U /**< Maximum unsigned short value. */ 70 #define X_USHRT_MAX X_USHORT_MAX /**< This alias is compatible with limits.h. */ 71 #define X_INT_MIN (-2147483647-1) /**< Minimum int value. */ 72 #define X_INT_MAX 2147483647 /**< Maximum int value. */ 73 #define X_LONG_MIN X_INT_MIN /**< Minimum long value. */ 74 #define X_LONG_MAX X_INT_MAX /**< Maximum long value. */ 75 #define X_UINT_MAX 4294967295U /**< Maximum unsigned int value. */ 76 #define X_INT64_MIN (-9223372036854775807LL-1LL) /**< Minimum int64 value. */ 77 #define X_INT64_MAX 9223372036854775807LL /**< Maximum int64 value. */ 78 #define X_UINT64_MAX 18446744073709551615ULL /**< Maximum unsigned int64 value. */ 79 #ifdef _WIN32 /* Windows, of course, has to be a *little* different. */ 80 #define X_FLOAT_MAX 3.402823466e+38f 81 #else 82 #define X_FLOAT_MAX 3.40282347e+38f /**< Maximum float value. */ 83 #endif /* _WIN32 */ 84 #define X_FLOAT_MIN (-X_FLOAT_MAX) /**< Minimum float value. */ 85 #define X_DOUBLE_MAX 1.7976931348623157e+308 /**< Maximum double value. */ 86 #define X_DOUBLE_MIN (-X_DOUBLE_MAX) /**< Minimum double value. */ 87 88 /** This is the number of netCDF atomic types. */ 89 #define NUM_ATOMIC_TYPES (NC_MAX_ATOMIC_TYPE + 1) 90 91 /** Number of parameters needed for ZLIB filter. */ 92 #define CD_NELEMS_ZLIB 1 93 94 /** Get a pointer to the NC_FILE_INFO_T from dispatchdata field. */ 95 #define NC4_DATA(nc) ((NC_FILE_INFO_T *)(nc)->dispatchdata) 96 97 /** Set a pointer to the NC_FILE_INFO_T in the dispatchdata field. */ 98 #define NC4_DATA_SET(nc,data) ((nc)->dispatchdata = (void *)(data)) 99 100 /* Reserved attribute flags: must be powers of 2. */ 101 /** Hidden dimscale-related, per-variable attributes; immutable and 102 * unreadable thru API. */ 103 #define DIMSCALEFLAG 1 104 105 /** Readonly global attributes; readable, but immutable thru the 106 * API. */ 107 #define READONLYFLAG 2 108 109 /** Subset of readonly flags; readable by name only thru the API. */ 110 #define NAMEONLYFLAG 4 111 112 /** Subset of readonly flags; Value is actually in file. */ 113 #define MATERIALIZEDFLAG 8 114 115 /* Generic reserved Attributes */ 116 #define NC_ATT_REFERENCE_LIST "REFERENCE_LIST" /**< HDF5 reference list attribute name. */ 117 #define NC_ATT_CLASS "CLASS" /**< HDF5 class atttribute name. */ 118 #define NC_ATT_DIMENSION_LIST "DIMENSION_LIST" /**< HDF5 dimension list attribute name. */ 119 #define NC_ATT_NAME "NAME" /**< HDF5 name atttribute name. */ 120 #define NC_ATT_COORDINATES COORDINATES /**< Coordinates atttribute name. */ 121 #define NC_ATT_FORMAT "_Format" /**< Format atttribute name. */ 122 123 /** Boolean type, to make the code easier to read. */ 124 typedef enum {NC_FALSE = 0, NC_TRUE = 1} nc_bool_t; 125 126 /* Forward declarations. */ 127 struct NC_GRP_INFO; 128 struct NC_TYPE_INFO; 129 struct NC_FIlterobject; 130 131 /** 132 * This struct provides indexed Access to Meta-data objects. See the 133 * document docs/indexing.dox for detailed information. 134 * 135 * Basically it provides a common header and use NCindex instances 136 * instead of linked lists. 137 * 138 * WARNING: ALL OBJECTS THAT CAN BE INSERTED INTO AN NCindex MUST HAVE 139 * AN INSTANCE of NC_OBJ AS THE FIRST FIELD. 140 */ 141 typedef struct NC_OBJ 142 { 143 NC_SORT sort; /**< Type of object. */ 144 char* name; /**< Name, assumed to be null terminated. */ 145 size_t id; /**< This objects ID. */ 146 unsigned int hashkey; /**< The hash key, crc32(name). */ 147 } NC_OBJ; 148 149 /** 150 * This struct holds information about reserved attributes. These 151 * attributes cannot be created or read by the user (through the 152 * netCDF API). */ 153 typedef struct NC_reservedatt 154 { 155 const char *name; /**< Name of the reserved attribute. */ 156 int flags; /**< Flags that control handling of reserved attribute. */ 157 } NC_reservedatt; 158 159 /** This is a struct to handle the dimension metadata. */ 160 typedef struct NC_DIM_INFO 161 { 162 NC_OBJ hdr; /**< The hdr contains the name and ID. */ 163 struct NC_GRP_INFO *container; /**< Pointer to containing group. */ 164 size_t len; /**< Length of this dimension. */ 165 nc_bool_t unlimited; /**< True if the dimension is unlimited */ 166 nc_bool_t extended; /**< True if the dimension needs to be extended. */ 167 nc_bool_t too_long; /**< True if len is too big to fit in local size_t. */ 168 void *format_dim_info; /**< Pointer to format-specific dim info. */ 169 struct NC_VAR_INFO *coord_var; /**< The coord var, if it exists. */ 170 } NC_DIM_INFO_T; 171 172 /** This is a struct to handle the attribute metadata. */ 173 typedef struct NC_ATT_INFO 174 { 175 NC_OBJ hdr; /**< The hdr contains the name and ID. */ 176 struct NC_OBJ *container; /**< Pointer to containing group|var. */ 177 int len; /**< Length of attribute data. */ 178 nc_bool_t dirty; /**< True if attribute modified. */ 179 nc_bool_t created; /**< True if attribute already created. */ 180 nc_type nc_typeid; /**< NetCDF type of attribute's data. */ 181 void *format_att_info; /**< Pointer to format-specific att info. */ 182 void *data; /**< The attribute data. */ 183 nc_vlen_t *vldata; /**< VLEN data (only used for vlen types). */ 184 char **stdata; /**< String data (only for string type). */ 185 } NC_ATT_INFO_T; 186 187 /** This is a struct to handle the var metadata. */ 188 typedef struct NC_VAR_INFO 189 { 190 NC_OBJ hdr; /**< The hdr contains the name and ID. */ 191 char *hdf5_name; /**< Used if name in HDF5 must be different from name. */ 192 struct NC_GRP_INFO *container; /**< Pointer to containing group. */ 193 size_t ndims; /**< Number of dims. */ 194 int *dimids; /**< Dim IDs. */ 195 NC_DIM_INFO_T **dim; /**< Pointer to array of NC_DIM_INFO_T. */ 196 nc_bool_t is_new_var; /**< True if variable is newly created. */ 197 nc_bool_t was_coord_var; /**< True if variable was a coordinate var, but either the dim or var has been renamed. */ 198 nc_bool_t became_coord_var; /**< True if variable _became_ a coordinate var, because either the dim or var has been renamed. */ 199 nc_bool_t fill_val_changed; /**< True if variable's fill value changes after it has been created. */ 200 nc_bool_t attr_dirty; /**< True if variable's attributes are dirty and should be rewritten. */ 201 nc_bool_t created; /**< Variable has already been created (_not_ that it was just created). */ 202 nc_bool_t written_to; /**< True if variable has data written to it. */ 203 struct NC_TYPE_INFO *type_info; /**< Contains info about the variable type. */ 204 int atts_read; /**< If true, the atts have been read. */ 205 nc_bool_t meta_read; /**< True if this vars metadata has been completely read. */ 206 nc_bool_t coords_read; /**< True if this var has hidden coordinates att, and it has been read. */ 207 NCindex *att; /**< List of NC_ATT_INFO_T. */ 208 nc_bool_t no_fill; /**< True if no fill value is defined for var. */ 209 void *fill_value; /**< Pointer to fill value, or NULL. */ 210 size_t *chunksizes; /**< For chunked storage, an array (size ndims) of chunksizes. */ 211 int storage; /**< Storage of this var, compact, contiguous, or chunked. */ 212 int parallel_access; /**< Type of parallel access for I/O on variable (collective or independent). */ 213 nc_bool_t dimscale; /**< True if var is a dimscale. */ 214 nc_bool_t *dimscale_attached; /**< Array of flags that are true if dimscale is attached for that dim index. */ 215 nc_bool_t shuffle; /**< True if var has shuffle filter applied. */ 216 nc_bool_t fletcher32; /**< True if var has fletcher32 filter applied. */ 217 size_t chunk_cache_size; /**< Size in bytes of the var chunk chache. */ 218 size_t chunk_cache_nelems; /**< Number of slots in var chunk cache. */ 219 float chunk_cache_preemption; /**< Chunk cache preemtion policy. */ 220 void *format_var_info; /**< Pointer to any binary format info. */ 221 NClist* filters; /**< List of filters to be applied to var data. */ 222 } NC_VAR_INFO_T; 223 224 /** This is a struct to handle the field metadata from a user-defined 225 * type. */ 226 typedef struct NC_FIELD_INFO 227 { 228 NC_OBJ hdr; /**< The hdr contains the name and ID. */ 229 nc_type nc_typeid; /**< The type of this field. */ 230 size_t offset; /**< Offset in bytes of field. */ 231 int ndims; /**< Number of dims. */ 232 int *dim_size; /**< Dim sizes. */ 233 void *format_field_info; /**< Pointer to any binary format info for field. */ 234 } NC_FIELD_INFO_T; 235 236 /** This is a struct to handle metadata for a user-defined enum 237 * type. */ 238 typedef struct NC_ENUM_MEMBER_INFO 239 { 240 char *name; /**< Name of member. */ 241 void *value; /**< Value of member. */ 242 } NC_ENUM_MEMBER_INFO_T; 243 244 /** This is a struct to handle metadata for a user-defined type. */ 245 typedef struct NC_TYPE_INFO 246 { 247 NC_OBJ hdr; /**< The hdr contains the name and ID. */ 248 struct NC_GRP_INFO *container; /**< Containing group */ 249 unsigned rc; /**< Ref. count of objects using this type */ 250 int endianness; /**< What endianness for the type? */ 251 size_t size; /**< Size of the type in memory, in bytes */ 252 nc_bool_t committed; /**< True when datatype is committed in the file */ 253 nc_type nc_type_class; /**< NC_VLEN, NC_COMPOUND, NC_OPAQUE, NC_ENUM, NC_INT, NC_FLOAT, or NC_STRING. */ 254 void *format_type_info; /**< HDF5-specific type info. */ 255 256 /** Information for each type or class */ 257 union { 258 struct { 259 NClist* enum_member; /**< <! NClist<NC_ENUM_MEMBER_INFO_T*> */ 260 nc_type base_nc_typeid; /**< Typeid of the base type. */ 261 } e; /**< Enum */ 262 struct Fields { 263 NClist* field; /**< <! NClist<NC_FIELD_INFO_T*> */ 264 } c; /**< Compound */ 265 struct { 266 nc_type base_nc_typeid; /**< Typeid of the base type. */ 267 } v; /**< Variable-length. */ 268 } u; /**< Union of structs, for each type/class. */ 269 } NC_TYPE_INFO_T; 270 271 /** This holds information for one group. Groups reproduce with 272 * parthenogenesis. */ 273 typedef struct NC_GRP_INFO 274 { 275 NC_OBJ hdr; /**< The hdr contains the name and ID. */ 276 void *format_grp_info; /**< Pointer to binary format info for group. */ 277 struct NC_FILE_INFO *nc4_info; /**< Pointer containing NC_FILE_INFO_T. */ 278 struct NC_GRP_INFO *parent; /**< Pointer tp parent group. */ 279 int atts_read; /**< True if atts have been read for this group. */ 280 NCindex* children; /**< NCindex<struct NC_GRP_INFO*> */ 281 NCindex* dim; /**< NCindex<NC_DIM_INFO_T> * */ 282 NCindex* att; /**< NCindex<NC_ATT_INFO_T> * */ 283 NCindex* type; /**< NCindex<NC_TYPE_INFO_T> * */ 284 /* Note that this is the list of vars with position == varid */ 285 NCindex* vars; /**< NCindex<NC_VAR_INFO_T> * */ 286 } NC_GRP_INFO_T; 287 288 /* These constants apply to the cmode parameter in the 289 * HDF5_FILE_INFO_T defined below. */ 290 #define NC_CREAT 2 /**< in create phase, cleared by ncendef */ 291 #define NC_INDEF 8 /**< in define mode, cleared by ncendef */ 292 #define NC_NSYNC 0x10 /**< synchronise numrecs on change */ 293 #define NC_HSYNC 0x20 /**< synchronise whole header on change */ 294 #define NC_NDIRTY 0x40 /**< numrecs has changed */ 295 #define NC_HDIRTY 0x80 /**< header info has changed */ 296 297 /** This is the metadata we need to keep track of for each 298 * netcdf-4/HDF5 file. */ 299 typedef struct NC_FILE_INFO 300 { 301 NC *controller; /**< Pointer to containing NC. */ 302 #ifdef USE_PARALLEL4 303 MPI_Comm comm; /**< Copy of MPI Communicator used to open the file. */ 304 MPI_Info info; /**< Copy of MPI Information Object used to open the file. */ 305 #endif 306 int flags; /**< Flags used to open the file. */ 307 int cmode; /**< Create mode used to create the file. */ 308 nc_bool_t parallel; /**< True if file is open for parallel access */ 309 nc_bool_t redef; /**< True if redefining an existing file */ 310 int fill_mode; /**< Fill mode for vars - Unused internally currently */ 311 nc_bool_t no_write; /**< true if nc_open has mode NC_NOWRITE. */ 312 NC_GRP_INFO_T *root_grp; /**< Pointer to root group. */ 313 short next_nc_grpid; /**< Next available group ID. */ 314 int next_typeid; /**< Next available type ID. */ 315 int next_dimid; /**< Next available dim ID. */ 316 /* Provide convenience vectors indexed by the object id. This 317 allows for direct conversion of e.g. an nc_type to the 318 corresponding NC_TYPE_INFO_T object. */ 319 NClist *alldims; /**< List of all dims. */ 320 NClist *alltypes; /**< List of all types. */ 321 NClist *allgroups; /**< List of all groups, including root group. */ 322 void *format_file_info; /**< Pointer to binary format info for file. */ 323 NC4_Provenance provenance; /**< File provenence info. */ 324 struct NC4_Memio 325 { 326 NC_memio memio; /**< What we sent to image_init and what comes back. */ 327 int locked; /**< Do not copy and do not free. */ 328 int persist; /**< Should file be persisted out on close? */ 329 int inmemory; /**< NC_INMEMORY flag was set. */ 330 int diskless; /**< NC_DISKLESS flag was set => inmemory. */ 331 int created; /**< 1 => create, 0 => open. */ 332 unsigned int imageflags; /**< for H5LTopen_file_image. */ 333 size_t initialsize; /**< Initial size. */ 334 void *udata; /**< Extra memory allocated in NC4_image_init. */ 335 } mem; 336 } NC_FILE_INFO_T; 337 338 /** Variable Length Datatype struct in memory. Must be identical to 339 * HDF5 hvl_t. (This is only used for VL sequences, not VL strings, 340 * which are stored in char *'s) */ 341 typedef struct 342 { 343 size_t len; /**< Length of VL data (in base type units) */ 344 void *p; /**< Pointer to VL data */ 345 } nc_hvl_t; 346 347 /** The names of the atomic data types. */ 348 extern const char *nc4_atomic_name[NC_MAX_ATOMIC_TYPE + 1]; 349 350 /* These functions convert between netcdf and HDF5 types. */ 351 int nc4_get_typelen_mem(NC_FILE_INFO_T *h5, nc_type xtype, size_t *len); 352 int nc4_convert_type(const void *src, void *dest, const nc_type src_type, 353 const nc_type dest_type, const size_t len, int *range_error, 354 const void *fill_value, int strict_nc3); 355 356 /* These functions do HDF5 things. */ 357 int nc4_reopen_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var); 358 int nc4_read_atts(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var); 359 360 /* Find items in the in-memory lists of metadata. */ 361 int nc4_find_nc_grp_h5(int ncid, NC **nc, NC_GRP_INFO_T **grp, 362 NC_FILE_INFO_T **h5); 363 int nc4_find_grp_h5(int ncid, NC_GRP_INFO_T **grp, NC_FILE_INFO_T **h5); 364 int nc4_find_nc4_grp(int ncid, NC_GRP_INFO_T **grp); 365 int nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim, 366 NC_GRP_INFO_T **dim_grp); 367 int nc4_find_var(NC_GRP_INFO_T *grp, const char *name, NC_VAR_INFO_T **var); 368 int nc4_find_dim_len(NC_GRP_INFO_T *grp, int dimid, size_t **len); 369 int nc4_find_type(const NC_FILE_INFO_T *h5, int typeid1, NC_TYPE_INFO_T **type); 370 NC_TYPE_INFO_T *nc4_rec_find_named_type(NC_GRP_INFO_T *start_grp, char *name); 371 NC_TYPE_INFO_T *nc4_rec_find_equal_type(NC_GRP_INFO_T *start_grp, int ncid1, 372 NC_TYPE_INFO_T *type); 373 int nc4_find_nc_att(int ncid, int varid, const char *name, int attnum, 374 NC_ATT_INFO_T **att); 375 int nc4_find_grp_h5_var(int ncid, int varid, NC_FILE_INFO_T **h5, 376 NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var); 377 int nc4_find_grp_att(NC_GRP_INFO_T *grp, int varid, const char *name, 378 int attnum, NC_ATT_INFO_T **att); 379 int nc4_get_typeclass(const NC_FILE_INFO_T *h5, nc_type xtype, 380 int *type_class); 381 382 /* Free various types */ 383 int nc4_type_free(NC_TYPE_INFO_T *type); 384 385 /* These list functions add and delete vars, atts. */ 386 int nc4_nc4f_list_add(NC *nc, const char *path, int mode); 387 int nc4_nc4f_list_del(NC_FILE_INFO_T *h5); 388 int nc4_file_list_add(int ncid, const char *path, int mode, 389 void **dispatchdata); 390 int nc4_file_list_get(int ncid, char **path, int *mode, 391 void **dispatchdata); 392 int nc4_file_list_del(int ncid); 393 int nc4_file_change_ncid(int ncid, unsigned short new_ncid_index); 394 int nc4_var_list_add(NC_GRP_INFO_T* grp, const char* name, int ndims, 395 NC_VAR_INFO_T **var); 396 int nc4_var_list_add2(NC_GRP_INFO_T* grp, const char* name, 397 NC_VAR_INFO_T **var); 398 int nc4_var_set_ndims(NC_VAR_INFO_T *var, int ndims); 399 int nc4_var_list_del(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var); 400 int nc4_dim_list_add(NC_GRP_INFO_T *grp, const char *name, size_t len, 401 int assignedid, NC_DIM_INFO_T **dim); 402 int nc4_dim_list_del(NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim); 403 int nc4_type_new(size_t size, const char *name, int assignedid, 404 NC_TYPE_INFO_T **type); 405 int nc4_type_list_add(NC_GRP_INFO_T *grp, size_t size, const char *name, 406 NC_TYPE_INFO_T **type); 407 int nc4_type_list_del(NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type); 408 int nc4_type_free(NC_TYPE_INFO_T *type); 409 int nc4_field_list_add(NC_TYPE_INFO_T* parent, const char *name, 410 size_t offset, nc_type xtype, int ndims, 411 const int *dim_sizesp); 412 int nc4_att_list_add(NCindex *list, const char *name, NC_ATT_INFO_T **att); 413 int nc4_att_list_del(NCindex *list, NC_ATT_INFO_T *att); 414 int nc4_grp_list_add(NC_FILE_INFO_T *h5, NC_GRP_INFO_T *parent, char *name, 415 NC_GRP_INFO_T **grp); 416 int nc4_build_root_grp(NC_FILE_INFO_T *h5); 417 int nc4_rec_grp_del(NC_GRP_INFO_T *grp); 418 int nc4_enum_member_add(NC_TYPE_INFO_T *type, size_t size, const char *name, 419 const void *value); 420 421 /* Check and normalize names. */ 422 int NC_check_name(const char *name); 423 int nc4_check_name(const char *name, char *norm_name); 424 int nc4_normalize_name(const char *name, char *norm_name); 425 int nc4_check_dup_name(NC_GRP_INFO_T *grp, char *norm_name); 426 427 /* Find default fill value. */ 428 int nc4_get_default_fill_value(const NC_TYPE_INFO_T *type_info, void *fill_value); 429 430 /* Get an att given pointers to file, group, and perhaps ver info. */ 431 int nc4_get_att_ptrs(NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, 432 const char *name, nc_type *xtype, nc_type mem_type, 433 size_t *lenp, int *attnum, void *data); 434 435 /* Close the file. */ 436 int nc4_close_netcdf4_file(NC_FILE_INFO_T *h5, int abort, NC_memio *memio); 437 438 /* HDF5 initialization/finalization */ 439 extern int nc4_hdf5_initialized; 440 extern void nc4_hdf5_initialize(void); 441 extern void nc4_hdf5_finalize(void); 442 443 /* This is only included if --enable-logging is used for configure; it 444 prints info about the metadata to stderr. */ 445 #ifdef LOGGING 446 int log_metadata_nc(NC_FILE_INFO_T *h5); 447 #endif 448 449 /* Binary searcher for reserved attributes */ 450 extern const NC_reservedatt *NC_findreserved(const char *name); 451 452 /**************************************************/ 453 /* Internal filter related structures */ 454 455 /* Internal filter actions */ 456 #define NCFILTER_DEF 1 457 #define NCFILTER_REMOVE 2 458 #define NCFILTER_INQ 3 459 #define NCFILTER_FILTERIDS 4 460 #define NCFILTER_INFO 5 461 #define NCFILTER_FREESPEC 6 462 #define NCFILTER_CLIENT_REG 10 463 #define NCFILTER_CLIENT_UNREG 11 464 #define NCFILTER_CLIENT_INQ 12 465 466 typedef enum NC_FILTER_SORT { 467 NC_FILTER_SORT_SPEC=((int)1), 468 NC_FILTER_SORT_IDS=((int)2), 469 NC_FILTER_SORT_CLIENT=((int)3), 470 } NC_FILTER_SORT; 471 472 /* Provide structs to pass args to filter_actions function for HDF5*/ 473 474 typedef struct NC_FILTER_SPEC_HDF5 { 475 int active; /**< true iff HDF5 library was told to activate filter */ 476 unsigned int filterid; /**< ID for arbitrary filter. */ 477 size_t nparams; /**< nparams for arbitrary filter. */ 478 unsigned int* params; /**< Params for arbitrary filter. */ 479 } NC_FILTER_SPEC_HDF5; 480 481 typedef struct NC_FILTERIDS_HDF5 { 482 size_t nfilters; /**< number of filters */ 483 unsigned int* filterids; /**< Filter ids. */ 484 } NC_FILTERIDS_HDF5; 485 486 typedef struct NC_FILTER_CLIENT_HDF5 { 487 unsigned int id; 488 /* The filter info for hdf5 */ 489 /* Avoid needing hdf.h by using void* */ 490 void* info; 491 } NC_FILTER_CLIENT_HDF5; 492 493 typedef struct NC_FILTER_OBJ_HDF5 { 494 NC_Filterobject hdr; /* So we can cast it */ 495 NC_FILTER_SORT sort; /* discriminate union */ 496 union { 497 NC_FILTER_SPEC_HDF5 spec; 498 NC_FILTERIDS_HDF5 ids; 499 NC_FILTER_CLIENT_HDF5 client; 500 } u; 501 } NC_FILTER_OBJ_HDF5; 502 503 extern void NC4_freefilterspec(NC_FILTER_SPEC_HDF5* f); 504 505 #endif /* _NC4INTERNAL_ */ 506