1*9663SMark.Logan@Sun.COM /* 2*9663SMark.Logan@Sun.COM libparted - a library for manipulating disk partitions 3*9663SMark.Logan@Sun.COM Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc. 4*9663SMark.Logan@Sun.COM 5*9663SMark.Logan@Sun.COM This program is free software; you can redistribute it and/or modify 6*9663SMark.Logan@Sun.COM it under the terms of the GNU General Public License as published by 7*9663SMark.Logan@Sun.COM the Free Software Foundation; either version 3 of the License, or 8*9663SMark.Logan@Sun.COM (at your option) any later version. 9*9663SMark.Logan@Sun.COM 10*9663SMark.Logan@Sun.COM This program is distributed in the hope that it will be useful, 11*9663SMark.Logan@Sun.COM but WITHOUT ANY WARRANTY; without even the implied warranty of 12*9663SMark.Logan@Sun.COM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*9663SMark.Logan@Sun.COM GNU General Public License for more details. 14*9663SMark.Logan@Sun.COM 15*9663SMark.Logan@Sun.COM You should have received a copy of the GNU General Public License 16*9663SMark.Logan@Sun.COM along with this program. If not, see <http://www.gnu.org/licenses/>. 17*9663SMark.Logan@Sun.COM */ 18*9663SMark.Logan@Sun.COM 19*9663SMark.Logan@Sun.COM /** 20*9663SMark.Logan@Sun.COM * \addtogroup PedException 21*9663SMark.Logan@Sun.COM * @{ 22*9663SMark.Logan@Sun.COM */ 23*9663SMark.Logan@Sun.COM 24*9663SMark.Logan@Sun.COM /** \file exception.h */ 25*9663SMark.Logan@Sun.COM 26*9663SMark.Logan@Sun.COM #ifndef PED_EXCEPTION_H_INCLUDED 27*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_H_INCLUDED 28*9663SMark.Logan@Sun.COM 29*9663SMark.Logan@Sun.COM typedef struct _PedException PedException; 30*9663SMark.Logan@Sun.COM 31*9663SMark.Logan@Sun.COM /** 32*9663SMark.Logan@Sun.COM * Exception type 33*9663SMark.Logan@Sun.COM */ 34*9663SMark.Logan@Sun.COM enum _PedExceptionType { 35*9663SMark.Logan@Sun.COM PED_EXCEPTION_INFORMATION=1, 36*9663SMark.Logan@Sun.COM PED_EXCEPTION_WARNING=2, 37*9663SMark.Logan@Sun.COM PED_EXCEPTION_ERROR=3, 38*9663SMark.Logan@Sun.COM PED_EXCEPTION_FATAL=4, 39*9663SMark.Logan@Sun.COM PED_EXCEPTION_BUG=5, 40*9663SMark.Logan@Sun.COM PED_EXCEPTION_NO_FEATURE=6, 41*9663SMark.Logan@Sun.COM }; 42*9663SMark.Logan@Sun.COM typedef enum _PedExceptionType PedExceptionType; 43*9663SMark.Logan@Sun.COM 44*9663SMark.Logan@Sun.COM /** 45*9663SMark.Logan@Sun.COM * Option for resolving the exception 46*9663SMark.Logan@Sun.COM */ 47*9663SMark.Logan@Sun.COM enum _PedExceptionOption { 48*9663SMark.Logan@Sun.COM PED_EXCEPTION_UNHANDLED=0, 49*9663SMark.Logan@Sun.COM PED_EXCEPTION_FIX=1, 50*9663SMark.Logan@Sun.COM PED_EXCEPTION_YES=2, 51*9663SMark.Logan@Sun.COM PED_EXCEPTION_NO=4, 52*9663SMark.Logan@Sun.COM PED_EXCEPTION_OK=8, 53*9663SMark.Logan@Sun.COM PED_EXCEPTION_RETRY=16, 54*9663SMark.Logan@Sun.COM PED_EXCEPTION_IGNORE=32, 55*9663SMark.Logan@Sun.COM PED_EXCEPTION_CANCEL=64, 56*9663SMark.Logan@Sun.COM }; 57*9663SMark.Logan@Sun.COM typedef enum _PedExceptionOption PedExceptionOption; 58*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_OK_CANCEL (PED_EXCEPTION_OK + PED_EXCEPTION_CANCEL) 59*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_YES_NO (PED_EXCEPTION_YES + PED_EXCEPTION_NO) 60*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_YES_NO_CANCEL (PED_EXCEPTION_YES_NO \ 61*9663SMark.Logan@Sun.COM + PED_EXCEPTION_CANCEL) 62*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_IGNORE_CANCEL (PED_EXCEPTION_IGNORE \ 63*9663SMark.Logan@Sun.COM + PED_EXCEPTION_CANCEL) 64*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_RETRY_CANCEL (PED_EXCEPTION_RETRY + PED_EXCEPTION_CANCEL) 65*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_RETRY_IGNORE_CANCEL (PED_EXCEPTION_RETRY \ 66*9663SMark.Logan@Sun.COM + PED_EXCEPTION_IGNORE_CANCEL) 67*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_OPTION_FIRST PED_EXCEPTION_FIX 68*9663SMark.Logan@Sun.COM #define PED_EXCEPTION_OPTION_LAST PED_EXCEPTION_CANCEL 69*9663SMark.Logan@Sun.COM 70*9663SMark.Logan@Sun.COM /** 71*9663SMark.Logan@Sun.COM * Structure with information about exception 72*9663SMark.Logan@Sun.COM */ 73*9663SMark.Logan@Sun.COM struct _PedException { 74*9663SMark.Logan@Sun.COM char* message; /**< text describing what the event was */ 75*9663SMark.Logan@Sun.COM PedExceptionType type; /**< type of exception */ 76*9663SMark.Logan@Sun.COM PedExceptionOption options; /**< ORed list of options that 77*9663SMark.Logan@Sun.COM the exception handler can 78*9663SMark.Logan@Sun.COM return (the ways an exception 79*9663SMark.Logan@Sun.COM can be resolved) */ 80*9663SMark.Logan@Sun.COM }; 81*9663SMark.Logan@Sun.COM 82*9663SMark.Logan@Sun.COM typedef PedExceptionOption (PedExceptionHandler) (PedException* ex); 83*9663SMark.Logan@Sun.COM 84*9663SMark.Logan@Sun.COM extern int ped_exception; /* set to true if there's an exception */ 85*9663SMark.Logan@Sun.COM 86*9663SMark.Logan@Sun.COM extern char* ped_exception_get_type_string (PedExceptionType ex_type); 87*9663SMark.Logan@Sun.COM extern char* ped_exception_get_option_string (PedExceptionOption ex_opt); 88*9663SMark.Logan@Sun.COM 89*9663SMark.Logan@Sun.COM extern void ped_exception_set_handler (PedExceptionHandler* handler); 90*9663SMark.Logan@Sun.COM extern PedExceptionHandler *ped_exception_get_handler(void); 91*9663SMark.Logan@Sun.COM 92*9663SMark.Logan@Sun.COM extern PedExceptionOption ped_exception_default_handler (PedException* ex); 93*9663SMark.Logan@Sun.COM 94*9663SMark.Logan@Sun.COM extern PedExceptionOption ped_exception_throw (PedExceptionType ex_type, 95*9663SMark.Logan@Sun.COM PedExceptionOption ex_opt, 96*9663SMark.Logan@Sun.COM const char* message, 97*9663SMark.Logan@Sun.COM ...); 98*9663SMark.Logan@Sun.COM /* rethrows an exception - i.e. calls the exception handler, (or returns a 99*9663SMark.Logan@Sun.COM code to return to pass up higher) */ 100*9663SMark.Logan@Sun.COM extern PedExceptionOption ped_exception_rethrow (); 101*9663SMark.Logan@Sun.COM 102*9663SMark.Logan@Sun.COM /* frees an exception, indicating that the exception has been handled. 103*9663SMark.Logan@Sun.COM Calling an exception handler counts. */ 104*9663SMark.Logan@Sun.COM extern void ped_exception_catch (); 105*9663SMark.Logan@Sun.COM 106*9663SMark.Logan@Sun.COM /* indicate that exceptions should not go to the exception handler, but passed 107*9663SMark.Logan@Sun.COM up to the calling function(s) */ 108*9663SMark.Logan@Sun.COM extern void ped_exception_fetch_all (); 109*9663SMark.Logan@Sun.COM 110*9663SMark.Logan@Sun.COM /* indicate that exceptions should invoke the exception handler */ 111*9663SMark.Logan@Sun.COM extern void ped_exception_leave_all (); 112*9663SMark.Logan@Sun.COM 113*9663SMark.Logan@Sun.COM #endif /* PED_EXCEPTION_H_INCLUDED */ 114*9663SMark.Logan@Sun.COM 115*9663SMark.Logan@Sun.COM /** @} */ 116*9663SMark.Logan@Sun.COM 117