cutil/danerror.h File Reference

#include <setjmp.h>

Go to the source code of this file.

Defines

Typedefs

Functions


Define Documentation

#define DO_NOTHING   0

Definition at line 29 of file danerror.h.

Referenced by DoError().

#define NOERROR   0

Definition at line 28 of file danerror.h.

#define SetErrorTrap ( Proc   )     setjmp(PushErrorTrap(Proc))

Note:
File:danerror.h
Definition of error trapping routines.
Author:
Dan Johnson
Date:
4/3/89, DSJ, Created.
 **	(c) Copyright Hewlett-Packard Company, 1988.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 27 of file danerror.h.

Referenced by cc_recog().


Typedef Documentation

TRAPERROR

Holds error trapped, int.

Definition at line 36 of file danerror.h.

typedef void(*) VOID_PROC()

Definition at line 37 of file danerror.h.


Function Documentation

void DoError ( int  Error,
const char *  Message 
)

Prints the specified error message to stderr & jumps to the current error trap.

Parameters:
Error Error number which is to be trapped
Message Pointer to a string to be printed as an error message
Note:
Globals:
  • ErrorTrapStack Stack of error traps
  • CurrentTrapDepth Number of traps on the stack
Returns:
none (does not return)
If the error trap stack is empty, the calling program is terminated with a fatal error message.
Note:
Exceptions: Empty error trap stack terminates the calling program.
Date:
4/3/89, DSJ, Created.

Definition at line 84 of file danerror.cpp.

References assert(), cprintf(), CurrentTrapDepth, DO_NOTHING, ErrorTrapStack, FALSE, NULL, ProcTrapStack, and signal_termination_handler().

Referenced by Efopen(), Efree(), Emalloc(), Erealloc(), ExtractorStub(), FillAmbigTable(), HeapPush(), HeapStore(), MakeSample(), memalloc_p(), memfree(), NameToChar(), PushErrorTrap(), ReadCharDescription(), ReadFeature(), ReadFeatureSet(), ReadNFloats(), ReadParamDesc(), ReadProtoStyle(), ReadPrototype(), ReadSampleSize(), and ShortNameToFeatureType().

00084                                              { 
00085   if (Message != NULL) {
00086     cprintf ("\nError: %s!\n", Message);
00087   }
00088 
00089   if (CurrentTrapDepth <= 0) {
00090     cprintf ("\nFatal error: No error trap defined!\n");
00091 
00092     /* SPC 20/4/94
00093        There used to be a call to abort() here. I've changed it to call into the
00094        C++ error code to generate a meaningful status code
00095      */
00096     signal_termination_handler(Error); 
00097   }
00098 
00099   if (ProcTrapStack[CurrentTrapDepth - 1] != DO_NOTHING)
00100     (*ProcTrapStack[CurrentTrapDepth - 1]) ();
00101 
00102   longjmp (ErrorTrapStack[CurrentTrapDepth - 1], 1);
00103   assert(FALSE); 
00104 }                                /* DoError */

jmp_buf& PushErrorTrap ( VOID_PROC  Procedure  ) 

Pushes a new error trap onto the top of the error trap stack.

Parameters:
Procedure Trap procedure to execute
Note:
Globals:
  • ErrorTrapStack Stack of error traps
  • CurrentTrapDepth Number of traps on the stack
Returns:
Pointer to a new error trap buffer
This new error trap can then be used in a call to setjmp. This trap is then in effect until ReleaseErrorTrap is called.

WARNING: a procedure that calls PushErrorTrap should never exit before calling ReleaseErrorTrap.

Note:
Exceptions: Traps an error if the error trap stack is already full
Date:
3/17/89, DSJ, Created. 9/12/90, DSJ, Added trap procedure parameter.

Definition at line 129 of file danerror.cpp.

References CurrentTrapDepth, DoError(), ERRORTRAPDEPTH, ErrorTrapStack, MAXTRAPDEPTH, and ProcTrapStack.

00129                                             { 
00130   if (CurrentTrapDepth >= MAXTRAPDEPTH)
00131     DoError (ERRORTRAPDEPTH, "Error trap depth exceeded");
00132   ProcTrapStack[CurrentTrapDepth] = Procedure;
00133   return ErrorTrapStack[CurrentTrapDepth++];
00134 
00135 }                                /* PushErrorTrap */

void ReleaseErrorTrap (  ) 

Removes the current error trap from the error trap stack, thus returning control to the previous error trap.

Note:
Globals: CurrentTrapDepth number of traps on the stack
Returns:
none
If the error trap stack is empty, nothing is done.
Note:
Exceptions: None
Date:
4/3/89, DSJ, Created.

Definition at line 60 of file danerror.cpp.

References CurrentTrapDepth.

Referenced by cc_recog().

00060                         { 
00061   if (CurrentTrapDepth > 0) {
00062     CurrentTrapDepth--;
00063   }
00064 }                                /* ReleaseErrorTrap */


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