OSDN Git Service

Fix "mingw-get deletes itself" bug in last rites handling.
[mingw/mingw-get.git] / src / dmh.h
index 60929b2..62fb179 100644 (file)
--- a/src/dmh.h
+++ b/src/dmh.h
@@ -29,6 +29,9 @@
 #define DMH_H  1
 
 #include <stdint.h>
+#ifdef __cplusplus
+#include <exception>
+#endif
 
 #undef EXTERN_C
 #ifdef __cplusplus
@@ -62,4 +65,24 @@ EXTERN_C int dmh_printf( const char *fmt, ... );
 
 EXTERN_C uint16_t dmh_control( const uint16_t, const uint16_t );
 
+#ifdef __cplusplus
+class dmh_exception : public std::exception
+{
+  /* Limited purpose exception class; can only accept messages
+   * that are const char, because lifetime is assumed infinite,
+   * and storage is not freed. Used to handle fatal errors,
+   * which otherwise would force a direct call to exit().  By
+   * using this class, we can ensure that last rites are
+   * performed before exiting.
+   */
+public:
+  dmh_exception() throw();
+  dmh_exception(const char * msg) throw();
+  virtual ~dmh_exception() throw();
+  virtual const char* what() const throw();
+protected:
+  const char * message;
+};
+#endif /* __cplusplus */
+
 #endif /* DMH_H: $RCSfile$: end of file */