summaryrefslogtreecommitdiffstats
path: root/src/H5Lexternal.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-10 17:11:34 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-10 17:11:34 (GMT)
commita83a4ece41ba2777ad8c6b5f82e476d9abc86974 (patch)
tree1d9a28e2486e9e7957e6bf801d4393e716754f7d /src/H5Lexternal.c
parente8f31a24797a129fd8ed2c7ec5e2a080d0b5fb88 (diff)
downloadhdf5-a83a4ece41ba2777ad8c6b5f82e476d9abc86974.zip
hdf5-a83a4ece41ba2777ad8c6b5f82e476d9abc86974.tar.gz
hdf5-a83a4ece41ba2777ad8c6b5f82e476d9abc86974.tar.bz2
[svn-r17860] Description:
"Normalize" object names for external links, making them into the same form as used for soft links. Begin the process of adding more printf-like information to library error reporting. HGOTO_ERROR() and HDONE_ERROR() macros can now use the last parameter (a string) like a printf() formatting string and pass extra parameters with additional information. (For example, see the HGOTO_ERROR macros in H5FD_sec2_read() in src/H5FDsec2.c) Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5Lexternal.c')
-rw-r--r--src/H5Lexternal.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index 57414c7..640ac07 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -514,6 +514,7 @@ H5Lcreate_external(const char *file_name, const char *obj_name,
hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id)
{
H5G_loc_t link_loc; /* Group location to create link */
+ char *norm_obj_name = NULL; /* Pointer to normalized current name */
void *ext_link_buf = NULL; /* Buffer to contain external link */
size_t buf_size; /* Size of buffer to hold external link */
uint8_t *p; /* Pointer into external link buffer */
@@ -533,8 +534,12 @@ H5Lcreate_external(const char *file_name, const char *obj_name,
if(!link_name || !*link_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified")
+ /* Get normalized copy of the link target */
+ if(NULL == (norm_obj_name = H5G_normalize(obj_name)))
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize object name")
+
/* Combine the filename and link name into a single buffer to give to the UD link */
- buf_size = 1 + (HDstrlen(file_name) + 1) + (HDstrlen(obj_name) + 1);
+ buf_size = 1 + (HDstrlen(file_name) + 1) + (HDstrlen(norm_obj_name) + 1);
if(NULL == (ext_link_buf = H5MM_malloc(buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate udata buffer")
@@ -543,14 +548,14 @@ H5Lcreate_external(const char *file_name, const char *obj_name,
*p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */
HDstrcpy((char *)p, file_name); /* Name of file containing external link's object */
p += HDstrlen(file_name) + 1;
- HDstrcpy((char *)p, obj_name); /* External link's object */
+ HDstrcpy((char *)p, norm_obj_name); /* External link's object */
/* Create an external link */
if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
done:
- if(ext_link_buf != NULL)
+ if(norm_obj_name)
H5MM_free(ext_link_buf);
FUNC_LEAVE_API(ret_value)