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 cpl_errorstate_get();
00068 _error_init = TRUE;
00069
00070 return;
00071
00072 }
00073
00074
00075 void
00076 giraffe_error_clear(void)
00077 {
00078
00079 if (_error_init == TRUE) {
00080 _error_init = FALSE;
00081 }
00082
00083 return;
00084
00085 }
00086
00087
00088 void
00089 giraffe_error_push(void)
00090 {
00091
00092 cx_assert(_error_init == TRUE);
00093
00094 _error.state = cpl_errorstate_get();
00095 _error_saved = TRUE;
00096
00097 cpl_error_reset();
00098
00099 return;
00100
00101 }
00102
00103
00104 void
00105 giraffe_error_pop(void)
00106 {
00107
00108 cx_assert(_error_init == TRUE);
00109
00110 if (_error_saved == TRUE) {
00111
00112 cpl_errorstate_set(_error.state);
00113 _error_saved = FALSE;
00114
00115 }
00116
00117 return;
00118
00119 }