OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
rdattr.c
Go to the documentation of this file.
1 /*****************************************************************
2  * File: rdattr
3  *
4  * Purpose: read global attributes from an HDF file
5  *
6  * Description: string arrays of label/value pairs read from the
7  * HDF file.
8  *
9  * Input parms:
10  * char *filename HDF file name basename (extension '.hdf' added)
11  *
12  * Output parms:
13  * GLOBAL struct char *annot - array of header labels and values read
14  *
15  * Returns: -1 on failure, 0 on success
16  *
17  * Subs called: HDF library routines
18  *
19  * History: based on DAAC "Metadata Submission Guide" 2/93
20  *
21  * Author: Brian D. Schieber, GSC, 2/93
22  *
23  * Notes: Uses header file (*.h) descriptors for maximum label,
24  * value and filename lengths.
25  *
26  * Mod history:
27  * BDS, 9/1/93 - modified to support new HDF formats.
28  *
29  *****************************************************************/
30 
31 #include <mfhdf.h>
32 #include "ancil.h"
33 
34 int rdattr(char *filename) {
35 
36  /*
37  * local variables
38  */
39 
40  int32 dfile;
41  int status;
42  int attnum;
43  char name[50];
44  int32 nt;
45  int32 count = 0;
46 
47  /**** open header file ***/
48 
49  dfile = SDstart(filename, DFACC_RDONLY);
50  if (dfile == FAIL) return -1;
51 
52  /**** read the first label and description ******/
53 
54  attnum = 1;
55  status = SDattrinfo(dfile, attnum, name, &nt, &count);
56  if (status < 0) printf("< 0 status from SDattrinfo\n");
57  if (status < 0) return (-1);
58 
59  printf("SDattrinfo returned:\n");
60  printf("attnum: %d\n", attnum);
61  printf("name: [%s]\n", name);
62  printf("nt: %d\n", nt);
63  printf("count: %d\n", count);
64 
65 #if 0
66  /****** read the rest of the labels and descriptions *******/
67 
68  while (llength >= 0) {
69  llength = DFANgetfidlen(dfile, NOTFIRST);
70  if (llength > 0) {
71  count++;
72  lreturn = DFANgetfid(dfile, annot[count].label, MAXLABLEN, NOTFIRST);
73 
74  dlength = DFANgetfdslen(dfile, NOTFIRST);
75 
76  dreturn = DFANgetfds(dfile, annot[count].descr, MAXDESCLEN, NOTFIRST);
77  }
78  }
79 
80  SDend(dfile);
81  if (result < 0) return (-1);
82 #endif
83 
84  return 0;
85 
86 } /* rdattr */
87 
int status
Definition: l1_czcs_hdf.c:32
#define FAIL
Definition: ObpgReadGrid.h:18
int rdattr(char *filename)
Definition: rdattr.c:34
#define MAXDESCLEN
Definition: ancil.h:42
char descr[MAXDESCLEN]
Definition: ancil.h:72
#define MAXLABLEN
Definition: ancil.h:41
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
#define NOTFIRST
Definition: ancil.h:27
struct annotation * annot
int count
Definition: decode_rs.h:79