1 /*
2     This code (with some modifications) is from GNU Parted
3     Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
4 */
5 
6 #ifndef EXCEPTION_H
7 #define EXCEPTION_H
8 
9 enum reiserfs_exception_type {
10     EXCEPTION_INFORMATION 			= 1,
11     EXCEPTION_WARNING 				= 2,
12     EXCEPTION_ERROR 				= 3,
13     EXCEPTION_FATAL 				= 4,
14     EXCEPTION_BUG 				= 5,
15     EXCEPTION_NO_FEATURE 			= 6
16 };
17 
18 typedef enum reiserfs_exception_type reiserfs_exception_type_t;
19 
20 enum reiserfs_exception_option {
21     EXCEPTION_UNHANDLED 			= 1 << 0,
22     EXCEPTION_YES 				= 1 << 1,
23     EXCEPTION_NO 				= 1 << 2,
24     EXCEPTION_OK 				= 1 << 3,
25     EXCEPTION_RETRY 				= 1 << 4,
26     EXCEPTION_IGNORE 				= 1 << 5,
27     EXCEPTION_CANCEL 				= 1 << 6
28 };
29 
30 typedef enum reiserfs_exception_option reiserfs_exception_option_t;
31 
32 #define EXCEPTION_OK_CANCEL			(EXCEPTION_OK + EXCEPTION_CANCEL)
33 #define EXCEPTION_YES_NO 			(EXCEPTION_YES + EXCEPTION_NO)
34 #define EXCEPTION_YES_NO_CANCEL			(EXCEPTION_YES_NO + EXCEPTION_CANCEL)
35 #define EXCEPTION_IGNORE_CANCEL			(EXCEPTION_IGNORE + EXCEPTION_CANCEL)
36 #define EXCEPTION_RETRY_CANCEL			(EXCEPTION_RETRY + EXCEPTION_CANCEL)
37 #define EXCEPTION_RETRY_IGNORE_CANCEL		(EXCEPTION_RETRY + EXCEPTION_IGNORE_CANCEL)
38 
39 #define EXCEPTION_OPTION_FIRST			EXCEPTION_FIX
40 #define EXCEPTION_OPTION_LAST			EXCEPTION_CANCEL
41 
42 struct reiserfs_exception {
43     char *message;
44     reiserfs_exception_type_t type;
45     reiserfs_exception_option_t options;
46 };
47 
48 typedef struct reiserfs_exception reiserfs_exception_t;
49 
50 typedef reiserfs_exception_option_t (*reiserfs_exception_handler_t)
51     (reiserfs_exception_t *ex);
52 
53 extern char *libreiserfs_exception_type_string(reiserfs_exception_type_t type);
54 extern reiserfs_exception_type_t libreiserfs_exception_type(reiserfs_exception_t *ex);
55 
56 extern char *libreiserfs_exception_option_string(reiserfs_exception_option_t opt);
57 extern reiserfs_exception_option_t libreiserfs_exception_option(reiserfs_exception_t *ex);
58 
59 extern char *libreiserfs_exception_message(reiserfs_exception_t *ex);
60 
61 extern void libreiserfs_exception_set_handler(reiserfs_exception_handler_t handler);
62 
63 extern reiserfs_exception_option_t libreiserfs_exception_throw(
64     reiserfs_exception_type_t type, reiserfs_exception_option_t opt,
65     const char* message, ...);
66 
67 extern reiserfs_exception_option_t libreiserfs_exception_rethrow(void);
68 
69 extern void libreiserfs_exception_catch(void);
70 extern void libreiserfs_exception_fetch_all(void);
71 extern void libreiserfs_exception_leave_all(void);
72 
73 #endif
74 
75