Files
harbour-core/harbour/source/vm/extrap.c
Viktor Szakats d9fe9a4688 2008-06-01 13:26 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* source/vm/extrap.c
     ! Fixed missing header for OS/2.

   * source/vm/classes.c
     ! Minor fix in internal error text.

   * contrib/hbcurl/make_b32.bat
   * contrib/hbcurl/make_vc.bat
   * contrib/hbcurl/hbcurl.c
   * contrib/hbcurl/hbcurl.ch
   * contrib/hbcurl/tests/ftp_uldl.prg
     ! non-GNU make will also look into the /bin folder 
       for .dlls.
     ! Lots of fixes, too many to mention.
     + Enabled GC pointers. (see TOFIX though)
     + Added all remaining CURL 'easy' API parts and 
       implemented all options existing in 7.18.1:
       + All option values (except bit-level ones) made available in hbcurl.ch
       + All options updated to latest CURL version in hbcurl.ch
       + All error codes made available in hbcurl.ch
       + CURL_EASY_DUPLICATE()
       + CURL_EASY_RESET()
       + CURL_EASY_PAUSE()
       + CURL_EASY_SEND() (not yet available in stable builds)
       + CURL_EASY_RECV() (not yet available in stable builds)
       + CURL_EASY_GETINFO()
       + CURL_ESCAPE() (obsolete)
       + CURL_UNESCAPE() (obsolete)
       + CURL_GETDATE()
     ; TOFIX1: Could someone look at it? In case I call the destructor 
               (curl_easy_cleanup()) manually, the garbage collector 
               will run into an invalid pointer, when terminating the 
               test program.
     ; TOFIX2: The casting to 'curl_off_t' goes wrong. Could someone 
               help?
     ; NOTE1:  Harbour needs at least libcurl 7.17.0. Unfortunately 
               compile time version detection is not working at this time, 
               so try with the latest version 7.18.1.
     ; NOTE2:  Most callback interfaces are not implemented on the 
               Harbour level.
     ; NOTE3:  Harbour is currently not optimizing
               "<const1> ** <const2>" type of expressions at compile time.
               Could we add it? This expression is not widespread, 
               but anyways, it cannot hurt, if isn't too much 
               work to do.
2008-06-01 11:31:48 +00:00

173 lines
5.6 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Exception handlers
*
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
* www - http://www.harbour-project.org
*
* 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; either version 2, or (at your option)
* any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#define HB_OS_WIN_32_USED
#include "hbapi.h"
#include "hbvm.h"
#include "hbapifs.h"
#include "hbdate.h"
#include "hbapierr.h"
#if defined(HB_OS_WIN_32) && !defined(HB_WINCE)
LONG WINAPI hb_win32ExceptionHandler( struct _EXCEPTION_POINTERS * ExceptionInfo )
{
char msg[ ( HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 32 ) * 32 ];
char buffer[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 ];
char * ptr;
USHORT uiLine;
int iLevel;
FILE * hLog = hb_fopen( "hb_ex.log", "a+" );
if( hLog )
{
char szTime[ 9 ];
int iYear, iMonth, iDay;
hb_dateToday( &iYear, &iMonth, &iDay );
hb_dateTimeStr( szTime );
fprintf( hLog, "Harbour Exception - %s\n", hb_cmdargARGV()[0] );
fprintf( hLog, "Terminated at: %04d.%02d.%02d %s\n", iYear, iMonth, iDay, szTime );
}
HB_SYMBOL_UNUSED( ExceptionInfo );
msg[ 0 ] = '\0';
ptr = msg;
iLevel = 0;
while( hb_procinfo( iLevel++, buffer, &uiLine, NULL ) )
{
snprintf( ptr, sizeof( msg ) - ( ptr - msg ),
HB_I_("Called from %s(%hu)\n"), buffer, uiLine );
if( hLog )
fwrite( ptr, sizeof( *ptr ), strlen( ptr ), hLog );
ptr += strlen( ptr );
}
/* GUI */
{
LPTSTR lpStr = HB_TCHAR_CONVTO( msg );
MessageBox( NULL, lpStr, TEXT( "Harbour Exception" ), MB_ICONSTOP );
HB_TCHAR_FREE( lpStr );
}
if( hLog )
{
fprintf( hLog, "------------------------------------------------------------------------\n");
fclose( hLog );
}
return EXCEPTION_CONTINUE_SEARCH; /* EXCEPTION_EXECUTE_HANDLER; */
}
#endif
#if defined(HB_OS_OS2)
ULONG _System hb_os2ExceptionHandler( PEXCEPTIONREPORTRECORD p1,
PEXCEPTIONREGISTRATIONRECORD p2,
PCONTEXTRECORD p3,
PVOID pv )
{
HB_SYMBOL_UNUSED( p1 );
HB_SYMBOL_UNUSED( p2 );
HB_SYMBOL_UNUSED( p3 );
HB_SYMBOL_UNUSED( pv );
/* Don't print stack trace if inside unwind, normal process termination or process killed or
during debugging */
if( p1->ExceptionNum != XCPT_UNWIND && p1->ExceptionNum < XCPT_BREAKPOINT )
{
char buffer[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 ];
USHORT uiLine;
int iLevel = 0;
fprintf( stderr, HB_I_("\nException %lx at address %p \n"), p1->ExceptionNum, p1->ExceptionAddress );
while( hb_procinfo( iLevel++, buffer, &uiLine, NULL ) )
fprintf( stderr, HB_I_("Called from %s(%hu)\n"), buffer, uiLine );
}
return XCPT_CONTINUE_SEARCH; /* Exception not resolved... */
}
#endif
void hb_vmSetExceptionHandler( void )
{
#if defined(HB_OS_WIN_32) && !defined(HB_WINCE)
{
LPTOP_LEVEL_EXCEPTION_FILTER ef = SetUnhandledExceptionFilter( hb_win32ExceptionHandler );
HB_SYMBOL_UNUSED( ef );
}
#elif defined(HB_OS_OS2) /* Add OS2TermHandler to this thread's chain of exception handlers */
{
EXCEPTIONREGISTRATIONRECORD RegRec; /* Exception Registration Record */
APIRET rc; /* Return code */
memset( &RegRec, 0, sizeof( RegRec ) );
RegRec.ExceptionHandler = ( ERR ) hb_os2ExceptionHandler;
rc = DosSetExceptionHandler( &RegRec );
if( rc != NO_ERROR )
{
hb_errInternal( HB_EI_ERRUNRECOV, "Unable to setup exception handler (DosSetExceptionHandler())", NULL, NULL );
}
}
#endif
}