/usr/share/doc/libhdf4-doc/examples/c/SD_create_sds.c is in libhdf4-doc 4.2.12-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #include "mfhdf.h"
#define FILE_NAME "SDS.hdf"
#define SDS_NAME "SDStemplate"
#define X_LENGTH 5
#define Y_LENGTH 16
#define RANK 2 /* Number of dimensions of the SDS */
int main()
{
/************************* Variable declaration **************************/
int32 sd_id, sds_id; /* SD interface and data set identifiers */
int32 dim_sizes[2]; /* sizes of the SDS dimensions */
intn status; /* status returned by some routines; has value
SUCCEED or FAIL */
/********************* End of variable declaration ***********************/
/*
* Create the file and initialize the SD interface.
*/
sd_id = SDstart (FILE_NAME, DFACC_CREATE);
/*
* Define the dimensions of the array to be created.
*/
dim_sizes[0] = Y_LENGTH;
dim_sizes[1] = X_LENGTH;
/*
* Create the data set with the name defined in SDS_NAME. Note that
* DFNT_INT32 indicates that the SDS data is of type int32. Refer to
* Table 2F, "Standard HDF Data Types and Flags," for definitions of
* other types.
*/
sds_id = SDcreate (sd_id, SDS_NAME, DFNT_INT32, RANK, dim_sizes);
/*
* Terminate access to the data set.
*/
status = SDendaccess (sds_id);
/*
* Terminate access to the SD interface and close the file.
*/
status = SDend (sd_id);
return 0;
}
|