[svn-r23953] Update stream handling to allow binary mode - due to unjam fix.

Tested: local linux
This commit is contained in:
Allen Byrne 2013-07-31 11:22:40 -05:00
parent ba181d404d
commit 4e1695576c
3 changed files with 61 additions and 18 deletions

View File

@ -1020,7 +1020,7 @@ parse_start:
break;
case 'O':
if (h5tools_set_output_file(opt_arg) < 0) {
if (h5tools_set_output_file(opt_arg, 0) < 0) {
usage(h5tools_getprogname());
goto error;
}

View File

@ -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;
}

View File

@ -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);