1 /*
2 * ObsPy wrapper functions for evalresp.
3 *
4 * These are needed because evalresp uses setjmp/longjmp to implement error
5 * handling. These cannot be called from Python without crashing due to it
6 * messing with the internals of the interpreter.
7 *
8 * Copyright (C) ObsPy Development Team, 2014.
9 *
10 * This file is licensed under the terms of the GNU Lesser General Public
11 * License, Version 3 (https://www.gnu.org/copyleft/lesser.html).
12 *
13 */
14
15
16 #include <setjmp.h>
17 #include "evresp.h"
18
19
_obspy_check_channel(struct channel * chan)20 int _obspy_check_channel(struct channel *chan)
21 {
22 int rc;
23 if ((rc = setjmp(jump_buffer)) == 0) {
24 /* Direct invocation */
25 GblChanPtr = chan;
26 check_channel(chan);
27 GblChanPtr = NULL;
28 return 0;
29 } else {
30 /* Error called by longjmp */
31 GblChanPtr = NULL;
32 return rc;
33 }
34 }
35
_obspy_norm_resp(struct channel * chan,int start_stage,int stop_stage,int hide_sensitivity_mismatch_warning)36 int _obspy_norm_resp(struct channel *chan, int start_stage, int stop_stage,
37 int hide_sensitivity_mismatch_warning)
38 {
39 int rc;
40 if ((rc = setjmp(jump_buffer)) == 0) {
41 /* Direct invocation */
42 GblChanPtr = chan;
43 norm_resp(chan, start_stage, stop_stage, hide_sensitivity_mismatch_warning);
44 GblChanPtr = NULL;
45 return 0;
46 } else {
47 /* Error called by longjmp */
48 GblChanPtr = NULL;
49 return rc;
50 }
51 }
52
53
_obspy_calc_resp(struct channel * chan,double * freq,int nfreqs,struct complex * output,char * out_units,int start_stage,int stop_stage,int useTotalSensitivityFlag)54 int _obspy_calc_resp(struct channel *chan, double *freq, int nfreqs,
55 struct complex *output, char *out_units,
56 int start_stage, int stop_stage,
57 int useTotalSensitivityFlag)
58 {
59 int rc;
60 if ((rc = setjmp(jump_buffer)) == 0) {
61 /* Direct invocation */
62 GblChanPtr = chan;
63 calc_resp(chan, freq, nfreqs, output, out_units, start_stage, stop_stage,
64 useTotalSensitivityFlag);
65 GblChanPtr = NULL;
66 return 0;
67 } else {
68 /* Error called by longjmp */
69 GblChanPtr = NULL;
70 return rc;
71 }
72 }
73