1 /********************************************************************** 2 * File: errcode.h (Formerly error.h) 3 * Description: Header file for generic error handler class 4 * Author: Ray Smith 5 * Created: Tue May 1 16:23:36 BST 1990 6 * 7 * (C) Copyright 1990, 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 #ifndef ERRCODE_H 21 #define ERRCODE_H 22 23 #include "host.h" 24 25 /*Control parameters for error()*/ 26 #define DBG -1 /*log without alert */ 27 #define TESSLOG 0 /*alert user */ 28 #define EXIT 1 /*exit after erro */ 29 #define ABORT 2 /*abort after error */ 30 31 /* Explicit Error Abort codes */ 32 #define NO_ABORT_CODE 0 33 #define LIST_ABORT 1 34 #define MEMORY_ABORT 2 35 #define FILE_ABORT 3 36 37 /* Location of code at error codes Reserve 0..2 (status codes 0..23 for UNLV)*/ 38 #define LOC_UNUSED0 0 39 #define LOC_UNUSED1 1 40 #define LOC_UNUSED2 2 41 #define LOC_INIT 3 42 #define LOC_EDGE_PROG 4 43 #define LOC_TEXT_ORD_ROWS 5 44 #define LOC_TEXT_ORD_WORDS 6 45 #define LOC_PASS1 7 46 #define LOC_PASS2 8 47 /* Reserve up to 8..13 for adding subloc 0/3 plus subsubloc 0/1/2 */ 48 #define LOC_FUZZY_SPACE 14 49 /* Reserve up to 14..20 for adding subloc 0/3 plus subsubloc 0/1/2 */ 50 #define LOC_MM_ADAPT 21 51 #define LOC_DOC_BLK_REJ 22 52 #define LOC_WRITE_RESULTS 23 53 #define LOC_ADAPTIVE 24 54 /* DONT DEFINE ANY LOCATION > 31 !!! */ 55 56 /* Sub locatation determines whether pass2 was in normal mode or fix xht mode*/ 57 #define SUBLOC_NORM 0 58 #define SUBLOC_FIX_XHT 3 59 60 /* Sub Sub locatation determines whether match_word_pass2 was in Tess 61 matcher, NN matcher or somewhere else */ 62 63 #define SUBSUBLOC_OTHER 0 64 #define SUBSUBLOC_TESS 1 65 #define SUBSUBLOC_NN 2 66 67 class DLLSYM ERRCODE //error handler class 68 { 69 const char *message; //error message 70 public: 71 void error ( //error print function 72 const char *caller, //function location 73 inT8 action, //action to take 74 const char *format, ... //fprintf format 75 ) const; ERRCODE(const char * string)76 ERRCODE(const char *string) { 77 message = string; 78 } //initialize with string 79 }; 80 81 const ERRCODE ASSERT_FAILED = "Assert failed"; 82 83 #define ASSERT_HOST(x) if (!(x)) \ 84 { \ 85 ASSERT_FAILED.error(#x,ABORT,"in file %s, line %d", \ 86 __FILE__,__LINE__); \ 87 } 88 89 void signal_exit( // 90 int signal_code //Signal which 91 ); 92 extern "C" 93 { 94 void err_exit(); 95 //The real signal 96 void signal_termination_handler(int sig); 97 }; 98 99 void set_global_loc_code(int loc_code); 100 101 void set_global_subloc_code(int loc_code); 102 103 void set_global_subsubloc_code(int loc_code); 104 #endif 105