exception.h

Go to the documentation of this file.
00001 /*
00002     libparted - a library for manipulating disk partitions
00003     Copyright (C) 1999, 2000 Free Software Foundation, Inc.
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018 */
00019 
00027 #ifndef PED_EXCEPTION_H_INCLUDED
00028 #define PED_EXCEPTION_H_INCLUDED
00029 
00030 typedef struct _PedException PedException;
00031 
00035 enum _PedExceptionType {
00036         PED_EXCEPTION_INFORMATION=1,
00037         PED_EXCEPTION_WARNING=2,
00038         PED_EXCEPTION_ERROR=3,
00039         PED_EXCEPTION_FATAL=4,
00040         PED_EXCEPTION_BUG=5,
00041         PED_EXCEPTION_NO_FEATURE=6,
00042 };
00043 typedef enum _PedExceptionType PedExceptionType;
00044 
00048 enum _PedExceptionOption {
00049         PED_EXCEPTION_UNHANDLED=0,
00050         PED_EXCEPTION_FIX=1,
00051         PED_EXCEPTION_YES=2,
00052         PED_EXCEPTION_NO=4,
00053         PED_EXCEPTION_OK=8,
00054         PED_EXCEPTION_RETRY=16,
00055         PED_EXCEPTION_IGNORE=32,
00056         PED_EXCEPTION_CANCEL=64,
00057 };
00058 typedef enum _PedExceptionOption PedExceptionOption;
00059 #define PED_EXCEPTION_OK_CANCEL     (PED_EXCEPTION_OK + PED_EXCEPTION_CANCEL)
00060 #define PED_EXCEPTION_YES_NO        (PED_EXCEPTION_YES + PED_EXCEPTION_NO)
00061 #define PED_EXCEPTION_YES_NO_CANCEL (PED_EXCEPTION_YES_NO \
00062                                      + PED_EXCEPTION_CANCEL)
00063 #define PED_EXCEPTION_IGNORE_CANCEL (PED_EXCEPTION_IGNORE \
00064                                      + PED_EXCEPTION_CANCEL)
00065 #define PED_EXCEPTION_RETRY_CANCEL  (PED_EXCEPTION_RETRY + PED_EXCEPTION_CANCEL)
00066 #define PED_EXCEPTION_RETRY_IGNORE_CANCEL (PED_EXCEPTION_RETRY \
00067                                            + PED_EXCEPTION_IGNORE_CANCEL)
00068 #define PED_EXCEPTION_OPTION_FIRST PED_EXCEPTION_FIX
00069 #define PED_EXCEPTION_OPTION_LAST PED_EXCEPTION_CANCEL
00070 
00074 struct _PedException {
00075         char*                   message;        
00076         PedExceptionType        type;           
00077         PedExceptionOption      options;        
00081 };
00082 
00083 typedef PedExceptionOption (PedExceptionHandler) (PedException* ex);
00084 
00085 extern int ped_exception;       /* set to true if there's an exception */
00086 
00087 extern char* ped_exception_get_type_string (PedExceptionType ex_type);
00088 extern char* ped_exception_get_option_string (PedExceptionOption ex_opt);
00089 
00090 extern void ped_exception_set_handler (PedExceptionHandler* handler);
00091 extern PedExceptionHandler *ped_exception_get_handler(void);
00092 
00093 extern PedExceptionOption ped_exception_default_handler (PedException* ex);
00094 
00095 extern PedExceptionOption       ped_exception_throw (PedExceptionType ex_type,
00096                                                      PedExceptionOption ex_opt,
00097                                                      const char* message,
00098                                                      ...);
00099 /* rethrows an exception - i.e. calls the exception handler, (or returns a
00100    code to return to pass up higher) */
00101 extern PedExceptionOption       ped_exception_rethrow ();
00102 
00103 /* frees an exception, indicating that the exception has been handled.
00104    Calling an exception handler counts. */
00105 extern void                     ped_exception_catch ();
00106 
00107 /* indicate that exceptions should not go to the exception handler, but passed
00108    up to the calling function(s) */
00109 extern void                     ped_exception_fetch_all ();
00110 
00111 /* indicate that exceptions should invoke the exception handler */
00112 extern void                     ped_exception_leave_all ();
00113 
00114 #endif /* PED_EXCEPTION_H_INCLUDED */
00115 

Generated on Fri May 4 05:15:31 2007 for libparted by  doxygen 1.5.2