diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2013-07-31 16:22:40 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2013-07-31 16:22:40 (GMT) |
commit | 4e1695576c49988a9d23c8f2a3d00601cb447593 (patch) | |
tree | ac48f2277271369b6cd2d956370f878c73ac1597 /tools/lib | |
parent | ba181d404dd47666ca5005b2d845aac5ee0ae46e (diff) | |
download | hdf5-4e1695576c49988a9d23c8f2a3d00601cb447593.zip hdf5-4e1695576c49988a9d23c8f2a3d00601cb447593.tar.gz hdf5-4e1695576c49988a9d23c8f2a3d00601cb447593.tar.bz2 |
[svn-r23953] Update stream handling to allow binary mode - due to unjam fix.
Tested: local linux
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools.c | 71 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 6 |
2 files changed, 60 insertions, 17 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 2e48889..d229eec 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -287,9 +287,18 @@ h5tools_set_attr_output_file(const char *fname, int is_bin) /* First check if filename is string "NULL" */ if (fname != NULL) { - if ((f = HDfopen(fname, "w")) != NULL) { - rawattrstream = f; - retvalue = SUCCEED; + /* binary output */ + if (is_bin) { + if ((f = HDfopen(fname, "wb")) != NULL) { + rawattrstream = f; + retvalue = SUCCEED; + } + } + else { + if ((f = HDfopen(fname, "w")) != NULL) { + rawattrstream = f; + retvalue = SUCCEED; + } } } else { @@ -312,7 +321,7 @@ h5tools_set_attr_output_file(const char *fname, int is_bin) *------------------------------------------------------------------------- */ int -h5tools_set_input_file(const char *fname) +h5tools_set_input_file(const char *fname, int is_bin) { int retvalue = FAIL; FILE *f; /* temporary holding place for the stream pointer @@ -326,9 +335,18 @@ h5tools_set_input_file(const char *fname) } /* First check if filename is string "NULL" */ if (fname != NULL) { - if ((f = HDfopen(fname, "r")) != NULL) { - rawinstream = f; - retvalue = SUCCEED; + /* binary output */ + if (is_bin) { + if ((f = HDfopen(fname, "rb")) != NULL) { + rawinstream = f; + retvalue = SUCCEED; + } + } + else { + if ((f = HDfopen(fname, "r")) != NULL) { + rawinstream = f; + retvalue = SUCCEED; + } } } else { @@ -351,7 +369,7 @@ h5tools_set_input_file(const char *fname) *------------------------------------------------------------------------- */ int -h5tools_set_output_file(const char *fname) +h5tools_set_output_file(const char *fname, int is_bin) { int retvalue = FAIL; FILE *f; /* temporary holding place for the stream pointer @@ -365,9 +383,18 @@ h5tools_set_output_file(const char *fname) } /* First check if filename is string "NULL" */ if (fname != NULL) { - if ((f = HDfopen(fname, "w")) != NULL) { - rawoutstream = f; - retvalue = SUCCEED; + /* binary output */ + if (is_bin) { + if ((f = HDfopen(fname, "wb")) != NULL) { + rawoutstream = f; + retvalue = SUCCEED; + } + } + else { + if ((f = HDfopen(fname, "w")) != NULL) { + rawoutstream = f; + retvalue = SUCCEED; + } } } else { @@ -390,7 +417,7 @@ h5tools_set_output_file(const char *fname) *------------------------------------------------------------------------- */ int -h5tools_set_error_file(const char *fname) +h5tools_set_error_file(const char *fname, int is_bin) { int retvalue = FAIL; FILE *f; /* temporary holding place for the stream pointer @@ -403,8 +430,24 @@ h5tools_set_error_file(const char *fname) rawerrorstream = NULL; } - if ((f = HDfopen(fname, "w")) != NULL) { - rawerrorstream = f; + /* First check if filename is string "NULL" */ + if (fname != NULL) { + /* binary output */ + if (is_bin) { + if ((f = HDfopen(fname, "wb")) != NULL) { + rawerrorstream = f; + retvalue = SUCCEED; + } + } + else { + if ((f = HDfopen(fname, "w")) != NULL) { + rawerrorstream = f; + retvalue = SUCCEED; + } + } + } + else { + rawerrorstream = NULL; retvalue = SUCCEED; } diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 5f834c5..ea6a44f 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -552,9 +552,9 @@ H5TOOLS_DLL void h5tools_init(void); H5TOOLS_DLL void h5tools_close(void); H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin); H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_input_file(const char *fname); -H5TOOLS_DLL int h5tools_set_output_file(const char *fname); -H5TOOLS_DLL int h5tools_set_error_file(const char *fname); +H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin); H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, char *drivername, size_t drivername_len); H5TOOLS_DLL hid_t h5tools_get_native_type(hid_t type); |