Commit babd19dd authored by gsell's avatar gsell

core API:

- add checks for file-handle and opened step
parent c80f6f56
......@@ -30,6 +30,7 @@ h5_add_attachment (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname);
CHECK_FILEHANDLE (f);
// allowed file modes: O_RDWR, O_WRONLY; O_APPEND
if (f->props->flags & H5_O_RDONLY) {
H5_LEAVE (
......@@ -130,6 +131,7 @@ h5_has_attachments (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
CHECK_FILEHANDLE (f);
TRY (ret_value = hdf5_link_exists (f->file, H5_ATTACHMENT));
H5_RETURN (ret_value);
}
......@@ -140,6 +142,7 @@ h5_get_num_attachments (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
CHECK_FILEHANDLE (f);
h5_err_t exists;
TRY (exists = hdf5_link_exists (f->file, H5_ATTACHMENT));
if (exists == 0) {
......@@ -166,6 +169,7 @@ h5_get_attachment_info_by_idx (
f, (unsigned long long)idx,
fname, (unsigned long long)len_fname,
fsize);
CHECK_FILEHANDLE (f);
hid_t loc_id;
TRY (loc_id = hdf5_open_group (f->file, H5_ATTACHMENT));
TRY (hdf5_get_name_of_dataset_by_idx (
......@@ -190,6 +194,7 @@ h5_has_attachment (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname);
CHECK_FILEHANDLE (f);
hid_t loc_id;
TRY (loc_id = hdf5_open_group (f->file, H5_ATTACHMENT));
TRY (ret_value = hdf5_link_exists (f->file, fname));
......@@ -204,7 +209,8 @@ h5_get_attachment_info_by_name (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s', fsize=%p", f, fname, fsize);
CHECK_FILEHANDLE (f);
hid_t loc_id;
TRY (loc_id = hdf5_open_group (f->file, H5_ATTACHMENT));
if (fsize) {
......@@ -224,6 +230,7 @@ h5_get_attachment (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname);
CHECK_FILEHANDLE (f);
// allowed modes: O_RDWR, O_RDONLY; O_APPEND
// forbidden modes: O_WRONLY
if (f->props->flags & H5_O_WRONLY) {
......@@ -310,6 +317,7 @@ h5_delete_attachment (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname);
CHECK_FILEHANDLE (f);
// allowed file modes: O_RDWR, O_WRONLY; O_APPEND
if (f->props->flags & H5_O_RDONLY) {
H5_LEAVE (
......
......@@ -43,6 +43,7 @@ h5_has_step_attrib (
f,
attrib_name);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
TRY (ret_value = hdf5_attribute_exists (f->step_gid, attrib_name));
H5_RETURN (ret_value);
}
......
......@@ -37,6 +37,7 @@ h5_set_step (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, step_idx=%lld",
f, (long long)step_idx);
CHECK_FILEHANDLE (f);
TRY (h5priv_close_step (f));
f->step_idx = step_idx;
......@@ -69,6 +70,7 @@ h5_has_step (
) {
h5_file_p f = (h5_file_p)f_;
H5_CORE_API_ENTER (h5_err_t, "f=%p, step_idx=%lld", f, (long long)step_idx);
CHECK_FILEHANDLE (f);
char name[2*H5_STEPNAME_LEN];
sprintf (name,
"%s#%0*lld",
......
......@@ -256,8 +256,9 @@ h5b_write_scalar_data (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, field_name='%s', data=%p, type=%lld",
f, field_name, data, (long long int)type);
CHECK_TIMEGROUP (f);
CHECK_FILEHANDLE (f);
CHECK_WRITABLE_MODE (f);
CHECK_TIMEGROUP (f);
CHECK_LAYOUT (f);
TRY( h5bpriv_create_field_group(f, field_name) );
......@@ -284,9 +285,10 @@ h5b_write_vector3d_data (
"zdata=%p, "
"type=%lld",
f, field_name, xdata, ydata, zdata, (long long int)type);
CHECK_TIMEGROUP( f );
CHECK_WRITABLE_MODE( f );
CHECK_LAYOUT( f );
CHECK_FILEHANDLE (f);
CHECK_WRITABLE_MODE (f);
CHECK_TIMEGROUP (f);
CHECK_LAYOUT (f);
TRY( h5bpriv_create_field_group(f, field_name) );
TRY( _select_hyperslab_for_writing(f) );
......@@ -416,8 +418,9 @@ h5b_read_scalar_data (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, field_name='%s', data=%p, type=%lld",
f, field_name, data, (long long int)type);
CHECK_TIMEGROUP( f );
CHECK_LAYOUT( f );
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
CHECK_LAYOUT (f);
TRY( h5bpriv_open_field_group(f, field_name) );
TRY( read_data(f, H5_BLOCKNAME_X, data, type) );
......@@ -442,8 +445,9 @@ h5b_read_vector3d_data (
"zdata=%p, "
"type=%lld",
f, field_name, xdata, ydata, zdata, (long long int)type);
CHECK_TIMEGROUP( f );
CHECK_LAYOUT( f );
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
CHECK_LAYOUT (f);
TRY( h5bpriv_open_field_group(f, field_name) );
TRY( read_data(f, H5_BLOCKNAME_X, xdata, type) );
......
......@@ -86,6 +86,7 @@ h5u_read_data (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, name='%s', data=%p, type=%lld",
f, name, data, (long long int)type);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
hid_t hdf5_type;
......@@ -186,8 +187,9 @@ h5u_write_data (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, name='%s', data=%p, type=%lld",
f, name, data, (long long int)type);
CHECK_TIMEGROUP( f );
CHECK_WRITABLE_MODE( f );
CHECK_FILEHANDLE (f);
CHECK_WRITABLE_MODE (f);
CHECK_TIMEGROUP (f);
hid_t hdf5_type;
TRY (hdf5_type = h5priv_map_enum_to_normalized_type (type));
......
......@@ -27,6 +27,8 @@ h5u_get_num_points (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
h5_ssize_t nparticles;
if (h5u_has_view ((h5_file_t)f)) {
......@@ -47,6 +49,8 @@ h5u_get_num_points_in_view (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
h5_ssize_t nparticles;
if (!h5u_has_view (fh)) {
......@@ -69,6 +73,8 @@ h5u_get_totalnum_particles_by_name (
H5_CORE_API_ENTER (h5_ssize_t,
"f=%p, dataset_name=%s",
f, dataset_name);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
h5_ssize_t nparticles;
TRY (nparticles = hdf5_get_npoints_of_dataset_by_name (
f->step_gid, dataset_name));
......@@ -84,6 +90,8 @@ h5u_get_totalnum_particles_by_idx (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p, idx=%lld", f, (long long)idx);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
char dataset_name[H5_DATANAME_LEN];
dataset_name[0] = '\0';
h5_err_t h5err;
......@@ -113,6 +121,8 @@ h5u_set_num_points (
"f=%p, nparticles=%llu, stride=%llu",
f, (long long unsigned)nparticles,
(long long unsigned)stride);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
struct h5u_fdata *u = f->u;
hsize_t start;
hsize_t dmax = H5S_UNLIMITED;
......@@ -222,6 +232,8 @@ h5u_has_view (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
H5_RETURN (f->u->viewindexed || f->u->viewstart >= 0);
}
......@@ -231,6 +243,8 @@ h5u_reset_view (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
struct h5u_fdata *u = f->u;
u->viewstart = -1;
......@@ -259,6 +273,8 @@ h5u_set_view (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, start=%lld, end=%lld",
f, (long long)start, (long long)end);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
hsize_t total = 0;
hsize_t dmax = H5S_UNLIMITED;
struct h5u_fdata *u = f->u;
......@@ -376,6 +392,8 @@ h5u_set_view_length (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, start=%lld, length=%lld",
f, (long long)start, (long long)length);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
struct h5u_fdata *u = f->u;
TRY (h5u_reset_view (fh));
......@@ -448,7 +466,7 @@ h5u_set_view_indices (
if (f->step_gid < 0) {
TRY (h5_set_step (fh, 0));
}
CHECK_TIMEGROUP (f);
hsize_t total = 0;
hsize_t dmax = H5S_UNLIMITED;
struct h5u_fdata *u = f->u;
......@@ -505,6 +523,8 @@ h5u_get_view (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, start=%p, end=%p",
f, start, end);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
struct h5u_fdata *u = f->u;
if ( u->viewindexed ) {
......@@ -540,6 +560,8 @@ h5u_set_canonical_view (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_int64_t, "f=%p", f);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
h5u_fdata_t* u = f->u;
TRY( h5u_reset_view (fh) );
......@@ -576,6 +598,8 @@ h5u_get_num_datasets (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
TRY (ret_value = hdf5_get_num_datasets (f->step_gid));
H5_RETURN (ret_value);
}
......@@ -589,6 +613,8 @@ h5u_has_dataset (
H5_CORE_API_ENTER (h5_err_t,
"f=%p, name='%s'",
f, name);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
TRY (ret_value = hdf5_link_exists (f->step_gid, name));
H5_RETURN (ret_value);
}
......@@ -671,6 +697,7 @@ h5u_get_dataset_info_by_idx (
(long long unsigned)len_dataset_name,
dataset_type, dataset_nelem);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
TRY (h5priv_get_dataset_info_by_idx (
f->step_gid,
idx,
......@@ -719,6 +746,7 @@ h5u_get_dataset_info_by_name (
dataset_name,
dataset_type, dataset_nelem);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
TRY (h5priv_get_dataset_info_by_name (
f->step_gid,
dataset_name,
......@@ -736,6 +764,8 @@ h5u_set_chunk (
h5_int64_t,
"f=%p, size=%llu",
f, (long long unsigned)size);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
if (size == 0) {
h5_info ("Disabling chunking" );
TRY (hdf5_set_layout_property (
......@@ -756,6 +786,8 @@ h5u_get_chunk (
) {
h5_file_p f = (h5_file_p)fh;
H5_CORE_API_ENTER (h5_int64_t, "f=%p, name='%s', size=%p", f,name,size);
CHECK_FILEHANDLE (f);
CHECK_TIMEGROUP (f);
hid_t dataset_id;
hid_t plist_id;
hsize_t hsize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment