HDF5  1.12.0
H5Epublic.h
Go to the documentation of this file.
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://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * This file contains public declarations for the H5E module.
16  */
17 #ifndef _H5Epublic_H
18 #define _H5Epublic_H
19 
20 #include <stdio.h> /*FILE arg of H5Eprint() */
21 
22 /* Public headers needed by this file */
23 #include "H5public.h"
24 #include "H5Ipublic.h"
25 
26 /* Value for the default error stack */
27 #define H5E_DEFAULT (hid_t)0
28 
29 /* Different kinds of error information */
30 typedef enum H5E_type_t {
32  H5E_MINOR
34 
35 /* Information about an error; element of error stack */
36 typedef struct H5E_error2_t {
37  hid_t cls_id; /*class ID */
38  hid_t maj_num; /*major error ID */
39  hid_t min_num; /*minor error number */
40  unsigned line; /*line in file where error occurs */
41  const char *func_name; /*function in which error occurred */
42  const char *file_name; /*file in which error occurred */
43  const char *desc; /*optional supplied description */
45 
46 /* When this header is included from a private header, don't make calls to H5open() */
47 #undef H5OPEN
48 #ifndef _H5private_H
49 #define H5OPEN H5open(),
50 #else /* _H5private_H */
51 #define H5OPEN
52 #endif /* _H5private_H */
53 
54 /* HDF5 error class */
55 #define H5E_ERR_CLS (H5OPEN H5E_ERR_CLS_g)
57 
58 /* Include the automatically generated public header information */
59 /* (This includes the list of major and minor error codes for the library) */
60 #include "H5Epubgen.h"
61 
62 /*
63  * One often needs to temporarily disable automatic error reporting when
64  * trying something that's likely or expected to fail. The code to try can
65  * be nested between calls to H5Eget_auto() and H5Eset_auto(), but it's
66  * easier just to use this macro like:
67  * H5E_BEGIN_TRY {
68  * ...stuff here that's likely to fail...
69  * } H5E_END_TRY;
70  *
71  * Warning: don't break, return, or longjmp() from the body of the loop or
72  * the error reporting won't be properly restored!
73  *
74  * These two macros still use the old API functions for backward compatibility
75  * purpose.
76  */
77 #ifndef H5_NO_DEPRECATED_SYMBOLS
78 #define H5E_BEGIN_TRY { \
79  unsigned H5E_saved_is_v2; \
80  union { \
81  H5E_auto1_t efunc1; \
82  H5E_auto2_t efunc2; \
83  } H5E_saved; \
84  void *H5E_saved_edata; \
85  \
86  (void)H5Eauto_is_v2(H5E_DEFAULT, &H5E_saved_is_v2); \
87  if(H5E_saved_is_v2) { \
88  (void)H5Eget_auto2(H5E_DEFAULT, &H5E_saved.efunc2, &H5E_saved_edata); \
89  (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); \
90  } else { \
91  (void)H5Eget_auto1(&H5E_saved.efunc1, &H5E_saved_edata); \
92  (void)H5Eset_auto1(NULL, NULL); \
93  }
94 
95 #define H5E_END_TRY \
96  if(H5E_saved_is_v2) \
97  (void)H5Eset_auto2(H5E_DEFAULT, H5E_saved.efunc2, H5E_saved_edata); \
98  else \
99  (void)H5Eset_auto1(H5E_saved.efunc1, H5E_saved_edata); \
100 }
101 #else /* H5_NO_DEPRECATED_SYMBOLS */
102 #define H5E_BEGIN_TRY { \
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 
109 #define H5E_END_TRY \
110  (void)H5Eset_auto2(H5E_DEFAULT, saved_efunc, H5E_saved_edata); \
111 }
112 #endif /* H5_NO_DEPRECATED_SYMBOLS */
113 
114 /*
115  * Public API Convenience Macros for Error reporting - Documented
116  */
117 /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */
118 #define H5Epush_sim(func, cls, maj, min, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str)
119 
120 /*
121  * Public API Convenience Macros for Error reporting - Undocumented
122  */
123 /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */
124 /* And return after pushing error onto stack */
125 #define H5Epush_ret(func, cls, maj, min, str, ret) { \
126  H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \
127  return(ret); \
128 }
129 
130 /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in
131  * And goto a label after pushing error onto stack.
132  */
133 #define H5Epush_goto(func, cls, maj, min, str, label) { \
134  H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, cls, maj, min, str); \
135  goto label; \
136 }
137 
138 /* Error stack traversal direction */
139 typedef enum H5E_direction_t {
140  H5E_WALK_UPWARD = 0, /*begin deep, end at API function */
141  H5E_WALK_DOWNWARD = 1 /*begin at API function, end deep */
143 
144 
145 #ifdef __cplusplus
146 extern "C" {
147 #endif
148 
149 /* Error stack traversal callback function pointers */
150 typedef herr_t (*H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc,
151  void *client_data);
152 typedef herr_t (*H5E_auto2_t)(hid_t estack, void *client_data);
153 
154 /* Public API functions */
155 H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name,
156  const char *version);
159 H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg);
163 H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size);
165 H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line,
166  hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...);
167 H5_DLL herr_t H5Epop(hid_t err_stack, size_t count);
168 H5_DLL herr_t H5Eprint2(hid_t err_stack, FILE *stream);
169 H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func,
170  void *client_data);
171 H5_DLL herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data);
172 H5_DLL herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data);
173 H5_DLL herr_t H5Eclear2(hid_t err_stack);
174 H5_DLL herr_t H5Eauto_is_v2(hid_t err_stack, unsigned *is_stack);
175 H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg,
176  size_t size);
177 H5_DLL ssize_t H5Eget_num(hid_t error_stack_id);
178 
179 
180 /* Symbols defined for compatibility with previous versions of the HDF5 API.
181  *
182  * Use of these symbols is deprecated.
183  */
184 #ifndef H5_NO_DEPRECATED_SYMBOLS
185 
186 /* Typedefs */
187 
188 /* Alias major & minor error types to hid_t's, for compatibility with new
189  * error API in v1.8
190  */
193 
194 /* Information about an error element of error stack. */
195 typedef struct H5E_error1_t {
196  H5E_major_t maj_num; /*major error number */
197  H5E_minor_t min_num; /*minor error number */
198  const char *func_name; /*function in which error occurred */
199  const char *file_name; /*file in which error occurred */
200  unsigned line; /*line in file where error occurs */
201  const char *desc; /*optional supplied description */
203 
204 /* Error stack traversal callback function pointers */
205 typedef herr_t (*H5E_walk1_t)(int n, H5E_error1_t *err_desc, void *client_data);
206 typedef herr_t (*H5E_auto1_t)(void *client_data);
207 
208 /* Function prototypes */
209 H5_DLL herr_t H5Eclear1(void);
210 H5_DLL herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data);
211 H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line,
212  H5E_major_t maj, H5E_minor_t min, const char *str);
213 H5_DLL herr_t H5Eprint1(FILE *stream);
214 H5_DLL herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data);
216  void *client_data);
217 H5_DLL char *H5Eget_major(H5E_major_t maj);
218 H5_DLL char *H5Eget_minor(H5E_minor_t min);
219 #endif /* H5_NO_DEPRECATED_SYMBOLS */
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif /* end _H5Epublic_H */
226 
H5public.h
ssize_t
int ssize_t
Definition: H5public.h:167
H5Ecreate_stack
H5_DLL hid_t H5Ecreate_stack(void)
Definition: H5E.c:899
H5Eget_minor
H5_DLL char * H5Eget_minor(H5E_minor_t min)
Definition: H5Edeprec.c:149
H5Ipublic.h
H5Eclose_stack
H5_DLL herr_t H5Eclose_stack(hid_t stack_id)
Definition: H5E.c:1158
H5Eget_auto1
H5_DLL herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data)
Definition: H5Edeprec.c:352
size
iblock size
Definition: H5EAcache.c:787
H5Eprint2
H5_DLL herr_t H5Eprint2(hid_t err_stack, FILE *stream)
Definition: H5E.c:1498
H5Eget_msg
H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size)
Definition: H5E.c:864
H5E_error2_t
struct H5E_error2_t H5E_error2_t
H5Eset_current_stack
H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id)
Definition: H5E.c:1052
H5Eget_num
H5_DLL ssize_t H5Eget_num(hid_t error_stack_id)
Definition: H5E.c:1227
H5E_error1_t::min_num
H5E_minor_t min_num
Definition: H5Epublic.h:197
H5Eregister_class
H5_DLL hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version)
Definition: H5E.c:437
H5Epush2
H5_DLL herr_t H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg,...)
Definition: H5E.c:1354
H5E_error2_t::func_name
const char * func_name
Definition: H5Epublic.h:41
H5E_WALK_UPWARD
@ H5E_WALK_UPWARD
Definition: H5Epublic.h:140
H5_DLLVAR
#define H5_DLLVAR
Definition: H5api_adpt.h:235
H5E_auto2_t
herr_t(* H5E_auto2_t)(hid_t estack, void *client_data)
Definition: H5Epublic.h:152
H5E_auto1_t
herr_t(* H5E_auto1_t)(void *client_data)
Definition: H5Epublic.h:206
H5E_major_t
hid_t H5E_major_t
Definition: H5Epublic.h:191
H5E_direction_t
H5E_direction_t
Definition: H5Epublic.h:139
H5E_minor_t
hid_t H5E_minor_t
Definition: H5Epublic.h:192
H5Eget_auto2
H5_DLL herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data)
Definition: H5E.c:1593
H5Eclose_msg
H5_DLL herr_t H5Eclose_msg(hid_t err_id)
Definition: H5E.c:708
H5Ewalk2
H5_DLL herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t func, void *client_data)
Definition: H5E.c:1543
hid_t
int64_t hid_t
Definition: H5Ipublic.h:55
H5Epubgen.h
H5E_error2_t
Definition: H5Epublic.h:36
H5E_error2_t::line
unsigned line
Definition: H5Epublic.h:40
FILE
Invalid arguments to routine Resource unavailable Internal File accessibility Low level I O Function entry exit Object atom Object cache Links B Tree node Symbol table Heap Object header Datatype Dataspace Dataset Data storage Property lists Attribute Data filters External file list References Virtual File Layer Virtual Object Layer Ternary Search Trees Reference Counted Strings Error API Skip Lists Free Space Manager Shared Object Header Messages Extensible Array Fixed Array Plugin for dynamically loaded library Page Buffering API Context Map No error Argument errors Resource errors File accessibility errors FILE
Definition: H5err.txt:88
H5E_error1_t::func_name
const char * func_name
Definition: H5Epublic.h:198
H5E_error1_t
Definition: H5Epublic.h:195
H5Eauto_is_v2
H5_DLL herr_t H5Eauto_is_v2(hid_t err_stack, unsigned *is_stack)
Definition: H5E.c:1710
H5Eget_major
H5_DLL char * H5Eget_major(H5E_major_t maj)
Definition: H5Edeprec.c:96
H5Eclear1
H5_DLL herr_t H5Eclear1(void)
Definition: H5Edeprec.c:241
H5E_error1_t::desc
const char * desc
Definition: H5Epublic.h:201
H5Eclear2
H5_DLL herr_t H5Eclear2(hid_t err_stack)
Definition: H5E.c:1453
H5E_MINOR
@ H5E_MINOR
Definition: H5Epublic.h:32
H5E_walk2_t
herr_t(* H5E_walk2_t)(unsigned n, const H5E_error2_t *err_desc, void *client_data)
Definition: H5Epublic.h:150
H5E_error2_t::desc
const char * desc
Definition: H5Epublic.h:43
H5E_error1_t::file_name
const char * file_name
Definition: H5Epublic.h:199
H5E_error2_t::cls_id
hid_t cls_id
Definition: H5Epublic.h:37
H5E_error2_t::min_num
hid_t min_num
Definition: H5Epublic.h:39
H5_DLL
#define H5_DLL
Definition: H5api_adpt.h:234
H5Eunregister_class
H5_DLL herr_t H5Eunregister_class(hid_t class_id)
Definition: H5E.c:525
H5E_error2_t::maj_num
hid_t maj_num
Definition: H5Epublic.h:38
H5E_error1_t::line
unsigned line
Definition: H5Epublic.h:200
H5Ecreate_msg
H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg)
Definition: H5E.c:771
H5Eprint1
H5_DLL herr_t H5Eprint1(FILE *stream)
Definition: H5Edeprec.c:275
H5E_WALK_DOWNWARD
@ H5E_WALK_DOWNWARD
Definition: H5Epublic.h:141
H5E_MAJOR
@ H5E_MAJOR
Definition: H5Epublic.h:31
H5Ewalk1
H5_DLL herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data)
Definition: H5Edeprec.c:311
n
*s *s n
Definition: H5HLdbg.c:111
H5Epop
H5_DLL herr_t H5Epop(hid_t err_stack, size_t count)
Definition: H5E.c:1296
H5Eget_current_stack
H5_DLL hid_t H5Eget_current_stack(void)
Definition: H5E.c:938
H5Eget_class_name
H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size)
Definition: H5E.c:597
herr_t
int herr_t
Definition: H5public.h:128
H5Eset_auto2
H5_DLL herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data)
Definition: H5E.c:1651
H5E_walk1_t
herr_t(* H5E_walk1_t)(int n, H5E_error1_t *err_desc, void *client_data)
Definition: H5Epublic.h:205
H5E_error1_t
struct H5E_error1_t H5E_error1_t
H5E_ERR_CLS_g
H5_DLLVAR hid_t H5E_ERR_CLS_g
Definition: H5Epublic.h:56
H5Epush1
H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str)
Definition: H5Edeprec.c:209
H5E_error1_t::maj_num
H5E_major_t maj_num
Definition: H5Epublic.h:196
H5E_type_t
H5E_type_t
Definition: H5Epublic.h:30
H5E_error2_t::file_name
const char * file_name
Definition: H5Epublic.h:42
H5Eset_auto1
H5_DLL herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data)
Definition: H5Edeprec.c:405