[svn-r485] Changes since 19980710

----------------------

./Makefile.in
./config/commence.in
./config/conclude.in
./config/depend.in
./src/Makefile.in
./test/Makefile.in
	Tests are no longer installed for `make install'.  Added a new
	target `make tests' that builds the tests but doesn't run them.

./configure.in
./configure		[REGENERATED]
./src/H5config.h.in	[REGENERATED]
	Added detection of fork() and waitpid().  If present the
	contants HAVE_FORK and HAVE_WAITPID will be defined in
	H5config.h.

./test/dtypes.c
	Minor tweaks for systems that don't have fork() or waitpid().

./MANIFEST
./tools			[NEW]
./tools/Makefile.in	[NEW]
./tools/h5debug.c	[NEW]
./tools/h5import.c	[NEW]
./tools/h5ls.c		[NEW]
./tools/h5repart.c	[NEW]
	Added a tools directory and moved tools from the src directory
	to here.
This commit is contained in:
Robb Matzke 1998-07-13 10:35:21 -05:00
parent b5189f738d
commit 614ae2dce6
17 changed files with 279 additions and 176 deletions

View File

@ -227,9 +227,6 @@
./src/H5private.h
./src/H5public.h
./src/Makefile.in
./src/debug.c
./src/h5ls.c
./src/h5repart.c
./src/hdf5.h
./test/.distdep
./test/Makefile.in
@ -263,3 +260,8 @@
./testpar/t_file.c
./testpar/testphdf5.c
./testpar/testphdf5.h
./tools/Makefile.in
./tools/h5debug.c
./tools/h5import.c
./tools/h5ls.c
./tools/h5repart.c

View File

@ -11,13 +11,15 @@
@COMMENCE@
# Subdirectories in build-order
SUBDIRS=src test
SUBDIRS=src test tools
##############################################################################
# T A R G E T S
#
# all: Build libraries, header files, and programs in the various
# subdirectories but do not install them.
# all: Build libraries, header files, tests, and programs in the
# various subdirectories but does not run tests or install the
# library, header files, or programs. The components can be
# built individually with the targets lib, progs, and tests.
#
# test: Test the uninstalled library to make sure it works.
#
@ -57,7 +59,7 @@ SUBDIRS=src test
# make used in combination with gcc will maintain dependency
# information automatically.
#
lib progs test _test install uninstall TAGS dep depend:
lib progs tests test _test install uninstall TAGS dep depend:
@@SETX@; for d in $(SUBDIRS); do \
(cd $$d && $(MAKE) $@) || exit 1; \
done

View File

@ -33,8 +33,8 @@ bindir=@bindir@
libdir=@libdir@
includedir=@includedir@
# The default is to build the programs which in turn builds the lib.
all: progs
# The default is to build the library and/or programs
all: lib tests progs
# The following rules insure that the Makefile is up-to-date by rerunning
# various autoconf components (although not all versions of make assume

View File

@ -20,7 +20,8 @@ TAGS: $(LIB_SRC)
-etags $(LIB_SRC)
# Runs each test in order, passing $(TEST_FLAGS) to the program.
test _test: $(PROGS)
tests: $(TESTS)
test _test: tests
@for test in $(TESTS) dummy; do \
if test $$test != dummy; then \
echo "Testing $$test $(TEST_FLAGS)"; \
@ -72,7 +73,7 @@ mostlyclean:
# is part of the HDF5 distribution.
#
clean: mostlyclean
$(RM) $(LIB) $(PROGS) $(CLEAN)
$(RM) $(LIB) $(TESTS) $(PROGS) $(CLEAN)
# Like `clean' except it also removes files that were created by running
# configure. If you've unpacked the source and built HDF5 without creating

View File

@ -27,7 +27,7 @@ dep depend: .distdep
touch .distdep
-perl -p $(ROOT)/bin/distdep .depend >.distdep
.depend: $(LIB_SRC) $(PROG_SRC)
.depend: $(LIB_SRC) $(TEST_SRC) $(PROG_SRC)
@touch .depend
@for dep in $? dummy; do \
if [ $$dep != "dummy" ]; then \

