summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-10-04 15:06:28 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-10-04 15:06:28 (GMT)
commit59b51a2ea72ff98586372a454adfd8c790a62734 (patch)
tree74173cf2dab79097c9dc8f116a22ad0138d310a2 /examples
parent302830e60108513d9ff2e710444dc0d0188c92ee (diff)
downloadhdf5-59b51a2ea72ff98586372a454adfd8c790a62734.zip
hdf5-59b51a2ea72ff98586372a454adfd8c790a62734.tar.gz
hdf5-59b51a2ea72ff98586372a454adfd8c790a62734.tar.bz2
[svn-r14180] Description:
Make H5Aiterate() versioned and change all internal use to H5Aiterate2() Leave some regression tests that exercise H5Aiterate1() Fix attribute display in h5dump & h5ls to be "by name" by default Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'examples')
-rw-r--r--examples/h5_attribute.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/examples/h5_attribute.c b/examples/h5_attribute.c
index e0549dd..4f55998 100644
--- a/examples/h5_attribute.c
+++ b/examples/h5_attribute.c
@@ -40,7 +40,7 @@
#define ANAME "Float attribute" /* Name of the array attribute */
#define ANAMES "Character attribute" /* Name of the string attribute */
-herr_t attr_info(hid_t loc_id, const char *name, void *opdata);
+static herr_t attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata);
/* Operator function */
int
@@ -209,7 +209,7 @@ main (void)
/*
* Get attribute info using iteration function.
*/
- ret = H5Aiterate(dataset, NULL, attr_info, NULL);
+ ret = H5Aiterate2(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, NULL, attr_info, NULL, H5P_DEFAULT);
/*
* Close the dataset and the file.
@@ -223,8 +223,8 @@ main (void)
/*
* Operator function.
*/
-herr_t
-attr_info(hid_t loc_id, const char *name, void *opdata)
+static herr_t
+attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata)
{
hid_t attr, atype, aspace; /* Attribute, datatype and dataspace identifiers */
int rank;
@@ -245,9 +245,7 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
/*
* Display attribute name.
*/
- printf("\n");
- printf("Name : ");
- puts(name);
+ printf("\nName : %s\n", name);
/*
* Get attribute datatype, dataspace, rank, and dimensions.
@@ -262,10 +260,11 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
*/
if(rank > 0) {
- printf("Rank : %d \n", rank);
- printf("Dimension sizes : ");
- for (i=0; i< rank; i++) printf("%d ", (int)sdim[i]);
- printf("\n");
+ printf("Rank : %d \n", rank);
+ printf("Dimension sizes : ");
+ for (i=0; i< rank; i++)
+ printf("%d ", (int)sdim[i]);
+ printf("\n");
}
/*
@@ -273,14 +272,15 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
*/
if (H5T_FLOAT == H5Tget_class(atype)) {
- printf("Type : FLOAT \n");
- npoints = H5Sget_simple_extent_npoints(aspace);
- float_array = (float *)malloc(sizeof(float)*(int)npoints);
- ret = H5Aread(attr, atype, float_array);
- printf("Values : ");
- for( i = 0; i < (int)npoints; i++) printf("%f ", float_array[i]);
- printf("\n");
- free(float_array);
+ printf("Type : FLOAT \n");
+ npoints = H5Sget_simple_extent_npoints(aspace);
+ float_array = (float *)malloc(sizeof(float)*(int)npoints);
+ ret = H5Aread(attr, atype, float_array);
+ printf("Values : ");
+ for( i = 0; i < (int)npoints; i++)
+ printf("%f ", float_array[i]);
+ printf("\n");
+ free(float_array);
}
/*
@@ -292,3 +292,4 @@ attr_info(hid_t loc_id, const char *name, void *opdata)
return 0;
}
+