Download HDF4 User's Guide
Transcript
HDF User’s Guide
/********************** End of variable declaration **********************/
/*
* Open the HDF file.
*/
file_id = Hopen (FILE_NAME, DFACC_READ, 0);
/*
* Initialize the GR interface.
*/
gr_id = GRstart (file_id);
/*
* Determine the number of attributes in the file.
*/
status = GRfileinfo (gr_id, &n_rimages, &n_file_attrs);
if (status != FAIL && n_file_attrs > 0)
{
for (f_att_index = 0; f_att_index < n_file_attrs; f_att_index++)
{
/*
* Get information about the current file attribute.
*/
status = GRattrinfo (gr_id, f_att_index, attr_name, &data_type,
&n_values);
/*
* Allocate a buffer to hold the file attribute data. In this example,
* knowledge about the data type is assumed to be available from
* the previous example for simplicity. In reality, the size
* of the type must be determined based on the machine where the
* program resides.
*/
if (data_type == DFNT_CHAR8)
{
data_buf = malloc (n_values * sizeof (char8));
if (data_buf == NULL)
{
printf ("Unable to allocate space for attribute data.\n");
exit (1);
}
}
else
{
printf ("Unable to determine data type to allocate data buffer.\n");
exit (1);
}
/*
* Read and display the attribute values.
*/
status = GRgetattr (gr_id, f_att_index, (VOIDP)data_buf);
char_ptr = (char8 *) data_buf;
printf ("Attribute %s: ", attr_name);
for (value_index = 0; value_index < n_values; value_index++)
printf ("%c", char_ptr[value_index]);
printf ("\n");
/*
* Free the space allocated for the data buffer.
*/
December 2007
8-309
Related documents
Memorex LOCK - VERSION 2-24 Specifications
HDF-EOS Library User's Guide for the ECS Project, Volume 1
AZGCORR - Airborne Research & Survey Facility
EO-1/ Hyperion Science Data User's Guide
Gamma-Ray Identification of Nuclear Weapon Materials
Sharp IM-MT899H User's Manual
Sharp TINSE0568AWZZ Specifications
Sharp MD-MT888H Specifications