6
configure vendored
View File

@ -1873,7 +1873,7 @@ EOF
esac
for ac_func in getpwuid gethostname system getrusage
for ac_func in getpwuid gethostname system getrusage fork waitpid
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1880: checking for $ac_func" >&5
@ -2512,7 +2512,7 @@ ac_given_srcdir=$srcdir
ac_given_INSTALL="$INSTALL"
trap 'rm -fr `echo "config/depend config/commence config/conclude \
Makefile src/Makefile test/Makefile examples/Makefile src/H5config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
Makefile src/Makefile test/Makefile tools/Makefile examples/Makefile src/H5config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@ -2607,7 +2607,7 @@ EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"config/depend config/commence config/conclude \
Makefile src/Makefile test/Makefile examples/Makefile"}
Makefile src/Makefile test/Makefile tools/Makefile examples/Makefile"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then

View File

@ -178,7 +178,7 @@ esac
dnl ----------------------------------------------------------------------
dnl Check for functions.
dnl
AC_CHECK_FUNCS(getpwuid gethostname system getrusage)
AC_CHECK_FUNCS(getpwuid gethostname system getrusage fork waitpid)
AC_TRY_COMPILE([#include<sys/types.h>],
[off64_t n = 0;],
@ -355,4 +355,4 @@ dnl before we generate them or the Makefiles.
touch ./config/stamp1 ./config/stamp2
AC_OUTPUT(config/depend config/commence config/conclude \
Makefile src/Makefile test/Makefile examples/Makefile)
Makefile src/Makefile test/Makefile tools/Makefile examples/Makefile)

View File

@ -61,6 +61,9 @@
/* The number of bytes in a size_t. */
#undef SIZEOF_SIZE_T
/* Define if you have the fork function. */
#undef HAVE_FORK
/* Define if you have the fseek64 function. */
#undef HAVE_FSEEK64
@ -79,6 +82,9 @@
/* Define if you have the system function. */
#undef HAVE_SYSTEM
/* Define if you have the waitpid function. */
#undef HAVE_WAITPID
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

View File

@ -10,9 +10,8 @@ TRACE=perl ../bin/trace
# Add `-I.' to the C preprocessor flags.
CPPFLAGS=-I. @CPPFLAGS@
# These are our main targets:
# This is our main target:
LIB=libhdf5.a
PROGS=debug h5ls h5repart
# Source and object files for the library (lexicographically)...
LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5D.c H5E.c H5F.c H5Farray.c H5Fcore.c \
@ -28,10 +27,6 @@ LIB_OBJ=$(LIB_SRC:.c=.o)
# Temporary files
MOSTLYCLEAN=H5detect.o H5detect H5Tinit.o H5Tinit.c
# Source and object files for programs...
PROG_SRC=debug.c h5ls.c h5repart.c
PROG_OBJ=$(PROG_SRC:.c=.o)
# Public header files (to be installed)...
PUB_HDR=H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5Dpublic.h \
H5Epublic.h H5Fpublic.h H5Gpublic.h H5HGpublic.h H5HLpublic.h \
@ -53,14 +48,4 @@ H5Tinit.c: H5detect
H5detect: H5detect.o
$(CC) $(CFLAGS) -o $@ H5detect.o $(LIBS)
# How to build the programs...
debug: debug.o $(LIB)
$(CC) $(CFLAGS) -o $@ debug.o $(LIB) $(LIBS)
h5ls: h5ls.o $(LIB)
$(CC) $(CFLAGS) -o $@ h5ls.o $(LIB) $(LIBS)
h5repart: h5repart.o $(LIB)
$(CC) $(CFLAGS) -o $@ h5repart.o $(LIB) $(LIBS)
@CONCLUDE@

View File

@ -1,9 +1,3 @@
testhdf5.o: \
testhdf5.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h
tattr.o: \
tattr.c \
testhdf5.h \
@ -157,34 +151,6 @@ th5s.o: \
../src/H5Zprivate.h \
../src/H5Zpublic.h \
../src/H5Pprivate.h
dtypes.o: \
dtypes.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5private.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
hyperslab.o: \
hyperslab.c \
../src/H5private.h \
@ -238,27 +204,6 @@ dsets.o: \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
cmpd_dset.o: \
cmpd_dset.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h
extend.o: \
extend.c \
../src/hdf5.h \
@ -446,3 +391,58 @@ bittests.o: \
../src/H5Gprivate.h \
../src/H5Gpublic.h \
../src/H5Bprivate.h
cmpd_dset.o: \
cmpd_dset.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h
testhdf5.o: \
testhdf5.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h
dtypes.o: \
dtypes.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5private.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h

View File

@ -11,8 +11,6 @@ CPPFLAGS=-I. -I../src @CPPFLAGS@
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
PROGS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset extend \
external shtype iopipe big links chunk
TESTS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset extend \
external shtype links
TIMINGS=iopipe chunk
@ -26,62 +24,14 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
gheap1.h5 gheap2.h5 gheap3.h5 gheap4.h5 shtype0.h5 shtype1.h5 \
shtype2a.h5 shtype2b.h5 shtype3.h5 links.h5 chunk.h5
# Source and object files for programs... The PROG_SRC list contains all the
# Source and object files for programs... The TEST_SRC list contains all the
# source files and is used for things like dependencies, archiving, etc. The
# other source lists are for the individual tests, the files of which may
# overlap with other tests.
PROG_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c \
TEST_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c \
dtypes.c hyperslab.c istore.c dsets.c cmpd_dset.c extend.c external.c \
iopipe.c gheap.c shtype.c big.c links.c chunk.c bittests.c
PROG_OBJ=$(PROG_SRC:.c=.o)
TESTHDF5_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c
TESTHDF5_OBJ=$(TESTHDF5_SRC:.c=.o)
GHEAP_SRC=gheap.c
GHEAP_OBJ=$(GHEAP_SRC:.c=.o)
DSETS_SRC=dsets.c
DSETS_OBJ=$(DSETS_SRC:.c=.o)
BITTESTS_SRC=bittests.c
BITTESTS_OBJ=$(BITTESTS_SRC:.c=.o)
DTYPES_SRC=dtypes.c
DTYPES_OBJ=$(DTYPES_SRC:.c=.o)
HYPERSLAB_SRC=hyperslab.c
HYPERSLAB_OBJ=$(HYPERSLAB_SRC:.c=.o)
ISTORE_SRC=istore.c
ISTORE_OBJ=$(ISTORE_SRC:.c=.o)
CMPD_DSET_SRC=cmpd_dset.c
CMPD_DSET_OBJ=$(CMPD_DSET_SRC:.c=.o)
EXTEND_SRC=extend.c
EXTEND_OBJ=$(EXTEND_SRC:.c=.o)
EXTERNAL_SRC=external.c
EXTERNAL_OBJ=$(EXTERNAL_SRC:.c=.o)
GRPTIME_SRC=grptime.c
GRPTIME_OBJ=$(GRPTIME_SRC:.c=.o)
SHTYPE_SRC=shtype.c
SHTYPE_OBJ=$(SHTYPE_SRC:.c=.o)
IOPIPE_SRC=iopipe.c
IOPIPE_OBJ=$(IOPIPE_SRC:.c=.o)
BIG_SRC=big.c
BIG_OBJ=$(BIG_SRC:.c=.o)
LINKS_SRC=links.c
LINKS_OBJ=$(LINKS_SRC:.c=.o)
CHUNK_SRC=chunk.c
CHUNK_OBJ=$(CHUNK_SRC:.c=.o)
TEST_OBJ=$(PROG_SRC:.c=.o)
# Private header files (not to be installed)...
PRIVATE_HDR=testhdf5.h
@ -97,52 +47,53 @@ timings _timings: $(TIMINGS)
done;
# How to build the programs...
TESTHDF5_OBJ=testhdf5.o tattr.o tfile.o theap.o tmeta.o tohdr.o tstab.o th5s.o
testhdf5: $(TESTHDF5_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(TESTHDF5_OBJ) ../src/libhdf5.a $(LIBS)
gheap: $(GHEAP_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(GHEAP_OBJ) ../src/libhdf5.a $(LIBS)
gheap: gheap.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ gheap.o ../src/libhdf5.a $(LIBS)
dsets: $(DSETS_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(DSETS_OBJ) ../src/libhdf5.a $(LIBS)
dsets: dsets.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ dsets.o ../src/libhdf5.a $(LIBS)
bittests: $(BITTESTS_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(BITTESTS_OBJ) ../src/libhdf5.a $(LIBS)
bittests: bittests.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ bittests.o ../src/libhdf5.a $(LIBS)
dtypes: $(DTYPES_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(DTYPES_OBJ) ../src/libhdf5.a $(LIBS)
dtypes: dtypes.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ dtypes.o ../src/libhdf5.a $(LIBS)
hyperslab: $(HYPERSLAB_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(HYPERSLAB_OBJ) ../src/libhdf5.a $(LIBS)
hyperslab: hyperslab.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ hyperslab.o ../src/libhdf5.a $(LIBS)
istore: $(ISTORE_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(ISTORE_OBJ) ../src/libhdf5.a $(LIBS)
istore: istore.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ istore.o ../src/libhdf5.a $(LIBS)
cmpd_dset: $(CMPD_DSET_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(CMPD_DSET_OBJ) ../src/libhdf5.a $(LIBS)
cmpd_dset: cmpd_dset.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ cmpd_dset.o ../src/libhdf5.a $(LIBS)
extend: $(EXTEND_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(EXTEND_OBJ) ../src/libhdf5.a $(LIBS)
extend: extend.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ extend.o ../src/libhdf5.a $(LIBS)
external: $(EXTERNAL_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(EXTERNAL_OBJ) ../src/libhdf5.a $(LIBS)
external: external.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ external.o ../src/libhdf5.a $(LIBS)
shtype: $(SHTYPE_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(SHTYPE_OBJ) ../src/libhdf5.a $(LIBS)
shtype: shtype.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ shtype.o ../src/libhdf5.a $(LIBS)
iopipe: $(IOPIPE_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(IOPIPE_OBJ) ../src/libhdf5.a $(LIBS)
iopipe: iopipe.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ iopipe.o ../src/libhdf5.a $(LIBS)
grptime: $(GRPTIME_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(GRPTIME_OBJ) ../src/libhdf5.a $(LIBS)
grptime: grptime.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ grptime.o ../src/libhdf5.a $(LIBS)
big: $(BIG_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(BIG_OBJ) ../src/libhdf5.a $(LIBS)
big: big.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ big.o ../src/libhdf5.a $(LIBS)
links: $(LINKS_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(LINKS_OBJ) ../src/libhdf5.a $(LIBS)
links: links.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ links.o ../src/libhdf5.a $(LIBS)
chunk: $(CHUNK_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(CHUNK_OBJ) ../src/libhdf5.a $(LIBS)
chunk: chunk.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ chunk.o ../src/libhdf5.a $(LIBS)
@CONCLUDE@

View File

@ -62,7 +62,9 @@ static int noverflows_g = 0;
* signal. Therefore, if the following constant is defined then tests that
* might raise SIGFPE are executed in a child process.
*/
#define HANDLE_SIGFPE
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
# define HANDLE_SIGFPE
#endif
/*-------------------------------------------------------------------------
@ -79,15 +81,17 @@ static int noverflows_g = 0;
*
*-------------------------------------------------------------------------
*/
#ifdef HANDLE_SIGFPE
static void
fpe_handler(int __unused__ signo)
{
puts(" -SKIP-");
puts(" Test skipped due to SIGFPE from probable overflow.");
#ifndef HANDLE_SIGFPE
puts(" Remaining tests could not be run.");
puts(" Please turn off SIGFPE on overflows and try again.");
#endif
exit(255);
}
#endif
/*-------------------------------------------------------------------------
@ -870,12 +874,13 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
return 1;
}
}
#endif
/*
* The remainder of this function is executed only by the child.
* The remainder of this function is executed only by the child if
* HANDLE_SIGFPE is defined.
*/
signal(SIGFPE,fpe_handler);
#endif
/* What are the names of the source and destination types */
if (H5Tequal(src, H5T_NATIVE_FLOAT)) {

32
tools/Makefile.in Normal file
View File

@ -0,0 +1,32 @@
# HDF5 Library Makefile(.in)
#
# Copyright (C) 1997 National Center for Supercomputing Applications.
# All rights reserved.
#
#
@COMMENCE@
# Add include directory to the C preprocessor flags.
CPPFLAGS=-I../src @CPPFLAGS@
# These are our main targets:
PROGS=h5debug h5import h5ls h5repart
# Source and object files for programs...
PROG_SRC=h5debug.c h5import.c h5ls.c h5repart.c
PROG_OBJ=$(PROG_SRC:.c=.o)
# How to build the programs...
h5debug: h5debug.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ h5debug.o ../src/libhdf5.a $(LIBS)
h5import: h5import.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ h5import.o ../src/libhdf5.a $(LIBS)
h5ls: h5ls.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ h5ls.o ../src/libhdf5.a $(LIBS)
h5repart: h5repart.o ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ h5repart.o ../src/libhdf5.a $(LIBS)
@CONCLUDE@

119
tools/h5import.c Normal file
View File

@ -0,0 +1,119 @@
/*
* Copyright (C) 1998 NCSA
* All rights reserved.
*
* Programmer: Robb Matzke <matzke@llnl.gov>
* Thursday, June 11, 1998
*
* Purpose: Create an hdf5 file with a 1d dataset of uint8.
*/
#include <fcntl.h>
#include <hdf5.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
/*-------------------------------------------------------------------------
* Function: usage
*
* Purpose: Print a usage message and exit with non-zero status
*
* Return: never returns
*
* Programmer: Robb Matzke
* Thursday, June 11, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
usage (const char *argv0)
{
fprintf (stderr, "Usage: %s -f HDF5-FILE FILES...\n", argv0);
exit (1);
}
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose:
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Robb Matzke
* Thursday, June 11, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
main (int argc, char *argv[])
{
hid_t file, space, dset;
const char *output_name, *dset_name;
int argno, fd=-1;
hsize_t size[1];
struct stat sb;
/* Parse arguments */
if (argc<4) usage (argv[0]);
if (strcmp (argv[1], "-f")) usage (argv[0]);
output_name = argv[2];
/* create the file */
H5E_BEGIN_TRY {
if ((file = H5Fcreate (output_name, H5F_ACC_EXCL,
H5P_DEFAULT, H5P_DEFAULT))<0 &&
(file = H5Fopen (output_name, H5F_ACC_RDWR, H5P_DEFAULT)<0)) {
fprintf (stderr, "%s: unable to create or open hdf5 file\n",
output_name);
exit (1);
}
} H5E_END_TRY;
/* process files from command-line */
for (argno=3; argno<argc; argno++) {
/* Open the file */
if ((dset_name=strrchr (argv[argno], '/'))) dset_name++;
else dset_name = argv[argno];
fprintf (stderr, "%s\n", dset_name);
if ((fd=open (argv[argno], O_RDONLY))<0) {
perror (argv[argno]);
goto next;
}
if (fstat (fd, &sb)<0) {
perror (argv[argno]);
goto next;
}
/* Data space */
size[0] = sb.st_size;
if ((space = H5Screate_simple (1, size, size))<0) goto next;
/* Dataset */
if ((dset=H5Dcreate (file, dset_name, H5T_NATIVE_CHAR,
space, H5P_DEFAULT))<0) goto next;
next:
if (fd>=0) close (fd);
fd = -1;
H5E_BEGIN_TRY {
H5Sclose (space);
H5Dclose (dset);
} H5E_END_TRY;
}
/* Close the file */
H5Fclose (file);
return 0;
}