H5Epublic.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * Copyright by the Board of Trustees of the University of Illinois. *
  4. * All rights reserved. *
  5. * *
  6. * This file is part of HDF5. The full HDF5 copyright notice, including *
  7. * terms governing use, modification, and redistribution, is contained in *
  8. * the COPYING file, which can be found at the root of the source code *
  9. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  10. * If you do not have access to either file, you may request a copy from *
  11. * help@hdfgroup.org. *
  12. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  13. /*
  14. * This file contains public declarations for the H5E module.
  15. */
  16. #ifndef H5Epublic_H
  17. #define H5Epublic_H
  18. #include <stdio.h> /*FILE arg of H5Eprint() */
  19. /* Public headers needed by this file */
  20. #include "H5public.h"
  21. #include "H5Ipublic.h"
  22. /* Value for the default error stack */
  23. #define H5E_DEFAULT 0 /* (hid_t) */
  24. /**
  25. * Different kinds of error information
  26. */
  27. typedef enum H5E_type_t { H5E_MAJOR, H5E_MINOR } H5E_type_t;
  28. /**
  29. * Information about an error; element of error stack
  30. */
  31. typedef struct H5E_error2_t {
  32. hid_t cls_id;
  33. /**< Class ID */
  34. hid_t maj_num;
  35. /**< Major error ID */
  36. hid_t min_num;
  37. /**< Minor error number */
  38. unsigned line;
  39. /**< Line in file where error occurs */
  40. const char *func_name;
  41. /**< Function in which error occurred */
  42. const char *file_name;
  43. /**< File in which error occurred */
  44. const char *desc;
  45. /**< Optional supplied description */
  46. } H5E_error2_t;
  47. /* When this header is included from a private header, don't make calls to H5open() */
  48. #undef H5OPEN
  49. #ifndef H5private_H
  50. #define H5OPEN H5open(),
  51. #else /* H5private_H */
  52. #define H5OPEN
  53. #endif /* H5private_H */
  54. /* HDF5 error class */
  55. #define H5E_ERR_CLS (H5OPEN H5E_ERR_CLS_g)
  56. H5_DLLVAR hid_t H5E_ERR_CLS_g;
  57. /* Include the automatically generated public header information */
  58. /* (This includes the list of major and minor error codes for the library) */
  59. #include "H5Epubgen.h"
  60. /*
  61. * One often needs to temporarily disable automatic error reporting when
  62. * trying something that's likely or expected to fail. The code to try can
  63. * be nested between calls to H5Eget_auto() and H5Eset_auto(), but it's
  64. * easier just to use this macro like:
  65. * H5E_BEGIN_TRY {
  66. * ...stuff here that's likely to fail...
  67. * } H5E_END_TRY;
  68. *
  69. * Warning: don't break, return, or longjmp() from the body of the loop or
  70. * the error reporting won't be properly restored!
  71. *
  72. * These two macros still use the old API functions for backward compatibility
  73. * purpose.
  74. */
  75. #ifndef H5_NO_DEPRECATED_SYMBOLS
  76. #define H5E_BEGIN_TRY \
  77. { \
  78. unsigned H5E_saved_is_v2; \
  79. union { \
  80. H5E_auto1_t efunc1; \
  81. H5E_auto2_t efunc2; \
  82. } H5E_saved; \
  83. void *H5E_saved_edata; \
  84. \
  85. (void)H5Eauto_is_v2(H5E_DEFAULT, &H5E_saved_is_v2); \
  86. if (H5E_saved_is_v2) { \
  87. (void)H5Eget_auto2(H5E_DEFAULT, &H5E_saved.efunc2, &H5E_saved_edata); \
  88. (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); \
  89. } \
  90. else { \
  91. (void)H5Eget_auto1(&H5E_saved.efunc1, &H5E_saved_edata); \
  92. (void)H5Eset_auto1(NULL, NULL); \
  93. }
  94. #define H5E_END_TRY \
  95. if (H5E_saved_is_v2) \
  96. (void)H5Eset_auto2(H5E_DEFAULT, H5E_saved.efunc2, H5E_saved_edata); \
  97. else \
  98. (void)H5Eset_auto1(H5E_saved.efunc1, H5E_saved_edata); \
  99. }
  100. #else /* H5_NO_DEPRECATED_SYMBOLS */
  101. #define H5E_BEGIN_TRY \
  102. { \
  103. H5E_auto2_t saved_efunc; \
  104. void * H5E_saved_edata; \
  105. \
  106. (void)H5Eget_auto2(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \
  107. (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
  108. #define H5E_END_TRY \
  109. (void)H5Eset_auto2(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \
  110. }
  111. #endif /* H5_NO_DEPRECATED_SYMBOLS */
  112. /*
  113. * Public API Convenience Macros for Error reporting - Documented
  114. */
  115. /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */
  116. #define H5Epush_sim(func, cls, maj, min, str) \
  117. H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str)
  118. /*
  119. * Public API Convenience Macros for Error reporting - Undocumented
  120. */
  121. /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */
  122. /* And return after pushing error onto stack */
  123. #define H5Epush_ret(func, cls, maj, min, str, ret) \
  124. do { \
  125. H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \
  126. return (ret); \
  127. } while (0)
  128. /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in
  129. * And goto a label after pushing error onto stack.
  130. */
  131. #define H5Epush_goto(func, cls, maj, min, str, label) \
  132. { \
  133. H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \
  134. goto label; \
  135. }
  136. /**
  137. * Error stack traversal direction
  138. */
  139. typedef enum H5E_direction_t {
  140. H5E_WALK_UPWARD = 0, /**< begin w/ most specific error, end at API function */
  141. H5E_WALK_DOWNWARD = 1 /**< begin at API function, end w/ most specific error */
  142. } H5E_direction_t;
  143. #ifdef __cplusplus
  144. extern "C" {
  145. #endif
  146. /* Error stack traversal callback function pointers */
  147. //! <!-- [H5E_walk2_t_snip] -->
  148. /**
  149. * \brief Callback function for H5Ewalk2()
  150. *
  151. * \param[in] n Indexed error position in the stack
  152. * \param[in] err_desc Pointer to a data structure describing the error
  153. * \param[in] client_data Pointer to client data in the format expected by the
  154. * user-defined function
  155. * \return \herr_t
  156. */
  157. typedef herr_t (*H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc, void *client_data);
  158. //! <!-- [H5E_walk2_t_snip] -->
  159. //! <!-- [H5E_auto2_t_snip] -->
  160. /**
  161. * \brief Callback function for H5Eset_auto2()
  162. *
  163. * \estack_id{estack}
  164. * \param[in] client_data Pointer to client data in the format expected by the
  165. * user-defined function
  166. * \return \herr_t
  167. */
  168. typedef herr_t (*H5E_auto2_t)(hid_t estack, void *client_data);
  169. //! <!-- [H5E_auto2_t_snip] -->
  170. /* Public API functions */
  171. /**
  172. * --------------------------------------------------------------------------
  173. * \ingroup H5E
  174. *
  175. * \brief Registers a client library or application program to the HDF5 error API
  176. *
  177. * \param[in] cls_name Name of the error class
  178. * \param[in] lib_name Name of the client library or application to which the error class belongs
  179. * \param[in] version Version of the client library or application to which the
  180. error class belongs. Can be \c NULL.
  181. * \return Returns a class identifier on success; otherwise returns H5I_INVALID_ID.
  182. *
  183. * \details H5Eregister_class() registers a client library or application
  184. * program to the HDF5 error API so that the client library or
  185. * application program can report errors together with the HDF5
  186. * library. It receives an identifier for this error class for further
  187. * error operations. The library name and version number will be
  188. * printed out in the error message as a preamble.
  189. *
  190. * \since 1.8.0
  191. */
  192. H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version);
  193. /**
  194. * --------------------------------------------------------------------------
  195. * \ingroup H5E
  196. *
  197. * \brief Removes an error class
  198. *
  199. * \param[in] class_id Error class identifier.
  200. * \return \herr_t
  201. *
  202. * \details H5Eunregister_class() removes the error class specified by \p
  203. * class_id. All the major and minor errors in this class will also be
  204. * closed.
  205. *
  206. * \since 1.8.0
  207. */
  208. H5_DLL herr_t H5Eunregister_class(hid_t class_id);
  209. /**
  210. * --------------------------------------------------------------------------
  211. * \ingroup H5E
  212. *
  213. * \brief Closes an error message
  214. *
  215. * \param[in] err_id An error message identifier
  216. * \return \herr_t
  217. *
  218. * \details H5Eclose_msg() closes an error message identifier, which can be
  219. * either a major or minor message.
  220. *
  221. * \since 1.8.0
  222. */
  223. H5_DLL herr_t H5Eclose_msg(hid_t err_id);
  224. /**
  225. * --------------------------------------------------------------------------
  226. * \ingroup H5E
  227. *
  228. * \brief Adds a major error message to an error class
  229. *
  230. * \param[in] cls An error class identifier
  231. * \param[in] msg_type The type of the error message
  232. * \param[in] msg Major error message
  233. * \return \herr_t
  234. *
  235. * \details H5Ecreate_msg() adds an error message to an error class defined by
  236. * client library or application program. The error message can be
  237. * either major or minor as indicated by the parameter \p msg_type.
  238. *
  239. * Use H5Eclose_msg() to close the message identifier returned by this
  240. * function.
  241. *
  242. * \since 1.8.0
  243. */
  244. H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg);
  245. /**
  246. * --------------------------------------------------------------------------
  247. * \ingroup H5E
  248. *
  249. * \brief Creates a new, empty error stack
  250. *
  251. * \return \hid_ti{error stack}
  252. *
  253. * \details H5Ecreate_stack() creates a new empty error stack and returns the
  254. * new stack’s identifier. Use H5Eclose_stack() to close the error stack
  255. * identifier returned by this function.
  256. *
  257. * \since 1.8.0
  258. */
  259. H5_DLL hid_t H5Ecreate_stack(void);
  260. /**
  261. * --------------------------------------------------------------------------
  262. * \ingroup H5E
  263. *
  264. * \brief Returns a copy of the current error stack
  265. *
  266. * \return \hid_ti{error stack}
  267. *
  268. * \details H5Eget_current_stack() copies the current error stack and returns an
  269. * error stack identifier for the new copy.
  270. *
  271. * \since 1.8.0
  272. */
  273. H5_DLL hid_t H5Eget_current_stack(void);
  274. /**
  275. * --------------------------------------------------------------------------
  276. * \ingroup H5E
  277. *
  278. * \brief Appends one error stack to another, optionally closing the source
  279. * stack.
  280. *
  281. * \estack_id{dst_stack_id}
  282. * \estack_id{src_stack_id}
  283. * \param[in] close_source_stack Flag to indicate whether to close the source stack
  284. * \return \herr_t
  285. *
  286. * \details H5Eappend_stack() appends the messages from error stack
  287. * \p src_stack_id to the error stack \p dst_stack_id.
  288. * If \p close_source_stack is \c TRUE, the source error stack
  289. * will be closed.
  290. *
  291. * \since 1.13.0
  292. */
  293. H5_DLL herr_t H5Eappend_stack(hid_t dst_stack_id, hid_t src_stack_id, hbool_t close_source_stack);
  294. /**
  295. * --------------------------------------------------------------------------
  296. * \ingroup H5E
  297. *
  298. * \brief Closes an error stack handle
  299. *
  300. * \estack_id{stack_id}
  301. *
  302. * \return \herr_t
  303. *
  304. * \details H5Eclose_stack() closes the error stack handle \p stack_id
  305. * and releases its resources. #H5E_DEFAULT cannot be closed.
  306. *
  307. * \since 1.8.0
  308. */
  309. H5_DLL herr_t H5Eclose_stack(hid_t stack_id);
  310. /**
  311. * --------------------------------------------------------------------------
  312. * \ingroup H5E
  313. *
  314. * \brief Retrieves error class name
  315. *
  316. * \param[in] class_id Error class identifier
  317. * \param[out] name Buffer for the error class name
  318. * \param[in] size The maximum number of characters the class name to be returned
  319. * by this function in\p name.
  320. * \return Returns non-negative value as on success; otherwise returns negative value.
  321. *
  322. * \details H5Eget_class_name() retrieves the name of the error class specified
  323. * by the class identifier. If non-NULL pointer is passed in for \p
  324. * name and \p size is greater than zero, the class name of \p size
  325. * long is returned. The length of the error class name is also
  326. * returned. If NULL is passed in as \p name, only the length of class
  327. * name is returned. If zero is returned, it means no name. The user is
  328. * responsible for allocating sufficient buffer space for the name.
  329. *
  330. * \since 1.8.0
  331. */
  332. H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size);
  333. /**
  334. * --------------------------------------------------------------------------
  335. * \ingroup H5E
  336. *
  337. * \brief Replaces the current error stack
  338. *
  339. * \estack_id{err_stack_id}
  340. *
  341. * \return \herr_t
  342. *
  343. * \details H5Eset_current_stack() replaces the content of the current error
  344. * stack with a copy of the content of the error stack specified by
  345. * \p err_stack_id, and it closes the error stack specified by
  346. * \p err_stack_id.
  347. *
  348. * \since 1.8.0
  349. */
  350. H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id);
  351. /**
  352. * --------------------------------------------------------------------------
  353. * \ingroup H5E
  354. *
  355. * \brief Pushes a new error record onto an error stack
  356. *
  357. * \estack_id{err_stack}. If the identifier is #H5E_DEFAULT, the error record
  358. * will be pushed to the current stack.
  359. * \param[in] file Name of the file in which the error was detected
  360. * \param[in] func Name of the function in which the error was detected
  361. * \param[in] line Line number in the file where the error was detected
  362. * \param[in] cls_id Error class identifier
  363. * \param[in] maj_id Major error identifier
  364. * \param[in] min_id Minor error identifier
  365. * \param[in] msg Error description string
  366. * \return \herr_t
  367. *
  368. * \details H5Epush2() pushes a new error record onto the error stack specified
  369. * by \p err_stack.\n
  370. * The error record contains the error class identifier \p cls_id, the
  371. * major and minor message identifiers \p maj_id and \p min_id, the
  372. * function name \p func where the error was detected, the file name \p
  373. * file and line number \p line in the file where the error was
  374. * detected, and an error description \p msg.\n
  375. * The major and minor errors must be in the same error class.\n
  376. * The function name, filename, and error description strings must be
  377. * statically allocated.\n
  378. * \p msg can be a format control string with additional
  379. * arguments. This design of appending additional arguments is similar
  380. * to the system and C functions printf() and fprintf().
  381. *
  382. * \since 1.8.0
  383. */
  384. H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id,
  385. hid_t maj_id, hid_t min_id, const char *msg, ...);
  386. /**
  387. * --------------------------------------------------------------------------
  388. * \ingroup H5E
  389. *
  390. * \brief Deletes specified number of error messages from the error stack
  391. *
  392. * \estack_id{err_stack}
  393. * \param[in] count The number of error messages to be deleted from the top
  394. * of error stack
  395. * \return \herr_t
  396. *
  397. * \details H5Epop() deletes the number of error records specified in \p count
  398. * from the top of the error stack specified by \p err_stack (including
  399. * major, minor messages and description). The number of error messages
  400. * to be deleted is specified by \p count.
  401. *
  402. * \since 1.8.0
  403. */
  404. H5_DLL herr_t H5Epop(hid_t err_stack, size_t count);
  405. /**
  406. * --------------------------------------------------------------------------
  407. * \ingroup H5E
  408. *
  409. * \brief Prints the specified error stack in a default manner
  410. *
  411. * \estack_id{err_stack}
  412. * \param[in] stream File pointer, or \c NULL for \c stderr
  413. * \return \herr_t
  414. *
  415. * \details H5Eprint2() prints the error stack specified by \p err_stack on the
  416. * specified stream, \p stream. Even if the error stack is empty, a
  417. * one-line message of the following form will be printed:
  418. * \code{.unparsed}
  419. * HDF5-DIAG: Error detected in HDF5 library version: 1.5.62 thread 0.
  420. * \endcode
  421. *
  422. * A similar line will appear before the error messages of each error
  423. * class stating the library name, library version number, and thread
  424. * identifier.
  425. *
  426. * If \p err_stack is #H5E_DEFAULT, the current error stack will be
  427. * printed.
  428. *
  429. * H5Eprint2() is a convenience function for H5Ewalk2() with a function
  430. * that prints error messages. Users are encouraged to write their own
  431. * more specific error handlers.
  432. *
  433. * \since 1.8.0
  434. */
  435. H5_DLL herr_t H5Eprint2(hid_t err_stack, FILE *stream);
  436. /**
  437. * --------------------------------------------------------------------------
  438. * \ingroup H5E
  439. *
  440. * \brief Walks the specified error stack, calling the specified function
  441. *
  442. * \estack_id{err_stack}
  443. * \param[in] direction Direction in which the error stack is to be walked
  444. * \param[in] func Function to be called for each error encountered
  445. * \param[in] client_data Data to be passed to \p func
  446. * \return \herr_t
  447. *
  448. * \details H5Ewalk2() walks the error stack specified by err_stack for the
  449. * current thread and calls the function specified in \p func for each
  450. * error along the way.
  451. *
  452. * If the value of \p err_stack is #H5E_DEFAULT, then H5Ewalk2() walks
  453. * the current error stack.
  454. *
  455. * \p direction specifies whether the stack is walked from the inside
  456. * out or the outside in. A value of #H5E_WALK_UPWARD means to begin
  457. * with the most specific error and end at the API; a value of
  458. * #H5E_WALK_DOWNWARD means to start at the API and end at the
  459. * innermost function where the error was first detected.
  460. *
  461. * \p func, a function conforming to the #H5E_walk2_t prototype, will
  462. * be called for each error in the error stack. Its arguments will
  463. * include an index number \c n (beginning at zero regardless of stack
  464. * traversal direction), an error stack entry \c err_desc, and the \c
  465. * client_data pointer passed to H5Eprint(). The #H5E_walk2_t prototype
  466. * is as follows:
  467. * \snippet this H5E_walk2_t_snip
  468. *
  469. * \since 1.8.0
  470. */
  471. H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func, void *client_data);
  472. /**
  473. * --------------------------------------------------------------------------
  474. * \ingroup H5E
  475. *
  476. * \brief Returns the settings for the automatic error stack traversal
  477. * function and its data
  478. *
  479. * \estack_id
  480. * \param[out] func The function currently set to be called upon an error condition
  481. * \param[out] client_data Data currently set to be passed to the error function
  482. * \return \herr_t
  483. *
  484. * \details H5Eget_auto2() returns the settings for the automatic error stack
  485. * traversal function, \p func, and its data, \p client_data, that are
  486. * associated with the error stack specified by \p estack_id.
  487. *
  488. * Either or both of the \p func and \p client_data arguments may be
  489. * \c NULL, in which case the value is not returned.
  490. *
  491. * The library initializes its default error stack traversal functions
  492. * to H5Eprint1() and H5Eprint2(). A call to H5Eget_auto2() returns
  493. * H5Eprint2() or the user-defined function passed in through
  494. * H5Eset_auto2(). A call to H5Eget_auto1() returns H5Eprint1() or the
  495. * user-defined function passed in through H5Eset_auto1(). However, if
  496. * the application passes in a user-defined function through
  497. * H5Eset_auto1(), it should call H5Eget_auto1() to query the traversal
  498. * function. If the application passes in a user-defined function
  499. * through H5Eset_auto2(), it should call H5Eget_auto2() to query the
  500. * traversal function.
  501. *
  502. * Mixing the new style and the old style functions will cause a
  503. * failure. For example, if the application sets a user-defined
  504. * old-style traversal function through H5Eset_auto1(), a call to
  505. * H5Eget_auto2() will fail and will indicate that the application has
  506. * mixed H5Eset_auto1() and H5Eget_auto2(). On the other hand, mixing
  507. * H5Eset_auto2() and H5Eget_auto1() will also cause a failure. But if
  508. * the traversal functions are the library’s default H5Eprint1() or
  509. * H5Eprint2(), mixing H5Eset_auto1() and H5Eget_auto2() or mixing
  510. * H5Eset_auto2() and H5Eget_auto1() does not fail.
  511. *
  512. * \since 1.8.0
  513. */
  514. H5_DLL herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data);
  515. /**
  516. * --------------------------------------------------------------------------
  517. * \ingroup H5E
  518. *
  519. * \brief Turns automatic error printing on or off
  520. *
  521. * \estack_id
  522. * \param[in] func Function to be called upon an error condition
  523. * \param[in] client_data Data passed to the error function
  524. * \return \herr_t
  525. *
  526. * \details H5Eset_auto2() turns on or off automatic printing of errors for the
  527. * error stack specified with \p estack_id. An \p estack_id value of
  528. * #H5E_DEFAULT indicates the current stack.
  529. *
  530. * When automatic printing is turned on, by the use of a non-null \p func
  531. * pointer, any API function which returns an error indication will
  532. * first call \p func, passing it \p client_data as an argument.
  533. *
  534. * \p func, a function compliant with the #H5E_auto2_t prototype, is
  535. * defined in the H5Epublic.h source code file as:
  536. * \snippet this H5E_auto2_t_snip
  537. *
  538. * When the library is first initialized, the auto printing function is
  539. * set to H5Eprint2() (cast appropriately) and \p client_data is the
  540. * standard error stream pointer, \c stderr.
  541. *
  542. * Automatic stack traversal is always in the #H5E_WALK_DOWNWARD
  543. * direction.
  544. *
  545. * Automatic error printing is turned off with a H5Eset_auto2() call
  546. * with a \c NULL \p func pointer.
  547. *
  548. * \since 1.8.0
  549. */
  550. H5_DLL herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data);
  551. /**
  552. * --------------------------------------------------------------------------
  553. * \ingroup H5E
  554. *
  555. * \brief Clears the specified error stack or the error stack for the current thread
  556. *
  557. * \estack_id{err_stack}
  558. * \return \herr_t
  559. *
  560. * \details H5Eclear2() clears the error stack specified by \p err_stack, or, if
  561. * \p err_stack is set to #H5E_DEFAULT, the error stack for the current
  562. * thread.
  563. *
  564. * \p err_stack is an error stack identifier, such as that returned by
  565. * H5Eget_current_stack().
  566. *
  567. * The current error stack is also cleared whenever an API function is
  568. * called, with certain exceptions (for instance, H5Eprint1() or
  569. * H5Eprint2()).
  570. *
  571. * \since 1.8.0
  572. */
  573. H5_DLL herr_t H5Eclear2(hid_t err_stack);
  574. /**
  575. * --------------------------------------------------------------------------
  576. * \ingroup H5E
  577. *
  578. * \brief Determines the type of error stack
  579. *
  580. * \estack_id{err_stack}
  581. * \param[out] is_stack A flag indicating which error stack \c typedef the
  582. * specified error stack conforms to
  583. *
  584. * \return \herr_t
  585. *
  586. * \details H5Eauto_is_v2() determines whether the error auto reporting function
  587. * for an error stack conforms to the #H5E_auto2_t \c typedef or the
  588. * #H5E_auto1_t \c typedef.
  589. *
  590. * The \p is_stack parameter is set to 1 if the error stack conforms to
  591. * #H5E_auto2_t and 0 if it conforms to #H5E_auto1_t.
  592. *
  593. * \since 1.8.0
  594. */
  595. H5_DLL herr_t H5Eauto_is_v2(hid_t err_stack, unsigned *is_stack);
  596. /**
  597. * --------------------------------------------------------------------------
  598. * \ingroup H5E
  599. *
  600. * \brief Retrieves an error message
  601. *
  602. * \param[in] msg_id Error message identifier
  603. * \param[out] type The type of the error message Valid values are #H5E_MAJOR
  604. * and #H5E_MINOR.
  605. * \param[out] msg Error message buffer
  606. * \param[in] size The length of error message to be returned by this function
  607. * \return Returns the size of the error message in bytes on success; otherwise
  608. * returns a negative value.
  609. *
  610. * \details H5Eget_msg() retrieves the error message including its length and
  611. * type. The error message is specified by \p msg_id. The user is
  612. * responsible for passing in sufficient buffer space for the
  613. * message. If \p msg is not NULL and \p size is greater than zero, the
  614. * error message of \p size long is returned. The length of the message
  615. * is also returned. If NULL is passed in as \p msg, only the length
  616. * and type of the message is returned. If the return value is zero, it
  617. * means there is no message.
  618. *
  619. * \since 1.8.0
  620. */
  621. H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size);
  622. /**
  623. * --------------------------------------------------------------------------
  624. * \ingroup H5E
  625. *
  626. * \brief Retrieves the number of error messages in an error stack
  627. *
  628. * \estack_id{error_stack_id}
  629. * \return Returns a non-negative value on success; otherwise returns a negative value.
  630. *
  631. * \details H5Eget_num() retrieves the number of error records in the error
  632. * stack specified by \p error_stack_id (including major, minor
  633. * messages and description).
  634. *
  635. * \since 1.8.0
  636. */
  637. H5_DLL ssize_t H5Eget_num(hid_t error_stack_id);
  638. /* Symbols defined for compatibility with previous versions of the HDF5 API.
  639. *
  640. * Use of these symbols is deprecated.
  641. */
  642. #ifndef H5_NO_DEPRECATED_SYMBOLS
  643. /* Typedefs */
  644. /* Alias major & minor error types to hid_t's, for compatibility with new
  645. * error API in v1.8
  646. */
  647. typedef hid_t H5E_major_t;
  648. typedef hid_t H5E_minor_t;
  649. /**
  650. * Information about an error element of error stack.
  651. */
  652. typedef struct H5E_error1_t {
  653. H5E_major_t maj_num; /**< major error number */
  654. H5E_minor_t min_num; /**< minor error number */
  655. const char *func_name; /**< function in which error occurred */
  656. const char *file_name; /**< file in which error occurred */
  657. unsigned line; /**< line in file where error occurs */
  658. const char *desc; /**< optional supplied description */
  659. } H5E_error1_t;
  660. /* Error stack traversal callback function pointers */
  661. //! <!-- [H5E_walk1_t_snip] -->
  662. /**
  663. * \brief Callback function for H5Ewalk1()
  664. *
  665. * \param[in] n Indexed error position in the stack
  666. * \param[in] err_desc Pointer to a data structure describing the error
  667. * \param[in] client_data Pointer to client data in the format expected by the
  668. * user-defined function
  669. * \return \herr_t
  670. */
  671. typedef herr_t (*H5E_walk1_t)(int n, H5E_error1_t *err_desc, void *client_data);
  672. //! <!-- [H5E_walk1_t_snip] -->
  673. //! <!-- [H5E_auto1_t_snip] -->
  674. /**
  675. * \brief Callback function for H5Eset_auto1()
  676. *
  677. * \param[in] client_data Pointer to client data in the format expected by the
  678. * user-defined function
  679. * \return \herr_t
  680. */
  681. typedef herr_t (*H5E_auto1_t)(void *client_data);
  682. //! <!-- [H5E_auto1_t_snip] -->
  683. /* Function prototypes */
  684. /**
  685. * --------------------------------------------------------------------------
  686. * \ingroup H5E
  687. *
  688. * \brief Clears the error stack for the current thread
  689. *
  690. * \return \herr_t
  691. *
  692. * \deprecated 1.8.0 Function H5Eclear() renamed to H5Eclear1() and deprecated
  693. * in this release.
  694. *
  695. * \details H5Eclear1() clears the error stack for the current thread.\n
  696. * The stack is also cleared whenever an API function is called, with
  697. * certain exceptions (for instance, H5Eprint1()).
  698. *
  699. */
  700. H5_DLL herr_t H5Eclear1(void);
  701. /**
  702. * --------------------------------------------------------------------------
  703. * \ingroup H5E
  704. *
  705. * \brief Returns the current settings for the automatic error stack traversal
  706. * function and its data
  707. *
  708. * \param[out] func Current setting for the function to be called upon an error
  709. * condition
  710. * \param[out] client_data Current setting for the data passed to the error
  711. * function
  712. * \return \herr_t
  713. *
  714. * \deprecated 1.8.0 Function H5Eget_auto() renamed to H5Eget_auto1() and
  715. * deprecated in this release.
  716. *
  717. * \details H5Eget_auto1() returns the current settings for the automatic error
  718. * stack traversal function, \p func, and its data,
  719. * \p client_data. Either or both arguments may be \c NULL, in which case the
  720. * value is not returned.
  721. *
  722. * The library initializes its default error stack traversal functions
  723. * to H5Eprint1() and H5Eprint2(). A call to H5Eget_auto2() returns
  724. * H5Eprint2() or the user-defined function passed in through
  725. * H5Eset_auto2(). A call to H5Eget_auto1() returns H5Eprint1() or the
  726. * user-defined function passed in through H5Eset_auto1(). However, if
  727. * the application passes in a user-defined function through
  728. * H5Eset_auto1(), it should call H5Eget_auto1() to query the traversal
  729. * function. If the application passes in a user-defined function
  730. * through H5Eset_auto2(), it should call H5Eget_auto2() to query the
  731. * traversal function.
  732. *
  733. * Mixing the new style and the old style functions will cause a
  734. * failure. For example, if the application sets a user-defined
  735. * old-style traversal function through H5Eset_auto1(), a call to
  736. * H5Eget_auto2() will fail and will indicate that the application has
  737. * mixed H5Eset_auto1() and H5Eget_auto2(). On the other hand, mixing
  738. * H5Eset_auto2() and H5Eget_auto1() will also cause a failure. But if
  739. * the traversal functions are the library’s default H5Eprint1() or
  740. * H5Eprint2(), mixing H5Eset_auto1() and H5Eget_auto2() or mixing
  741. * H5Eset_auto2() and H5Eget_auto1() does not fail.
  742. *
  743. */
  744. H5_DLL herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data);
  745. /**
  746. * --------------------------------------------------------------------------
  747. * \ingroup H5E
  748. *
  749. * \brief Pushes a new error record onto the error stack
  750. *
  751. * \param[in] file Name of the file in which the error was detected
  752. * \param[in] func Name of the function in which the error was detected
  753. * \param[in] line Line number in the file where the error was detected
  754. * \param[in] maj Major error identifier
  755. * \param[in] min Minor error identifier
  756. * \param[in] str Error description string
  757. * \return \herr_t
  758. *
  759. * \deprecated 1.8.0 Function H5Epush() renamed to H5Epush1() and
  760. * deprecated in this release.
  761. *
  762. * \details H5Epush1() pushes a new error record onto the error stack for the
  763. * current thread.\n
  764. * The error has major and minor numbers \p maj_num
  765. * and \p min_num, the function \p func where the error was detected, the
  766. * name of the file \p file where the error was detected, the line \p line
  767. * within that file, and an error description string \p str.\n
  768. * The function name, filename, and error description strings must be statically
  769. * allocated.
  770. *
  771. * \since 1.4.0
  772. */
  773. H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min,
  774. const char *str);
  775. /**
  776. * --------------------------------------------------------------------------
  777. * \ingroup H5E
  778. *
  779. * \brief Prints the current error stack in a default manner
  780. *
  781. * \param[in] stream File pointer, or \c NULL for \c stderr
  782. * \return \herr_t
  783. *
  784. * \deprecated 1.8.0 Function H5Eprint() renamed to H5Eprint1() and
  785. * deprecated in this release.
  786. *
  787. * \details H5Eprint1() prints prints the error stack for the current thread
  788. * on the specified stream, \p stream. Even if the error stack is empty, a
  789. * one-line message of the following form will be printed:
  790. * \code{.unparsed}
  791. * HDF5-DIAG: Error detected in thread 0.
  792. * \endcode
  793. * H5Eprint1() is a convenience function for H5Ewalk1() with a function
  794. * that prints error messages. Users are encouraged to write their own
  795. * more specific error handlers.
  796. *
  797. */
  798. H5_DLL herr_t H5Eprint1(FILE *stream);
  799. /**
  800. * --------------------------------------------------------------------------
  801. * \ingroup H5E
  802. *
  803. * \brief Turns automatic error printing on or off
  804. *
  805. * \param[in] func Function to be called upon an error condition
  806. * \param[in] client_data Data passed to the error function
  807. * \return \herr_t
  808. *
  809. * \deprecated 1.8.0 Function H5Eset_auto() renamed to H5Eset_auto1() and
  810. * deprecated in this release.
  811. *
  812. * \details H5Eset_auto1() turns on or off automatic printing of errors. When
  813. * turned on (non-null \p func pointer), any API function which returns
  814. * an error indication will first call \p func, passing it \p
  815. * client_data as an argument.
  816. *
  817. * \p func, a function conforming to the #H5E_auto1_t prototype, is
  818. * defined in the H5Epublic.h source code file as:
  819. * \snippet this H5E_auto1_t_snip
  820. *
  821. * When the library is first initialized, the auto printing function is
  822. * set to H5Eprint1() (cast appropriately) and \p client_data is the
  823. * standard error stream pointer, \c stderr.
  824. *
  825. * Automatic stack traversal is always in the #H5E_WALK_DOWNWARD
  826. * direction.
  827. *
  828. */
  829. H5_DLL herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data);
  830. /**
  831. * --------------------------------------------------------------------------
  832. * \ingroup H5E
  833. *
  834. * \brief Walks the current error stack, calling the specified function
  835. *
  836. * \param[in] direction Direction in which the error stack is to be walked
  837. * \param[in] func Function to be called for each error encountered
  838. * \param[in] client_data Data to be passed to \p func
  839. * \return \herr_t
  840. *
  841. * \deprecated 1.8.0 Function H5Ewalk() renamed to H5Ewalk1() and
  842. * deprecated in this release.
  843. *
  844. * \details H5Ewalk1() walks the error stack for the current thread and calls
  845. * the function specified in \p func for each error along the way.
  846. *
  847. * \p direction specifies whether the stack is walked from the inside
  848. * out or the outside in. A value of #H5E_WALK_UPWARD means to begin
  849. * with the most specific error and end at the API; a value of
  850. * #H5E_WALK_DOWNWARD means to start at the API and end at the
  851. * innermost function where the error was first detected.
  852. *
  853. * \p func, a function conforming to the #H5E_walk1_t prototype, will
  854. * be called for each error in the error stack. Its arguments will
  855. * include an index number \c n (beginning at zero regardless of stack
  856. * traversal direction), an error stack entry \c err_desc, and the \c
  857. * client_data pointer passed to H5Eprint(). The #H5E_walk1_t prototype
  858. * is as follows:
  859. * \snippet this H5E_walk1_t_snip
  860. *
  861. */
  862. H5_DLL herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data);
  863. /**
  864. * --------------------------------------------------------------------------
  865. * \ingroup H5E
  866. *
  867. * \brief Returns a character string describing an error specified by a major
  868. * error number
  869. *
  870. * \param[in] maj Major error number
  871. * \return \herr_t
  872. *
  873. * \deprecated 1.8.0 Function deprecated in this release.
  874. *
  875. * \details Given a major error number, H5Eget_major() returns a constant
  876. * character string that describes the error.
  877. *
  878. * \attention This function returns a dynamically allocated string (\c char
  879. * array). An application calling this function must free the memory
  880. * associated with the return value to prevent a memory leak.
  881. *
  882. */
  883. H5_DLL char *H5Eget_major(H5E_major_t maj);
  884. /**
  885. * --------------------------------------------------------------------------
  886. * \ingroup H5E
  887. *
  888. * \brief Returns a character string describing an error specified by a minor
  889. * error number
  890. *
  891. * \param[in] min Minor error number
  892. * \return \herr_t
  893. *
  894. * \deprecated 1.8.0 Function deprecated and return type changed in this release.
  895. *
  896. * \details Given a minor error number, H5Eget_minor() returns a constant
  897. * character string that describes the error.
  898. *
  899. * \attention In the Release 1.8.x series, H5Eget_minor() returns a string of
  900. * dynamic allocated \c char array. An application calling this
  901. * function from an HDF5 library of Release 1.8.0 or later must free
  902. * the memory associated with the return value to prevent a memory
  903. * leak. This is a change from the 1.6.x release series.
  904. *
  905. */
  906. H5_DLL char *H5Eget_minor(H5E_minor_t min);
  907. #endif /* H5_NO_DEPRECATED_SYMBOLS */
  908. #ifdef __cplusplus
  909. }
  910. #endif
  911. #endif /* end H5Epublic_H */