*** empty log message ***
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
19990621-04:04 CET Victor Szel <info@szelvesz.hu>
|
||||
* include/errorapi.h - Some additions, note
|
||||
the copyright message at the beginning, as the
|
||||
final text gets done, we should put similar header
|
||||
to each file.
|
||||
! include/hbsetup.h - USE_GTAPI was mistakenly
|
||||
left defined.
|
||||
+ include/errorapi.h
|
||||
include/error.api
|
||||
source/rtl/errorapi.c
|
||||
The rest of the ERROR API functions
|
||||
implemented.
|
||||
. hb_errorRT_BASE() implemented.
|
||||
+ doc/header.txt - added as a function header
|
||||
template.
|
||||
|
||||
19990621-01:30 CET Victor Szel <info@szelvesz.hu>
|
||||
* whatsnew.txt moved to doc/ directory.
|
||||
* doc/hrb.faq renamed to hrb_faq.txt
|
||||
|
||||
74
harbour/doc/header.txt
Normal file
74
harbour/doc/header.txt
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
*
|
||||
* $CATEGORY$
|
||||
*
|
||||
* $ONELINER$
|
||||
*
|
||||
* $SYNTAX$
|
||||
*
|
||||
* $ARGUMENTS$
|
||||
*
|
||||
* $RETURNS$
|
||||
*
|
||||
* $DESCRIPTION$
|
||||
*
|
||||
* $EXAMPLES$
|
||||
*
|
||||
* $TESTS$
|
||||
*
|
||||
* $STATUS$
|
||||
*
|
||||
* $COMPLIANCE$
|
||||
*
|
||||
* $SEEALSO$
|
||||
*
|
||||
* $END$
|
||||
*/
|
||||
|
||||
Example:
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* IsLeapYr()
|
||||
* $CATEGORY$
|
||||
* Dates
|
||||
* $ONELINER$
|
||||
* Test if a date falls in a leap year.
|
||||
* $SYNTAX$
|
||||
* IsLeapYr( [<dDate>] ) --> lIsLeap
|
||||
* $ARGUMENTS$
|
||||
* <dDate> is an optional date. If not supplied is defaults to the
|
||||
* value returned from date().
|
||||
* $RETURNS$
|
||||
* TRUE if <dDate> falls in a leap year, FALSE if not.
|
||||
* $DESCRIPTION$
|
||||
* IsLeapYr() can be used to check if a given year is a leap year.
|
||||
* $EXAMPLES$
|
||||
* // Check if it's a leap year.
|
||||
*
|
||||
* If IsLeapYr()
|
||||
* ? "One extra day before you get paid this Feb!!"
|
||||
* Else
|
||||
* ? "A normal year"
|
||||
* EndIf
|
||||
* $TESTS$
|
||||
* valtype( IsLeapYr( date() ) ) == "L"
|
||||
* valtype( IsLeapYr( ctod( "" ) ) ) == "L"
|
||||
* valtype( IsLeapYr() ) == "L"
|
||||
* IsLeapYr( SToD( "20000101" ) )
|
||||
* !IsLeapYr( SToD( "19000101" ) )
|
||||
* IsLeapYr( SToD( "19841231" ) )
|
||||
* !IsLeapYr()
|
||||
* $STATUS$
|
||||
* C
|
||||
* $COMPLIANCE$
|
||||
* IsLeapYr() works exactly like CA-Clipper's IsLeapYr(), if your
|
||||
* CA-Clipper doesn't have such a function you're probably in a
|
||||
* different universe from the author of this function.
|
||||
* $SEEALSO$
|
||||
* Date() IsWeekend() IsHarbourFinished() IsApocalypse()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@ void PushInteger( int iNumber );
|
||||
void PushLong( long lNumber );
|
||||
void PushDouble( double dNumber, WORD wDec );
|
||||
void PushString( char * szText, WORD wLength ); /* pushes a string on to the stack */
|
||||
void PushLogical( int iTrueFalse ); /* pushes a logical value onto the stack */
|
||||
void PushSymbol( PSYMBOL );
|
||||
void Do( WORD wParams ); /* invokes the virtual machine */
|
||||
void Function( WORD wParams ); /* invokes the virtual machine */
|
||||
|
||||
@@ -16,21 +16,27 @@
|
||||
#include "errorapi.h"
|
||||
|
||||
#define _errNew hb_errNew
|
||||
#define _errGetDescription hb_errGetDescription
|
||||
#define _errPutDescription hb_errPutDescription
|
||||
#define _errGetFileName hb_errGetFileName
|
||||
#define _errPutFileNaem hb_errPutFileName
|
||||
#define _errGetGenCode hb_errGetGenCode
|
||||
#define _errPutGenCode hb_errPutGenCode
|
||||
#define _errGetOperation hb_errGetOperation
|
||||
#define _errPutOperation hb_errPutOperation
|
||||
#define _errGetOsCode hb_errGetOsCode
|
||||
#define _errPutOsCode hb_errPutOsCode
|
||||
#define _errPutSeverity hb_errPutSeverity
|
||||
#define _errPutSubCode hb_errPutSubCode
|
||||
#define _errPutSubSystem hb_errPutSubSystem
|
||||
#define _errPutTries hb_errPutTries
|
||||
#define _errLaunch hb_errLaunch
|
||||
#define _errRelease hb_errRelease
|
||||
|
||||
#endif
|
||||
#define _errGetSeverity hb_errGetSeverity
|
||||
#define _errPutSeverity hb_errPutSeverity
|
||||
#define _errGetGenCode hb_errGetGenCode
|
||||
#define _errPutGenCode hb_errPutGenCode
|
||||
#define _errGetOsCode hb_errGetOsCode
|
||||
#define _errPutOsCode hb_errPutOsCode
|
||||
#define _errGetFlags hb_errGetFlags
|
||||
#define _errPutFlags hb_errPutFlags
|
||||
#define _errGetTries hb_errGetTries
|
||||
#define _errPutTries hb_errPutTries
|
||||
#define _errGetSubCode hb_errGetSubCode
|
||||
#define _errPutSubCode hb_errPutSubCode
|
||||
#define _errGetSubSystem hb_errGetSubSystem
|
||||
#define _errPutSubSystem hb_errPutSubSystem
|
||||
#define _errGetDescription hb_errGetDescription
|
||||
#define _errPutDescription hb_errPutDescription
|
||||
#define _errGetOperation hb_errGetOperation
|
||||
#define _errPutOperation hb_errPutOperation
|
||||
#define _errGetFileName hb_errGetFileName
|
||||
#define _errPutFileNaem hb_errPutFileName
|
||||
|
||||
|
||||
@@ -1,54 +1,102 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
/* $Id$
|
||||
|
||||
Harbour Project source code
|
||||
|
||||
This file contains the Harbour internal error handling definitions
|
||||
|
||||
Copyright (C) 1999 ?
|
||||
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 of the License, 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 program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
V 1.0 1999-04-25 - Initial posting.
|
||||
*/
|
||||
|
||||
#ifndef ERRORAPI_H_
|
||||
#define ERRORAPI_H_
|
||||
|
||||
/*
|
||||
* +
|
||||
* Harbour project
|
||||
*
|
||||
* 99.04.25 initial posting.
|
||||
* compatible
|
||||
*-
|
||||
*/
|
||||
|
||||
#include <extend.h>
|
||||
#include "error.ch"
|
||||
|
||||
/* Error codes (returned from hb_errLaunch()) */
|
||||
|
||||
/*
|
||||
* error flag definations
|
||||
*/
|
||||
#define E_BREAK 0xFFFF
|
||||
#define E_RETRY 1
|
||||
#define E_DEFAULT 0
|
||||
|
||||
#define EF_CANRETRY 1
|
||||
#define EF_CANDEFAULT 4
|
||||
/* Error flags */
|
||||
|
||||
/*
|
||||
* error codes (returned from _errLaunch())
|
||||
*/
|
||||
#define EF_NONE 0
|
||||
#define EF_CANRETRY 1
|
||||
#define EF_CANSUBSTITUTE 2
|
||||
#define EF_CANDEFAULT 4
|
||||
|
||||
#define E_BREAK 0xFFFF
|
||||
#define E_RETRY 1
|
||||
#define E_DEFAULT 0
|
||||
/* oError:Severity */
|
||||
|
||||
/* ... defined in extend.ch */
|
||||
|
||||
/* oError:SubSystem (commonly used) */
|
||||
|
||||
#define HB_ERR_SS_BASE "BASE"
|
||||
#define HB_ERR_SS_TERMINAL "TERM"
|
||||
#define HB_ERR_SS_DBCMD "DBCMD"
|
||||
|
||||
/* oError:GenCode */
|
||||
|
||||
/* ... defined in extend.ch */
|
||||
|
||||
/* Internal error numbers */
|
||||
|
||||
#define HB_ERR_IE_NOT_ENOUGH_MEM 1024
|
||||
#define HB_ERR_IE_ERR_RECOV_FAIL 1025
|
||||
#define HB_ERR_IE_UNREC_ERROR 1026
|
||||
#define HB_ERR_IE_GENERIC 1027
|
||||
|
||||
/* Standard API */
|
||||
|
||||
PHB_ITEM hb_errNew( void );
|
||||
char * hb_errGetDescription( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutDescription( PHB_ITEM pError, char * szDescription );
|
||||
char * hb_errGetFileName( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutFileName( PHB_ITEM pError, char * szFileName );
|
||||
USHORT hb_errGetGenCode( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutGenCode( PHB_ITEM pError, USHORT uiGenCode );
|
||||
char * hb_errGetOperation( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutOperation( PHB_ITEM pError, char * szOperation );
|
||||
USHORT hb_errGetOsCode( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode );
|
||||
PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity );
|
||||
PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode );
|
||||
PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem );
|
||||
PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries );
|
||||
WORD hb_errLaunch( PHB_ITEM pError );
|
||||
void hb_errRelease( PHB_ITEM pError );
|
||||
|
||||
USHORT hb_errGetSeverity( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity );
|
||||
USHORT hb_errGetGenCode( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutGenCode( PHB_ITEM pError, USHORT uiGenCode );
|
||||
USHORT hb_errGetOsCode( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode );
|
||||
USHORT hb_errGetFlags( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutFlags( PHB_ITEM pError, USHORT uiFlags );
|
||||
USHORT hb_errGetTries( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries );
|
||||
USHORT hb_errGetSubCode( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode );
|
||||
char * hb_errGetSubSystem( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem );
|
||||
char * hb_errGetDescription( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutDescription( PHB_ITEM pError, char * szDescription );
|
||||
char * hb_errGetOperation( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutOperation( PHB_ITEM pError, char * szOperation );
|
||||
char * hb_errGetFileName( PHB_ITEM pError );
|
||||
PHB_ITEM hb_errPutFileName( PHB_ITEM pError, char * szFileName );
|
||||
|
||||
/* Error launchers */
|
||||
|
||||
void hb_errorRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char* szDescription, char* szOperation );
|
||||
/* TODO: Enable this:
|
||||
void hb_errorInternal( ULONG ulCode );
|
||||
*/
|
||||
|
||||
#endif /* ERRORAPI_H_ */
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
#define ERR_SYNTAX2 20
|
||||
#define ERR_INCOMPLETE_STMT 21
|
||||
|
||||
#define WARN_AMBIGUOUS_VAR 1
|
||||
#define WARN_VAR_NOT_USED 2
|
||||
#define WARN_BLOCKVAR_NOT_USED 3
|
||||
#define WARN_ASSIGN_TYPE 4
|
||||
#define WARN_ASSIGN_SUSPECTED 5
|
||||
#define WARN_AMBIGUOUS_VAR 1
|
||||
#define WARN_VAR_NOT_USED 2
|
||||
#define WARN_BLOCKVAR_NOT_USED 3
|
||||
#define WARN_ASSIGN_TYPE 4
|
||||
#define WARN_ASSIGN_SUSPECTED 5
|
||||
|
||||
void GenError( int, char*, char * ); /* generic parsing error management function */
|
||||
void GenWarning( int, char*, char * ); /* generic parsing warning management function */
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
*
|
||||
* By default it is disabled (symbol is not defined)
|
||||
*/
|
||||
#define USE_GTAPI
|
||||
/*#define USE_GTAPI*/
|
||||
|
||||
/* Operating system specific definitions
|
||||
*/
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
#include <itemapi.h>
|
||||
#include <errorapi.h>
|
||||
|
||||
/* error codes ( returned from hb_errLaunch() ) */
|
||||
|
||||
|
||||
extern HB_ITEM errorBlock;
|
||||
extern STACK stack;
|
||||
extern SYMBOL symEval;
|
||||
@@ -27,6 +24,21 @@ PHB_ITEM hb_errNew( void )
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
WORD hb_errLaunch( PHB_ITEM pError )
|
||||
{
|
||||
PushSymbol( &symEval );
|
||||
Push( &errorBlock );
|
||||
Push( pError );
|
||||
Do( 1 );
|
||||
|
||||
return stack.Return.value.iNumber; /* TODO: hb_parnl( -1 ) */
|
||||
}
|
||||
|
||||
void hb_errRelease( PHB_ITEM pError )
|
||||
{
|
||||
hb_itemRelease( pError );
|
||||
}
|
||||
|
||||
char * hb_errGetDescription( PHB_ITEM pError )
|
||||
{
|
||||
PushSymbol( GetDynSym( "DESCRIPTION" )->pSymbol );
|
||||
@@ -113,6 +125,14 @@ PHB_ITEM hb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode )
|
||||
return pError;
|
||||
}
|
||||
|
||||
USHORT hb_errGetSeverity( PHB_ITEM pError )
|
||||
{
|
||||
PushSymbol( GetDynSym( "SEVERITY" )->pSymbol );
|
||||
Push( pError );
|
||||
Do( 0 );
|
||||
return stack.Return.value.iNumber;
|
||||
}
|
||||
|
||||
PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity )
|
||||
{
|
||||
PushSymbol( GetDynSym( "_SEVERITY" )->pSymbol );
|
||||
@@ -122,6 +142,14 @@ PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity )
|
||||
return pError;
|
||||
}
|
||||
|
||||
USHORT hb_errGetSubCode( PHB_ITEM pError )
|
||||
{
|
||||
PushSymbol( GetDynSym( "SUBCODE" )->pSymbol );
|
||||
Push( pError );
|
||||
Do( 0 );
|
||||
return stack.Return.value.iNumber;
|
||||
}
|
||||
|
||||
PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode )
|
||||
{
|
||||
PushSymbol( GetDynSym( "_SUBCODE" )->pSymbol );
|
||||
@@ -131,6 +159,14 @@ PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode )
|
||||
return pError;
|
||||
}
|
||||
|
||||
char * hb_errGetSubSystem( PHB_ITEM pError )
|
||||
{
|
||||
PushSymbol( GetDynSym( "SUBSYSTEM" )->pSymbol );
|
||||
Push( pError );
|
||||
Do( 0 );
|
||||
return stack.Return.value.szText;
|
||||
}
|
||||
|
||||
PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem )
|
||||
{
|
||||
PushSymbol( GetDynSym( "_SUBSYSTEM" )->pSymbol );
|
||||
@@ -140,6 +176,14 @@ PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, char * szSubSystem )
|
||||
return pError;
|
||||
}
|
||||
|
||||
USHORT hb_errGetTries( PHB_ITEM pError )
|
||||
{
|
||||
PushSymbol( GetDynSym( "TRIES" )->pSymbol );
|
||||
Push( pError );
|
||||
Do( 0 );
|
||||
return stack.Return.value.iNumber;
|
||||
}
|
||||
|
||||
PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries )
|
||||
{
|
||||
PushSymbol( GetDynSym( "_TRIES" )->pSymbol );
|
||||
@@ -149,18 +193,79 @@ PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries )
|
||||
return pError;
|
||||
}
|
||||
|
||||
WORD hb_errLaunch( PHB_ITEM pError )
|
||||
USHORT hb_errGetFlags( PHB_ITEM pError )
|
||||
{
|
||||
PushSymbol( &symEval );
|
||||
Push( &errorBlock );
|
||||
USHORT uiFlags = EF_NONE;
|
||||
|
||||
/* ; */
|
||||
|
||||
PushSymbol( GetDynSym( "CANRETRY" )->pSymbol );
|
||||
Push( pError );
|
||||
Do( 0 );
|
||||
|
||||
if (stack.Return.value.iLogical) uiFlags |= EF_CANRETRY;
|
||||
|
||||
/* ; */
|
||||
|
||||
PushSymbol( GetDynSym( "CANSUBSTITUTE" )->pSymbol );
|
||||
Push( pError );
|
||||
Do( 0 );
|
||||
|
||||
if (stack.Return.value.iLogical) uiFlags |= EF_CANSUBSTITUTE;
|
||||
|
||||
/* ; */
|
||||
|
||||
PushSymbol( GetDynSym( "CANDEFAULT" )->pSymbol );
|
||||
Push( pError );
|
||||
Do( 0 );
|
||||
|
||||
if (stack.Return.value.iLogical) uiFlags |= EF_CANDEFAULT;
|
||||
|
||||
/* ; */
|
||||
|
||||
return uiFlags;
|
||||
}
|
||||
|
||||
PHB_ITEM hb_errPutFlags( PHB_ITEM pError, USHORT uiFlags )
|
||||
{
|
||||
PushSymbol( GetDynSym( "_CANRETRY" )->pSymbol );
|
||||
Push( pError );
|
||||
PushLogical( uiFlags & EF_CANRETRY );
|
||||
Do( 1 );
|
||||
|
||||
return stack.Return.value.iNumber; /* TODO: hb_parnl( -1 ) */
|
||||
/* ; */
|
||||
|
||||
PushSymbol( GetDynSym( "_CANSUBSTITUTE" )->pSymbol );
|
||||
Push( pError );
|
||||
PushLogical( uiFlags & EF_CANSUBSTITUTE );
|
||||
Do( 1 );
|
||||
|
||||
/* ; */
|
||||
|
||||
PushSymbol( GetDynSym( "_CANDEFAULT" )->pSymbol );
|
||||
Push( pError );
|
||||
PushLogical( uiFlags & EF_CANDEFAULT );
|
||||
Do( 1 );
|
||||
|
||||
/* ; */
|
||||
|
||||
return pError;
|
||||
}
|
||||
|
||||
void hb_errRelease( PHB_ITEM pError )
|
||||
/* Wrappers for hb_errLaunch() */
|
||||
|
||||
void hb_errorRT_BASE( ULONG ulGenCode, ULONG ulSubCode, char* szDescription, char* szOperation )
|
||||
{
|
||||
hb_itemRelease( pError );
|
||||
PHB_ITEM pError = hb_errNew();
|
||||
|
||||
hb_errPutSeverity( pError, ES_ERROR );
|
||||
hb_errPutSubSystem( pError, HB_ERR_SS_BASE );
|
||||
hb_errPutGenCode( pError, ulGenCode );
|
||||
hb_errPutSubCode( pError, ulSubCode );
|
||||
hb_errPutDescription( pError, szDescription );
|
||||
hb_errPutOperation( pError, szOperation );
|
||||
hb_errLaunch( pError );
|
||||
|
||||
hb_errRelease( pError );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user