Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
globaloc.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 * File: errcode.c (Formerly error.c)
3 * Description: Generic error handler function
4 * Author: Ray Smith
5 * Created: Tue May 1 16:28:39 BST 1990
6 *
7 * (C) Copyright 1989, Hewlett-Packard Ltd.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 *
18 **********************************************************************/
19
20 #include "mfcpch.h"
21 #include <signal.h>
22 #include "errcode.h"
23 #include "tprintf.h"
24
25 /*inT16 global_loc_code = LOC_INIT;//location code
26 inT16 global_subloc_code = SUBLOC_NORM;
27 //pass2 subloc code
28 inT16 global_subsubloc_code = SUBSUBLOC_OTHER;
29 //location code
30 inT16 global_abort_code = NO_ABORT_CODE;
31 //Prog abort code
32 */
33 void signal_exit( //
34 int signal_code //Signal which
35 ) {
36 /*int exit_status;
37
38 if ((global_loc_code == LOC_PASS2) || (global_loc_code == LOC_FUZZY_SPACE))
39 global_loc_code += global_subloc_code + global_subsubloc_code;
40
41 if (signal_code < 0) {
42 exit_status = global_loc_code * 8 + global_abort_code * 2 + 1;
43 tprintf ("Signal_exit %d ABORT. LocCode: %d AbortCode: %d\n",
44 exit_status, global_loc_code, global_abort_code);
45 }
46 else {
47 exit_status = global_loc_code * 8 + signal_code * 2;
48 tprintf ("Signal_exit %d SIGNAL ABORT. LocCode: %d SignalCode: %d\n",
49 exit_status, global_loc_code, signal_code);
50 }
51
52 exit(exit_status);*/
53 exit(signal_code);
54 }
55
56
57 /*************************************************************************
58 * err_exit()
59 * All program exits should go through this point. It allows a meaningful status
60 * code to be generated for the real exit() call. The status code is made up
61 * as follows:
62 * Bit 0 : 1 = Program Abort 0 = System Abort
63 * Bits 1,2 : IF bit 0 = 1 THEN ERRCODE::abort_code
64 * ELSE 0 = Bus Err or Seg Vi
65 * 1 = Floating point exception
66 * 2 = TimeOut (Signal 15 from command timer)
67 * 3 = Any other signal
68 * Bits 3..7 : Location code NEVER 0 !
69 *************************************************************************/
70
71 //extern "C" {
72
73 void err_exit() {
74 signal_exit (-1);
75 }
76
77
78 void signal_termination_handler(int sig) {
79 const ERRCODE SIGNAL_HANDLER_ERR = "Signal_termination_handler called";
80 SIGNAL_HANDLER_ERR.error("signal_termination_handler", ABORT, "Code %d", sig);
81 switch (sig) {
82 case SIGABRT:
83 signal_exit (-1); //use abort code
84 // case SIGBUS:
85 case SIGSEGV:
86 signal_exit (0);
87 case SIGFPE:
88 signal_exit (1); //floating point
89 case SIGTERM:
90 signal_exit (2); //timeout by cmdtimer
91 default:
92 signal_exit (3); //Anything else
93 }
94 }
95
96
97 //}; //end extern "C"
98
99
100 void set_global_loc_code(int loc_code) {
101 // global_loc_code = loc_code;
102
103 }
104
105
106 void set_global_subloc_code(int loc_code) {
107 // global_subloc_code = loc_code;
108
109 }
110
111
112 void set_global_subsubloc_code(int loc_code) {
113 // global_subsubloc_code = loc_code;
114
115 }