00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00002 * Copyright by The HDF Group. * 00003 * Copyright by the Board of Trustees of the University of Illinois. * 00004 * All rights reserved. * 00005 * * 00006 * This file is part of HDF5. The full HDF5 copyright notice, including * 00007 * terms governing use, modification, and redistribution, is contained in * 00008 * the files COPYING and Copyright.html. COPYING can be found at the root * 00009 * of the source code distribution tree; Copyright.html can be found at the * 00010 * root level of an installed copy of the electronic HDF5 document set and * 00011 * is linked from the top-level documents page. It can also be found at * 00012 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 00013 * access to either file, you may request a copy from help@hdfgroup.org. * 00014 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00015 00016 /* 00017 * Programmer: Bill Wendling <wendling@ncsa.uiuc.edu> 00018 * Tuesday, 6. March 2001 00019 * 00020 * Purpose: Support functions for the various tools. 00021 */ 00022 #ifndef H5TOOLS_UTILS_H__ 00023 #define H5TOOLS_UTILS_H__ 00024 00025 #include "hdf5.h" 00026 00027 /* 00028 * begin get_option section 00029 */ 00030 extern int opt_err; /* getoption prints errors if this is on */ 00031 extern int opt_ind; /* token pointer */ 00032 extern const char *opt_arg; /* flag argument (or value) */ 00033 00034 enum { 00035 no_arg = 0, /* doesn't take an argument */ 00036 require_arg, /* requires an argument */ 00037 optional_arg /* argument is optional */ 00038 }; 00039 00040 /* 00041 * get_option determines which options are specified on the command line and 00042 * returns a pointer to any arguments possibly associated with the option in 00043 * the ``opt_arg'' variable. get_option returns the shortname equivalent of 00044 * the option. The long options are specified in the following way: 00045 * 00046 * struct long_options foo[] = { 00047 * { "filename", require_arg, 'f' }, 00048 * { "append", no_arg, 'a' }, 00049 * { "width", require_arg, 'w' }, 00050 * { NULL, 0, 0 } 00051 * }; 00052 * 00053 * Long named options can have arguments specified as either: 00054 * 00055 * ``--param=arg'' or ``--param arg'' 00056 * 00057 * Short named options can have arguments specified as either: 00058 * 00059 * ``-w80'' or ``-w 80'' 00060 * 00061 * and can have more than one short named option specified at one time: 00062 * 00063 * -aw80 00064 * 00065 * in which case those options which expect an argument need to come at the 00066 * end. 00067 */ 00068 typedef struct long_options { 00069 const char *name; /* name of the long option */ 00070 int has_arg; /* whether we should look for an arg */ 00071 char shortval; /* the shortname equivalent of long arg 00072 * this gets returned from get_option */ 00073 } long_options; 00074 00075 extern int get_option(int argc, const char **argv, const char *opt, 00076 const struct long_options *l_opt); 00077 /* 00078 * end get_option section 00079 */ 00080 00081 /*struct taken from the dumper. needed in table struct*/ 00082 typedef struct obj_t { 00083 haddr_t objno; 00084 char *objname; 00085 hbool_t displayed; /* Flag to indicate that the object has been displayed */ 00086 hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */ 00087 } obj_t; 00088 00089 /*struct for the tables that the find_objs function uses*/ 00090 typedef struct table_t { 00091 size_t size; 00092 size_t nobjs; 00093 obj_t *objs; 00094 } table_t; 00095 00096 /*this struct stores the information that is passed to the find_objs function*/ 00097 typedef struct find_objs_t { 00098 hid_t fid; 00099 table_t *group_table; 00100 table_t *type_table; 00101 table_t *dset_table; 00102 } find_objs_t; 00103 00104 extern int nCols; /*max number of columns for outputting */ 00105 00106 /* Definitions of useful routines */ 00107 extern void indentation(int); 00108 extern void print_version(const char *progname); 00109 extern void error_msg(const char *progname, const char *fmt, ...); 00110 extern void warn_msg(const char *progname, const char *fmt, ...); 00111 extern void free_table(table_t *table); 00112 #ifdef H5DUMP_DEBUG 00113 extern void dump_tables(find_objs_t *info) 00114 #endif /* H5DUMP_DEBUG */ 00115 extern herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, 00116 table_t **dset_table, table_t **type_table); 00117 extern obj_t *search_obj(table_t *temp, haddr_t objno); 00118 #ifndef H5_HAVE_TMPFILE 00119 extern FILE * tmpfile(void); 00120 #endif 00121 00122 #endif /* H5TOOLS_UTILS_H__ */