2011-08-18 22:32:47 +08:00
|
|
|
/****h* root/fortran/test/tc.c
|
|
|
|
*
|
|
|
|
* NAME
|
|
|
|
* tc.c
|
|
|
|
*
|
|
|
|
* FUNCTION
|
|
|
|
* This file contains C routines needed for the test programs.
|
|
|
|
*
|
|
|
|
* COPYRIGHT
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-08-12 03:37:59 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
|
|
|
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
|
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2011-08-18 22:32:47 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
*
|
|
|
|
******
|
|
|
|
*/
|
2002-09-24 06:06:01 +08:00
|
|
|
|
|
|
|
#include "t.h"
|
[svn-r18157] Description:
Bring back changes from Coverity session on 1/15/10:
r18111:
Fix Coverity issue #130: make certain that the cache gets freed on error.
r18112:
Fix Coverity issue #43 by making cache testing calls protected by 'pass'
variable.
r18113:
Fix Coverity issue #129 by releasing the cache on error.
r18115:
Coverity #45 fix: patched an error check in H5Screate_simple to prevent future dereferencing of a NULL point.
Added a verification in test/th5s.c.
r18116:
Fix Coverity issue #43 by releasing cache on error.
r18117:
Coverity #362,363 by adding HGOTO_DONE, freeing allocations and associated changes. REsolving coverity results #364-368, 369, 370-372, 377, 379, and 380.
r18118:
Fix Coverity issue #42: assert that cache & test specification pointer are
valid.
r18122:
Coverity #362,363 by adding HGOTO_DONE and freeing allocations. This also takes care of #357,358.
r18123:
Coverity #359-361, 373-376: Added HGOTO_DONE(FAIL) statement after checking allocation for NULL. Verified allocation is freed in done block.
r18128:
Fixed coverity issue #10 -- removed dead code.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-23 12:39:40 +08:00
|
|
|
#include "H5Eprivate.h"
|
2002-09-24 06:06:01 +08:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
* Name: h5_fixname_c
|
|
|
|
* Purpose: Call h5_fixname to modify file name
|
2005-08-14 04:53:35 +08:00
|
|
|
* Inputs: base_name - name of the file
|
2002-09-24 06:06:01 +08:00
|
|
|
* base_namelen - name length
|
2005-08-14 04:53:35 +08:00
|
|
|
* fapl - file access property list
|
2002-09-24 06:06:01 +08:00
|
|
|
* full_name - buffer to return full name
|
|
|
|
* full_namelen - name length
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
* Programmer: Elena Pourmal
|
|
|
|
* Friday, September 13, 2002
|
|
|
|
* Modifications:
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
int_f
|
2004-12-29 22:26:20 +08:00
|
|
|
nh5_fixname_c(_fcd base_name, size_t_f *base_namelen, hid_t_f* fapl, _fcd full_name, size_t_f *full_namelen)
|
2002-09-24 06:06:01 +08:00
|
|
|
{
|
[svn-r18157] Description:
Bring back changes from Coverity session on 1/15/10:
r18111:
Fix Coverity issue #130: make certain that the cache gets freed on error.
r18112:
Fix Coverity issue #43 by making cache testing calls protected by 'pass'
variable.
r18113:
Fix Coverity issue #129 by releasing the cache on error.
r18115:
Coverity #45 fix: patched an error check in H5Screate_simple to prevent future dereferencing of a NULL point.
Added a verification in test/th5s.c.
r18116:
Fix Coverity issue #43 by releasing cache on error.
r18117:
Coverity #362,363 by adding HGOTO_DONE, freeing allocations and associated changes. REsolving coverity results #364-368, 369, 370-372, 377, 379, and 380.
r18118:
Fix Coverity issue #42: assert that cache & test specification pointer are
valid.
r18122:
Coverity #362,363 by adding HGOTO_DONE and freeing allocations. This also takes care of #357,358.
r18123:
Coverity #359-361, 373-376: Added HGOTO_DONE(FAIL) statement after checking allocation for NULL. Verified allocation is freed in done block.
r18128:
Fixed coverity issue #10 -- removed dead code.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-23 12:39:40 +08:00
|
|
|
char *c_base_name = NULL;
|
|
|
|
char *c_full_name = NULL;
|
|
|
|
int_f ret_value = 0;
|
2002-09-24 06:06:01 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert FORTRAN name to C name
|
|
|
|
*/
|
[svn-r18157] Description:
Bring back changes from Coverity session on 1/15/10:
r18111:
Fix Coverity issue #130: make certain that the cache gets freed on error.
r18112:
Fix Coverity issue #43 by making cache testing calls protected by 'pass'
variable.
r18113:
Fix Coverity issue #129 by releasing the cache on error.
r18115:
Coverity #45 fix: patched an error check in H5Screate_simple to prevent future dereferencing of a NULL point.
Added a verification in test/th5s.c.
r18116:
Fix Coverity issue #43 by releasing cache on error.
r18117:
Coverity #362,363 by adding HGOTO_DONE, freeing allocations and associated changes. REsolving coverity results #364-368, 369, 370-372, 377, 379, and 380.
r18118:
Fix Coverity issue #42: assert that cache & test specification pointer are
valid.
r18122:
Coverity #362,363 by adding HGOTO_DONE and freeing allocations. This also takes care of #357,358.
r18123:
Coverity #359-361, 373-376: Added HGOTO_DONE(FAIL) statement after checking allocation for NULL. Verified allocation is freed in done block.
r18128:
Fixed coverity issue #10 -- removed dead code.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-23 12:39:40 +08:00
|
|
|
if(NULL == (c_base_name = (char *)HD5f2cstring(base_name, (size_t)*base_namelen)))
|
|
|
|
HGOTO_DONE(FAIL)
|
|
|
|
if(NULL == (c_full_name = (char *)HDmalloc((size_t)*full_namelen + 1)))
|
|
|
|
HGOTO_DONE(FAIL)
|
2002-09-24 06:06:01 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Call h5_fixname function.
|
|
|
|
*/
|
[svn-r18157] Description:
Bring back changes from Coverity session on 1/15/10:
r18111:
Fix Coverity issue #130: make certain that the cache gets freed on error.
r18112:
Fix Coverity issue #43 by making cache testing calls protected by 'pass'
variable.
r18113:
Fix Coverity issue #129 by releasing the cache on error.
r18115:
Coverity #45 fix: patched an error check in H5Screate_simple to prevent future dereferencing of a NULL point.
Added a verification in test/th5s.c.
r18116:
Fix Coverity issue #43 by releasing cache on error.
r18117:
Coverity #362,363 by adding HGOTO_DONE, freeing allocations and associated changes. REsolving coverity results #364-368, 369, 370-372, 377, 379, and 380.
r18118:
Fix Coverity issue #42: assert that cache & test specification pointer are
valid.
r18122:
Coverity #362,363 by adding HGOTO_DONE and freeing allocations. This also takes care of #357,358.
r18123:
Coverity #359-361, 373-376: Added HGOTO_DONE(FAIL) statement after checking allocation for NULL. Verified allocation is freed in done block.
r18128:
Fixed coverity issue #10 -- removed dead code.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-23 12:39:40 +08:00
|
|
|
if(NULL == h5_fixname(c_base_name, (hid_t)*fapl, c_full_name, (size_t)*full_namelen + 1))
|
|
|
|
HGOTO_DONE(FAIL)
|
|
|
|
HD5packFstring(c_full_name, _fcdtocp(full_name), (size_t)*full_namelen);
|
|
|
|
|
|
|
|
done:
|
2010-01-30 12:29:13 +08:00
|
|
|
if(c_base_name)
|
[svn-r18157] Description:
Bring back changes from Coverity session on 1/15/10:
r18111:
Fix Coverity issue #130: make certain that the cache gets freed on error.
r18112:
Fix Coverity issue #43 by making cache testing calls protected by 'pass'
variable.
r18113:
Fix Coverity issue #129 by releasing the cache on error.
r18115:
Coverity #45 fix: patched an error check in H5Screate_simple to prevent future dereferencing of a NULL point.
Added a verification in test/th5s.c.
r18116:
Fix Coverity issue #43 by releasing cache on error.
r18117:
Coverity #362,363 by adding HGOTO_DONE, freeing allocations and associated changes. REsolving coverity results #364-368, 369, 370-372, 377, 379, and 380.
r18118:
Fix Coverity issue #42: assert that cache & test specification pointer are
valid.
r18122:
Coverity #362,363 by adding HGOTO_DONE and freeing allocations. This also takes care of #357,358.
r18123:
Coverity #359-361, 373-376: Added HGOTO_DONE(FAIL) statement after checking allocation for NULL. Verified allocation is freed in done block.
r18128:
Fixed coverity issue #10 -- removed dead code.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-23 12:39:40 +08:00
|
|
|
HDfree(c_base_name);
|
2010-01-30 12:29:13 +08:00
|
|
|
if(c_full_name)
|
[svn-r18157] Description:
Bring back changes from Coverity session on 1/15/10:
r18111:
Fix Coverity issue #130: make certain that the cache gets freed on error.
r18112:
Fix Coverity issue #43 by making cache testing calls protected by 'pass'
variable.
r18113:
Fix Coverity issue #129 by releasing the cache on error.
r18115:
Coverity #45 fix: patched an error check in H5Screate_simple to prevent future dereferencing of a NULL point.
Added a verification in test/th5s.c.
r18116:
Fix Coverity issue #43 by releasing cache on error.
r18117:
Coverity #362,363 by adding HGOTO_DONE, freeing allocations and associated changes. REsolving coverity results #364-368, 369, 370-372, 377, 379, and 380.
r18118:
Fix Coverity issue #42: assert that cache & test specification pointer are
valid.
r18122:
Coverity #362,363 by adding HGOTO_DONE and freeing allocations. This also takes care of #357,358.
r18123:
Coverity #359-361, 373-376: Added HGOTO_DONE(FAIL) statement after checking allocation for NULL. Verified allocation is freed in done block.
r18128:
Fixed coverity issue #10 -- removed dead code.
Tested on:
Mac OS X/32 10.6.2 (amazon)
2010-01-23 12:39:40 +08:00
|
|
|
HDfree(c_full_name);
|
2004-12-29 22:26:20 +08:00
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
2002-09-24 06:06:01 +08:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
* Name: h5_cleanup_c
|
|
|
|
* Purpose: Call h5_cleanup to clean temporary files.
|
2005-08-14 04:53:35 +08:00
|
|
|
* Inputs: base_name - name of the file
|
2002-09-24 06:06:01 +08:00
|
|
|
* base_namelen - name length
|
2005-08-14 04:53:35 +08:00
|
|
|
* fapl - file access property list
|
2002-09-24 06:06:01 +08:00
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
* Programmer: Elena Pourmal
|
|
|
|
* Thursday, September 19, 2002
|
|
|
|
* Modifications:
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
int_f
|
2004-12-29 22:26:20 +08:00
|
|
|
nh5_cleanup_c(_fcd base_name, size_t_f *base_namelen, hid_t_f* fapl)
|
2002-09-24 06:06:01 +08:00
|
|
|
{
|
|
|
|
char filename[1024];
|
|
|
|
int ret_value = -1;
|
|
|
|
char *c_base_name[1];
|
|
|
|
hid_t c_fapl;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define ifile access property list
|
|
|
|
*/
|
|
|
|
c_fapl = (hid_t)*fapl;
|
|
|
|
/*c_fapl = H5Pcreate(H5P_FILE_ACCESS);*/
|
|
|
|
/*
|
|
|
|
* Convert FORTRAN name to C name
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
c_base_name[0] = (char *)HD5f2cstring(base_name, (size_t)*base_namelen);
|
2002-09-24 06:06:01 +08:00
|
|
|
if (c_base_name[0] == NULL) goto DONE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call h5_cleanup function.
|
|
|
|
*/
|
|
|
|
/*if (h5_cleanup(c_base_name, c_fapl) != 0) {
|
|
|
|
ret_value = 0;
|
|
|
|
goto DONE;
|
|
|
|
}
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
h5_fixname(c_base_name[0], c_fapl, filename, sizeof(filename));
|
2004-12-29 22:26:20 +08:00
|
|
|
HDremove(filename);
|
2002-09-24 06:06:01 +08:00
|
|
|
ret_value =0;
|
2004-12-29 22:26:20 +08:00
|
|
|
|
2002-09-24 06:06:01 +08:00
|
|
|
DONE:
|
|
|
|
if (NULL != c_base_name[0]) HDfree(c_base_name[0]);
|
2005-08-14 04:53:35 +08:00
|
|
|
return ret_value;
|
|
|
|
|
|
|
|
}
|
2004-12-29 22:26:20 +08:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
* Name: h5_exit_c
|
2005-08-14 04:53:35 +08:00
|
|
|
* Purpose: Call 'exit()' to terminate application. Be careful not to
|
2005-01-09 14:19:16 +08:00
|
|
|
* overflow the exit value range since UNIX supports a very
|
|
|
|
* small range such as 1 byte. Therefore, exit(256) may end
|
|
|
|
* up as exit(0).
|
2004-12-29 22:26:20 +08:00
|
|
|
* Inputs: status - status for exit() to return
|
|
|
|
* Returns: none
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
* Tuesday, December 14, 2004
|
|
|
|
* Modifications:
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
nh5_exit_c(int_f *status)
|
|
|
|
{
|
|
|
|
HDexit((int)*status);
|
|
|
|
} /* h5_exit_c */
|
|
|
|
|
2008-10-01 05:05:39 +08:00
|
|
|
/*----------------------------------------------------------------------------
|
|
|
|
* Name: h5_env_nocleanup_c
|
|
|
|
* Purpose: Determines the state of the environment variable HDF5_NOCLEANUP
|
|
|
|
* Input: none
|
|
|
|
* Output: status: 1 - HDF5_NOCLEANUP is set
|
|
|
|
* 0 - HDF5_NOCLEANUP is not set
|
|
|
|
* Returns: none
|
|
|
|
* Programmer: M.S. Breitenfeld
|
2014-03-12 22:20:47 +08:00
|
|
|
* September 30, 2008
|
2008-10-01 05:05:39 +08:00
|
|
|
* Modifications:
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
nh5_env_nocleanup_c(int_f *status)
|
|
|
|
{
|
|
|
|
*status = (int_f)0;
|
|
|
|
if (HDgetenv("HDF5_NOCLEANUP"))
|
|
|
|
*status = (int_f)1;
|
|
|
|
} /* h5_env_nocleanup_c */
|
|
|
|
|