2
libparted - a library for manipulating disk partitions
3
Copyright (C) 1999-2000, 2007, 2009-2012 Free Software Foundation, Inc.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 3 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
20
* \addtogroup PedException
24
/** \file exception.h */
26
#ifndef PED_EXCEPTION_H_INCLUDED
27
#define PED_EXCEPTION_H_INCLUDED
29
typedef struct _PedException PedException;
34
enum _PedExceptionType {
35
PED_EXCEPTION_INFORMATION=1,
36
PED_EXCEPTION_WARNING=2,
37
PED_EXCEPTION_ERROR=3,
38
PED_EXCEPTION_FATAL=4,
40
PED_EXCEPTION_NO_FEATURE=6,
42
typedef enum _PedExceptionType PedExceptionType;
45
* Option for resolving the exception
47
enum _PedExceptionOption {
48
PED_EXCEPTION_UNHANDLED=0,
53
PED_EXCEPTION_RETRY=16,
54
PED_EXCEPTION_IGNORE=32,
55
PED_EXCEPTION_CANCEL=64,
57
typedef enum _PedExceptionOption PedExceptionOption;
58
#define PED_EXCEPTION_OK_CANCEL (PED_EXCEPTION_OK + PED_EXCEPTION_CANCEL)
59
#define PED_EXCEPTION_YES_NO (PED_EXCEPTION_YES + PED_EXCEPTION_NO)
60
#define PED_EXCEPTION_YES_NO_CANCEL (PED_EXCEPTION_YES_NO \
61
+ PED_EXCEPTION_CANCEL)
62
#define PED_EXCEPTION_IGNORE_CANCEL (PED_EXCEPTION_IGNORE \
63
+ PED_EXCEPTION_CANCEL)
64
#define PED_EXCEPTION_RETRY_CANCEL (PED_EXCEPTION_RETRY + PED_EXCEPTION_CANCEL)
65
#define PED_EXCEPTION_RETRY_IGNORE_CANCEL (PED_EXCEPTION_RETRY \
66
+ PED_EXCEPTION_IGNORE_CANCEL)
67
#define PED_EXCEPTION_OPTION_FIRST PED_EXCEPTION_FIX
68
#define PED_EXCEPTION_OPTION_LAST PED_EXCEPTION_CANCEL
71
* Structure with information about exception
73
struct _PedException {
74
char* message; /**< text describing what the event was */
75
PedExceptionType type; /**< type of exception */
76
PedExceptionOption options; /**< ORed list of options that
77
the exception handler can
78
return (the ways an exception
82
typedef PedExceptionOption (PedExceptionHandler) (PedException* ex);
84
extern int ped_exception; /* set to true if there's an exception */
86
extern char* ped_exception_get_type_string (PedExceptionType ex_type)
88
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
89
__attribute ((__const__))
92
extern char* ped_exception_get_option_string (PedExceptionOption ex_opt)
94
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
95
__attribute ((__pure__))
99
extern void ped_exception_set_handler (PedExceptionHandler* handler);
100
extern PedExceptionHandler *ped_exception_get_handler(void)
102
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
103
__attribute ((__pure__))
107
extern PedExceptionOption ped_exception_default_handler (PedException* ex);
109
extern PedExceptionOption ped_exception_throw (PedExceptionType ex_type,
110
PedExceptionOption ex_opt,
113
/* rethrows an exception - i.e. calls the exception handler, (or returns a
114
code to return to pass up higher) */
115
extern PedExceptionOption ped_exception_rethrow ();
117
/* frees an exception, indicating that the exception has been handled.
118
Calling an exception handler counts. */
119
extern void ped_exception_catch ();
121
/* indicate that exceptions should not go to the exception handler, but passed
122
up to the calling function(s) */
123
extern void ped_exception_fetch_all ();
125
/* indicate that exceptions should invoke the exception handler */
126
extern void ped_exception_leave_all ();
128
#endif /* PED_EXCEPTION_H_INCLUDED */