/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "hdf5.h" #include "h5test.h" #include "h5repack.h" /*------------------------------------------------------------------------- * Function: has_filter * * Purpose: verify if a filter is present in the property list DCPL_ID * * Return: 1 has, 0 does not, -1 error * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * * Date: December 19, 2003 * *------------------------------------------------------------------------- */ int has_filter(hid_t dcpl_id, H5Z_filter_t filtnin) { int nfilters; /* number of filters */ unsigned filt_flags; /* filter flags */ H5Z_filter_t filtn; /* filter identification number */ unsigned cd_values[20]; /* filter client data values */ size_t cd_nelmts; /* filter client number of values */ char f_name[256]; /* filter name */ int have=0; /* flag, filter is present */ hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; /* layout */ int rank; /* rank */ int i; /* index */ /* if no information about the input filter is requested return exit */ if (filtnin==-1) return 1; /* get information about filters */ if ((nfilters = H5Pget_nfilters(dcpl_id))<0) return -1; /* H5D_COMPACT = 0 H5D_CONTIGUOUS = 1 H5D_CHUNKED = 2 */ layout = H5Pget_layout(dcpl_id); if (layout==H5D_CHUNKED) { if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/))<0) return -1; } for (i=0; iop_tbl->nelems; i++) { char* name=options->op_tbl->objs[i].path; pack_info_t obj=options->op_tbl->objs[i]; /*------------------------------------------------------------------------- * open *------------------------------------------------------------------------- */ if ((dset_id=H5Dopen(fid,name))<0) goto error; if ((space_id=H5Dget_space(dset_id))<0) goto error; if ((dcpl_id=H5Dget_create_plist(dset_id))<0) goto error; /*------------------------------------------------------------------------- * filter check *------------------------------------------------------------------------- */ if (has_filter(dcpl_id,obj.filter.filtn)==0) ret=0; /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ if (H5Pclose(dcpl_id)<0) goto error; if (H5Sclose(space_id)<0) goto error; if (H5Dclose(dset_id)<0) goto error; } /*------------------------------------------------------------------------- * check for the "all" objects option *------------------------------------------------------------------------- */ if (options->all_filter==1) { /* init table */ trav_table_init(&travt); /* get the list of objects in the file */ if (h5trav_gettable(fid,travt)<0) goto error; for ( i=0; inobjs; i++) { char* name=travt->objs[i].name; switch ( travt->objs[i].type ) { case H5G_DATASET: /*------------------------------------------------------------------------- * open *------------------------------------------------------------------------- */ if ((dset_id=H5Dopen(fid,name))<0) goto error; if ((space_id=H5Dget_space(dset_id))<0) goto error; if ((dcpl_id=H5Dget_create_plist(dset_id))<0) goto error; /*------------------------------------------------------------------------- * filter check *------------------------------------------------------------------------- */ if (has_filter(dcpl_id,options->filter_g.filtn)==0) ret=0; /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ if (H5Pclose(dcpl_id)<0) goto error; if (H5Sclose(space_id)<0) goto error; if (H5Dclose(dset_id)<0) goto error; break; default: break; } /* switch */ } /* i */ /* free table */ trav_table_free(travt); } /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ if (H5Fclose(fid)<0) return -1; return ret; error: H5E_BEGIN_TRY { H5Pclose(dcpl_id); H5Sclose(space_id); H5Dclose(dset_id); H5Fclose(fid); trav_table_free(travt); } H5E_END_TRY; return -1; }