1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF.  The full HDF copyright notice, including       *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* $Id$ */
15 
16 #ifndef __HDP_H
17 #define __HDP_H
18 
19 #include "hdf.h"
20 #include "hfile.h"
21 
22 /* Global Variables (ick) */
23 #ifndef HDP_MASTER
24 extern
25 #endif							/* !HDP_MASTER */
26 intn        vinit_done
27 #ifdef HDP_MASTER
28 = FALSE							/* indicates Vsets have been init'ed for the current file */
29 #endif							/* HDP_MASTER */
30            ;
31 
32 /* Global Definitions */
33 #define MAXCHOICES 50
34 #ifndef MAXNAMELEN
35 #define MAXNAMELEN 100
36 #endif /* !MAXNAMELEN */
37 #define MAXCLASSLEN 100
38 #define MAXPERLINE 65	/* max # of chars per line in the output */
39 #define MAXRANK 100
40 #define MAXFNLEN 256
41 #define CONDENSE 1
42 #define NO_SPECIFIC -1     /* no specific datasets are requested */
43 #define	ATTR_INDENT	0	/* # of spaces in front of attribute data */
44 #define ATTR_CONT_INDENT  25	/* # of spaces in front of attribute data
45 					on a continuous line */
46 #define	DATA_INDENT	16	/* # of spaces in front of dataset data */
47 #define DATA_CONT_INDENT  16	/* # of spaces in front of dataset data
48 					on a continuous line */
49 
50 /* Free a char pointer if it's not NULL, then set it to NULL */
51 #define SAFE_FREE(ptr) {	\
52 	if (ptr != NULL)	\
53 	{ HDfree((VOIDP)ptr);	\
54 	  ptr = NULL; }}
55 
56 /* ERROR_GOTO_n macros are used to facilitate error printing.  Each
57    macro prints the given message to the stderr, then uses the HDF
58    library macro HGOTO_DONE to set the variable ret_value to FAIL
59    and jump to label "done"
60 	ERROR_GOTO_0 is used for fprintf with no parameters.
61 	ERROR_GOTO_1 is used for fprintf with 1 parameter.
62 	ERROR_GOTO_2 is used for fprintf with 2 parameters.
63 	ERROR_GOTO_3 is used for fprintf with 3 parameters.
64 	ERROR_GOTO_4 is used for fprintf with 4 parameters.
65 	ERROR_GOTO_5 is used for fprintf with 5 parameters.
66 	ERROR_GOTO_6 is used for fprintf with 6 parameters.
67 */
68 #define ERROR_GOTO_0(txt) { \
69 	fprintf(stderr, "\nHDP ERROR>>> %s", txt); \
70 	fprintf(stderr, ".\n"); \
71 	HGOTO_DONE( FAIL ); }
72 #define ERROR_GOTO_1(txt, par1 ) {	\
73 	fprintf(stderr, "\nHDP ERROR>>> "); \
74 	fprintf(stderr, txt, par1 ); \
75 	fprintf(stderr, ".\n"); \
76 	HGOTO_DONE( FAIL ); }
77 #define ERROR_GOTO_2(txt, par1, par2) {	\
78 	fprintf(stderr, "\nHDP ERROR>>> "); \
79 	fprintf(stderr, txt, par1, par2); \
80 	fprintf(stderr, ".\n"); \
81 	HGOTO_DONE( FAIL ); }
82 #define ERROR_GOTO_3(txt, par1, par2, par3) { \
83 	fprintf(stderr, "\nHDP ERROR>>> "); \
84 	fprintf(stderr, txt, par1, par2, par3); \
85 	fprintf(stderr, ".\n"); \
86 	HGOTO_DONE( FAIL ); }
87 #define ERROR_GOTO_4(txt, par1, par2, par3, par4) { \
88 	fprintf(stderr, "\nHDP ERROR>>> "); \
89 	fprintf(stderr, txt, par1, par2, par3, par4); \
90 	fprintf(stderr, ".\n"); \
91 	HGOTO_DONE( FAIL ); }
92 #define ERROR_GOTO_5(txt, par1, par2, par3, par4, par5) { \
93 	fprintf(stderr, "\nHDP ERROR>>> "); \
94 	fprintf(stderr, txt, par1, par2, par3, par4, par5); \
95 	fprintf(stderr, ".\n"); \
96 	HGOTO_DONE( FAIL ); }
97 #define ERROR_GOTO_6(txt, par1, par2, par3, par4, par5, par6) { \
98 	fprintf(stderr, "\nHDP ERROR>>> "); \
99 	fprintf(stderr, txt, par1, par2, par3, par4, par5, par6); \
100 	fprintf(stderr, ".\n"); \
101 	HGOTO_DONE( FAIL ); }
102 
103 /* ERROR_CONT_n macros are used to facilitate error printing.  Each
104    macro prints the given message to the stderr, then "continue"s.
105    Note: at this time, set ret_value to FAIL, but if it turns out
106    that there are cases where ret_value should be SUCCEED, then
107    add another argument 'ret' (=FAIL/SUCCEED) to set ret_value to
108    appropriate value.
109    Note: having extra \n after Continued. separates the following
110    output from the error messages.
111 	ERROR_CONT_0 is used for fprintf with no parameters.
112 	ERROR_CONT_1 is used for fprintf with 1 parameter.
113 	ERROR_CONT_2 is used for fprintf with 2 parameters.
114 	ERROR_CONT_3 is used for fprintf with 3 parameters.
115 	ERROR_CONT_4 is used for fprintf with 4 parameters.
116 	ERROR_CONT_5 is used for fprintf with 5 parameters.
117 	ERROR_CONT_6 is used for fprintf with 6 parameters.
118 */
119 #define ERROR_CONT_0(txt) { \
120 	fprintf(stderr, "\nHDP ERROR>>> ", txt ); \
121 	fprintf(stderr, ".  Continued.\n\n"); \
122 	ret_value = FAIL; \
123 	continue; }
124 #define ERROR_CONT_1(txt, par1 ) {	\
125 	fprintf(stderr, "\nHDP ERROR>>> "); \
126 	fprintf(stderr, txt, par1 ); \
127 	fprintf(stderr, ".  Continued.\n\n"); \
128 	ret_value = FAIL; \
129 	continue; }
130 #define ERROR_CONT_2(txt, par1, par2 ) {	\
131 	fprintf(stderr, "\nHDP ERROR>>> "); \
132 	fprintf(stderr, txt, par1, par2); \
133 	fprintf(stderr, ".  Continued.\n\n"); \
134 	ret_value = FAIL; \
135 	continue; }
136 #define ERROR_CONT_3(txt, par1, par2, par3 ) { \
137 	fprintf(stderr, "\nHDP ERROR>>> "); \
138 	fprintf(stderr, txt, par1, par2, par3); \
139 	fprintf(stderr, ".  Continued.\n\n"); \
140 	ret_value = FAIL; \
141 	continue; }
142 #define ERROR_CONT_4(txt, par1, par2, par3, par4 ) { \
143 	fprintf(stderr, "\nHDP ERROR>>> "); \
144 	fprintf(stderr, txt, par1, par2, par3, par4); \
145 	fprintf(stderr, ".  Continued.\n\n"); \
146 	ret_value = FAIL; \
147 	continue; }
148 
149 /* ERROR_CONT_END is used to facilitate error handling when an error
150    occurs on a vdata.  It prints the provided error message to the
151    stderr, end access to the vdata, then continue */
152 #define ERROR_CONT_END(txt, par1, par2, vd_id ) { \
153 	fprintf(stderr, "\nHDP ERROR>>> "); \
154 	fprintf(stderr, txt, par1, par2 ); \
155 	fprintf(stderr, ".  Continued.\n\n"); \
156 	ret_value = FAIL; \
157         VSdetach(vd_id); \
158         vd_id = FAIL; /* reset */ \
159 	continue; }
160 
161 /* ERROR_BREAK_n macros are used to facilitate error printing.  Each
162    macro prints the given message to the stderr, then sets the variable
163    ret_value to the given value and "break"s.
164 	ERROR_BREAK_0 is used for fprintf with no parameters.
165 	ERROR_BREAK_1 is used for fprintf with 1 parameter.
166 	ERROR_BREAK_2 is used for fprintf with 2 parameters.
167 	ERROR_BREAK_3 is used for fprintf with 3 parameters.
168 	ERROR_BREAK_4 is used for fprintf with 4 parameters.
169 	ERROR_BREAK_5 is used for fprintf with 5 parameters.
170 	ERROR_BREAK_6 is used for fprintf with 6 parameters.
171 */
172 #define ERROR_BREAK_0(txt, ret) { \
173 	fprintf(stderr, "\nHDP ERROR>>> %s", txt); \
174 	fprintf(stderr, ".\n"); \
175 	ret_value = ret; \
176 	break; }
177 #define ERROR_BREAK_1(txt, par1, ret ) {	\
178 	fprintf(stderr, "\nHDP ERROR>>> "); \
179 	fprintf(stderr, txt, par1 ); \
180 	fprintf(stderr, ".\n"); \
181 	ret_value = ret; \
182 	break; }
183 #define ERROR_BREAK_2(txt, par1, par2, ret) {	\
184 	fprintf(stderr, "\nHDP ERROR>>> "); \
185 	fprintf(stderr, txt, par1, par2); \
186 	fprintf(stderr, ".\n"); \
187 	ret_value = ret; \
188 	break; }
189 #define ERROR_BREAK_3(txt, par1, par2, par3, ret) {	\
190 	fprintf(stderr, "\nHDP ERROR>>> "); \
191 	fprintf(stderr, txt, par1, par2, par3 ); \
192 	fprintf(stderr, ".\n"); \
193 	ret_value = ret; \
194 	break; }
195 #define ERROR_BREAK_4(txt, par1, par2, par3, par4, ret) {	\
196 	fprintf(stderr, "\nHDP ERROR>>> "); \
197 	fprintf(stderr, txt, par1, par2, par3, par4 ); \
198 	fprintf(stderr, ".\n"); \
199 	ret_value = ret; \
200 	break; }
201 
202 /* ERROR_NOTIFY macros are used to display a failure but does not do
203    anything else except setting ret_value to FAIL so that the failure
204    can be traced back to the caller.
205 */
206 #define ERROR_NOTIFY_2(txt, par1, par2) { \
207 	fprintf(stderr, "\nHDP ERROR>>> " ); \
208 	fprintf(stderr, txt, par1, par2 ); \
209 	fprintf(stderr, ".\n"); \
210 	ret_value = FAIL; }
211 #define ERROR_NOTIFY_3(txt, par1, par2, par3) { \
212 	fprintf(stderr, "\nHDP ERROR>>> " ); \
213 	fprintf(stderr, txt, par1, par2, par3 ); \
214 	fprintf(stderr, ".\n"); \
215 	ret_value = FAIL; }
216 
217 /* CHECK_POS makes sure that number is > 0 so we are not going to
218    allocate 0 elements.  Macro is used here instead of function call
219    so if we decide to change exit(1) to goto done and return FAIL,
220    it will be possible */
221 #define CHECK_POS( number, buf_size_name, func_name ) { \
222      if( number <= 0 ) { \
223         fprintf(stderr, "in %s: Attempting to allocate 0 items using '%s'!\n",\
224 		func_name, buf_size_name ); \
225 	exit(1); } \
226 }
227 
228 /* CHECK_ALLOC macro validates that 'buffer' has been successfully
229    allocated; if the allocation fails, exit the application after displaying
230    an appropriate message.  Macro is used here to simplify the validation
231    and to facilitate maintenance, i.e., if decide to change from exit(1)
232    to goto "done" and return with FAIL in all allocation failure cases, it
233    will be possible.
234 */
235 #define CHECK_ALLOC(buffer, buf_name, func_name ) { \
236       if (buffer == NULL) {\
237          fprintf(stderr,"in %s: space allocation for %s failed.  Terminated!\n",\
238 		func_name, buf_name ); \
239          exit(1); }  \
240 }
241 
242 /* Add enum and string for new commands to both of the variables below. */
243 /* Preserve the correct/corresponding ordering */
244 typedef enum
245   {
246 	  HELP, LIST, DUMPSDS, DUMPRIG, DUMPVG, DUMPVD, DUMPGR, NONE
247   }
248 command_t;
249 #ifndef HDP_MASTER
250 extern
251 #endif							/* !HDP_MASTER */
252 const char *commands[]
253 #ifdef HDP_MASTER
254 =
255 {
256 	"help",
257 	"list",
258 	"dumpsds",
259 	"dumprig",
260 	"dumpvg",
261 	"dumpvd",
262 	"dumpgr"
263 }
264 #endif							/* HDP_MASTER */
265            ;
266 
267 /* Global options structure */
268 typedef struct
269   {
270 	  intn        help;			/* Print help on this command */
271   }
272 dump_opt_t;
273 
274 typedef enum
275   {
276 	  OTAG, OFILE, OGROUP, ONAME
277   }
278 sort_t;							/* The order tag/refs are sorted */
279 
280 /* 'list' command option structure */
281 typedef struct
282   {
283 	  sort_t      order;		/* The sort order tag/refs are printed in */
284 	  enum
285 		{
286 			VSHORT, VLONG, VDEBUG
287 		}
288 	  verbosity;				/* verbosity level of list */
289 	  enum
290 		{
291 			LNONE, LTAGNUM, LTAGNAME, LGROUP
292 		}
293 	  limit;					/* How to limit tag/refs */
294 	  intn        class;		/* Whether to dump class information */
295 	  intn        name;			/* Whether to dump name information */
296 	  intn        desc;			/* Whether to dump description information */
297 	  intn        spec;			/* Whether to dump special element information */
298 	  intn        group;		/* Whether to dump group information */
299 	  uint16      limit_tag;	/* tag # to limit search to */
300 	  char       *limit_name;	/* tag name to limit search to */
301   }
302 list_info_t;
303 
304 /* Which dataset to dump */
305 /* BMR: added defined values to fix exclusive problem - 1/23/99 */
306 typedef enum
307   {
308 	  DALL=0, DINDEX=1, DREFNUM=2, DNAME=4, DCLASS=8, DFIELDS=16
309   }
310 filter_t;
311 
312 /* What type of information being stored */
313 typedef enum
314   {
315 	  INVALID=0, IS_INDEX, IS_REFNUM, IS_NAME, IS_CLASS, IS_FIELD
316   }
317 info_type_t;
318 
319 /* Which contents to dump */
320 typedef enum
321   {
322 	  DVERBOSE, DHEADER, DDATA
323   }
324 content_t;
325 
326 /* What kind of data to dump to file */
327 typedef enum
328   {
329 	  DASCII, DBINARY
330   }
331 file_format_t;
332 
333 /* BMR: numerical filter structure; used to hold a list of indices or
334    reference numbers and the number of indices or reference numbers
335    given - 1/23/99 */
336 typedef struct
337 {
338 	int32 *num_list;
339 	int32 num_items;
340 }
341 number_filter_t;
342 
343 /* BMR: character filter structure; used to hold a list of names or class names
344    and the number of names or class names given - 1/23/99 */
345 typedef struct
346 {
347 	char **str_list;
348 	int32 num_items;
349 }
350 char_filter_t;
351 
352 typedef struct
353 {
354 	int index;
355 	int refnum;
356 	char *name;
357 	char *classname;
358 	info_type_t type_of_info;
359 }
360 obj_chosen_t;
361 
362 /* 'dumpsds' command option structure */
363 /* BMR: added fields to hold indices, reference numbers, names, and classes
364    separately - 1/23/99 */
365 typedef struct
366 {
367    filter_t    filter;		/* which data object to dump */
368    intn      *filter_num;       /* ref #'s or indices to use as filter */
369    char      **filter_str;      /* names or classes to use as filter */
370    number_filter_t by_index;	/* data objects requested by index */
371    number_filter_t by_ref;	/* data objects requested by reference number */
372    char_filter_t by_name;	/* data objects requested by name */
373    char_filter_t by_class;	/* data objects requested by class name */
374    char_filter_t by_field;	/* data objects requested by field - only VD */
375    obj_chosen_t  *all_types;	/* list of all datasets chosen and in the order
376 				   specified by the user */
377    int32       num_chosen;	/* number of items specified at command line,
378 	which can be different from the number of objects being printed due
379 	to multiple objects of the same name or class name (-1==NO_SPECIFIC) */
380    content_t   contents;        /* what contents to dump */
381    intn        keep_order;	/* whether to dump the datasets in the same
382 				   order as specified by the user */
383    intn        dump_to_file;	/* whether to dump to a file */
384    file_format_t file_format;	/* Is data written in ASCII or binary */
385    intn	       as_stream;	/* whether carriage return added to output data lines */
386    intn	       clean_output;	/* whether to print space characters as they
387 				   are or to print in \digit format */
388    intn	       firstln_indent;	/* col# where data starts on the first line*/
389    intn	       contln_indent;	/* col# where data continues on the next line*/
390    char        file_name[MAXFNLEN];/* Name of file to dump into */
391    char        ifile_name[MAXFNLEN];/* Name of input file being processed */
392 
393    intn        print_pal;	/* for GR only: TRUE if option -p selected */
394    gr_interlace_t interlace;	/* user's choice of interlace mode to print data in */
395    intn	       no_lattr_data;	/* GR & SD only: TRUE if option -l selected */
396    intn	       no_gattr_data;	/* GR & SD only: TRUE if option -g selected */
397    intn	       file_type;	/* netCDF, HDF, or other, which hdp doesn't process */
398   }
399 dump_info_t;
400 
401 /* Filename list structure */
402 typedef struct
403   {
404 	  intn        max_files;	/* the number of files in the file list */
405 	  intn        curr_file;	/* the current file */
406 	  char      **file_arr;		/* pointer to the filename information */
407   }
408 filelist_t;
409 
410 /* Group info structure */
411 typedef struct
412   {
413 	  intn        max_dds;		/* the number of DDs in the group */
414 	  intn        curr_dd;		/* The current DD */
415 	  DFdi       *dd_arr;		/* array to hold the DDs in the group */
416   }
417 groupinfo_t;
418 
419 /* DD info structure */
420 typedef struct
421   {
422 	uint16  tag, ref;	/* tag and ref of object */
423 	int32   offset, length;	/* offset and length of object in file */
424 	int32   index;		/* index of the object in the file */
425 	uintn   is_group:1,	/* flag to indicate item is a group */
426 	        is_special:1,	/* flag to indicate item is a special element */
427 	        has_label:1,	/* flag to indicate item has a label */
428 	        has_desc:1;	/* flag to indicate item has a desc. */
429 	intn    no_element;	/* TRUE if group_info is NULL */
430 	groupinfo_t     *group_info;/* pointer to group information */
431 	sp_info_block_t *spec_info;/* pointer to special element information */
432   }
433 objinfo_t;
434 #define CHECK_SPECIAL   0x0001	/* Look for spec. elem. when building dd list */
435 #define CHECK_GROUP     0x0002	/* Look for groups when building dd list */
436 #define CHECK_LABEL     0x0004	/* Look for anno. labels when building dd list */
437 #define CHECK_DESC      0x0008	/* Look for anno. desc. when building dd list */
438 
439 /* DD list structure */
440 typedef struct
441   {
442 	  intn        max_obj;		/* the number of dds in the obj list */
443 	  intn        curr_obj;		/* the current obj */
444 	  uint32      options;		/* storage for options used to build the dd list */
445 	  objinfo_t **srt_obj_arr;	/* the sorted dd/object information array */
446 	  objinfo_t  *raw_obj_arr;	/* the raw dd/object information array */
447   }
448 objlist_t;
449 
450 /* hdp_vd.c */
451 
452 /* Vdata information: used to hold various information of a vdata to
453    facilitate parameter passing */
454 typedef struct
455   {
456 	int32   index;			/* vdata index */
457 	int32   nvf;			/* number of records in the vdata */
458 	int32   interlace;		/* interlace mode of the vdata */
459 	int32   vsize;			/* record size of the vdata */
460 	int32   ref;			/* vdata ref# */
461 	int32   tag;			/* vdata tag */
462 	char    clss[VSNAMELENMAX+1];	/* vdata class */
463 	char    name[VSNAMELENMAX+1];	/* vdata name */
464   }
465 vd_info_t;
466 
467 /* hdp_vg.c */
468 
469 #define NUM_VGS 20;
470 
471 typedef struct
472 {
473 	int32  index;
474 	int32  displayed;
475 	int32  treedisplayed;   /* BMR: added to do the loop - 01/16/99 */
476 	char  *vg_name;		/* vgroup name, variable length - 10/26/06 */
477 	int32  n_entries;	/* added for convenience - 10/26/06 */
478 	char **children;
479 	char **type;
480 }
481 vg_info_t;
482 
483 /* hdp.c */
484 extern int32 VShdfsize(int32 vkey, char *fields);
485 extern intn VSattrhdfsize(int32 vsid, int32 findex, intn attrindex,int32 *size);
486 extern intn Vattrhdfsize(int32 vsid, intn attrindex, int32 *size);
487 
488 /* hdp_list.c */
489 /*extern intn print_data_annotations(const char *fname, int32 an_id, ann_type annot_type, uint16 tag, uint16 ref);*/
490 extern intn print_all_data_labels(const char *fname, int32 an_id);
491 extern intn print_all_data_descs(const char *fname, int32 an_id);
492 extern intn do_list(intn curr_arg, intn argc, char *argv[], int help);
493 extern intn print_all_file_labels(const char *fname, int32 an_id);
494 extern intn print_file_descs(const char *f_name, int32 an_id );
495 /*intn print_annots_by_object( const char *fname, int32 an_id, ann_type annot_type, uint16 tag, uint16 ref);
496 intn print_annots_in_file( int32 an_id, char* fname, int32 n_annotations, ann_type annot_type );
497 */
498 intn print_all_file_descs(const char *fname, list_info_t* list_opts, /* for print_SDattrs */ int32 an_id);
499 intn print_data_labels( const char *fname, int32 an_id, uint16 tag, uint16 ref);
500 intn print_data_descs( const char *fname, int32 an_id, uint16 tag, uint16 ref);
501 
502 /* hdp_sds.c */
503 void dumpsds_usage(intn argc, char *argv[]);
504 intn parse_dumpsds_opts(dump_info_t *dumpsds_opts, intn *curr_arg, intn argc, char *argv[]);
505 intn do_dumpsds(intn curr_arg, intn argc, char *argv[], intn help);
506 intn dsd(dump_info_t *dumpsds_opts, intn curr_arg, intn argc, char *argv[]);
507 int32 sdsdumpfull(int32 sds_id, dump_info_t *dumpsds_opts, int32 rank, int32 dimsizes[], int32 nt, FILE *fp);
508 intn printSDS_ASCII(int32 sd_id, dump_info_t *dumpsds_opts, int32 sds_index, FILE *fp);
509 intn printSDS_BINARY(int32 sd_id, dump_info_t *dumpsds_opts, int32 sds_index, FILE *fp);
510 intn get_SDSindex_list(int32 sd_id, dump_info_t *dumpsds_opts, int32 **sds_chosen, intn *index_error);
511 char *comp_method_txt(comp_coder_t comp_type);
512 intn option_mask_string(int32 options_mask, char* opt_mask_strg);
513 intn print_comp_info(FILE *fp, int32 sds_id, comp_coder_t *comp_type);
514 void resetSDS(int32 *sds_id, int32 sds_index, char *curr_file_name);
515 
516 /* hdp_rig.c */
517 extern intn do_dumprig(intn curr_arg, intn argc, char *argv[], intn help);
518 
519 /* hdp_vg.c */
520 extern intn do_dumpvg(intn curr_arg, intn argc, char *argv[], intn help);
521 extern intn print_data_annots(int32 file_id, const char *file_name, int32 tag, int32 ref);
522 extern intn print_file_annotations( int32 file_id, const char *file_name );
523 void print_fields( char *fields, char *field_title, FILE *fp );
524 /* hdp_vd.c */
525 intn do_dumpvd(intn curr_arg, intn argc, char *argv[], intn help);
526 intn parse_dumpvd_opts(dump_info_t * dumpvd_opts, intn *curr_arg, intn argc, char *argv[], char *flds_chosen[MAXCHOICES], int *dumpallfields);
527 
528 /* hdp_gr.c */
529 intn do_dumpgr(intn curr_arg, intn argc, char *argv[], intn help);
530 intn parse_dumpgr_opts(dump_info_t *dumpgr_opts, intn *curr_arg, intn argc, char *argv[]);
531 
532 /* hdp_dump.c */
533 extern intn fmtchar(VOIDP x, file_format_t ft, FILE * ofp);
534 extern intn fmtuchar8(VOIDP x, file_format_t ft, FILE * ofp);
535 extern intn fmtbyte(unsigned char *x, file_format_t ft, FILE * ofp);
536 extern intn fmtint(VOIDP x, file_format_t ft, FILE * ofp);
537 extern intn fmtshort(VOIDP x, file_format_t ft, FILE * ofp);
538 extern intn fmtint8(VOIDP x, file_format_t ft, FILE * ofp);
539 extern intn fmtuint8(VOIDP x, file_format_t ft, FILE * ofp);
540 extern intn fmtint16(VOIDP x, file_format_t ft, FILE * ofp);
541 extern intn fmtuint16(VOIDP x, file_format_t ft, FILE * ofp);
542 extern intn fmtint32(VOIDP x, file_format_t ft, FILE * ofp);
543 extern intn fmtuint32(VOIDP x, file_format_t ft, FILE * ofp);
544 extern intn fmtfloat32(VOIDP x, file_format_t ft, FILE * ofp);
545 extern intn fmtfloat64(VOIDP x, file_format_t ft, FILE * ofp);
546 extern intn dumpfull(int32 nt, dump_info_t * dump_opts, int32 cnt, VOIDP databuf, FILE * ofp, intn indent, intn cont_indent );
547 extern intn dumpclean(int32 nt, dump_info_t * dump_opts, int32 cnt, VOIDP databuf, FILE * ofp );
548 extern int32 dumpGR_SDattr(int32 nt, dump_info_t * dump_opts, int32 cnt, VOIDP databuf, FILE * ofp);
549 
550 /* show.c */
551 extern int32 dumpvd(int32 vd, file_format_t ft, int data_only, FILE *fp,
552                     char separater[2],int32 flds_indices[VSFIELDMAX],
553                     int dumpallfields);
554 extern intn dumpattr(int32 vid, int32 findex, intn isvs, file_format_t ft, FILE *fp);
555 
556 /* hdp_util.c */
557 	/* misc. functions */
558 
559 void init_dump_opts(dump_info_t *dump_opts);
560 void parse_number_opts( char *argv[], int *curr_arg, number_filter_t *filter);
561 void parse_string_opts( char *argv[], int *curr_arg, char_filter_t *filter);
562 void parse_value_opts( char *argv[], int *curr_arg, dump_info_t **dump_opts,
563                    info_type_t info_type);
564 extern char *tagnum_to_name(intn num);
565 extern intn tagname_to_num(const char *name);
566 extern void sort(int32 *chosen, int32 choices);
567 int sort_obj_list_by_tag(const void *, const void *);
568 int int32_compare(const void *, const void *);
569 
570 	/* filename list functions */
571 extern filelist_t *make_file_list(intn curr_arg, intn argc, char *argv[]);
572 extern char *get_next_file(filelist_t * f_list, intn advance);
573 
574 	/* memory management functions */
575 extern int32* free_num_list(int32 *num_list);
576 extern char** free_str_list(char **str_list, int32 num_items);
577 extern vg_info_t** free_vginfo_list(vg_info_t** list, int32 num_items);
578 extern vg_info_t* free_node_vg_info_t(vg_info_t* aNode);
579 void free_obj_chosen_t_list(obj_chosen_t **nodelist, int32 num_items);
580 extern void free_file_list(filelist_t * f_list);
581 
582 	/* group list functions */
583 extern groupinfo_t *make_group_list(int32 fid, uint16 tag, uint16 ref);
584 extern DFdi *get_next_group(groupinfo_t * g_list, intn advance);
585 extern int32 get_group_max(groupinfo_t * g_list);
586 extern void free_group_list(groupinfo_t * g_list);
587 	/* object list functions */
588 extern objlist_t *make_obj_list(int32 fid, uint32 options);
589 extern objinfo_t *get_next_obj(objlist_t * o_list, intn advance);
590 extern objinfo_t *goto_nth_obj(objlist_t * o_list, intn n);
591 extern void reset_obj_list(objlist_t * o_list);
592 extern void resetBuff(VOIDP *buf);
593 extern void free_obj_list(objlist_t * o_list);
594 extern void sort_obj_list(objlist_t * o_list, sort_t sort_type);
595 extern intn print_SDattrs( int32 sd_id, FILE *fp, int32 n_file_attrs, dump_info_t *dumpsds_opts );
596 extern intn print_SDSattrs( int32 sds_id, int32 nattrs, FILE *fp, dump_info_t *dumpsds_opts);
597 
598 extern intn print_GRattrs( int32 gr_id, int32 n_file_attrs, FILE *fp, dump_info_t *dumpgr_opts );
599 extern intn print_RIattrs( int32 ri_id, intn ri_index, int32 nattrs, FILE *fp, dump_info_t *dumpgr_opts);
600 
601 extern void alloc_index_list( int32 **index_list, int32 num_chosen );
602 
603 #define PPSTR( name, str) { \
604    printf( " %s: %s\n", name, str ); }
605 #define PPNUM( name, num) { \
606    printf(" %s: %d\n", name, num ); }
607 #define PSTR( name, str) { \
608    fprintf(stderr, " %s: %s\n", name, str ); }
609 #define PNUM( name, num) { \
610    fprintf(stderr, " %s: %d\n", name, num ); }
611 /***************** end remove when done ******************/
612 
613 #endif /* __HDP_H */
614