/*HEAD ERROR_DATATYPES HHH SYSS */
/*===============================================================================

                  Copyright (c) 2003-2004 Unigraphics Solutions Inc.
                        Unpublished - All rights reserved

=================================================================================
File description:                                                                                                              

Header file to define data types for the ERROR module.

=================================================================================
   Date      Name                    Description of Change
NX3
17-Jul-2003  Lavarini                Split from error.h
17-Oct-2003  Lavarini                Add ERROR_FINALLY_TYPE so support error_finally.h
12-Jan-2004  Lavarini                Replace ERROR_raise_handler_t with
                                     ERROR_raise_handler_fn_p_t and change signature
                                     Implement ERROR_raise_handler_id_t
23-Jan-2004  Lavarini                Rename ERROR_handler_t to ERROR_debug_handler_fn_p_t
                                     Implement ERROR_debug_handler_t
27-Feb-2004  Alasdair Mackintosh     Add ERROR_THIRD_PARTY_ERROR
24-Mar-2005  Jack Marr               Include stdarg.h to get the va_list typedef
27-Sep-2005  Lavarini                Add ERROR_QUIT_TYPE
$HISTORY$
===============================================================================*/

#ifndef ERROR_DATATYPES_H_INCLUDED
#define ERROR_DATATYPES_H_INCLUDED

#include <stdarg.h>      /* define va_list */

/* Define the special code number for internal errors.
   (give unix twice the space for sigs => 65!)
   <BJS> 18-Nov-94
   Unfortunately Windows (NT) has a symbol ERROR_INTERNAL_ERROR too
   so I've renamed ours to ERROR_INTERNAL_ERROR_CODE.
   Added ERROR_USER_ABORT for user aborts
   <AJM> 27-Feb-04
   Added ERROR_THIRD_PARTY_ERROR for C++ exceptions thrown in external libraries.
*/

#define ERROR_INTERNAL_ERROR_CODE   65
#define ERROR_USER_ABORT            66
#define ERROR_THIRD_PARTY_ERROR     67

/*  <BJS> 18-Nov-94
    This is the maximum error code generated by the ERROR module itself
*/

#define ERROR_MAX_INTERNAL_CODE     67

/*  <BJS> 11-Mar-93
    default value for ERROR_this_file_name.
*/

#ifndef ERROR__STATIC_FILE_NAME
#define ERROR_this_file_name __FILE__
#endif


/* The ERROR_line macro saves having to type in two arguments to every
   call of an error reporting routine.
*/

#define ERROR_line ERROR_this_file_name, __LINE__

#define ERROR_system_log_name_len  256

/*  <BJS> 16-Apr-93
    Enum for exception types
*/

typedef enum
  { ERROR_NO_EXCEPTION,     /* no exception has ever been thrown */
    ERROR_ESCAPE,           /* last exception caused by ERROR_escape */
    ERROR_ERROR             /* last exception caused by ERROR_raise/ERROR_internal */
  } ERROR_exception_type_t;

/*  <DJL> 17-Jul-2003
*   Enum to specify in the Error_Exception class just what macro is
*   being used.
*/
typedef enum ERROR_recover_type_e
{
    ERROR_PROTECT_TYPE,
    ERROR_ESCAPE_TYPE,
    ERROR_TOP_TYPE,
    ERROR_UF_TYPE,
    ERROR_USERABORT_TYPE,
    ERROR_CALLBACK_PROTECT_TYPE,
    ERROR_CALLBACK_WATCH_TYPE,
    ERROR_FRUSTRUM_PROTECT_TYPE,
    ERROR_FINALLY_TYPE,
    ERROR_QUIT_TYPE
} ERROR_recover_type_t;

/*  ERROR_log_file_status_t

    <BJS> 14-May-93
    This enum gives possible values for the log file status
    and dictates the behaviour on exitting this program run
*/

typedef enum
  { ERROR_LOG_FILE_NOT_OPEN,
    ERROR_KEEP_LOG_FILE,
    ERROR_KEEP_LOG_FILE_ON_NOTE, /* implies keep on error too */
    ERROR_KEEP_LOG_FILE_ON_ERROR
  } ERROR_log_file_status_t;

/*
   <BJS> name of argument commented out to get through AGA
   <ARMB> finally got it acceptable, with argument name, to cc, AGA and g++. (Based on Stroustrup p.208)
   <AJF> Can now pass in a pointer to some data, which gets passed to the error handler when it is called.
*/
typedef void (*ERROR_debug_handler_fn_p_t)(int failure_code, void *data);
typedef struct ERROR_debug_handler_s
{
    ERROR_debug_handler_fn_p_t  pHandler;
    void *                      pData;
} ERROR_debug_handler_t, *ERROR_debug_handler_p_t;


typedef void (*ERROR_note_handler_t)(const char *file_name, int line_number, const char *control_string, va_list ap);

/*  <BJS> 19-Oct-01
    Raise handlers take no args (you can use ERROR_ask routines to find out
    what is happening).
    <DJL> 12-Jan-04
    Rename typedef, and pass in error code because ERROR_ask routines are now
    limited to being called from RECOVER blocks
*/

typedef void (*ERROR_raise_handler_fn_p_t)( int error_code );

/*
    Data type that defines a particular raise handler.  This id is returned
    by the set routine to specify the handler just set, and subsequently used
    by the cancel routine when that particular handler is no longer needed.
*/
typedef ERROR_raise_handler_fn_p_t ERROR_raise_handler_id_t;

/*  <BJS> 26-Mar-93
    Data types for routines to manipulate user suppliable signal routine. 
    Is simply  called with the signal number and may return to
    faulting code (e.g. for ^C) or continue fault handling
*/

typedef enum
  { ERROR_return_to_faulting_code, 
    ERROR_continue_fault_handling
  } ERROR_signal_action_t;

typedef ERROR_signal_action_t (*ERROR_signal_fn_t) (int /* signal_number */); 

typedef generic_routine_t ERROR_generic_routine_t;

/*  <TAS> 19-Aug-96
    This is a registered function that determines if the
    error reporting mechinism should be suppressed.
*/
typedef logical (*ERROR_suppression_fn_p_t) ( int error );

#endif /* ERROR_DATATYPES_H_INCLUDED */
