[svn-r8023] This commit was manufactured by cvs2svn to create branch 'hdf5_1_6'.

This commit is contained in:
cvs2svn
2004-01-06 12:53:16 -05:00
parent 83c7a8dfaa
commit 64e365a48f
8 changed files with 1700 additions and 0 deletions

298
test/testframe.c Normal file
View File

@@ -0,0 +1,298 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
* Tuesday, January 6, 2004
*
* Purpose: Provides support functions for the testing framework.
*
*/
#include "testhdf5.h"
/*
* Definitions for the testing structure.
*/
#define MAXNUMOFTESTS 30
#define MAXTESTNAME 16
#define MAXTESTDESC 64
typedef struct TestStruct {
int NumErrors;
char Description[MAXTESTDESC];
int SkipFlag;
char Name[MAXTESTNAME];
void (*Call)(void);
void (*Cleanup)(void);
} TestStruct;
/*
* Global variables used by InitTest().
*/
static TestStruct Test[MAXNUMOFTESTS];
static int Index = 0;
/*
* Setup a test function and add it to the list of tests.
* It must have no parameters and returns void.
*/
void
AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr)
{
/* Sanity checking */
if (Index >= MAXNUMOFTESTS) {
printf("Too many tests added, increase MAXNUMOFTEST(%d).\n",
MAXNUMOFTESTS);
exit(-1);
} /* end if */
if (HDstrlen(TheDescr) >= MAXTESTDESC) {
printf("Test description too long, increase MAXTESTDESC(%d).\n",
MAXTESTDESC);
exit(-1);
} /* end if */
if (HDstrlen(TheName) >= MAXTESTNAME) {
printf("Test name too long, increase MAXTESTNAME(%d).\n",
MAXTESTNAME);
exit(-1);
} /* end if */
/* Set up test function */
HDstrcpy(Test[Index].Description, TheDescr);
HDstrcpy(Test[Index].Name, TheName);
Test[Index].Call = TheCall;
Test[Index].Cleanup = Cleanup;
Test[Index].NumErrors = -1;
Test[Index].SkipFlag = 0;
/* Increment test count */
Index++;
}
/*
* Initialize testing framework
*/
void TestInit(void)
{
#if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C)
/* Un-buffer the stdout and stderr */
setbuf(stderr, NULL);
setbuf(stdout, NULL);
#endif
/*
* Turn off automatic error reporting since we do it ourselves. Besides,
* half the functions this test calls are private, so automatic error
* reporting wouldn't do much good since it's triggered at the API layer.
*/
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eset_auto (NULL, NULL);
#else
H5Eset_auto (H5E_DEFAULT, NULL, NULL);
#endif /* H5_WANT_H5_V1_6_COMPAT */
}
/*
* Print test usage.
*/
void TestUsage(void)
{
int i;
print_func("Usage: ttsafe [-v[erbose] (l[ow]|m[edium]|h[igh]|0-10)] \n");
print_func(" [-[e]x[clude] name+] \n");
print_func(" [-o[nly] name+] \n");
print_func(" [-b[egin] name] \n");
print_func(" [-s[ummary]] \n");
print_func(" [-c[leanoff]] \n");
print_func(" [-h[elp]] \n");
print_func("\n\n");
print_func("verbose controls the amount of information displayed\n");
print_func("exclude to exclude tests by name\n");
print_func("only to name tests which should be run\n");
print_func("begin start at the name of the test givin\n");
print_func("summary prints a summary of test results at the end\n");
print_func("cleanoff does not delete *.hdf files after execution of tests\n");
print_func("help print out this information\n");
print_func("\n\n");
print_func("This program currently tests the following: \n\n");
print_func("%16s %s\n", "Name", "Description");
print_func("%16s %s\n", "----", "-----------");
for (i = 0; i < Index; i++)
print_func("%16s %s\n", Test[i].Name, Test[i].Description);
print_func("\n\n");
}
/*
* Print test info.
*/
void TestInfo(const char *ProgName)
{
unsigned major, minor, release;
H5get_libversion(&major, &minor, &release);
print_func("\nFor help use: %s -help\n",ProgName);
print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release);
}
/*
* Parse command line information
*/
void TestParseCmdLine(int argc, char *argv[], int *Summary, int *CleanUp)
{
int CLLoop; /* Command Line Loop */
int Loop, Loop1;
for (CLLoop = 1; CLLoop < argc; CLLoop++) {
if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) ||
(HDstrcmp(argv[CLLoop], "-v") == 0))) {
if (argv[CLLoop + 1][0] == 'l')
Verbosity = 4;
else if (argv[CLLoop + 1][0] == 'm')
Verbosity = 6;
else if (argv[CLLoop + 1][0] == 'h')
Verbosity = 10;
else
Verbosity = atoi(argv[CLLoop + 1]);
} /* end if */
if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) ||
(HDstrcmp(argv[CLLoop], "-s") == 0)))
*Summary = 1;
if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-help") == 0) ||
(HDstrcmp(argv[CLLoop], "-h") == 0))) {
TestUsage();
exit(0);
}
if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) ||
(HDstrcmp(argv[CLLoop], "-c") == 0)))
*CleanUp = 0;
if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) ||
(HDstrcmp(argv[CLLoop], "-x") == 0))) {
Loop = CLLoop + 1;
while ((Loop < argc) && (argv[Loop][0] != '-')) {
for (Loop1 = 0; Loop1 < Index; Loop1++)
if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
Test[Loop1].SkipFlag = 1;
Loop++;
} /* end while */
} /* end if */
if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-begin") == 0) ||
(HDstrcmp(argv[CLLoop], "-b") == 0))) {
Loop = CLLoop + 1;
while ((Loop < argc) && (argv[Loop][0] != '-')) {
for (Loop1 = 0; Loop1 < Index; Loop1++) {
if (HDstrcmp(argv[Loop], Test[Loop1].Name) != 0)
Test[Loop1].SkipFlag = 1;
if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
Loop1 = Index;
} /* end for */
Loop++;
} /* end while */
} /* end if */
if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) ||
(HDstrcmp(argv[CLLoop], "-o") == 0))) {
for (Loop = 0; Loop < Index; Loop++)
Test[Loop].SkipFlag = 1;
Loop = CLLoop + 1;
while ((Loop < argc) && (argv[Loop][0] != '-')) {
for (Loop1 = 0; Loop1 < Index; Loop1++)
if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0)
Test[Loop1].SkipFlag = 0;
Loop++;
} /* end while */
} /* end if */
} /* end for */
}
/*
* Perform Tests.
*/
void PerformTests(void)
{
int Loop;
for (Loop = 0; Loop < Index; Loop++)
if (Test[Loop].SkipFlag) {
MESSAGE(2, ("Skipping -- %s \n", Test[Loop].Description));
} else {
MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
MESSAGE(5, ("===============================================\n"));
Test[Loop].NumErrors = num_errs;
Test[Loop].Call();
Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
MESSAGE(5, ("===============================================\n"));
MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors));
}
MESSAGE(2, ("\n\n"))
if (num_errs)
print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs);
else
print_func("All tests were successful. \n\n");
}
/*
* Display test summary.
*/
void TestSummary(void)
{
int Loop;
print_func("Summary of Test Results:\n");
print_func("Name of Test Errors Description of Test\n");
print_func("---------------- ------ --------------------------------------\n");
for (Loop = 0; Loop < Index; Loop++) {
if (Test[Loop].NumErrors == -1)
print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
else
print_func("%16s %6d %s\n", Test[Loop].Name, (int)Test[Loop].NumErrors, Test[Loop].Description);
}
print_func("\n\n");
}
/*
* Cleanup files from testing
*/
void TestCleanup(void)
{
int Loop;
MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
/* call individual cleanup routines in each source module */
for (Loop = 0; Loop < Index; Loop++)
if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL)
Test[Loop].Cleanup();
}

