diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2010-05-11 20:10:25 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2010-05-11 20:10:25 (GMT) |
commit | 68fa42f3360945d07a0443289025a6a91618aac5 (patch) | |
tree | ca90a2cf0244915347d531bddd78e7e7d898825d /tools/lib | |
parent | fe49632588af7cafdd220998be6006d91ed0247c (diff) | |
download | hdf5-68fa42f3360945d07a0443289025a6a91618aac5.zip hdf5-68fa42f3360945d07a0443289025a6a91618aac5.tar.gz hdf5-68fa42f3360945d07a0443289025a6a91618aac5.tar.bz2 |
[svn-r18759] pull r18757 from 1.8 branch
Enable tools lib to be built as a dll on windows. Added two get/set functions for progname and d_status.
Also add windows import/export declarations to functions.
Updated error_mesg() and warn_mesg() to remove progname argument and use get functions
Tested:
Windows, linux
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff.h | 6 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 30 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 43 | ||||
-rw-r--r-- | tools/lib/h5tools_error.h | 6 | ||||
-rw-r--r-- | tools/lib/h5tools_ref.c | 7 | ||||
-rw-r--r-- | tools/lib/h5tools_ref.h | 14 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 8 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.h | 39 | ||||
-rw-r--r-- | tools/lib/h5trav.h | 22 |
9 files changed, 111 insertions, 64 deletions
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 6718d9a..ede6ea0 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -55,15 +55,15 @@ typedef struct { extern "C" { #endif -hsize_t h5diff(const char *fname1, +H5TOOLS_DLL hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, diff_opt_t *options); #ifdef H5_HAVE_PARALLEL -void phdiff_dismiss_workers(void); -void print_manager_output(void); +H5TOOLS_DLL void phdiff_dismiss_workers(void); +H5TOOLS_DLL void print_manager_output(void); #endif #ifdef __cplusplus diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index e997d03..5d4ea87 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -42,6 +42,8 @@ FILE *rawdatastream; /* should initialize to stdout but gcc moans about it int bin_output; /* binary output */ int bin_form; /* binary form */ int region_output; /* region output */ +static int h5tools_d_status = 0; +static const char *h5tools_progname = "h5tools"; static h5tool_format_t h5tools_dataformat = { 0, /*raw */ @@ -283,6 +285,34 @@ enum { /*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library + * Purpose: Initialize the name and operation status of the H5 Tools library + * Description: + * These are utility functions to set/get the program name and operation status. + *------------------------------------------------------------------------- + */ +void h5tools_setprogname(const char *Progname) +{ + h5tools_progname = Progname; +} + +void h5tools_setstatus(int D_status) +{ + h5tools_d_status = D_status; +} + +const char*h5tools_getprogname() +{ + return h5tools_progname; +} + +int h5tools_getstatus() +{ + return h5tools_d_status; +} + +/*------------------------------------------------------------------------- + * Audience: Public + * Chapter: H5Tools Library * Purpose: Initialize the H5 Tools library * Description: * This should be called before any other h5tools function is called. diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 7d207ba..cb01580 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -521,10 +521,14 @@ struct subset_t { #include "h5tools_str.h" -extern FILE *rawdatastream; /* output stream for raw data */ -extern int bin_output; /* binary output */ -extern int bin_form; /* binary form */ -extern int region_output; /* region output */ +#ifdef __cplusplus +extern "C" { +#endif + +H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */ +H5TOOLS_DLLVAR int bin_output; /* binary output */ +H5TOOLS_DLLVAR int bin_form; /* binary form */ +H5TOOLS_DLLVAR int region_output; /* region output */ /* Strings for output */ #define H5_TOOLS_GROUP "GROUP" @@ -532,26 +536,30 @@ extern int region_output; /* region output */ #define H5_TOOLS_DATATYPE "DATATYPE" /* Definitions of useful routines */ -extern void h5tools_init(void); -extern void h5tools_close(void); -extern hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, +H5TOOLS_DLL const char *h5tools_getprogname(void); +H5TOOLS_DLL void h5tools_setprogname(const char*progname); +H5TOOLS_DLL int h5tools_getstatus(void); +H5TOOLS_DLL void h5tools_setstatus(int d_status); +H5TOOLS_DLL void h5tools_init(void); +H5TOOLS_DLL void h5tools_close(void); +H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, char *drivername, size_t drivername_len); -extern int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, +H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t p_typ, struct subset_t *sset, int indentlevel); -extern int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, +H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel); -extern hid_t h5tools_get_native_type(hid_t type); -extern hid_t h5tools_get_little_endian_type(hid_t type); -extern hid_t h5tools_get_big_endian_type(hid_t type); +H5TOOLS_DLL hid_t h5tools_get_native_type(hid_t type); +H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type); +H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type); -extern void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, +H5TOOLS_DLL void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem); -extern int h5tools_canreadf(const char* name, +H5TOOLS_DLL int h5tools_canreadf(const char* name, hid_t dcpl_id); -extern int h5tools_can_encode(H5Z_filter_t filtn); +H5TOOLS_DLL int h5tools_can_encode(H5Z_filter_t filtn); void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); /* @@ -564,5 +572,10 @@ int h5tools_print_datatype(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t type); int h5tools_print_enum(h5tools_str_t *buffer/*in,out*/, hid_t type); + +#ifdef __cplusplus +} +#endif + #endif /* H5TOOLS_H__ */ diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index a7c0d3c..207218e 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -22,9 +22,9 @@ #include "H5Epublic.h" /* tools-HDF5 Error variables */ -extern hid_t H5tools_ERR_CLS_g; -extern hid_t H5E_tools_g; -extern hid_t H5E_tools_min_id_g; +H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g; +H5TOOLS_DLLVAR hid_t H5E_tools_g; +H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g; /* Use FUNC to safely handle variations of C99 __func__ keyword handling */ #ifdef H5_HAVE_C99_FUNC diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index 03e6efd..07d2a57 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -45,9 +45,6 @@ typedef struct { static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */ static hid_t thefile = (-1); -extern char *progname; -extern int d_status; - static int ref_path_table_put(const char *, haddr_t objno); /*------------------------------------------------------------------------- @@ -122,8 +119,8 @@ init_ref_path_table(void) /* Iterate over objects in this file */ if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) { - error_msg(progname, "unable to construct reference path table\n"); - d_status = EXIT_FAILURE; + error_msg("unable to construct reference path table\n"); + h5tools_setstatus(EXIT_FAILURE); } /* end if */ return(0); diff --git a/tools/lib/h5tools_ref.h b/tools/lib/h5tools_ref.h index 567ca4b..7ddb91a 100644 --- a/tools/lib/h5tools_ref.h +++ b/tools/lib/h5tools_ref.h @@ -22,13 +22,13 @@ extern "C" { #endif -herr_t fill_ref_path_table(hid_t fid); -const char *lookup_ref_path(haddr_t ref); -int get_next_xid(void); -haddr_t get_fake_xid(void); -haddr_t ref_path_table_lookup(const char *); -haddr_t ref_path_table_gen_fake(const char *); -int term_ref_path_table(void); +H5TOOLS_DLL herr_t fill_ref_path_table(hid_t fid); +H5TOOLS_DLL const char *lookup_ref_path(haddr_t ref); +H5TOOLS_DLL int get_next_xid(void); +H5TOOLS_DLL haddr_t get_fake_xid(void); +H5TOOLS_DLL haddr_t ref_path_table_lookup(const char *); +H5TOOLS_DLL haddr_t ref_path_table_gen_fake(const char *); +H5TOOLS_DLL int term_ref_path_table(void); #ifdef __cplusplus } diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index a51a286..757d4d7 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -64,13 +64,13 @@ static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t *------------------------------------------------------------------------- */ void -error_msg(const char *progname, const char *fmt, ...) +error_msg(const char *fmt, ...) { va_list ap; va_start(ap, fmt); HDfflush(stdout); - HDfprintf(stderr, "%s error: ", progname); + HDfprintf(stderr, "%s error: ", h5tools_getprogname()); HDvfprintf(stderr, fmt, ap); va_end(ap); @@ -93,13 +93,13 @@ error_msg(const char *progname, const char *fmt, ...) *------------------------------------------------------------------------- */ void -warn_msg(const char *progname, const char *fmt, ...) +warn_msg(const char *fmt, ...) { va_list ap; va_start(ap, fmt); HDfflush(stdout); - HDfprintf(stderr, "%s warning: ", progname); + HDfprintf(stderr, "%s warning: ", h5tools_getprogname()); HDvfprintf(stderr, fmt, ap); va_end(ap); } diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index dcd8f2b..3720afd 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -24,12 +24,16 @@ #include "hdf5.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * begin get_option section */ -extern int opt_err; /* getoption prints errors if this is on */ -extern int opt_ind; /* token pointer */ -extern const char *opt_arg; /* flag argument (or value) */ +H5TOOLS_DLLVAR int opt_err; /* getoption prints errors if this is on */ +H5TOOLS_DLLVAR int opt_ind; /* token pointer */ +H5TOOLS_DLLVAR const char *opt_arg; /* flag argument (or value) */ enum { no_arg = 0, /* doesn't take an argument */ @@ -72,7 +76,7 @@ typedef struct long_options { * this gets returned from get_option */ } long_options; -extern int get_option(int argc, const char **argv, const char *opt, +H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt, const struct long_options *l_opt); /* * end get_option section @@ -101,25 +105,24 @@ typedef struct find_objs_t { table_t *dset_table; } find_objs_t; -extern int nCols; /*max number of columns for outputting */ +H5TOOLS_DLLVAR int nCols; /*max number of columns for outputting */ /* Definitions of useful routines */ -extern void indentation(int); -extern void print_version(const char *progname); -extern void error_msg(const char *progname, const char *fmt, ...); -extern void warn_msg(const char *progname, const char *fmt, ...); -extern void free_table(table_t *table); +H5TOOLS_DLL void indentation(int); +H5TOOLS_DLL void print_version(const char *progname); +H5TOOLS_DLL void error_msg(const char *fmt, ...); +H5TOOLS_DLL void warn_msg(const char *fmt, ...); +H5TOOLS_DLL void free_table(table_t *table); #ifdef H5DUMP_DEBUG -extern void dump_tables(find_objs_t *info) +H5TOOLS_DLL void dump_tables(find_objs_t *info) #endif /* H5DUMP_DEBUG */ -extern herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, +H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table); -extern obj_t *search_obj(table_t *temp, haddr_t objno); +H5TOOLS_DLL obj_t *search_obj(table_t *temp, haddr_t objno); #ifndef H5_HAVE_TMPFILE -extern FILE * tmpfile(void); +H5TOOLS_DLL FILE * tmpfile(void); #endif - /************************************************************* * * candidate functions to be public @@ -148,6 +151,10 @@ typedef struct { /* Definitions of routines */ -extern int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info); +H5TOOLS_DLL int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info); + +#ifdef __cplusplus +} +#endif #endif /* H5TOOLS_UTILS_H__ */ diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index 5c07331..bb31461 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -110,7 +110,7 @@ extern "C" { * "h5trav general" public functions *------------------------------------------------------------------------- */ -int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, +H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata); @@ -118,22 +118,22 @@ int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, * "h5trav info" public functions *------------------------------------------------------------------------- */ -int h5trav_getinfo(hid_t file_id, trav_info_t *info); -ssize_t h5trav_getindex(const trav_info_t *info, const char *obj); +H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info); +H5TOOLS_DLL ssize_t h5trav_getindex(const trav_info_t *info, const char *obj); /*------------------------------------------------------------------------- * "h5trav table" public functions *------------------------------------------------------------------------- */ -int h5trav_gettable(hid_t fid, trav_table_t *travt); -int h5trav_getindext(const char *obj, const trav_table_t *travt); +H5TOOLS_DLL int h5trav_gettable(hid_t fid, trav_table_t *travt); +H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt); /*------------------------------------------------------------------------- * "h5trav print" public functions *------------------------------------------------------------------------- */ -int h5trav_print(hid_t fid); +H5TOOLS_DLL int h5trav_print(hid_t fid); #ifdef __cplusplus } @@ -144,20 +144,20 @@ int h5trav_print(hid_t fid); *------------------------------------------------------------------------- */ -void trav_info_init(trav_info_t **info); +H5TOOLS_DLL void trav_info_init(trav_info_t **info); -void trav_info_free(trav_info_t *info); +H5TOOLS_DLL void trav_info_free(trav_info_t *info); /*------------------------------------------------------------------------- * table private functions *------------------------------------------------------------------------- */ -void trav_table_init(trav_table_t **table); +H5TOOLS_DLL void trav_table_init(trav_table_t **table); -void trav_table_free(trav_table_t *table); +H5TOOLS_DLL void trav_table_free(trav_table_t *table); -void trav_table_addflags(unsigned *flags, +H5TOOLS_DLL void trav_table_addflags(unsigned *flags, char *objname, h5trav_type_t type, trav_table_t *table); |