ccutil/globaloc.cpp

Go to the documentation of this file.
00001 
00020 #include          "mfcpch.h"
00021 #include          <signal.h>
00022 #include          "errcode.h"
00023 #include          "tprintf.h"
00024 
00025 INT16 global_loc_code = LOC_INIT;//location code
00026 INT16 global_subloc_code = SUBLOC_NORM;
00027                                  //pass2 subloc code
00028 INT16 global_subsubloc_code = SUBSUBLOC_OTHER;
00029                                  //location code
00030 INT16 global_abort_code = NO_ABORT_CODE;
00031                                  //Prog abort code
00032 
00035 void signal_exit(                 //
00036                  int signal_code  //Signal which
00037                 ) {
00038   int exit_status;
00039 
00040   if ((global_loc_code == LOC_PASS2) || (global_loc_code == LOC_FUZZY_SPACE))
00041     global_loc_code += global_subloc_code + global_subsubloc_code;
00042 
00043   if (signal_code < 0) {
00044     exit_status = global_loc_code * 8 + global_abort_code * 2 + 1;
00045     tprintf ("Signal_exit %d ABORT. LocCode: %d  AbortCode: %d\n",
00046       exit_status, global_loc_code, global_abort_code);
00047   }
00048   else {
00049     exit_status = global_loc_code * 8 + signal_code * 2;
00050     tprintf ("Signal_exit %d SIGNAL ABORT. LocCode: %d  SignalCode: %d\n",
00051       exit_status, global_loc_code, signal_code);
00052   }
00053 
00054   exit(exit_status); 
00055 }
00056 
00057 
00058 //extern "C" {
00059 
00075 void err_exit() { 
00076   signal_exit (-1);
00077 }
00078 
00079 
00083 void signal_termination_handler(  //The real signal
00084                                 int sig) {
00085   tprintf ("Signal_termination_handler called with signal %d\n", sig);
00086   switch (sig) {
00087     case SIGABRT:
00088       signal_exit (-1);          //use abort code
00089       //         case SIGBUS:
00090     case SIGSEGV:
00091       signal_exit (0);
00092     case SIGFPE:
00093       signal_exit (1);           //floating point
00094     case SIGTERM:
00095       signal_exit (2);           //timeout by cmdtimer
00096     default:
00097       signal_exit (3);           //Anything else
00098   }
00099 }
00100 
00101 
00102 //};                                                                                                            //end extern "C"
00103 
00107 void set_global_loc_code(int loc_code) { 
00108   global_loc_code = loc_code;
00109 
00110 }
00111 
00112 
00116 void set_global_subloc_code(int loc_code) { 
00117   global_subloc_code = loc_code;
00118 
00119 }
00120 
00121 
00125 void set_global_subsubloc_code(int loc_code) { 
00126   global_subsubloc_code = loc_code;
00127 
00128 }

Generated on Wed Feb 28 19:49:09 2007 for Tesseract by  doxygen 1.5.1