OSDN Git Service

74c08cd88e9dd900ddf20a874f27f04865e3eee3
[mingw/mingw-get.git] / src / dmh.h
1 #ifndef DMH_H
2 /*
3  * dmh.h
4  *
5  * $Id$
6  *
7  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8  * Copyright (C) 2009, 2010, 2011, MinGW Project
9  *
10  *
11  * This header file provides the public API declarations for the
12  * diagnostic message handling subsystem.
13  *
14  *
15  * This is free software.  Permission is granted to copy, modify and
16  * redistribute this software, under the provisions of the GNU General
17  * Public License, Version 3, (or, at your option, any later version),
18  * as published by the Free Software Foundation; see the file COPYING
19  * for licensing details.
20  *
21  * Note, in particular, that this software is provided "as is", in the
22  * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23  * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24  * PARTICULAR PURPOSE.  Under no circumstances will the author, or the
25  * MinGW Project, accept liability for any damages, however caused,
26  * arising from the use of this software.
27  *
28  */
29 #define DMH_H  1
30
31 #include <stdint.h>
32 #ifdef __cplusplus
33 #include <exception>
34 #endif
35
36 #undef EXTERN_C
37 #ifdef __cplusplus
38 # define EXTERN_C  extern "C"
39 #else
40 # define EXTERN_C
41 #endif
42
43 typedef
44 enum dmh_class
45 {
46   DMH_SUBSYSTEM_TTY = 0,
47   DMH_SUBSYSTEM_GUI
48 } dmh_class;
49
50 typedef
51 enum dmh_severity
52 {
53   DMH_INFO = 0,
54   DMH_WARNING,
55   DMH_ERROR,
56   DMH_FATAL
57 } dmh_severity;
58
59 EXTERN_C void dmh_init( const dmh_class, const char* );
60 EXTERN_C int dmh_notify( const dmh_severity, const char *fmt, ... );
61 EXTERN_C int dmh_printf( const char *fmt, ... );
62
63 #define DMH_BEGIN_DIGEST  (uint16_t)(0x0001U), ~(uint16_t)(0x0001U)
64 #define DMH_END_DIGEST    (uint16_t)(0x0100U),  (uint16_t)(0x0000U)
65
66 EXTERN_C uint16_t dmh_control( const uint16_t, const uint16_t );
67
68 #ifdef __cplusplus
69 class dmh_exception : public std::exception
70 {
71   /* Limited purpose exception class; can only accept messages
72    * that are const char, because lifetime is assumed infinite,
73    * and storage is not freed. Used to handle fatal errors,
74    * which otherwise would force a direct call to exit().  By
75    * using this class, we can ensure that last rites are
76    * performed before exiting.
77    */
78   public:
79     dmh_exception() throw();
80     dmh_exception( const char* ) throw();
81     virtual ~dmh_exception() throw();
82     virtual const char* what() const throw();
83
84   protected:
85     const char *message;
86 };
87 #endif /* __cplusplus */
88
89 #endif /* DMH_H: $RCSfile$: end of file */