Kaydet (Commit) 64832b93 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS os2port01 (1.1.2); FILE ADDED

2006/11/29 14:31:18 ydario 1.1.2.1: Forgot some files.
üst 590b1e78
This diff is collapsed.
/*
*@@sourcefile except.h:
* header file for except.c. See remarks there.
*
* Note: Version numbering in this file relates to XWorkplace version
* numbering.
*
*@@include #define INCL_DOSEXCEPTIONS
*@@include #define INCL_DOSPROCESS
*@@include #include <os2.h>
*@@include #include <stdio.h>
*@@include #include <setjmp.h>
*@@include #include "helpers\except.h"
*/
/*
* Copyright (C) 1999-2000 Ulrich Mller.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, in version 2 as it comes in the COPYING
* file of the XFolder main distribution.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#if __cplusplus
extern "C" {
#endif
#ifndef EXCEPT_HEADER_INCLUDED
#define EXCEPT_HEADER_INCLUDED
#if defined __IBMCPP__ || defined __IBMC__
#ifndef INCL_DOSEXCEPTIONS
#error except.h requires INCL_DOSEXCEPTIONS to be defined.
#endif
#ifndef INCL_DOSPROCESS
#error except.h requires INCL_DOSPROCESS to be defined.
#endif
#ifndef __stdio_h
#error except.h requires stdio.h to be included.
#endif
#ifndef __setjmp_h
#error except.h requires setjmp.h to be included.
#endif
#endif
/********************************************************************
*
* Declarations
*
********************************************************************/
// forward declaration
typedef struct _EXCEPTIONREGISTRATIONRECORD2 *PEXCEPTIONREGISTRATIONRECORD2;
// "OnKill" function prototype for EXCEPTIONREGISTRATIONRECORD2
// added V0.9.0 (99-10-22) [umoeller]
// removed V0.9.7 (2000-12-08) [umoeller]
// typedef VOID APIENTRY FNEXCONKILL(PEXCEPTIONREGISTRATIONRECORD2);
// typedef FNEXCONKILL *PFNEXCONKILL;
/*
*@@ EXCEPTIONREGISTRATIONRECORD2:
* replacement EXCEPTIONREGISTRATIONRECORD
* struct for thread exception handling.
*
*@@changed V0.9.0 (99-10-22) [umoeller]: pfnOnKill added
*@@changed V0.9.0 (99-10-22) [umoeller]: renamed from REGREC2
*/
typedef struct _EXCEPTIONREGISTRATIONRECORD2
{
PVOID pNext; // as in EXCEPTIONREGISTRATIONRECORD
PFN pfnHandler; // as in EXCEPTIONREGISTRATIONRECORD
jmp_buf jmpThread; // additional buffer for setjmp
EXCEPTIONREPORTRECORD err; // exception handlers copy the report rec here
PVOID pvUser; // user ptr
} EXCEPTIONREGISTRATIONRECORD2;
/*
*@@ EXCEPTSTRUCT:
* structure used with TRY_xxx macros.
*/
typedef struct _EXCEPTSTRUCT
{
EXCEPTIONREGISTRATIONRECORD2 RegRec2;
ULONG ulExcpt; // != NULL if exception caught
APIRET arc; // rc of DosSetExceptionHandler
} EXCEPTSTRUCT, *PEXCEPTSTRUCT;
// function prototypes for exception hooks (V0.9.0)
// "open traplog file" hook
typedef FILE* APIENTRY FNEXCOPENFILE(VOID);
typedef FNEXCOPENFILE *PFNEXCOPENFILE;
// "exception" hook
typedef VOID APIENTRY FNEXCHOOK(FILE*, PTIB, ULONG); // V0.9.16 (2001-12-02) [pr]
typedef FNEXCHOOK *PFNEXCHOOK;
// "error" hook
typedef VOID APIENTRY FNEXCHOOKERROR(const char *pcszFile,
ULONG ulLine,
const char *pcszFunction,
APIRET arc);
typedef FNEXCHOOKERROR *PFNEXCHOOKERROR;
/********************************************************************
*
* Prototypes
*
********************************************************************/
VOID excExplainException(FILE *file,
PSZ pszHandlerName,
PEXCEPTIONREPORTRECORD pReportRec,
PCONTEXTRECORD pContextRec);
VOID excRegisterHooks(PFNEXCOPENFILE pfnExcOpenFileNew,
PFNEXCHOOK pfnExcHookNew,
PFNEXCHOOKERROR pfnExcHookError,
BOOL fBeepOnExceptionNew);
ULONG _System excHandlerLoud(PEXCEPTIONREPORTRECORD pReportRec,
PEXCEPTIONREGISTRATIONRECORD2 pRegRec2,
PCONTEXTRECORD pContextRec,
PVOID pv);
ULONG _System excHandlerQuiet(PEXCEPTIONREPORTRECORD pReportRec,
PEXCEPTIONREGISTRATIONRECORD2 pRegRec2,
PCONTEXTRECORD pContextRec,
PVOID pv);
extern PFNEXCHOOKERROR G_pfnExcHookError;
extern ULONG G_ulExplainExceptionRunning;
/********************************************************************
*
* Macros
*
********************************************************************/
/* See except.c for explanations how to use these. */
#ifdef __NO_EXCEPTION_HANDLERS__
// exception handlers can completely be disabled
#define TRY_LOUD(excptstruct)
#else
#ifdef __NO_LOUD_EXCEPTION_HANDLERS__
#define TRY_LOUD(e) TRY_QUIET(e)
#else // __NO_LOUD_EXCEPTION_HANDLERS__
#define TRY_LOUD(excptstruct) \
{ \
EXCEPTSTRUCT excptstruct = {0}; \
excptstruct.RegRec2.pfnHandler = (PFN)excHandlerLoud; \
excptstruct.arc = DosSetExceptionHandler( \
(PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2)); \
if (excptstruct.arc) \
if (G_pfnExcHookError) \
G_pfnExcHookError(__FILE__, __LINE__, __FUNCTION__, excptstruct.arc); \
else \
DosBeep(1000, 1000); \
excptstruct.ulExcpt = setjmp(excptstruct.RegRec2.jmpThread); \
if (excptstruct.ulExcpt == 0) \
{
#endif // __NO_LOUD_EXCEPTION_HANDLERS__
#endif
#ifdef __NO_EXCEPTION_HANDLERS__
// exception handlers can completely be disabled
#define TRY_QUIET(excptstruct)
#else
#define TRY_QUIET(excptstruct) \
{ \
EXCEPTSTRUCT excptstruct = {0}; \
excptstruct.RegRec2.pfnHandler = (PFN)excHandlerQuiet; \
excptstruct.arc = DosSetExceptionHandler( \
(PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2)); \
if (excptstruct.arc) \
if (G_pfnExcHookError) \
G_pfnExcHookError(__FILE__, __LINE__, __FUNCTION__, excptstruct.arc); \
else \
DosBeep(1000, 1000); \
excptstruct.ulExcpt = setjmp(excptstruct.RegRec2.jmpThread); \
if (excptstruct.ulExcpt == 0) \
{
#endif
#ifdef __NO_EXCEPTION_HANDLERS__
// exception handlers can completely be disabled
#define CATCH(excptstruct) if (FALSE) {
#else
#define CATCH(excptstruct) \
DosUnsetExceptionHandler( \
(PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2)); \
} /* end of TRY block */ \
else \
{ /* exception occured: */ \
DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2));
#endif
#ifdef __NO_EXCEPTION_HANDLERS__
// exception handlers can completely be disabled
#define END_CATCH() }
#else
#define END_CATCH() \
} /* end of exception-occured block */ \
}
#endif
/*
* CRASH:
* this macro is helpful for testing
* the exception handlers.
* This is not for general use. ;-)
*/
#define CRASH {PSZ p = NULL; *p = 'a'; }
#endif // EXCEPT_HEADER_INCLUDED
#if __cplusplus
}
#endif
/*
* setup.h:
* sample master include file which gets included
* from all helpers *.c sources.
*/
#ifndef SETUP_HEADER_INCLUDED
#define SETUP_HEADER_INCLUDED
// XWPEXPORT defines the standard linkage for the
// XWorkplace helpers.
#ifdef __EMX__
#define XWPENTRY
#elif defined (__IBMCPP__) || defined (__IBMC__)
#define XWPENTRY _Optlink
#endif
/*************************************************************
* *
* Additional stuff for EMX *
* *
*************************************************************/
#ifdef __EMX__
// EMX doesn't have all these 16-bit typedefs;
// added (99-10-22) [umoeller]
#define APIENTRY16 _Far16 _Pascal
#define PASCAL16 _Far16 _Pascal
#define CDECL16 _Far16 _Cdecl
typedef unsigned short APIRET16;
typedef unsigned long APIRET32;
#if 0
//YD do not use with gcc 3.3.5
#define _System
#define APIENTRY
// with VAC++, this defines _System linkage, which
// EMX doesn't have, or does it?!?
#endif // 0
#endif
// the following is a VAC++-specific macro, which doesn't exist
// with EMX, so we need to implement this... this was one of
// the "undefined symbols" we got (99-10-23) [umoeller]
// changed this to prefix underscore, because the STL apparently
// redefines this V0.9.3 (2000-05-15) [umoeller]
#define _min(a,b) ( ((a) > (b)) ? b : a )
#define _max(a,b) ( ((a) > (b)) ? a : b )
// Uncomment the following if you have trouble with the
// exception handlers in helpers\except.c; WarpIN will
// then install _no_ additional exception handlers at all
// (include\helpers\except.h reacts to these defines).
// I'm not sure if the handlers work well with EMX.
#ifdef __EMX__00
#define __NO_EXCEPTION_HANDLERS__
#endif
/*************************************************************
* *
* Additional stuff for VAC++ 3.0 *
* *
*************************************************************/
// all this added V0.9.2 (2000-03-10) [umoeller]
#if ( defined ( __IBMCPP__ ) && ( __IBMCPP__ < 400 ) )
typedef int bool;
#define true 1
#define false 0
#define _BooleanConst // needed for some VAC headers, which define bool also
#endif
#ifndef __stdlib_h // <stdlib.h>
#include <stdlib.h>
#endif
#ifndef __string_h // <string.h>
#include <string.h>
#endif
/*************************************************************
* *
* Debugging *
* *
*************************************************************/
// All the following redone (99-10-23) [umoeller]:
// __DEBUG__ is defined as a macro on the compiler
// command line by the makefiles if DEBUG was enabled
// in \setup.in
#ifdef __DEBUG__
// with debug code, disable the exception handlers
#define __NO_EXCEPTION_HANDLERS__
// If the following is commented out, no PMPRINTF will be
// used at all. WarpIN uses Dennis Bareis' PMPRINTF
// package to do this.
// NOTE: We cannot use PmPrintf with EMX,
// because pmprintf.lib imports the VAC++ runtimes.
// That's the strange errors I was reporting yesterday.
#ifndef __EMX__
#ifdef OS2_INCLUDED
#define _PMPRINTF_
#include "helpers/pmprintf.h"
#endif
#endif
#endif
#ifndef _PMPRINTF_
// not defined: define empty macro so we don't
// get compiler errors
#define _Pmpf(x)
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment