gierror.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 # include <config.h>
00030 #endif
00031
00032 #include <cxmemory.h>
00033 #include <cxstring.h>
00034 #include <cxstrutils.h>
00035
00036 #include <cpl_error.h>
00037 #include <cpl_errorstate.h>
00038
00039 #include "gierror.h"
00040
00041
00042 struct GiError {
00043 cpl_errorstate state;
00044 };
00045
00046 typedef struct GiError GiError;
00047
00048
00049 static GiError _error ;
00050
00051 static cxbool _error_init = FALSE;
00052 static cxbool _error_saved = FALSE;
00053
00054
00063 void
00064 giraffe_error_init(void)
00065 {
00066
00067 _error_init = TRUE;
00068 return;
00069
00070 }
00071
00072
00073 void
00074 giraffe_error_clear(void)
00075 {
00076
00077 if (_error_init == TRUE) {
00078 _error_init = FALSE;
00079 }
00080
00081 return;
00082
00083 }
00084
00085
00086 void
00087 giraffe_error_push(void)
00088 {
00089
00090 cx_assert(_error_init == TRUE);
00091
00092 _error.state = cpl_errorstate_get();
00093 _error_saved = TRUE;
00094
00095 cpl_error_reset();
00096
00097 return;
00098
00099 }
00100
00101
00102 void
00103 giraffe_error_pop(void)
00104 {
00105
00106 cx_assert(_error_init == TRUE);
00107
00108 if (_error_saved == TRUE) {
00109
00110 cpl_errorstate_set(_error.state);
00111 _error_saved = FALSE;
00112
00113 }
00114
00115 return;
00116
00117 }