View File

@@ -0,0 +1,498 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "testh5diff.h"
/*UINT_MAX Maximum value for a variable of type unsigned int. 4294967295 */
#define UIMAX 4294967295u
/*
# ##############################################################################
# # Common usage
# ##############################################################################
# 1.0
-h
# 1.1
file1.h5 file2.h5 g1/dset1 g1/dset2
# 1.2
file1.h5 file2.h5 -n 2 g1/dset1 g1/dset2
# 1.3
file1.h5 file2.h5 -d 5 g1/dset3 g1/dset4
# 1.4
file1.h5 file2.h5 -p 0.05 g1/dset3 g1/dset4
# 1.5
file1.h5 file2.h5 -r g1/dset1 g1/dset2
# 1.6
file1.h5 file2.h5
# ##############################################################################
# # basic types
# ##############################################################################
# 2.0
file3.h5 file3.h5 dset group
# 2.1
file3.h5 file3.h5 dset link
# 2.2
file3.h5 file3.h5 dset type
# 2.3
file3.h5 file3.h5 group group
# 2.4
file3.h5 file3.h5 type type
# 2.5
file3.h5 file3.h5 link link
# ##############################################################################
# # Dimensions
# ##############################################################################
# 4.0
file5.h5 file5.h5 dset1 dset2
# 4.1
file5.h5 file5.h5 dset3 dset4
# 4.2
file5.h5 file5.h5 dset5 dset6
# ##############################################################################
# # Dataset types
# ##############################################################################
# 5.0
file6.h5 file6.h5 dset0a dset0b
# 5.1
file6.h5 file6.h5 dset1a dset1b
# 5.2
file6.h5 file6.h5 dset2a dset2b
# 5.3
file6.h5 file6.h5 dset3a dset4b
# 5.4
file6.h5 file6.h5 dset4a dset4b
# 5.5
file6.h5 file6.h5 dset5a dset5b
# 5.6
file6.h5 file6.h5 dset6a dset6b
# 5.7
file6.h5 file6.h5 dset7a dset7b
# 5.8
file6.h5 file6.h5 dset8a dset8b
# ##############################################################################
# # Error messages
# ##############################################################################
# 6.0: Check if the command line number of arguments is less than 3
h5diff_test1.h5
# 6.1: Check for invalid options
h5diff_test1.h5 h5diff_test2.h5 -x
# ##############################################################################
# # -d
# ##############################################################################
# 6.2: no value
file1.h5 file2.h5 -d g1/dset3 g1/dset4
# 6.3: negative value
file1.h5 file2.h5 -d -4 g1/dset3 g1/dset4
# 6.4: zero
file1.h5 file2.h5 -d 0 g1/dset3 g1/dset4
# 6.5: non number
file1.h5 file2.h5 -d u g1/dset3 g1/dset4
# 6.6: hexadecimal
file1.h5 file2.h5 -d 0x1 g1/dset3 g1/dset4
# 6.7: string
file1.h5 file2.h5 -d "1" g1/dset3 g1/dset4
# 6.8: repeated option
file1.h5 file2.h5 -d 1 -d 2 g1/dset3 g1/dset4
# 6.9: number larger than biggest difference
file1.h5 file2.h5 -d 200 g1/dset3 g1/dset4
# 6.10: number smaller than smallest difference
file1.h5 file2.h5 -d 1 g1/dset3 g1/dset4
# ##############################################################################
# # -p
# ##############################################################################
# 6.11: no value
file1.h5 file2.h5 -p g1/dset3 g1/dset4
# 6.12: negative value
file1.h5 file2.h5 -p -4 g1/dset3 g1/dset4
# 6.13: zero
file1.h5 file2.h5 -p 0 g1/dset3 g1/dset4
# 6.14: non number
file1.h5 file2.h5 -p u g1/dset3 g1/dset4
# 6.15: hexadecimal
file1.h5 file2.h5 -p 0x1 g1/dset3 g1/dset4
# 6.16: string
file1.h5 file2.h5 -p "0.21" g1/dset3 g1/dset4
# 6.17: repeated option
file1.h5 file2.h5 -p 0.21 -p 0.22 g1/dset3 g1/dset4
# 6.18: number larger than biggest difference
file1.h5 file2.h5 -p 2 g1/dset3 g1/dset4
# 6.19: number smaller than smallest difference
file1.h5 file2.h5 -p 0.005 g1/dset3 g1/dset4
# ##############################################################################
# # -n
# ##############################################################################
# 6.20: no value
file1.h5 file2.h5 -n g1/dset3 g1/dset4
# 6.21: negative value
file1.h5 file2.h5 -n -4 g1/dset3 g1/dset4
# 6.22: zero
file1.h5 file2.h5 -n 0 g1/dset3 g1/dset4
# 6.23: non number
file1.h5 file2.h5 -n u g1/dset3 g1/dset4
# 6.24: hexadecimal
file1.h5 file2.h5 -n 0x1 g1/dset3 g1/dset4
# 6.25: string
file1.h5 file2.h5 -n "2" g1/dset3 g1/dset4
# 6.26: repeated option
file1.h5 file2.h5 -n 2 -n 3 g1/dset3 g1/dset4
# 6.27: number larger than biggest difference
file1.h5 file2.h5 -n 200 g1/dset3 g1/dset4
# 6.28: number smaller than smallest difference
file1.h5 file2.h5 -n 1 g1/dset3 g1/dset4
# ##############################################################################
# # non valid files
# ##############################################################################
file1.h6 file2.h6
*/
/*-------------------------------------------------------------------------
* Basic review tests
*-------------------------------------------------------------------------
*/
int test_basic(const char *file1, const char *file2)
{
hid_t file1_id, file2_id;
hid_t group1_id, group2_id, group3_id;
herr_t status;
hsize_t dims[2] = { 3,2 };
/* Test */
double data1[3][2] = {{1,1},{1,1},{1,1}};
double data2[3][2] = {{1,1.1},{1.01,1.001},{1.0001,1}};
double data3[3][2] = {{100,110},{100,100},{100,100}};
double data4[3][2] = {{110,100},{90,80},{140,200}};
/*-------------------------------------------------------------------------
* Create two files
*-------------------------------------------------------------------------
*/
file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
file2_id = H5Fcreate (file2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create groups */
group1_id = H5Gcreate(file1_id, "g1", 0);
group2_id = H5Gcreate(file2_id, "g1", 0);
group3_id = H5Gcreate(file2_id, "g2", 0);
write_dset(group1_id,2,dims,"dset1",H5T_NATIVE_DOUBLE,data1);
write_dset(group2_id,2,dims,"dset2",H5T_NATIVE_DOUBLE,data2);
write_dset(group1_id,2,dims,"dset3",H5T_NATIVE_DOUBLE,data3);
write_dset(group2_id,2,dims,"dset4",H5T_NATIVE_DOUBLE,data4);
write_dset(group2_id,2,dims,"dset1",H5T_NATIVE_DOUBLE,data2);
/*-------------------------------------------------------------------------
* Close
*-------------------------------------------------------------------------
*/
status = H5Gclose(group1_id);
status = H5Gclose(group2_id);
status = H5Gclose(group3_id);
status = H5Fclose(file1_id);
status = H5Fclose(file2_id);
return status;
}
/*-------------------------------------------------------------------------
* Compare different types: H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK
*-------------------------------------------------------------------------
*/
int test_types(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
hid_t group_id;
hid_t type_id;
herr_t status;
hsize_t dims[1]={1};
/* Compound datatype */
typedef struct s_t
{
int a;
float b;
} s_t;
/*-------------------------------------------------------------------------
* Create one file
*-------------------------------------------------------------------------
*/
file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
* H5G_DATASET
*-------------------------------------------------------------------------
*/
write_dset(file1_id,1,dims,"dset",H5T_NATIVE_INT,0);
/*-------------------------------------------------------------------------
* H5G_GROUP
*-------------------------------------------------------------------------
*/
group_id = H5Gcreate(file1_id, "group", 0);
status = H5Gclose(group_id);
/*-------------------------------------------------------------------------
* H5G_TYPE
*-------------------------------------------------------------------------
*/
/* Create a memory compound datatype */
type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t));
H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_INT);
H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_FLOAT);
/* Commit compound datatype and close it */
H5Tcommit(file1_id, "type", type_id);
H5Tclose(type_id);
/*-------------------------------------------------------------------------
* H5G_LINK
*-------------------------------------------------------------------------
*/
status = H5Glink(file1_id, H5G_LINK_SOFT, "dset", "link");
/*-------------------------------------------------------------------------
* Close
*-------------------------------------------------------------------------
*/
status = H5Fclose(file1_id);
return status;
}
/*-------------------------------------------------------------------------
* Datasets datatypes
*-------------------------------------------------------------------------
*/
int test_native(const char *file1, const char UNUSED *file2)
{
hid_t file1_id;
hsize_t dims[2]={3,2};
herr_t status;
char buf1a[3][2] = {{1,1},{1,1},{1,1}};
char buf1b[3][2] = {{1,1},{3,4},{5,6}};
short buf2a[3][2] = {{1,1},{1,1},{1,1}};
short buf2b[3][2] = {{1,1},{3,4},{5,6}};
int buf3a[3][2] = {{1,1},{1,1},{1,1}};
int buf3b[3][2] = {{1,1},{3,4},{5,6}};
long buf4a[3][2] = {{1,1},{1,1},{1,1}};
long buf4b[3][2] = {{1,1},{3,4},{5,6}};
float buf5a[3][2] = {{1,1},{1,1},{1,1}};
float buf5b[3][2] = {{1,1},{3,4},{5,6}};
double buf6a[3][2] = {{1,1},{1,1},{1,1}};
double buf6b[3][2] = {{1,1},{3,4},{5,6}};
/*unsigned/signed test
signed char -128 to 127
unsigned char 0 to 255
*/
char buf7a[3][2] = {{-1,-128},{-1,-1},{-1,-1}};
unsigned char buf7b[3][2] = {{1,128},{1,1},{1,1}};
/* long_long test */
long_long buf8a[3][2] = {{1,1},{1,1},{1,1}};
long_long buf8b[3][2] = {{1,1},{3,4},{5,6}};
unsigned long_long buf9a[3][2] = {{1,1},{1,1},{1,1}};
unsigned long_long buf9b[3][2] = {{1,1},{3,4},{5,6}};
unsigned int buf10a[3][2] = {{UIMAX,1},{1,1},{1,1}};
unsigned int buf10b[3][2] = {{UIMAX-1,1},{3,4},{5,6}};
/*-------------------------------------------------------------------------
* Create a file
*-------------------------------------------------------------------------
*/
file1_id = H5Fcreate (file1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
* Check for different storage order. Give a warning if they are different
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset0a",H5T_STD_I16LE,buf2a);
write_dset(file1_id,2,dims,"dset0b",H5T_STD_I32LE,buf3b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_CHAR
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset1a",H5T_NATIVE_CHAR,buf1a);
write_dset(file1_id,2,dims,"dset1b",H5T_NATIVE_CHAR,buf1b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_SHORT
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset2a",H5T_NATIVE_SHORT,buf2a);
write_dset(file1_id,2,dims,"dset2b",H5T_NATIVE_SHORT,buf2b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_INT
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset3a",H5T_NATIVE_INT,buf3a);
write_dset(file1_id,2,dims,"dset3b",H5T_NATIVE_INT,buf3b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_LONG
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset4a",H5T_NATIVE_LONG,buf4a);
write_dset(file1_id,2,dims,"dset4b",H5T_NATIVE_LONG,buf4b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_FLOAT
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset5a",H5T_NATIVE_FLOAT,buf5a);
write_dset(file1_id,2,dims,"dset5b",H5T_NATIVE_FLOAT,buf5b);
/*-------------------------------------------------------------------------
* Check H5T_NATIVE_DOUBLE
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset6a",H5T_NATIVE_DOUBLE,buf6a);
write_dset(file1_id,2,dims,"dset6b",H5T_NATIVE_DOUBLE,buf6b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_CHAR and H5T_NATIVE_UCHAR
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset7a",H5T_NATIVE_CHAR,buf7a);
write_dset(file1_id,2,dims,"dset7b",H5T_NATIVE_UCHAR,buf7b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_LLONG
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset8a",H5T_NATIVE_LLONG,buf8a);
write_dset(file1_id,2,dims,"dset8b",H5T_NATIVE_LLONG,buf8b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_ULLONG
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset9a",H5T_NATIVE_ULLONG,buf9a);
write_dset(file1_id,2,dims,"dset9b",H5T_NATIVE_ULLONG,buf9b);
/*-------------------------------------------------------------------------
* H5T_NATIVE_INT
*-------------------------------------------------------------------------
*/
write_dset(file1_id,2,dims,"dset10a",H5T_NATIVE_UINT,buf10a);
write_dset(file1_id,2,dims,"dset10b",H5T_NATIVE_UINT,buf10b);
/*-------------------------------------------------------------------------
* Close
*-------------------------------------------------------------------------
*/
status = H5Fclose(file1_id);
return status;
}

View File

@@ -0,0 +1,36 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "testh5diff.h"
int main(int UNUSED argc, const UNUSED char *argv[])
{
test_basic ("file1.h5","file2.h5");
test_types ("file3.h5",NULL);
test_native("file4.h5",NULL);
/* generate 2 files with attribute differences */
test_attr("file5.h5",0);
test_attr("file6.h5",1);
/* generate 2 files with all datatype differences */
test_dsetall("file7.h5",0);
test_dsetall("file8.h5",1);
return 0;
}

View File

@@ -0,0 +1,99 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "testh5diff.h"
/*-------------------------------------------------------------------------
* Function: write_attr
*
* Purpose: utility function to write an attribute in LOC_ID
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November 12, 2003
*
*-------------------------------------------------------------------------
*/
int write_attr(hid_t loc_id,
int rank,
hsize_t *dims,
const char *attr_name,
hid_t type_id,
void *buf)
{
hid_t attr_id;
hid_t space_id;
herr_t status;
/* Create a buf space */
space_id = H5Screate_simple(rank,dims,NULL);
/* Create the attribute */
attr_id = H5Acreate(loc_id,attr_name,type_id,space_id,H5P_DEFAULT);
/* Write the buf */
if ( buf )
status = H5Awrite(attr_id,type_id,buf);
/* Close */
status = H5Aclose(attr_id);
status = H5Sclose(space_id);
return status;
}
/*-------------------------------------------------------------------------
* Function: write_dset
*
* Purpose: utility function to create and write a dataset in LOC_ID
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November 12, 2003
*
*-------------------------------------------------------------------------
*/
int write_dset( hid_t loc_id,
int rank,
hsize_t *dims,
const char *dset_name,
hid_t type_id,
void *buf )
{
hid_t dset_id;
hid_t space_id;
herr_t status;
/* Create a buf space */
space_id = H5Screate_simple(rank,dims,NULL);
/* Create a dataset */
dset_id = H5Dcreate(loc_id,dset_name,type_id,space_id,H5P_DEFAULT);
/* Write the buf */
if ( buf )
status = H5Dwrite(dset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
/* Close */
status = H5Dclose(dset_id);
status = H5Sclose(space_id);
return status;
}

View File

@@ -0,0 +1,175 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "hdf5.h"
#include "h5test.h"
#include "h5repack.h"
static void CANNOT_LAYOUT(pack_opt_t *options)
{
if (options->verbose)
printf("Warning: This layout cannot be applied, this object\
requires chunked layout\n");
}
/*-------------------------------------------------------------------------
* Function: layout_this
*
* Purpose: check if the layout can be applied;
* find the object name NAME (got from the traverse list)
* in the repack options list; assign the layout information OBJ
*
* Return: 0 cannot apply, 1 can, -1 error
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: December 30, 2003
*
*-------------------------------------------------------------------------
*/
int layout_this(hid_t dcpl_id, /* DCPL from input object */
const char* name, /* object name from traverse list */
pack_opt_t *options, /* repack options */
pack_info_t *pack /*OUT*/) /* object to apply layout */
{
int nfilters; /* number of filters in the input object */
H5D_layout_t layout; /* layout */
char *pdest;
int result;
int i, ret=1;
/* check if we have filters in the input object */
if ((nfilters = H5Pget_nfilters(dcpl_id))<0)
return -1;
/* applying to all objects */
if (options->all_layout)
{
/* assign the global layout info to the OBJ info */
pack->layout=options->layout_g;
switch (options->layout_g)
{
case H5D_CHUNKED:
pack->chunk.rank=options->chunk_g.rank;
for ( i=0; i<pack->chunk.rank; i++)
pack->chunk.chunk_lengths[i]=options->chunk_g.chunk_lengths[i];
break;
case H5D_CONTIGUOUS:
case H5D_COMPACT:
if (nfilters)
{
CANNOT_LAYOUT(options);
ret=0;
}
break;
default:
ret=0;
break;
}/*switch*/
return ret;
}
/* find the object */
for ( i=0; i<options->op_tbl->nelems; i++)
{
layout=options->op_tbl->objs[i].layout;
if ( layout != -1 )
{
if (strcmp(options->op_tbl->objs[i].path,name)==0)
{
if (nfilters && layout!=H5D_CHUNKED)
{
CANNOT_LAYOUT(options);
return 0;
}
else
{
*pack=options->op_tbl->objs[i];
return 1;
}
}
pdest = strstr(name,options->op_tbl->objs[i].path);
result = (int)(pdest - name);
/* found at position 1, meaning without '/' */
if( pdest != NULL && result==1 )
{
if (nfilters && layout!=H5D_CHUNKED)
{
CANNOT_LAYOUT(options);
return 0;
}
else
{
*pack=options->op_tbl->objs[i];
return 1;
}
}
}
}
return 0;
}
/*-------------------------------------------------------------------------
* Function: apply_layout
*
* Purpose: apply a layout to the property list. Valid values for layout are:
*
* H5D_COMPACT
* Store raw data in the dataset object header in file.
* This should only be used for very small amounts of raw data.
* H5D_CONTIGUOUS
* Store raw data separately from the object header in one large chunk
* in the file.
* H5D_CHUNKED
* Store raw data separately from the object header as chunks of data in
* separate locations in the file.
*
* Return: 0, ok, -1 no
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: December 30, 2003
*
*-------------------------------------------------------------------------
*/
int apply_layout(hid_t dcpl_id,
pack_info_t *obj) /* info about object */
{
if (H5Pset_layout(dcpl_id, obj->layout)<0)
return -1;
if (H5D_CHUNKED==obj->layout) { /* set up chunk */
if(H5Pset_chunk(dcpl_id, obj->chunk.rank, obj->chunk.chunk_lengths)<0)
return -1;
}
else if (H5D_COMPACT==obj->layout) {
if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY)<0)
return -1;
}
return 0;
}

199
tools/lib/h5diff.h Normal file
View File

@@ -0,0 +1,199 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef H5DIFF_H__
#define H5DIFF_H__
#include "hdf5.h"
#include "h5trav.h"
#if 0
#define H5DIFF_DEBUG
#endif
/*-------------------------------------------------------------------------
* printf formatting
*-------------------------------------------------------------------------
*/
#define FFORMAT "%-15f %-15f %-15f\n"
#define IFORMAT "%-15d %-15d %-15d\n"
#define CFORMAT "%-16c %-17c\n"
#define SFORMAT "%-16s %-17s\n"
#define UIFORMAT "%-15u %-15u %-15u\n"
#define LIFORMAT "%-15ld %-15ld %-15ld\n"
#define ULIFORMAT "%-15lu %-15lu %-15lu\n"
/* with -p option */
#define FPFORMAT "%-15.10g %-15.10g %-15.10g %-14.10g\n"
#define IPFORMAT "%-15d %-15d %-15d %-14d\n"
#define UIPFORMAT "%-15u %-15u %-15u %-14u\n"
#define LPIFORMAT "%-15ld %-15ld %-15ld %-14ld\n"
#define ULPIFORMAT "%-15lu %-15lu %-15lu %-14lu\n"
#define SPACES " "
/*-------------------------------------------------------------------------
* command line options
*-------------------------------------------------------------------------
*/
typedef struct {
int r; /* report only what objects differ */
int d; /* delta */
double delta; /* delta value */
int p; /* relative error */
double percent; /* relative error value */
int n; /* count */
int count; /* count value */
int verbose; /* print information */
} diff_opt_t;
/*-------------------------------------------------------------------------
* public functions
*-------------------------------------------------------------------------
*/
#ifdef __cplusplus
extern "C" {
#endif
int h5diff(const char *fname1,
const char *fname2,
const char *objname1,
const char *objname2,
diff_opt_t *options);
#ifdef __cplusplus
}
#endif
/*-------------------------------------------------------------------------
* private functions
*-------------------------------------------------------------------------
*/
int diff_dataset( hid_t file1_id,
hid_t file2_id,
const char *obj1_name,
const char *obj2_name,
diff_opt_t *options );
int diff_datasetid( hid_t dset1_id,
hid_t dset2_id,
const char *obj1_name,
const char *obj2_name,
diff_opt_t *options );
int diff( hid_t file1_id,
const char *path1,
hid_t file2_id,
const char *path2,
diff_opt_t *options,
H5G_obj_t type );
int diff_compare( hid_t file1_id,
const char *file1_name,
const char *obj1_name,
int nobjects1,
trav_info_t *info1,
hid_t file2_id,
const char *file2_name,
const char *obj2_name,
int nobjects2,
trav_info_t *info2,
diff_opt_t *options );
int diff_match( hid_t file1_id,
int nobjects1,
trav_info_t *info1,
hid_t file2_id,
int nobjects2,
trav_info_t *info2,
diff_opt_t *options );
int diff_array( void *_mem1,
void *_mem2,
hsize_t nelmts,
int rank,
hsize_t *dims,
diff_opt_t *options,
const char *name1,
const char *name2,
hid_t m_type,
hid_t container1_id,
hid_t container2_id); /* dataset where the reference came from*/
int diff_can_type( hid_t f_type1, /* file data type */
hid_t f_type2, /* file data type */
int rank1,
int rank2,
hsize_t *dims1,
hsize_t *dims2,
hsize_t *maxdim1,
hsize_t *maxdim2,
const char *obj1_name,
const char *obj2_name,
diff_opt_t *options );
int diff_attr(hid_t loc1_id,
hid_t loc2_id,
const char *path1,
const char *path2,
diff_opt_t *options
);
/*-------------------------------------------------------------------------
* utility functions
*-------------------------------------------------------------------------
*/
void print_type(hid_t type);
const char* diff_basename(const char *name);
const char* get_type(int type);
const char* get_class(H5T_class_t tclass);
const char* get_sign(H5T_sign_t sign);
void print_dims( int r, hsize_t *d );
void print_pos( int *ph,
int per,
hsize_t curr_pos,
hsize_t *acc,
hsize_t *pos,
int rank,
const char *obj1,
const char *obj2 );
#if defined (H5DIFF_DEBUG)
void print_sizes( const char *obj1, const char *obj2,
hid_t f_type1, hid_t f_type2,
hid_t m_type1, hid_t m_type2 );
#endif
#ifdef NOT_YET
void diff_list( const char *filename, int nobjects, trav_info_t *info );
#endif /* NOT_YET */
#endif /* H5DIFF_H__ */

139
tools/lib/h5trav.h Normal file
View File

@@ -0,0 +1,139 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef H5TRAV_H__
#define H5TRAV_H__
#include "hdf5.h"
#if 0
#define H5_TRAV_DEBUG
#endif
/*-------------------------------------------------------------------------
* public struct to store name and type of an object
* the TYPE can be:
* H5G_UNKNOWN = -1,
* H5G_LINK, Object is a symbolic link
* H5G_GROUP, Object is a group
* H5G_DATASET, Object is a dataset
* H5G_TYPE, Object is a named data type
*-------------------------------------------------------------------------
*/
typedef struct trav_info_t {
char *name;
H5G_obj_t type;
} trav_info_t;
/*-------------------------------------------------------------------------
* keep record of hard link information
*-------------------------------------------------------------------------
*/
typedef struct trav_link_t {
char *new_name;
} trav_link_t;
/*-------------------------------------------------------------------------
* struct to store basic info needed for the h5trav table traversal algorythm
*-------------------------------------------------------------------------
*/
typedef struct trav_obj_t {
haddr_t objno; /* object number from H5Gget_objinfo */
unsigned flags[2]; /* h5diff.object is present or not in both files*/
char *name; /* name */
int displayed; /* hard link already traversed once */
H5G_obj_t type; /* type of object */
trav_link_t *links; /* array of possible link names */
int sizelinks; /* size of links array */
int nlinks; /* number of links */
} trav_obj_t;
/*-------------------------------------------------------------------------
* private struct that stores all objects
*-------------------------------------------------------------------------
*/
typedef struct trav_table_t {
int size;
int nobjs;
trav_obj_t *objs;
} trav_table_t;
/*-------------------------------------------------------------------------
* public functions
*-------------------------------------------------------------------------
*/
#ifdef __cplusplus
extern "C" {
#endif
/*-------------------------------------------------------------------------
* "h5trav info" public functions
*-------------------------------------------------------------------------
*/
int h5trav_getinfo( hid_t file_id, trav_info_t *info );
int h5trav_getindex( const char *obj, int nobjs, trav_info_t *info );
void h5trav_freeinfo( trav_info_t *info, int nobjs );
void h5trav_printinfo(int nobjs, trav_info_t *info);
/*-------------------------------------------------------------------------
* "h5trav table" public functions
*-------------------------------------------------------------------------
*/
int h5trav_getindext(const char *obj,trav_table_t *travt);
int h5trav_gettable(hid_t fid, trav_table_t *travt);
void h5trav_printtable(trav_table_t *table);
#ifdef __cplusplus
}
#endif
/*-------------------------------------------------------------------------
* table private functions
*-------------------------------------------------------------------------
*/
void trav_table_init(trav_table_t **table);
void trav_table_free(trav_table_t *table);
int trav_table_search(haddr_t objno,
trav_table_t *table );
void trav_table_add(haddr_t objno,
char *objname,
H5G_obj_t type,
trav_table_t *table);
void trav_table_addflags(unsigned *flags,
char *objname,
H5G_obj_t type,
trav_table_t *table);
void trav_table_addlink(trav_table_t *table,
int j /* the object index */,
char *path );
#endif /* H5TRAV_H__ */

256
tools/lib/h5trav_table.c Normal file
View File

@@ -0,0 +1,256 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5trav.h"
#include "H5private.h"
/*-------------------------------------------------------------------------
* Function: trav_table_search
*
* Purpose: Search in the table for OBJNO
*
* Return: index of object in table
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November 4, 2002
*
*-------------------------------------------------------------------------
*/
int trav_table_search(haddr_t objno, trav_table_t *table )
{
int i;
for (i = 0; i < table->nobjs; i++)
if (table->objs[i].objno == objno)
return i;
return -1;
}
/*-------------------------------------------------------------------------
* Function: trav_table_add
*
* Purpose: Add OBJNO, NAME and TYPE of object to table
*
* Return: void
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November 4, 2002
*
*-------------------------------------------------------------------------
*/
void trav_table_add(haddr_t objno,
char *name,
H5G_obj_t type,
trav_table_t *table)
{
int i;
if (table->nobjs == table->size) {
table->size *= 2;
table->objs =
(trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
for (i = table->nobjs; i < table->size; i++) {
table->objs[i].objno = 0;
table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
table->objs[i].displayed = 0;
table->objs[i].type = H5G_UNKNOWN;
table->objs[i].name = NULL;
table->objs[i].links = NULL;
table->objs[i].nlinks = 0;
table->objs[i].sizelinks = 0;
}
}
i = table->nobjs++;
table->objs[i].objno = objno;
table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
HDfree(table->objs[i].name);
table->objs[i].name = (char *)HDstrdup(name);
table->objs[i].type = type;
table->objs[i].links = NULL;
table->objs[i].nlinks = 0;
}
/*-------------------------------------------------------------------------
* Function: trav_table_addflags
*
* Purpose: Add FLAGS, NAME and TYPE of object to table
*
* Return: void
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November 4, 2002
*
*-------------------------------------------------------------------------
*/
void trav_table_addflags(unsigned *flags,
char *name,
H5G_obj_t type,
trav_table_t *table)
{
int i;
if (table->nobjs == table->size) {
table->size *= 2;
table->objs =
(trav_obj_t*)HDrealloc(table->objs, table->size * sizeof(trav_obj_t));
for (i = table->nobjs; i < table->size; i++) {
table->objs[i].objno = 0;
table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
table->objs[i].displayed = 0;
table->objs[i].type = H5G_UNKNOWN;
table->objs[i].name = NULL;
table->objs[i].links = NULL;
table->objs[i].nlinks = 0;
table->objs[i].sizelinks = 0;
}
}
i = table->nobjs++;
table->objs[i].objno = 0;
table->objs[i].flags[0] = flags[0];
table->objs[i].flags[1] = flags[1];
HDfree(table->objs[i].name);
table->objs[i].name = (char *)HDstrdup(name);
table->objs[i].type = type;
table->objs[i].links = NULL;
table->objs[i].nlinks = 0;
}
/*-------------------------------------------------------------------------
* Function: trav_table_init
*
* Purpose: Initialize the table
*
* Return: void
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November 4, 2002
*
*-------------------------------------------------------------------------
*/
void trav_table_init( trav_table_t **tbl )
{
int i;
trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t));
table->size = 20;
table->nobjs = 0;
table->objs =
(trav_obj_t*)HDmalloc(table->size * sizeof(trav_obj_t));
for (i = 0; i < table->size; i++) {
table->objs[i].objno = 0;
table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
table->objs[i].displayed = 0;
table->objs[i].type = H5G_UNKNOWN;
table->objs[i].name = NULL;
table->objs[i].links = NULL;
table->objs[i].nlinks = 0;
table->objs[i].sizelinks = 0;
}
*tbl = table;
}
/*-------------------------------------------------------------------------
* Function: trav_table_free
*
* Purpose: free table memory
*
* Return: void
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: November 4, 2002
*
*-------------------------------------------------------------------------
*/
void trav_table_free( trav_table_t *table )
{
int i, j;
for ( i = 0; i < table->nobjs; i++)
{
HDfree( table->objs[i].name );
if (table->objs[i].nlinks)
{
for ( j=0; j<table->objs[i].nlinks; j++)
HDfree( table->objs[i].links[j].new_name );
HDfree(table->objs[i].links);
}
}
HDfree(table->objs);
HDfree(table);
}
/*-------------------------------------------------------------------------
* Function: trav_table_addlink
*
* Purpose: Add a hardlink name to the object
*
* Return: void
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Date: December 17, 2003
*
*-------------------------------------------------------------------------
*/
void trav_table_addlink(trav_table_t *table,
int j /* the object index */,
char *path )
{
int k;
/* already inserted */
if (strcmp(table->objs[j].name,path)==0)
return;
/* allocate space if necessary */
if (table->objs[j].nlinks == table->objs[j].sizelinks) {
table->objs[j].sizelinks += 2;
table->objs[j].links =
(trav_link_t*)HDrealloc(table->objs[j].links,
table->objs[j].sizelinks * sizeof(trav_link_t));
}
/* insert it */
k=table->objs[j].nlinks++;
table->objs[j].links[k].new_name = (char*)HDstrdup(path);
}