00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00002 * Copyright by The HDF Group. * 00003 * Copyright by the Board of Trustees of the University of Illinois. * 00004 * All rights reserved. * 00005 * * 00006 * This file is part of HDF5. The full HDF5 copyright notice, including * 00007 * terms governing use, modification, and redistribution, is contained in * 00008 * the files COPYING and Copyright.html. COPYING can be found at the root * 00009 * of the source code distribution tree; Copyright.html can be found at the * 00010 * root level of an installed copy of the electronic HDF5 document set and * 00011 * is linked from the top-level documents page. It can also be found at * 00012 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 00013 * access to either file, you may request a copy from help@hdfgroup.org. * 00014 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00015 00016 /* 00017 * Programmer: Quincey Koziol <koziol@hdfgroup.org> 00018 * Wednesday, April 11, 2007 00019 * 00020 * Purpose: This file contains declarations which are visible only within 00021 * the H5E package. Source files outside the H5E package should 00022 * include H5Eprivate.h instead. 00023 */ 00024 #ifndef H5E_PACKAGE 00025 #error "Do not include this file outside the H5E package!" 00026 #endif 00027 00028 #ifndef _H5Epkg_H 00029 #define _H5Epkg_H 00030 00031 /* Get package's private header */ 00032 #include "H5Eprivate.h" 00033 00034 /* Other private headers needed by this file */ 00035 00036 00037 /**************************/ 00038 /* Package Private Macros */ 00039 /**************************/ 00040 00041 /* Amount to indent each error */ 00042 #define H5E_INDENT 2 00043 00044 /* Number of slots in an error stack */ 00045 #define H5E_NSLOTS 32 00046 00047 #ifdef H5_HAVE_THREADSAFE 00048 /* 00049 * The per-thread error stack. pthread_once() initializes a special 00050 * key that will be used by all threads to create a stack specific to 00051 * each thread individually. The association of stacks to threads will 00052 * be handled by the pthread library. 00053 * 00054 * In order for this macro to work, H5E_get_my_stack() must be preceeded 00055 * by "H5E_t *estack =". 00056 */ 00057 #define H5E_get_my_stack() H5E_get_stack() 00058 #else /* H5_HAVE_THREADSAFE */ 00059 /* 00060 * The current error stack. 00061 */ 00062 #define H5E_get_my_stack() (H5E_stack_g + 0) 00063 #endif /* H5_HAVE_THREADSAFE */ 00064 00065 00066 /****************************/ 00067 /* Package Private Typedefs */ 00068 /****************************/ 00069 00070 /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ 00071 typedef struct { 00072 unsigned vers; /* Which version callback to use */ 00073 union { 00074 #ifndef H5_NO_DEPRECATED_SYMBOLS 00075 H5E_auto1_t func1; /* Old-style callback, NO error stack param. */ 00076 #endif /* H5_NO_DEPRECATED_SYMBOLS */ 00077 H5E_auto2_t func2; /* New-style callback, with error stack param. */ 00078 }u; 00079 } H5E_auto_op_t; 00080 00081 /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ 00082 typedef struct { 00083 unsigned vers; /* Which version callback to use */ 00084 union { 00085 #ifndef H5_NO_DEPRECATED_SYMBOLS 00086 H5E_walk1_t func1; /* Old-style callback, NO error stack param. */ 00087 #endif /* H5_NO_DEPRECATED_SYMBOLS */ 00088 H5E_walk2_t func2; /* New-style callback, with error stack param. */ 00089 }u; 00090 } H5E_walk_op_t; 00091 00092 /* Error class */ 00093 typedef struct H5E_cls_t { 00094 char *cls_name; /* Name of error class */ 00095 char *lib_name; /* Name of library within class */ 00096 char *lib_vers; /* Version of library */ 00097 } H5E_cls_t; 00098 00099 /* Major or minor message */ 00100 typedef struct H5E_msg_t { 00101 char *msg; /* Message for error */ 00102 H5E_type_t type; /* Type of error (major or minor) */ 00103 H5E_cls_t *cls; /* Which error class this message belongs to */ 00104 } H5E_msg_t; 00105 00106 /* Error stack */ 00107 struct H5E_t { 00108 size_t nused; /* Num slots currently used in stack */ 00109 H5E_error2_t slot[H5E_NSLOTS]; /* Array of error records */ 00110 H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */ 00111 void *auto_data; /* Callback data for 'automatic error reporting */ 00112 }; 00113 00114 00115 /*****************************/ 00116 /* Package Private Variables */ 00117 /*****************************/ 00118 00119 #ifndef H5_HAVE_THREADSAFE 00120 /* 00121 * The current error stack. 00122 */ 00123 H5_DLLVAR H5E_t H5E_stack_g[1]; 00124 #endif /* H5_HAVE_THREADSAFE */ 00125 00126 00127 /******************************/ 00128 /* Package Private Prototypes */ 00129 /******************************/ 00130 #ifdef H5_HAVE_THREADSAFE 00131 H5_DLL H5E_t *H5E_get_stack(void); 00132 #endif /* H5_HAVE_THREADSAFE */ 00133 H5_DLL ssize_t H5E_get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, 00134 char *msg, size_t size); 00135 H5_DLL herr_t H5E_print(const H5E_t *estack, FILE *stream, hbool_t bk_compat); 00136 H5_DLL herr_t H5E_walk(const H5E_t *estack, H5E_direction_t direction, 00137 const H5E_walk_op_t *op, void *client_data); 00138 H5_DLL herr_t H5E_get_auto(const H5E_t *estack, H5E_auto_op_t *op, 00139 void **client_data); 00140 H5_DLL herr_t H5E_set_auto(H5E_t *estack, const H5E_auto_op_t *op, 00141 void *client_data); 00142 H5_DLL herr_t H5E_pop(H5E_t *err_stack, size_t count); 00143 00144 #endif /* _H5HFpkg_H */ 00145