diff --git a/.gitattributes b/.gitattributes index 2f79ef6..be10b7a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -375,6 +375,7 @@ src/C/H5Fed_retrieve.c -text src/C/H5Fed_store.c -text src/C/H5Fed_tags.c -text src/C/H5Part.c -text +src/C/H5_attachments.c -text src/C/H5_attribs.c -text src/C/Makefile.am -text src/C/generate-h5b-readwrite.py -text @@ -393,7 +394,7 @@ src/Fortran/TestUnderscore.f -text src/Fortran/TestUnderscoreC.c -text src/Makefile.am -text src/h5core/Makefile.am -text -src/h5core/h5_attachments.c -text +src/h5core/h5_attach.c -text src/h5core/h5_attribs.c -text src/h5core/h5_attribs_private.h -text src/h5core/h5_core_private.h -text @@ -478,9 +479,11 @@ src/include/H5Fed_retrieve.h -text src/include/H5Fed_store.h -text src/include/H5Fed_tags.h -text src/include/H5Part.h -text +src/include/H5_attachments.h -text src/include/H5_attribs.h -text src/include/H5hut.h -text src/include/grephdr -text +src/include/h5core/h5_attach.h -text src/include/h5core/h5_attribs.h -text src/include/h5core/h5_core.h -text src/include/h5core/h5_errno.h -text diff --git a/src/C/H5.c b/src/C/H5.c index 6fee39c..b29d862 100644 --- a/src/C/H5.c +++ b/src/C/H5.c @@ -320,8 +320,7 @@ H5ReportErrorhandler ( const char* fmt, va_list ap ) { - H5_API_ENTER (h5_err_t); - H5_API_RETURN (h5_report_errorhandler (fmt, ap)); + return h5_report_errorhandler (fmt, ap); } h5_err_t @@ -329,8 +328,7 @@ H5AbortErrorhandler ( const char* fmt, va_list ap ) { - H5_API_ENTER (h5_err_t); - H5_API_RETURN (h5_abort_errorhandler (fmt, ap)); + return h5_abort_errorhandler (fmt, ap); } /*! @@ -342,10 +340,9 @@ H5AbortErrorhandler ( */ h5_err_t H5GetErrno ( - h5_file_t* const f + void ) { - H5_API_ENTER (h5_err_t); - H5_API_RETURN (h5_get_errno ()); + return h5_get_errno (); } diff --git a/src/C/H5Fed.c b/src/C/H5Fed.c index db9d53b..5fa1918 100644 --- a/src/C/H5Fed.c +++ b/src/C/H5Fed.c @@ -47,6 +47,7 @@ H5FedLinkMeshToStep ( h5_file_t* const f, const h5_id_t mesh_id ) { + UNUSED_ARGUMENT (f); UNUSED_ARGUMENT (mesh_id); H5_API_ENTER (h5_err_t); H5_API_RETURN (h5_error_not_implemented ()); diff --git a/src/C/H5_attachments.c b/src/C/H5_attachments.c new file mode 100644 index 0000000..4fd97ac --- /dev/null +++ b/src/C/H5_attachments.c @@ -0,0 +1,157 @@ +#include "h5core/h5_core.h" +#include "H5hut.h" + +h5_ssize_t +H5GetNumAttachments ( + h5_file_t* const f /*!< [in] Handle to open file */ + ) { + H5_API_ENTER (h5_ssize_t); + H5_API_RETURN (h5_get_num_attachments (f)); +} + +h5_err_t +H5GetAttachmentInfoByIdx ( + h5_file_t* const f, + const h5_size_t idx, // IN + char* const name, // OUT + h5_size_t len_name, // IN + h5_int64_t* const type, // OUT + h5_size_t* const npoints // OUT + ) { + H5_API_ENTER5 (h5_err_t, "idx=%llu, name=0x%p, len_name=%llu, type=0x%p, npoints=0x%p", + idx, name, len_name, type, npoints); + H5_API_RETURN (h5_get_attachment_info_by_idx ( + f, idx, name, len_name, type, npoints)); +} + +h5_err_t +H5GetAttachmentInfoByName ( + h5_file_t* const f, + char* const name, // OUT + h5_int64_t* const type, // OUT + h5_size_t* const npoints // OUT + ) { + H5_API_ENTER3 (h5_err_t, "name=\"%s\", type=0x%p, npoints=0x%p", + name, type, npoints); + H5_API_RETURN (h5_get_attachment_info_by_name ( + f, name, type, npoints)); +} + +h5_err_t +H5WriteAttachmentBitstream ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + const void* const content, /*!< [in] Value of attribute */ + const h5_size_t size + ) { + H5_API_ENTER3 (h5_err_t, "name=\"%s\", content=0x%p, size=%llu", + name, content, (unsigned long long)size); + H5_API_RETURN (h5_write_attachment (f, name, H5T_NATIVE_CHAR, content, size)); +} + +h5_err_t +H5WriteAttachmentFloat32 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + const void* const content, /*!< [in] Value of attribute */ + const h5_size_t size + ) { + H5_API_ENTER3 (h5_err_t, "name=\"%s\", content=0x%p, size=%llu", + name, content, (unsigned long long)size); + H5_API_RETURN (h5_write_attachment (f, name, H5T_NATIVE_FLOAT, content, size)); +} + +h5_err_t +H5WriteAttachmentFloat64 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + const void* const content, /*!< [in] Value of attribute */ + const h5_size_t size + ) { + H5_API_ENTER3 (h5_err_t, "name=\"%s\", content=0x%p, size=%llu", + name, content, (unsigned long long)size); + H5_API_RETURN (h5_write_attachment (f, name, H5T_NATIVE_DOUBLE, content, size)); +} + +h5_err_t +H5WriteAttachmentInt32 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + const void* const content, /*!< [in] Value of attribute */ + const h5_size_t size + ) { + H5_API_ENTER3 (h5_err_t, "name=\"%s\", content=0x%p, size=%llu", + name, content, (unsigned long long)size); + H5_API_RETURN (h5_write_attachment (f, name, H5T_NATIVE_INT32, content, size)); +} + +h5_err_t +H5WriteAttachmentInt64 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + const void* const content, /*!< [in] Value of attribute */ + const h5_size_t size + ) { + H5_API_ENTER3 (h5_err_t, "name=\"%s\", content=0x%p, size=%llu", + name, content, (unsigned long long)size); + H5_API_RETURN (h5_write_attachment (f, name, H5T_NATIVE_INT64, content, size)); +} + +h5_err_t +H5ReadAttachmentBitstream ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + void* const content /*!< [in] Value of attribute */ + ) { + H5_API_ENTER2 (h5_err_t, "name=\"%s\", content=0x%p", name, content); + H5_API_RETURN (h5_read_attachment (f, name, H5T_NATIVE_CHAR, content)); +} + +h5_err_t +H5ReadAttachmentFloat32 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + void* const content /*!< [in] Attachment */ + ) { + H5_API_ENTER2 (h5_err_t, "name=\"%s\", content=0x%p", name, content); + H5_API_RETURN (h5_read_attachment (f, name, H5T_NATIVE_FLOAT, content)); +} + +h5_err_t +H5ReadAttachmentFloat64 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + void* const content /*!< [out] Attachment */ + ) { + H5_API_ENTER2 (h5_err_t, "name=\"%s\", content=0x%p", name, content); + H5_API_RETURN (h5_read_attachment (f, name, H5T_NATIVE_DOUBLE, content)); +} + +h5_err_t +H5ReadAttachmentInt32 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + void* const content /*!< [out] Attachment */ + ) { + H5_API_ENTER2 (h5_err_t, "name=\"%s\", content=0x%p", name, content); + H5_API_RETURN (h5_read_attachment (f, name, H5T_NATIVE_INT32, content)); +} + +h5_err_t +H5ReadAttachmentInt64 ( + h5_file_t* const f, /*!< [in] Handle to open file */ + const char* name, /*!< [in] Name of attribute to create */ + void* const content /*!< [out] Attachment */ + ) { + H5_API_ENTER2 (h5_err_t, "name=\"%s\", content=0x%p", name, content); + H5_API_RETURN (h5_read_attachment (f, name, H5T_NATIVE_INT64, content)); +} + +h5_err_t +H5DeleteAttachment ( + h5_file_t* const f, + const char* const name + ) { + H5_API_ENTER1 (h5_err_t, "name=\"%s\"", name); + H5_API_RETURN (h5_delete_attachment (f, name)); +} diff --git a/src/C/Makefile.am b/src/C/Makefile.am index 26defe7..b907c24 100644 --- a/src/C/Makefile.am +++ b/src/C/Makefile.am @@ -16,6 +16,7 @@ include_HEADERS = \ ../include/H5hut.h \ ../include/H5.h \ ../include/H5_attribs.h \ + ../include/H5_attachments.h \ ../include/H5Part.h \ ../include/H5Block.h \ ../include/H5Block_readwrite.h \ @@ -33,6 +34,7 @@ EXTRA_HEADERS = libH5hutC_a_SOURCES = \ H5.c \ H5_attribs.c \ + H5_attachments.c \ H5Part.c \ H5Block.c \ H5Block_readwrite.c \ diff --git a/src/h5core/Makefile.am b/src/h5core/Makefile.am index 9233d8b..eb94a30 100644 --- a/src/h5core/Makefile.am +++ b/src/h5core/Makefile.am @@ -6,6 +6,7 @@ LIBS = @LIBS@ INCLUDES = -I../include @INCLUDES@ EXTRA_HEADERS = \ + ../include/h5core/h5_attach.h \ ../include/h5core/h5_attribs.h \ ../include/h5core/h5_core.h \ ../include/h5core/h5_errno.h \ @@ -74,6 +75,7 @@ EXTRA_LIBRARIES = libH5hut.a # Listing of sources libH5hut_a_SOURCES = \ + h5_attach.c \ h5_attribs.c \ h5_errorhandling.c \ h5_fcmp.c \ diff --git a/src/h5core/h5_attachments.c b/src/h5core/h5_attach.c similarity index 59% rename from src/h5core/h5_attachments.c rename to src/h5core/h5_attach.c index b8f2d21..92f2cea 100644 --- a/src/h5core/h5_attachments.c +++ b/src/h5core/h5_attach.c @@ -1,5 +1,6 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" +#include static hid_t open_space_all ( @@ -12,27 +13,28 @@ open_space_all ( } h5_err_t -h5_add_attachment ( +h5_write_attachment ( h5_file_t* const f, const char* const name, - h5_int64_t* const type, + const hid_t type, const char* const content, const h5_size_t size ) { - H5_CORE_API_ENTER2 (h5_ssize_t, - "name=\"%s\, type=%d, content=0x%p", - name, type, content); + H5_CORE_API_ENTER4 (h5_ssize_t, + "name=\"%s\", type=%ld, content=0x%p, size=%llu", + name, (long)type, content, (unsigned long long)size); // write only on proc 0 if (f->myproc != 0) { H5_CORE_API_LEAVE (H5_SUCCESS); } + hid_t group_id; TRY (group_id = h5priv_open_group (f, f->file, H5_ATTACHMENT)); + h5_err_t exists; TRY (exists = hdf5_link_exists (group_id, name)); if (exists > 0) { // warn user on overwrite h5_warn ("Dataset %s/%s already exists", hdf5_get_objname(group_id), name); - } h5_dsinfo_t dsinfo; strncpy (dsinfo.name, name, sizeof (dsinfo.name) - 1); @@ -57,13 +59,13 @@ static inline hid_t open_attachments ( h5_file_t* const f ) { - h5_err_t exists; - TRY (exists = hdf5_link_exists(f->file, H5_ATTACHMENT)); + h5_err_t exists = hdf5_link_exists (f->file, H5_ATTACHMENT); if (exists > 0) { return hdf5_open_group (f->file, H5_ATTACHMENT); - } else { + } else if (exists == 0) { return h5_warn ("No attachment group in file"); } + return exists; } h5_ssize_t @@ -85,54 +87,96 @@ h5_get_num_attachments ( h5_err_t h5_get_attachment_info_by_idx ( h5_file_t* const f, - const size_t idx, // IN + const h5_size_t idx, // IN char* const name, // OUT - size_t l_name, // IN + h5_size_t len_name, // IN h5_int64_t* const type, // OUT h5_size_t* const npoints // OUT ) { H5_CORE_API_ENTER0 (h5_err_t); - TRY (group_id = open_attachments (f)); - if (group_id < 0) { + hid_t loc_id; + TRY (loc_id = open_attachments (f)); + if (loc_id < 0) { // no attachment group in file H5_CORE_API_LEAVE (0); } - TRY (hdf5_get_dataset_info_by_idx (group_id, idx, name, l_name, type, npoints)); - TRY (hdf5_close_group (group_id)); - H5_CORE_API_RETURN (num); + TRY (hdf5_get_name_of_dataset_by_idx ( + loc_id, + idx, + name, len_name)); + + if (npoints) { + // get number of elements, do not change value on error + h5_ssize_t np; + TRY (np = hdf5_get_npoints_of_dataset_by_name (loc_id, name)); + *npoints = np; + } + if (type) { + // get normalized data type, do not change value on error + h5_int64_t t; + TRY (t = h5_get_dataset_type (loc_id, name)); + *type = t; + } + TRY (hdf5_close_group (loc_id)); + H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t h5_get_attachment_info_by_name ( h5_file_t* const f, - const char* const name, // IN - h5_int64_t* const type, // OUT - h5_size_t* const nelem // OUT + const char* const name, // IN + h5_int64_t* const type, // OUT + h5_size_t* const npoints // OUT + ) { + H5_CORE_API_ENTER3 (h5_err_t, + "name=\"%s\", type=0x%p, npoints=0x%p", + name, type, npoints); + + hid_t loc_id; + TRY (loc_id = open_attachments (f)); + if (loc_id < 0) { + H5_CORE_API_LEAVE (H5_NOK); + } + if (npoints) { + h5_ssize_t np; + TRY (np = hdf5_get_npoints_of_dataset_by_name (loc_id, name)); + *npoints = np; + } + + if (type) { + h5_int64_t t; + TRY (t = h5_get_dataset_type (loc_id, name)); + *type = t; + } + TRY (hdf5_close_group (loc_id)); + H5_CORE_API_RETURN (H5_SUCCESS); +} + +h5_err_t +h5_read_attachment ( + h5_file_t* const f, + const char* const name, + const hid_t type, + void* const content ) { H5_CORE_API_ENTER0 (h5_err_t); hid_t group_id; TRY (group_id = open_attachments (f)); - if (group_id < 0) { - H5_CORE_API_LEAVE (H5_NOK); - } - TRY (hdf5_get_dataset_info_by_name (group_id, idx, name, type, npoints)); + h5_dsinfo_t dsinfo; + strncpy (dsinfo.name, name, sizeof (dsinfo.name) - 1); + dsinfo.type_id = type; + TRY (h5priv_read_dataset_by_name ( + f, + group_id, + &dsinfo, + open_space_all, + open_space_all, + content)); TRY (hdf5_close_group (group_id)); H5_CORE_API_RETURN (H5_SUCCESS); } h5_err_t -h5_get_attachment ( - h5_file_t* const f, - const char* const name, - const hid_t type, - void* const content, - ) { - H5_CORE_API_ENTER0 (h5_err_t); - H5_CORE_API_RETURN (H5_SUCCESS); -} - - -h5_err_t -h5_remove_attachment ( +h5_delete_attachment ( h5_file_t* const f, const char* const name ) { diff --git a/src/h5core/h5_core_private.h b/src/h5core/h5_core_private.h index d5367d4..dab74e9 100644 --- a/src/h5core/h5_core_private.h +++ b/src/h5core/h5_core_private.h @@ -2,12 +2,15 @@ #define __H5_CORE_PRIVATE_H #define H5_CORE_API_ENTER(type) __FUNC_ENTER(type) +#define H5_CORE_API_ENTER0(type) __FUNC_ENTER(type) #define H5_CORE_API_ENTER1(type, fmt, a1) \ __FUNC_ENTER1(type, fmt, a1, H5_DEBUG_CORE_API) #define H5_CORE_API_ENTER2(type, fmt, a1, a2) \ __FUNC_ENTER2(type, fmt, a1, a2, H5_DEBUG_CORE_API) #define H5_CORE_API_ENTER3(type, fmt, a1, a2, a3) \ __FUNC_ENTER3(type, fmt, a1, a2, a3, H5_DEBUG_CORE_API) +#define H5_CORE_API_ENTER4(type, fmt, a1, a2, a3, a4) \ + __FUNC_ENTER4(type, fmt, a1, a2, a3, a4, H5_DEBUG_CORE_API) #define H5_CORE_API_LEAVE(value) __FUNC_LEAVE(value) #define H5_CORE_API_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_CORE_API) diff --git a/src/h5core/h5_hdf5.c b/src/h5core/h5_hdf5.c index b2a136b..c9bdd86 100644 --- a/src/h5core/h5_hdf5.c +++ b/src/h5core/h5_hdf5.c @@ -1598,62 +1598,6 @@ hdf5_get_name_of_dataset_by_idx ( HDF5_WRAPPER_RETURN (H5_SUCCESS); } -h5_err_t -hdf5_get_dataset_info_by_idx ( - const hid_t loc_id, /*!< [in] Group */ - const hsize_t idx, /*!< [in] Index of the dataset */ - char* const name, /*!< [out] Name of dataset */ - const size_t len_name, /*!< [in] Size of buffer \c name */ - h5_int64_t* const type, /*!< [out] Type of data in dataset */ - hsize_t* const npoints /*!< [out] Number of elements. */ - ) { - HDF5_WRAPPER_ENTER5 (h5_err_t, - "loc_id=%d (%s), idx=%llu, name=0x%p, len_name=%llu", - loc_id, hdf5_get_objname (loc_id), - idx, name, (unsigned long long)len_name); - - TRY (hdf5_get_name_of_dataset_by_idx (loc_id, idx, name, len_name)); - - if (npoints) { - h5_ssize_t np; - TRY (np = hdf5_get_npoints_of_dataset_by_name (loc_id, name)); - *npoints = np; - } - - if (type) { - h5_int64_t t; - TRY (t = h5_get_dataset_type (loc_id, name)); - *type = t; - } - H5_CORE_API_RETURN (H5_SUCCESS); -} - -h5_err_t -hdf5_get_dataset_info_by_name ( - const hid_t loc_id, /*!< [in] Group */ - const hsize_t idx, /*!< [in] Index of the dataset */ - const char* name, /*!< [in] Name of dataset */ - h5_int64_t* const type, /*!< [out] Type of data in dataset */ - hsize_t* const npoints /*!< [out] Number of elements. */ - ) { - HDF5_WRAPPER_ENTER4 (h5_err_t, - "loc_id=%d (%s), idx=%llu, name=\"%s\"", - loc_id, hdf5_get_objname (loc_id), - idx, name); - if (npoints) { - h5_ssize_t np; - TRY (np = hdf5_get_npoints_of_dataset_by_name (loc_id, name)); - *npoints = np; - } - - if (type) { - h5_int64_t t; - TRY (t = h5_get_dataset_type (loc_id, name)); - *type = t; - } - H5_CORE_API_RETURN (H5_SUCCESS); -} - /****** I d e n t i f i e r **************************************************/ const char * diff --git a/src/h5core/h5_hdf5_private.h b/src/h5core/h5_hdf5_private.h index cb66e2f..b2e263b 100644 --- a/src/h5core/h5_hdf5_private.h +++ b/src/h5core/h5_hdf5_private.h @@ -377,13 +377,4 @@ hdf5_delete_link ( hid_t lapl_id ); -/*** other ***/ -h5_err_t -hdf5_get_dataset_info_by_name ( - const hid_t loc_id, - const hsize_t idx, - const char* name, - h5_int64_t* const type, - hsize_t* const npoints - ); #endif diff --git a/src/h5core/h5u_model.c b/src/h5core/h5u_model.c index cd0ee79..4d4e4c1 100644 --- a/src/h5core/h5u_model.c +++ b/src/h5core/h5u_model.c @@ -408,24 +408,39 @@ h5u_get_num_datasets ( /*! Get information about dataset in current index given by its index - */ +*/ h5_err_t h5u_get_dataset_info ( - h5_file_t* const f, /*!< [in] Handle to open file */ - const h5_id_t idx, /*!< [in] Index of the dataset */ - char* const dset_name, /*!< [out] Name of dataset */ - const h5_size_t len_dset_name, /*!< [in] Size of buffer \c dset_name */ - h5_int64_t* const type, /*!< [out] Type of data in dataset */ - h5_size_t* const npoints /*!< [out] Number of elements. */ + h5_file_t *const f, /*!< [in] Handle to open file */ + const h5_id_t idx, /*!< [in] Index of the dataset */ + char *dataset_name, /*!< [out] Name of dataset */ + const h5_size_t len_dataset_name, + /*!< [in] Size of buffer \c dataset_name */ + h5_int64_t *type, /*!< [out] Type of data in dataset */ + h5_size_t *nelem /*!< [out] Number of elements. */ ) { H5_CORE_API_ENTER (h5_err_t); - H5_CORE_API_RETURN ( - hdf5_get_dataset_info_by_idx ( - f->step_gid, - idx, - dset_name, len_dset_name, - type, npoints)); -} + TRY (hdf5_get_name_of_dataset_by_idx ( + f->step_gid, + idx, + dataset_name, len_dataset_name) ); + + if ( nelem ) { + h5_ssize_t nelem_; + TRY (nelem_ = hdf5_get_npoints_of_dataset_by_name ( + f->step_gid, + dataset_name) ); + if ( nelem_ < 0 ) return nelem_; + *nelem = nelem_; + } + + if ( type ) { + *type = h5_get_dataset_type (f->step_gid, dataset_name); + if ( *type < 0 ) return *type; + } + + H5_CORE_API_RETURN (H5_SUCCESS); +} h5_err_t h5u_set_chunk ( diff --git a/src/include/H5.h b/src/include/H5.h index 4db566a..ebc7f0a 100644 --- a/src/include/H5.h +++ b/src/include/H5.h @@ -119,7 +119,7 @@ H5AbortErrorhandler ( h5_err_t H5GetErrno ( - h5_file_t * const f + void ); #ifdef PARALLEL_IO diff --git a/src/include/H5_attachments.h b/src/include/H5_attachments.h new file mode 100644 index 0000000..9137203 --- /dev/null +++ b/src/include/H5_attachments.h @@ -0,0 +1,108 @@ +#ifndef __H5_ATTACHMENTS_H +#define __H5_ATTACHMENTS_H + +h5_ssize_t +H5GetNumAttachments ( + h5_file_t* const f + ); + +h5_err_t +H5GetAttachmentInfoByIdx ( + h5_file_t* const f, + const h5_size_t idx, + char* const name, + h5_size_t len_name, + h5_int64_t* const type, + h5_size_t* const npoints + ); + +h5_err_t +H5GetAttachmentInfoByName ( + h5_file_t* const f, + char* const name, + h5_int64_t* const type, + h5_size_t* const npoints + ); + +h5_err_t +H5WriteAttachmentBitstream ( + h5_file_t* const f, + const char* name, + const void* const content, + const h5_size_t size + ); + +h5_err_t +H5WriteAttachmentFloat32 ( + h5_file_t* const f, + const char* name, + const void* const content, + const h5_size_t size + ); + +h5_err_t +H5WriteAttachmentFloat64 ( + h5_file_t* const f, + const char* name, + const void* const content, + const h5_size_t size + ); + +h5_err_t +H5WriteAttachmentInt32 ( + h5_file_t* const f, + const char* name, + const void* const content, + const h5_size_t size + ); + +h5_err_t +H5WriteAttachmentInt64 ( + h5_file_t* const f, + const char* name, + const void* const content, + const h5_size_t size + ); + +h5_err_t +H5ReadAttachmentBitstream ( + h5_file_t* const f, + const char* name, + void* const content + ); + +h5_err_t +H5ReadAttachmentFloat32 ( + h5_file_t* const f, + const char* name, + void* const content + ); + +h5_err_t +H5ReadAttachmentFloat64 ( + h5_file_t* const f, + const char* name, + void* const content + ); + +h5_err_t +H5ReadAttachmentInt32 ( + h5_file_t* const f, + const char* name, + void* const content + ); + +h5_err_t +H5ReadAttachmentInt64 ( + h5_file_t* const f, + const char* name, + void* const content + ); + +h5_err_t +H5DeleteAttachment ( + h5_file_t* const f, + const char* const name + ); + +#endif diff --git a/src/include/H5hut.h b/src/include/H5hut.h index 4c5c550..c4400b7 100644 --- a/src/include/H5hut.h +++ b/src/include/H5hut.h @@ -8,6 +8,7 @@ extern "C" { #include "h5core/h5_core.h" #include "H5.h" #include "H5_attribs.h" +#include "H5_attachments.h" #include "H5Part.h" #include "H5Block.h" #include "H5Block_readwrite.h" diff --git a/src/include/h5core/h5_attach.h b/src/include/h5core/h5_attach.h new file mode 100644 index 0000000..025eef7 --- /dev/null +++ b/src/include/h5core/h5_attach.h @@ -0,0 +1,50 @@ +#ifndef __H5_ATTACH_H +#define __H5_ATTACH_H + +h5_err_t +h5_write_attachment ( + h5_file_t* const f, + const char* const name, + const hid_t type, + const char* const content, + const h5_size_t size + ); + +h5_ssize_t +h5_get_num_attachments ( + h5_file_t* const f + ); + +h5_err_t +h5_get_attachment_info_by_idx ( + h5_file_t* const f, + const h5_size_t idx, // IN + char* const name, // OUT + h5_size_t len_name, // IN + h5_int64_t* const type, // OUT + h5_size_t* const npoints // OUT + ); + +h5_err_t +h5_get_attachment_info_by_name ( + h5_file_t* const f, + const char* const name, // IN + h5_int64_t* const type, // OUT + h5_size_t* const npoints // OUT + ); + +h5_err_t +h5_read_attachment ( + h5_file_t* const f, + const char* const name, + const hid_t type, + void* const content + ); + +h5_err_t +h5_delete_attachment ( + h5_file_t* const f, + const char* const name + ); + +#endif diff --git a/src/include/h5core/h5_core.h b/src/include/h5core/h5_core.h index 21623fb..8365ed6 100644 --- a/src/include/h5core/h5_core.h +++ b/src/include/h5core/h5_core.h @@ -14,13 +14,13 @@ #define H5_DEBUG_ALL (-1) extern char* h5_rfmts[]; -#define __FUNC_ENTER(type) \ +#define __FUNC_ENTER(type) \ h5_call_stack_push (__func__,e_##type); \ type ret_value = (type)H5_ERR; -#define __FUNC_ARGS0(mask) \ +#define __FUNC_ARGS0(mask) \ if (h5_debug_level & mask ) { \ - h5_debug ("(void)"); \ + h5_debug ("(void)"); \ } #define __FUNC_ARGS1(fmt, a1, mask) \ @@ -69,7 +69,7 @@ extern char* h5_rfmts[]; __FUNC_ARGS4(fmt, a1, a2, a3, a4, mask); #define __FUNC_ENTER5(type, fmt, a1, a2, a3, a4, a5, mask) \ - __FUNC_ENTER(type); \ + __FUNC_ENTER(type); \ __FUNC_ARGS5(fmt, a1, a2, a3, a4, a5, mask); #define __FUNC_LEAVE(expr) { \ @@ -80,8 +80,8 @@ extern char* h5_rfmts[]; #define __FUNC_RETURN(expr, mask) \ ret_value = expr; \ goto done; \ -done: \ - if (h5_debug_level & mask ) { \ +done: \ + if (h5_debug_level & mask ) { \ char fmt[256]; \ snprintf (fmt, sizeof(fmt), "return: %s", \ h5_rfmts[h5_call_stack_get_type()]); \ @@ -109,6 +109,14 @@ done: \ H5_API_ENTER(type); \ __FUNC_ARGS3(fmt, a1,a2,a3, H5_DEBUG_API) +#define H5_API_ENTER4(type, fmt, a1, a2, a3, a4) \ + H5_API_ENTER(type); \ + __FUNC_ARGS4(fmt, a1,a2,a3, a4, H5_DEBUG_API) + +#define H5_API_ENTER5(type, fmt, a1, a2, a3, a4, a5) \ + H5_API_ENTER(type); \ + __FUNC_ARGS5(fmt, a1,a2,a3, a4, a5, H5_DEBUG_API) + #define H5_API_LEAVE(expr) __FUNC_LEAVE(expr) #define H5_API_RETURN(expr) __FUNC_RETURN(expr, H5_DEBUG_API); @@ -135,6 +143,7 @@ done: \ #include "h5_types.h" #include "h5_errno.h" +#include "h5_attach.h" #include "h5_attribs.h" #include "h5_hdf5.h" #include "h5_maps.h" diff --git a/src/include/h5core/h5_hdf5.h b/src/include/h5core/h5_hdf5.h index d11d9f0..4f59a89 100644 --- a/src/include/h5core/h5_hdf5.h +++ b/src/include/h5core/h5_hdf5.h @@ -33,16 +33,6 @@ hdf5_get_name_of_dataset_by_idx ( size_t len ); -h5_err_t -hdf5_get_dataset_info_by_idx ( - const hid_t loc_id, - const hsize_t idx, - char* const name, - const size_t len_name, - h5_int64_t* const type, - hsize_t* const npoints - ); - const char * hdf5_get_objname ( hid_t id