summaryrefslogtreecommitdiffstats
path: root/src/H5Eint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-10 17:30:09 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-10 17:30:09 (GMT)
commit37358db8ab62fa9c9057ea118b8576d5a4368ef1 (patch)
treea1290bfece5213bedc47eb9a0817ef19f5c9ea9b /src/H5Eint.c
parentfbd4cf9bfea5418e2e4e2b81f31459db4aae4d61 (diff)
downloadhdf5-37358db8ab62fa9c9057ea118b8576d5a4368ef1.zip
hdf5-37358db8ab62fa9c9057ea118b8576d5a4368ef1.tar.gz
hdf5-37358db8ab62fa9c9057ea118b8576d5a4368ef1.tar.bz2
[svn-r17862] Description:
Bring r17860 from trunk to 1.8 branch: "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) Bring the underlying H5E_printf_stack() routine from trunk to 1.8 branch also. 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/H5Eint.c')
-rw-r--r--src/H5Eint.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/H5Eint.c b/src/H5Eint.c
index f45e9fd..3265fc7 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -661,6 +661,107 @@ H5E_set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data)
/*-------------------------------------------------------------------------
+ * Function: H5E_printf_stack
+ *
+ * Purpose: Printf-like wrapper around H5E_push_stack.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, August 12, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line,
+ hid_t cls_id, hid_t maj_id, hid_t min_id, const char *fmt, ...)
+{
+ va_list ap; /* Varargs info */
+#ifndef H5_HAVE_VASPRINTF
+ int tmp_len; /* Current size of description buffer */
+ int desc_len; /* Actual length of description when formatted */
+#endif /* H5_HAVE_VASPRINTF */
+ char *tmp = NULL; /* Buffer to place formatted description in */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ /*
+ * WARNING: We cannot call HERROR() from within this function or else we
+ * could enter infinite recursion. Furthermore, we also cannot
+ * call any other HDF5 macro or function which might call
+ * HERROR(). HERROR() is called by HRETURN_ERROR() which could
+ * be called by FUNC_ENTER().
+ */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_printf_stack)
+
+ /* Sanity check */
+ HDassert(cls_id > 0);
+ HDassert(maj_id > 0);
+ HDassert(min_id > 0);
+ HDassert(fmt);
+
+/* Note that the variable-argument parsing for the format is identical in
+ * the H5Epush2() routine - correct errors and make changes in both
+ * places. -QAK
+ */
+
+ /* Start the variable-argument parsing */
+ va_start(ap, fmt);
+
+#ifdef H5_HAVE_VASPRINTF
+ /* Use the vasprintf() routine, since it does what we're trying to do below */
+ if(HDvasprintf(&tmp, fmt, ap) < 0)
+ HGOTO_DONE(FAIL)
+#else /* H5_HAVE_VASPRINTF */
+ /* Allocate space for the formatted description buffer */
+ tmp_len = 128;
+ if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
+ HGOTO_DONE(FAIL)
+
+ /* If the description doesn't fit into the initial buffer size, allocate more space and try again */
+ while((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap))
+#ifdef H5_VSNPRINTF_WORKS
+ >
+#else /* H5_VSNPRINTF_WORKS */
+ >=
+#endif /* H5_VSNPRINTF_WORKS */
+ (tmp_len - 1)
+#ifndef H5_VSNPRINTF_WORKS
+ || (desc_len < 0)
+#endif /* H5_VSNPRINTF_WORKS */
+ ) {
+ /* shutdown & restart the va_list */
+ va_end(ap);
+ va_start(ap, fmt);
+
+ /* Release the previous description, it's too small */
+ H5MM_xfree(tmp);
+
+ /* Allocate a description of the appropriate length */
+#ifdef H5_VSNPRINTF_WORKS
+ tmp_len = desc_len + 1;
+#else /* H5_VSNPRINTF_WORKS */
+ tmp_len = 2 * tmp_len;
+#endif /* H5_VSNPRINTF_WORKS */
+ if(NULL == (tmp = H5MM_malloc((size_t)tmp_len)))
+ HGOTO_DONE(FAIL)
+ } /* end while */
+#endif /* H5_HAVE_VASPRINTF */
+
+ va_end(ap);
+
+ /* Push the error on the stack */
+ if(H5E_push_stack(estack, file, func, line, cls_id, maj_id, min_id, tmp) < 0)
+ HGOTO_DONE(FAIL)
+
+done:
+ if(tmp)
+ H5MM_xfree(tmp);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5E_printf_stack() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5E_push_stack
*
* Purpose: Pushes a new error record onto error stack for the current