diff options
author | James Laird <jlaird@hdfgroup.org> | 2006-08-02 23:41:53 (GMT) |
---|---|---|
committer | James Laird <jlaird@hdfgroup.org> | 2006-08-02 23:41:53 (GMT) |
commit | 3e755623cb24eb37c19fa645d74dc46948318253 (patch) | |
tree | 66e0a3807f37d50a8d6e5f3469864c604cd837c6 /test/gen_udlinks.c | |
parent | 71a4d0e9c48c4e02e5384cd3f6e38a2a530e9d22 (diff) | |
download | hdf5-3e755623cb24eb37c19fa645d74dc46948318253.zip hdf5-3e755623cb24eb37c19fa645d74dc46948318253.tar.gz hdf5-3e755623cb24eb37c19fa645d74dc46948318253.tar.bz2 |
[svn-r12528] Added User-Defined links to the library.
Users can create external links using H5L_create_external(). These links
point to an object in another HDF5 file. Users can alter the behavior of
external links or create new kinds of links by registering callbacks
using the H5L interface.
Added tests, tools support, etc.
Also a number of other, minor changes have been made (some restructuring of
the H5L interface, for instance).
Additional documentation and examples are forthcoming.
Diffstat (limited to 'test/gen_udlinks.c')
-rw-r--r-- | test/gen_udlinks.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/gen_udlinks.c b/test/gen_udlinks.c new file mode 100644 index 0000000..1230ffe --- /dev/null +++ b/test/gen_udlinks.c @@ -0,0 +1,81 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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: James Laird <jlaird@hdfgroup.org> + * Tuesday, June 6, 2006 + * + * This program creates HDF5 files with user-defined links. These files + * should be created on a little-endian and a big-endian machine. + * They will be named according to the platform and should + * be placed in the hdf5/test directory so that the links test can use them. + */ + +#include "hdf5.h" +#include <string.h> + +#define NAME_LE_1 "le_extlink1.h5" +#define NAME_LE_2 "le_extlink2.h5" +#define NAME_BE_1 "be_extlink1.h5" +#define NAME_BE_2 "be_extlink2.h5" +#define NAME_BUF_SIZE 25 + +int +main (void) +{ + hid_t fid1=-1; + hid_t fid2=-1; + hid_t gid=-1; + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + + /* Name the files differently depending on the endianness of this platform */ + + switch(H5Tget_order(H5T_NATIVE_INT)) + { + case H5T_ORDER_LE: + strcpy(filename1, NAME_LE_1); + strcpy(filename2, NAME_LE_2); + break; + case H5T_ORDER_BE: + strcpy(filename1, NAME_BE_1); + strcpy(filename2, NAME_BE_2); + break; + default: + goto error; + } + + /* Create the two files */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + + /* Create two groups in the second file */ + if((gid = H5Gcreate(fid2, "group", 0)) < 0) goto error; + if((H5Gclose(gid)) < 0) goto error; + if((gid = H5Gcreate(fid2, "group/subgroup", 0)) < 0) goto error; + if((H5Gclose(gid)) < 0) goto error; + + /* Create an external link in the first file pointing to the group in the second file */ + if(H5Lcreate_external(filename2, "group", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Fclose(fid1); + H5Fclose(fid2); + H5Gclose(gid); + } H5E_END_TRY + return 1; +} |