GIRAFFE Pipeline Reference Manual

gierror.c
1 /*
2  * This file is part of the GIRAFFE Pipeline
3  * Copyright (C) 2002-2019 European Southern Observatory
4  *
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 2 of the License, or
8  * (at your option) any later version.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23 
24 #include <cxmemory.h>
25 #include <cxstring.h>
26 #include <cxstrutils.h>
27 
28 #include <cpl_error.h>
29 #include <cpl_errorstate.h>
30 
31 #include "gierror.h"
32 
33 
34 struct GiError {
35  cpl_errorstate state;
36 };
37 
38 typedef struct GiError GiError;
39 
40 
41 static GiError _error ;
42 
43 static cxbool _error_init = FALSE;
44 static cxbool _error_saved = FALSE;
45 
46 
55 void
56 giraffe_error_init(void)
57 {
58 
59  _error_init = TRUE;
60  return;
61 
62 }
63 
64 
65 void
66 giraffe_error_clear(void)
67 {
68 
69  if (_error_init == TRUE) {
70  _error_init = FALSE;
71  }
72 
73  return;
74 
75 }
76 
77 
78 void
79 giraffe_error_push(void)
80 {
81 
82  cx_assert(_error_init == TRUE);
83 
84  _error.state = cpl_errorstate_get();
85  _error_saved = TRUE;
86 
87  cpl_error_reset();
88 
89  return;
90 
91 }
92 
93 
94 void
95 giraffe_error_pop(void)
96 {
97 
98  cx_assert(_error_init == TRUE);
99 
100  if (_error_saved == TRUE) {
101 
102  cpl_errorstate_set(_error.state);
103  _error_saved = FALSE;
104 
105  }
106 
107  return;
108 
109 }

This file is part of the GIRAFFE Pipeline Reference Manual 2.16.10.
Documentation copyright © 2002-2006 European Southern Observatory.
Generated on Thu Dec 15 2022 21:18:51 by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2004