H Files

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  
c:\harbour\include
c:\harbour\include\clipdefs.h
/*
 * $Id: clipdefs.h 9191 2008-08-19 13:11:22Z vszakats $
 */

/*
 * Harbour Project source code:
 * Compatibility header file for CA-Cl*pper base definitions
 *
 * Copyright 1999-2001 Viktor Szakats 
 * 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.
 *
 */

/* DON'T USE THIS FILE FOR NEW HARBOUR C CODE */

/* This file is provided to support some level of */
/* Harbour compatibility for old Clipper C extension code */

#ifndef _CLIPDEFS_H
#define _CLIPDEFS_H

#include "hbapi.h"

/* Old types */

typedef BYTE    byte;
typedef USHORT  quant;
typedef BOOL    Boolean;

/* New types */

typedef BYTE *  BYTEP;
typedef BYTEP   BYTEPP;
#if !( defined( HB_OS_OS2 ) && defined( HB_DONT_DEFINE_BASIC_TYPES ) )
typedef BYTEP   PBYTE;
#endif

typedef SHORT * SHORTP;
#if !( defined( HB_OS_OS2 ) && defined( HB_DONT_DEFINE_BASIC_TYPES ) )
typedef SHORTP  PSHORT;
#endif

typedef USHORT * USHORTP;
#if !( defined( HB_OS_OS2 ) && defined( HB_DONT_DEFINE_BASIC_TYPES ) )
typedef USHORTP PUSHORT;
#endif

#if !(defined(HB_OS_WIN_32) && defined(HB_OS_WIN_32_USED))
   typedef unsigned int WORD;
   typedef WORD *  WORDP;
   typedef WORDP   PWORD;
#endif

typedef LONG *  LONGP;
#if !( defined( HB_OS_OS2 ) && defined( HB_DONT_DEFINE_BASIC_TYPES ) )
typedef LONGP   PLONG;
#endif

typedef ULONG * ULONGP;
#if !( defined( HB_OS_OS2 ) && defined( HB_DONT_DEFINE_BASIC_TYPES ) )
typedef ULONGP  PULONG;
#endif

typedef unsigned long DWORD;
typedef DWORD * DWORDP;
typedef DWORDP  PDWORD;

typedef BOOL *  BOOLP;
#if !( defined( HB_OS_OS2 ) && defined( HB_DONT_DEFINE_BASIC_TYPES ) )
typedef BOOLP   PBOOL;
#endif

typedef void *  NEARP;
typedef NEARP * NEARPP;

#if !(defined(HB_OS_WIN_32) && defined(HB_OS_WIN_32_USED))
   typedef void *      FARP;
   typedef FARP *      FARPP;
   typedef FARP        VOIDP;
#if !( defined( HB_OS_OS2 ) && defined( HB_DONT_DEFINE_BASIC_TYPES ) )
   typedef FARP        PVOID;
#endif
   typedef HB_VMHANDLE HANDLE;
#endif

typedef ERRCODE IHELP;
typedef ERRCODE ICODE;

/* default func ptr -- USHORT return, USHORT param */
typedef USHORT  ( * FUNCP )( USHORT param, ...);
typedef FUNCP * FUNCPP;

#define HIDE    static
#define CLIPPER HARBOUR

#ifndef NIL
   #define NIL     '\0'
#endif
#ifndef NULL
   #define NULL    0
#endif

#endif /* _CLIPDEFS_H */
c:\harbour\include\extend.h
/*
 * $Id: extend.h 9191 2008-08-19 13:11:22Z vszakats $
 */

/*
 * Harbour Project source code:
 * Compatibility header file for CA-Cl*pper Extend System
 *
 * Copyright 1999-2001 Viktor Szakats 
 * 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.
 *
 */

/* DON'T USE THIS FILE FOR NEW HARBOUR C CODE */

/* This file is provided to support some level of */
/* Harbour compatibility for old Clipper C extension code */

#ifndef HB_EXTEND_H_
#define HB_EXTEND_H_

#include "hbapi.h"

/* Please leave these at the bottom of this file */

#include "extend.api"
#include "fm.api"

#endif /* HB_EXTEND_H_ */

c:\harbour\include\hbapi.h
/*
 * $Id: hbapi.h 9454 2008-09-21 21:04:47Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Extend API, Array API, misc API and base declarations
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

/* TOFIX: There are several things in this file which are not part of the
          standard Harbour API, in other words these things are not
          guaranteed to remain unchanged. To avoid confusion these should be
          moved to somewhere else (like hbrtl.h). [vszakats] */

#ifndef HB_APIEXT_H_
#define HB_APIEXT_H_

#include "hbvmpub.h"

HB_EXTERN_BEGIN


/* this definition signals that number of decimal places for double value
 * was not specified at compile time (the value is a result of optimization
 * performed by the compiler)
 */
#define HB_DEFAULT_WIDTH     255
#define HB_DEFAULT_DECIMALS  255


/* items types and type checking macros */
#define HB_IT_NIL       ( ( HB_TYPE ) 0x00000 )
#define HB_IT_POINTER   ( ( HB_TYPE ) 0x00001 )
#define HB_IT_INTEGER   ( ( HB_TYPE ) 0x00002 )
#define HB_IT_HASH      ( ( HB_TYPE ) 0x00004 )
#define HB_IT_LONG      ( ( HB_TYPE ) 0x00008 )
#define HB_IT_DOUBLE    ( ( HB_TYPE ) 0x00010 )
#define HB_IT_DATE      ( ( HB_TYPE ) 0x00020 )
#define HB_IT_LOGICAL   ( ( HB_TYPE ) 0x00080 )
#define HB_IT_SYMBOL    ( ( HB_TYPE ) 0x00100 )
#define HB_IT_ALIAS     ( ( HB_TYPE ) 0x00200 )
#define HB_IT_STRING    ( ( HB_TYPE ) 0x00400 )
#define HB_IT_MEMOFLAG  ( ( HB_TYPE ) 0x00800 )
#define HB_IT_MEMO      ( HB_IT_MEMOFLAG | HB_IT_STRING )
#define HB_IT_BLOCK     ( ( HB_TYPE ) 0x01000 )
#define HB_IT_BYREF     ( ( HB_TYPE ) 0x02000 )
#define HB_IT_MEMVAR    ( ( HB_TYPE ) 0x04000 )
#define HB_IT_ARRAY     ( ( HB_TYPE ) 0x08000 )
#define HB_IT_ENUM      ( ( HB_TYPE ) 0x10000 )
#define HB_IT_EXTREF    ( ( HB_TYPE ) 0x20000 )
#define HB_IT_DEFAULT   ( ( HB_TYPE ) 0x40000 )
#define HB_IT_OBJECT    HB_IT_ARRAY
#define HB_IT_NUMERIC   ( ( HB_TYPE ) ( HB_IT_INTEGER | HB_IT_LONG | HB_IT_DOUBLE ) )
#define HB_IT_NUMINT    ( ( HB_TYPE ) ( HB_IT_INTEGER | HB_IT_LONG ) )
#define HB_IT_ANY       ( ( HB_TYPE ) 0xFFFFFFFF )
#define HB_IT_COMPLEX   ( ( HB_TYPE ) ( HB_IT_BLOCK | HB_IT_ARRAY | HB_IT_HASH | HB_IT_POINTER | /* HB_IT_MEMVAR | HB_IT_ENUM | HB_IT_EXTREF |*/ HB_IT_BYREF | HB_IT_STRING ) )
#define HB_IT_GCITEM    ( ( HB_TYPE ) ( HB_IT_BLOCK | HB_IT_ARRAY | HB_IT_HASH | HB_IT_POINTER | HB_IT_BYREF ) )
#define HB_IT_HASHKEY   ( ( HB_TYPE ) ( HB_IT_INTEGER | HB_IT_LONG | HB_IT_DOUBLE | HB_IT_DATE | HB_IT_STRING | HB_IT_POINTER ) )

#if 0

/*
 * In Harbour VM HB_IT_BYREF is never ORed with item type. It can be used
 * as stand alone type for locals and statics passed by reference or with
 * HB_IT_MEMVAR for memvars passed by reference so this macro is less usable.
 * only the hb_parinfo() function can return HB_TYPE as HB_IT_BYREF ORed
 * with real type but this value is never set as item type.
 */

#define HB_IS_OF_TYPE( p, t ) ( ( HB_ITEM_TYPE( p ) & ~HB_IT_BYREF ) == t )

/*
 * These macros are slower but can be usable in debugging some code.
 * They are a little bit more safe in buggy code but they can
 * also hide bugs which should be exploited as soon as possible to
 * know that sth is wrong and has to be fixed.
 * the version below which check only chosen bits allow compiler to
 * use some optimizations if used CPU supports it. F.e. on standard
 * x86 machines they can safe few CPU cycles. [druzus]
 */

#define HB_IS_NIL( p )        HB_IS_OF_TYPE( p, HB_IT_NIL )
#define HB_IS_ARRAY( p )      HB_IS_OF_TYPE( p, HB_IT_ARRAY )
#define HB_IS_BLOCK( p )      HB_IS_OF_TYPE( p, HB_IT_BLOCK )
#define HB_IS_DATE( p )       HB_IS_OF_TYPE( p, HB_IT_DATE )
#define HB_IS_DOUBLE( p )     HB_IS_OF_TYPE( p, HB_IT_DOUBLE )
#define HB_IS_INTEGER( p )    HB_IS_OF_TYPE( p, HB_IT_INTEGER )
#define HB_IS_LOGICAL( p )    HB_IS_OF_TYPE( p, HB_IT_LOGICAL )
#define HB_IS_LONG( p )       HB_IS_OF_TYPE( p, HB_IT_LONG )
#define HB_IS_SYMBOL( p )     HB_IS_OF_TYPE( p, HB_IT_SYMBOL )
#define HB_IS_POINTER( p )    HB_IS_OF_TYPE( p, HB_IT_POINTER )
#define HB_IS_HASH( p )       HB_IS_OF_TYPE( p, HB_IT_HASH )
#define HB_IS_MEMVAR( p )     HB_IS_OF_TYPE( p, HB_IT_MEMVAR )
#define HB_IS_MEMO( p )       HB_IS_OF_TYPE( p, HB_IT_MEMO )
#define HB_IS_ENUM( p )       HB_IS_OF_TYPE( p, HB_IT_ENUM )
#define HB_IS_EXTREF( p )     HB_IS_OF_TYPE( p, HB_IT_EXTREF )
#define HB_IS_STRING( p )     ( ( HB_ITEM_TYPE( p ) & ~( HB_IT_BYREF | HB_IT_MEMOFLAG ) ) == HB_IT_STRING )
#define HB_IS_BYREF( p )      ( ( HB_ITEM_TYPE( p ) & HB_IT_BYREF ) != 0 )
#define HB_IS_NUMERIC( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_NUMERIC ) != 0 )
#define HB_IS_NUMINT( p )     ( ( HB_ITEM_TYPE( p ) & HB_IT_NUMINT ) != 0 )
#define HB_IS_COMPLEX( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_COMPLEX ) != 0 )
#define HB_IS_GCITEM( p )     ( ( HB_ITEM_TYPE( p ) & HB_IT_GCITEM ) != 0 )
#define HB_IS_BADITEM( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_COMPLEX ) != 0 && ( HB_ITEM_TYPE( p ) & ~( HB_IT_COMPLEX | HB_IT_MEMOFLAG ) ) != 0 )
#define HB_IS_HASHKEY( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_HASHKEY ) != 0 )
#define HB_IS_OBJECT( p )     ( HB_IS_ARRAY( p ) && HB_ARRAY_OBJ( p ) )
#define HB_IS_NUMBER( p )     HB_IS_NUMERIC( p )

#elif 0

/*
 * these macros illustrates possible HB_TYPE bit combinations in HVM,
 * they are the safest one in buggy code which may produce wrong item
 * signatures but also they can be slower on some machines
 */
#define HB_IS_NIL( p )        ( HB_ITEM_TYPE( p ) == HB_IT_NIL )
#define HB_IS_ARRAY( p )      ( HB_ITEM_TYPE( p ) == HB_IT_ARRAY )
#define HB_IS_BLOCK( p )      ( HB_ITEM_TYPE( p ) == HB_IT_BLOCK )
#define HB_IS_DATE( p )       ( HB_ITEM_TYPE( p ) == HB_IT_DATE )
#define HB_IS_DOUBLE( p )     ( HB_ITEM_TYPE( p ) == HB_IT_DOUBLE )
#define HB_IS_INTEGER( p )    ( HB_ITEM_TYPE( p ) == HB_IT_INTEGER )
#define HB_IS_LOGICAL( p )    ( HB_ITEM_TYPE( p ) == HB_IT_LOGICAL )
#define HB_IS_LONG( p )       ( HB_ITEM_TYPE( p ) == HB_IT_LONG )
#define HB_IS_SYMBOL( p )     ( HB_ITEM_TYPE( p ) == HB_IT_SYMBOL )
#define HB_IS_POINTER( p )    ( HB_ITEM_TYPE( p ) == HB_IT_POINTER )
#define HB_IS_HASH( p )       ( HB_ITEM_TYPE( p ) == HB_IT_HASH )
#define HB_IS_MEMO( p )       ( HB_ITEM_TYPE( p ) == HB_IT_MEMO )
#define HB_IS_MEMVAR( p )     ( HB_ITEM_TYPE( p ) == ( HB_IT_MEMVAR | HB_IT_BYREF ) )
#define HB_IS_ENUM( p )       ( HB_ITEM_TYPE( p ) == ( HB_IT_ENUM | HB_IT_BYREF ) )
#define HB_IS_EXTREF( p )     ( HB_ITEM_TYPE( p ) == ( HB_IT_EXTREF | HB_IT_BYREF ) )
#define HB_IS_STRING( p )     ( ( HB_ITEM_TYPE( p ) & ~HB_IT_MEMOFLAG ) == HB_IT_STRING )
#define HB_IS_BYREF( p )      ( ( HB_ITEM_TYPE( p ) & ~HB_IT_MEMVAR ) == HB_IT_BYREF )
#define HB_IS_NUMERIC( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_NUMERIC ) != 0 )
#define HB_IS_NUMINT( p )     ( ( HB_ITEM_TYPE( p ) & HB_IT_NUMINT ) != 0 )
#define HB_IS_COMPLEX( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_COMPLEX ) != 0 )
#define HB_IS_GCITEM( p )     ( ( HB_ITEM_TYPE( p ) & HB_IT_GCITEM ) != 0 )
#define HB_IS_HASHKEY( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_HASHKEY ) != 0 )
#define HB_IS_BADITEM( p )    ( ( HB_ITEM_TYPE( p ) & HB_IT_COMPLEX ) != 0 && ( HB_ITEM_TYPE( p ) & ~( HB_IT_COMPLEX | HB_IT_MEMOFLAG ) ) != 0 )
#define HB_IS_OBJECT( p )     ( HB_IS_ARRAY( p ) && HB_ARRAY_OBJ( p ) )
#define HB_IS_NUMBER( p )     HB_IS_NUMERIC( p )

#else

/*
 * these ones are can be the most efficiently optimized on some CPUs
 */
#define HB_IS_NIL( p )        ( HB_ITEM_TYPE( p ) == HB_IT_NIL )
#define HB_IS_ARRAY( p )      ( ( HB_ITEM_TYPERAW( p ) & HB_IT_ARRAY ) != 0 )
#define HB_IS_BLOCK( p )      ( ( HB_ITEM_TYPERAW( p ) & HB_IT_BLOCK ) != 0 )
#define HB_IS_DATE( p )       ( ( HB_ITEM_TYPERAW( p ) & HB_IT_DATE ) != 0 )
#define HB_IS_DOUBLE( p )     ( ( HB_ITEM_TYPERAW( p ) & HB_IT_DOUBLE ) != 0 )
#define HB_IS_INTEGER( p )    ( ( HB_ITEM_TYPERAW( p ) & HB_IT_INTEGER ) != 0 )
#define HB_IS_LOGICAL( p )    ( ( HB_ITEM_TYPERAW( p ) & HB_IT_LOGICAL ) != 0 )
#define HB_IS_LONG( p )       ( ( HB_ITEM_TYPERAW( p ) & HB_IT_LONG ) != 0 )
#define HB_IS_SYMBOL( p )     ( ( HB_ITEM_TYPERAW( p ) & HB_IT_SYMBOL ) != 0 )
#define HB_IS_POINTER( p )    ( ( HB_ITEM_TYPERAW( p ) & HB_IT_POINTER ) != 0 )
#define HB_IS_HASH( p )       ( ( HB_ITEM_TYPERAW( p ) & HB_IT_HASH ) != 0 )
#define HB_IS_MEMO( p )       ( ( HB_ITEM_TYPERAW( p ) & HB_IT_MEMOFLAG ) != 0 )
#define HB_IS_STRING( p )     ( ( HB_ITEM_TYPERAW( p ) & HB_IT_STRING ) != 0 )
#define HB_IS_MEMVAR( p )     ( ( HB_ITEM_TYPERAW( p ) & HB_IT_MEMVAR ) != 0 )
#define HB_IS_ENUM( p )       ( ( HB_ITEM_TYPERAW( p ) & HB_IT_ENUM ) != 0 )
#define HB_IS_EXTREF( p )     ( ( HB_ITEM_TYPERAW( p ) & HB_IT_EXTREF ) != 0 )
#define HB_IS_BYREF( p )      ( ( HB_ITEM_TYPERAW( p ) & HB_IT_BYREF ) != 0 )
#define HB_IS_NUMERIC( p )    ( ( HB_ITEM_TYPERAW( p ) & HB_IT_NUMERIC ) != 0 )
#define HB_IS_NUMINT( p )     ( ( HB_ITEM_TYPERAW( p ) & HB_IT_NUMINT ) != 0 )
#define HB_IS_COMPLEX( p )    ( ( HB_ITEM_TYPERAW( p ) & HB_IT_COMPLEX ) != 0 )
#define HB_IS_GCITEM( p )     ( ( HB_ITEM_TYPERAW( p ) & HB_IT_GCITEM ) != 0 )
#define HB_IS_HASHKEY( p )    ( ( HB_ITEM_TYPERAW( p ) & HB_IT_HASHKEY ) != 0 )
#define HB_IS_BADITEM( p )    ( ( HB_ITEM_TYPERAW( p ) & HB_IT_COMPLEX ) != 0 && ( HB_ITEM_TYPERAW( p ) & ~( HB_IT_COMPLEX | HB_IT_MEMOFLAG | HB_IT_DEFAULT ) ) != 0 )
#define HB_IS_OBJECT( p )     ( HB_IS_ARRAY( p ) && HB_ARRAY_OBJ( p ) )
#define HB_IS_NUMBER( p )     HB_IS_NUMERIC( p )

#endif


#define ISNIL( n )         ( hb_param( n, HB_IT_ANY ) == NULL || HB_IS_NIL( hb_param( n, HB_IT_ANY ) ) ) /* NOTE: Intentionally using a different method */
#define ISCHAR( n )        ( hb_param( n, HB_IT_STRING ) != NULL )
#define ISNUM( n )         ( hb_param( n, HB_IT_NUMERIC ) != NULL )
#define ISLOG( n )         ( hb_param( n, HB_IT_LOGICAL ) != NULL )
#define ISDATE( n )        ( hb_param( n, HB_IT_DATE ) != NULL )
#define ISMEMO( n )        ( hb_param( n, HB_IT_MEMO ) != NULL )
#define ISBYREF( n )       ( ( hb_parinfo( n ) & HB_IT_BYREF ) != 0 ) /* NOTE: Intentionally using a different method */
#define ISARRAY( n )       ( hb_param( n, HB_IT_ARRAY ) != NULL )
#define ISOBJECT( n )      ( hb_extIsObject( n ) )
#define ISBLOCK( n )       ( hb_param( n, HB_IT_BLOCK ) != NULL )    /* Not available in CA-Cl*pper. */
#define ISPOINTER( n )     ( hb_param( n, HB_IT_POINTER ) != NULL )  /* Not available in CA-Cl*pper. */
#define ISHASH( n )        ( hb_param( n, HB_IT_HASH ) != NULL )     /* Not available in CA-Cl*pper. */
#define ISSYMBOL( n )      ( hb_param( n, HB_IT_SYMBOL ) != NULL )   /* Not available in CA-Cl*pper. */


#ifdef _HB_API_INTERNAL_

/* forward declarations */
struct _HB_CODEBLOCK;
struct _HB_BASEARRAY;
struct _HB_BASEHASH;
struct _HB_ITEM;
struct _HB_EXTREF;

typedef struct _HB_STACK_STATE
{
   LONG     lBaseItem;        /* stack base offset of previous func/proc */
   LONG     lStatics;         /* statics offset of previous func/proc */
   ULONG    ulPrivateBase;    /* memvars base offset of previous func/proc */
   USHORT   uiClass;          /* class when message is sent */
   USHORT   uiMethod;         /* number of class method */
   USHORT   uiLineNo;         /* current line number */
} HB_STACK_STATE, * PHB_STACK_STATE; /* used to save/restore stack state in hb_vmDo)_ */


/* Internal structures that holds data */
struct hb_struArray
{
   struct _HB_BASEARRAY * value;
};

struct hb_struHash
{
   struct _HB_BASEHASH * value;
};

struct hb_struBlock
{
   struct _HB_CODEBLOCK * value;
   USHORT paramcnt;
   USHORT lineno;
   USHORT hclass;
   USHORT method;
};

struct hb_struDate
{
   long value;
};

struct hb_struDouble
{
   USHORT length;
   USHORT decimal;
   double value;
};

struct hb_struInteger
{
   USHORT length;
   int value;
};

struct hb_struLogical
{
   BOOL value;
};

struct hb_struLong
{
   USHORT length;
   HB_LONG value;
};

struct hb_struPointer
{
   void * value;
   BOOL collect;
   BOOL single;
};

struct hb_struMemvar
{
   struct _HB_ITEM * value;
};

struct hb_struRefer
{
   union {
      struct _HB_BASEARRAY * array;       /* array (statics and array item references) */
      struct _HB_CODEBLOCK * block;       /* codeblock */
      struct _HB_ITEM * itemPtr;          /* item pointer  */
      struct _HB_ITEM ** *itemsbasePtr;   /* local variables */
   } BasePtr;
   LONG offset;                           /* 0 for static variables */
   LONG value;
};

struct hb_struEnum
{
   struct _HB_ITEM * basePtr;             /* base item pointer */
   struct _HB_ITEM * valuePtr;            /* value item pointer */
   LONG offset;
};

struct hb_struExtRef
{
   void * value;                          /* value item pointer */
   const struct _HB_EXTREF * func;        /* extended reference functions */
};

struct hb_struString
{
   ULONG length;
   ULONG allocated;     /* size of memory block allocated for string value, 0 for static strings */
   char * value;
};

struct hb_struSymbol
{
   PHB_SYMB        value;
   PHB_STACK_STATE stackstate;      /* function stack state */
   USHORT          paramcnt;        /* number of passed parameters in function call */
   USHORT          paramdeclcnt;    /* number of declared parameters in function definition */
};

struct hb_struRecover
{
   ULONG    recover;    /* address of recover code */
   ULONG    base;       /* previous recover base */
   USHORT   flags;      /* previous recovery state and recover type */
   USHORT   request;    /* requested action */
};

/* items hold at the virtual machine stack */
typedef struct _HB_ITEM
{
   HB_TYPE type;
   union
   {
      struct hb_struArray     asArray;
      struct hb_struBlock     asBlock;
      struct hb_struDate      asDate;
      struct hb_struDouble    asDouble;
      struct hb_struInteger   asInteger;
      struct hb_struLogical   asLogical;
      struct hb_struLong      asLong;
      struct hb_struPointer   asPointer;
      struct hb_struHash      asHash;
      struct hb_struMemvar    asMemvar;
      struct hb_struRefer     asRefer;
      struct hb_struEnum      asEnum;
      struct hb_struExtRef    asExtRef;
      struct hb_struString    asString;
      struct hb_struSymbol    asSymbol;
      struct hb_struRecover   asRecover;
   } item;
} HB_ITEM, * PHB_ITEM, * HB_ITEM_PTR;

/* internal structure for arrays */
typedef struct _HB_BASEARRAY
{
   PHB_ITEM    pItems;       /* pointer to the array items */
   ULONG       ulLen;        /* number of items in the array */
   USHORT      uiClass;      /* offset to the classes base if it is an object */
   USHORT      uiPrevCls;    /* for fixing after access super */
} HB_BASEARRAY, * PHB_BASEARRAY, * HB_BASEARRAY_PTR;

#ifndef _HB_HASH_INTERNAL_
/* internal structure for hashes */
typedef struct _HB_BASEHASH
{
   void *      value;
} HB_BASEHASH, * PHB_BASEHASH;
#endif

/* internal structure for codeblocks */
typedef struct _HB_CODEBLOCK
{
   BYTE *      pCode;        /* codeblock pcode */
   PHB_SYMB    pSymbols;     /* codeblocks symbols */
   PHB_SYMB    pDefSymb;     /* symbol where the codeblock was created */
   PHB_ITEM    pLocals;      /* table with referenced local variables */
   LONG        lStatics;     /* STATICs base address */
   USHORT      uiLocals;     /* number of referenced local variables */
   SHORT       dynBuffer;    /* is pcode buffer allocated dynamically, SHORT used instead of BOOL intentionally to force optimal alignment */
} HB_CODEBLOCK, * PHB_CODEBLOCK, * HB_CODEBLOCK_PTR;

typedef void     ( * HB_EXTREF_FUNC0 )( void * );
typedef PHB_ITEM ( * HB_EXTREF_FUNC1 )( PHB_ITEM );
typedef PHB_ITEM ( * HB_EXTREF_FUNC2 )( PHB_ITEM, PHB_ITEM );
typedef void     ( * HB_EXTREF_FUNC3 )( PHB_ITEM );

typedef struct _HB_EXTREF
{
   HB_EXTREF_FUNC1 read;
   HB_EXTREF_FUNC2 write;
   HB_EXTREF_FUNC3 copy;
   HB_EXTREF_FUNC0 clear;
   HB_EXTREF_FUNC0 mark;
} HB_EXTREF, * PHB_EXTREF, * HB_EXTREF_PTR;

typedef struct _HB_NESTED_CLONED
{
   void *   value;
   PHB_ITEM pDest;
   struct _HB_NESTED_CLONED * pNext;
} HB_NESTED_CLONED, * PHB_NESTED_CLONED;

typedef struct _HB_GRIP
{
   HB_ITEM     value;
   HB_COUNTER  counter;
} HB_GRIP, * PHB_GRIP, * HB_GRIP_PTR;


#endif


/* RDD method return codes */
typedef USHORT ERRCODE;
#define SUCCESS            0
#define FAILURE            1

extern HB_SYMB  hb_symEval;

typedef ULONG HB_VMHANDLE;

extern HB_EXPORT void   hb_xinit( void );                           /* Initialize fixed memory subsystem */
extern HB_EXPORT void   hb_xexit( void );                           /* Deinitialize fixed memory subsystem */
extern HB_EXPORT void * hb_xalloc( ULONG ulSize );                  /* allocates memory, returns NULL on failure */
extern HB_EXPORT void * hb_xgrab( ULONG ulSize );                   /* allocates memory, exits on failure */
extern HB_EXPORT void   hb_xfree( void * pMem );                    /* frees memory */
extern HB_EXPORT void * hb_xrealloc( void * pMem, ULONG ulSize );   /* reallocates memory */
extern HB_EXPORT ULONG  hb_xsize( void * pMem );                    /* returns the size of an allocated memory block */
extern HB_EXPORT ULONG  hb_xquery( USHORT uiMode );                 /* Query different types of memory information */
extern HB_EXPORT void   hb_xsetfilename( char * szValue );
extern HB_EXPORT void   hb_xsetinfo( char * szValue );

extern HB_EXPORT HB_VMHANDLE hb_xvalloc( ULONG nSize, USHORT nFlags );
extern HB_EXPORT void        hb_xvfree( HB_VMHANDLE h );
extern HB_EXPORT HB_VMHANDLE hb_xvrealloc( HB_VMHANDLE h, ULONG nSize, USHORT nFlags );
extern HB_EXPORT void *      hb_xvlock( HB_VMHANDLE h );
extern HB_EXPORT void        hb_xvunlock( HB_VMHANDLE h );
extern HB_EXPORT void *      hb_xvwire( HB_VMHANDLE h );
extern HB_EXPORT void        hb_xvunwire( HB_VMHANDLE h );
extern HB_EXPORT ULONG       hb_xvlockcount( HB_VMHANDLE h );
extern HB_EXPORT ULONG       hb_xvsize( HB_VMHANDLE h );
extern HB_EXPORT HB_VMHANDLE hb_xvheapnew( ULONG nSize );
extern HB_EXPORT void        hb_xvheapdestroy( HB_VMHANDLE h );
extern HB_EXPORT HB_VMHANDLE hb_xvheapresize( HB_VMHANDLE h, ULONG nSize );
extern HB_EXPORT ULONG       hb_xvheapalloc( HB_VMHANDLE h, ULONG nSize );
extern HB_EXPORT void        hb_xvheapfree( HB_VMHANDLE h, ULONG nOffset );
extern HB_EXPORT void *      hb_xvheaplock( HB_VMHANDLE h, ULONG nOffset );
extern HB_EXPORT void        hb_xvheapunlock( HB_VMHANDLE h, ULONG nOffset );

#ifdef _HB_API_INTERNAL_
extern void       hb_xRefInc( void * pMem );    /* increment reference counter */
extern BOOL       hb_xRefDec( void * pMem );    /* decrement reference counter, return TRUE when 0 reached */
extern void       hb_xRefFree( void * pMem );   /* decrement reference counter and free the block when 0 reached */
extern HB_COUNTER hb_xRefCount( void * pMem );  /* return number of references */
extern void *     hb_xRefResize( void * pMem, ULONG ulSave, ULONG ulSize );   /* reallocates memory, create copy if reference counter greater then 1 */

#if 0

/*
 * I used this macros only to test some speed overhead,
 * They may not be supported in the future so please do
 * not create any code which needs them. [druzus]
 */

#define hb_xRefInc( p )             (++(*HB_COUNTER_PTR( p )))
#define hb_xRefDec( p )             (--(*HB_COUNTER_PTR( p ))==0)
#define hb_xRefFree( p )            do { \
                                       if( hb_xRefDec( p ) ) \
                                          hb_xfree( p ); \
                                    } while( 0 )
#define hb_xRefCount( p )           (*HB_COUNTER_PTR( p ))

#endif

#endif /* _HB_API_INTERNAL_ */

/* #if UINT_MAX == ULONG_MAX */
/* it fails on 64bit platforms where int has 32 bit and long has 64 bit.
   we need these functions only when max(size_t) < max(long)
   and only on 16bit platforms, so the below condition seems to be
   more reasonable. */
#if UINT_MAX > USHRT_MAX
   /* NOTE: memcpy/memset can work with ULONG data blocks */
   #define  hb_xmemcpy  memcpy
   #define  hb_xmemset  memset
#else
   /* NOTE: otherwise, the hb_xmemcpy and hb_xmemset functions
            will be used to copy and/or set ULONG data blocks */
extern HB_EXPORT void * hb_xmemcpy( void * pDestArg, void * pSourceArg, ULONG ulLen ); /* copy more than memcpy() can */
extern HB_EXPORT void * hb_xmemset( void * pDestArg, int iFill, ULONG ulLen ); /* set more than memset() can */
#endif

/* garbage collector */
#define HB_GARBAGE_FUNC( hbfunc )   void hbfunc( void * Cargo ) /* callback function for cleaning garbage memory pointer */
typedef HB_GARBAGE_FUNC( HB_GARBAGE_FUNC_ );
typedef HB_GARBAGE_FUNC_ * HB_GARBAGE_FUNC_PTR;

#define HB_GARBAGE_SWEEPER( hbfunc )   BOOL hbfunc( void * Cargo ) /* callback function for cleaning garbage memory pointer */
typedef HB_GARBAGE_SWEEPER( HB_GARBAGE_SWEEPER_ );
typedef HB_GARBAGE_SWEEPER_ * HB_GARBAGE_SWEEPER_PTR;

extern void  hb_gcRegisterSweep( HB_GARBAGE_SWEEPER_PTR pSweep, void * Cargo );

extern PHB_ITEM   hb_gcGripGet( HB_ITEM_PTR pItem );
extern void       hb_gcGripDrop( HB_ITEM_PTR pItem );

extern HB_EXPORT void *hb_gcAlloc( ULONG ulSize, HB_GARBAGE_FUNC_PTR pFunc ); /* allocates a memory controlled by the garbage collector */
extern void       hb_gcFree( void *pAlloc ); /* deallocates a memory allocated by the garbage collector */
extern void *     hb_gcLock( void *pAlloc ); /* do not release passed memory block */
extern void *     hb_gcUnlock( void *pAlloc ); /* passed block is allowed to be released */
#ifdef _HB_API_INTERNAL_
HB_GARBAGE_FUNC_PTR hb_gcFunc( void *pBlock );  /* return cleanup function pointer */
extern void       hb_gcItemRef( HB_ITEM_PTR pItem ); /* checks if passed item refers passed memory block pointer */
extern void       hb_vmIsStackRef( void ); /* hvm.c - mark all local variables as used */
extern void       hb_vmIsStaticRef( void ); /* hvm.c - mark all static variables as used */
extern void       hb_gcReleaseAll( void ); /* release all memory blocks unconditionally */

extern void       hb_gcRefCheck( void * pBlock ); /* Check if block still cannot be access after destructor execution */
extern void       hb_gcRefInc( void * pAlloc );  /* increment reference counter */
extern BOOL       hb_gcRefDec( void * pAlloc );  /* decrement reference counter, return TRUE when 0 reached */
extern void       hb_gcRefFree( void * pAlloc ); /* decrement reference counter and free the block when 0 reached */
extern HB_COUNTER hb_gcRefCount( void * pAlloc );  /* return number of references */

#if 0
#define hb_gcRefInc( p )      hb_xRefInc( HB_GC_PTR( p ) )
#define hb_gcRefDec( p )      hb_xRefDec( HB_GC_PTR( p ) )
#define hb_gcRefCount( p )    hb_xRefCount( HB_GC_PTR( p ) )
#define hb_gcFunc( p )        ( HB_GC_PTR( p )->pFunc )
#endif

#endif /* _HB_API_INTERNAL_ */
extern void       hb_gcCollect( void ); /* checks if a single memory block can be released */
extern void       hb_gcCollectAll( BOOL fForce ); /* checks if all memory blocks can be released */

/* Extend API */
extern HB_EXPORT char *     hb_parc( int iParam, ... );  /* retrieve a string parameter */
extern HB_EXPORT char *     hb_parcx( int iParam, ... );  /* retrieve a string parameter */
extern HB_EXPORT ULONG      hb_parclen( int iParam, ... ); /* retrieve a string parameter length */
extern HB_EXPORT ULONG      hb_parcsiz( int iParam, ... ); /* retrieve a by-reference string parameter length, including terminator */
extern HB_EXPORT char *     hb_pards( int iParam, ... ); /* retrieve a date as a string yyyymmdd */
extern HB_EXPORT char *     hb_pardsbuff( char * szDate, int iParam, ... ); /* retrieve a date as a string yyyymmdd */
extern HB_EXPORT LONG       hb_pardl( int iParam, ... ); /* retrieve a date as a LONG NUMBER  */
extern HB_EXPORT ULONG      hb_parinfa( int iParamNum, ULONG uiArrayIndex ); /* retrieve length or element type of an array parameter */
extern HB_EXPORT ULONG      hb_parinfo( int iParam ); /* Determine the param count or data type */
extern HB_EXPORT int        hb_parl( int iParam, ... ); /* retrieve a logical parameter as an int */
extern HB_EXPORT double     hb_parnd( int iParam, ... ); /* retrieve a numeric parameter as a double */
extern HB_EXPORT int        hb_parni( int iParam, ... ); /* retrieve a numeric parameter as a integer */
extern HB_EXPORT long       hb_parnl( int iParam, ... ); /* retrieve a numeric parameter as a long */
extern HB_EXPORT HB_LONG    hb_parnint( int iParam, ... ); /* retrieve a numeric parameter as a HB_LONG */
extern HB_EXPORT void *     hb_parptr( int iParam, ... ); /* retrieve a parameter as a pointer */
extern HB_EXPORT void *     hb_parptrGC( HB_GARBAGE_FUNC_PTR pFunc, int iParam, ... ); /* retrieve a parameter as a pointer if it's a pointer to GC allocated block */
extern HB_EXPORT PHB_ITEM   hb_param( int iParam, long lMask ); /* retrieve a generic parameter */
extern HB_EXPORT PHB_ITEM   hb_paramError( int iParam ); /* Returns either the generic parameter or a NIL item if param not provided */
extern HB_EXPORT BOOL       hb_extIsArray( int iParam );
extern HB_EXPORT BOOL       hb_extIsObject( int iParam );

#ifndef HB_LONG_LONG_OFF
extern HB_EXPORT LONGLONG   hb_parnll( int iParam, ... ); /* retrieve a numeric parameter as a long long */
#endif

extern HB_EXPORT int    hb_pcount( void );          /* returns the number of suplied parameters */
extern HB_EXPORT void   hb_ret( void );             /* post a NIL return value */
extern HB_EXPORT void   hb_retc( const char * szText );   /* returns a string */
extern HB_EXPORT void   hb_retc_null( void );       /* returns an empty string */
extern HB_EXPORT void   hb_retc_buffer( char * szText ); /* sames as above, but accepts an allocated buffer */
extern HB_EXPORT void   hb_retc_const( const char * szText ); /* returns a string as a pcode based string */
extern HB_EXPORT void   hb_retclen( const char * szText, ULONG ulLen ); /* returns a string with a specific length */
extern HB_EXPORT void   hb_retclen_buffer( char * szText, ULONG ulLen ); /* sames as above, but accepts an allocated buffer */
extern HB_EXPORT void   hb_retds( const char * szDate );  /* returns a date, must use yyyymmdd format */
extern HB_EXPORT void   hb_retd( int iYear, int iMonth, int iDay ); /* returns a date */
extern HB_EXPORT void   hb_retdl( long lJulian );   /* returns a long value as a julian date */
extern HB_EXPORT void   hb_retl( int iTrueFalse );  /* returns a logical integer */
extern HB_EXPORT void   hb_retnd( double dNumber ); /* returns a double */
extern HB_EXPORT void   hb_retni( int iNumber );    /* returns a integer number */
extern HB_EXPORT void   hb_retnl( long lNumber );/* returns a long number */
extern HB_EXPORT void   hb_retnint( HB_LONG lNumber );/* returns a long number */
extern HB_EXPORT void   hb_retnlen( double dNumber, int iWidth, int iDec ); /* returns a double, with specific width and decimals */
extern HB_EXPORT void   hb_retndlen( double dNumber, int iWidth, int iDec ); /* returns a double, with specific width and decimals */
extern HB_EXPORT void   hb_retnilen( int iNumber, int iWidth ); /* returns a integer number, with specific width */
extern HB_EXPORT void   hb_retnllen( long lNumber, int iWidth ); /* returns a long number, with specific width */
extern HB_EXPORT void   hb_retnintlen( HB_LONG lNumber, int iWidth ); /* returns a long long number, with specific width */
extern HB_EXPORT void   hb_reta( ULONG ulLen );  /* returns an array with a specific length */
extern HB_EXPORT void   hb_retptr( void * ptr );  /* returns a pointer */
extern HB_EXPORT void   hb_retptrGC( void * ptr );  /* returns a pointer to an allocated memory, collected by GC */
#ifndef HB_LONG_LONG_OFF
extern HB_EXPORT void   hb_retnll( LONGLONG lNumber );/* returns a long long number */
extern HB_EXPORT void   hb_retnlllen( LONGLONG lNumber, int iWidth ); /* returns a long long number, with specific width */
#endif

#define HB_IS_VALID_INDEX( idx, max )  ( (idx) > 0 && ( ULONG ) (idx) <= (max) )

/* xHarbour compatible functions */
#define hb_retcAdopt( szText )               hb_retc_buffer( (szText) )
#define hb_retclenAdopt( szText, ulLen )     hb_retclen_buffer( (szText), (ulLen) )
#define hb_retcStatic( szText )              hb_retc_const( (szText) )
#define hb_storclenAdopt                     hb_storclen_buffer
#define hb_itemPutCRawStatic                 hb_itemPutCLConst

#ifdef HB_API_MACROS

#define hb_pcount()                          ( ( int ) ( hb_stackBaseItem() )->item.asSymbol.paramcnt )

#define hb_ret()                             hb_itemClear( hb_stackReturnItem() )
#define hb_reta( ulLen )                     hb_arrayNew( hb_stackReturnItem(), ulLen )
#define hb_retc( szText )                    hb_itemPutC( hb_stackReturnItem(), szText )
#define hb_retc_null()                       hb_itemPutC( hb_stackReturnItem(), NULL )
#define hb_retc_buffer( szText )             hb_itemPutCPtr2( hb_stackReturnItem(), szText )
#define hb_retc_const( szText )              hb_itemPutCConst( hb_stackReturnItem(), szText )
#define hb_retclen( szText, ulLen )          hb_itemPutCL( hb_stackReturnItem(), szText, ulLen )
#define hb_retclen_buffer( szText, ulLen )   hb_itemPutCLPtr( hb_stackReturnItem(), szText, ulLen )
#define hb_retds( szDate )                   hb_itemPutDS( hb_stackReturnItem(), szDate )
#define hb_retd( iYear, iMonth, iDay )       hb_itemPutD( hb_stackReturnItem(), iYear, iMonth, iDay )
#define hb_retdl( lJulian )                  hb_itemPutDL( hb_stackReturnItem(), lJulian )
#define hb_retl( iLogical )                  hb_itemPutL( hb_stackReturnItem(), (iLogical) ? TRUE : FALSE )
#define hb_retnd( dNumber )                  hb_itemPutND( hb_stackReturnItem(), dNumber )
#define hb_retni( iNumber )                  hb_itemPutNI( hb_stackReturnItem(), iNumber )
#define hb_retnl( lNumber )                  hb_itemPutNL( hb_stackReturnItem(), lNumber )
#define hb_retnll( lNumber )                 hb_itemPutNLL( hb_stackReturnItem(), lNumber )
#define hb_retnlen( dNumber, iWidth, iDec )  hb_itemPutNLen( hb_stackReturnItem(), dNumber, iWidth, iDec )
#define hb_retndlen( dNumber, iWidth, iDec ) hb_itemPutNDLen( hb_stackReturnItem(), dNumber, iWidth, iDec )
#define hb_retnilen( iNumber, iWidth )       hb_itemPutNILen( hb_stackReturnItem(), iNumber, iWidth )
#define hb_retnllen( lNumber, iWidth )       hb_itemPutNLLen( hb_stackReturnItem(), lNumber, iWidth )
#define hb_retnlllen( lNumber, iWidth )      hb_itemPutNLLLen( hb_stackReturnItem(), lNumber, iWidth )
#define hb_retnint( iNumber )                hb_itemPutNInt( hb_stackReturnItem(), iNumber )
#define hb_retnintlen( lNumber, iWidth )     hb_itemPutNIntLen( hb_stackReturnItem(), lNumber, iWidth )
#define hb_retptr( pointer )                 hb_itemPutPtr( hb_stackReturnItem(), pointer )
#define hb_retptrGC( pointer )               hb_itemPutPtrGC( hb_stackReturnItem(), pointer )

#endif /* HB_API_MACROS */


extern HB_EXPORT int    hb_storc( const char * szText, int iParam, ... ); /* stores a szString on a variable by reference */
extern HB_EXPORT int    hb_storclen( const char * szText, ULONG ulLength, int iParam, ... ); /* stores a fixed length string on a variable by reference */
extern HB_EXPORT int    hb_storclen_buffer( char * szText, ULONG ulLength, int iParam, ... ); /* stores a fixed length string buffer on a variable by reference */
extern HB_EXPORT int    hb_stords( const char * szDate, int iParam, ... );   /* szDate must have yyyymmdd format */
extern HB_EXPORT int    hb_storl( int iLogical, int iParam, ... ); /* stores a logical integer on a variable by reference */
extern HB_EXPORT int    hb_storni( int iValue, int iParam, ... ); /* stores an integer on a variable by reference */
extern HB_EXPORT int    hb_stornl( long lValue, int iParam, ... ); /* stores a long on a variable by reference */
extern HB_EXPORT int    hb_stornd( double dValue, int iParam, ... ); /* stores a double on a variable by reference */
extern HB_EXPORT int    hb_stornint( HB_LONG lValue, int iParam, ... ); /* stores a HB_LONG on a variable by reference */
extern HB_EXPORT int    hb_storptr( void * pointer, int iParam, ... ); /* stores a pointer on a variable by reference */
extern HB_EXPORT int    hb_storptrGC( void * pointer, int iParam, ... ); /* stores a pointer to GC block on a variable by reference */
#ifndef HB_LONG_LONG_OFF
extern HB_EXPORT int    hb_stornll( LONGLONG lValue, int iParam, ... ); /* stores a long long on a variable by reference */
#endif

/* array management */
extern HB_EXPORT BOOL      hb_arrayNew( PHB_ITEM pItem, ULONG ulLen ); /* creates a new array */
extern HB_EXPORT ULONG     hb_arrayLen( PHB_ITEM pArray ); /* retrieves the array len */
extern HB_EXPORT BOOL      hb_arrayIsObject( PHB_ITEM pArray ); /* retrieves if the array is an object */
extern HB_EXPORT void *    hb_arrayId( PHB_ITEM pArray ); /* retrieves the array unique ID */
extern HB_EXPORT BOOL      hb_arrayAdd( PHB_ITEM pArray, PHB_ITEM pItemValue ); /* add a new item to the end of an array item */
extern HB_EXPORT BOOL      hb_arrayAddForward( PHB_ITEM pArray, PHB_ITEM pValue ); /* add a new item to the end of an array item with no incrementing of reference counters */
extern HB_EXPORT BOOL      hb_arrayIns( PHB_ITEM pArray, ULONG ulIndex ); /* insert a nil item into an array, without changing the length */
extern HB_EXPORT BOOL      hb_arrayDel( PHB_ITEM pArray, ULONG ulIndex ); /* delete an array item, without changing length */
extern HB_EXPORT BOOL      hb_arraySize( PHB_ITEM pArray, ULONG ulLen ); /* sets the array total length */
extern HB_EXPORT BOOL      hb_arrayLast( PHB_ITEM pArray, PHB_ITEM pResult ); /* retrieve last item in an array */
extern HB_EXPORT BOOL      hb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); /* retrieves an item */
extern HB_EXPORT BOOL      hb_arrayGetItemRef( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); /* create a reference to an array element */
/* hb_arrayGetItemPtr() is dangerous, be sure that base ARRAY value will not be changed (f.e. resized) */
extern HB_EXPORT PHB_ITEM  hb_arrayGetItemPtr( PHB_ITEM pArray, ULONG ulIndex ); /* returns pointer to specified element of the array */
extern HB_EXPORT ULONG     hb_arrayCopyC( PHB_ITEM pArray, ULONG ulIndex, char * szBuffer, ULONG ulLen ); /* copy a string into an array item */
extern HB_EXPORT char *    hb_arrayGetC( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the string contained on an array element */
extern HB_EXPORT char *    hb_arrayGetCPtr( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the string pointer on an array element */
extern HB_EXPORT ULONG     hb_arrayGetCLen( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the string length contained on an array element */
extern HB_EXPORT void *    hb_arrayGetPtr( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the pointer contained on an array element */
extern HB_EXPORT void *    hb_arrayGetPtrGC( PHB_ITEM pArray, ULONG ulIndex, HB_GARBAGE_FUNC_PTR pFunc ); /* retrieves the GC pointer contained on an array element */
extern HB_EXPORT PHB_SYMB  hb_arrayGetSymbol( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves symbol contained on an array element */
extern HB_EXPORT BOOL      hb_arrayGetL( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the logical value contained on an array element */
extern HB_EXPORT int       hb_arrayGetNI( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the int value contained on an array element */
extern HB_EXPORT long      hb_arrayGetNL( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the long numeric value contained on an array element */
extern HB_EXPORT HB_LONG   hb_arrayGetNInt( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the HB_LONG value contained on an array element */
extern HB_EXPORT double    hb_arrayGetND( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the double value contained on an array element */
extern HB_EXPORT char *    hb_arrayGetDS( PHB_ITEM pArray, ULONG ulIndex, char * szDate ); /* retrieves the date value contained in an array element */
extern HB_EXPORT long      hb_arrayGetDL( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the date value contained in an array element, as a long integer */
extern HB_EXPORT HB_TYPE   hb_arrayGetType( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the type of an array item */
extern HB_EXPORT BOOL      hb_arraySet( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); /* sets an array element */
extern HB_EXPORT BOOL      hb_arraySetForward( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); /* sets an array element by forwarding it's value */
extern HB_EXPORT BOOL      hb_arraySetDS( PHB_ITEM pArray, ULONG ulIndex, const char * szDate );
extern HB_EXPORT BOOL      hb_arraySetDL( PHB_ITEM pArray, ULONG ulIndex, LONG lDate );
extern HB_EXPORT BOOL      hb_arraySetL( PHB_ITEM pArray, ULONG ulIndex, BOOL fValue );
extern HB_EXPORT BOOL      hb_arraySetNI( PHB_ITEM pArray, ULONG ulIndex, int iNumber );
extern HB_EXPORT BOOL      hb_arraySetNL( PHB_ITEM pArray, ULONG ulIndex, LONG lNumber );
#ifndef HB_LONG_LONG_OFF
extern HB_EXPORT BOOL      hb_arraySetNLL( PHB_ITEM pArray, ULONG ulIndex, LONGLONG llNumber );
#endif
extern HB_EXPORT BOOL      hb_arraySetNInt( PHB_ITEM pArray, ULONG ulIndex, HB_LONG lNumber );
extern HB_EXPORT BOOL      hb_arraySetND( PHB_ITEM pArray, ULONG ulIndex, double dNumber );
extern HB_EXPORT BOOL      hb_arraySetC( PHB_ITEM pArray, ULONG ulIndex, const char * szText );
extern HB_EXPORT BOOL      hb_arraySetCL( PHB_ITEM pArray, ULONG ulIndex, const char * szText, ULONG ulLen );
extern HB_EXPORT BOOL      hb_arraySetCPtr( PHB_ITEM pArray, ULONG ulIndex, char * szText, ULONG ulLen );
extern HB_EXPORT BOOL      hb_arraySetPtr( PHB_ITEM pArray, ULONG ulIndex, void * pValue );
extern HB_EXPORT BOOL      hb_arraySetPtrGC( PHB_ITEM pArray, ULONG ulIndex, void * pValue );
extern HB_EXPORT BOOL      hb_arraySetSymbol( PHB_ITEM pArray, ULONG ulIndex, PHB_SYMB pSymbol );
extern HB_EXPORT BOOL      hb_arrayFill( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount ); /* fill an array with a given item */
extern HB_EXPORT ULONG     hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount, BOOL fExact ); /* scan an array for a given item, or until code-block item returns TRUE */
extern HB_EXPORT ULONG     hb_arrayRevScan( PHB_ITEM pArray, PHB_ITEM pValue, ULONG * pulStart, ULONG * pulCount, BOOL fExact ); /* scan an array for a given item, or until code-block item returns TRUE in reverted order */
extern HB_EXPORT BOOL      hb_arrayEval( PHB_ITEM pArray, PHB_ITEM bBlock, ULONG * pulStart, ULONG * pulCount ); /* execute a code-block for every element of an array item */
extern HB_EXPORT BOOL      hb_arrayCopy( PHB_ITEM pSrcArray, PHB_ITEM pDstArray, ULONG * pulStart, ULONG * pulCount, ULONG * pulTarget ); /* copy items from one array to another */
extern HB_EXPORT PHB_ITEM  hb_arrayClone( PHB_ITEM pArray ); /* returns a duplicate of an existing array, including all nested items */
extern HB_EXPORT BOOL      hb_arraySort( PHB_ITEM pArray, ULONG * pulStart, ULONG * pulCount, PHB_ITEM pBlock ); /* sorts an array item */
extern HB_EXPORT PHB_ITEM  hb_arrayFromStack( USHORT uiLen ); /* Creates and returns an Array of n Elements from the Eval Stack - Does NOT pop the items. */
extern HB_EXPORT PHB_ITEM  hb_arrayFromParams( int iLevel ); /* Creates and returns an Array of Generic Parameters for a given call level */
extern HB_EXPORT PHB_ITEM  hb_arrayBaseParams( void ); /* Creates and returns an Array of Generic Parameters for current base symbol. */
extern HB_EXPORT PHB_ITEM  hb_arraySelfParams( void ); /* Creates and returns an Array of Generic Parameters for current base symbol with self item */
#ifndef HB_LONG_LONG_OFF
extern HB_EXPORT LONGLONG  hb_arrayGetNLL( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the long long numeric value contained on an array element */
#endif
#ifdef _HB_API_INTERNAL_
/* internal array API not exported */
extern void hb_arrayPushBase( PHB_BASEARRAY pBaseArray );
extern void hb_cloneNested( PHB_ITEM pDstItem, PHB_ITEM pSrcItem, PHB_NESTED_CLONED pClonedList );
extern void hb_hashCloneBody( PHB_ITEM pHash, PHB_ITEM pDest, PHB_NESTED_CLONED pClonedList );
#endif


/* hash management */
extern HB_EXPORT PHB_ITEM  hb_hashNew( PHB_ITEM pItem );
extern HB_EXPORT ULONG     hb_hashLen( PHB_ITEM pHash );
extern HB_EXPORT BOOL      hb_hashDel( PHB_ITEM pHash, PHB_ITEM pKey );
extern HB_EXPORT BOOL      hb_hashAdd( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
extern HB_EXPORT BOOL      hb_hashAddNew( PHB_ITEM pHash, PHB_ITEM pKey, PHB_ITEM pValue );
extern HB_EXPORT BOOL      hb_hashRemove( PHB_ITEM pHash, PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM  hb_hashClone( PHB_ITEM pSource );
extern HB_EXPORT void      hb_hashJoin( PHB_ITEM pDest, PHB_ITEM pSource, int iType );
extern HB_EXPORT BOOL      hb_hashScan( PHB_ITEM pHash, PHB_ITEM pKey, ULONG * pulPos );
extern HB_EXPORT void      hb_hashPreallocate( PHB_ITEM pHash, ULONG ulNewSize );
extern HB_EXPORT PHB_ITEM  hb_hashGetKeys( PHB_ITEM pHash );
extern HB_EXPORT PHB_ITEM  hb_hashGetValues( PHB_ITEM pHash );
extern HB_EXPORT void      hb_hashSetDefault( PHB_ITEM pHash, PHB_ITEM pValue );
extern HB_EXPORT PHB_ITEM  hb_hashGetDefault( PHB_ITEM pHash );
extern HB_EXPORT void      hb_hashSetFlags( PHB_ITEM pHash, int iFlags );
extern HB_EXPORT void      hb_hashClearFlags( PHB_ITEM pHash, int iFlags );
extern HB_EXPORT int       hb_hashGetFlags( PHB_ITEM pHash );
extern HB_EXPORT void *    hb_hashId( PHB_ITEM pHash ); /* retrieves the hash unique ID */

/* these hb_hashGet*() functions are dangerous, be sure that base HASH value will not be changed */
extern HB_EXPORT PHB_ITEM  hb_hashGetItemPtr( PHB_ITEM pHash, PHB_ITEM pKey, int iFlags );
extern HB_EXPORT PHB_ITEM  hb_hashGetItemRefPtr( PHB_ITEM pHash, PHB_ITEM pKey );
extern HB_EXPORT PHB_ITEM  hb_hashGetKeyAt( PHB_ITEM pHash, ULONG ulPos );
extern HB_EXPORT PHB_ITEM  hb_hashGetValueAt( PHB_ITEM pHash, ULONG ulPos );

extern HB_EXPORT BOOL      hb_hashDelAt( PHB_ITEM pHash, ULONG ulPos );

/* hash item flags */
#define HB_HASH_AUTOADD_NEVER       0x00
#define HB_HASH_AUTOADD_ACCESS      0x01
#define HB_HASH_AUTOADD_ASSIGN      0x02
#define HB_HASH_AUTOADD_ALWAYS      ( HB_HASH_AUTOADD_ACCESS | HB_HASH_AUTOADD_ASSIGN )
#define HB_HASH_AUTOADD_REFERENCE   HB_HASH_AUTOADD_ALWAYS
#define HB_HASH_AUTOADD_MASK        0x03

#define HB_HASH_IGNORECASE          0x10

#ifdef _HB_API_INTERNAL_
/* internal hash API not exported */
extern void hb_hashRefGrabage( PHB_ITEM pHash );
#endif

#define HB_HASH_UNION      0  /* logical OR  on items in two hash tables */
#define HB_HASH_INTERSECT  1  /* logical AND on items in two hash tables */
#define HB_HASH_DIFFERENCE 2  /* logical XOR on items in two hash tables */
#define HB_HASH_REMOVE     3  /* h1 & ( h1 ^ h2 ) */


/* string management */

#define HB_ISSPACE( c ) ( ( c ) == ' ' || \
                          ( c ) == HB_CHAR_HT || \
                          ( c ) == HB_CHAR_LF || \
                          ( c ) == HB_CHAR_CR )

#define HB_ISFIRSTIDCHAR(c)   ( ( (c) >= 'A' && (c) <= 'Z' ) || \
                                ( (c) >= 'a' && (c) <= 'z' ) || (c) == '_' )
#define HB_ISNEXTIDCHAR(c)    ( HB_ISFIRSTIDCHAR(c) || \
                                ( ( (c) >= '0' && (c) <= '9' ) ) )

extern const char * hb_szAscii[256];      /* array of 1 character length strings */

extern HB_EXPORT int       hb_stricmp( const char * s1, const char * s2 ); /* compare two strings without regards to case */
extern HB_EXPORT int       hb_strnicmp( const char * s1, const char * s2, ULONG ulLen ); /* compare two string without regards to case, limited by length */
extern HB_EXPORT char *    hb_strupr( char * pszText ); /* convert a string in-place to upper-case */
extern HB_EXPORT char *    hb_strlow( char * pszText ); /* convert a string in-place to lower-case */
extern HB_EXPORT char *    hb_strdup( const char * pszText ); /* returns a pointer to a newly allocated copy of the source string */
extern HB_EXPORT char *    hb_strndup( const char * pszText, ULONG ulLen ); /* returns a pointer to a newly allocated copy of the source string not longer then ulLen */
extern HB_EXPORT char *    hb_strduptrim( const char * pszText ); /* returns a pointer to a newly allocated copy of the trimmed source string */
extern HB_EXPORT ULONG     hb_strlentrim( const char * pszText ); /* like strlen() but result is the length of trimmed text */
extern HB_EXPORT ULONG     hb_strnlen( const char * pszText, ULONG ulLen ); /* like strlen() but result is limited to ulLen */
extern HB_EXPORT char *    hb_xstrcat( char *dest, const char *src, ... ); /* Concatenates multiple strings into a single result */
extern HB_EXPORT char *    hb_xstrcpy( char *szDest, const char *szSrc, ...); /* Concatenates multiple strings into a single result */
extern HB_EXPORT BOOL      hb_compStrToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth );  /* converts string to number, sets iDec, iWidth and returns TRUE if results is double, used by compiler */
extern HB_EXPORT BOOL      hb_valStrnToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth );  /* converts string to number, sets iDec, iWidth and returns TRUE if results is double, used by VAL() */
extern HB_EXPORT BOOL      hb_strToNum( const char* szNum, HB_LONG * plVal, double * pdVal ); /* converts string to number, returns TRUE if results is double */
extern HB_EXPORT BOOL      hb_strnToNum( const char* szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal ); /* converts string to number, returns TRUE if results is double */

extern HB_EXPORT BOOL      hb_strMatchFile( const char * pszString, const char * szPattern ); /* compare two strings using platform dependent rules for file matching */
extern HB_EXPORT BOOL      hb_strMatchRegExp( const char * szString, const char * szPattern ); /* compare two strings using a regular expression pattern */
extern HB_EXPORT BOOL      hb_strMatchWild(const char *szString, const char *szPattern ); /* compare two strings using pattern with wildcard (?*) - patern have to be prefix of given string */
extern HB_EXPORT BOOL      hb_strMatchWildExact( const char *szString, const char *szPattern ); /* compare two strings using pattern with wildcard (?*) - patern have to cover whole string */
extern HB_EXPORT BOOL      hb_strMatchCaseWildExact( const char *szString, const char *szPattern ); /* compare two strings using pattern with wildcard (?*) ignoring the case of the characters - patern have to cover whole string */
extern HB_EXPORT BOOL      hb_strEmpty( const char * szText, ULONG ulLen ); /* returns whether a string contains only white space */
extern HB_EXPORT void      hb_strDescend( char * szStringTo, const char * szStringFrom, ULONG ulLen ); /* copy a string to a buffer, inverting each character */
extern HB_EXPORT ULONG     hb_strAt( const char * szSub, ULONG ulSubLen, const char * szText, ULONG ulLen ); /* returns an index to a sub-string within another string */
extern HB_EXPORT char *    hb_strUpper( char * szText, ULONG ulLen ); /* convert an existing string buffer to upper case */
extern HB_EXPORT char *    hb_strUpperCopy( char * szText, ULONG ulLen );
extern HB_EXPORT char *    hb_strLower( char * szText, ULONG ulLen ); /* convert an existing string buffer to lower case */
extern HB_EXPORT int       hb_charUpper( int iChar );  /* converts iChar to upper case */
extern HB_EXPORT int       hb_charLower( int iChar );  /* converts iChar to lower case */
extern HB_EXPORT char *    hb_strncpy( char * pDest, const char * pSource, ULONG ulLen ); /* copy at most ulLen bytes from string buffer to another buffer and _always_ set 0 in destin buffer */
extern HB_EXPORT char *    hb_strncat( char * pDest, const char * pSource, ULONG ulLen ); /* copy at most ulLen-strlen(pDest) bytes from string buffer to another buffer and _always_ set 0 in destin buffer */
extern HB_EXPORT char *    hb_strncpyTrim( char * pDest, const char * pSource, ULONG ulLen );
extern HB_EXPORT char *    hb_strncpyLower( char * pDest, const char * pSource, ULONG ulLen ); /* copy an existing string buffer to another buffer, as lower case */
extern HB_EXPORT char *    hb_strncpyUpper( char * pDest, const char * pSource, ULONG ulLen ); /* copy an existing string buffer to another buffer, as upper case */
extern HB_EXPORT char *    hb_strncpyUpperTrim( char * pDest, const char * pSource, ULONG ulLen );
extern HB_EXPORT double    hb_strVal( const char * szText, ULONG ulLen ); /* return the numeric value of a character string representation of a number */
extern HB_EXPORT char *    hb_strLTrim( const char * szText, ULONG * ulLen ); /* return a pointer to the first non-white space character */
extern HB_EXPORT ULONG     hb_strRTrimLen( const char * szText, ULONG ulLen, BOOL bAnySpace ); /* return length of a string, ignoring trailing white space (or true spaces) */
extern HB_EXPORT double    hb_strVal( const char * szText, ULONG ulLen );
extern HB_EXPORT HB_LONG   hb_strValInt( const char * szText, int * iOverflow );
extern HB_EXPORT char *    hb_strRemEscSeq( char * szText, ULONG * ulLen ); /* remove C ESC sequences and converts them to Clipper chars */
                          
extern HB_EXPORT double    hb_numRound( double dResult, int iDec ); /* round a number to a specific number of digits */
extern HB_EXPORT double    hb_numInt( double dNum ); /* take the integer part of the number */
extern HB_EXPORT double    hb_numDecConv( double dNum, int iDec );


/* architecture dependent number conversions */
extern HB_EXPORT void      hb_put_ieee754( BYTE * ptr, double d );
extern HB_EXPORT double    hb_get_ieee754( BYTE * ptr );
extern HB_EXPORT void      hb_put_ord_ieee754( BYTE * ptr, double d );
extern HB_EXPORT double    hb_get_ord_ieee754( BYTE * ptr );
extern HB_EXPORT double    hb_get_rev_double( BYTE * ptr );
extern HB_EXPORT double    hb_get_std_double( BYTE * ptr );

#if defined( HB_LONG_LONG_OFF )
extern HB_EXPORT double    hb_get_le_int64( BYTE * ptr );
extern HB_EXPORT double    hb_get_le_uint64( BYTE * ptr );
extern HB_EXPORT void      hb_put_le_uint64( BYTE * ptr, double d );
#endif

/* dynamic symbol table management */
extern HB_EXPORT PHB_DYNS  hb_dynsymGet( const char * szName );    /* finds and creates a dynamic symbol if not found */
extern HB_EXPORT PHB_DYNS  hb_dynsymGetCase( const char * szName );    /* finds and creates a dynamic symbol if not found - case sensitive */
extern HB_EXPORT PHB_DYNS  hb_dynsymNew( PHB_SYMB pSymbol ); /* creates a new dynamic symbol based on a local one */
extern HB_EXPORT PHB_DYNS  hb_dynsymFind( const char * szName );   /* finds a dynamic symbol */
extern HB_EXPORT PHB_DYNS  hb_dynsymFindName( const char * szName ); /* converts to uppercase and finds a dynamic symbol */
extern HB_EXPORT void      hb_dynsymRelease( void );         /* releases the memory of the dynamic symbol table */
extern HB_EXPORT void      hb_dynsymEval( PHB_DYNS_FUNC pFunction, void * Cargo ); /* enumerates all dynamic symbols */
extern HB_EXPORT void      hb_dynsymProtectEval( PHB_DYNS_FUNC pFunction, void * Cargo ); /* enumerates all dynamic symbols with global symbol table locked - can be used ONLY when user function does not try to access dynamic symbol table */
extern HB_EXPORT PHB_SYMB  hb_dynsymGetSymbol( const char * szName ); /* finds and creates a dynamic symbol if not found and return pointer to its HB_SYMB structure */
extern HB_EXPORT PHB_SYMB  hb_dynsymFindSymbol( const char * szName ); /* finds a dynamic symbol and return pointer to its HB_SYMB structure */
extern HB_EXPORT PHB_SYMB  hb_dynsymSymbol( PHB_DYNS pDynSym );
extern HB_EXPORT const char * hb_dynsymName( PHB_DYNS pDynSym ); /* return dynamic symbol name */
extern HB_EXPORT BOOL      hb_dynsymIsFunction( PHB_DYNS pDynSym );
extern HB_EXPORT int       hb_dynsymAreaHandle( PHB_DYNS pDynSym ); /* return work area number bound with given dynamic symbol */
extern HB_EXPORT void      hb_dynsymSetAreaHandle( PHB_DYNS pDynSym, int iArea ); /* set work area number for a given dynamic symbol */
#ifdef _HB_API_INTERNAL_
extern           PHB_ITEM  hb_dynsymGetMemvar( PHB_DYNS pDynSym ); /* return memvar handle number bound with given dynamic symbol */
extern           void      hb_dynsymSetMemvar( PHB_DYNS pDynSym, PHB_ITEM pMemvar ); /* set memvar handle for a given dynamic symbol */
#endif

/* Symbol management */
extern HB_EXPORT PHB_SYMB  hb_symbolNew( const char * szName ); /* create a new symbol */

/* Command line and environment argument management */
extern HB_EXPORT void hb_cmdargInit( int argc, char * argv[] ); /* initialize command line argument API's */
extern int       hb_cmdargARGC( void ); /* retrieve command line argument count */
extern char **   hb_cmdargARGV( void ); /* retrieve command line argument buffer pointer */
extern BOOL      hb_cmdargIsInternal( const char * szArg, int * piLen ); /* determine if a string is an internal setting */
extern BOOL      hb_cmdargCheck( const char * pszName ); /* Check if a given internal switch (like //INFO) was set */
extern char *    hb_cmdargString( const char * pszName ); /* Returns the string value of an internal switch (like //TEMPPATH:"C:\") */
extern int       hb_cmdargNum( const char * pszName ); /* Returns the numeric value of an internal switch (like //F:90) */
extern ULONG     hb_cmdargProcessVM( int*, int* ); /* Check for command line internal arguments */
#if defined( HB_OS_WIN_32 ) && defined( HB_OS_WIN_32_USED )
extern HB_EXPORT void hb_winmainArgInit( HANDLE hInstance, HANDLE hPrevInstance, int iCmdShow ); /* Set WinMain() parameters */
extern HB_EXPORT BOOL hb_winmainArgGet( HANDLE * phInstance, HANDLE * phPrevInstance, int * piCmdShow ); /* Retrieve WinMain() parameters */
#endif

/* Codeblock management */
extern HB_EXPORT void * hb_codeblockId( PHB_ITEM pItem ); /* retrieves the codeblock unique ID */
extern HB_CODEBLOCK_PTR hb_codeblockNew( const BYTE * pBuffer, USHORT uiLocals, const BYTE * pLocalPosTable, PHB_SYMB pSymbols, ULONG ulLen ); /* create a code-block */
extern HB_CODEBLOCK_PTR hb_codeblockMacroNew( const BYTE * pBuffer, ULONG ulLen );
extern PHB_ITEM         hb_codeblockGetVar( PHB_ITEM pItem, LONG iItemPos ); /* get local variable referenced in a codeblock */
extern PHB_ITEM         hb_codeblockGetRef( HB_CODEBLOCK_PTR pCBlock, LONG iItemPos ); /* get local variable passed by reference */
extern void             hb_codeblockEvaluate( HB_ITEM_PTR pItem ); /* evaluate a codeblock */

/* memvars subsystem */
extern void       hb_memvarsClear( void ); /* clear all PUBLIC and PRIVATE variables */
extern void       hb_memvarSetValue( PHB_SYMB pMemvarSymb, HB_ITEM_PTR pItem ); /* copy an item into a symbol */
extern ERRCODE    hb_memvarGet( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb ); /* copy an symbol value into an item */
extern void       hb_memvarGetValue( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb ); /* copy an symbol value into an item, with error trapping */
extern void       hb_memvarGetRefer( HB_ITEM_PTR pItem, PHB_SYMB pMemvarSymb ); /* copy a reference to a symbol value into an item, with error trapping */
extern ULONG      hb_memvarGetPrivatesBase( void ); /* retrieve current PRIVATE variables stack base */
extern void       hb_memvarSetPrivatesBase( ULONG ulBase ); /* release PRIVATE variables created after specified base */
extern void       hb_memvarUpdatePrivatesBase( void ); /* Update PRIVATE base ofsset so they will not be removed when function return */
extern void       hb_memvarNewParameter( PHB_SYMB pSymbol, PHB_ITEM pValue );
extern char *     hb_memvarGetStrValuePtr( char * szVarName, ULONG *pulLen );
extern void       hb_memvarCreateFromItem( PHB_ITEM pMemvar, BYTE bScope, PHB_ITEM pValue );
extern int        hb_memvarScope( char * szVarName, ULONG ulLength ); /* retrieve scope of a dynamic variable symbol */
extern PHB_ITEM   hb_memvarDetachLocal( HB_ITEM_PTR pLocal ); /* Detach a local variable from the eval stack */
extern PHB_ITEM   hb_memvarGetValueBySym( PHB_DYNS pDynSym );
extern PHB_ITEM   hb_memvarSaveInArray( int iScope, BOOL fCopy ); /* create array with visible memvar references or copies respecting given memvars scope */
extern void       hb_memvarRestoreFromArray( PHB_ITEM pArray );

#ifdef _HB_API_INTERNAL_
extern void       hb_memvarValueIncRef( PHB_ITEM pValue ); /* increase the reference count of a global value */
extern void       hb_memvarValueDecRef( PHB_ITEM pValue ); /* decrease the reference count of a global value */
extern PHB_ITEM   hb_memvarGetItem( PHB_SYMB pMemvarSymb );
#if defined( HB_API_MACROS )
#  define hb_memvarValueIncRef( p )       hb_xRefInc( p )
#endif /* HB_API_MACROS */
#endif /* _HB_API_INTERNAL_ */

/* console I/O subsystem */
extern void     hb_conInit( void ); /* initialize the console API system */
extern void     hb_conRelease( void ); /* release the console API system */
extern char *   hb_conNewLine( void ); /* retrieve a pointer to a static buffer containing new-line characters */
extern void     hb_conOutStd( const char * pStr, ULONG ulLen ); /* output an string to STDOUT */
extern void     hb_conOutErr( const char * pStr, ULONG ulLen ); /* output an string to STDERR */
extern void     hb_conOutAlt( const char * pStr, ULONG ulLen ); /* output an string to the screen and/or printer and/or alternate */
extern USHORT   hb_conSetCursor( BOOL bSetCursor, USHORT usNewCursor ); /* retrieve and optionally set cursor shape */
extern char *   hb_conSetColor( const char * szColor ); /* retrieve and optionally set console color */

/* compiler and macro compiler */
extern const char * hb_compReservedName( const char * szName ); /* determines if a string contains a reserve word */
extern char *   hb_compEncodeString( int iMethod, const char * szText, ULONG * pulLen );
extern char *   hb_compDecodeString( int iMethod, const char * szText, ULONG * pulLen );

/* misc */
extern char *   hb_procname( int iLevel, char * szName, BOOL bskipBlock ); /* retrieve a procedure name into a buffer */
extern BOOL     hb_procinfo( int iLevel, char * szName, USHORT * puiLine, char * szFile );

/* macro compiler */
#if defined( HB_MACRO_SUPPORT )
struct HB_MACRO_;
typedef struct HB_MACRO_ * HB_MACRO_PTR;
#else
typedef void * HB_MACRO_PTR;
#endif
extern void   hb_macroGetValue( HB_ITEM_PTR pItem, BYTE iContext, BYTE flags ); /* retrieve results of a macro expansion */
extern void   hb_macroSetValue( HB_ITEM_PTR pItem, BYTE flags ); /* assign a value to a macro-expression item */
extern void   hb_macroTextValue( HB_ITEM_PTR pItem ); /* macro text substitution */
extern void   hb_macroPushSymbol( HB_ITEM_PTR pItem ); /* handle a macro function calls, e.g. var := ¯o() */
extern void   hb_macroRun( HB_MACRO_PTR pMacro ); /* executes pcode compiled by macro compiler */
extern HB_MACRO_PTR hb_macroCompile( char * szString ); /* compile a string and return a pcode buffer */
extern void   hb_macroDelete( HB_MACRO_PTR pMacro ); /* release all memory allocated for macro evaluation */
extern char * hb_macroTextSymbol( const char *szString, ULONG ulLength, BOOL *pfNewString ); /* substitute macro variables occurences within a given string and check if result is a valid function or variable name */
extern char * hb_macroExpandString( const char *szString, ULONG ulLength, BOOL *pfNewString ); /* expands valid '&' operator */
extern void   hb_macroPopAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags ); /* compiles and evaluates an aliased macro expression */
extern void   hb_macroPushAliasedValue( HB_ITEM_PTR pAlias, HB_ITEM_PTR pVar, BYTE flags ); /* compiles and evaluates an aliased macro expression */
extern char * hb_macroGetType( HB_ITEM_PTR pItem ); /* determine the type of an expression */

/* idle states */
extern void   hb_releaseCPU( void );
extern void   hb_idleState( void ); /* services a single idle state */
extern void   hb_idleReset( void ); /* services a single idle state */
extern void   hb_idleSleep( double dSeconds ); /* sleep for a given time serving idle task */

/* misc */
extern char * hb_verPlatform( void );  /* retrieves a newly allocated buffer containing platform version */
extern char * hb_verCompiler( void );  /* retrieves a newly allocated buffer containing compiler version */
extern char * hb_verHarbour( void );   /* retrieves a newly allocated buffer containing harbour version */
extern char * hb_verPCode( void );     /* retrieves a newly allocated buffer containing PCode version */
extern char * hb_verBuildDate( void ); /* retrieves a newly allocated buffer containing build date and time */
extern void   hb_verBuildInfo( void ); /* display harbour, compiler, and platform versions to standard console */
extern int          hb_verSvnID( void );           /* retrieves ChangeLog SVN revision number */
extern const char * hb_verSvnChangeLogID( void );  /* retrieves a static buffer containing ChangeLog ID string */
extern const char * hb_verSvnLastEntry( void );    /* retrieves a static buffer containing ChangeLog last entry string */
extern const char * hb_verFlagsC( void );          /* retrieves a static buffer containing build time C compiler flags in C_USR envvar */
extern const char * hb_verFlagsL( void );          /* retrieves a static buffer containing build time linker flags in L_USR envvar */
extern const char * hb_verFlagsPRG( void );        /* retrieves a static buffer containing build time Harbour compiler flags in PRG_USR envvar */

extern HB_EXPORT BOOL   hb_iswinnt( void ); /* return .T. if OS == WinNt, 2000, XP */
extern HB_EXPORT BOOL   hb_iswince( void ); /* return .T. if OS is Windows CE or Windows Mobile */
extern HB_EXPORT BOOL   hb_printerIsReady( char * pszPrinterName );

/* environment variables access */
/* WARNING: This returned pointer must be freed if not NULL using hb_xfree( ( void * ) ptr ); */
extern char * hb_getenv( const char * name );
extern char * hb_netname( void );
extern char * hb_username( void );

/* Translation related things */

/* Dummy define for start */
#define HB_I_( x ) x

HB_EXTERN_END

#if defined( HB_MACRO_SUPPORT )
#include "hbcompdf.h"
#endif

#endif /* HB_APIEXT_H_ */
c:\harbour\include\hbapicdp.h
/*
 * $Id: hbapicdp.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the CodePages API
 *
 * Copyright 2002 Alexander S.Kresin 
 * 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.
 *
 */

#ifndef HB_APICDP_H_
#define HB_APICDP_H_

#include 

#ifndef HB_CDP_SUPPORT_OFF

#include "hbapi.h"
#include "hbinit.h"

HB_EXTERN_BEGIN

/* This hack is needed to force preprocessing if id is also a macro */
#define HB_CODEPAGE_REQUEST( id )      HB_CODEPAGE_REQUEST_( id )
#define HB_CODEPAGE_REQUEST_( id )     HB_FUNC_EXTERN( HB_CODEPAGE_##id ); \
                                       void hb_codepage_ForceLink_##id( void ) \
                                       { \
                                          HB_FUNC_EXEC( HB_CODEPAGE_##id ); \
                                       }
#define HB_CODEPAGE_ANNOUNCE( id )     HB_FUNC( HB_CODEPAGE_##id ) {}

#define HB_CODEPAGE_INIT( id )         HB_CODEPAGE_ANNOUNCE( id ) \
                                       HB_CALL_ON_STARTUP_BEGIN( hb_codepage_Init_##id ) \
                                       hb_cdpRegister( &s_codepage ); \
                                       HB_CALL_ON_STARTUP_END( hb_codepage_Init_##id )


typedef struct _HB_UNITABLE
{
   const char *   uniID;
   int            nChars;
   BOOL           lMulti;
   USHORT *       uniCodes;
} HB_UNITABLE, * PHB_UNITABLE;

typedef struct _HB_MULTICHAR
{
   char  cLast[2];
   char  cFirst[2];
   int   nCode;
} HB_MULTICHAR, * PHB_MULTICHAR;

typedef struct _HB_CODEPAGE
{
   const char *   id;
   const char *   uniID;
   PHB_UNITABLE   uniTable;
   int            nChars;
   const char *   CharsUpper;
   const char *   CharsLower;
   BOOL           lLatin;
   BOOL           lAccEqual;
   BOOL           lAccInterleave;
   BOOL           lSort;
   BOOL           lChClone;
   BYTE *         s_chars;
   BYTE *         s_upper;
   BYTE *         s_lower;
   BYTE *         s_accent;
   int            nMulti;
   PHB_MULTICHAR  multi;
} HB_CODEPAGE, * PHB_CODEPAGE;

#define HB_CPID_437        "cp437"
#define HB_CPID_737        "cp737"
#define HB_CPID_850        "cp850"
#define HB_CPID_852        "cp852"
#define HB_CPID_857        "cp857"
#define HB_CPID_866        "cp866"
#define HB_CPID_1250       "cp1250"
#define HB_CPID_1251       "cp1251"
#define HB_CPID_1252       "cp1252"
#define HB_CPID_1253       "cp1253"
#define HB_CPID_1254       "cp1254"
#define HB_CPID_1257       "cp1257"
#define HB_CPID_8859_1     "iso8859-1"
#define HB_CPID_8859_1B    "iso8859-1b"
#define HB_CPID_8859_2     "iso8859-2"
#define HB_CPID_8859_5     "iso8859-5"
#define HB_CPID_KOI_8      "koi-8"
#define HB_CPID_KOI_8U     "koi-8u"
#define HB_CPID_KAM        "kamenicky"
#define HB_CPID_MAZ        "plmaz"
#define HB_CPID_MIK        "bg-mik"
#define HB_UNITB_437       &hb_uniTbl_437
#define HB_UNITB_737       &hb_uniTbl_737
#define HB_UNITB_850       &hb_uniTbl_850
#define HB_UNITB_852       &hb_uniTbl_852
#define HB_UNITB_857       &hb_uniTbl_857
#define HB_UNITB_866       &hb_uniTbl_866
#define HB_UNITB_1250      &hb_uniTbl_1250
#define HB_UNITB_1251      &hb_uniTbl_1251
#define HB_UNITB_1252      &hb_uniTbl_1252
#define HB_UNITB_1253      &hb_uniTbl_1253
#define HB_UNITB_1254      &hb_uniTbl_1254
#define HB_UNITB_1257      &hb_uniTbl_1257
#define HB_UNITB_8859_1    &hb_uniTbl_8859_1
#define HB_UNITB_8859_1B   &hb_uniTbl_8859_1b
#define HB_UNITB_8859_2    &hb_uniTbl_8859_2
#define HB_UNITB_8859_5    &hb_uniTbl_8859_5
#define HB_UNITB_KOI_8     &hb_uniTbl_KOI_8
#define HB_UNITB_KOI_8U    &hb_uniTbl_KOI_8U
#define HB_UNITB_KAM       &hb_uniTbl_kamenicky
#define HB_UNITB_MAZ       &hb_uniTbl_mazovia
#define HB_UNITB_MIK       &hb_uniTbl_MIK
#define HB_UNITB_UNDEF     NULL /* ((PHB_UNITABLE) (-1)) */

extern HB_UNITABLE hb_uniTbl_437;
extern HB_UNITABLE hb_uniTbl_737;
extern HB_UNITABLE hb_uniTbl_850;
extern HB_UNITABLE hb_uniTbl_852;
extern HB_UNITABLE hb_uniTbl_857;
extern HB_UNITABLE hb_uniTbl_866;
extern HB_UNITABLE hb_uniTbl_1250;
extern HB_UNITABLE hb_uniTbl_1251;
extern HB_UNITABLE hb_uniTbl_1252;
extern HB_UNITABLE hb_uniTbl_1253;
extern HB_UNITABLE hb_uniTbl_1254;
extern HB_UNITABLE hb_uniTbl_1257;
extern HB_UNITABLE hb_uniTbl_8859_1;
extern HB_UNITABLE hb_uniTbl_8859_1b;
extern HB_UNITABLE hb_uniTbl_8859_2;
extern HB_UNITABLE hb_uniTbl_8859_5;
extern HB_UNITABLE hb_uniTbl_KOI_8;
extern HB_UNITABLE hb_uniTbl_KOI_8U;
extern HB_UNITABLE hb_uniTbl_kamenicky;
extern HB_UNITABLE hb_uniTbl_mazovia;
extern HB_UNITABLE hb_uniTbl_MIK;

extern HB_EXPORT PHB_CODEPAGE  hb_vmCDP( void );
extern HB_EXPORT void          hb_vmSetCDP( PHB_CODEPAGE pCDP );

extern HB_EXPORT BOOL          hb_cdpRegister( PHB_CODEPAGE );
extern HB_EXPORT char *        hb_cdpSelectID( const char * );
extern HB_EXPORT char *        hb_cdpID( void );
extern HB_EXPORT PHB_CODEPAGE  hb_cdpSelect( PHB_CODEPAGE );
extern HB_EXPORT PHB_CODEPAGE  hb_cdpFind( const char * );
extern HB_EXPORT void          hb_cdpTranslate( char *, PHB_CODEPAGE, PHB_CODEPAGE );
extern HB_EXPORT void          hb_cdpnTranslate( char *, PHB_CODEPAGE, PHB_CODEPAGE, ULONG );
extern HB_EXPORT int           hb_cdpcmp( const char *, ULONG, const char *, ULONG, PHB_CODEPAGE, BOOL );
extern HB_EXPORT int           hb_cdpicmp( const char *, ULONG, const char *, ULONG, PHB_CODEPAGE, BOOL );
extern HB_EXPORT int           hb_cdpchrcmp( char, char, PHB_CODEPAGE );
extern HB_EXPORT void          hb_cdpReleaseAll( void );
       
extern HB_EXPORT USHORT        hb_cdpGetU16( PHB_CODEPAGE, BOOL, BYTE );
extern HB_EXPORT UCHAR         hb_cdpGetChar( PHB_CODEPAGE, BOOL, USHORT );
extern HB_EXPORT BOOL          hb_cdpGetFromUTF8( PHB_CODEPAGE, BOOL, BYTE, int *, USHORT * );
extern HB_EXPORT ULONG         hb_cdpStrnToUTF8( PHB_CODEPAGE, BOOL, const BYTE *, ULONG, BYTE * );
extern HB_EXPORT ULONG         hb_cdpStrnToU16( PHB_CODEPAGE, BOOL, const BYTE *, ULONG, BYTE * );
extern HB_EXPORT ULONG         hb_cdpStringInUTF8Length( PHB_CODEPAGE, BOOL, const BYTE *, ULONG );
extern HB_EXPORT ULONG         hb_cdpUTF8ToStrn( PHB_CODEPAGE, BOOL, const BYTE *, ULONG, BYTE *, ULONG );
extern HB_EXPORT ULONG         hb_cdpUTF8StringLength( const BYTE *, ULONG );
extern HB_EXPORT BYTE *        hb_cdpUTF8StringSubstr( const BYTE *, ULONG, ULONG, ULONG, ULONG * );
extern HB_EXPORT ULONG         hb_cdpUTF8StringPeek( const BYTE *, ULONG, ULONG );

HB_EXTERN_END

#else

typedef void * PHB_CODEPAGE;

#endif /* HB_CDP_SUPPORT_OFF */

#endif /* HB_APICDP_H_ */
c:\harbour\include\hbapicls.h
/*
 * $Id: hbapicls.h 8359 2008-04-22 02:51:18Z druzus $
 */

/*
 * Harbour Project source code:
 *    Harbour class API
 *
 * Copyright 2006 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_APICLS_H_
#define HB_APICLS_H_

#include "hbapi.h"

HB_EXTERN_BEGIN

#ifdef _HB_API_INTERNAL_

#define HB_OO_OP_PLUS         0
#define HB_OO_OP_MINUS        1
#define HB_OO_OP_MULT         2
#define HB_OO_OP_DIVIDE       3
#define HB_OO_OP_MOD          4
#define HB_OO_OP_POWER        5
#define HB_OO_OP_INC          6
#define HB_OO_OP_DEC          7
#define HB_OO_OP_EQUAL        8
#define HB_OO_OP_EXACTEQUAL   9
#define HB_OO_OP_NOTEQUAL     10
#define HB_OO_OP_LESS         11
#define HB_OO_OP_LESSEQUAL    12
#define HB_OO_OP_GREATER      13
#define HB_OO_OP_GREATEREQUAL 14
#define HB_OO_OP_ASSIGN       15
#define HB_OO_OP_INSTRING     16
#define HB_OO_OP_INCLUDE      17
#define HB_OO_OP_NOT          18
#define HB_OO_OP_AND          19
#define HB_OO_OP_OR           20
#define HB_OO_OP_ARRAYINDEX   21
#define HB_OO_OP_ENUMINDEX    22
#define HB_OO_OP_ENUMBASE     23
#define HB_OO_OP_ENUMVALUE    24
#define HB_OO_OP_ENUMSTART    25
#define HB_OO_OP_ENUMSKIP     26
#define HB_OO_OP_ENUMSTOP     27

#define HB_OO_MAX_OPERATOR    27

extern void       hb_clsInit( void );           /* initialize Classy/OO system at HVM startup */
extern void       hb_clsDoInit( void );         /* initialize Classy/OO system .prg functions */
extern void       hb_clsReleaseAll( void );     /* releases all defined classes */
extern void       hb_clsIsClassRef( void );     /* classes.c - mark all class internals as used */
extern BOOL       hb_clsHasDestructor( USHORT uiClass );

extern PHB_SYMB   hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pSymMsg, PHB_STACK_STATE pStack ); /* returns the method pointer of an object class */
extern BOOL       hb_objGetVarRef( PHB_ITEM pObject, PHB_SYMB pMessage, PHB_STACK_STATE pStack ); /* create object variable reference */
extern BOOL       hb_objHasOperator( PHB_ITEM pObject, USHORT uiOperator );
extern BOOL       hb_objOperatorCall( USHORT uiOperator, HB_ITEM_PTR pResult, PHB_ITEM pObject, PHB_ITEM pMsgArg1, PHB_ITEM pMsgArg2 );
extern void       hb_objDestructorCall( PHB_ITEM pObject );

#ifndef HB_NO_PROFILER
/* profiler for object management */
extern void       hb_mthAddTime( ULONG );       /* profiler from classes.c */
#endif

#endif

/* class management */
HB_EXPORT extern const char * hb_clsName( USHORT uiClass );
HB_EXPORT extern const char * hb_clsFuncName( USHORT uiClass );
HB_EXPORT extern BOOL       hb_clsIsParent( USHORT uiClass, const char * szParentName ); /* is a class handle inherited from szParentName Class ? */
HB_EXPORT extern USHORT     hb_clsFindClass( const char * szClass, const char * szFunc );

/* object management */
HB_EXPORT extern USHORT     hb_objGetClass( PHB_ITEM pItem );      /* get object class handle */
HB_EXPORT extern USHORT     hb_objSetClass( PHB_ITEM pItem, const char * szClass, const char * szFunc );    /* get object class handle using class name and class function name */
HB_EXPORT extern const char * hb_objGetClsName( PHB_ITEM pObject );  /* retrieves an object class name */
HB_EXPORT extern const char * hb_objGetRealClsName( PHB_ITEM pObject, const char * szString  ); /* retrieves an object class name for a specific message */

HB_EXPORT extern BOOL       hb_objHasMsg( PHB_ITEM pObject, const char * szString ); /* returns TRUE/FALSE whether szString is an existing message for object */
HB_EXPORT extern BOOL       hb_objHasMessage( PHB_ITEM pObject, PHB_DYNS pMessage );
HB_EXPORT extern PHB_ITEM   hb_objSendMsg( PHB_ITEM pObj, const char *sMsg, ULONG ulArg, ... );
HB_EXPORT extern PHB_ITEM   hb_objSendMessage( PHB_ITEM pObj, PHB_DYNS pMessage, ULONG ulArg, ... );

/* send message which allows to set execution context for debugger */
HB_EXPORT extern void       hb_dbgObjSendMessage( int iProcLevel, PHB_ITEM pObject, PHB_ITEM pMessage, int iParamOffset );

/* Harbour equivalent for Clipper internal __mdCreate() */
USHORT hb_clsCreate( USHORT usSize, const char * szClassName );
/* Harbour equivalent for Clipper internal __mdAdd() */
void hb_clsAdd( USHORT usClassH, const char * szMethodName, PHB_FUNC pFuncPtr );
/* Harbour equivalent for Clipper internal __mdAssociate() */
void hb_clsAssociate( USHORT usClassH );


HB_EXTERN_END

#endif /* HB_APICLS_H_ */
c:\harbour\include\hbapidbg.h
/*
 * $Id: hbapidbg.h 7212 2007-04-15 22:20:37Z druzus $
 */

/*
 * Harbour Project source code:
 *    debugger C API
 *
 * Copyright 2007 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_APIDBG_H_
#define HB_APIDBG_H_

#include "hbapi.h"

HB_EXTERN_BEGIN

/*Debugger API */

/* HVM debugger function */
typedef void (*HB_DBGENTRY_FUNC) ( int , int , char *, int , int );
HB_EXPORT extern HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry );
HB_EXPORT extern BOOL hb_dbg_InvokeDebug( BOOL bInvoke );
HB_EXPORT extern ULONG hb_dbg_ProcLevel( void );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarSGet( int nStatic, int nOffset );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarLGet( int iLevel, int iLocal );
HB_EXPORT extern ULONG hb_dbg_vmVarGCount( void );
HB_EXPORT extern PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset );

/* internal debugger function */
HB_EXPORT extern void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, int nFrame );
HB_EXPORT extern void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction );
HB_EXPORT extern void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace );
HB_EXPORT extern void hb_dbgDelBreak( void *handle, int nBreak );
HB_EXPORT extern void hb_dbgDelWatch( void *handle, int nWatch );
HB_EXPORT extern PHB_ITEM hb_dbgGetExpressionValue( void *handle, char *expression );
HB_EXPORT extern PHB_ITEM hb_dbgGetSourceFiles( void *handle );
HB_EXPORT extern PHB_ITEM hb_dbgGetWatchValue( void *handle, int nWatch );
HB_EXPORT extern BOOL hb_dbgIsValidStopLine( void *handle, char *szModule, int nLine );
HB_EXPORT extern void hb_dbgSetCBTrace( void *handle, BOOL bCBTrace );
HB_EXPORT extern void hb_dbgSetGo( void *handle );
HB_EXPORT extern void hb_dbgSetInvoke( void *handle, BOOL ( *pFunInvoke )( void ) );
HB_EXPORT extern void hb_dbgSetNextRoutine( void *handle );
HB_EXPORT extern void hb_dbgSetQuit( void *handle );
HB_EXPORT extern void hb_dbgSetToCursor( void *handle, char *szModule, int nLine );
HB_EXPORT extern void hb_dbgSetTrace( void *handle );
HB_EXPORT extern void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BOOL bTrace );

HB_EXTERN_END

#endif /* HB_APIDBG_H_ */
c:\harbour\include\hbapierr.h
/*
 * $Id: hbapierr.h 8807 2008-06-22 20:55:06Z vszakats $
 */

/*
 * Harbour Project source code:
 * Header file for the Error API
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

#ifndef HB_APIERR_H_
#define HB_APIERR_H_

#include "hbapi.h"
#include "error.ch"

HB_EXTERN_BEGIN

/* Error codes (returned from hb_errLaunch()) */

#define E_BREAK                         0xFFFF
#define E_RETRY                         1
#define E_DEFAULT                       0

/* Error flags */

#define EF_NONE                         0
#define EF_CANRETRY                     1
#define EF_CANSUBSTITUTE                2
#define EF_CANDEFAULT                   4

/* oError:Severity */

/* ... defined in error.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

#define HB_ERR_ARGS_BASEPARAMS          0xFFFFFFFF
#define HB_ERR_ARGS_SELFPARAMS          0xFFFFFFFE

/* pseudo function name in operation description
   (deprecated, kept for compatibility, use HB_ERR_FUNCNAME instead) */
extern const char hb_errFuncName;

#define HB_ERR_FUNCNAME ( ( char * ) 1 )

/* Standard API */

extern PHB_ITEM hb_errGetCargo( PHB_ITEM pError );
extern PHB_ITEM hb_errGetArgs( PHB_ITEM pError );
extern char *   hb_errGetDescription    ( PHB_ITEM pError );
extern char *   hb_errGetFileName       ( PHB_ITEM pError );
extern USHORT   hb_errGetFlags          ( PHB_ITEM pError );
extern USHORT   hb_errGetGenCode        ( PHB_ITEM pError );
extern char *   hb_errGetOperation      ( PHB_ITEM pError );
extern USHORT   hb_errGetOsCode         ( PHB_ITEM pError );
extern USHORT   hb_errGetSeverity       ( PHB_ITEM pError );
extern USHORT   hb_errGetSubCode        ( PHB_ITEM pError );
extern char *   hb_errGetSubSystem      ( PHB_ITEM pError );
extern USHORT   hb_errGetTries          ( PHB_ITEM pError );
extern USHORT   hb_errLaunch            ( PHB_ITEM pError );
extern PHB_ITEM hb_errNew               ( void );
extern PHB_ITEM hb_errPutCargo          ( PHB_ITEM pError, PHB_ITEM pCargo );
extern PHB_ITEM hb_errPutArgsArray      ( PHB_ITEM pError, PHB_ITEM pArgs );
extern PHB_ITEM hb_errPutArgs           ( PHB_ITEM pError, ULONG ulArgCount, ... );
extern PHB_ITEM hb_errPutDescription    ( PHB_ITEM pError, const char * szDescription );
extern PHB_ITEM hb_errPutFileName       ( PHB_ITEM pError, const char * szFileName );
extern PHB_ITEM hb_errPutFlags          ( PHB_ITEM pError, USHORT uiFlags );
extern PHB_ITEM hb_errPutGenCode        ( PHB_ITEM pError, USHORT uiGenCode );
extern PHB_ITEM hb_errPutOperation      ( PHB_ITEM pError, const char * szOperation );
extern PHB_ITEM hb_errPutOsCode         ( PHB_ITEM pError, USHORT uiOsCode );
extern PHB_ITEM hb_errPutSeverity       ( PHB_ITEM pError, USHORT uiSeverity );
extern PHB_ITEM hb_errPutSubCode        ( PHB_ITEM pError, USHORT uiSubCode );
extern PHB_ITEM hb_errPutSubSystem      ( PHB_ITEM pError, const char * szSubSystem );
extern PHB_ITEM hb_errPutTries          ( PHB_ITEM pError, USHORT uiTries );
extern void     hb_errRelease           ( PHB_ITEM pError );

/* Harbour additions */

extern void     hb_errInit              ( void );
extern void     hb_errExit              ( void );

extern HB_EXPORT PHB_ITEM  hb_errLaunchSubst( PHB_ITEM pError );

extern HB_EXPORT PHB_ITEM  hb_errRT_New( USHORT uiSeverity,
                                         const char * szSubSystem,
                                         ULONG  ulGenCode,
                                         ULONG  ulSubCode,
                                         const char * szDescription,
                                         const char * szOperation,
                                         USHORT uiOsCode,
                                         USHORT uiFlags );

extern HB_EXPORT PHB_ITEM  hb_errRT_New_Subst( USHORT uiSeverity,
                                         const char * szSubSystem,
                                         ULONG  ulGenCode,
                                         ULONG  ulSubCode,
                                         const char * szDescription,
                                         const char * szOperation,
                                         USHORT uiOsCode,
                                         USHORT uiFlags );

extern HB_EXPORT PHB_ITEM  hb_errRT_SubstParams( const char *szSubSystem, ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation );
       
extern HB_EXPORT USHORT    hb_errRT_BASE        ( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... );
extern HB_EXPORT USHORT    hb_errRT_BASE_Ext1   ( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... );
extern HB_EXPORT PHB_ITEM  hb_errRT_BASE_Subst  ( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... );
extern HB_EXPORT void      hb_errRT_BASE_SubstR ( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... );
extern HB_EXPORT USHORT    hb_errRT_TERM        ( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOSCode, USHORT uiFlags );
extern HB_EXPORT USHORT    hb_errRT_DBCMD       ( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation );
extern HB_EXPORT USHORT    hb_errRT_DBCMD_Ext   ( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiFlags );
       
extern HB_EXPORT void      hb_errInternal       ( ULONG ulIntCode, const char * szText, const char * szPar1, const char * szPar2 );

/* Low-level error handling */
struct HB_ERROR_INFO_;   /* forward declaration */
#define HB_ERROR_HANDLE( hbfunc )   HB_ITEM_PTR hbfunc( struct HB_ERROR_INFO_ * ErrorInfo )
typedef HB_ERROR_HANDLE( HB_ERROR_HANDLER );
typedef HB_ERROR_HANDLER * HB_ERROR_HANDLER_PTR;

typedef struct HB_ERROR_INFO_
{
   HB_ERROR_HANDLER_PTR Func;
   HB_ITEM_PTR Error;
   void * Cargo;
   struct HB_ERROR_INFO_ * Previous;
   HB_ITEM_PTR ErrorBlock;
} HB_ERROR_INFO, * HB_ERROR_INFO_PTR;

/* set/get current error handler */
extern HB_EXPORT HB_ERROR_INFO_PTR  hb_errorHandler( HB_ERROR_INFO_PTR pNewHandler );

/* current errorblock item */
extern HB_EXPORT PHB_ITEM hb_errorBlock( void );

HB_EXTERN_END

#endif /* HB_APIERR_H_ */
c:\harbour\include\hbapifs.h
/*
 * $Id: hbapifs.h 9530 2008-10-02 12:34:36Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Filesys API
 *
 * Copyright 1999 David G. Holm 
 * 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.
 *
 */

#ifndef HB_APIFS_H_
#define HB_APIFS_H_

#include "hbapi.h"
#include "fileio.ch"

HB_EXTERN_BEGIN

#define FS_ERROR ( HB_FHANDLE ) F_ERROR

/* File locking flags */
#define FL_LOCK       0x0000   /* Lock a region   */
#define FL_UNLOCK     0x0001   /* Unlock a region */
#define FL_MASK       0x00FF   /* Mask for lock type */

/* Extended file locking flags */
#define FLX_EXCLUSIVE 0x0000   /* Exclusive lock  */
#define FLX_SHARED    0x0100   /* Shared lock     */
#define FLX_WAIT      0x0200   /* Wait for lock until success */

/* File inheritance flags */
#define FO_INHERITED  0x0000   /* Spawned processes can inherit this file handle     */
#define FO_PRIVATE    0x0080   /* Spawned processes can not inherit this file handle */

/* Extended file open mode flags */
#define FXO_TRUNCATE  0x0100   /* Create (truncate if exists) */
#define FXO_APPEND    0x0200   /* Create (append if exists)   */
#define FXO_UNIQUE    0x0400   /* Create unique file FO_EXCL ??? */
#define FXO_FORCEEXT  0x0800   /* Force default extension     */
#define FXO_DEFAULTS  0x1000   /* Use SET command defaults    */
#define FXO_DEVICERAW 0x2000   /* Open devices in raw mode    */
/* xHarbour extension */
#define FXO_SHARELOCK 0x4000   /* emulate DOS SH_DENY* mode in POSIX OS */
#define FXO_COPYNAME  0x8000   /* copy final szPath into pFilename */

/* File attributes flags */
#define HB_FA_ALL             0x00000000

#define HB_FA_READONLY        0x00000001     /* R */
#define HB_FA_HIDDEN          0x00000002     /* H */
#define HB_FA_SYSTEM          0x00000004     /* S */
#define HB_FA_LABEL           0x00000008     /* V */
#define HB_FA_DIRECTORY       0x00000010     /* D | S_ISDIR() */
#define HB_FA_ARCHIVE         0x00000020     /* A | S_ISREG() */
#define HB_FA_DEVICE          0x00000040     /* I | S_ISBLK() */
#define HB_FA_NORMAL          0x00000080     /*   */

#define HB_FA_TEMPORARY       0x00000100     /* T | S_ISFIFO()??? */
#define HB_FA_SPARSE          0x00000200     /* P | S_ISSOCK()??? */
#define HB_FA_REPARSE         0x00000400     /* L | S_ISLNK() */
#define HB_FA_COMPRESSED      0x00000800     /* C | S_ISCHR()??? */
#define HB_FA_OFFLINE         0x00001000     /* O */
#define HB_FA_NOTINDEXED      0x00002000     /* X */
#define HB_FA_ENCRYPTED       0x00004000     /* E */
#define HB_FA_VOLCOMP         0x00008000     /* M volume supports compression. */

/* these definitions should be cleared,
 * now they only help to clean lower level code
 */
#define HB_FA_FIFO            HB_FA_TEMPORARY   /* S_ISFIFO() */
#define HB_FA_FILE            HB_FA_ARCHIVE     /* S_ISREG() */
#define HB_FA_BLKDEVICE       HB_FA_DEVICE      /* S_ISBLK() */
#define HB_FA_CHRDEVICE       HB_FA_COMPRESSED  /* S_ISCHR() */
#define HB_FA_SOCKET          HB_FA_SPARSE      /* S_ISSOCK() */
#define HB_FA_LINK            HB_FA_REPARSE     /* S_ISLNK() */

/* POSIX file permission */
#define HB_FA_SUID            0x08000000     /* set user ID on execution */
#define HB_FA_SGID            0x04000000     /* set group ID on execution */
#define HB_FA_SVTX            0x02000000     /* sticky bit */
#define HB_FA_RUSR            0x01000000     /* read by owner */
#define HB_FA_WUSR            0x00800000     /* write by owner */
#define HB_FA_XUSR            0x00400000     /* execute/search by owner */
#define HB_FA_RGRP            0x00200000     /* read by group */
#define HB_FA_WGRP            0x00100000     /* write by group */
#define HB_FA_XGRP            0x00080000     /* execute/search by group */
#define HB_FA_ROTH            0x00040000     /* read by others */
#define HB_FA_WOTH            0x00020000     /* write by others */
#define HB_FA_XOTH            0x00010000     /* execute/search by others */

#define HB_FA_UGVS            ( HB_FA_SUID | HB_FA_SGID | HB_FA_SVTX )
#define HB_FA_RWXU            ( HB_FA_RUSR | HB_FA_WUSR | HB_FA_XUSR )
#define HB_FA_RWXG            ( HB_FA_RGRP | HB_FA_WGRP | HB_FA_XGRP )
#define HB_FA_RWXO            ( HB_FA_ROTH | HB_FA_WOTH | HB_FA_XOTH )

/* macros to convert Harbour attributes to POSIX ones */
#define HB_FA_POSIX_SID(a)    ( ( ( ( a ) & HB_FA_SVTX ) ? S_ISVTX : 0 ) | \
                                ( ( ( a ) & HB_FA_SGID ) ? S_ISGID : 0 ) | \
                                ( ( ( a ) & HB_FA_SUID ) ? S_ISUID : 0 ) )
#define HB_FA_POSIX_OTH(a)    ( ( ( ( a ) & HB_FA_XOTH ) ? S_IXOTH : 0 ) | \
                                ( ( ( a ) & HB_FA_WOTH ) ? S_IWOTH : 0 ) | \
                                ( ( ( a ) & HB_FA_ROTH ) ? S_IROTH : 0 ) )
#define HB_FA_POSIX_GRP(a)    ( ( ( ( a ) & HB_FA_XGRP ) ? S_IXGRP : 0 ) | \
                                ( ( ( a ) & HB_FA_WGRP ) ? S_IWGRP : 0 ) | \
                                ( ( ( a ) & HB_FA_RGRP ) ? S_IRGRP : 0 ) )
#define HB_FA_POSIX_USR(a)    ( ( ( ( a ) & HB_FA_XUSR ) ? S_IXUSR : 0 ) | \
                                ( ( ( a ) & HB_FA_WUSR ) ? S_IWUSR : 0 ) | \
                                ( ( ( a ) & HB_FA_RUSR ) ? S_IRUSR : 0 ) )

#define HB_FA_POSIX_ATTR(a)   ( HB_FA_POSIX_OTH(a) | \
                                HB_FA_POSIX_GRP(a) | \
                                HB_FA_POSIX_USR(a) | \
                                HB_FA_POSIX_SID(a) )

extern HB_EXPORT BOOL       hb_fsChDir      ( BYTE * pszDirName ); /* change working directory */
extern HB_EXPORT USHORT     hb_fsChDrv      ( BYTE nDrive ); /* change working drive */
extern HB_EXPORT void       hb_fsClose      ( HB_FHANDLE hFileHandle ); /* close a file */
extern HB_EXPORT void       hb_fsCommit     ( HB_FHANDLE hFileHandle ); /* commit updates of a file */
extern HB_EXPORT HB_FHANDLE hb_fsCreate     ( BYTE * pszFileName, ULONG ulAttr ); /* create a file */
extern HB_EXPORT HB_FHANDLE hb_fsCreateEx   ( BYTE * pszFilename, ULONG ulAttr, USHORT uiFlags ); /* create a file, with specific open mode */
extern HB_EXPORT HB_FHANDLE hb_fsCreateTemp ( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName ); /* create a temporary file from components */
extern HB_EXPORT BYTE *     hb_fsCurDir     ( USHORT uiDrive ); /* retrieve a static pointer containing current directory for specified drive */
extern HB_EXPORT USHORT     hb_fsCurDirBuff ( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ); /* copy current directory for given drive into a buffer */
extern HB_EXPORT BYTE       hb_fsCurDrv     ( void ); /* retrieve current drive number */
extern HB_EXPORT BOOL       hb_fsDelete     ( BYTE * pszFileName ); /* delete a file */
extern HB_EXPORT BOOL       hb_fsEof        ( HB_FHANDLE hFileHandle ); /* determine if an open file is position at end-of-file */
extern HB_EXPORT USHORT     hb_fsError      ( void ); /* retrieve file system error */
extern HB_EXPORT USHORT     hb_fsOsError    ( void ); /* retrieve system dependant file system error */
extern HB_EXPORT BOOL       hb_fsFile       ( BYTE * pszFileName ); /* determine if a file exists */
extern HB_EXPORT BOOL       hb_fsIsDirectory( BYTE * pFilename );
extern HB_EXPORT HB_FOFFSET hb_fsFSize      ( BYTE * pszFileName, BOOL bUseDirEntry ); /* determine the size of a file */
extern HB_EXPORT HB_FHANDLE hb_fsExtOpen    ( BYTE * pszFileName, BYTE * pDefExt,
                                              USHORT uiFlags, BYTE * pPaths, PHB_ITEM pError ); /* open a file using default extension and a list of paths */
extern HB_EXPORT BYTE *     hb_fsExtName    ( BYTE * pFilename, BYTE * pDefExt,
                                              USHORT uiExFlags, BYTE * pPaths ); /* convert file name for hb_fsExtOpen, caller must free the returned buffer */
extern HB_EXPORT USHORT     hb_fsIsDrv      ( BYTE nDrive ); /* determine if a drive number is a valid drive */
extern HB_EXPORT BOOL       hb_fsIsDevice   ( HB_FHANDLE hFileHandle ); /* determine if a file is attached to a device (console?) */
extern HB_EXPORT BOOL       hb_fsLock       ( HB_FHANDLE hFileHandle, ULONG ulStart, ULONG ulLength, USHORT uiMode ); /* request a lock on a portion of a file */
extern HB_EXPORT BOOL       hb_fsLockLarge  ( HB_FHANDLE hFileHandle, HB_FOFFSET ulStart,
                                              HB_FOFFSET ulLength, USHORT uiMode ); /* request a lock on a portion of a file using 64bit API */
extern HB_EXPORT BOOL       hb_fsMkDir      ( BYTE * pszDirName ); /* create a directory */
extern HB_EXPORT HB_FHANDLE hb_fsOpen       ( BYTE * pszFileName, USHORT uiFlags ); /* open a file */
extern HB_EXPORT USHORT     hb_fsRead       ( HB_FHANDLE hFileHandle, BYTE * pBuff, USHORT ulCount ); /* read contents of a file into a buffer (<=64K) */
extern HB_EXPORT ULONG      hb_fsReadLarge  ( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ); /* read contents of a file into a buffer (>64K) */
extern HB_EXPORT ULONG      hb_fsReadAt     ( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset ); /* read from given offset contents of a file into a buffer (>64K) */
extern HB_EXPORT BOOL       hb_fsRmDir      ( BYTE * pszDirName ); /* remove a directory */
extern HB_EXPORT BOOL       hb_fsRename     ( BYTE * pszOldName, BYTE * pszNewName ); /* rename a file */
extern HB_EXPORT ULONG      hb_fsSeek       ( HB_FHANDLE hFileHandle, LONG lOffset, USHORT uiMode ); /* reposition an open file */
extern HB_EXPORT HB_FOFFSET hb_fsSeekLarge  ( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset, USHORT uiFlags ); /* reposition an open file using 64bit API */
extern HB_EXPORT ULONG      hb_fsTell       ( HB_FHANDLE hFileHandle ); /* retrieve the current position of a file */
extern HB_EXPORT BOOL       hb_fsSetDevMode ( HB_FHANDLE hFileHandle, USHORT uiDevMode ); /* change the device mode of a file (text/binary) */
extern HB_EXPORT BOOL       hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec );
extern HB_EXPORT BOOL       hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec );
extern HB_EXPORT BOOL       hb_fsGetAttr    ( BYTE * pszFileName, ULONG * pulAttr );
extern HB_EXPORT BOOL       hb_fsSetAttr    ( BYTE * pszFileName, ULONG ulAttr );
extern HB_EXPORT void       hb_fsSetError   ( USHORT uiError ); /* set the file system DOS error number */
extern HB_EXPORT void       hb_fsSetIOError ( BOOL fResult, USHORT uiOperation ); /* set the file system error number after IO operation */
extern HB_EXPORT BOOL       hb_fsTruncAt    ( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset ); /* truncate file to given size */
extern HB_EXPORT USHORT     hb_fsWrite      ( HB_FHANDLE hFileHandle, const BYTE * pBuff, USHORT ulCount ); /* write to an open file from a buffer (<=64K) */
extern HB_EXPORT ULONG      hb_fsWriteLarge ( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount ); /* write to an open file from a buffer (>64K) */
extern HB_EXPORT ULONG      hb_fsWriteAt    ( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset ); /* write to an open file at given offset from a buffer (>64K) */
extern HB_EXPORT HB_FHANDLE hb_fsPOpen      ( BYTE * pFilename, BYTE * pMode );
extern HB_EXPORT HB_FHANDLE hb_fsGetOsHandle( HB_FHANDLE hFileHandle );
extern HB_EXPORT USHORT     hb_fsGetFError  ( void ); /* get FERROR() flag */
extern HB_EXPORT void       hb_fsSetFError  ( USHORT uiError ); /* set FERROR() flag */
extern HB_EXPORT BOOL       hb_fsFileExists ( const char * pszFileName ); /* check if a file exists (wildcard chars not accepted). */
extern HB_EXPORT BOOL       hb_fsDirExists  ( const char * pszDirName ); /* check if a directory exists (wildcard chars not accepted). */

#define hb_fsFLock( h, s, l )   hb_fsLock( h, s, l, FL_LOCK )
#define hb_fsFUnlock( h, s, l ) hb_fsLock( h, s, l, FL_UNLOCK )

#if defined( HB_OS_UNIX_COMPATIBLE ) && !defined( HB_USE_SHARELOCKS_OFF )
#  define HB_USE_SHARELOCKS
#  define HB_SHARELOCK_POS          0x7fffffffUL
#  define HB_SHARELOCK_SIZE         0x1UL
#  if defined( HB_USE_BSDLOCKS_OFF )
#     undef HB_USE_BSDLOCKS
#  elif defined( HB_OS_LINUX ) && \
        !defined( __WATCOMC__ ) && !defined( HB_USE_BSDLOCKS )
      /* default usage of BSD locks in *BSD systems for emulating
       * DOS/Windows DENY_* flags has been disabled because tests
       * on FreeBSD 6.2 and MacOSX shows that this implementation
       * can create self deadlock when used simultaneously with
       * POSIX locks - thanks to Phil and Lorenzo for locating the
       * problem and tests [druzus]
       */
#     define HB_USE_BSDLOCKS
#  endif
#endif

#define HB_MAX_DRIVE_LENGTH   10
#define HB_MAX_FILE_EXT       10

/* Filename support */
typedef struct
{
   const char * szPath;
   const char * szName;
   const char * szExtension;
   const char * szDrive;
   char   szBuffer[ _POSIX_PATH_MAX + HB_MAX_DRIVE_LENGTH + 4 ];
} HB_FNAME, * PHB_FNAME, * HB_FNAME_PTR;

extern HB_EXPORT PHB_FNAME  hb_fsFNameSplit( const char * pszFileName ); /* Split given filename into path, name and extension */
extern HB_EXPORT char *     hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName ); /* This function joins path, name and extension into a string with a filename */

/* Searchable path support */
typedef struct _HB_PATHNAMES
{
   char * szPath;
   struct _HB_PATHNAMES * pNext;
   BOOL   fFree;
} HB_PATHNAMES;

extern HB_EXPORT void       hb_fsAddSearchPath( const char * szPath, HB_PATHNAMES ** pSearchList );
extern HB_EXPORT void       hb_fsFreeSearchPath( HB_PATHNAMES * pSearchList );
       
extern HB_EXPORT BOOL       hb_spFile( BYTE * pFilename, BYTE * pRetPath );
extern HB_EXPORT HB_FHANDLE hb_spOpen( BYTE * pFilename, USHORT uiFlags );
extern HB_EXPORT HB_FHANDLE hb_spCreate( BYTE * pFilename, ULONG ulAttr );
extern HB_EXPORT HB_FHANDLE hb_spCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags );

/* File Find API structure */
typedef struct
{
   char        szName[ _POSIX_PATH_MAX + 1 ];
   LONG        lDate;
   char        szDate[ 9 ]; /* in YYYYMMDD format */
   char        szTime[ 9 ]; /* in HH:MM:SS format */
   ULONG       attr;
   HB_FOFFSET  size;

   /* Private */

   const char * pszFileMask;
   ULONG  attrmask;
   BOOL   bFirst;

   void * info; /* Pointer to the platform specific find info */

} HB_FFIND, * PHB_FFIND;

/* File Find API functions */
extern HB_EXPORT PHB_FFIND hb_fsFindFirst( const char * pszFileName, ULONG ulAttrMask );
extern HB_EXPORT BOOL      hb_fsFindNext( PHB_FFIND ffind );
extern HB_EXPORT void      hb_fsFindClose( PHB_FFIND ffind );

/* Misc helper functions */
extern ULONG               hb_fsAttrFromRaw( ULONG raw_attr );
extern ULONG               hb_fsAttrToRaw( ULONG  ulAttr );
extern ULONG               hb_fsAttrEncode( const char * szAttr );
extern char *              hb_fsAttrDecode( ULONG  ulAttr, char * szAttr );
extern HB_EXPORT BYTE *    hb_fsNameConv( BYTE * szFileName, BOOL * pfFree );
extern HB_EXPORT BOOL      hb_fsMaxFilesError( void );

/* Harbour file functions with shared file handles and locks
 * (buffers in the future)
 */
#ifndef _HB_FILE_INTERNAL_
   typedef void * PHB_FILE;
#endif
HB_EXPORT PHB_FILE   hb_fileExtOpen( BYTE * pFilename, BYTE * pDefExt,
                                     USHORT uiExFlags, BYTE * pPaths,
                                     PHB_ITEM pError );
HB_EXPORT PHB_FILE   hb_fileCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix,
                                        ULONG ulAttr, BYTE * pszName );
HB_EXPORT void       hb_fileClose( PHB_FILE pFile );
HB_EXPORT BOOL       hb_fileLock( PHB_FILE pFile, HB_FOFFSET ulStart, HB_FOFFSET ulLen, int iType );
HB_EXPORT ULONG      hb_fileReadAt( PHB_FILE pFile, BYTE * buffer, ULONG ulSize, HB_FOFFSET llOffset );
HB_EXPORT ULONG      hb_fileWriteAt( PHB_FILE pFile, const BYTE * buffer, ULONG ulSize, HB_FOFFSET llOffset );
HB_EXPORT BOOL       hb_fileTruncAt( PHB_FILE pFile, HB_FOFFSET llOffset );
HB_EXPORT HB_FOFFSET hb_fileSize( PHB_FILE pFile );
HB_EXPORT void       hb_fileCommit( PHB_FILE pFile );
HB_EXPORT HB_FHANDLE hb_fileHandle( PHB_FILE pFile );

/* wrapper to fopen() which calls hb_fsNameConv() */
extern FILE * hb_fopen( const char *path, const char *mode );

#ifdef HB_LEGACY_LEVEL
/* Compatibility. Obsolete. */
extern HB_EXPORT BYTE *    hb_fileNameConv( char * str );
#endif

HB_EXTERN_END

#endif /* HB_APIFS_H_ */
c:\harbour\include\hbapigt.h
/*
 * $Id: hbapigt.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Terminal API
 *
 * Copyright 1999 {list of individual authors and e-mail addresses}
 * 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.
 *
 */

/*
 * The following parts are Copyright of the individual authors.
 * www - http://www.harbour-project.org
 *
 * Copyright 1999 David G. Holm 
 *    Keyboard related declarations
 *    Cursor declarations
 * See above for licensing terms.
 *
 * Copyright 1999-2001 Viktor Szakats 
 *    Mouse related declarations
 *    Undocumented GT API declarations
 *
 * Copyright 2005 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
 *    Internal GT code reimplemented in differ way
 *
 * See doc/license.txt for licensing terms.
 *
 */

#ifndef HB_APIGT_H_
#define HB_APIGT_H_

#include "hbapi.h"

HB_EXTERN_BEGIN

#include "inkey.ch"
#include "setcurs.ch"
#include "hbgtinfo.ch"

/* maximum length of color string */
#define HB_CLRSTR_LEN           64

#ifdef HB_LEGACY_LEVEL
   #define CLR_STRLEN              HB_CLRSTR_LEN
#endif

/* attributes for color strings, these are the same as the ones in color.ch
   but prefixed with HB_ to avoid collision. */
#define HB_CLR_STANDARD         0
#define HB_CLR_ENHANCED         1
#define HB_CLR_BORDER           2
#define HB_CLR_BACKGROUND       3
#define HB_CLR_UNSELECTED       4
#define HB_CLR_MAX_             HB_CLR_UNSELECTED


/* strings for borders (same as box.ch, but defined for use by C) */

/* Note. This part will never be used, but is being kept in the source,
         so that if you use code page 437, you can see what the line
         draw characters are supposed to look like.
                                01234567
#define _B_SINGLE              "ÚÄ¿³ÙÄÀ³"
#define _B_DOUBLE              "ÉÍ»º¼ÍȺ"
#define _B_SINGLE_DOUBLE       "ÖÄ·º½ÄÓº"
#define _B_DOUBLE_SINGLE       "Õ͸³¾ÍÔ³"
#define HB_B_SINGLE_V          '³'
#define HB_B_SINGLE_H          'Ä'
#define HB_B_DOUBLE_V          'º'
#define HB_B_DOUBLE_H          'Í'
*/
#define _B_SINGLE              "\xDA\xC4\xBF\xB3\xD9\xC4\xC0\xB3"
#define _B_DOUBLE              "\xC9\xCD\xBB\xBA\xBC\xCD\xC8\xBA"
#define _B_SINGLE_DOUBLE       "\xD6\xC4\xB7\xBA\xBD\xC4\xD3\xBA"
#define _B_DOUBLE_SINGLE       "\xD5\xCD\xB8\xB3\xBE\xCD\xD4\xB3"
#define HB_B_SINGLE_V          '\xB3'
#define HB_B_SINGLE_H          '\xC4'
#define HB_B_DOUBLE_V          '\xBA'
#define HB_B_DOUBLE_H          '\xCD'

#if defined( HB_COMPAT_C53 ) && !defined( HB_C52_STRICT )
#  define HB_DEFAULT_INKEY_BUFSIZE  50
#else
#  define HB_DEFAULT_INKEY_BUFSIZE  15
#endif


/* structure used to pass/receive parameters in hb_gtInfo() */

typedef struct
{
   PHB_ITEM pNewVal;
   PHB_ITEM pResult;
   PHB_ITEM pNewVal2;
} HB_GT_INFO, * PHB_GT_INFO;

/* Public interface. These should never change, only be added to. */

extern HB_EXPORT ERRCODE hb_gtInit( HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr );
extern HB_EXPORT ERRCODE hb_gtExit( void );
extern HB_EXPORT ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, BYTE * pbyFrame );
extern HB_EXPORT ERRCODE hb_gtBoxD( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight );
extern HB_EXPORT ERRCODE hb_gtBoxS( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight );
extern HB_EXPORT ERRCODE hb_gtColorSelect( USHORT uiColorIndex );
extern HB_EXPORT int     hb_gtColorToN( char * szColorString );
extern HB_EXPORT ERRCODE hb_gtColorsToString( int * pColors, int iColorCount, char * pszColorString, int iBufSize );
extern HB_EXPORT ERRCODE hb_gtDispBegin( void );
extern HB_EXPORT USHORT  hb_gtDispCount( void );
extern HB_EXPORT ERRCODE hb_gtDispEnd( void );
extern HB_EXPORT ERRCODE hb_gtDrawShadow( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr );
extern HB_EXPORT ERRCODE hb_gtGetBlink( BOOL * pbBlink );
extern HB_EXPORT ERRCODE hb_gtGetColorStr( char * pszColorString );
extern HB_EXPORT ERRCODE hb_gtGetCursor( USHORT * puiCursorShape );
extern HB_EXPORT ERRCODE hb_gtGetPos( SHORT * piRow, SHORT * piCol );
extern HB_EXPORT BOOL    hb_gtIsColor( void );
extern HB_EXPORT USHORT  hb_gtMaxCol( void );
extern HB_EXPORT USHORT  hb_gtMaxRow( void );
extern HB_EXPORT ERRCODE hb_gtPostExt( void );
extern HB_EXPORT ERRCODE hb_gtPreExt( void );
extern HB_EXPORT ERRCODE hb_gtSuspend( void ); /* prepare the reminal for shell output */
extern HB_EXPORT ERRCODE hb_gtResume( void ); /* resume the terminal after the shell output */
extern HB_EXPORT int     hb_gtReadKey( int iEventMask );
extern HB_EXPORT ERRCODE hb_gtRectSize( int iTop, int iLeft, int iBottom, int iRight, ULONG * puiBuffSize );
extern HB_EXPORT ERRCODE hb_gtRepChar( USHORT uiRow, USHORT uiCol, BYTE byChar, USHORT uiCount );
extern HB_EXPORT ERRCODE hb_gtSave( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, void * pScrBuff );
extern HB_EXPORT ERRCODE hb_gtRest( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, void * pScrBuff );
extern HB_EXPORT ERRCODE hb_gtGetChar( USHORT uiRow, USHORT uiCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar );
extern HB_EXPORT ERRCODE hb_gtPutChar( USHORT uiRow, USHORT uiCol, BYTE bColor, BYTE bAttr, USHORT usChar );
extern HB_EXPORT ERRCODE hb_gtBeginWrite( void );
extern HB_EXPORT ERRCODE hb_gtEndWrite( void );
extern HB_EXPORT ERRCODE hb_gtScrDim( USHORT * puiHeight, USHORT * puiWidth );
extern HB_EXPORT ERRCODE hb_gtScroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, SHORT iRows, SHORT iCols );
extern HB_EXPORT ERRCODE hb_gtScrollUp( USHORT uiRows );
extern HB_EXPORT ERRCODE hb_gtSetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr );
extern HB_EXPORT ERRCODE hb_gtSetBlink( BOOL bBlink );
extern HB_EXPORT ERRCODE hb_gtSetColorStr( const char * pszColorString );
extern HB_EXPORT ERRCODE hb_gtSetCursor( USHORT uiCursorShape );
extern HB_EXPORT ERRCODE hb_gtSetMode( USHORT uiRows, USHORT uiCols );
extern HB_EXPORT ERRCODE hb_gtSetPos( SHORT iRow, SHORT iCol );
extern HB_EXPORT ERRCODE hb_gtSetSnowFlag( BOOL bNoSnow );
extern HB_EXPORT ERRCODE hb_gtTone( double dFrequency, double dDuration );
extern HB_EXPORT ERRCODE hb_gtWrite( BYTE * pbyStr, ULONG ulLen );
extern HB_EXPORT ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pbyStr, ULONG ulLen );
extern HB_EXPORT ERRCODE hb_gtWriteCon( BYTE * pbyStr, ULONG ulLen );
extern HB_EXPORT const char * hb_gtVersion( int iType );
extern HB_EXPORT ERRCODE hb_gtOutStd( BYTE * pbyStr, ULONG ulLen );
extern HB_EXPORT ERRCODE hb_gtOutErr( BYTE * pbyStr, ULONG ulLen );
extern HB_EXPORT ERRCODE hb_gtSetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox );
extern HB_EXPORT ERRCODE hb_gtSetKeyCP( char * pszTermCDP, char * pszHostCDP );
extern HB_EXPORT ERRCODE hb_gtInfo( int iType, PHB_GT_INFO pInfo );
extern HB_EXPORT int     hb_gtAlert( PHB_ITEM pMessage, PHB_ITEM pOptions, int iClrNorm, int iClrHigh, double dDelay );
extern HB_EXPORT int     hb_gtSetFlag( int iType, int iNewValue );
extern HB_EXPORT int     hb_gtGetCurrColor( void );
extern HB_EXPORT int     hb_gtGetClearColor( void );
extern HB_EXPORT ERRCODE hb_gtSetClearColor( int );
extern HB_EXPORT int     hb_gtGetClearChar( void );
extern HB_EXPORT ERRCODE hb_gtSetClearChar( int );
extern HB_EXPORT ERRCODE hb_gtGetScrChar( int iRow, int iCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar );
extern HB_EXPORT ERRCODE hb_gtPutScrChar( int iRow, int iCol, BYTE bColor, BYTE bAttr, USHORT usChar );
extern HB_EXPORT ERRCODE hb_gtFlush( void );
extern HB_EXPORT ERRCODE hb_gtGetPosEx( int * piRow, int * piCol );
extern HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, BYTE bColor, BYTE bChar, int iRows, int iCols );
extern HB_EXPORT ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor );
extern HB_EXPORT int     hb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor );
extern HB_EXPORT ERRCODE hb_gtGfxText( int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth );

extern HB_EXPORT BOOL    hb_mouseIsPresent( void );
extern HB_EXPORT BOOL    hb_mouseGetCursor( void );
extern HB_EXPORT void    hb_mouseSetCursor( BOOL bVisible );
extern HB_EXPORT int     hb_mouseCol( void );
extern HB_EXPORT int     hb_mouseRow( void );
extern HB_EXPORT void    hb_mouseGetPos( int * piRow, int * piCol );
extern HB_EXPORT void    hb_mouseSetPos( int iRow, int iCol );
extern HB_EXPORT void    hb_mouseSetBounds( int iTop, int iLeft, int iBottom, int iRight );
extern HB_EXPORT void    hb_mouseGetBounds( int * piTop, int * piLeft, int * piBottom, int * piRight );
extern HB_EXPORT int     hb_mouseStorageSize( void );
extern HB_EXPORT void    hb_mouseSaveState( BYTE * pBuffer );
extern HB_EXPORT void    hb_mouseRestoreState( BYTE * pBuffer );
extern HB_EXPORT int     hb_mouseGetDoubleClickSpeed( void );
extern HB_EXPORT void    hb_mouseSetDoubleClickSpeed( int iSpeed );
extern HB_EXPORT int     hb_mouseCountButton( void );
extern HB_EXPORT BOOL    hb_mouseButtonState( int iButton );
extern HB_EXPORT BOOL    hb_mouseButtonPressed( int iButton, int * piRow, int * piCol );
extern HB_EXPORT BOOL    hb_mouseButtonReleased( int iButton, int * piRow, int * piCol );
extern HB_EXPORT int     hb_mouseReadKey( int iEventMask );

typedef struct
{
   int   iTop;
   int   iLeft;
   int   iBottom;
   int   iRight;
} HB_GT_RECT;
typedef HB_GT_RECT * PHB_GT_RECT;

typedef struct
{
   int   iRow;
   int   iCol;
} HB_GT_CORD;
typedef HB_GT_CORD * PHB_GT_CORD;

/* Undocumented CA-Cl*pper 5.x GT API calls */

#define HB_GT_WND void
#define HB_GT_RGB void
#define HB_GT_SLR void

extern HB_EXPORT void    hb_gtWCreate( HB_GT_RECT * rect, HB_GT_WND ** wnd );
extern HB_EXPORT void    hb_gtWDestroy( HB_GT_WND * wnd );
extern HB_EXPORT BOOL    hb_gtWFlash( void );
extern HB_EXPORT void    hb_gtWApp( HB_GT_WND ** wnd );
extern HB_EXPORT void    hb_gtWCurrent( HB_GT_WND * wnd );
extern HB_EXPORT void    hb_gtWPos( HB_GT_WND * wnd, HB_GT_RECT * rect );
extern HB_EXPORT BOOL    hb_gtWVis( HB_GT_WND * wnd, USHORT uiStatus );

extern HB_EXPORT ERRCODE hb_gtSLR( HB_GT_SLR * pSLR ); /* System Level Request */
extern HB_EXPORT ERRCODE hb_gtModalRead( void * );
extern HB_EXPORT ERRCODE hb_gtFlushCursor( void );
extern HB_EXPORT ERRCODE hb_gtSetColor( HB_GT_RGB * color );
extern HB_EXPORT ERRCODE hb_gtGetColor( HB_GT_RGB * color );
extern HB_EXPORT ERRCODE hb_gtSetBorder( HB_GT_RGB * color );


/* Keyboard related declarations */

#define HB_BREAK_FLAG 256 /* 256, because that's what DJGPP returns Ctrl+Break as.
                             Clipper has no key code 256, so it may as well be
                             used for all the Harbour builds that need it */

#define INKEY_RAW 256   /* Minimally Decoded Keyboard Events */

/* Harbour keyboard support functions */
extern HB_EXPORT int     hb_inkey( BOOL bWait, double dSeconds, int iEvenMask ); /* Wait for keyboard input */
extern HB_EXPORT void    hb_inkeyPut( int ch );          /* Inserts an inkey code into the keyboard buffer */
extern HB_EXPORT void    hb_inkeyIns( int ch );          /* Inserts an inkey code into the keyboard buffer */
extern HB_EXPORT int     hb_inkeyLast( int iEvenMask );  /* Return the value of the last key that was extracted */
extern HB_EXPORT int     hb_inkeyNext( int iEvenMask );  /* Return the next key without extracting it */
extern HB_EXPORT void    hb_inkeyPoll( void );           /* Poll the console keyboard to stuff the Harbour buffer */
extern HB_EXPORT void    hb_inkeyReset( void );          /* Reset the Harbour keyboard buffer */
extern HB_EXPORT void    hb_inkeySetCancelKeys( int CancelKey, int CancelKeyEx ); /* Set keycodes for Cancel key (usually K_ALT_C) */
extern HB_EXPORT void    hb_inkeySetText( const char * szText, ULONG ulLen ); /* Set text into inkey buffer */
extern HB_EXPORT int     hb_inkeySetLast( int iKey );    /* Set new LASTKEY() value, return previous one */
extern HB_EXPORT void    hb_inkeyExit( void );           /* reset inkey pool to default state and free any allocated resources */

HB_EXTERN_END

#endif /* HB_APIGT_H_ */
c:\harbour\include\hbapiitm.h
/*
 * $Id: hbapiitm.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Item API
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

#ifndef HB_APIITM_H_
#define HB_APIITM_H_

#include "hbapi.h"

HB_EXTERN_BEGIN

#define HB_EVAL_PARAM_MAX_ 9

typedef struct
{
   USHORT   paramCount;
   PHB_ITEM pItems[ HB_EVAL_PARAM_MAX_ + 1 ];
} HB_EVALINFO, * PHB_EVALINFO;

#ifdef HB_LEGACY_LEVEL
   #define EVALINFO            HB_EVALINFO
   #define PEVALINFO           PHB_EVALINFO
   #define EVALINFO_PTR        PHB_EVALINFO
#endif

extern HB_EXPORT PHB_ITEM   hb_evalLaunch    ( PHB_EVALINFO pEvalInfo );
extern HB_EXPORT BOOL       hb_evalNew       ( PHB_EVALINFO pEvalInfo, PHB_ITEM pItem );
extern HB_EXPORT BOOL       hb_evalPutParam  ( PHB_EVALINFO pEvalInfo, PHB_ITEM pItem );
extern HB_EXPORT BOOL       hb_evalRelease   ( PHB_EVALINFO pEvalInfo );

extern HB_EXPORT void       hb_evalBlock( PHB_ITEM pCodeBlock, ... );
extern HB_EXPORT void       hb_evalBlock0( PHB_ITEM pCodeBlock );
extern HB_EXPORT void       hb_evalBlock1( PHB_ITEM pCodeBlock, PHB_ITEM pParam );

extern HB_EXPORT BOOL       hb_execFromArray ( PHB_ITEM pParam );

extern HB_EXPORT PHB_ITEM   hb_itemDo        ( PHB_ITEM pItem, ULONG ulPCount, ... );
extern HB_EXPORT PHB_ITEM   hb_itemDoC       ( const char * szFunc, ULONG ulPCount, ... );

extern HB_EXPORT PHB_ITEM   hb_itemArrayGet  ( PHB_ITEM pArray, ULONG ulIndex );
extern HB_EXPORT PHB_ITEM   hb_itemArrayNew  ( ULONG ulLen );
extern HB_EXPORT PHB_ITEM   hb_itemArrayPut  ( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem );
extern HB_EXPORT ULONG      hb_itemCopyC     ( PHB_ITEM pItem, char * szBuffer, ULONG ulLen );
extern HB_EXPORT BOOL       hb_itemFreeC     ( char * szText );
extern HB_EXPORT char *     hb_itemGetC      ( PHB_ITEM pItem );
extern HB_EXPORT char *     hb_itemGetCPtr   ( PHB_ITEM pItem );
extern HB_EXPORT ULONG      hb_itemGetCLen   ( PHB_ITEM pItem );
extern HB_EXPORT char *     hb_itemGetDS     ( PHB_ITEM pItem, char * szDate );
extern HB_EXPORT long       hb_itemGetDL     ( PHB_ITEM pItem );
extern HB_EXPORT BOOL       hb_itemGetL      ( PHB_ITEM pItem );
extern HB_EXPORT double     hb_itemGetND     ( PHB_ITEM pItem );
extern HB_EXPORT double     hb_itemGetNDDec  ( PHB_ITEM pItem, int * piDec );
extern HB_EXPORT int        hb_itemGetNI     ( PHB_ITEM pItem );
extern HB_EXPORT long       hb_itemGetNL     ( PHB_ITEM pItem );
extern HB_EXPORT HB_LONG    hb_itemGetNInt   ( PHB_ITEM pItem );
extern HB_EXPORT void       hb_itemGetNLen   ( PHB_ITEM pItem, int * piWidth, int * piDec );
extern HB_EXPORT void *     hb_itemGetPtr    ( PHB_ITEM pItem );
extern HB_EXPORT void *     hb_itemGetPtrGC  ( PHB_ITEM pItem, HB_GARBAGE_FUNC_PTR pFunc );
extern HB_EXPORT PHB_SYMB   hb_itemGetSymbol ( PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM   hb_itemNew       ( PHB_ITEM pNull );
extern HB_EXPORT void       hb_itemInit      ( PHB_ITEM pItem );
extern HB_EXPORT USHORT     hb_itemPCount    ( void );
extern HB_EXPORT PHB_ITEM   hb_itemParam     ( USHORT uiParam );
extern HB_EXPORT PHB_ITEM   hb_itemPutC      ( PHB_ITEM pItem, const char * szText );
extern HB_EXPORT PHB_ITEM   hb_itemPutCL     ( PHB_ITEM pItem, const char * szText, ULONG ulLen );
extern HB_EXPORT PHB_ITEM   hb_itemPutCConst ( PHB_ITEM pItem, const char * szText );
extern HB_EXPORT PHB_ITEM   hb_itemPutCLConst( PHB_ITEM pItem, const char * szText, ULONG ulLen );
extern HB_EXPORT PHB_ITEM   hb_itemPutCPtr2  ( PHB_ITEM pItem, char * szText );
extern HB_EXPORT PHB_ITEM   hb_itemPutCPtr   ( PHB_ITEM pItem, char * szText, ULONG ulLen );
extern HB_EXPORT PHB_ITEM   hb_itemPutCLPtr  ( PHB_ITEM pItem, char * szText, ULONG ulLen );
extern HB_EXPORT void       hb_itemSetCMemo  ( PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM   hb_itemPutD      ( PHB_ITEM pItem, int iYear, int iMonth, int iDay );
extern HB_EXPORT PHB_ITEM   hb_itemPutDS     ( PHB_ITEM pItem, const char * szDate );
extern HB_EXPORT PHB_ITEM   hb_itemPutDL     ( PHB_ITEM pItem, long lJulian );
extern HB_EXPORT PHB_ITEM   hb_itemPutL      ( PHB_ITEM pItem, BOOL bValue );
extern HB_EXPORT PHB_ITEM   hb_itemPutND     ( PHB_ITEM pItem, double dNumber );
extern HB_EXPORT PHB_ITEM   hb_itemPutNI     ( PHB_ITEM pItem, int iNumber );
extern HB_EXPORT PHB_ITEM   hb_itemPutNL     ( PHB_ITEM pItem, long lNumber );
extern HB_EXPORT PHB_ITEM   hb_itemPutNInt   ( PHB_ITEM pItem, HB_LONG lNumber );
extern HB_EXPORT PHB_ITEM   hb_itemPutNIntLen( PHB_ITEM pItem, HB_LONG lNumber, int iWidth );
extern HB_EXPORT PHB_ITEM   hb_itemPutNLen   ( PHB_ITEM pItem, double dNumber, int iWidth, int iDec );
extern HB_EXPORT PHB_ITEM   hb_itemPutNDLen  ( PHB_ITEM pItem, double dNumber, int iWidth, int iDec );
extern HB_EXPORT PHB_ITEM   hb_itemPutNDDec  ( PHB_ITEM pItem, double dNumber, int iDec );
extern HB_EXPORT PHB_ITEM   hb_itemPutNILen  ( PHB_ITEM pItem, int iNumber, int iWidth );
extern HB_EXPORT PHB_ITEM   hb_itemPutNLLen  ( PHB_ITEM pItem, long lNumber, int iWidth );
extern HB_EXPORT PHB_ITEM   hb_itemPutNumType( PHB_ITEM pItem, double dNumber, int iDec, int iType1, int iType2 );
extern HB_EXPORT PHB_ITEM   hb_itemPutPtr    ( PHB_ITEM pItem, void * pValue );
extern HB_EXPORT PHB_ITEM   hb_itemPutPtrGC  ( PHB_ITEM pItem, void * pValue );
extern HB_EXPORT PHB_ITEM   hb_itemPutSymbol ( PHB_ITEM pItem, PHB_SYMB pSym );
extern HB_EXPORT BOOL       hb_itemRelease   ( PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM   hb_itemReturn    ( PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM   hb_itemReturnForward( PHB_ITEM pItem );
extern HB_EXPORT void       hb_itemReturnRelease( PHB_ITEM pItem );
extern HB_EXPORT ULONG      hb_itemSize      ( PHB_ITEM pItem );
extern HB_EXPORT HB_TYPE    hb_itemType      ( PHB_ITEM pItem );
extern HB_EXPORT char *     hb_itemTypeStr   ( PHB_ITEM pItem );
#ifndef HB_LONG_LONG_OFF
extern HB_EXPORT LONGLONG   hb_itemGetNLL    ( PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM   hb_itemPutNLL    ( PHB_ITEM pItem, LONGLONG lNumber );
extern HB_EXPORT PHB_ITEM   hb_itemPutNLLLen ( PHB_ITEM pItem, LONGLONG lNumber, int iWidth );
#endif

/* Non Clipper compliant internal API */

extern HB_EXPORT PHB_ITEM   hb_itemParamPtr  ( USHORT uiParam, long lMask );
extern HB_EXPORT BOOL       hb_itemParamStore( USHORT uiParam, PHB_ITEM pItem );
extern HB_EXPORT BOOL       hb_itemParamStoreForward( USHORT uiParam, PHB_ITEM pItem );
extern HB_EXPORT int        hb_itemStrCmp    ( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact ); /* our string compare */
extern HB_EXPORT int        hb_itemStrICmp   ( PHB_ITEM pFirst, PHB_ITEM pSecond, BOOL bForceExact ); /* our string compare */
extern HB_EXPORT void       hb_itemCopy      ( PHB_ITEM pDest, PHB_ITEM pSource ); /* copies an item to one place to another respecting its containts */
extern HB_EXPORT void       hb_itemCopyToRef ( PHB_ITEM pDest, PHB_ITEM pSource );
extern HB_EXPORT void       hb_itemCopyFromRef( PHB_ITEM pDest, PHB_ITEM pSource );
extern HB_EXPORT void       hb_itemMove      ( PHB_ITEM pDest, PHB_ITEM pSource ); /* moves the value of an item without incrementing of reference counters, source is cleared */
extern HB_EXPORT void       hb_itemMoveRef   ( PHB_ITEM pDest, PHB_ITEM pSource );
extern HB_EXPORT void       hb_itemMoveToRef ( PHB_ITEM pDest, PHB_ITEM pSource );
extern HB_EXPORT void       hb_itemMoveFromRef( PHB_ITEM pDest, PHB_ITEM pSource );
extern HB_EXPORT void       hb_itemClear     ( PHB_ITEM pItem );
extern HB_EXPORT PHB_ITEM   hb_itemUnRef     ( PHB_ITEM pItem ); /* de-references passed variable */
extern HB_EXPORT PHB_ITEM   hb_itemUnRefOnce ( PHB_ITEM pItem ); /* de-references passed variable, one step*/
extern HB_EXPORT PHB_ITEM   hb_itemUnRefRefer( PHB_ITEM pItem ); /* de-references passed variable, leaving the last reference */
extern HB_EXPORT PHB_ITEM   hb_itemUnRefWrite( PHB_ITEM pItem, PHB_ITEM pSource ); /* de-references passed variable for writing */
extern HB_EXPORT PHB_ITEM   hb_itemUnShare   ( PHB_ITEM pItem ); /* un-share given string item */
extern HB_EXPORT PHB_ITEM   hb_itemUnShareString( PHB_ITEM pItem ); /* un-share given string item - the pItem have to be valid unrefed string item */
extern HB_EXPORT PHB_ITEM   hb_itemReSizeString( PHB_ITEM pItem, ULONG ulSize ); /* Resize string buffer of given string item - the pItem have to be valid unrefed string item */
extern HB_EXPORT PHB_ITEM   hb_itemClone     ( PHB_ITEM pItem ); /* clone the given item */
extern HB_EXPORT char *     hb_itemStr       ( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec ); /* convert a number to a string */
extern HB_EXPORT char *     hb_itemString    ( PHB_ITEM pItem, ULONG * ulLen, BOOL * bFreeReq );  /* Convert any scalar to a string */
extern HB_EXPORT BOOL       hb_itemStrBuf    ( char *szResult, PHB_ITEM pNumber, int iSize, int iDec ); /* convert a number to a string */
extern HB_EXPORT PHB_ITEM   hb_itemValToStr  ( PHB_ITEM pItem ); /* Convert any scalar to a string */
extern HB_EXPORT char *     hb_itemPadConv   ( PHB_ITEM pItem, ULONG * pulSize, BOOL * bFreeReq );
extern HB_EXPORT void       hb_itemSwap      ( PHB_ITEM pItem1, PHB_ITEM pItem2 );

#if defined( _HB_API_INTERNAL_ )

#  define hb_itemSetNil( item )           do { \
                                             if( HB_IS_COMPLEX( item ) ) \
                                                hb_itemClear( item ); \
                                             else \
                                                (item)->type = HB_IT_NIL; \
                                          } while( 0 )

#if 0
#  define hb_itemRawMove( dst, src )      do { \
                                             memcpy( (dst), (src), sizeof( HB_ITEM ) ); \
                                             (src)->type = HB_IT_NIL; \
                                          } while( 0 )
#else
#  define hb_itemRawMove( dst, src )      hb_itemMove( (dst), (src) )
#endif

#else

#  define hb_itemSetNil( item )           hb_itemClear( (item) )

#  define hb_itemRawMove( dst, src )      hb_itemMove( (dst), (src) )

#endif

/* xHarbour compatible function */
#define hb_itemForwardValue( dst, src )   hb_itemMove( (dst), (src) )
#define hb_itemPutCStatic( itm, str )     hb_itemPutCConst( (itm), (str) )

HB_EXTERN_END

#endif /* HB_APIITM_H_ */
c:\harbour\include\hbapilng.h
/*
 * $Id: hbapilng.h 9374 2008-09-13 16:53:45Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Language API
 *
 * Copyright 1999-2001 Viktor Szakats 
 * 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.
 *
 */

#ifndef HB_APILNG_H_
#define HB_APILNG_H_

#include "hbdefs.h"
#include "hbvmpub.h"
#include "hbinit.h"

#include "hblang.ch" /* Base values for the unified language item table */

HB_EXTERN_BEGIN

/* This hack is needed to force preprocessing if id is also a macro */
#define HB_LANG_REQUEST( id )          HB_LANG_REQUEST_( id )
#define HB_LANG_REQUEST_( id )         HB_FUNC_EXTERN( HB_LANG_##id ); \
                                       void hb_lang_ForceLink_##id( void ) \
                                       { \
                                          HB_FUNC_EXEC( HB_LANG_##id ); \
                                       }

/* Macro to publish a specific language module, for both C and Harbour level */
#define HB_LANG_ANNOUNCE( id )          HB_FUNC( HB_LANG_##id ) {}

typedef struct _HB_LANG
{
   const void * pItemList[ HB_LANG_ITEM_MAX_ ];
} HB_LANG, * PHB_LANG, * HB_LANG_PTR;

extern HB_EXPORT PHB_LANG  hb_vmLang( void );
extern HB_EXPORT void      hb_vmSetLang( PHB_LANG pLang );

/* Supported language list management */

extern HB_EXPORT BOOL      hb_langRegister         ( PHB_LANG lang );
extern HB_EXPORT BOOL      hb_langDeRegister       ( const char * pszID );
extern HB_EXPORT PHB_LANG  hb_langFind             ( const char * pszID );

/* Default language selection and data query */

extern HB_EXPORT PHB_LANG  hb_langSelect           ( PHB_LANG lang );
extern HB_EXPORT char *    hb_langSelectID         ( const char * pszID );
extern HB_EXPORT char *    hb_langDGetItem         ( int iIndex );
extern HB_EXPORT char *    hb_langID               ( void );
extern HB_EXPORT char *    hb_langName             ( void );

/* Compatibility interface */

extern HB_EXPORT char *    hb_langDGetErrorDesc    ( ULONG ulIndex );

HB_EXTERN_END

#endif /* HB_APILNG_H_ */
c:\harbour\include\hbapirdd.h
/*
 * $Id: hbapirdd.h 9449 2008-09-19 20:28:26Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the RDD API
 *
 * Copyright 1999 {list of individual authors and e-mail addresses}
 * 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.
 *
 */

#ifndef HB_APIRDD_H_
#define HB_APIRDD_H_

#include "hbapifs.h"
#include "dbinfo.ch"   /* Constants for SELF_ORDINFO, SELF_INFO(), SELF_RECINFO() */
#include "dbstruct.ch" /* Constants for SELF_FIELDINFO() */
#include "hbapicdp.h"

HB_EXTERN_BEGIN

#define HB_RDD_MAX_DRIVERNAME_LEN          32

#ifndef HB_RDD_MAX_ALIAS_LEN
   #define HB_RDD_MAX_ALIAS_LEN            32
#endif

/* #define HB_MAX_RDD_FIELDNAME_LEN        32 */
#define HB_RDD_MAX_AREA_NUM                65535

/* Compatibility #defines. These will be removed, so 
   please use the new names in your code. */
#ifdef HB_LEGACY_LEVEL
   #define HARBOUR_MAX_RDD_DRIVERNAME_LENGTH  HB_RDD_MAX_DRIVERNAME_LEN
   #define HARBOUR_MAX_RDD_ALIAS_LENGTH       HB_RDD_MAX_ALIAS_LEN
#endif


/* DBCMD errors */

#define EDBCMD_SEEK_BADPARAMETER          1001
#define EDBCMD_NOALIAS                    1002
#define EDBCMD_NOVAR                      1003
#define EDBCMD_USE_BADPARAMETER           1005
#define EDBCMD_REL_BADPARAMETER           1006
#define EDBCMD_ORDLSTADD_BADPARAMETER     1008
#define EDBCMD_FIELDNAME_BADPARAMETER     1009
#define EDBCMD_BADALIAS                   1010
#define EDBCMD_DUPALIAS                   1011
#define EDBCMD_DBCMDBADPARAMETER          1014
#define EDBCMD_BADPARAMETER               1015
#define EDBCMD_INFOBADPARAMETER           1032
#define EDBCMD_DBINFOBADPARAMETER         1034
#define EDBCMD_DBFILEPUTBADPARAMETER      1041
#define EDBCMD_DBFILEGETBADPARAMETER      1042
#define EDBCMD_NOTABLE                    2001
#define EDBCMD_EVAL_BADPARAMETER          2019



/* FIeld types */

#define HB_FT_NONE            0
#define HB_FT_STRING          1     /* "C" */
#define HB_FT_LOGICAL         2     /* "L" */
#define HB_FT_DATE            3     /* "D" */
#define HB_FT_LONG            4     /* "N" */
#define HB_FT_FLOAT           5     /* "F" */
#define HB_FT_INTEGER         6     /* "I" */
#define HB_FT_DOUBLE          7     /* "B" */
#define HB_FT_TIME            8     /* "T" */
#define HB_FT_DAYTIME         9     /* "@" */
#define HB_FT_MODTIME         10    /* "=" */
#define HB_FT_ROWVER          11    /* "^" */
#define HB_FT_AUTOINC         12    /* "+" */
#define HB_FT_CURRENCY        13    /* "Y" */
#define HB_FT_CURDOUBLE       14    /* "Z" */
#define HB_FT_VARLENGTH       15    /* "Q" */
#define HB_FT_MEMO            16    /* "M" */
#define HB_FT_ANY             17    /* "V" */
#define HB_FT_IMAGE           18    /* "P" */
#define HB_FT_BLOB            19    /* "W" */
#define HB_FT_OLE             20    /* "G" */



/* FIeld flags */

#define HB_FF_HIDDEN          0x0001 /* System Column (not visible to user) */
#define HB_FF_NULLABLE        0x0002 /* Column can store null values */
#define HB_FF_BINARY          0x0004 /* Binary column */
#define HB_FF_AUTOINC         0x0008 /* Column is autoincrementing */
#define HB_FF_COMPRESSED      0x0010 /* Column is compressed */
#define HB_FF_ENCRYPTED       0x0020 /* Column is encrypted */



/* Flags for DBTRANSINFO */

#define DBTF_MATCH         0x0001
#define DBTF_PUTREC        0x0002



/* Codes for Locking methods */

#define DBLM_EXCLUSIVE     1
#define DBLM_MULTIPLE      2
#define DBLM_FILE          3


/* Codes for RawLock types */

#define FILE_LOCK          1
#define FILE_UNLOCK        2
#define REC_LOCK           3
#define REC_UNLOCK         4
#define HEADER_LOCK        5
#define HEADER_UNLOCK      6
#define APPEND_LOCK        7
#define APPEND_UNLOCK      8



/*
 * Forward declarations
 */
struct _RDDFUNCS;
struct _AREA;
struct _RDDNODE;


/*
*  DBFIELDINFO
*  -----------
*  The field structure
*/

typedef struct
{
   BYTE *   atomName;         /* FIELD (symbol) name */
   HB_TYPE  uiType;           /* FIELD type */
   USHORT   uiTypeExtended;   /* FIELD type extended */
   USHORT   uiLen;            /* Overall FIELD length */
   USHORT   uiDec;            /* Decimal places of numeric FIELD */
   USHORT   uiFlags;          /* FIELD flags */
} DBFIELDINFO;

typedef DBFIELDINFO * LPDBFIELDINFO;



/*
 *  DBOPENINFO
 *  ----------
 *  The Open Info structure
 */

typedef struct
{
   USHORT uiArea;          /* Work Area number of the data store */
   BYTE * abName;          /* The qualified name of the data store */
   BYTE * atomAlias;       /* The logical name of the data store */
   BOOL   fShared;         /* Share mode of the data store */
   BOOL   fReadonly;       /* Readonly mode of the data store */
   BYTE * cdpId;           /* Id of a codepage */
   ULONG  ulConnection;    /* connection handler for RDDs which support it */
   void * lpdbHeader;      /* Pointer to a header of the data store */
} DBOPENINFO;

typedef DBOPENINFO * LPDBOPENINFO;



/*
 *  DBORDERCONDINFO
 *  ---------------
 *  The Create Order conditional Info structure
 */

typedef struct _DBORDERCONDINFO
{
   BOOL     fActive;
   BYTE *   abFor;
   BYTE *   abWhile;
   PHB_ITEM itmCobFor;
   PHB_ITEM itmCobWhile;
   PHB_ITEM itmCobEval;
   LONG     lStep;
   PHB_ITEM itmStartRecID;
   LONG     lNextCount;
   PHB_ITEM itmRecID;
   BOOL     fRest;
   BOOL     fDescending;
   BOOL     fScoped;
   BOOL     fAll;
   BOOL     fAdditive;
   BOOL     fUseCurrent;
   BOOL     fCustom;
   BOOL     fNoOptimize;
   BOOL     fCompound;
   BOOL     fUseFilter;
   BOOL     fTemporary;
   BOOL     fExclusive;
   void *   lpvCargo;
} DBORDERCONDINFO;

typedef DBORDERCONDINFO * LPDBORDERCONDINFO;



typedef struct
{
   BYTE *             abConstrName;       /* Name of relational integrity constraint */
   BYTE *             abTargetName;       /* Name of target relation table */
   PHB_ITEM           itmRelationKey;     /* Array of columns in source table to match target primary key */
   BOOL               fEnabled;           /* Is constraint enabled ? */
} DBCONSTRAINTINFO;

typedef DBCONSTRAINTINFO * LPDBCONSTRAINTINFO;


/*
 *  DBORDERCREATE
 *  -------------
 *  The Create Order Info structure
 */

typedef struct
{
   LPDBORDERCONDINFO  lpdbOrdCondInfo;    /* Conditional information */
   BYTE *             abBagName;          /* Name of the Order bag */
   BYTE *             atomBagName;        /* Name of the Order */
   PHB_ITEM           itmOrder;
   BOOL               fUnique;            /* Flag to determine if all keys are unique */
   PHB_ITEM           itmCobExpr;         /* Code block containing the KEY expression */
   PHB_ITEM           abExpr;             /* String containing the KEY expression */
   LPDBCONSTRAINTINFO lpdbConstraintInfo; /* Relational constraint info */
} DBORDERCREATEINFO;

typedef DBORDERCREATEINFO * LPDBORDERCREATEINFO;



/*
 *  DBORDERINFO
 *  -----------
 *  The Set Index Info structure
 */

typedef struct
{
   PHB_ITEM atomBagName;  /* Name of the Order Bag */
   PHB_ITEM itmOrder;     /* Name or Number of the Order */
   PHB_ITEM itmCobExpr;   /* Code block containing the KEY expression */
   PHB_ITEM itmResult;    /* Operation result */
   PHB_ITEM itmNewVal;    /* New Setting   */
   BOOL     fAllTags;     /* Open all tags */
} DBORDERINFO;

typedef DBORDERINFO * LPDBORDERINFO;



/*
 *  DBSCOPEINFO
 *  -----------
 *  The Scope Info structure
 */

typedef struct
{
   PHB_ITEM itmCobFor;   /* Code Block representation of a FOR clause */
   PHB_ITEM lpstrFor;    /* String representation of a FOR clause */
   PHB_ITEM itmCobWhile; /* Code Block representation of a WHILE clause */
   PHB_ITEM lpstrWhile;  /* String representation of a WHILE clause */
   PHB_ITEM lNext;       /* NEXT record */
   PHB_ITEM itmRecID;    /* single record ID */
   PHB_ITEM fRest;       /* TRUE if start from the current record */
   BOOL     fIgnoreFilter;       /* process should ignore any filter condition */
   BOOL     fIncludeDeleted;     /* process should include deleted records */
   BOOL     fLast;               /* last record of the current scope required */
   BOOL     fIgnoreDuplicates;   /* process should ignore duplicate key value */
   BOOL     fBackward;           /* skip backward */
   BOOL     fOptimized;          /* Is (should be) scope optimized */
} DBSCOPEINFO;

typedef DBSCOPEINFO * LPDBSCOPEINFO;


/*
 *  DBORDSCOPEINFO
 *  --------------
 *  The Order Scope Info structure
 */

typedef struct
{
   USHORT nScope;        /* scope operation: TOPSCOPE/ENDSCOPE */
   PHB_ITEM scopeValue;
} DBORDSCOPEINFO;

typedef DBORDSCOPEINFO * LPDBORDSCOPEINFO;


/*
 *  DBFILTERINFO
 *  ------------
 *  The Filter Info structure
 */

typedef struct
{
   PHB_ITEM itmCobExpr;       /* Block representation of the FILTER expression */
   PHB_ITEM abFilterText;     /* String representation of FILTER expression */
   BOOL     fFilter;          /* flag to indicate that filter is active */
   BOOL     fOptimized;       /* Is (should be) filter optimized */
   void *   lpvCargo;         /* RDD specific extended filter info */
} DBFILTERINFO;

typedef DBFILTERINFO * LPDBFILTERINFO;



/*
 *  DBRELINFO
 *  ---------
 *  The Relationship Info structure
 */

typedef struct _DBRELINFO
{
   PHB_ITEM            itmCobExpr;   /* Block representation of the relational SEEK key */
   PHB_ITEM            abKey;        /* String representation of the relational SEEK key */
   BOOL                isScoped;     /* Is this relation scoped */
   BOOL                isOptimized;  /* Is relation optimized */
   struct _AREA      * lpaParent;    /* The parent of this relation */
   struct _AREA      * lpaChild;     /* The parents children */
   struct _DBRELINFO * lpdbriNext;   /* Next child or parent */
} DBRELINFO;

typedef DBRELINFO * LPDBRELINFO;



/*
 *  DBEVALINFO
 *  ----------
 *  The Evaluation Info structure
 *
 *  Contains information necessary for a block evaluation
 *  on each record of the workarea
 */

typedef struct
{
   PHB_ITEM    itmBlock;   /* The block to be evaluated */
   PHB_ITEM    abBlock;    /* String representation of evaluated block */
   DBSCOPEINFO dbsci;      /* Scope info that limits the evaluation */
} DBEVALINFO;

typedef DBEVALINFO * LPDBEVALINFO;

/*
 * NOTE: If your redefine EVAL() method then you may use itmBlock as
 * string ITEM to make some operations on server side of remote RDD.
 */


/*
 *  DBTRANSITEM
 *  -----------
 *  The Transfer Item structure
 *
 *  Defines a single transfer item (usually a field) from
 *  one database to another; used by DBTRANSINFO
 */

typedef struct
{
   USHORT uiSource;       /* Field index number from the source */
   USHORT uiDest;         /* Destination field index number */
} DBTRANSITEM;

typedef DBTRANSITEM * LPDBTRANSITEM;



/*
 *  DBTRANSINFO
 *  -----------
 *  The Transfer Info structure
 *
 *  Defines a global transfer of data items from on workarea
 *  to another
 */

typedef struct
{
   struct _AREA * lpaSource;     /* Pointer to source work area */
   struct _AREA * lpaDest;       /* Pointer to dest work area */
   DBSCOPEINFO    dbsci;         /* Scope to limit transfer */
   USHORT         uiFlags;       /* Transfer attributes */
   USHORT         uiItemCount;   /* Number of items below */
   LPDBTRANSITEM  lpTransItems;  /* Array of items */
} DBTRANSINFO;

typedef DBTRANSINFO * LPDBTRANSINFO;



/*
 *  DBSORTITEM
 *  ----------
 *  The Sort Item Structure
 *
 *  An array of items that, together, indicate the key value to
 *  use while sorting data. The order of the array determines the
 *  order of the sorting.
 */

typedef struct
{
   USHORT uiField;        /* Index into the workarea->fields structure */
   USHORT uiFlags;        /* Sort flags */
} DBSORTITEM;

typedef DBSORTITEM * LPDBSORTITEM;


/* Flags for DBSORTITEM */
#define SF_ASCEND       1
#define SF_CASE         2
#define SF_DESCEND      4
#define SF_NUM         32
#define SF_DOUBLE      64
#define SF_LONG       128



/*
 *  DBSORTINFO
 *  ----------
 *  The Sort Info Structure
 *
 *  Information for a physical sort on the workarea
 */

typedef struct
{
   DBTRANSINFO   dbtri;        /* Destination workarea transfer information */
   LPDBSORTITEM  lpdbsItem;    /* Fields which compose the key values for the sort */
   USHORT        uiItemCount;  /* The number of fields above */
} DBSORTINFO;

typedef DBSORTINFO * LPDBSORTINFO;



/*
 *  DBLOCKINFO
 *  ----------
 *  The Lock Info Structure
 *
 *  Information for a record or file lock
 */

typedef struct
{
   PHB_ITEM itmRecID;
   USHORT   uiMethod;
   BOOL     fResult;
} DBLOCKINFO;

typedef DBLOCKINFO * LPDBLOCKINFO;



/*
 *  FIELD
 *  -----
 *  The Field structure
 *
 *  This is the basic unit of access for a workarea
 */

typedef struct _FIELD
{
   HB_TYPE  uiType;           /* Field type */
   USHORT   uiTypeExtended;   /* Field type - extended */
   USHORT   uiLen;            /* Field length */
   USHORT   uiDec;            /* Decimal length */
   USHORT   uiFlags;          /* FIELD flags */
   USHORT   uiArea;           /* Area this field resides in */
   void *   sym;              /* Symbol that represents the field */
   struct _FIELD * lpfNext;   /* The next field in the list */
} FIELD;

typedef FIELD * LPFIELD;

/*
 * prototype for function to evaluate against index keys
 * only for local RDDs (DBFNTX, DBFCDX, ...)
 */
typedef void ( * HB_EVALSCOPE_FUNC )( ULONG, BYTE *, ULONG, void * );


/*--------------------* WORKAREA structure *----------------------*/

/*
 *  WORKAREA
 *  --------
 *  The Workarea Structure
 *
 *  Information to administrate the workarea
 */

typedef struct _AREA
{
   struct _RDDFUNCS * lprfsHost; /* Virtual method table for this workarea */
#if 0
   /* I'll add this soon, Druzus */
   struct _RDDFUNCS * lprfsSuper;/* Virtual super method table for this workarea */
#endif
   USHORT uiArea;                /* The number assigned to this workarea */
   void * atomAlias;             /* Pointer to the alias symbol for this workarea */
   USHORT uiFieldExtent;         /* Total number of fields allocated */
   USHORT uiFieldCount;          /* Total number of fields used */
   LPFIELD lpFields;             /* Pointer to an array of fields */
   void * lpFieldExtents;        /* Void ptr for additional field properties */
   PHB_ITEM valResult;           /* All purpose result holder */
   BOOL fTop;                    /* TRUE if "top" */
   BOOL fBottom;                 /* TRUE if "bottom" */
   BOOL fBof;                    /* TRUE if "bof" */
   BOOL fEof;                    /* TRUE if "eof" */
   BOOL fFound;                  /* TRUE if "found" */
   DBSCOPEINFO dbsi;             /* Info regarding last LOCATE */
   DBFILTERINFO dbfi;            /* Filter in effect */
   LPDBORDERCONDINFO lpdbOrdCondInfo;
   LPDBRELINFO lpdbRelations;    /* Parent/Child relationships used */
   USHORT uiParents;             /* Number of parents for this area */
   USHORT heap;
   USHORT heapSize;
   USHORT rddID;
   USHORT uiMaxFieldNameLength;
   PHB_CODEPAGE cdPage;          /* Area's codepage pointer */
} AREA;

typedef AREA * LPAREA;

#ifndef AREAP
#define AREAP LPAREA
#endif


/*--------------------* Virtual Method Table *----------------------*/

typedef USHORT ( * DBENTRYP_V    )( AREAP area );
typedef USHORT ( * DBENTRYP_BP   )( AREAP area, BOOL * param );
typedef USHORT ( * DBENTRYP_B    )( AREAP area, BOOL param );
typedef USHORT ( * DBENTRYP_L    )( AREAP area, LONG param );
typedef USHORT ( * DBENTRYP_UL   )( AREAP area, ULONG param );
typedef USHORT ( * DBENTRYP_I    )( AREAP area, PHB_ITEM param );
typedef USHORT ( * DBENTRYP_SI   )( AREAP area, USHORT index, PHB_ITEM param );
typedef USHORT ( * DBENTRYP_VP   )( AREAP area, LPDBOPENINFO param );
typedef USHORT ( * DBENTRYP_VT   )( AREAP area, LPDBTRANSINFO param );
typedef USHORT ( * DBENTRYP_VF   )( AREAP area, LPDBFIELDINFO param );
typedef USHORT ( * DBENTRYP_VL   )( AREAP area, LPDBLOCKINFO param );
typedef USHORT ( * DBENTRYP_VR   )( AREAP area, LPDBRELINFO param );
typedef USHORT ( * DBENTRYP_VS   )( AREAP area, LPDBSORTINFO param );
typedef USHORT ( * DBENTRYP_VFI  )( AREAP area, LPDBFILTERINFO param );
typedef USHORT ( * DBENTRYP_VEI  )( AREAP area, LPDBEVALINFO param );
typedef USHORT ( * DBENTRYP_VLO  )( AREAP area, LPDBSCOPEINFO param );
typedef USHORT ( * DBENTRYP_VOC  )( AREAP area, LPDBORDERCREATEINFO param );
typedef USHORT ( * DBENTRYP_VOI  )( AREAP area, LPDBORDERCONDINFO param );
typedef USHORT ( * DBENTRYP_VOS  )( AREAP area, LPDBORDSCOPEINFO param );
typedef USHORT ( * DBENTRYP_OI   )( AREAP area, LPDBORDERINFO param );
typedef USHORT ( * DBENTRYP_OII  )( AREAP area, USHORT index, LPDBORDERINFO param );
typedef USHORT ( * DBENTRYP_SP   )( AREAP area, USHORT * param );
typedef USHORT ( * DBENTRYP_P    )( AREAP area, BYTE * param );
typedef USHORT ( * DBENTRYP_PP   )( AREAP area, BYTE ** param );
typedef USHORT ( * DBENTRYP_S    )( AREAP area, USHORT param );
typedef USHORT ( * DBENTRYP_LP   )( AREAP area, LONG * param );
typedef USHORT ( * DBENTRYP_ULP  )( AREAP area, ULONG * param );
typedef USHORT ( * DBENTRYP_SVP  )( AREAP area, USHORT index, void * param );
typedef USHORT ( * DBENTRYP_SVPB )( AREAP area, USHORT index, void * param, USHORT p3 );
typedef USHORT ( * DBENTRYP_VSP  )( AREAP area, USHORT action, ULONG lRecord );
typedef USHORT ( * DBENTRYP_SVL  )( AREAP area, USHORT index, ULONG * param );
typedef USHORT ( * DBENTRYP_SSI  )( AREAP area, USHORT p1, USHORT p2, PHB_ITEM p3 );
typedef USHORT ( * DBENTRYP_ISI  )( AREAP area, PHB_ITEM p1, USHORT p2, PHB_ITEM p3 );
typedef USHORT ( * DBENTRYP_BIB  )( AREAP area, BOOL p1, PHB_ITEM p2, BOOL p3 );
typedef USHORT ( * DBENTRYP_VPL  )( AREAP area, void * p1, LONG p2 );
typedef USHORT ( * DBENTRYP_VPLP )( AREAP area, void * p1, LONG * p2 );
typedef USHORT ( * DBENTRYP_LSP  )( AREAP area, ULONG p1, BOOL * p2 );

/* this methods DO USE take a Workarea but an RDDNODE */

typedef USHORT ( * DBENTRYP_R    )( struct _RDDNODE * pRDD );
typedef USHORT ( * DBENTRYP_RVVL )( struct _RDDNODE * pRDD, PHB_ITEM p1, PHB_ITEM p2, ULONG p3 );
typedef USHORT ( * DBENTRYP_RSLV )( struct _RDDNODE * pRDD, USHORT index, ULONG p1, PHB_ITEM p2 );
/*--------------------* Virtual Method Table *----------------------*/

typedef struct _RDDFUNCS
{
   /* Movement and positioning methods */

   DBENTRYP_BP   bof;               /* Determine logical beginning of file. */
   DBENTRYP_BP   eof;               /* Determine logical end of file. */
   DBENTRYP_BP   found;             /* Determine outcome of the last search operation. */
   DBENTRYP_V    goBottom;          /* Position cursor at the last record. */
   DBENTRYP_UL   go;                /* Position cursor at a specific physical record. */
   DBENTRYP_I    goToId;            /* Position the cursor to a specific, physical identity. */
   DBENTRYP_V    goTop;             /* Position cursor at the first record. */
   DBENTRYP_BIB  seek;              /*  */
   DBENTRYP_L    skip;              /* Reposition cursor relative to current position. */
   DBENTRYP_L    skipFilter;        /*-Reposition cursor respecting any filter setting. */
   DBENTRYP_L    skipRaw;           /* Reposition cursor, regardless of filter. */


   /* Data management */

   DBENTRYP_VF   addField;          /* Add a field to the WorkArea. */
   DBENTRYP_B    append;            /* Append a record to the WorkArea. */
   DBENTRYP_I    createFields;      /*-Add all fields defined in an array to the WorkArea. */
   DBENTRYP_V    deleterec;         /* Delete a record. */
   DBENTRYP_BP   deleted;           /* Determine deleted status for a record. */
   DBENTRYP_SP   fieldCount;        /*-Determine the number of fields in the WorkArea. */
   DBENTRYP_VF   fieldDisplay;      /*  */
   DBENTRYP_SSI  fieldInfo;         /*-Retrieve information about a field. */
   DBENTRYP_SVP  fieldName;         /*-Determine the name associated with a field number. */
   DBENTRYP_V    flush;             /* Write data buffer to the data store. */
   DBENTRYP_PP   getRec;            /*  */
   DBENTRYP_SI   getValue;          /* Obtain the current value of a field. */
   DBENTRYP_SVL  getVarLen;         /* Obtain the length of a field value. */
   DBENTRYP_V    goCold;            /* Perform a write of WorkArea memory to the data store. */
   DBENTRYP_V    goHot;             /* Mark the WorkArea data buffer as hot. */
   DBENTRYP_P    putRec;            /* Replace the current record. */
   DBENTRYP_SI   putValue;          /* Assign a value to a field. */
   DBENTRYP_V    recall;            /* Undelete the current record. */
   DBENTRYP_ULP  reccount;          /* Obtain number of records in WorkArea. */
   DBENTRYP_ISI  recInfo;           /*  */
   DBENTRYP_ULP  recno;             /* Obtain physical row number at current WorkArea cursor position. */
   DBENTRYP_I    recid;             /* Obtain physical row ID at current WorkArea cursor position. */
   DBENTRYP_S    setFieldExtent;    /* Establish the extent of the array of fields for a WorkArea. */


   /* WorkArea/Database management */

   DBENTRYP_P    alias;             /*-Obtain the alias of the WorkArea. */
   DBENTRYP_V    close;             /* Close the table in the WorkArea. */
   DBENTRYP_VP   create;            /* Create a data store in the specified WorkArea. */
   DBENTRYP_SI   info;              /* Retrieve information about the current driver (DBI). */
   DBENTRYP_V    newarea;           /* Clear the WorkArea for use. */
   DBENTRYP_VP   open;              /* Open a data store in the WorkArea. */
   DBENTRYP_V    release;           /*-Release all references to a WorkArea. */
   DBENTRYP_SP   structSize;        /* Retrieve the size of the WorkArea structure. */
   DBENTRYP_P    sysName;           /* Obtain the name of replaceable database driver (RDD) subsystem. */
   DBENTRYP_VEI  dbEval;            /*-Evaluate code block for each record in WorkArea. */
   DBENTRYP_V    pack;              /* Remove records marked for deletion from a database. */
   DBENTRYP_LSP  packRec;           /*  */
   DBENTRYP_VS   sort;              /* Physically reorder a database. */
   DBENTRYP_VT   trans;             /* Copy one or more records from one WorkArea to another. */
   DBENTRYP_VT   transRec;          /* Copy a record to another WorkArea. */
   DBENTRYP_V    zap;               /* Physically remove all records from data store. */


   /* Relational Methods */

   DBENTRYP_VR   childEnd;          /* Report end of relation. */
   DBENTRYP_VR   childStart;        /* Report initialization of a relation. */
   DBENTRYP_VR   childSync;         /* Post a pending relational movement. */
   DBENTRYP_V    syncChildren;      /*-Force relational movement in child WorkAreas. */
   DBENTRYP_V    clearRel;          /* Clear all relations in the specified WorkArea. */
   DBENTRYP_V    forceRel;          /* Force relational seeks in the specified WorkArea. */
   DBENTRYP_SVP  relArea;           /*-Obtain the workarea number of the specified relation. */
   DBENTRYP_VR   relEval;           /*-Evaluate a block against the relation in specified WorkArea. */
   DBENTRYP_SI   relText;           /*-Obtain the character expression of the specified relation. */
   DBENTRYP_VR   setRel;            /*-Set a relation in the parent file. */


   /* Order Management */

   DBENTRYP_OI   orderListAdd;      /*  */
   DBENTRYP_V    orderListClear;    /*  */
   DBENTRYP_OI   orderListDelete;   /*  */
   DBENTRYP_OI   orderListFocus;    /*  */
   DBENTRYP_V    orderListRebuild;  /*  */
   DBENTRYP_VOI  orderCondition;    /*  */
   DBENTRYP_VOC  orderCreate;       /*  */
   DBENTRYP_OI   orderDestroy;      /*  */
   DBENTRYP_OII  orderInfo;         /*-Retrieve information about the current order that SELF could not. */


   /* Filters and Scope Settings */

   DBENTRYP_V    clearFilter;       /*-Clear the active filter expression. */
   DBENTRYP_V    clearLocate;       /*-Clear the active locate expression. */
   DBENTRYP_V    clearScope;        /*  */
   DBENTRYP_VPLP countScope;        /*  */
   DBENTRYP_I    filterText;        /*-Return filter condition of the specified WorkArea. */
   DBENTRYP_SI   scopeInfo;         /*  */
   DBENTRYP_VFI  setFilter;         /* Set the filter condition for the specified WorkArea. */
   DBENTRYP_VLO  setLocate;         /*-Set the locate scope for the specified WorkArea. */
   DBENTRYP_VOS  setScope;          /*  */
   DBENTRYP_VPL  skipScope;         /*  */
   DBENTRYP_B    locate;            /* reposition cursor to postions set by setLocate */


   /* Miscellaneous */

   DBENTRYP_P    compile;           /*-Compile a character expression. */
   DBENTRYP_I    error;             /*-Raise a runtime error. */
   DBENTRYP_I    evalBlock;         /*-Evaluate a code block. */


   /* Network operations */

   DBENTRYP_VSP  rawlock;           /* Perform a lowlevel network lock in the specified WorkArea. */
   DBENTRYP_VL   lock;              /* Perform a network lock in the specified WorkArea. */
   DBENTRYP_I    unlock;            /* Release network locks in the specified WorkArea. */


   /* Memofile functions */

   DBENTRYP_V    closeMemFile;      /* Close a memo file in the WorkArea. */
   DBENTRYP_VP   createMemFile;     /* Create a memo file in the WorkArea. */
   DBENTRYP_SVPB getValueFile;      /*  */
   DBENTRYP_VP   openMemFile;       /* Open a memo file in the specified WorkArea. */
   DBENTRYP_SVPB putValueFile;      /*  */


   /* Database file header handling */

   DBENTRYP_V    readDBHeader;      /* Read the database file header record in the WorkArea. */
   DBENTRYP_V    writeDBHeader;     /* Write the database file header record in the WorkArea. */


   /* non WorkArea functions       */

   DBENTRYP_R    init;              /* init RDD after registration */
   DBENTRYP_R    exit;              /* unregister RDD */
   DBENTRYP_RVVL drop;              /* remove table */
   DBENTRYP_RVVL exists;            /* check if table exist */
   DBENTRYP_RSLV rddInfo;           /* RDD info */


   /* Special and reserved methods */

   DBENTRYP_SVP  whoCares;          /*  */

} RDDFUNCS;

typedef RDDFUNCS * PRDDFUNCS;

#define RDDFUNCSCOUNT   ( sizeof( RDDFUNCS ) / sizeof( DBENTRYP_V ) )

/* RDD Node structure              */
typedef struct _RDDNODE
{
   char szName[ HB_RDD_MAX_DRIVERNAME_LEN + 1 ]; /* Name of RDD */
   USHORT   uiType;           /* Type of RDD */
   USHORT   rddID;            /* Type of RDD */
   RDDFUNCS pTable;           /* Table of functions */
   RDDFUNCS pSuperTable;      /* Table of super functions */
   USHORT   uiAreaSize;       /* Size of the WorkArea */
   void     *lpvCargo;        /* RDD specific extended data, if used then
                                 RDD should free it in EXIT() non WA method */
} RDDNODE;

typedef RDDNODE * LPRDDNODE;


/*--------------------* SELF Methods *------------------------*/

/* Movement and positioning methods */

#define SELF_BOF(w, sp)                 ((*(w)->lprfsHost->bof)(w, sp))
#define SELF_EOF(w, sp)                 ((*(w)->lprfsHost->eof)(w, sp))
#define SELF_FOUND(w, sp)               ((*(w)->lprfsHost->found)(w, sp))
#define SELF_GOTO(w, l)                 ((*(w)->lprfsHost->go)(w, l))
#define SELF_GOTOID(w, sp)              ((*(w)->lprfsHost->goToId)(w, sp))
#define SELF_GOBOTTOM(w)                ((*(w)->lprfsHost->goBottom)(w))
#define SELF_GOTOP(w)                   ((*(w)->lprfsHost->goTop)(w))
#define SELF_SEEK(w, i1, v, i2)         ((*(w)->lprfsHost->seek)(w, i1, v, i2))
#define SELF_SKIP(w, l)                 ((*(w)->lprfsHost->skip)(w, l))
#define SELF_SKIPFILTER(w, l)           ((*(w)->lprfsHost->skipFilter)(w, l))
#define SELF_SKIPRAW(w, l)              ((*(w)->lprfsHost->skipRaw)(w, l))


/* Data management */

#define SELF_ADDFIELD(w, ip)            ((*(w)->lprfsHost->addField)(w, ip))
#define SELF_APPEND(w, b)               ((*(w)->lprfsHost->append)(w, b))
#define SELF_CREATEFIELDS(w, v)         ((*(w)->lprfsHost->createFields)(w, v))
#define SELF_DELETE(w)                  ((*(w)->lprfsHost->deleterec)(w))
#define SELF_DELETED(w, sp)             ((*(w)->lprfsHost->deleted)(w, sp))
#define SELF_FIELDCOUNT(w, sp)          ((*(w)->lprfsHost->fieldCount)(w, sp))
#define SELF_FIELDDISPLAY(w, sp)        ((*(w)->lprfsHost->fieldDisplay)(w, sp))
#define SELF_FIELDINFO(w,s1,s2,v)       ((*(w)->lprfsHost->fieldInfo)(w,s1,s2,v))
#define SELF_FIELDNAME(w, i, bp)        ((*(w)->lprfsHost->fieldName)(w, i, bp))
#define SELF_FLUSH(w)                   ((*(w)->lprfsHost->flush)(w))
#define SELF_GETREC(w, bpp)             ((*(w)->lprfsHost->getRec)(w, bpp))
#define SELF_GETVALUE(w, i, v)          ((*(w)->lprfsHost->getValue)(w, i, v))
#define SELF_GETVARLEN(w, i, lp)        ((*(w)->lprfsHost->getVarLen)(w, i, lp))
#define SELF_GOCOLD(w)                  ((*(w)->lprfsHost->goCold)(w))
#define SELF_GOHOT(w)                   ((*(w)->lprfsHost->goHot)(w))
#define SELF_PUTVALUE(w, i, v)          ((*(w)->lprfsHost->putValue)(w, i, v))
#define SELF_PUTREC(w, bp)              ((*(w)->lprfsHost->putRec)(w, bp))
#define SELF_RECALL(w)                  ((*(w)->lprfsHost->recall)(w))
#define SELF_RECCOUNT(w, lp)            ((*(w)->lprfsHost->reccount)(w, lp))
#define SELF_RECINFO(w,v1,i,v2)         ((*(w)->lprfsHost->recInfo)(w,v1,i,v2))
#define SELF_RECNO(w, lp)               ((*(w)->lprfsHost->recno)(w, lp))
#define SELF_RECID(w, i)                ((*(w)->lprfsHost->recid)(w, i))
#define SELF_SETFIELDEXTENT(w, s)       ((*(w)->lprfsHost->setFieldExtent)(w, s))


/* WorkArea/Database management */

#define SELF_ALIAS(w, bp)               ((*(w)->lprfsHost->alias)(w, bp))
#define SELF_CLOSE(w)                   ((*(w)->lprfsHost->close)(w))
#define SELF_CREATE(w, ip)              ((*(w)->lprfsHost->create)(w, ip))
#define SELF_INFO(w, i, g)              ((*(w)->lprfsHost->info)(w, i, g))
#define SELF_NEW(w)                     ((*(w)->lprfsHost->newarea)(w))
#define SELF_OPEN(w, ip)                ((*(w)->lprfsHost->open)(w, ip))
#define SELF_RELEASE(w)                 ((*(w)->lprfsHost->release)(w))
#define SELF_STRUCTSIZE(w, sp)          ((*(w)->lprfsHost->structSize)(w,sp))
#define SELF_SYSNAME(w, bp)             ((*(w)->lprfsHost->sysName)(w, bp))
#define SELF_DBEVAL(w, ip)              ((*(w)->lprfsHost->dbEval)(w, ip))
#define SELF_PACK(w)                    ((*(w)->lprfsHost->pack)(w))
#define SELF_PACKREC(w, l, sp)          ((*(w)->lprfsHost->packRec)(w, l, sp))
#define SELF_SORT(w, ip)                ((*(w)->lprfsHost->sort)(w, ip))
#define SELF_TRANS(w, ip)               ((*(w)->lprfsHost->trans)(w, ip))
#define SELF_TRANSREC(w, ip)            ((*(w)->lprfsHost->transRec)(w, ip))
#define SELF_ZAP(w)                     ((*(w)->lprfsHost->zap)(w))


/* Relational Methods */

#define SELF_CHILDEND(w, ip)            ((*(w)->lprfsHost->childEnd)(w, ip))
#define SELF_CHILDSTART(w, ip)          ((*(w)->lprfsHost->childStart)(w, ip))
#define SELF_CHILDSYNC(w, ip)           ((*(w)->lprfsHost->childSync)(w, ip))
#define SELF_SYNCCHILDREN(w)            ((*(w)->lprfsHost->syncChildren)(w))
#define SELF_CLEARREL(w)                ((*(w)->lprfsHost->clearRel)(w))
#define SELF_FORCEREL(w)                ((*(w)->lprfsHost->forceRel)(w))
#define SELF_RELAREA(w, s, sp)          ((*(w)->lprfsHost->relArea)(w, s, sp))
#define SELF_RELEVAL(w, ip)             ((*(w)->lprfsHost->relEval)(w, ip))
#define SELF_RELTEXT(w, s, bp)          ((*(w)->lprfsHost->relText)(w, s, bp))
#define SELF_SETREL(w, ip)              ((*(w)->lprfsHost->setRel)(w, ip))


/* Order Management */

#define SELF_ORDLSTADD(w, lp)           ((*(w)->lprfsHost->orderListAdd)(w, lp))
#define SELF_ORDLSTDELETE(w, lp)        ((*(w)->lprfsHost->orderListDelete)(w, lp))
#define SELF_ORDLSTFOCUS(w, lp)         ((*(w)->lprfsHost->orderListFocus)(w,lp))
#define SELF_ORDLSTREBUILD(w)           ((*(w)->lprfsHost->orderListRebuild)(w))
#define SELF_ORDLSTCLEAR(w)             ((*(w)->lprfsHost->orderListClear)(w))
#define SELF_ORDSETCOND(w, ip)          ((*(w)->lprfsHost->orderCondition)(w, ip))
#define SELF_ORDCREATE(w, ip)           ((*(w)->lprfsHost->orderCreate)(w, ip))
#define SELF_ORDDESTROY(w, p)           ((*(w)->lprfsHost->orderDestroy)(w, p))
#define SELF_ORDINFO(w, i, p)           ((*(w)->lprfsHost->orderInfo)(w, i, p))
#define SELF_ORDEXPR(w, p)              ((*(w)->lprfsHost->orderInfo)(w, DBOI_EXPRESSION, p))
#define SELF_ORDCOND(w, p)              ((*(w)->lprfsHost->orderInfo)(w, DBOI_CONDITION,  p))
#define SELF_ORDRECNO(w, p)             ((*(w)->lprfsHost->orderInfo)(w, DBOI_RECNO,      p))
#define SELF_ORDPOS(w, p)               ((*(w)->lprfsHost->orderInfo)(w, DBOI_POSITION,   p))
#define SELF_ORDNUMBER(w, p)            ((*(w)->lprfsHost->orderInfo)(w, DBOI_NUMBER,     p))
#define SELF_ORDNAME(w, p)              ((*(w)->lprfsHost->orderInfo)(w, DBOI_NAME,       p))
#define SELF_ORDBAGNAME(w, p)           ((*(w)->lprfsHost->orderInfo)(w, DBOI_BAGNAME,    p))
#define SELF_ORDBAGEXT(w,  p)           ((*(w)->lprfsHost->orderInfo)(w, DBOI_BAGEXT,     p))


/* Filters and Scope Settings */

#define SELF_CLEARFILTER(w)             ((*(w)->lprfsHost->clearFilter)(w))
#define SELF_CLEARLOCATE(w)             ((*(w)->lprfsHost->clearLocate)(w))
#define SELF_CLEARSCOPE(w)              ((*(w)->lprfsHost->clearScope)(w))
#define SELF_COUNTSCOPE(w,ip,lp)        ((*(w)->lprfsHost->countScope)(w,ip,lp))
#define SELF_FILTERTEXT(w, bp)          ((*(w)->lprfsHost->filterText)(w, bp))
#define SELF_SCOPEINFO(w,i,v)           ((*(w)->lprfsHost->scopeInfo)(w,i,v))
#define SELF_SETFILTER(w, ip)           ((*(w)->lprfsHost->setFilter)(w, ip))
#define SELF_SETLOCATE(w, ip)           ((*(w)->lprfsHost->setLocate)(w, ip))
#define SELF_SETSCOPE(w, ip)            ((*(w)->lprfsHost->setScope)(w, ip))
#define SELF_SKIPSCOPE(w, bp, l)        ((*(w)->lprfsHost->skipScope)(w, bp, l))
#define SELF_LOCATE(w, b)               ((*(w)->lprfsHost->locate)(w, b))


/* Miscellaneous */

#define SELF_COMPILE(w, bp)             ((*(w)->lprfsHost->compile)(w, bp))
#define SELF_ERROR(w, ip)               ((*(w)->lprfsHost->error)(w, ip))
#define SELF_EVALBLOCK(w, v)            ((*(w)->lprfsHost->evalBlock)(w, v))


/* Network operations */

#define SELF_GETLOCKS(w, g)             ((*(w)->lprfsHost->info)(w, DBI_GETLOCKARRAY, g))
#define SELF_RAWLOCK(w, i, l)           ((*(w)->lprfsHost->rawlock)(w, i, l))
#define SELF_LOCK(w, sp)                ((*(w)->lprfsHost->lock)(w, sp))
#define SELF_UNLOCK(w, i)               ((*(w)->lprfsHost->unlock)(w, i))


/* Memofile functions */

#define SELF_CLOSEMEMFILE(w)            ((*(w)->lprfsHost->closeMemFile)(w))
#define SELF_CREATEMEMFILE(w,bp)        ((*(w)->lprfsHost->createMemFile)(w,bp))
#define SELF_GETVALUEFILE(w,i,bp,u)     ((*(w)->lprfsHost->getValueFile)(w,i,bp,u))
#define SELF_OPENMEMFILE(w,bp)          ((*(w)->lprfsHost->openMemFile)(w,bp))
#define SELF_PUTVALUEFILE(w,i,bp,u)     ((*(w)->lprfsHost->putValueFile)(w,i,bp,u))


/* Database file header handling */

#define SELF_READDBHEADER(w)            ((*(w)->lprfsHost->readDBHeader)(w))
#define SELF_WRITEDBHEADER(w)           ((*(w)->lprfsHost->writeDBHeader)(w))


/* Info operations */

#define SELF_RECSIZE(w, lp)             ((*(w)->lprfsHost->info)(w, DBI_GETRECSIZE, lp))
#define SELF_HEADERSIZE(w, fp)          ((*(w)->lprfsHost->info)(w, DBI_GETHEADERSIZE, fp))
#define SELF_LUPDATE(w, fp)             ((*(w)->lprfsHost->info)(w, DBI_LASTUPDATE, fp ))
#define SELF_SETDELIM(w, fp)            ((*(w)->lprfsHost->info)(w, DBI_SETDELIMITER, fp))
#define SELF_GETDELIM(w, fp)            ((*(w)->lprfsHost->info)(w, DBI_GETDELIMITER, fp))
#define SELF_TABLEEXT(w, fp)            ((*(w)->lprfsHost->info)(w, DBI_TABLEEXT, fp))

#define SELF_RDDNODE(w)                 hb_rddGetNode((w)->rddID)

/* non WorkArea functions */
#define SELF_INIT(r)                    ((*(r)->pTable.init)(r))
#define SELF_EXIT(r)                    ((*(r)->pTable.exit)(r))
#define SELF_DROP(r, it, ii, l)         ((*(r)->pTable.drop)(r, it, ii, l))
#define SELF_EXISTS(r, it, ii, l)       ((*(r)->pTable.exists)(r, it, ii, l))
#define SELF_RDDINFO(r, i, l, g)        ((*(r)->pTable.rddInfo)(r, i, l, g))


/*--------------------* SUPER Methods *------------------------*/

#ifndef _SUPERTABLE
#define _SUPERTABLE(w)                  SUPERTABLE
#endif
#ifndef __SUPERTABLE
#define __SUPERTABLE(w)                 SUPERTABLE
#endif

/* Movement and positioning methods */

#define SUPER_BOF(w, sp)                ((*(_SUPERTABLE(w))->bof)(w, sp))
#define SUPER_EOF(w, sp)                ((*(_SUPERTABLE(w))->eof)(w, sp))
#define SUPER_FOUND(w, sp)              ((*(_SUPERTABLE(w))->found)(w, sp))
#define SUPER_GOTO(w, l)                ((*(_SUPERTABLE(w))->go)(w, l))
#define SUPER_GOTOID(w, sp)             ((*(_SUPERTABLE(w))->goToId)(w, sp))
#define SUPER_GOBOTTOM(w)               ((*(_SUPERTABLE(w))->goBottom)(w))
#define SUPER_GOTOP(w)                  ((*(_SUPERTABLE(w))->goTop)(w))
#define SUPER_SEEK(w, i1, v, i2)        ((*(_SUPERTABLE(w))->seek)(w, i1, v, i2))
#define SUPER_SKIP(w, l)                ((*(_SUPERTABLE(w))->skip)(w, l))
#define SUPER_SKIPFILTER(w, l)          ((*(_SUPERTABLE(w))->skipFilter)(w, l))
#define SUPER_SKIPRAW(w, l)             ((*(_SUPERTABLE(w))->skipRaw)(w, l))


/* Data management */

#define SUPER_ADDFIELD(w, ip)           ((*(_SUPERTABLE(w))->addField)(w, ip))
#define SUPER_APPEND(w, b)              ((*(_SUPERTABLE(w))->append)(w, b))
#define SUPER_CREATEFIELDS(w, v)        ((*(_SUPERTABLE(w))->createFields)(w, v))
#define SUPER_DELETE(w)                 ((*(_SUPERTABLE(w))->deleterec)(w))
#define SUPER_DELETED(w, sp)            ((*(_SUPERTABLE(w))->deleted)(w, sp))
#define SUPER_FIELDCOUNT(w, sp)         ((*(_SUPERTABLE(w))->fieldCount)(w, sp))
#define SUPER_FIELDDISPLAY(w, sp)       ((*(_SUPERTABLE(w))->fieldDisplay)(w, sp))
#define SUPER_FIELDINFO(w,s1,s2,v)      ((*(_SUPERTABLE(w))->fieldInfo)(w,s1,s2,v))
#define SUPER_FIELDNAME(w, i, bp)       ((*(_SUPERTABLE(w))->fieldName)(w, i, bp))
#define SUPER_FLUSH(w)                  ((*(_SUPERTABLE(w))->flush)(w))
#define SUPER_GETREC(w, bpp)            ((*(_SUPERTABLE(w))->getRec)(w, bpp))
#define SUPER_GETVALUE(w, i, v)         ((*(_SUPERTABLE(w))->getValue)(w, i, v))
#define SUPER_GETVARLEN(w, i, lp)       ((*(_SUPERTABLE(w))->getVarLen)(w, i, lp))
#define SUPER_GOCOLD(w)                 ((*(_SUPERTABLE(w))->goCold)(w))
#define SUPER_GOHOT(w)                  ((*(_SUPERTABLE(w))->goHot)(w))
#define SUPER_PUTVALUE(w, i, v)         ((*(_SUPERTABLE(w))->putValue)(w, i, v))
#define SUPER_PUTREC(w, bp)             ((*(_SUPERTABLE(w))->putRec)(w, bp))
#define SUPER_RECALL(w)                 ((*(_SUPERTABLE(w))->recall)(w))
#define SUPER_RECCOUNT(w, lp)           ((*(_SUPERTABLE(w))->reccount)(w, lp))
#define SUPER_RECINFO(w,v1,i,v2)        ((*(_SUPERTABLE(w))->recInfo)(w,v1,i,v2))
#define SUPER_RECNO(w, lp)              ((*(_SUPERTABLE(w))->recno)(w, lp))
#define SUPER_RECID(w, i)               ((*(_SUPERTABLE(w))->recid)(w, i))
#define SUPER_SETFIELDEXTENT(w, s)      ((*(_SUPERTABLE(w))->setFieldExtent)(w, s))


/* WorkArea/Database management */

#define SUPER_ALIAS(w, bp)              ((*(_SUPERTABLE(w))->alias)(w, bp))
#define SUPER_CLOSE(w)                  ((*(_SUPERTABLE(w))->close)(w))
#define SUPER_CREATE(w, ip)             ((*(_SUPERTABLE(w))->create)(w, ip))
#define SUPER_INFO(w, i, g)             ((*(_SUPERTABLE(w))->info)(w, i, g))
#define SUPER_NEW(w)                    ((*(_SUPERTABLE(w))->newarea)(w))
#define SUPER_OPEN(w, ip)               ((*(_SUPERTABLE(w))->open)(w, ip))
#define SUPER_RELEASE(w)                ((*(_SUPERTABLE(w))->release)(w))
#define SUPER_STRUCTSIZE(w, sp)         ((*(_SUPERTABLE(w))->structSize)(w, sp))
#define SUPER_SYSNAME(w, bp)            ((*(_SUPERTABLE(w))->sysName)(w, bp))
#define SUPER_DBEVAL(w, ip)             ((*(_SUPERTABLE(w))->dbEval)(w, ip))
#define SUPER_PACK(w)                   ((*(_SUPERTABLE(w))->pack)(w))
#define SUPER_PACKREC(w, l, sp)         ((*(_SUPERTABLE(w))->packRec)(w, l, sp))
#define SUPER_SORT(w, ip)               ((*(_SUPERTABLE(w))->sort)(w, ip))
#define SUPER_TRANS(w, ip)              ((*(_SUPERTABLE(w))->trans)(w, ip))
#define SUPER_TRANSREC(w, ip)           ((*(_SUPERTABLE(w))->transRec)(w, ip))
#define SUPER_ZAP(w)                    ((*(_SUPERTABLE(w))->zap)(w))


/* Relational Methods */

#define SUPER_CHILDEND(w, ip)           ((*(_SUPERTABLE(w))->childEnd)(w, ip))
#define SUPER_CHILDSTART(w, ip)         ((*(_SUPERTABLE(w))->childStart)(w, ip))
#define SUPER_CHILDSYNC(w, ip)          ((*(_SUPERTABLE(w))->childSync)(w, ip))
#define SUPER_SYNCCHILDREN(w)           ((*(_SUPERTABLE(w))->syncChildren)(w))
#define SUPER_CLEARREL(w)               ((*(_SUPERTABLE(w))->clearRel)(w))
#define SUPER_FORCEREL(w)               ((*(_SUPERTABLE(w))->forceRel)(w))
#define SUPER_RELAREA(w, s, sp)         ((*(_SUPERTABLE(w))->relArea)(w, s, sp))
#define SUPER_RELEVAL(w, ip)            ((*(_SUPERTABLE(w))->relEval)(w, ip))
#define SUPER_RELTEXT(w, s, bp)         ((*(_SUPERTABLE(w))->relText)(w, s, bp))
#define SUPER_SETREL(w, ip)             ((*(_SUPERTABLE(w))->setRel)(w, ip))


/* Order Management */

#define SUPER_ORDLSTADD(w, lp)          ((*(_SUPERTABLE(w))->orderListAdd)(w, lp))
#define SUPER_ORDLSTDELETE(w, lp)       ((*(_SUPERTABLE(w))->orderListDelete)(w, lp))
#define SUPER_ORDLSTFOCUS(w, lp)        ((*(_SUPERTABLE(w))->orderListFocus)(w, lp))
#define SUPER_ORDLSTREBUILD(w)          ((*(_SUPERTABLE(w))->orderListRebuild)(w))
#define SUPER_ORDLSTCLEAR(w)            ((*(_SUPERTABLE(w))->orderListClear)(w))
#define SUPER_ORDSETCOND(w,ip)          ((*(_SUPERTABLE(w))->orderCondition)(w, ip))
#define SUPER_ORDCREATE(w, ip)          ((*(_SUPERTABLE(w))->orderCreate)(w, ip))
#define SUPER_ORDDESTROY(w, ip)         ((*(_SUPERTABLE(w))->orderDestroy)(w, ip))
#define SUPER_ORDDELETE(w, ip)          ((*(_SUPERTABLE(w))->orderDelete)(w, ip))
#define SUPER_ORDINFO(w, i, p)          ((*(_SUPERTABLE(w))->orderInfo)(w, i, p))
#define SUPER_ORDEXPR(w, p)             ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_EXPRESSION, p))
#define SUPER_ORDCOND(w, p)             ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_CONDITION,  p))
#define SUPER_ORDRECNO(w, p)            ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_RECNO,      p))
#define SUPER_ORDPOS(w, p)              ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_POSITION,   p))
#define SUPER_ORDNUMBER(w, p)           ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_NUMBER,     p))
#define SUPER_ORDNAME(w, p)             ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_NAME,       p))
#define SUPER_ORDBAGNAME(w, p)          ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_BAGNAME,    p))
#define SUPER_ORDBAGEXT(w,  p)          ((*(_SUPERTABLE(w))->orderInfo)(w, DBOI_BAGEXT,     p))


/* Filters and Scope Settings */

#define SUPER_CLEARFILTER(w)            ((*(_SUPERTABLE(w))->clearFilter)(w))
#define SUPER_CLEARLOCATE(w)            ((*(_SUPERTABLE(w))->clearLocate)(w))
#define SUPER_CLEARSCOPE(w)             ((*(_SUPERTABLE(w))->clearScope)(w))
#define SUPER_COUNTSCOPE(w,ip,lp)       ((*(_SUPERTABLE(w))->countScope)(w,ip,lp))
#define SUPER_FILTERTEXT(w, bp)         ((*(_SUPERTABLE(w))->filterText)(w, bp))
#define SUPER_SCOPEINFO(w,i,v)          ((*(_SUPERTABLE(w))->scopeInfo)(w,i,v))
#define SUPER_SETFILTER(w, ip)          ((*(_SUPERTABLE(w))->setFilter)(w, ip))
#define SUPER_SETLOCATE(w, ip)          ((*(_SUPERTABLE(w))->setLocate)(w, ip))
#define SUPER_SETSCOPE(w, ip)           ((*(_SUPERTABLE(w))->setScope)(w, ip))
#define SUPER_SKIPSCOPE(w, bp, l)       ((*(_SUPERTABLE(w))->skipScope)(w, bp, l))
#define SUPER_LOCATE(w, b)              ((*(_SUPERTABLE(w))->locate)(w, b))


/* Miscellaneous */

#define SUPER_COMPILE(w, bp)            ((*(_SUPERTABLE(w))->compile)(w, bp))
#define SUPER_ERROR(w, ip)              ((*(_SUPERTABLE(w))->error)(w, ip))
#define SUPER_EVALBLOCK(w, v)           ((*(_SUPERTABLE(w))->evalBlock)(w, v))


/* Network operations */

#define SUPER_GETLOCKS(w, g)            ((*(_SUPERTABLE(w))->info)(w, DBI_GETLOCKARRAY, g))
#define SUPER_RAWLOCK(w, i, l)          ((*(_SUPERTABLE(w))->rawlock)(w, i, l))
#define SUPER_LOCK(w, sp)               ((*(_SUPERTABLE(w))->lock)(w, sp))
#define SUPER_UNLOCK(w, i)              ((*(_SUPERTABLE(w))->unlock)(w, i))


/* Memofile functions */

#define SUPER_CLOSEMEMFILE(w)           ((*(_SUPERTABLE(w))->closeMemFile)(w))
#define SUPER_CREATEMEMFILE(w,bp)       ((*(_SUPERTABLE(w))->createMemFile)(w,bp))
#define SUPER_GETVALUEFILE(w,i,bp,u)    ((*(_SUPERTABLE(w))->getValueFile)(w,i,bp,u))
#define SUPER_OPENMEMFILE(w,bp)         ((*(_SUPERTABLE(w))->openMemFile)(w,bp))
#define SUPER_PUTVALUEFILE(w,i,bp,u)    ((*(_SUPERTABLE(w))->putValueFile)(w,i,bp,u))


/* Database file header handling */

#define SUPER_READDBHEADER(w)           ((*(_SUPERTABLE(w))->readDBHeader)(w))
#define SUPER_WRITEDBHEADER(w)          ((*(_SUPERTABLE(w))->writeDBHeader)(w))


/* Info operations */

#define SUPER_RECSIZE(w, lp)            ((*(_SUPERTABLE(w))->info)(w, DBI_GETRECSIZE, lp))
#define SUPER_HEADERSIZE(w, fp)         ((*(_SUPERTABLE(w))->info)(w, DBI_GETHEADERSIZE, fp))
#define SUPER_LUPDATE(w, fp)            ((*(_SUPERTABLE(w))->info)(w, DBI_LASTUPDATE, fp ))
#define SUPER_SETDELIM(w, fp)           ((*(_SUPERTABLE(w))->info)(w, DBI_SETDELIMITER, fp))
#define SUPER_GETDELIM(w, fp)           ((*(_SUPERTABLE(w))->info)(w, DBI_GETDELIMITER, fp))
#define SUPER_TABLEEXT(w, fp)           ((*(_SUPERTABLE(w))->info)(w, DBI_TABLEEXT, fp))

/* non WorkArea functions */
#define SUPER_INIT(r)                   ((*(__SUPERTABLE(r))->init)(r))
#define SUPER_EXIT(r)                   ((*(__SUPERTABLE(r))->exit)(r))
#define SUPER_DROP(r, it, ii, l)        ((*(__SUPERTABLE(r))->drop)(r, it, ii, l))
#define SUPER_EXISTS(r, it, ii, l)      ((*(__SUPERTABLE(r))->exists)(r, it, ii, l))
#define SUPER_RDDINFO(r, i, l, g)       ((*(__SUPERTABLE(r))->rddInfo)(r, i, l, g))

#define ISSUPER_INIT(r)                 ((__SUPERTABLE(r))->init != NULL)
#define ISSUPER_EXIT(r)                 ((__SUPERTABLE(r))->exit != NULL)

/*
 *  PROTOTYPES
 *  ----------
 */
 

/* internal RDD functions */
extern void hb_rddCloseDetachedAreas( void );

/* RDD virtual machine integration functions */
extern HB_EXPORT void    hb_rddShutDown( void );
extern HB_EXPORT ERRCODE hb_rddGetFieldValue( HB_ITEM_PTR pItem, PHB_SYMB pFieldSymbol );
extern HB_EXPORT ERRCODE hb_rddPutFieldValue( HB_ITEM_PTR pItem, PHB_SYMB pFieldSymbol );
extern HB_EXPORT ERRCODE hb_rddFieldGet( HB_ITEM_PTR pItem, PHB_SYMB pFieldSymbol );
extern HB_EXPORT ERRCODE hb_rddFieldPut( HB_ITEM_PTR pItem, PHB_SYMB pFieldSymbol );
extern HB_EXPORT int     hb_rddGetCurrentWorkAreaNumber( void );
extern HB_EXPORT ERRCODE hb_rddSelectWorkAreaNumber( int iArea );
extern HB_EXPORT ERRCODE hb_rddSelectWorkAreaAlias( const char * szAlias );
extern HB_EXPORT ERRCODE hb_rddSelectWorkAreaSymbol( PHB_SYMB pSymAlias );
extern HB_EXPORT ERRCODE hb_rddGetAliasNumber( const char * szAlias, int * iArea );

/* other functions */
extern HB_EXPORT void *  hb_rddAllocWorkAreaAlias( const char * szAlias, int iArea );
extern HB_EXPORT void *  hb_rddGetCurrentWorkAreaPointer( void );
extern HB_EXPORT void *  hb_rddGetWorkAreaPointer( int iArea );
extern HB_EXPORT USHORT  hb_rddInsertAreaNode( const char *szDriver );
extern HB_EXPORT void    hb_rddReleaseCurrentArea( void );

extern HB_EXPORT int       hb_rddRegister( const char * szDriver, USHORT uiType );
extern HB_EXPORT ERRCODE   hb_rddInherit( RDDFUNCS * pTable, const RDDFUNCS * pSubTable, RDDFUNCS * pSuperTable, const char * szDrvName );
extern HB_EXPORT LPRDDNODE hb_rddGetNode( USHORT uiNode );
extern HB_EXPORT LPRDDNODE hb_rddFindNode( const char * szDriver, USHORT * uiIndex );
extern HB_EXPORT USHORT    hb_rddFieldIndex( AREAP pArea, const char * szName );
extern HB_EXPORT USHORT    hb_rddFieldExpIndex( AREAP pArea, const char * szField );
extern HB_EXPORT const char * hb_rddDefaultDrv( const char * szDriver );
extern HB_EXPORT ERRCODE   hb_rddSelectFirstAvailable( void );
extern HB_EXPORT ERRCODE   hb_rddVerifyAliasName( const char * szAlias );
extern HB_EXPORT void *    hb_rddNewAreaNode( LPRDDNODE pRddNode, USHORT uiRddID );
extern HB_EXPORT PHB_ITEM  hb_rddList( USHORT uiType );
extern HB_EXPORT void      hb_rddCloseAll( void );
extern HB_EXPORT void      hb_rddFlushAll( void );
extern HB_EXPORT void      hb_rddUnLockAll( void );
extern HB_EXPORT BOOL      hb_rddGetNetErr( void );
extern HB_EXPORT void      hb_rddSetNetErr( BOOL fNetErr );

extern HB_EXPORT ERRCODE   hb_rddOpenTable( 
                              const char * szFileName, const char * szDriver,
                              USHORT uiArea, const char *szAlias,
                              BOOL fShared, BOOL fReadonly,
                              const char * szCpId, ULONG ulConnection,
                              PHB_ITEM pStruct, PHB_ITEM pDelim );
extern HB_EXPORT ERRCODE   hb_rddCreateTable(
                              const char * szFileName, const char * szDriver,
                              USHORT uiArea, const char *szAlias,
                              BOOL fKeepOpen,
                              const char * szCpId, ULONG ulConnection,
                              PHB_ITEM pStruct, PHB_ITEM pDelim );
extern HB_EXPORT ERRCODE   hb_dbTransStruct(
                              AREAP lpaSource, AREAP lpaDest,
                              LPDBTRANSINFO lpdbTransInfo,
                              PHB_ITEM *pStruct, PHB_ITEM pFields );
extern HB_EXPORT ERRCODE   hb_rddTransRecords(
                              AREAP pArea,
                              const char *szFileName, const char *szDriver,
                              ULONG ulConnection,
                              PHB_ITEM pFields, BOOL fExport,
                              PHB_ITEM pCobFor, PHB_ITEM pStrFor,
                              PHB_ITEM pCobWhile, PHB_ITEM pStrWhile,
                              PHB_ITEM pNext, PHB_ITEM pRecID,
                              PHB_ITEM pRest,
                              const char *szCpId,
                              PHB_ITEM pDelim );
extern HB_EXPORT void      hb_tblStructure( AREAP pArea, PHB_ITEM pStruct, USHORT uiSize );
extern HB_EXPORT ERRCODE   hb_rddCloseAllParentRelations( AREAP pArea );

extern HB_EXPORT ERRCODE   hb_rddDetachArea( AREAP pArea, PHB_ITEM pCargo );
extern HB_EXPORT AREAP     hb_rddRequestArea( char * szAlias, PHB_ITEM pCargo,
                                              BOOL fNewArea, BOOL fWait );

#if 0
extern HB_EXPORT ERRCODE   hb_rddDisinherit( const char * drvName );
extern HB_EXPORT USHORT    hb_rddGetCurrentFieldPos( const char * szName );
extern HB_EXPORT USHORT    hb_rddExtendType( HB_TYPE fieldType );
extern HB_EXPORT HB_TYPE   hb_rddFieldType( USHORT extendType );
#endif
typedef ERRCODE ( * WACALLBACK )( AREAP, void * );
extern HB_EXPORT ERRCODE   hb_rddIterateWorkAreas( WACALLBACK pCallBack, void * cargo );
extern HB_EXPORT ERRCODE   hb_rddGetTempAlias( char * szAliasTmp );

HB_EXTERN_END

#endif /* HB_APIRDD_H_ */
c:\harbour\include\hbassert.h
/*
 * $Id: hbassert.h 7959 2007-11-12 18:22:51Z druzus $
 */

/*
 * Harbour Project source code:
 *    assert() wrapper
 *
 * Copyright 2007 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_ASSERT_H_
#define HB_ASSERT_H_

#include "hbapi.h"

#if defined( HB_WINCE ) && defined( _MSC_VER )
   #ifndef assert
      #define assert(exp)     ((void)0)
   #endif
#else
   #include 
#endif /* HB_WINCE */

#endif /* HB_ASSERT_H_ */
c:\harbour\include\hbchksum.h
/*
 * $Id: hbchksum.h 9252 2008-08-26 11:33:03Z vszakats $
 */

/*
 * Harbour Project source code:
 *    header files for functions to calculate different checksums
 *
 * Copyright 2007 Przemyslaw Czerpak 
 * 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.
 *
 */

#include "hbapi.h"

HB_EXTERN_BEGIN

extern HB_EXPORT ULONG hb_adler32( ULONG adler, const BYTE *buf, ULONG len );
extern HB_EXPORT ULONG hb_crc16( ULONG crc, const BYTE *buf, ULONG len );
extern HB_EXPORT ULONG hb_crc32( ULONG crc, const BYTE *buf, ULONG len );
extern HB_EXPORT HB_ULONG hb_crc( HB_ULONG crc, const BYTE * buf, ULONG len, HB_ULONG poly );
extern HB_EXPORT HB_ULONG hb_crcct( HB_ULONG crc, const BYTE * buf, ULONG len, HB_ULONG poly );
extern HB_EXPORT void hb_md5( BYTE * ucData, ULONG ulLen, BYTE * ucDigest );
extern HB_EXPORT void hb_md5file( HB_FHANDLE hFile, BYTE * ucDigest );

HB_EXTERN_END
c:\harbour\include\hbcomp.h
/*
 * $Id: hbcomp.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Harbour Compiler
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

#ifndef HB_COMP_H_
#define HB_COMP_H_

#include 
#include 
#include 
#include 
#include 
#if defined(__WATCOMC__)
#include      /* alloca prototype */
#endif

#include "hbmacro.ch"
#include "hbapi.h"
#include "hberrors.h"
#include "hbpp.h"
#include "hbmacro.h"
#include "hbexprop.h"
#include "hbpcode.h"
#include "hbhash.h"

HB_EXTERN_BEGIN

/* definitions for hb_compPCodeEval() support */
typedef void * HB_VOID_PTR;
#define HB_PCODE_FUNC( func, type ) ULONG func( PFUNCTION pFunc, ULONG lPCodePos, type cargo )
typedef  HB_PCODE_FUNC( HB_PCODE_FUNC_, HB_VOID_PTR );
typedef  HB_PCODE_FUNC_ * HB_PCODE_FUNC_PTR;

extern LONG hb_compPCodeSize( PFUNCTION, ULONG );
extern void hb_compPCodeEval( PFUNCTION, const HB_PCODE_FUNC_PTR *, void * );
extern void hb_compPCodeTrace( PFUNCTION, const HB_PCODE_FUNC_PTR *, void * );

extern void hb_compGenLabelTable( PFUNCTION pFunc, PHB_LABEL_INFO label_info );
extern PHB_DEBUGINFO hb_compGetDebugInfo( HB_COMP_DECL );

extern void hb_compInitPP( HB_COMP_DECL, int argc, char * const argv[] );
extern void hb_compCompileEnd( HB_COMP_DECL );

extern int  hb_compparse( HB_COMP_DECL );
extern void hb_compParserStop( HB_COMP_DECL );

#define VS_NONE       0
#define VS_LOCAL      1
#define VS_STATIC     2
#define VS_FIELD      4
#define VS_PARAMETER  8
#define VS_THREAD     16
#define VS_PRIVATE    64
#define VS_PUBLIC     128
#define VS_MEMVAR     ( VS_PUBLIC | VS_PRIVATE )
#define VS_TH_STATIC  ( VS_STATIC | VS_THREAD )

/* return detailed information about a class of variable  */
extern int hb_compVariableScope( HB_COMP_DECL, const char * );
#define HB_VS_UNDECLARED      0
/* variables declared in a current codeblock/function/procedure */
#define HB_VS_CBLOCAL_VAR     1     /* local parameter of a codeblock */
#define HB_VS_LOCAL_VAR       2
#define HB_VS_LOCAL_MEMVAR    4
#define HB_VS_LOCAL_FIELD     8
#define HB_VS_STATIC_VAR     16
#define HB_VS_FILEWIDE       32
/* variables declared outside of a current function/procedure */
#define HB_VS_GLOBAL_MEMVAR   ( HB_VS_FILEWIDE | HB_VS_LOCAL_MEMVAR )
#define HB_VS_GLOBAL_FIELD    ( HB_VS_FILEWIDE | HB_VS_LOCAL_FIELD )
#define HB_VS_GLOBAL_STATIC   ( HB_VS_FILEWIDE | HB_VS_STATIC_VAR )

#define VU_NOT_USED           0
#define VU_INITIALIZED        1
#define VU_USED               2

#define VT_OFFSET_BYREF       60
#define VT_OFFSET_VARIANT     90
#define VT_OFFSET_OPTIONAL    90

/*
 * flags for bFlags member
 */
#define FUN_STATEMENTS        0x01  /* Function have at least one executable statement */
#define FUN_USES_STATICS      0x02  /* Function uses static variables */
#define FUN_PROCEDURE         0x04  /* This is a procedure that shouldn't return value */
#define FUN_BREAK_CODE        0x08  /* last statement breaks execution flow */
#define FUN_USES_LOCAL_PARAMS 0x10  /* parameters are declared using () */
#define FUN_WITH_RETURN       0x20  /* there was RETURN statement in previous line */
#define FUN_EXTBLOCK          0x40  /* it's extended codeblock */

extern void      hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cScope, int iType ); /* starts a new Clipper language function definition */
extern PFUNCTION hb_compFunctionFind( HB_COMP_DECL, const char * szFunName ); /* locates a previously defined function */
extern void      hb_compAnnounce( HB_COMP_DECL, const char * );

extern PINLINE   hb_compInlineAdd( HB_COMP_DECL, const char * szFunName, int iLine );
extern PINLINE   hb_compInlineFind( HB_COMP_DECL, const char * szFunName );

extern PFUNCALL  hb_compFunCallFind( HB_COMP_DECL, const char * szFunName ); /* locates a previously defined called function */
extern BOOL      hb_compFunCallCheck( HB_COMP_DECL, const char *, int );

extern void hb_compVariableAdd( HB_COMP_DECL, const char * szVarName, BYTE cType ); /* add a new param, local, static variable to a function definition or a public or private */
extern PVAR hb_compVariableFind( HB_COMP_DECL, const char * szVarName, int * piPos, int * piScope );
extern const char * hb_compLocalVariableName( PFUNCTION pFunc, USHORT wVar );   /* returns the name of local variable */
extern const char * hb_compStaticVariableName( HB_COMP_DECL, USHORT wVar );   /* returns the name of static variable */

#define HB_SYM_MEMVAR   FALSE
#define HB_SYM_ALIAS    FALSE
#define HB_SYM_MSGNAME  FALSE
#define HB_SYM_FUNCNAME TRUE
extern const char * hb_compSymbolName( HB_COMP_DECL, USHORT );   /* returns a symbol name based on its index on the symbol table */

extern PCOMDECLARED hb_compDeclaredAdd( HB_COMP_DECL, const char * );

extern PCOMCLASS hb_compClassAdd( HB_COMP_DECL, const char *, const char * );
extern PCOMCLASS hb_compClassFind( HB_COMP_DECL, const char * );
extern PCOMDECLARED hb_compMethodAdd( HB_COMP_DECL, PCOMCLASS pClass, const char * );
extern PCOMDECLARED hb_compMethodFind( PCOMCLASS pClass, const char * );
extern void hb_compDeclaredParameterAdd( HB_COMP_DECL, const char * szVarName, BYTE cValueType );

extern void hb_compGenBreak( HB_COMP_DECL );  /* generate code for BREAK statement */

extern void hb_compExternGen( HB_COMP_DECL ); /* generates the symbols for the EXTERN names */
extern void hb_compExternAdd( HB_COMP_DECL, const char * szExternName, HB_SYMBOLSCOPE cScope ); /* defines a new extern name */
extern void hb_compAutoOpenAdd( HB_COMP_DECL, const char * szName );

extern void hb_compRTVariableKill( HB_COMP_DECL, PFUNCTION );
extern void hb_compSwitchKill( HB_COMP_DECL, PFUNCTION );
extern void hb_compElseIfKill( PFUNCTION );
extern void hb_compLoopKill( PFUNCTION );

extern void hb_compGenError( HB_COMP_DECL, const char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ); /* generic parsing error management function */
extern void hb_compGenWarning( HB_COMP_DECL, const char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2); /* generic parsing warning management function */

extern BOOL hb_compForEachVarError( HB_COMP_DECL, const char * );       /* checks if it is FOR EACH enumerator variable and generates a warning */

extern ULONG hb_compGenJump( LONG, HB_COMP_DECL );                /* generates the pcode to jump to a specific offset */
extern ULONG hb_compGenJumpFalse( LONG, HB_COMP_DECL );           /* generates the pcode to jump if false */
extern ULONG hb_compGenJumpTrue( LONG, HB_COMP_DECL );            /* generates the pcode to jump if true */
extern void  hb_compGenJumpHere( ULONG, HB_COMP_DECL );           /* returns the pcode pos where to set a jump offset */
extern void  hb_compGenJumpThere( ULONG, ULONG, HB_COMP_DECL );   /* sets a jump offset */

extern void hb_compGenModuleName( HB_COMP_DECL, const char * szFunName );  /* generates the pcode with the currently compiled module and function name */
extern void hb_compLinePush( HB_COMP_DECL );             /* generates the pcode with the currently compiled source code line */
extern void hb_compLinePushIfDebugger( HB_COMP_DECL );   /* generates the pcode with the currently compiled source code line */
extern void hb_compLinePushIfInside( HB_COMP_DECL );     /* generates the pcode with the currently compiled source code line */
extern void hb_compStatmentStart( HB_COMP_DECL );        /* Check if we can start statement (without line pushing) */

extern void hb_compGenMessage( const char * szMsgName, BOOL bIsObject, HB_COMP_DECL );    /* sends a message to an object */
extern void hb_compGenMessageData( const char * szMsg, BOOL bIsObject, HB_COMP_DECL );    /* generates an underscore-symbol name for a data assignment */
extern void hb_compGenPopVar( const char * szVarName, HB_COMP_DECL );                     /* generates the pcode to pop a value from the virtual machine stack onto a variable */
extern void hb_compGenPopMemvar( const char * szVarName, HB_COMP_DECL );                  /* generates the pcode to pop a value from the virtual machine stack onto a memvar variable */
extern void hb_compGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL ); /* Pushes a number on the virtual machine stack */
extern void hb_compGenPushFunCall( const char *, HB_COMP_DECL );                          /* generates the pcode to push function's call */
extern void hb_compGenPushFunSym( const char *, HB_COMP_DECL );                           /* generates the pcode to push function's symbol */
extern void hb_compGenPushFunRef( const char *, HB_COMP_DECL );                           /* generates the pcode to push function's reference symbol */
extern void hb_compGenPushVar( const char * szVarName, BOOL bMacroVar, HB_COMP_DECL );    /* generates the pcode to push a variable value to the virtual machine stack */
extern void hb_compGenPushVarRef( const char * szVarName, HB_COMP_DECL );                 /* generates the pcode to push a variable by reference to the virtual machine stack */
extern void hb_compGenPushMemvarRef( const char * szVarName, HB_COMP_DECL );              /* generates the pcode to push memvar variable by reference to the virtual machine stack */
extern void hb_compGenPushInteger( int iNumber, HB_COMP_DECL );                           /* Pushes a integer number on the virtual machine stack */
extern void hb_compGenPushLogical( int iTrueFalse, HB_COMP_DECL );                        /* pushes a logical value on the virtual machine stack */
extern void hb_compGenPushLong( HB_LONG lNumber, HB_COMP_DECL );                          /* Pushes a long number on the virtual machine stack */
extern void hb_compGenPushDate( HB_LONG lNumber, HB_COMP_DECL );                          /* Pushes a date constant on the virtual machine stack */
extern void hb_compGenPushNil( HB_COMP_DECL );                                            /* Pushes nil on the virtual machine stack */
extern void hb_compGenPushString( const char * szText, ULONG ulLen, HB_COMP_DECL );       /* Pushes a string on the virtual machine stack */
extern void hb_compGenPushSymbol( const char * szSymbolName, BOOL bFunction, HB_COMP_DECL ); /* Pushes a symbol on to the Virtual machine stack */
extern void hb_compGenPushAliasedVar( const char *, BOOL, const char *, HB_LONG, HB_COMP_DECL );
extern void hb_compGenPopAliasedVar( const char *, BOOL, const char *, HB_LONG, HB_COMP_DECL );
extern void hb_compGenPushFunRef( const char *, HB_COMP_DECL );
extern void hb_compGenPCode1( BYTE, HB_COMP_DECL ); /* generates 1 byte of pcode */
extern void hb_compGenPCode2( BYTE, BYTE, HB_COMP_DECL ); /* generates 2 bytes of pcode + flag for optional StrongType(). */
extern void hb_compGenPCode3( BYTE, BYTE, BYTE, HB_COMP_DECL ); /* generates 3 bytes of pcode + flag for optional StrongType() */
extern void hb_compGenPCode4( BYTE, BYTE, BYTE, BYTE, HB_COMP_DECL ); /* generates 4 bytes of pcode + flag for optional StrongType() */
extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ); /* copy bytes to a pcode buffer + flag for optional StrongType() */

extern ULONG hb_compSequenceBegin( HB_COMP_DECL );
extern ULONG hb_compSequenceEnd( HB_COMP_DECL );
extern ULONG hb_compSequenceAlways( HB_COMP_DECL );
extern void hb_compSequenceFinish( HB_COMP_DECL, ULONG, ULONG, ULONG, BOOL, BOOL, BOOL );

/* support for FIELD declaration */
extern void hb_compFieldSetAlias( HB_COMP_DECL, const char *, int );
extern int  hb_compFieldsCount( HB_COMP_DECL );

/* Static variables */
extern void hb_compStaticDefStart( HB_COMP_DECL );
extern void hb_compStaticDefEnd( HB_COMP_DECL, const char * );

extern BOOL hb_compCheckUnclosedStru( HB_COMP_DECL, PFUNCTION );

#define HB_COMP_ERROR_TYPE( x )     HB_COMP_PARAM->funcs->ErrorType( HB_COMP_PARAM, x )
#define HB_COMP_ERROR_SYNTAX( x )   HB_COMP_PARAM->funcs->ErrorSyntax( HB_COMP_PARAM, x )
#define HB_COMP_ERROR_DUPLVAR( s )  HB_COMP_PARAM->funcs->ErrorDuplVar( HB_COMP_PARAM, s )

#define HB_COMP_EXPR_NEW( i )       HB_COMP_PARAM->funcs->ExprNew( HB_COMP_PARAM, i )
#define HB_COMP_EXPR_FREE( x )      HB_COMP_PARAM->funcs->ExprFree( HB_COMP_PARAM, x )
#define HB_COMP_EXPR_CLEAR( x )     HB_COMP_PARAM->funcs->ExprClear( HB_COMP_PARAM, x )
#define HB_COMP_EXPR_DELETE( x )    HB_COMP_PARAM->funcs->ExprDelete( HB_COMP_PARAM, x )

#if defined( HB_MACRO_SUPPORT )

#define HB_GEN_FUNC1( func, p1 )          hb_macroGen##func( p1, HB_COMP_PARAM )
#define HB_GEN_FUNC2( func, p1,p2 )       hb_macroGen##func( p1, p2, HB_COMP_PARAM )
#define HB_GEN_FUNC3( func, p1,p2,p3 )    hb_macroGen##func( p1, p2, p3, HB_COMP_PARAM )
#define HB_GEN_FUNC4( func, p1,p2,p3,p4 ) hb_macroGen##func( p1, p2, p3, p4, HB_COMP_PARAM )

#define hb_compErrorIndex( p, x )         hb_macroError( EG_BOUND, ( p ) )
#define hb_compErrorLValue( p, x )        hb_macroError( EG_SYNTAX, ( p ) )
#define hb_compErrorBound( p, x )         hb_macroError( EG_BOUND, ( p ) )
#define hb_compErrorAlias( p, x )         hb_macroError( EG_NOALIAS, ( p ) )
#define hb_compErrorRefer( p, x, c )      hb_macroError( EG_SYNTAX, ( p ) )
#define hb_compErrorVParams( p, x )       hb_macroError( EG_SYNTAX, ( p ) )
#define hb_compWarnMeaningless( p, x )
#define hb_compErrorMacro( p, x )

#elif !defined( HB_COMMON_SUPPORT )

#define HB_GEN_FUNC1( func, p1 )          hb_compGen##func( p1, HB_COMP_PARAM )
#define HB_GEN_FUNC2( func, p1,p2 )       hb_compGen##func( p1, p2, HB_COMP_PARAM )
#define HB_GEN_FUNC3( func, p1,p2,p3 )    hb_compGen##func( p1, p2, p3, HB_COMP_PARAM )
#define HB_GEN_FUNC4( func, p1,p2,p3,p4 ) hb_compGen##func( p1, p2, p3, p4, HB_COMP_PARAM )

extern int  hb_compMain( int argc, char * const argv[], BYTE ** pBufPtr, ULONG * pulSize, const char * szSource );
extern void hb_compOutStd( HB_COMP_DECL, const char * szMessage );
extern void hb_compOutErr( HB_COMP_DECL, const char * szMessage );

extern void hb_compExprLstDealloc( HB_COMP_DECL );

extern HB_EXPR_PTR hb_compExprGenStatement( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprGenPush( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprGenPop( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR, HB_COMP_DECL );

extern HB_EXPR_PTR hb_compErrorIndex( HB_COMP_DECL, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compErrorLValue( HB_COMP_DECL, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compErrorBound( HB_COMP_DECL, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compErrorAlias( HB_COMP_DECL, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compErrorRefer( HB_COMP_DECL, HB_EXPR_PTR, const char * );
extern HB_EXPR_PTR hb_compWarnMeaningless( HB_COMP_DECL, HB_EXPR_PTR );
extern void        hb_compErrorMacro( HB_COMP_DECL, const char * );
extern void        hb_compErrorVParams( HB_COMP_DECL, const char * );

extern HB_EXPR_PTR hb_compErrorStatic( HB_COMP_DECL, const char *, HB_EXPR_PTR );
extern void        hb_compErrorCodeblock( HB_COMP_DECL, const char * );

extern BOOL        hb_compIsValidMacroText( HB_COMP_DECL, const char *, ULONG );

/* Codeblocks */
extern void hb_compCodeBlockStart( HB_COMP_DECL, BOOL ); /* starts a codeblock creation */
extern void hb_compCodeBlockEnd( HB_COMP_DECL );         /* end of codeblock creation */
extern void hb_compCodeBlockStop( HB_COMP_DECL );        /* end of fake codeblock */
extern void hb_compCodeBlockRewind( HB_COMP_DECL );      /* restart of fake codeblock */

#endif    /* HB_MACRO_SUPPORT */


extern ULONG hb_compExprListEval( HB_COMP_DECL, HB_EXPR_PTR pExpr, HB_CARGO_FUNC_PTR pEval );
extern ULONG hb_compExprListEval2( HB_COMP_DECL, HB_EXPR_PTR pExpr1, HB_EXPR_PTR pExpr2, HB_CARGO2_FUNC_PTR pEval );

extern void hb_compChkCompilerSwitch( HB_COMP_DECL, int, char * const Args[] );
extern void hb_compChkPaths( HB_COMP_DECL );
extern void hb_compChkDefines( HB_COMP_DECL, int iArg, char * const Args[] );

extern void hb_compPrintUsage( HB_COMP_DECL, const char * );
extern void hb_compPrintCredits( HB_COMP_DECL );
extern void hb_compPrintLogo( HB_COMP_DECL );
extern void hb_compPrintModes( HB_COMP_DECL );

/* Misc functions defined in harbour.c */
extern void hb_compNOOPfill( PFUNCTION pFunc, ULONG ulFrom, int iCount, BOOL fPop, BOOL fCheck );
extern BOOL hb_compIsJump( HB_COMP_DECL, PFUNCTION pFunc, ULONG ulPos );

/* Misc functions defined in hbfix.c */
extern void hb_compFixFuncPCode( HB_COMP_DECL, PFUNCTION pFunc );
/* Misc functions defined in hbdead.c */
extern void hb_compCodeTraceMarkDead( HB_COMP_DECL, PFUNCTION pFunc );
/* Misc functions defined in hbopt.c */
extern void hb_compOptimizePCode( HB_COMP_DECL, PFUNCTION pFunc );
/* Misc functions defined in hbstripl.c */
extern void hb_compStripFuncLines( PFUNCTION pFunc );

/* output related functions defined in gen*.c */
extern void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME );      /* generates the C language output */
extern void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME );    /* generates the portable objects */
extern void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME );     /* generates the .NET IL language output */
extern void hb_compGenJava( HB_COMP_DECL, PHB_FNAME );       /* generates the Java language output */
extern void hb_compGenObj32( HB_COMP_DECL, PHB_FNAME );      /* generates OBJ 32 bits */
extern void hb_compGenCObj( HB_COMP_DECL, PHB_FNAME );       /* generates platform dependant object module */

extern void hb_compGenBufPortObj( HB_COMP_DECL, BYTE ** pBufPtr, ULONG * pulSize ); /* generates the portable objects to memory buffer */

extern void hb_compGenCRealCode( HB_COMP_DECL, PFUNCTION pFunc, FILE * yyc );
extern void hb_compGenCString( FILE * yyc, BYTE * pText, ULONG ulLen );

/* hbident.c   */
extern const char * hb_compIdentifierNew( HB_COMP_DECL, const char * szName, int iType ); /* create the reusable identifier */
extern void hb_compIdentifierOpen( HB_COMP_DECL ); /* prepare the table of identifiers */
extern void hb_compIdentifierClose( HB_COMP_DECL ); /* release the table of identifiers */

/* global readonly variables used by compiler
 */

extern const char *  hb_comp_szErrors[];
extern const char *  hb_comp_szWarnings[];

/* table with PCODEs' length */
extern const BYTE    hb_comp_pcode_len[];

/* identifier types for hb_compIdentifierNew() */
#define HB_IDENT_STATIC       0
#define HB_IDENT_FREE         1
#define HB_IDENT_COPY         2

/* /GC command line setting types */
#define HB_COMPGENC_COMPACT     0
#define HB_COMPGENC_NORMAL      1
#define HB_COMPGENC_VERBOSE     2
#define HB_COMPGENC_REALCODE    3

/* /ES command line setting types */
#define HB_EXITLEVEL_DEFAULT    0
#define HB_EXITLEVEL_SETEXIT    1
#define HB_EXITLEVEL_DELTARGET  2

/* /kx command line setting types - compatibility modes
 * (turn on a bit in ULONG word)
*/
#define HB_COMPFLAG_HARBOUR      HB_SM_HARBOUR     /* 1 -kh */
#define HB_COMPFLAG_XBASE        HB_SM_XBASE       /* 2 -kx */
#define HB_COMPFLAG_SHORTCUTS    HB_SM_SHORTCUTS   /* 8 -z enable sortcuts for logical operators */
#define HB_COMPFLAG_ARRSTR       HB_SM_ARRSTR      /* 16 -ks strings as array of bytes */
#define HB_COMPFLAG_RT_MACRO     HB_SM_RT_MACRO    /* 64 -kr */
#define HB_COMPFLAG_OPTJUMP      256               /* -kj turn off jump optimalization */
#define HB_COMPFLAG_HB_INLINE    512               /* -ki hb_inLine(...) { ... } support */
#define HB_COMPFLAG_MACROTEXT    1024              /* -kM turn off macrotext substitution */

#define HB_COMP_ISSUPPORTED(flag)   ( HB_COMP_PARAM->supported & (flag) )

#define HB_SUPPORT_XBASE            ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_XBASE) )
#define HB_SUPPORT_HARBOUR          ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) )
#define HB_SUPPORT_ARRSTR           ( HB_COMP_ISSUPPORTED(HB_COMPFLAG_ARRSTR) )

#if defined( HB_MACRO_SUPPORT )
#  define HB_MACRO_GENFLAGS   HB_COMPFLAG_RT_MACRO
#elif ! defined( HB_COMMON_SUPPORT )
#  define HB_MACRO_GENFLAGS   ( ( ( BYTE ) HB_COMP_PARAM->supported ) & \
                                ( HB_COMPFLAG_HARBOUR | \
                                  HB_COMPFLAG_XBASE | \
                                  HB_COMPFLAG_SHORTCUTS | \
                                  HB_COMPFLAG_ARRSTR | \
                                  HB_COMPFLAG_RT_MACRO ) )
#endif

HB_EXTERN_END

#endif /* HB_COMP_H_ */
c:\harbour\include\hbcompdf.h
/*
 * $Id: hbcompdf.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 *    definitions shared by compiler and macro compiler
 *
 * Copyright 2006 Przemyslaw Czerpak 
 * 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.
 *
 */


#ifndef HB_COMPDF_H_
#define HB_COMPDF_H_

#include "hbapi.h"
#include "hbpp.h"
#include "hbhash.h"

HB_EXTERN_BEGIN

/* compiler related declarations */

/* Output types */
typedef enum
{
   HB_LANG_C,                      /* C language (by default)  */
   HB_LANG_OBJ32,                  /* DOS/Windows 32 bits  */
   HB_LANG_PORT_OBJ,               /* Portable objects  */
   HB_LANG_PORT_OBJ_BUF,           /* Portable objects in memory buffer */
   HB_LANG_OBJ_MODULE              /* Platform dependant object module  */
} HB_LANGUAGES;                    /* supported Harbour output languages */

struct _COMCLASS;    /* forward declaration */

/* Declared Function/Method support structure */
typedef struct _COMDECLARED
{
   const char          * szName;              /* the name of the symbol */
   BYTE                  cType;
   USHORT                iParamCount;
   BYTE                * cParamTypes;
   struct _COMCLASS    * pClass;
   struct _COMCLASS    * ( * pParamClasses );
   struct _COMDECLARED * pNext;               /* pointer to the next declared function */
} COMDECLARED, * PCOMDECLARED;

/* Declared Class support structure */
typedef struct _COMCLASS
{
   const char       * szName;
   PCOMDECLARED       pMethod;
   PCOMDECLARED       pLastMethod;
   struct _COMCLASS * pNext;
} COMCLASS, * PCOMCLASS;

/* locals, static, public variables support */
typedef struct _VAR
{
   const char *   szName;           /* variable name */
   const char *   szAlias;          /* variable alias namespace */
   int            iUsed;            /* number of times used */
   int            iDeclLine;        /* declaration line number */
   USHORT         uiFlags;          /* optional falgs, f.e. THREAD STATIC */
   BYTE           cType;            /* optional strong typing */
   PCOMCLASS      pClass;
   struct _VAR * pNext;            /* pointer to next defined variable */
} VAR, * PVAR;

/* local variables declared in a codeblock */
typedef struct HB_CBVAR_
{
   const char * szName;
   BYTE bType;
   BOOL bUsed;
   struct HB_CBVAR_ * pNext;
} HB_CBVAR, * HB_CBVAR_PTR;

/* value types seen at language level
 */
#define  HB_EV_UNKNOWN     0x0000
#define  HB_EV_NIL         0x0001
#define  HB_EV_NUMERIC     0x0002
#define  HB_EV_STRING      0x0004
#define  HB_EV_CODEBLOCK   0x0008
#define  HB_EV_LOGICAL     0x0010
#define  HB_EV_OBJECT      0x0020
#define  HB_EV_ARRAY       0x0040
#define  HB_EV_SYMBOL      0x0080
#define  HB_EV_VARREF      0x0100
#define  HB_EV_FUNREF      0x0200
#define  HB_EV_DATE        0x0400
#define  HB_EV_HASH        0x0800

/* messages sent to expressions
 */
typedef enum
{
   HB_EA_REDUCE = 0,    /* reduce the expression into optimized one */
   HB_EA_ARRAY_AT,      /* check if the expession can be used as array */
   HB_EA_ARRAY_INDEX,   /* check if the expession can be used as index */
   HB_EA_LVALUE,        /* check if the expression can be used as lvalue (left side of an assigment) */
   HB_EA_PUSH_PCODE,    /* generate the pcodes to push the value of expression */
   HB_EA_POP_PCODE,     /* generate the pcodes to pop the value of expression */
   HB_EA_PUSH_POP,      /* generate the pcodes to push and pop the expression */
   HB_EA_STATEMENT,     /* generate the pcodes for a statement */
   HB_EA_DELETE         /* delete components of the expression */
} HB_EXPR_MESSAGE;

/* additional definitions used to distinguish numeric expressions
 */
#define  HB_ET_LONG     1
#define  HB_ET_DOUBLE   2

/* additional definitions used to distinguish macro expressions
 */
#define  HB_ET_MACRO_VAR      0   /* &variable */
#define  HB_ET_MACRO_SYMBOL   1   /* &fimcall() */
#define  HB_ET_MACRO_ALIASED  2   /* &alias->&variable */
#define  HB_ET_MACRO_EXPR     4   /* &( expr ) */
#define  HB_ET_MACRO_LIST    16   /* &variable used as in literal arrays or function call argument. */
#define  HB_ET_MACRO_PARE    32   /* &variable used as parentesised expressions. */
#define  HB_ET_MACRO_REFER   64   /* ¯o used in @ (pass by reference) */
#define  HB_ET_MACRO_ASSIGN 128   /* o:&msgname := value */

/* types of expressions
 * NOTE: the order of these definition is important - change it carefully
 *    All types <= HB_ET_FUNREF are constant values
 *    All types <= HB_ET_VARIABLE are a simple values
 *    All types > HB_ET_VARIABLE are operators
 */
typedef enum
{
   HB_ET_NONE = 0,
   HB_ET_NIL,
   HB_ET_NUMERIC,
   HB_ET_DATE,
   HB_ET_STRING,
   HB_ET_CODEBLOCK,
   HB_ET_LOGICAL,
   HB_ET_SELF,
   HB_ET_ARRAY,
   HB_ET_HASH,
   HB_ET_VARREF,
   HB_ET_REFERENCE,
   HB_ET_FUNREF,
   HB_ET_IIF,
   HB_ET_LIST,
   HB_ET_ARGLIST,
   HB_ET_MACROARGLIST,
   HB_ET_ARRAYAT,
   HB_ET_MACRO,
   HB_ET_FUNCALL,
   HB_ET_ALIASVAR,
   HB_ET_ALIASEXPR,
   HB_ET_SEND,
   HB_ET_FUNNAME,
   HB_ET_ALIAS,
   HB_ET_RTVAR,      /* PRIVATE or PUBLIC declaration of variable */
   HB_ET_VARIABLE,
   HB_EO_POSTINC,    /* post-operators -> lowest precedence */
   HB_EO_POSTDEC,
   HB_EO_ASSIGN,     /* assigments */
   HB_EO_PLUSEQ,
   HB_EO_MINUSEQ,
   HB_EO_MULTEQ,
   HB_EO_DIVEQ,
   HB_EO_MODEQ,
   HB_EO_EXPEQ,
   HB_EO_OR,         /* logical operators */
   HB_EO_AND,
   HB_EO_NOT,
   HB_EO_EQUAL,      /* relational operators */
   HB_EO_EQ,
   HB_EO_NE,
   HB_EO_IN,
   HB_EO_LT,
   HB_EO_GT,
   HB_EO_LE,
   HB_EO_GE,
   HB_EO_PLUS,       /* addition */
   HB_EO_MINUS,
   HB_EO_MULT,       /* multiple */
   HB_EO_DIV,
   HB_EO_MOD,
   HB_EO_POWER,
   HB_EO_NEGATE,     /* sign operator */
   HB_EO_PREINC,
   HB_EO_PREDEC      /* pre-operators -> the highest precedence */
} HB_EXPR_OPERATOR;

#define HB_EXPR_COUNT   ( HB_EO_PREDEC + 1 )

typedef USHORT HB_EXPRTYPE;

typedef struct HB_EXPR_
{
   union
   {
      const char *asSymbol;/* variable name */
      BOOL asLogical;      /* logical value */
      struct
      {
         char *string;        /* literal strings */
         BOOL dealloc;        /* automatic deallocate on expresion deletion */
      } asString;
      struct
      {
         struct HB_EXPR_ *pMacro;   /* macro variable */
         const char *szName;        /* variable name  */
      } asRTVar;                 /* PUBLIC or PRIVATE variable declaration */
      struct
      {
         union {
            HB_LONG  l;             /* long value */
            double   d;             /* double value */
         } val;
         unsigned char bWidth;   /* unsigned char used intentionally */
         unsigned char bDec;     /* unsigned char used intentionally */
         unsigned char NumType;  /* used to distinguish LONG and DOUBLE */
      } asNum;
      struct
      {
         const char * szMacro;         /* identifier after the macro operator */
         struct HB_EXPR_ *pExprList;   /* list elements if &(...) was used */
         USHORT SubType;               /* context in which macro is used */
         unsigned char cMacroOp;       /* macro operator */
      } asMacro;
      struct
      {
         struct HB_EXPR_ *pExprList;   /* list elements */
         struct HB_EXPR_ *pIndex;      /* array index, others */
         BOOL     reference;           /* push array item by reference or pass variable parameters to called function or method */
      } asList;
      struct
      {
         struct HB_EXPR_ *pExprList;   /* list elements */
         HB_CBVAR_PTR pLocals;         /* list of local variables */
         char     *string;             /* source code of a codeblock */
         USHORT   flags;               /* HB_BLOCK_MACRO, HB_BLOCK_LATEEVAL, HB_BLOCK_VPARAMS */
      } asCodeblock;
      struct
      {
         struct HB_EXPR_ *pAlias;      /* alias expression */
         struct HB_EXPR_ *pVar;        /* aliased variable or macro */
         struct HB_EXPR_ *pExpList;    /* aliased expression list */
      } asAlias;
      struct
      {
         struct HB_EXPR_ *pFunName;     /* function name */
         struct HB_EXPR_ *pParms;       /* function call parameters */
      } asFunCall;
      struct
      {
         struct HB_EXPR_ *pObject;     /* object */
         struct HB_EXPR_ *pParms;      /* method parameters */
         const char * szMessage;       /* message as string */
         struct HB_EXPR_ *pMessage;    /* message as macro */
      } asMessage;
      struct
      {
         struct HB_EXPR_ *pLeft;       /* object */
         struct HB_EXPR_ *pRight;      /* object */
      } asOperator;
      struct HB_EXPR_ *asReference;
   } value;
   ULONG ulLength;
   ULONG Counter;
   HB_EXPRTYPE ExprType;      /* internal expression type */
   USHORT ValType;            /* language level value type */
   struct HB_EXPR_ *pNext;    /* next expression in the list of expressions */
} HB_EXPR, *HB_EXPR_PTR;

typedef struct HB_ENUMERATOR_
{
   const char *szName;
   BOOL bForEach;
   struct HB_ENUMERATOR_ *pNext;
} HB_ENUMERATOR, *HB_ENUMERATOR_PTR; /* support structure for FOR EACH statements */

/* support structure for else if pcode fixups */
typedef struct HB_ELSEIF_
{
   ULONG    ulOffset;
   struct   HB_ELSEIF_ * pElseif;   /* next ELSEIF in the current IF statement */
   struct   HB_ELSEIF_ * pPrev;     /* previous IF statement */
} HB_ELSEIF, * HB_ELSEIF_PTR;      

/* support structure for EXIT and LOOP statements */
typedef struct HB_LOOPEXIT_
{
   ULONG    ulOffset;
   BOOL     fCanLoop;
   USHORT   wSeqCounter;
   USHORT   wAlwaysCounter;
   USHORT   wWithObjectCnt;
   struct HB_LOOPEXIT_ * pLoopList;
   struct HB_LOOPEXIT_ * pExitList;
   struct HB_LOOPEXIT_ * pNext;
} HB_LOOPEXIT, * HB_LOOPEXIT_PTR;  

/* support structure for SWITCH statement */
typedef struct HB_SWITCHCASE_
{
   ULONG ulOffset;
   HB_EXPR_PTR pExpr;
   struct HB_SWITCHCASE_ *pNext;
} HB_SWITCHCASE, * HB_SWITCHCASE_PTR;

typedef struct HB_SWITCHCMD_
{
   ULONG ulOffset;
   int iCount;
   HB_SWITCHCASE_PTR pCases;
   HB_SWITCHCASE_PTR pLast;
   ULONG ulDefault;
   struct HB_SWITCHCMD_ *pPrev;
} HB_SWITCHCMD, *HB_SWITCHCMD_PTR;

/* support structure for PUBLIC and PRIVATE statements */
typedef struct HB_RTVAR_
{
   HB_EXPR_PTR pVar;
   BOOL bPopValue;
   struct HB_RTVAR_ *pNext;
   struct HB_RTVAR_ *pPrev;
} HB_RTVAR, *HB_RTVAR_PTR;

/* structure to hold a Clipper defined function */
typedef struct __FUNC
{
   const char * szName;                   /* name of a defined Clipper function */
   HB_SYMBOLSCOPE cScope;                 /* scope of a defined Clipper function */
   BYTE         bFlags;                   /* some flags we may need */
   USHORT       wParamCount;              /* number of declared parameters */
   USHORT       wParamNum;                /* current parameter number */
   PVAR         pLocals;                  /* pointer to local variables list */
   PVAR         pStatics;                 /* pointer to static variables list */
   PVAR         pFields;                  /* pointer to fields variables list */
   PVAR         pMemvars;                 /* pointer to memvar variables list */
   PVAR         pDetached;                /* pointer to detached local variables list */
   PVAR         pPrivates;                /* pointer to private variables list */
   BYTE *       pCode;                    /* pointer to a memory block where pcode is stored */
   ULONG        lPCodeSize;               /* total memory size for pcode */
   ULONG        lPCodePos;                /* actual pcode offset */
   int          iStaticsBase;             /* base for this function statics */
   ULONG *      pNOOPs;                   /* pointer to the NOOP array */
   ULONG *      pJumps;                   /* pointer to the Jumps array */
   ULONG        iNOOPs;                   /* NOOPs Counter */
   ULONG        iJumps;                   /* Jumps Counter */
   BOOL         bLateEval;                /* TRUE if accessing of declared (compile time) variables is allowed */
   BOOL         fVParams;                 /* TRUE if variable number of parameters is used */
   BOOL         bError;                   /* error during function compilation */
   struct __FUNC * pOwner;                /* pointer to the function/procedure that owns the codeblock */
   struct __FUNC * pNext;                 /* pointer to the next defined function */
   HB_ENUMERATOR_PTR pEnum;               /* pointer to FOR EACH variables */
   HB_LOOPEXIT_PTR   pLoops;
   HB_SWITCHCMD_PTR  pSwitch;
   HB_ELSEIF_PTR     elseif;
   HB_RTVAR_PTR      rtvars;
   USHORT            wSeqCounter;
   USHORT            wAlwaysCounter;
   USHORT            wForCounter;
   USHORT            wIfCounter;
   USHORT            wWhileCounter;
   USHORT            wCaseCounter;
   USHORT            wSwitchCounter;
   USHORT            wWithObjectCnt;
} _FUNC, * PFUNCTION;

/* structure to hold an INLINE block of source */
typedef struct __INLINE
{
   const char * szName;                   /* name of a inline function */
   BYTE *       pCode;                    /* pointer to a memory block where pcode is stored */
   ULONG        lPCodeSize;               /* total memory size for pcode */
   const char * szFileName;               /* Source file name */
   int          iLine;                    /* Source line number */
   struct __INLINE * pNext;               /* pointer to the next defined inline */
} _INLINE, * PINLINE;

/* structure to hold a called functions */
typedef struct __FUNCALL
{
   const char * szName;                   /* name of a called function */
   struct __FUNCALL * pNext;              /* pointer to the next called function */
} _FUNCALL, * PFUNCALL;

/* structure to control all Clipper defined functions */
typedef struct
{
   PFUNCTION pFirst;            /* pointer to the first defined funtion */
   PFUNCTION pLast;             /* pointer to the last defined function */
   int       iCount;            /* number of defined functions */
} FUNCTIONS;

/* structure to control all Clipper defined functions */
typedef struct
{
   PINLINE pFirst;            /* pointer to the first defined inline */
   PINLINE pLast;             /* pointer to the last defined inline */
   int     iCount;            /* number of defined inlines */
} INLINES;

/* structure to control all Clipper defined functions */
typedef struct
{
   PFUNCALL  pFirst;            /* pointer to the first called funtion */
   PFUNCALL  pLast;             /* pointer to the last called function */
   int       iCount;            /* number of defined functions */
} FUNCALLS;

/* compiler symbol support structure */
typedef struct _COMSYMBOL
{
   const char *   szName;               /* the name of the symbol */
   HB_SYMBOLSCOPE cScope;               /* the scope of the symbol */
   BOOL           bFunc;      /* is it a function name (TRUE) or memvar (FALSE) */
   PCOMCLASS      pClass;
   struct _COMSYMBOL * pNext; /* pointer to the next defined symbol */
} COMSYMBOL, * PCOMSYMBOL;

/* symbol table support structures */
typedef struct
{
   PCOMSYMBOL pFirst;           /* pointer to the first defined symbol */
   PCOMSYMBOL pLast;            /* pointer to the last defined symbol */
   int        iCount;           /* number of defined symbols */
} SYMBOLS;

typedef struct __EXTERN
{
   const char * szName;         /* name of the extern function */
   HB_SYMBOLSCOPE cScope;       /* the scope of the function */
   struct __EXTERN * pNext;
} _EXTERN, * PEXTERN;      /* support structure for extern symbols */
/* as they have to be placed on the symbol table later than the first public symbol */

typedef struct _AUTOOPEN
{
   const char * szName;
   struct _AUTOOPEN * pNext;
} AUTOOPEN, * PAUTOOPEN;      /* support structure for extern symbols */

typedef struct _HB_DEBUGINFO
{
   char *   pszModuleName;
   ULONG    ulFirstLine;
   ULONG    ulLastLine;
   ULONG    ulAllocated;
   BYTE *   pLineMap;
   struct _HB_DEBUGINFO * pNext;
} HB_DEBUGINFO, * PHB_DEBUGINFO;

typedef struct _HB_LABEL_INFO
{
   FILE *   yyc;
   BOOL     fVerbose;
   BOOL     fSetSeqBegin;
   BOOL     fCondJump;
   int      iNestedBlock;
   ULONG *  pulLabels;
} HB_LABEL_INFO, * PHB_LABEL_INFO;

#define HB_MODE_COMPILER      1
#define HB_MODE_MACRO         2

struct _HB_COMP_FUNCS;

#if defined( HB_COMMON_SUPPORT )

typedef struct _HB_COMMON
{
   /* common to macro compiler members */
   int    mode;               /* HB_MODE_* */
   ULONG  supported;          /* various flags for supported capabilities */
   const struct _HB_COMP_FUNCS * funcs;
}
HB_COMMON, * HB_COMMON_PTR;

#define HB_COMP_PARAM         pCommon
#define HB_COMP_DECL          HB_COMMON_PTR HB_COMP_PARAM

#elif defined( HB_MACRO_SUPPORT )

#define HB_COMP_PARAM         pMacro
#define HB_COMP_DECL          HB_MACRO_PTR HB_COMP_PARAM

typedef struct HB_PCODE_INFO_ /* compiled pcode container for macro compiler */
{
   BYTE * pCode;           /* pointer to a memory block where pcode is stored */
   ULONG  lPCodeSize;      /* total memory size for pcode */
   ULONG  lPCodePos;       /* actual pcode offset */
   BOOL   fVParams;        /* function/codeblock with variable parameters */
   struct HB_PCODE_INFO_ * pPrev;
   HB_CBVAR_PTR pLocals;
} HB_PCODE_INFO, * HB_PCODE_INFO_PTR;

typedef struct HB_MACRO_    /* a macro compiled pcode container */
{
   /* common to compiler members */
   int    mode;            /* HB_MODE_* */
   ULONG  supported;       /* various flags for supported capabilities */
   const struct _HB_COMP_FUNCS * funcs;

   /* macro compiler only members */
   char * string;          /* compiled string */
   ULONG  length;          /* length of the string */
   int    Flags;           /* some flags we may need */
   int    status;          /* status of compilation */
   HB_ITEM_PTR pError;     /* error object returned from the parser */
   HB_PCODE_INFO_PTR pCodeInfo;  /* pointer to pcode buffer and info */
   void * pLex;            /* lexer buffer pointer */
   void * pExprLst;        /* list with allocated expressions */
   void * pIdentLst;       /* list with allocated identifiers */
   int    exprType;        /* type of successfully compiled expression */
   USHORT uiListElements;  /* number of elements in macro list expression */
   USHORT uiNameLen;       /* the maximum symbol name length */
} HB_MACRO;

#else

#define HB_COMP_PARAM         pComp
#define HB_COMP_DECL          HB_COMP_PTR HB_COMP_PARAM

typedef struct _HB_I18NSTRING
{
   char*      szText;
   char*      szContext;
   UINT       uiLine;
   UINT*      pLine;
   UINT       uiLineCount;
} HB_I18NSTRING, * PHB_I18NSTRING;

typedef struct _HB_I18NTABLE
{
   PHB_I18NSTRING    pString;
   ULONG             uiCount;
   ULONG             uiAllocated;
} HB_I18NTABLE, * PHB_I18NTABLE;

typedef struct _HB_COMP_LEX
{
   PHB_PP_STATE   pPP;
   int            iState;
   BOOL           fEol;
   const char *   lasttok;
}
HB_COMP_LEX, * PHB_COMP_LEX;

typedef struct _HB_EXPRLST
{
   HB_EXPR Expression;
   struct _HB_EXPRLST *pPrev;
   struct _HB_EXPRLST *pNext;
}
HB_EXPRLST, * PHB_EXPRLST;

typedef struct _HB_COMP
{
   /* common to macro compiler members */
   int    mode;            /* HB_MODE_* */
   ULONG  supported;       /* various flags for supported capabilities */
   const struct _HB_COMP_FUNCS * funcs;

   /* compiler only members */
   PHB_COMP_LEX      pLex;
   PHB_EXPRLST       pExprLst;

   HB_HASH_TABLE_PTR pIdentifiers;
   FUNCTIONS         functions;
   FUNCALLS          funcalls;
   SYMBOLS           symbols;
   INLINES           inlines;
   PEXTERN           externs;
   PAUTOOPEN         autoopen;

   PCOMDECLARED      pFirstDeclared;
   PCOMDECLARED      pLastDeclared;
   PCOMDECLARED      pLastMethod;
   PCOMCLASS         pFirstClass;
   PCOMCLASS         pLastClass;

   PFUNCTION         pInitFunc;
   PFUNCTION         pLineFunc;
   PHB_FNAME         pMainFileName;
   PHB_FNAME         pFileName;
   PHB_FNAME         pOutPath;
   PHB_FNAME         pPpoPath;
   PHB_FNAME         pI18nFileName;
   PHB_I18NTABLE     pI18n;
   BOOL              fI18n;

   void              ( * outStdFunc ) ( void *, const char* );
   void              ( * outErrFunc ) ( void *, const char* );
   void *            cargo;
   
   ULONG             ulOutBufSize;        /* memory output buffer size */
   BYTE *            pOutBuf;             /* memory output buffer address */

   ULONG             lastLinePos;         /* position of last opcode with line number */
   int               lastLine;            /* last generated in PCODE line number */
   int               currLine;            /* currently compiled line number */
   const char *      lastModule;          /* last generated in PCODE module name */
   const char *      currModule;          /* currently compiled module name */

   const char *      szAnnounce;
   char *            szStdCh;             /* standard definitions file name (-u) */
   const char *      szFromClass;
   const char *      szDeclaredFun;
   const char *      szFile;              /* Source file name of compiled module */
   char              szPrefix[ 20 ];      /* holds the prefix added to the generated symbol init function name (in C output currently) */

   char              cVarType;            /* current declared variable type */
   char              cDataListType;       /* current declared variable list type */
   char              cCastType;           /* current casting type */

   int               iPassByRef;          /* check if it's possible to pass variable be reference, can be removed */

   int               iErrorCount;
   int               iFunctionCnt;
   int               iMaxTransCycles;     /* maximum translate cycles in PP (-r=) */
   int               iHidden;             /* hide strings */
   int               iWarnings;           /* enable parse warnings */
   int               iExitLevel;          /* holds if there was any warning during the compilation process */
   int               iStaticCnt;          /* number of defined statics variables on the PRG */
   int               iVarScope;           /* holds the scope for next variables to be defined */
   int               iLanguage;           /* default Harbour generated output language */
   int               iGenCOutput;         /* C code generation should be verbose (use comments) or not */
   int               ilastLineErr;        /* line numer with last syntax error */

   BOOL              fQuiet;              /* be quiet during compilation (-q) */
   BOOL              fFullQuiet;          /* be quiet during compilation disable all messages */
   BOOL              fExit;               /* force breaking compilation process */
   BOOL              fPPO;                /* flag indicating, is ppo output needed */
   BOOL              fPPT;                /* flag indicating, is ppt output needed */
   BOOL              fStartProc;          /* holds if we need to create the starting procedure */
   BOOL              fLineNumbers;        /* holds if we need pcodes with line numbers */
   BOOL              fAnyWarning;         /* holds if there was any warning during the compilation process */
   BOOL              fAutoMemvarAssume;   /* holds if undeclared variables are automatically assumed MEMVAR (-a)*/
   BOOL              fForceMemvars;       /* holds if memvars are assumed when accesing undeclared variable (-v)*/
   BOOL              fDebugInfo;          /* holds if generate debugger required info */
   BOOL              fNoStartUp;          /* C code generation embed HB_FS_FIRST or not */
   BOOL              fCredits;            /* print credits */
   BOOL              fBuildInfo;          /* print build info */
   BOOL              fLogo;               /* print logo */
   BOOL              fSyntaxCheckOnly;    /* syntax check only */
   BOOL              fTextSubst;          /* check if string variables are macros (&) which needs substitution */
   BOOL              fLongOptimize;       /* optimize PCODEs generated for integers */
   BOOL              fAutoOpen;           /* automatically compile DO...[WITH...] external modules (-m) */
   BOOL              fError;              /* error appeared during compilation */
   BOOL              fMeaningful;         /* do not generate warnings about meaningless expression usage */
}
HB_COMP, * HB_COMP_PTR;

extern HB_COMP_PTR hb_comp_new( void );
extern void hb_comp_free( HB_COMP_PTR );

#endif /* !HB_MACRO_SUPPORT  */

typedef struct _HB_COMP_FUNCS
{
   HB_EXPR_PTR ( * ExprNew )        ( HB_COMP_DECL, HB_EXPRTYPE iType );
   void        ( * ExprClear )      ( HB_COMP_DECL, HB_EXPR_PTR pExpr );
   void        ( * ExprFree )       ( HB_COMP_DECL, HB_EXPR_PTR pExpr );
   void        ( * ExprDelete )     ( HB_COMP_DECL, HB_EXPR_PTR pExpr );

   HB_EXPR_PTR ( * ErrorType )      ( HB_COMP_DECL, HB_EXPR_PTR );
   HB_EXPR_PTR ( * ErrorSyntax )    ( HB_COMP_DECL, HB_EXPR_PTR );
   void        ( * ErrorDuplVar )   ( HB_COMP_DECL, const char* );
} HB_COMP_FUNCS, * PHB_COMP_FUNCS;


#define HB_MACRO_DATA         HB_COMP_PARAM
#define HB_PCODE_DATA         ( HB_MACRO_DATA->pCodeInfo )


/*Support for traversing of linked list */
#define  HB_CARGO_FUNC( proc )   void proc( HB_COMP_DECL, void *cargo )
typedef  HB_CARGO_FUNC( HB_CARGO_FUNC_ );
typedef  HB_CARGO_FUNC_ *HB_CARGO_FUNC_PTR;

#define  HB_CARGO2_FUNC( proc )  void proc( HB_COMP_DECL, void *cargo, void *dummy )
typedef  HB_CARGO2_FUNC( HB_CARGO2_FUNC_ );
typedef  HB_CARGO2_FUNC_ *HB_CARGO2_FUNC_PTR;

/* pcode chunks bytes size */
#define HB_PCODE_CHUNK   100


HB_EXTERN_END

#endif /* HB_COMPDF_H_ */
c:\harbour\include\hbdate.h
/*
 * $Id: hbdate.h 8964 2008-07-09 09:57:33Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Date API
 *
 * Copyright 1999-2001 Viktor Szakats 
 * 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.
 *
 */

#ifndef HB_DATE_H_
#define HB_DATE_H_

#include "hbdefs.h"

HB_EXTERN_BEGIN

extern HB_EXPORT double hb_dateSeconds( void );
extern HB_EXPORT HB_ULONG hb_dateMilliSeconds( void );
extern HB_EXPORT double hb_secondsCPU( int n );
extern HB_EXPORT void   hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec );
extern HB_EXPORT char * hb_timeStampStr( char * szTime, LONG lMillisec );
extern HB_EXPORT LONG   hb_timeStampEncode( int iHour, int iMinutes, int iSeconds, int iMSec );
extern HB_EXPORT void   hb_timeStampDecode( LONG lMillisec, int * piHour, int * piMinutes, int * piSeconds, int * piMSec );
extern HB_EXPORT void   hb_timeStrGet( const char * szTime, int * piHour, int * piMinutes, int * piSeconds, int * piMSec );
extern HB_EXPORT char * hb_dateTimeStampStr( char * szDateTime, LONG lJulian, LONG lMillisec );
extern HB_EXPORT void   hb_dateTimeStampStrGet( const char * szDateTime, LONG * plJulian, LONG * plMillisec );
extern HB_EXPORT void   hb_dateToday( int * piYear, int * piMonth, int * piDay );
extern HB_EXPORT void   hb_dateTimeStr( char * pszTime );
extern HB_EXPORT char * hb_dateCMonth( int iMonth );
extern HB_EXPORT char * hb_dateCDOW( int iDay );
extern HB_EXPORT int    hb_dateDOW( int iYear, int iMonth, int iDay );
extern HB_EXPORT int    hb_dateJulianDOW( LONG lJulian );
extern HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, const char * szDateFormat );
extern HB_EXPORT long   hb_dateUnformat( const char * szDate, const char * szDateFormat );
extern HB_EXPORT long   hb_dateEncode( int iYear, int iMonth, int iDay );
extern HB_EXPORT void   hb_dateDecode( long julian, int * piYear, int * piMonth, int * piDay );
extern HB_EXPORT void   hb_dateStrPut( char * szDate, int iYear, int iMonth, int iDay );
extern HB_EXPORT void   hb_dateStrGet( const char * szDate, int * piYear, int * piMonth, int * piDay );
extern HB_EXPORT char * hb_dateDecStr( char * szDate, long lJulian );
extern HB_EXPORT long   hb_dateEncStr( const char * szDate );

HB_EXTERN_END

#endif /* HB_DATE_H_ */
c:\harbour\include\hbdbf.h
/*
 * $Id: hbdbf.h 6504 2005-09-23 08:45:05Z rglab $
 */

/*
 * Harbour Project source code:
 * DBF structures
 *
 * Copyright 1999 Bruno Cantero 
 * 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.
 *
 */

#ifndef HB_DBF_H_
#define HB_DBF_H_

#include "hbapirdd.h"

HB_EXTERN_BEGIN

/* DBF header */

typedef struct _DBFHEADER
{
   BYTE   bVersion;
   BYTE   bYear;
   BYTE   bMonth;
   BYTE   bDay;
   BYTE   ulRecCount[ 4 ];
   BYTE   uiHeaderLen[ 2 ];
   BYTE   uiRecordLen[ 2 ];
   BYTE   bReserved1[ 2 ];
   BYTE   bTransaction;       /* 1-transaction begin */
   BYTE   bEncrypted;         /* 1-encryptpted table */
   BYTE   bReserved2[ 12 ];
   BYTE   bHasTags;           /* bit filed: 1-production index, 2-memo file in VFP */
   BYTE   bCodePage;
   BYTE   bReserved3[ 2 ];
} DBFHEADER;

typedef DBFHEADER * LPDBFHEADER;



/* DBF fields */

typedef struct _DBFFIELD
{
   BYTE bName[ 11 ];
   BYTE bType;
   BYTE bReserved1[ 4 ];      /* offset from record begin in FP */
   BYTE bLen;
   BYTE bDec;
   BYTE bFieldFlags;          /* 1-system column, 2-nullable, 4-binary */
   BYTE bCounter[4];          /* autoincrement counter */
   BYTE bStep;                /* autoincrement step */
   BYTE bReserved2[ 7 ];
   BYTE bHasTag;
} DBFFIELD;

typedef DBFFIELD * LPDBFFIELD;



/* SMT MEMO field */

typedef struct _SMTFIELD
{
   BYTE     type[2];
   BYTE     length[4];
   BYTE     block[4];
} SMTFIELD;

typedef SMTFIELD * LPSMTFIELD;


HB_EXTERN_END

#endif /* HB_DBF_H_ */
c:\harbour\include\hbdbferr.h
/*
 * $Id: hbdbferr.h 7771 2007-09-25 01:21:03Z druzus $
 */

/*
 * xHarbour Project source code:
 * DBF error codes
 *
 * Copyright 2003 Przemyslaw Czerpak 
 * www - http://www.xharbour.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.
 *
 */

#ifndef HB_DBFERR_H_
#define HB_DBFERR_H_

HB_EXTERN_BEGIN

/* DBF errors */
#define EDBF_UNSUPPORTED                           1000
#define EDBF_OPEN_DBF                              1001
#define EDBF_OPEN_MEMO                             1002
#define EDBF_OPEN_INDEX                            1003
#define EDBF_CREATE_DBF                            1004
#define EDBF_CREATE_MEMO                           1005
#define EDBF_CREATE_INDEX                          1006
#define EDBF_CREATE                   EDBF_CREATE_INDEX
#define EDBF_READ                                  1010
#define EDBF_WRITE                                 1011
#define EDBF_CORRUPT                               1012
#define EDBF_DATATYPE                              1020
#define EDBF_DATAWIDTH                             1021
#define EDBF_UNLOCKED                              1022
#define EDBF_SHARED                                1023
#define EDBF_APPENDLOCK                            1024
#define EDBF_READONLY                              1025
#define EDBF_LIMITEXCEEDED                         1027
#define EDBF_LOCKTIMEOUT                           1035
#define EDBF_LOCK                                  1038
/* ORDER errors */
#define EDBF_INVALIDKEY                            1026
#define EDBF_NOTINDEXED                            1201
#define EDBF_INVALIDORDER                          1050
#define EDBF_SCOPETYPE                             1051
#define EDBF_NOTCUSTOM                             1052
#define EDBF_INVALIDFOR                            1053
#define EDBF_KEYLENGTH                             1054
#define EDBF_SIGNATURE                             1055

#define EDBF_MEMOTYPE                              1056
#define EDBF_MEMOTOOLONG                           1057

#define EDBF_CREATE_TEMP                           1060
#define EDBF_WRITE_TEMP                            1061
#define EDBF_READ_TEMP                             1062

HB_EXTERN_END

#endif /* HB_DBFERR_H_ */
c:\harbour\include\hbdbsort.h
/*
 * $Id: hbdbsort.h 9252 2008-08-26 11:33:03Z vszakats $
 */

/*
 * Harbour Project source code:
 * SORT RDD module
 *
 * Copyright 1999 Bruno Cantero 
 * 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.
 *
 */

#ifndef HB_DBSORT_H_
#define HB_DBSORT_H_

#define HB_EXTERNAL_RDDDBF_USE
#include "hbrdddbf.h"

HB_EXTERN_BEGIN

/*
 *  DBQUICKSORT
 *  -----------
 *  The Quick Sort Item Structure
 */

typedef struct _DBQUICKSORT
{
   HB_FHANDLE hFile;
   BYTE szTempName[ _POSIX_PATH_MAX + 1 ];
   BYTE * pBuffer;
   BYTE * pSwapBufferA;
   BYTE * pSwapBufferB;
   BYTE * pCmpBufferA;
   BYTE * pCmpBufferB;
   USHORT uiRecordLen;
   USHORT uiMaxRecords;
   LPDBSORTINFO pSortInfo;
} DBQUICKSORT;

typedef DBQUICKSORT * LPDBQUICKSORT;

/*
 *  PROTOTYPES
 *  ----------
 */
extern BOOL hb_dbQSortInit( LPDBQUICKSORT pQuickSort, LPDBSORTINFO pSortInfo, USHORT uiRecordLen );
extern void hb_dbQSortExit( LPDBQUICKSORT pQuickSort );
extern BOOL hb_dbQSortAdvance( LPDBQUICKSORT pQuickSort, USHORT uiCount );
extern void hb_dbQSortComplete( LPDBQUICKSORT pQuickSort );

HB_EXTERN_END

#endif /* HB_DBSORT_H_ */
c:\harbour\include\hbdefs.h
/*
 * $Id: hbdefs.h 9507 2008-09-25 19:55:52Z vszakats $
 */

/*
 * Harbour Project source code:
 * Header file for compiler and runtime basic type declarations
 *
 * Copyright 1999 {list of individual authors and e-mail addresses}
 * 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.
 *
 */

#ifndef HB_DEFS_H_
#define HB_DEFS_H_

#include 
#include 
#include 
#include 
#include 

#include "hbsetup.h"
#include "hbtrace.h"
#include "hbver.h"

#if defined( __XCC__ ) || defined( __MINGW32__ ) || \
    ( defined( __BORLANDC__ ) && __BORLANDC__ >= 1410 ) || \
    ( defined( __GNUC__ ) && \
      ( defined( HB_OS_LINUX ) || defined( HB_OS_DARWIN ) ) )
   #include 
   /* workaround for BCC 5.8 bug */
   #if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 1410 )
      #undef INT32_MIN
      #define INT32_MIN ((int32_t) (-INT32_MAX-1))
      #undef INT64_MIN
      #define INT64_MIN (9223372036854775807i64-1)
      #undef INT64_MAX
      #define INT64_MAX 9223372036854775807i64
   #endif
#endif

/*
#define HB_CLIPPER_INT_ITEMS
#define HB_LONG_LONG_OFF
*/

#if defined( HB_OS_WIN_32 ) || defined( HB_OS_WIN_64 )
   #if defined( HB_OS_WIN_64 )
      #undef HB_LONG_LONG_OFF
      #define HB_STRICT_ALIGNMENT
      #if !defined( HB_OS_WIN_32 )
         #define HB_OS_WIN_32
      #endif
   #endif

   #if !defined( HB_WIN32_IO_OFF )
      #define HB_WIN32_IO
   #endif
   #if defined( HB_WIN32_IO ) && !defined( HB_OS_WIN_32_USED )
      /* disabled to avoid problems with windows.h */
      /* #define HB_OS_WIN_32_USED */
   #endif
#else
   #undef HB_WIN32_IO
   #undef HB_OS_WIN_32_USED
#endif

/* Include windows.h if applicable and requested */
#if defined( HB_OS_WIN_32_USED ) && defined( HB_OS_WIN_32 )

   #include 
   #if defined( __GNUC__ )
      #define HB_DONT_DEFINE_BASIC_TYPES
   #endif

#elif defined( HB_OS_OS2 )

   /* With the exception of WORD, the IBM Visual Age C++ compiler has
      its own definitions of the Harbour types most of which conflict with the
      Harbour #undefs, due to typedef being the prevalent method of
      defining the types in IBMCPP, whereas Harbour assumes that the
      definitions that it is replacing have been defined using
      #define. Therefore, it is necessary to skip the Harbour
      definition section when using the IBMCPP compiiler, include
      the IBMCPP type definitions, and then add the definition for WORD

      NOTE: This only applies to the common types that most C compilers
            define. Any new types, particulary those that start with
            HB_, must be placed AFTER the #endif __IBMCPP__ line!
   */
   /* 28/03/2000 - maurilio.longo@libero.it
      The same holds true when using GCC under OS/2
   */
   #define INCL_TYPES
   #define INCL_DOSEXCEPTIONS    /* DOS exception values */
   #define INCL_ERRORS           /* DOS error values     */

   #include 
   #undef INT
   #undef UINT
   #define HB_DONT_DEFINE_BASIC_TYPES

#elif defined( HB_OS_DOS )

   #include 

   #if defined(__WATCOMC__) && defined(__386__) && !defined(__WINDOWS_386__)
      #define HB_DOS_INT86 int386
      #define HB_DOS_INT86X int386x
      #define HB_XREGS w
   #elif defined(__RSX32__)
      #define HB_DOS_INT86 _int86
      #define HB_DOS_INT86X _int86x
      #define HB_XREGS x
   #elif defined( __DJGPP__ )
      #define HB_DOS_INT86 int86
      #define HB_DOS_INT86X int86x
      #define HB_XREGS w
   #else
      #define HB_DOS_INT86 int86
      #define HB_DOS_INT86X int86x
      #define HB_XREGS x
   #endif

#elif defined( HB_OS_DARWIN )

   /* Detect if it is Darwin < 6.x */
   #include 
   #ifndef PTHREAD_MUTEX_RECURSIVE
      #define HB_OS_DARWIN_5
   #endif

#endif

#if defined( HB_OS_WIN_32 )
   #include "hbwince.h"
#endif

#if ! defined( HB_DONT_DEFINE_BASIC_TYPES )

   #if ! defined( HB_DONT_DEFINE_BOOL )
      #undef BOOL                         /* boolean */
      typedef int BOOL;
   #endif

   #undef UINT                            /* varies with platform */
   typedef unsigned int UINT;

   #undef SCHAR                           /* 1 byte signed */
   typedef signed char SCHAR;

   #undef UCHAR                           /* 1 byte unsigned */
   typedef unsigned char UCHAR;

   #undef BYTE                            /* 1 byte unsigned */
   typedef unsigned char BYTE;

   #undef SHORT                           /* 2 bytes signed */
   typedef short int SHORT;

   #undef USHORT                          /* 2 bytes unsigned */
   typedef unsigned short int USHORT;

   #undef LONG                            /* 4 or 8 bytes signed */
   typedef long LONG;

   #undef ULONG                           /* 4 or 8 bytes unsigned */
   typedef unsigned long ULONG;

   #undef FALSE
   #define FALSE  0
   #undef TRUE
   #define TRUE   (!0)

#else  /* HB_DONT_DEFINE_BASIC_TYPES */

   /*
    * if HB_DONT_DEFINE_BASIC_TYPES excluded some types which are not
    * defined in included platform dependent header files then please
    * add necessary definitions here.
    */

   /* SCHAR is needed using GCC on OS/2 */
   #if ! defined( SCHAR )
      typedef signed char SCHAR;          /* 1 byte signed */
   #endif

#endif /* HB_DONT_DEFINE_BASIC_TYPES */

#ifndef HB_LONG_LONG_OFF

   #if ! defined(HB_DONT_DEFINE_BASIC_TYPES) && ! defined(_WINNT_H)
      #if !defined(LONGLONG)
         #if defined(__GNUC__)
            typedef long long LONGLONG;
         #else
            typedef __int64 LONGLONG;
         #endif
      #endif
      #if !defined(ULONGLONG)
         #if defined(__GNUC__)
            typedef unsigned long long ULONGLONG;
         #else
            typedef unsigned __int64 ULONGLONG;
         #endif
      #endif
   #endif

   #if !defined(ULONGLONG_MAX)
      #if defined(_UI64_MAX)
         #define ULONGLONG_MAX      _UI64_MAX
      #elif defined(ULLONG_MAX)
         #define ULONGLONG_MAX      ULLONG_MAX
      #elif defined(ULONG_LONG_MAX)
         #define ULONGLONG_MAX      ULONG_LONG_MAX
      #else
         #define ULONGLONG_MAX      18446744073709551615ULL
      #endif
   #endif
   #if !defined(LONGLONG_MAX)
      #if defined(_I64_MAX)
         #define LONGLONG_MAX       _I64_MAX
      #elif defined(LLONG_MAX)
         #define LONGLONG_MAX       LLONG_MAX
      #elif defined(LONG_LONG_MAX)
         #define LONGLONG_MAX       LONG_LONG_MAX
      #else
         #define LONGLONG_MAX       9223372036854775807LL
      #endif
   #endif
   #if !defined(LONGLONG_MIN)
      #if defined(_I64_MIN)
         #define LONGLONG_MIN       _I64_MIN
      #elif defined(LLONG_MIN)
         #define LONGLONG_MIN       LLONG_MIN
      #elif defined(LONG_LONG_MIN)
         #define LONGLONG_MIN       LONG_LONG_MIN
      #else
         #define LONGLONG_MIN       (-LONGLONG_MAX - 1LL)
      #endif
   #endif

#endif /* HB_LONG_LONG_OFF */

/*
 * below are some hacks which don't have to be true on some machines
 * please update it if necessary
 */
#if defined( HB_OS_WIN_64 )
#  define HB_ARCH_64BIT
#elif ULONG_MAX > UINT_MAX && UINT_MAX > USHRT_MAX
#  define HB_ARCH_64BIT
#elif ULONG_MAX == UINT_MAX && UINT_MAX > USHRT_MAX
#  define HB_ARCH_32BIT
#elif ULONG_MAX > UINT_MAX && UINT_MAX == USHRT_MAX
#  define HB_ARCH_16BIT
#endif

#if USHRT_MAX == 0xffff
#  if !defined( UINT16 )
      typedef USHORT       UINT16;
#  endif
#  if !defined( INT16 )
      typedef SHORT        INT16;
#  endif
#  if !defined( UINT16_MAX )
#     define UINT16_MAX    USHRT_MAX
#  endif
#  if !defined( INT16_MAX )
#     define INT16_MAX     SHRT_MAX
#  endif
#  if !defined( INT16_MIN )
#     define INT16_MIN     SHRT_MIN
#  endif
#endif

#if UINT_MAX == 0xFFFFFFFF
#  if !defined( UINT32 )
      typedef UINT         UINT32;
#  endif
#  if !defined( INT32 )
      typedef int          INT32;
#  endif
#  if !defined( UINT32_MAX )
#     define UINT32_MAX    UINT_MAX
#  endif
#  if !defined( INT32_MAX )
#     define INT32_MAX     INT_MAX
#  endif
#  if !defined( INT32_MIN )
#     define INT32_MIN     INT_MIN
#  endif
#elif ULONG_MAX == 0xFFFFFFFF
#  if !defined( UINT32 )
      typedef ULONG        UINT32;
#  endif
#  if !defined( INT32 )
      typedef LONG         INT32;
#  endif
#  if !defined( UINT32_MAX )
#     define UINT32_MAX    ULONG_MAX
#  endif
#  if !defined( INT32_MAX )
#     define INT32_MAX     LONG_MAX
#  endif
#  if !defined( INT32_MIN )
#     define INT32_MIN     LONG_MIN
#  endif
#endif

#if !defined( UCHAR_MAX )
#  define UCHAR_MAX     0x0FF
#endif
#if !defined( UINT24_MAX )
#  define UINT24_MAX    0x0FFFFFFL
#endif
#if !defined( INT24_MAX )
#  define INT24_MAX     8388607L
#endif
#if !defined( INT24_MIN )
#  define INT24_MIN     -8388608L
#endif

#if defined( HB_ARCH_64BIT ) && !defined( HB_OS_WIN_64 )
#  if !defined( UINT64 )
     typedef ULONG        UINT64;
#  endif
#  if !defined( INT64 )
     typedef LONG         INT64;
#  endif
#  if !defined( UINT64_MAX )
#    define UINT64_MAX    ULONG_MAX
#  endif
#  if !defined( INT64_MAX )
#    define INT64_MAX     LONG_MAX
#  endif
#  if !defined( INT64_MIN )
#    define INT64_MIN     LONG_MIN
#  endif
#elif !defined( HB_LONG_LONG_OFF )
#  if !defined( UINT64 )
     typedef ULONGLONG    UINT64;
#  endif
#  if !defined( INT64 )
     typedef LONGLONG     INT64;
#  endif
#  if !defined( UINT64_MAX )
#    define UINT64_MAX    ULONGLONG_MAX
#  endif
#  if !defined( INT64_MAX )
#    define INT64_MAX     LONGLONG_MAX
#  endif
#  if !defined( INT64_MIN )
#    define INT64_MIN     LONGLONG_MIN
#  endif
#endif

#ifndef HB_LONG_DOUBLE_OFF
   typedef long double  HB_MAXDBL;
#else
   typedef double       HB_MAXDBL;
#endif

#if defined( HB_CLIPPER_INT_ITEMS )
#  define HB_INT_MAX             SHRT_MAX
#  define HB_INT_MIN             SHRT_MIN
#  define HB_LONG_MAX            LONG_MAX
#  define HB_LONG_MIN            LONG_MIN
#  define HB_ULONG_MAX           ULONG_MAX
   typedef LONG                  HB_LONG;
   typedef ULONG                 HB_ULONG;
#  define PFHL                   "l"
#elif !defined( HB_LONG_LONG_OFF ) && ULONG_MAX == UINT_MAX
#  define HB_INT_MAX             INT_MAX
#  define HB_INT_MIN             INT_MIN
#  define HB_LONG_MAX            LONGLONG_MAX
#  define HB_LONG_MIN            LONGLONG_MIN
#  define HB_ULONG_MAX           ULONGLONG_MAX
   typedef LONGLONG              HB_LONG;
   typedef ULONGLONG             HB_ULONG;
#else
#  define HB_INT_MAX             INT_MAX
#  define HB_INT_MIN             INT_MIN
#  define HB_LONG_MAX            LONG_MAX
#  define HB_LONG_MIN            LONG_MIN
#  define HB_ULONG_MAX           ULONG_MAX
   typedef LONG                  HB_LONG;
   typedef ULONG                 HB_ULONG;
#  define PFHL                   "l"
#endif

#define HB_DBL_LIM_INT(d)     ( HB_INT_MIN <= (d) && (d) <= HB_INT_MAX )
#define HB_DBL_LIM_LONG(d)    ( (HB_MAXDBL) HB_LONG_MIN <= (HB_MAXDBL) (d) && (HB_MAXDBL) (d) <= (HB_MAXDBL) HB_LONG_MAX )
#define HB_LIM_INT(l)         ( HB_INT_MIN <= (l) && (l) <= HB_INT_MAX )
#define HB_LIM_LONG(l)        ( HB_LONG_MIN <= (l) && (l) <= HB_LONG_MAX )

#define HB_DBL_LIM_INT8(d)    ( -128 <= (d) && (d) <= 127 )
#define HB_DBL_LIM_INT16(d)   ( INT16_MIN <= (d) && (d) <= INT16_MAX )
#define HB_DBL_LIM_INT24(d)   ( INT24_MIN <= (d) && (d) <= INT24_MAX )
#define HB_DBL_LIM_INT32(d)   ( INT32_MIN <= (d) && (d) <= INT32_MAX )
#define HB_DBL_LIM_INT64(d)   ( (HB_MAXDBL) INT64_MIN <= (HB_MAXDBL) (d) && (HB_MAXDBL) (d) <= (HB_MAXDBL) INT64_MAX )
#define HB_LIM_INT8(l)        ( -128 <= (l) && (l) <= 127 )
#define HB_LIM_INT16(l)       ( INT16_MIN <= (l) && (l) <= INT16_MAX )
#define HB_LIM_INT24(l)       ( INT24_MIN <= (l) && (l) <= INT24_MAX )
#define HB_LIM_INT32(l)       ( INT32_MIN <= (l) && (l) <= INT32_MAX )
#define HB_LIM_INT64(l)       ( INT64_MIN <= (l) && (l) <= INT64_MAX )

/*
 * It's a hack for compilers which don't support LL suffix for LONGLONG
 * numeric constant. This suffix is necessary for some compilers -
 * without it they cut the number to LONG
 */
#if defined( __BORLANDC__ )
#  if __BORLANDC__ >= 1328
#     define HB_LL( num )           num##i64
#  else
#     define HB_LL( num )           num
#  endif
#elif defined( _MSC_VER )
#  define HB_LL( num )           num
#else
#  define HB_LL( num )           num##LL
#endif


/* HB_*_EXPLENGTH() macros are used by HVM to set the size of
 * math operations, HB_*_LENGTH() macros are used when new
 * item is created. [druzus]
 */
/* NOTE: the positive number limit 999999999 in HB_INT_LENGTH()
 *       (HB_LONG_LENGTH() on 16-bit platforms) below is not
 *       compatible with other limits. Clipper have such limit
 *       but IMHO it's result of some typo or wrong compiler
 *       warnings cleanup when someone removed one digit from
 *       upper limit instead of removing the whole limit.
 *       It's also possible that it comes from DBASE and was
 *       intentionally replicated. I think we should keep it
 *       only in strict compatibility mode. [druzus]
 */
#if HB_INT_MIN < -999999999
#  define HB_INT_LENGTH( i )        ( ( (i) < -999999999 || (i) > 999999999 ) ? 20 : 10 )
#else
#  define HB_INT_LENGTH( i )        10
#  define HB_INT_EXPLENGTH( i )     10
#  if HB_LONG_MIN < -999999999
#     define HB_LONG_LENGTH( i )    ( ( (i) < -999999999 || (i) > 999999999 ) ? 20 : 10 )
#  endif
#endif

#if !defined( HB_LONG_LONG_OFF )
#  if HB_LONG_MAX > HB_LL( 9999999999 )
#     define HB_LONG_LENGTH( l )    ( ( (l) < -999999999 || (l) > HB_LL( 9999999999 ) ) ? 20 : 10 )
#  endif
#  if HB_INT_MAX > HB_LL( 9999999999 )
#     define HB_INT_EXPLENGTH( i )  HB_LONG_LENGTH( i )
#  endif
#endif

#if !defined( HB_LONG_LENGTH )
#  define HB_LONG_LENGTH( l )       ( ( (l) < -999999999 ) ? 20 : 10 )
#endif
#if !defined( HB_INT_EXPLENGTH )
#  define HB_INT_EXPLENGTH( i )     ( ( (i) < -999999999 ) ? 20 : 10 )
#endif
#if !defined( HB_LONG_EXPLENGTH )
#  define HB_LONG_EXPLENGTH( l ) HB_LONG_LENGTH( l )
#endif

/* HB_DBL_LENGTH() is used by VAL() for strings longer then 10 characters
 * (counted to '.') and to set the size of math operations and new
 * double item - it's CA-Cl*pper compatible range. For doubles we do
 * not have separated limit for result of math operations. [druzus]
 */
#define HB_DBL_LENGTH( d ) ( ( (d) > 9999999999.0 || (d) < -999999999.0 ) ? 20 : 10 )

/* uncomment this if you need strict Clipper compatibility */
/* #define PCODE_LONG_LIM(l)     HB_LIM_INT32( l ) */

/* #define PCODE_LONG_LIM(l)     HB_LIM_LONG( l ) */

/* type of HB_ITEM */
/* typedef USHORT HB_TYPE; */
typedef UINT32 HB_TYPE;

/* type of reference counter */
typedef unsigned long HB_COUNTER;
#if ULONG_MAX <= UINT32_MAX
#  define HB_COUNTER_SIZE     4
#else
#  define HB_COUNTER_SIZE     8
#endif

/* type for memory pointer diff */
#if defined( HB_OS_WIN_64 )
   typedef LONGLONG HB_PTRDIFF;
#else
   typedef long HB_PTRDIFF;
#endif

#ifdef HB_LONG_LONG_OFF
   typedef LONG HB_FOFFSET;
   /* we can add hack with double as work around what should
      effectively give 52bit file size limit */
#else
   typedef LONGLONG HB_FOFFSET;
#endif

#if defined( HB_WIN32_IO )
#if 1
   typedef HB_PTRDIFF HB_FHANDLE;
#else
   typedef void * HB_FHANDLE;
#endif
   typedef HB_PTRDIFF HB_NHANDLE;
#  define hb_numToHandle( h )   ( ( HB_FHANDLE ) ( HB_NHANDLE ) ( h ) )
#else
   typedef int HB_FHANDLE;
   typedef int HB_NHANDLE;
#  define hb_numToHandle( h )   ( ( int ) ( h ) )
#endif

#ifdef HB_LEGACY_LEVEL
   #define FHANDLE                 HB_FHANDLE
#endif

/* maximum length of double number in decimal representation:
   log10(2^1024) ~ 308.25 */
#define HB_MAX_DOUBLE_LENGTH 320

/* This value is used to hack the double FL value in round/int
   operation - similar thing is done by CL5.3 - I do not know
   only the exact factor value but it should be close to this one.
   When HB_C52_STRICT is set this macro is not used.
*/
#define HB_DBLFL_PREC_FACTOR 1.0000000000000002;

/* try to detect byte order if not explicitly set */
#if !defined( HB_PDP_ENDIAN ) && !defined( HB_BIG_ENDIAN ) && \
    !defined( HB_LITTLE_ENDIAN )

   /* I intentionaly move the first two #if/#elif to the begining
      to avoid compiler error when this macro will be defined as
      empty statement in next conditions, F.e. SunOS
    */
#  if ( defined( __LITTLE_ENDIAN__ ) && ! defined( __BIG_ENDIAN__ ) ) || \
      ( defined( __LITTLE_ENDIAN ) && ! defined( __BIG_ENDIAN ) ) || \
      ( defined( _LITTLE_ENDIAN ) && ! defined( _BIG_ENDIAN ) ) || \
      ( defined( LITTLE_ENDIAN ) && ! defined( BIG_ENDIAN ) )

#     define HB_LITTLE_ENDIAN

#  elif ( ! defined( __LITTLE_ENDIAN__ ) && defined( __BIG_ENDIAN__ ) ) || \
        ( ! defined( __LITTLE_ENDIAN ) && defined( __BIG_ENDIAN ) ) || \
        ( ! defined( _LITTLE_ENDIAN ) && defined( _BIG_ENDIAN ) ) || \
        ( ! defined( LITTLE_ENDIAN ) && defined( BIG_ENDIAN ) )

#     define HB_BIG_ENDIAN

#  elif ( defined( __BYTE_ORDER ) && defined( __LITTLE_ENDIAN ) && __BYTE_ORDER == __LITTLE_ENDIAN ) || \
        ( defined( _BYTE_ORDER ) && defined( _LITTLE_ENDIAN ) && _BYTE_ORDER == _LITTLE_ENDIAN ) || \
        ( defined( BYTE_ORDER ) && defined( LITTLE_ENDIAN ) && BYTE_ORDER == LITTLE_ENDIAN )

#     define HB_LITTLE_ENDIAN

#  elif ( defined( __BYTE_ORDER ) && defined( __BIG_ENDIAN ) && __BYTE_ORDER == __BIG_ENDIAN ) || \
        ( defined( _BYTE_ORDER ) && defined( _BIG_ENDIAN ) && _BYTE_ORDER == _BIG_ENDIAN ) || \
        ( defined( BYTE_ORDER ) && defined( BIG_ENDIAN ) && BYTE_ORDER == BIG_ENDIAN )

#     define HB_BIG_ENDIAN

#  elif ( defined( __BYTE_ORDER ) && defined( __PDP_ENDIAN ) && __BYTE_ORDER == __PDP_ENDIAN ) || \
        ( defined( _BYTE_ORDER ) && defined( _PDP_ENDIAN ) && _BYTE_ORDER == _PDP_ENDIAN ) || \
        ( defined( BYTE_ORDER ) && defined( PDP_ENDIAN ) && BYTE_ORDER == PDP_ENDIAN )

#     define HB_PDP_ENDIAN

#  else /* We cannot detect byte order, we will have to guess */

#     if defined( HB_OS_DARWIN ) || defined( HB_OS_SUNOS ) || defined( HB_OS_HPUX )
#        define HB_BIG_ENDIAN
#     else
#        define HB_LITTLE_ENDIAN
#     endif

#  endif

#endif


#define HB_MAX( a, b )          ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
#define HB_MIN( a, b )          ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )

#define HB_LOBYTE( w )          ( ( BYTE ) ( w ) )
#define HB_HIBYTE( w )          ( ( BYTE ) ( ( ( w ) >>  8 ) & 0xFF ) )
#define HB_ULBYTE( w )          ( ( BYTE ) ( ( ( w ) >> 16 ) & 0xFF ) )
#define HB_UHBYTE( w )          ( ( BYTE ) ( ( ( w ) >> 24 ) & 0xFF ) )
#define HB_LOWORD( l )          ( ( UINT16 ) ( l ) )
#define HB_HIWORD( l )          ( ( UINT16 ) ( ( ( l ) >> 16 ) & 0xFFFF ) )
#define HB_MKSHORT( lo, hi )    ( ( SHORT ) ( ( ( INT16 ) ( hi ) ) << 8 ) | ( lo ) )
#define HB_MKUSHORT( lo, hi )   ( ( USHORT ) ( ( ( UINT16 ) ( hi ) ) << 8 ) | ( lo ) )
#define HB_MKLONG( b1, b2, b3, b4 )  ( ( LONG ) \
                                       ( ( ( ( INT32 ) ( b4 ) ) << 24 ) | \
                                         ( ( ( INT32 ) ( b3 ) ) << 16 ) | \
                                         ( ( ( INT32 ) ( b2 ) ) <<  8 ) | \
                                         ( ( ( INT32 ) ( b1 ) ) ) ) )
#define HB_MKULONG( b1, b2, b3, b4 ) ( ( ULONG ) \
                                       ( ( ( ( UINT32 ) ( b4 ) ) << 24 ) | \
                                         ( ( ( UINT32 ) ( b3 ) ) << 16 ) | \
                                         ( ( ( UINT32 ) ( b2 ) ) <<  8 ) | \
                                         ( ( ( UINT32 ) ( b1 ) ) ) ) )

#define HB_SWAP_UINT16( w )     ( ( UINT16 ) ( ( ( ( UINT16 ) ( w ) & 0xFF00 ) >> 8 ) | \
                                               ( ( ( UINT16 ) ( w ) & 0x00FF ) << 8 ) ) )
#define HB_SWAP_UINT32( w )     ( ( UINT32 ) ( ( ( ( UINT32 ) ( w ) & 0x000000FF ) << 24 ) | \
                                               ( ( ( UINT32 ) ( w ) & 0x0000FF00 ) <<  8 ) | \
                                               ( ( ( UINT32 ) ( w ) & 0x00FF0000 ) >>  8 ) | \
                                               ( ( ( UINT32 ) ( w ) & 0xFF000000 ) >> 24 ) ) )


#ifndef PFLL
#  if defined( __BORLANDC__ ) || defined( _MSC_VER ) || defined( __MINGW32__ )
#     define PFLL    "I64"
#  else
#     define PFLL    "ll"
#  endif
#endif
#ifndef PFHL
#  define PFHL    PFLL
#endif


#define HB_SWAP_UINT64( w )      ( ( UINT64 ) ( ( ( ( UINT64 ) ( w ) & HB_LL( 0x00000000000000FF ) ) << 56 ) | \
                                                ( ( ( UINT64 ) ( w ) & HB_LL( 0x000000000000FF00 ) ) << 40 ) | \
                                                ( ( ( UINT64 ) ( w ) & HB_LL( 0x0000000000FF0000 ) ) >> 24 ) | \
                                                ( ( ( UINT64 ) ( w ) & HB_LL( 0x00000000FF000000 ) ) >>  8 ) | \
                                                ( ( ( UINT64 ) ( w ) & HB_LL( 0x000000FF00000000 ) ) >>  8 ) | \
                                                ( ( ( UINT64 ) ( w ) & HB_LL( 0x0000FF0000000000 ) ) >> 24 ) | \
                                                ( ( ( UINT64 ) ( w ) & HB_LL( 0x00FF000000000000 ) ) >> 40 ) | \
                                                ( ( ( UINT64 ) ( w ) & HB_LL( 0xFF00000000000000 ) ) >> 56 ) ) )

/*
 * on some machines it's not safe to directly access pointers stored
 * at byte buffer they have to be stored at odd (or other alignment)
 * addresses.
 * For example SPARC which needs 4 byte alignment for pointers
 * and 8 byte alignment for doubles and structures (when GCC is used)
 * IMHO need HB_ARCH_ macro yet - the same OS can be used with
 * different architectures - SPARC + LINUX, ALPHA + LINUX
 */
#if !defined( HB_STRICT_ALIGNMENT )
#  if defined( HB_OS_SUNOS ) || defined( HB_OS_HPUX ) || defined( _M_ARM )
#     define HB_STRICT_ALIGNMENT
#  endif
#endif

#if defined( HB_STRICT_ALIGNMENT )
#  if !defined( HB_ALLOC_ALIGNMENT ) || ( HB_ALLOC_ALIGNMENT + 1 == 1 )
#     define HB_ALLOC_ALIGNMENT     8
#  endif
#endif

#if defined( HB_ALLOC_ALIGNMENT ) && HB_COUNTER_SIZE < HB_ALLOC_ALIGNMENT + 0
#  define HB_COUNTER_OFFSET   HB_ALLOC_ALIGNMENT
#else
#  define HB_COUNTER_OFFSET   HB_COUNTER_SIZE
#endif

#define HB_COUNTER_PTR( p )         ((HB_COUNTER*) ((BYTE *) (p)-HB_COUNTER_OFFSET))

/*
 * These macros are necessary for architectures which need
 * strict alignment for pointers.
 */
#if defined( HB_BIG_ENDIAN )
#  if defined( HB_ARCH_64BIT )
#     define   HB_PUT_LONG( p, v )  HB_PUT_BE_UINT64( p, ( UINT64 ) ( v ) )
#     define   HB_GET_LONG( p )     HB_GET_BE_UINT64( p )
#  else
#     define   HB_PUT_LONG( p, v )  HB_PUT_BE_UINT32( p, ( UINT32 ) ( v ) )
#     define   HB_GET_LONG( p )     HB_GET_BE_UINT32( p )
#  endif
#  define   HB_PUT_UINT32( p, v )   HB_PUT_BE_UINT32( p, ( UINT32 ) ( v ) )
#  define   HB_GET_UINT32( p )      HB_GET_BE_UINT32( p )
#else
#  if defined( HB_ARCH_64BIT )
#     define   HB_PUT_LONG( p, v )  HB_PUT_LE_UINT64( p, ( UINT64 ) ( v ) )
#     define   HB_GET_LONG( p )     HB_GET_LE_UINT64( p )
#  else
#     define   HB_PUT_LONG( p, v )  HB_PUT_LE_UINT32( p, ( UINT32 ) ( v ) )
#     define   HB_GET_LONG( p )     HB_GET_LE_UINT32( p )
#  endif
#  define   HB_PUT_UINT32( p, v )   HB_PUT_LE_UINT32( p, ( UINT32 ) ( v ) )
#  define   HB_GET_UINT32( p )      HB_GET_LE_UINT32( p )
#endif

#if !defined( HB_STRICT_ALIGNMENT )
#  define   HB_PUT_PTR( p, v )      do { *( void ** ) ( p ) = ( void * ) ( v ); } while ( 0 )
#  define   HB_GET_PTR( p )         ( *( void ** ) ( p ) )
#else
#  define   HB_PUT_PTR( p, v )      HB_PUT_LONG( p, v )
#  define   HB_GET_PTR( p )         ( ( void * ) HB_GET_LONG( p ) )
#endif

/* Macros to store/retrive double value */
#if defined( __GNUC__ )
#  define HB_GET_REV_DOUBLE( p )    \
       ( { \
            union { \
               double dbl; \
               BYTE buffer[ 8 ]; \
            } u; \
            u.buffer[ 0 ] = (( BYTE * )( p ))[ 7 ]; \
            u.buffer[ 1 ] = (( BYTE * )( p ))[ 6 ]; \
            u.buffer[ 2 ] = (( BYTE * )( p ))[ 5 ]; \
            u.buffer[ 3 ] = (( BYTE * )( p ))[ 4 ]; \
            u.buffer[ 4 ] = (( BYTE * )( p ))[ 3 ]; \
            u.buffer[ 5 ] = (( BYTE * )( p ))[ 2 ]; \
            u.buffer[ 6 ] = (( BYTE * )( p ))[ 1 ]; \
            u.buffer[ 7 ] = (( BYTE * )( p ))[ 0 ]; \
            u.dbl; \
         } )
#  define HB_GET_STD_DOUBLE( p )    \
       ( { \
            union { \
               double dbl; \
               BYTE buffer[ 8 ]; \
            } u; \
            u.buffer[ 0 ] = (( BYTE * )( p ))[ 0 ]; \
            u.buffer[ 1 ] = (( BYTE * )( p ))[ 1 ]; \
            u.buffer[ 2 ] = (( BYTE * )( p ))[ 2 ]; \
            u.buffer[ 3 ] = (( BYTE * )( p ))[ 3 ]; \
            u.buffer[ 4 ] = (( BYTE * )( p ))[ 4 ]; \
            u.buffer[ 5 ] = (( BYTE * )( p ))[ 5 ]; \
            u.buffer[ 6 ] = (( BYTE * )( p ))[ 6 ]; \
            u.buffer[ 7 ] = (( BYTE * )( p ))[ 7 ]; \
            u.dbl; \
         } )
#else
#  define HB_GET_REV_DOUBLE( p )    hb_get_rev_double( ( BYTE * ) ( p ) )
#  define HB_GET_STD_DOUBLE( p )    hb_get_std_double( ( BYTE * ) ( p ) )
#endif

#define HB_PUT_REV_DOUBLE( p, d )    \
         do { \
            union { \
               double dbl; \
               BYTE buffer[ 8 ]; \
            } u; \
            u.dbl = ( double ) ( d ); \
            (( BYTE * )( p ))[ 7 ] = u.buffer[ 0 ]; \
            (( BYTE * )( p ))[ 6 ] = u.buffer[ 1 ]; \
            (( BYTE * )( p ))[ 5 ] = u.buffer[ 2 ]; \
            (( BYTE * )( p ))[ 4 ] = u.buffer[ 3 ]; \
            (( BYTE * )( p ))[ 3 ] = u.buffer[ 4 ]; \
            (( BYTE * )( p ))[ 2 ] = u.buffer[ 5 ]; \
            (( BYTE * )( p ))[ 1 ] = u.buffer[ 6 ]; \
            (( BYTE * )( p ))[ 0 ] = u.buffer[ 7 ]; \
         } while ( 0 )
#define HB_PUT_STD_DOUBLE( p, d )    \
         do { \
            union { \
               double dbl; \
               BYTE buffer[ 8 ]; \
            } u; \
            u.dbl = ( double ) ( d ); \
            (( BYTE * )( p ))[ 0 ] = u.buffer[ 0 ]; \
            (( BYTE * )( p ))[ 1 ] = u.buffer[ 1 ]; \
            (( BYTE * )( p ))[ 2 ] = u.buffer[ 2 ]; \
            (( BYTE * )( p ))[ 3 ] = u.buffer[ 3 ]; \
            (( BYTE * )( p ))[ 4 ] = u.buffer[ 4 ]; \
            (( BYTE * )( p ))[ 5 ] = u.buffer[ 5 ]; \
            (( BYTE * )( p ))[ 6 ] = u.buffer[ 6 ]; \
            (( BYTE * )( p ))[ 7 ] = u.buffer[ 7 ]; \
         } while ( 0 )

/*
 * HB_FORCE_IEEE754_DOUBLE will can be used on platforms which use differ
 * double format and we want to force storing double number as IEEE754
 * double value for sharing binary data (f.e. PCODE in .hrb files or CDX
 * indexes or DBFs with "B" fields.
 */
#if defined( HB_FORCE_IEEE754_DOUBLE )

#  define HB_GET_LE_DOUBLE( p )     hb_get_ieee754( ( BYTE * ) ( p ) )
#  define HB_PUT_LE_DOUBLE( p, d )  hb_put_ieee754( ( BYTE * ) ( p ), ( d ) )
#  define HB_DBL2ORD( d, o )        hb_put_ord_ieee754( ( o ), *( d ) )
#  define HB_ORD2DBL( o, d )  do { \
                                 *d = hb_get_ord_ieee754( ( BYTE * ) ( o ) ); \
                              } while( 0 )

#elif defined( HB_STRICT_ALIGNMENT )

#  if defined( HB_LITTLE_ENDIAN )
#     define HB_GET_LE_DOUBLE( p )     HB_GET_STD_DOUBLE( ( p ) )
#     define HB_PUT_LE_DOUBLE( p, d )  HB_PUT_STD_DOUBLE( ( p ), ( d ) )
#  elif defined( HB_BIG_ENDIAN )
#     define HB_GET_LE_DOUBLE( p )     HB_GET_REV_DOUBLE( ( p ) )
#     define HB_PUT_LE_DOUBLE( p, d )  HB_PUT_REV_DOUBLE( ( p ), ( d ) )
#  endif

#else

#  if defined( HB_LITTLE_ENDIAN )
#     define HB_GET_LE_DOUBLE( p )     ( *( double * )( p ) )
#     define HB_PUT_LE_DOUBLE( p, d )  ( *( double * )( p ) = ( double ) ( d ) )
#  elif defined( HB_BIG_ENDIAN )
#     define HB_GET_LE_DOUBLE( p )     HB_GET_REV_DOUBLE( ( p ) )
#     define HB_PUT_LE_DOUBLE( p, d )  HB_PUT_REV_DOUBLE( ( p ), ( d ) )
#  endif

#endif

/* Now the rest of endian macros */
#if defined( HB_STRICT_ALIGNMENT ) || !defined( HB_LITTLE_ENDIAN )

   #define HB_GET_LE_UINT16( p )    ( ( UINT16 ) \
                                      ( ( ( UINT16 ) (( BYTE * )( p ))[0] ) | \
                                        ( ( UINT16 ) (( BYTE * )( p ))[1] <<  8 ) ) )
   #define HB_GET_LE_UINT32( p )    ( ( UINT32 ) \
                                      ( ( ( UINT32 ) (( BYTE * )( p ))[0] ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[1] <<  8 ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[2] << 16 ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[3] << 24 ) ) )
   #define HB_GET_LE_UINT64( p )    ( ( UINT64 ) \
                                      ( ( ( UINT64 ) (( BYTE * )( p ))[0] ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[1] <<  8 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[2] << 16 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[3] << 24 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[4] << 32 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[5] << 40 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[6] << 48 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[7] << 56 ) ) )

   #define HB_PUT_LE_UINT16( p, w )    do { \
                                         (( BYTE * )( p ))[0] = ( BYTE )( w ); \
                                         (( BYTE * )( p ))[1] = ( BYTE )( (w) >>  8 ); \
                                       } while ( 0 )
   #define HB_PUT_LE_UINT32( p, w )    do { \
                                         (( BYTE * )( p ))[0] = ( BYTE )( w ); \
                                         (( BYTE * )( p ))[1] = ( BYTE )( (w) >>  8 ); \
                                         (( BYTE * )( p ))[2] = ( BYTE )( (w) >> 16 ); \
                                         (( BYTE * )( p ))[3] = ( BYTE )( (w) >> 24 ); \
                                       } while ( 0 )
   #define HB_PUT_LE_UINT64( p, w )    do { \
                                         (( BYTE * )( p ))[0] = ( BYTE )( w ); \
                                         (( BYTE * )( p ))[1] = ( BYTE )( (w) >>  8 ); \
                                         (( BYTE * )( p ))[2] = ( BYTE )( (w) >> 16 ); \
                                         (( BYTE * )( p ))[3] = ( BYTE )( (w) >> 24 ); \
                                         (( BYTE * )( p ))[4] = ( BYTE )( (w) >> 32 ); \
                                         (( BYTE * )( p ))[5] = ( BYTE )( (w) >> 40 ); \
                                         (( BYTE * )( p ))[6] = ( BYTE )( (w) >> 48 ); \
                                         (( BYTE * )( p ))[7] = ( BYTE )( (w) >> 56 ); \
                                       } while ( 0 )
#endif

#if defined( HB_STRICT_ALIGNMENT ) || !defined( HB_BIG_ENDIAN )

   #define HB_GET_BE_UINT16( p )    ( ( UINT16 ) \
                                      ( ( ( UINT16 ) (( BYTE * )( p ))[0] << 8 ) | \
                                        ( ( UINT16 ) (( BYTE * )( p ))[1] ) ) )
   #define HB_GET_BE_UINT32( p )    ( ( UINT32 ) \
                                      ( ( ( UINT32 ) (( BYTE * )( p ))[0] << 24 ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[1] << 16 ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[2] <<  8 ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[3] ) ) )
   #define HB_GET_BE_UINT64( p )    ( ( UINT64 ) \
                                      ( ( ( UINT64 ) (( BYTE * )( p ))[0] << 56 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[1] << 48 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[2] << 40 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[3] << 32 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[4] << 24 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[5] << 16 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[6] <<  8 ) | \
                                        ( ( UINT64 ) (( BYTE * )( p ))[7] ) ) )

   #define HB_PUT_BE_UINT16( p, w )    do { \
                                         (( BYTE * )( p ))[0] = ( BYTE )( (w) >>  8 ); \
                                         (( BYTE * )( p ))[1] = ( BYTE )( w ); \
                                       } while ( 0 )
   #define HB_PUT_BE_UINT32( p, w )    do { \
                                         (( BYTE * )( p ))[0] = ( BYTE )( (w) >> 24 ); \
                                         (( BYTE * )( p ))[1] = ( BYTE )( (w) >> 16 ); \
                                         (( BYTE * )( p ))[2] = ( BYTE )( (w) >>  8 ); \
                                         (( BYTE * )( p ))[3] = ( BYTE )( w ); \
                                       } while ( 0 )
   #define HB_PUT_BE_UINT64( p, w )    do { \
                                         (( BYTE * )( p ))[0] = ( BYTE )( (w) >> 56 ); \
                                         (( BYTE * )( p ))[1] = ( BYTE )( (w) >> 48 ); \
                                         (( BYTE * )( p ))[2] = ( BYTE )( (w) >> 40 ); \
                                         (( BYTE * )( p ))[3] = ( BYTE )( (w) >> 32 ); \
                                         (( BYTE * )( p ))[4] = ( BYTE )( (w) >> 24 ); \
                                         (( BYTE * )( p ))[5] = ( BYTE )( (w) >> 16 ); \
                                         (( BYTE * )( p ))[6] = ( BYTE )( (w) >>  8 ); \
                                         (( BYTE * )( p ))[7] = ( BYTE )( w ); \
                                       } while ( 0 )
#endif

/*
 * 24 bit integers are not directly supported by any processor we used so far
 * so we always have to build them from BYTEs and cannot use C casting
 */
#define HB_GET_LE_INT24( p )        ( ( INT32 ) \
                                      ( ( ( INT32 ) (( BYTE * )( p ))[0] ) | \
                                        ( ( INT32 ) (( BYTE * )( p ))[1] <<  8 ) | \
                                        ( ( INT32 ) (( BYTE * )( p ))[2] << 16 ) | \
                                        ( ( INT32 ) ((( BYTE * )( p ))[2] & 0x80 ? 0xFF : 0x00 ) << 24 ) ) )
#define HB_GET_LE_UINT24( p )       ( ( UINT32 ) \
                                      ( ( ( UINT32 ) (( BYTE * )( p ))[0] ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[1] <<  8 ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[2] << 16 ) ) )
#define HB_PUT_LE_UINT24( p, w )    do { \
                                       (( BYTE * )( p ))[0] = ( BYTE )( w ); \
                                       (( BYTE * )( p ))[1] = ( BYTE )( (w) >>  8 ); \
                                       (( BYTE * )( p ))[2] = ( BYTE )( (w) >> 16 ); \
                                    } while ( 0 )
#define HB_GET_BE_INT24( p )        ( ( INT32 ) \
                                      ( ( ( INT32 ) (( BYTE * )( p ))[2] ) | \
                                        ( ( INT32 ) (( BYTE * )( p ))[1] <<  8 ) | \
                                        ( ( INT32 ) (( BYTE * )( p ))[0] << 16 ) | \
                                        ( ( INT32 ) ((( BYTE * )( p ))[0] & 0x80 ? 0xFF : 0x00 ) << 24 ) ) )
#define HB_GET_BE_UINT24( p )       ( ( UINT32 ) \
                                      ( ( ( UINT32 ) (( BYTE * )( p ))[2] ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[1] <<  8 ) | \
                                        ( ( UINT32 ) (( BYTE * )( p ))[0] << 16 ) ) )
#define HB_PUT_BE_UINT24( p, w )    do { \
                                       (( BYTE * )( p ))[2] = ( BYTE )( w ); \
                                       (( BYTE * )( p ))[1] = ( BYTE )( (w) >>  8 ); \
                                       (( BYTE * )( p ))[0] = ( BYTE )( (w) >> 16 ); \
                                    } while ( 0 )


#if defined( HB_PDP_ENDIAN )
   #error PDP-Endian support unimplemented. If you have such machine do it yourself.
#elif defined( HB_BIG_ENDIAN )
   /* We use Big-Endian here */

#  ifndef HB_STRICT_ALIGNMENT

   #define HB_GET_BE_UINT16( p )    ( *( UINT16 * )( p ) )
   #define HB_PUT_BE_UINT16( p, w ) ( *( UINT16 * )( p ) = ( UINT16 ) ( w ) )
   #define HB_GET_BE_UINT32( p )    ( *( UINT32 * )( p ) )
   #define HB_PUT_BE_UINT32( p, l ) ( *( UINT32 * )( p ) = ( UINT32 ) ( l ) )
   #define HB_GET_BE_UINT64( p )    ( *( UINT64 * )( p ) )
   #define HB_PUT_BE_UINT64( p, l ) ( *( UINT64 * )( p ) = ( UINT64 ) ( l ) )

#  endif

   #define HB_USHORT_FROM_LE( w )   HB_MKUSHORT( HB_HIBYTE( w ), HB_LOBYTE( w ) )
   #define HB_ULONG_FROM_LE( l )    HB_MKULONG( HB_UHBYTE( l ), HB_ULBYTE( l ), HB_HIBYTE( l ), HB_LOBYTE( l ) )
   #define HB_USHORT_TO_LE( w )     HB_USHORT_FROM_LE( w )
   #define HB_ULONG_TO_LE( l )      HB_ULONG_FROM_LE( l )

#  ifndef HB_FORCE_IEEE754_DOUBLE
   #define HB_ORD2DBL( o, d )       do { \
      if ( ( ( BYTE * ) ( o ) )[ 0 ] & 0x80 ) { \
         ( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 0 ]; \
         ( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 1 ]; \
         ( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 2 ]; \
         ( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 3 ]; \
         ( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 4 ]; \
         ( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 5 ]; \
         ( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 6 ]; \
         ( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 7 ] ^ ( BYTE ) 0x80; \
      } else { \
         ( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 0 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 1 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 2 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 3 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 4 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 5 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 6 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 7 ] ^ ( BYTE ) 0xFF; \
      } } while ( 0 )

   #define HB_DBL2ORD( d, o )       do { \
      if ( *( double * )( d ) >= 0.0 ) { \
         if( *( double * )( d ) == -0.0 ) *( double * )( d ) = 0.0; \
         ( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 0 ] ^ ( BYTE ) 0x80; \
         ( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 1 ]; \
         ( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 2 ]; \
         ( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 3 ]; \
         ( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 4 ]; \
         ( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 5 ]; \
         ( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 6 ]; \
         ( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 7 ]; \
      } else { \
         ( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 0 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 1 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 2 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 3 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 4 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 5 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 6 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 7 ] ^ ( BYTE ) 0xFF; \
      } } while ( 0 )
#  endif

#else /* HB_LITTLE_ENDIAN */
      /* We use Little-Endian here */

#  ifndef HB_STRICT_ALIGNMENT

   #define HB_GET_LE_UINT16( p )    ( *( UINT16 * )( p ) )
   #define HB_PUT_LE_UINT16( p, w ) ( *( UINT16 * )( p ) = ( UINT16 ) ( w ) )
   #define HB_GET_LE_UINT32( p )    ( *( UINT32 * )( p ) )
   #define HB_PUT_LE_UINT32( p, l ) ( *( UINT32 * )( p ) = ( UINT32 ) ( l ) )
   #define HB_GET_LE_UINT64( p )    ( *( UINT64 * )( p ) )
   #define HB_PUT_LE_UINT64( p, l ) ( *( UINT64 * )( p ) = ( UINT64 ) ( l ) )

#  endif

   #define HB_USHORT_FROM_LE( w )   ( ( USHORT )( w ) )
   #define HB_ULONG_FROM_LE( l )    ( ( ULONG )( l ) )
   #define HB_USHORT_TO_LE( w )     ( ( USHORT )( w ) )
   #define HB_ULONG_TO_LE( l )      ( ( ULONG )( l ) )

#  ifndef HB_FORCE_IEEE754_DOUBLE
   #define HB_ORD2DBL( o, d )       do { \
      if ( ( ( BYTE * ) ( o ) )[ 0 ] & 0x80 ) { \
         ( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 7 ]; \
         ( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 6 ]; \
         ( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 5 ]; \
         ( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 4 ]; \
         ( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 3 ]; \
         ( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 2 ]; \
         ( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 1 ]; \
         ( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 0 ] ^ ( BYTE ) 0x80; \
      } else { \
         ( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 7 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 6 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 5 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 4 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 3 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 2 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 1 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 0 ] ^ ( BYTE ) 0xFF; \
      } } while ( 0 )

   #define HB_DBL2ORD( d, o )       do { \
      if ( *( double * )( d ) >= 0.0 ) { \
         if( *( double * )( d ) == -0.0 ) *( double * )( d ) = 0.0; \
         ( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 7 ] ^ ( BYTE ) 0x80; \
         ( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 6 ]; \
         ( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 5 ]; \
         ( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 4 ]; \
         ( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 3 ]; \
         ( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 2 ]; \
         ( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 1 ]; \
         ( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 0 ]; \
      } else { \
         ( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 7 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 6 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 5 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 4 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 3 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 2 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 1 ] ^ ( BYTE ) 0xFF; \
         ( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 0 ] ^ ( BYTE ) 0xFF; \
      } } while ( 0 )
#  endif

#endif

#define HB_GET_LE_INT16( p )        (( INT16 ) HB_GET_LE_UINT16( p ))
#define HB_GET_LE_INT32( p )        (( INT32 ) HB_GET_LE_UINT32( p ))
#define HB_GET_LE_INT64( p )        (( INT64 ) HB_GET_LE_UINT64( p ))

#define HB_PCODE_MKSHORT( p )       (( SHORT )     HB_GET_LE_INT16( p ))
#define HB_PCODE_MKUSHORT( p )      (( USHORT )    HB_GET_LE_UINT16( p ))
#define HB_PCODE_MKLONG( p )        (( LONG )      HB_GET_LE_INT32( p ))
#define HB_PCODE_MKULONG( p )       (( ULONG )     HB_GET_LE_UINT32( p ))
#define HB_PCODE_MKLONGLONG( p )    (( LONGLONG )  HB_GET_LE_INT64( p ))
#define HB_PCODE_MKULONGLONG( p )   (( ULONGLONG ) HB_GET_LE_UINT64( p ))
#define HB_PCODE_MKDOUBLE( p )      (( double )    HB_GET_LE_DOUBLE( p ))
#define HB_PCODE_MKINT24( p )       (( LONG )      HB_GET_LE_INT24( p ))
#define HB_PCODE_MKUINT24( p )      (( ULONG )     HB_GET_LE_UINT24( p ))

/*
 * Below are hacked version of INT64 macros which operates on double
 * when INT64 is not supported - they are necessary for PCODE and
 * database access
 */
#if defined( HB_LONG_LONG_OFF ) && !defined( HB_ARCH_64BIT )
   #undef HB_GET_LE_INT64
   #undef HB_GET_LE_UINT64
   #undef HB_PUT_LE_UINT64
   #undef HB_PCODE_MKLONGLONG
   #undef HB_PCODE_MKULONGLONG
   #undef HB_DBL_LIM_INT64
   #define UINT64_MAXDBL               ( (( double ) UINT32_MAX + 1.0) * \
                                         (( double ) UINT32_MAX + 1.0) - 1.0 )
   #define HB_GET_LE_INT64( p )        hb_get_le_int64( ( BYTE * ) ( p ) )
   #define HB_GET_LE_UINT64( p )       hb_get_le_uint64( ( BYTE * ) ( p ) )
   #define HB_PUT_LE_UINT64( p, d )    hb_put_le_uint64( ( BYTE * ) ( p ), \
                                                         ( double ) ( d ) )
   #define HB_PCODE_MKLONGLONG( p )    (( double ) HB_GET_LE_INT64( p ))
   #define HB_PCODE_MKULONGLONG( p )   (( double ) HB_GET_LE_UINT64( p ))
   #define HB_DBL_LIM_INT64(d)         ( (HB_MAXDBL) -UINT64_MAXDBL / 2 - 1 <= \
                                         (HB_MAXDBL) (d) && (HB_MAXDBL) (d) <= \
                                         (HB_MAXDBL) UINT64_MAXDBL / 2 )
#endif

#define HB_MACRO2STRING( macro )    HB_MACRO2STRING_( macro )
#define HB_MACRO2STRING_( macro )   #macro

#if defined( __POCC__ ) || defined( __XCC__ )
   #define HB_SYMBOL_UNUSED( symbol )  do if( symbol ) {;} while( 0 )
#else
   #define HB_SYMBOL_UNUSED( symbol )  ( void ) symbol
#endif

/* ***********************************************************************
 * The name of starting procedure
 * Note: You have to define it in case when Harbour cannot find the proper
 * starting procedure (due to incorrect order of static data initialization)
 *
 * The list of compilers that require it:
 * - Watcom C/C++ 10.0
 * - GCC on Linux
 *
 * By default we are using automatic lookup (symbol not defined)
*/
#if defined(__WATCOMC__) || defined(__DMC__) || ( defined(__GNUC__) && !defined(__DJGPP__) && !defined(HB_OS_OS2_GCC) )
   #define HB_START_PROCEDURE "MAIN"
#endif

#if defined(HB_FUNC_CALLCONV)
   #define HARBOUR void HB_FUNC_CALLCONV
#else
   #define HARBOUR void
#endif

typedef HARBOUR ( * PHB_FUNC )( void );
typedef PHB_FUNC HB_FUNC_PTR;

#if defined( HB_DYNLIB )
   #if defined( __RSXNT__ )
      /* RSXNT does not support any type of export keyword.
         Exported (i.e., public) names can be obtained via
         the emxexp utility and the output can be used for
         input to a module definition file. See emxdev.doc
         in the RSXNT doc/ directory for more information. */
      #define HB_EXPORT

   #elif defined( __GNUC__ ) && defined( HB_OS_WIN_32 )
      #define HB_EXPORT __attribute__ (( dllexport ))

   #elif defined( __GNUC__ ) && defined( HB_OS_LINUX )
      #define HB_EXPORT __attribute__ ((visibility ("default")))

   #elif defined( __BORLANDC__ )
      #define HB_EXPORT __declspec( dllexport )

   #elif defined( __WATCOMC__ )
      #define HB_EXPORT __declspec( dllexport )

   #elif defined( ASANLM ) || defined( ASANT )
      #define HB_EXPORT

   #elif defined( HB_OS_WIN_32 )
      #define HB_EXPORT _declspec( dllexport )

   #else
      #define HB_EXPORT

   #endif
#else
   #define HB_EXPORT
#endif

#if defined( __RSXNT__ )
   /* RSXNT does not support any type of export keyword.
      Exported (i.e., public) names can be obtained via
      the emxexp utility and the output can be used for
      input to a module definition file. See emxdev.doc
      in the RSXNT doc/ directory for more information. */
   #define HB_IMPORT

#elif defined( __GNUC__ ) && defined( HB_OS_WIN_32 )
   #define HB_IMPORT __attribute__ (( dllimport ))

#elif defined( __BORLANDC__ )
   #define HB_IMPORT __declspec( dllimport )

#elif defined( __WATCOMC__ )
   #define HB_IMPORT __declspec( dllimport )

#elif defined( ASANLM ) || defined( ASANT )
   #define HB_IMPORT

#elif defined( HB_OS_WIN_32 )
   #define HB_IMPORT _declspec( dllimport )

#else
   #define HB_IMPORT

#endif


/* Function declaration macros */

/* NOTE: The prefix is "HB_FUN_" currently, this is needed to
         avoid collision with any other declared symbol.
         Note that "HB_" is not enough, since the Harbour internals
         are also prefixed with HB_. [vszakats] */

#define HB_FUNCNAME( funcname )        HB_FUN_##funcname
#define HB_INIT_FUNCNAME( funcname )   HB_FUN_init_##funcname
#define HB_EXIT_FUNCNAME( funcname )   HB_FUN_exit_##funcname
#define HB_INITSTATICS_FUNCNAME()      hb_INITSTATICS

#if defined( __cplusplus ) && !defined( HB_FUNC_USE_DECORATION )
   #define HB_EXTERN_C_ extern "C"
   #define HB_EXTERN_
#else
   #define HB_EXTERN_C_
   #define HB_EXTERN_ extern
#endif

#define HB_FUNC_EXEC( funcname )   HB_FUN_##funcname();
#define HB_FUNC( funcname )        HB_EXTERN_C_ HB_EXPORT HARBOUR HB_FUN_##funcname ( void )
#define HB_FUNC_EXTERN( funcname ) HB_EXTERN_C_ HB_EXTERN_ HARBOUR HB_EXPORT HB_FUN_##funcname ( void )
#define HB_FUNC_STATIC( funcname ) static HARBOUR HB_FUN_##funcname ( void )
#define HB_FUNC_INIT( funcname )   static HARBOUR HB_FUN_init_##funcname ( void )
#define HB_FUNC_EXIT( funcname )   static HARBOUR HB_FUN_exit_##funcname ( void )
#define HB_FUNC_INITSTATICS( )     static HARBOUR hb_INITSTATICS( void )
#define HB_FUNC_INITLINES( )       static HARBOUR hb_INITLINES( void )

typedef SHORT HB_SYMBOLSCOPE;   /* stores symbol's scope */

typedef BYTE HB_CHAR;
typedef BYTE HB_ATTR;

/* Some common character constants */

#define HB_CHAR_NUL             '\0'    /*   0 - NUL */
#define HB_CHAR_EOS             HB_CHAR_NUL
#define HB_CHAR_BEL             '\a'    /*   7 - Bell */
#define HB_CHAR_BS              '\b'    /*   8 - Backspace */
#define HB_CHAR_HT              '\t'    /*   9 - Tab horizontal */
#define HB_CHAR_LF              '\n'    /*  10 - Linefeed */
#define HB_CHAR_VT              '\v'    /*  11 - Tab vertical */
#define HB_CHAR_FF              '\f'    /*  12 - Formfeed */
#define HB_CHAR_CR              '\r'    /*  13 - Carriage return */
#define HB_CHAR_EOF             '\x1A'  /*  26 - End of file marker */

/* Harbour specific character constants */

#define HB_CHAR_HARD1           ( ( char ) HB_CHAR_CR )
#define HB_CHAR_HARD2           ( ( char ) HB_CHAR_LF )

#define HB_CHAR_SOFT1           ( ( char ) 141 )
#define HB_CHAR_SOFT2           ( ( char ) HB_CHAR_LF )

#endif /* HB_DEFS_H_ */
c:\harbour\include\hberrors.h
/*
 * $Id: hberrors.h 8543 2008-05-31 08:09:09Z vszakats $
 */

/*
 * Harbour Project source code:
 * Header file for compiler error codes
 *
 * Copyright 1999 Ryszard Glab 
 * 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.
 *
 */

#ifndef HB_ERRORS_H_
#define HB_ERRORS_H_

#include "hbsetup.h"

HB_EXTERN_BEGIN

/*
 * Errors generated by Harbour compiler
 */
#define HB_COMP_ERR_OUTSIDE                     1
#define HB_COMP_ERR_FUNC_DUPL                   2
#define HB_COMP_ERR_VAR_DUPL                    3
#define HB_COMP_ERR_FOLLOWS_EXEC                4
#define HB_COMP_ERR_OUTER_VAR                   5
#define HB_COMP_ERR_NUMERIC_FORMAT              6
#define HB_COMP_ERR_STRING_TERMINATOR           7
#define HB_COMP_ERR_FUNC_RESERVED               8
#define HB_COMP_ERR_ILLEGAL_INIT                9
#define HB_COMP_ERR_ENDIF                       10
#define HB_COMP_ERR_ENDDO                       11
#define HB_COMP_ERR_ENDCASE                     12
#define HB_COMP_ERR_NEXTFOR                     13
#define HB_COMP_ERR_UNMATCHED_ELSE              14
#define HB_COMP_ERR_UNMATCHED_ELSEIF            15
#define HB_COMP_ERR_SYNTAX                      16
#define HB_COMP_ERR_UNCLOSED_STRU               17
#define HB_COMP_ERR_UNMATCHED_EXIT              18
#define HB_COMP_ERR_SYNTAX2                     19
#define HB_COMP_ERR_INCOMPLETE_STMT             20
#define HB_COMP_ERR_CHECKING_ARGS               21
#define HB_COMP_ERR_INVALID_LVALUE              22
#define HB_COMP_ERR_INVALID_REFER               23
#define HB_COMP_ERR_PARAMETERS_NOT_ALLOWED      24
#define HB_COMP_ERR_EXIT_IN_SEQUENCE            25
#define HB_COMP_ERR_UNTERM_ARRAY_INDEX          26
#define HB_COMP_ERR_MEMALLOC                    27
#define HB_COMP_ERR_MEMREALLOC                  28
#define HB_COMP_ERR_MEMFREE                     29
#define HB_COMP_ERR_YACC                        30
#define HB_COMP_ERR_JUMP_TOO_LONG               31
#define HB_COMP_ERR_CREATE_OUTPUT               32
#define HB_COMP_ERR_CREATE_PPO                  33
#define HB_COMP_ERR_BADOPTION                   34
#define HB_COMP_ERR_BADPARAM                    35
#define HB_COMP_ERR_BADFILENAME                 36
#define HB_COMP_ERR_MAYHEM_IN_CASE              37
#define HB_COMP_ERR_INVALID_TYPE                38
#define HB_COMP_ERR_INVALID_ALIAS               39
#define HB_COMP_ERR_INVALID_INDEX               40
#define HB_COMP_ERR_INVALID_BOUND               41
#define HB_COMP_ERR_BAD_MACRO                   42
#define HB_COMP_ERR_INVALID_SEND                43
#define HB_COMP_ERR_FUNC_ANNOUNCE               44
#define HB_COMP_ERR_JUMP_NOT_FOUND              45
#define HB_COMP_ERR_CASE                        46
#define HB_COMP_ERR_BLOCK                       47
#define HB_COMP_ERR_GET_COMPLEX_MACRO           48
#define HB_COMP_ERR_INVALID_INLINE              49
#define HB_COMP_ERR_TOOMANY_INLINE              50
#define HB_COMP_ERR_REQUIRES_C                  51
#define HB_COMP_ERR_OPTIMIZEDLOCAL_OUT_OF_RANGE 52
#define HB_COMP_ERR_FORVAR_TOOMANY              53
#define HB_COMP_ERR_FORVAR_DIFF                 54
#define HB_COMP_ERR_NOT_LITERAL_CASE            55
#define HB_COMP_ERR_INVALID_STR                 56
#define HB_COMP_ERR_INVALID_DATE                57
#define HB_COMP_ERR_MEMOVERFLOW                 58
#define HB_COMP_ERR_MEMCORRUPT                  59
#define HB_COMP_ERR_WITHOBJECT                  60
#define HB_COMP_ERR_BUFFER_OVERFLOW             61
#define HB_COMP_ERR_UNSUPPORTED_LANG            62
#define HB_COMP_ERR_STRING_TOO_LONG             63
#define HB_COMP_ERR_BLOCK_TOO_BIG               64
#define HB_COMP_ERR_NOT_VPARAMS                 65
#define HB_COMP_ERR_OPEN_CFG                    66
#define HB_COMP_ERR_ALWAYS_AFTER_EXIT           67
#define HB_COMP_ERR_HISTORICAL_1                68
#define HB_COMP_ERR_HISTORICAL_2                69
#define HB_COMP_ERR_HISTORICAL_3                70
#define HB_COMP_ERR_HISTORICAL_4                71

#define HB_COMP_WARN_AMBIGUOUS_VAR              1
#define HB_COMP_WARN_MEMVAR_ASSUMED             2
#define HB_COMP_WARN_VAR_NOT_USED               3
#define HB_COMP_WARN_BLOCKVAR_NOT_USED          4
#define HB_COMP_WARN_NO_RETURN_VALUE            5
#define HB_COMP_WARN_PROC_RETURN_VALUE          6
#define HB_COMP_WARN_FUN_WITH_NO_RETURN         7
#define HB_COMP_WARN_ASSIGN_TYPE                8
#define HB_COMP_WARN_OPERAND_TYPE               9
#define HB_COMP_WARN_OPERANDS_INCOMPATIBLE      10
#define HB_COMP_WARN_ASSIGN_SUSPECT             11
#define HB_COMP_WARN_OPERAND_SUSPECT            12
#define HB_COMP_WARN_NOT_ARRAY                  13
#define HB_COMP_WARN_RETURN_TYPE                14
#define HB_COMP_WARN_RETURN_SUSPECT             15
#define HB_COMP_WARN_PARAM_COUNT                16
#define HB_COMP_WARN_PARAM_TYPE                 17
#define HB_COMP_WARN_PARAM_SUSPECT              18
#define HB_COMP_WARN_DUP_DECLARATION            19
#define HB_COMP_WARN_DECLARATION_CONFLICT       20
#define HB_COMP_WARN_NOT_INITIALIZED            21
#define HB_COMP_WARN_VAL_NOT_USED               22
#define HB_COMP_WARN_ARRAY_ASSIGN_TYPE          23
#define HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT       24
#define HB_COMP_WARN_CLASS_NOT_FOUND            25
#define HB_COMP_WARN_MESSAGE_NOT_FOUND          26
#define HB_COMP_WARN_MEANINGLESS                27
#define HB_COMP_WARN_UNREACHABLE                28
#define HB_COMP_WARN_DUPL_ANNOUNCE              29
#define HB_COMP_WARN_FORVAR_DUPL                30
#define HB_COMP_WARN_ENUM_INVALID               31

HB_EXTERN_END

#endif /* HB_ERRORS_H_ */
c:\harbour\include\hbexprop.h
/*
 * $Id: hbexprop.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Harbour Compiler
 *
 * Copyright 1999 Ryszard Glab
 * 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.
 *
 */

#ifndef HB_EXPROP_H_
#define HB_EXPROP_H_

#include "hbapi.h"

HB_EXTERN_BEGIN

/* Definitions of function templates used in expression's message
 * handling
 */
#define  HB_EXPR_FUNC( proc )  HB_EXPR_PTR proc( HB_EXPR_PTR pSelf, HB_EXPR_MESSAGE iMessage, HB_COMP_DECL )
typedef  HB_EXPR_FUNC( HB_EXPR_FUNC_ );
typedef  HB_EXPR_FUNC_ *HB_EXPR_FUNC_PTR;

typedef  HB_EXPR_PTR HB_EXPR_ACTION( HB_EXPR_PTR pSelf, int iMessage, HB_COMP_DECL );
#define HB_EXPR_PCODE0( action ) action( HB_COMP_PARAM )
#define HB_EXPR_PCODE1( action, p1 ) action( (p1), HB_COMP_PARAM )
#define HB_EXPR_PCODE2( action, p1, p2 ) action( (p1), (p2), HB_COMP_PARAM )
#define HB_EXPR_PCODE3( action, p1, p2, p3 ) action( (p1), (p2), (p3), HB_COMP_PARAM )
#define HB_EXPR_PCODE4( action, p1, p2, p3, p4 ) action( (p1), (p2), (p3), (p4), HB_COMP_PARAM )

#if defined( HB_MACRO_SUPPORT )
#define hb_comp_ExprTable     hb_macro_ExprTable
#endif

#if !defined( HB_COMMON_SUPPORT )
extern const HB_EXPR_FUNC_PTR hb_comp_ExprTable[ HB_EXPR_COUNT ];
#define  HB_EXPR_USE( pSelf, iMessage )  \
         hb_comp_ExprTable[ (pSelf)->ExprType ]( (pSelf), (iMessage), HB_COMP_PARAM )
#endif

extern HB_EXPR_PTR hb_compExprNewEmpty( HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewNil( HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewDouble( double, BYTE, BYTE, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewLong( HB_LONG, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewDate( HB_LONG, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewString( const char *, ULONG, BOOL, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewLogical( int, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewSelf( HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewCodeBlock( char *, ULONG, int, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewVar( const char *, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewAliasVar( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewAliasExpr( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewMacro( HB_EXPR_PTR, unsigned char, const char *, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewFunName( const char *, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewRTVar( const char *, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewAlias( const char *, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewEQ( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewNE( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewLT( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewLE( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewGT( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewGE( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewIN( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewPlus( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewMinus( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewMult( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewDiv( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewMod( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewPower( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewAssign( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewEqual( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewPlusEq( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewMinusEq( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewMultEq( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewDivEq( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewModEq( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewExpEq( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewPostInc( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewPostDec( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewPreInc( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewPreDec( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewAnd( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewOr( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewNot( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewNegate( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewVarRef( const char *, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewFunRef( const char *, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewRef( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewCodeblockExpr( HB_EXPR_PTR, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compExprNewSend( HB_EXPR_PTR, const char *szMessage, HB_EXPR_PTR pMessage, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewMethodCall( HB_EXPR_PTR, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compExprNewList( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewArgList( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewArgRef( HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewArray( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewHash( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprNewArrayAt( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprAddListExpr( HB_EXPR_PTR, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compExprCBVarAdd( HB_EXPR_PTR, const char *, BYTE, HB_COMP_DECL );
extern void hb_compExprCBVarDel( HB_CBVAR_PTR );
extern HB_EXPR_PTR hb_compExprAddCodeblockExpr( HB_EXPR_PTR, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compExprSetCodeblockBody( HB_EXPR_PTR pExpr, BYTE * pCode, ULONG ulLen );
extern HB_EXPR_PTR hb_compExprNewIIF( HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compExprMacroAsAlias( HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compExprAssign( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprEqual( HB_EXPR_PTR, HB_EXPR_PTR );
extern HB_EXPR_PTR hb_compExprAssignStatic( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprClone( HB_EXPR_PTR pSrc );
extern ULONG hb_compExprListLen( HB_EXPR_PTR );
extern ULONG hb_compExprParamListLen( HB_EXPR_PTR );
extern ULONG hb_compExprMacroListLen( HB_EXPR_PTR );
extern ULONG hb_compExprParamListCheck( HB_COMP_DECL, HB_EXPR_PTR );

extern const char * hb_compExprDescription( HB_EXPR_PTR );
extern int hb_compExprType( HB_EXPR_PTR );
extern int hb_compExprIsInteger( HB_EXPR_PTR );
extern int hb_compExprIsLong( HB_EXPR_PTR );
extern int hb_compExprAsInteger( HB_EXPR_PTR );
extern int hb_compExprAsNumSign( HB_EXPR_PTR );
extern int hb_compExprIsString( HB_EXPR_PTR );
extern int hb_compExprAsStringLen( HB_EXPR_PTR );
extern HB_LONG hb_compExprAsLongNum( HB_EXPR_PTR );
extern const char * hb_compExprAsString( HB_EXPR_PTR );
extern const char * hb_compExprAsSymbol( HB_EXPR_PTR );

extern HB_EXPR_PTR hb_compExprListStrip( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprIsValidMacro( const char *, ULONG, BOOL *, HB_COMP_DECL );

extern HB_EXPR_PTR hb_compExprSetOperand( HB_EXPR_PTR, HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL );

extern void hb_compExprDelOperator( HB_EXPR_PTR, HB_COMP_DECL );

extern HB_EXPR_PTR hb_compExprReducePower( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceMod( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceDiv( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceMult( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceMinus( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReducePlus( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceNegate( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceIN( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceNE( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceGE( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceLE( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceGT( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceLT( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceEQ( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceAnd( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceOr( HB_EXPR_PTR pSelf, HB_COMP_DECL );
extern HB_EXPR_PTR hb_compExprReduceIIF( HB_EXPR_PTR, HB_COMP_DECL );

extern BOOL hb_compExprReduceAT( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceCHR( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceLEN( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceASC( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceINT( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceEMPTY( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceSTOD( HB_EXPR_PTR, USHORT usCount, HB_COMP_DECL );
extern BOOL hb_compExprReduceDTOS( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceCTOD( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceUPPER( HB_EXPR_PTR, HB_COMP_DECL );
extern BOOL hb_compExprReduceBitFunc( HB_EXPR_PTR, HB_LONG, BOOL, HB_COMP_DECL );

extern void hb_compI18nAdd( HB_COMP_DECL, const char* szText, const char* szContext, UINT uiLine );

HB_EXTERN_END

#endif  /* HB_EXPROP_H_ */
c:\harbour\include\hbfixdj.h
/*
 * $Id: hbfixdj.h 7631 2007-08-02 15:58:50Z vszakats $
 */

/*
 * Harbour Project source code:
 * Header file for compiler and runtime basic type declarations
 *
 * Copyright 1999 {list of individual authors and e-mail addresses}
 * 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.
 *
 */

#ifdef __dj_include_inline_ctype_ha_

#undef isalnum
#undef isalpha
#undef iscntrl
#undef isdigit
#undef isgraph
#undef islower
#undef isprint
#undef ispunct
#undef isspace
#undef isupper
#undef isxdigit

#undef tolower
#undef toupper

#define isalnum(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISALNUM)
#define isalpha(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISALPHA)
#define iscntrl(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISCNTRL)
#define isdigit(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISDIGIT)
#define isgraph(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISGRAPH)
#define islower(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISLOWER)
#define isprint(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISPRINT)
#define ispunct(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISPUNCT)
#define isspace(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISSPACE)
#define isupper(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISUPPER)
#define isxdigit(c) (__dj_ctype_flags[(unsigned char)(c)+1] & __dj_ISXDIGIT)

#define tolower(c) (__dj_ctype_tolower[(unsigned char)(c)+1])
#define toupper(c) (__dj_ctype_toupper[(unsigned char)(c)+1])

#endif /* __dj_include_inline_ctype_ha_ */
c:\harbour\include\hbgtcore.h
/*
 * $Id: hbgtcore.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Internal Terminal API
 *
 * Copyright 2006 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
 * 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.
 *
 */

/* NOTE: The declaration of hb_gtSetPos(), hb_gtGetPos(), hb_gtWrite(),
         hb_gtWriteAt(), hb_gtRepChar(), hb_gtBox(), hb_gtBoxS(), hb_gtBoxD()
         hb_gtInit() differs in parameter types from the original CA-Cl*pper
         versions. [vszakats] */

#ifndef HB_GTCORE_H_
#define HB_GTCORE_H_

#include "hbapigt.h"
#include "hbapicdp.h"

HB_EXTERN_BEGIN

/* extended attributes used by core screen buffer */
#define HB_GT_ATTR_BOX        0x01
#define HB_GT_ATTR_SHADOW     0x02
#define HB_GT_ATTR_UNDEF      0x40
#define HB_GT_ATTR_REFRESH    0x80

/* convert lower case suffixes to upper */
#define HB_GT_nul    HB_GT_NUL
#define HB_GT_std    HB_GT_STD
#define HB_GT_cgi    HB_GT_CGI
#define HB_GT_pca    HB_GT_PCA
#define HB_GT_crs    HB_GT_CRS
#define HB_GT_sln    HB_GT_SLN
#define HB_GT_win    HB_GT_WIN
#define HB_GT_wvt    HB_GT_WVT
#define HB_GT_dos    HB_GT_DOS
#define HB_GT_os2    HB_GT_OS2
#define HB_GT_tpl    HB_GT_TPL
#define HB_GT_trm    HB_GT_TRM
#define HB_GT_QTc    HB_GT_QTC
#define HB_GT_xvt    HB_GT_XVT
#define HB_GT_xwc    HB_GT_XWC
#define HB_GT_gui    HB_GT_GUI

/* These hacks are needed to force preprocessing if id/x is also a macro */
#define _HB_GT_PREF_( id )      _HB_GT_PREF__( id )
#define _HB_GT_PREF__( id )     HB_GT_##id

#define HB_GT_REQUEST( id )      HB_GT_REQUEST_( _HB_GT_PREF_( id ) )
#define HB_GT_REQUEST_( id )     HB_GT_REQUEST__( id )
#define HB_GT_REQUEST__( id )    HB_FUNC_EXTERN( id ); \
                                 void hb_gt_ForceLink_##id( void ) \
                                 { \
                                    HB_FUNC_EXEC( id ); \
                                 }

#define HB_GT_ANNOUNCE( id )     HB_GT_ANNOUNCE_( _HB_GT_PREF_( id ) )
#define HB_GT_ANNOUNCE_( id )    HB_GT_ANNOUNCE__( id )
#define HB_GT_ANNOUNCE__( id )   HB_FUNC( id ) {} HB_FUNC( id##_DEFAULT ) {}

#define HB_GT_DRVNAME( id )      HB_MACRO2STRING( id )

#define HB_GT_FUNC( x )          HB_GT_FUNC_( x, HB_GT_NAME )
#define HB_GT_FUNC_( x, id )     HB_GT_FUNC__( x, id )
#define HB_GT_FUNC__( x, id )    hb##_##id##_##x

/* forward declaration */
struct _HB_GT_BASE;

#define HB_GT_PTR       struct _HB_GT_BASE *

typedef struct
{
   void     (* Init) ( HB_GT_PTR, HB_FHANDLE, HB_FHANDLE, HB_FHANDLE );
   void     (* Exit) ( HB_GT_PTR );
   void *   (* New) ( HB_GT_PTR );
   void     (* Free) ( HB_GT_PTR );
   BOOL     (* Resize ) ( HB_GT_PTR, int, int );
   BOOL     (* SetMode) ( HB_GT_PTR, int, int );
   void     (* GetSize) ( HB_GT_PTR, int *, int * );
   void     (* SemiCold) ( HB_GT_PTR );
   void     (* ColdArea) ( HB_GT_PTR, int, int, int, int );
   void     (* ExposeArea) ( HB_GT_PTR, int, int, int, int );
   void     (* ScrollArea) ( HB_GT_PTR, int, int, int, int, BYTE, BYTE, int, int );
   void     (* TouchCell) ( HB_GT_PTR, int, int );
   void     (* Redraw) ( HB_GT_PTR, int, int, int );
   void     (* Refresh) ( HB_GT_PTR );
   void     (* Flush) ( HB_GT_PTR );
   int      (* MaxCol) ( HB_GT_PTR );
   int      (* MaxRow) ( HB_GT_PTR );
   BOOL     (* CheckPos) ( HB_GT_PTR, int, int, long * );
   void     (* SetPos) ( HB_GT_PTR, int, int );
   void     (* GetPos) ( HB_GT_PTR, int *, int * );
   BOOL     (* IsColor) ( HB_GT_PTR );
   void     (* GetColorStr) ( HB_GT_PTR, char * );
   void     (* SetColorStr) ( HB_GT_PTR, const char * );
   void     (* ColorSelect) ( HB_GT_PTR, int );
   int      (* GetColor) ( HB_GT_PTR );
   int      (* ColorNum) ( HB_GT_PTR, const char * );
   void     (* ColorsToString) ( HB_GT_PTR, int *, int, char *, int );
   void     (* StringToColors) ( HB_GT_PTR, const char *, int **, int * );
   void     (* GetColorData) ( HB_GT_PTR, int **, int *, int * );
   int      (* GetClearColor) ( HB_GT_PTR );
   void     (* SetClearColor) ( HB_GT_PTR, int );
   int      (* GetClearChar) ( HB_GT_PTR );
   void     (* SetClearChar) ( HB_GT_PTR, int );
   int      (* GetCursorStyle) ( HB_GT_PTR );
   void     (* SetCursorStyle) ( HB_GT_PTR, int );
   void     (* GetScrCursor) ( HB_GT_PTR, int *, int *, int * );
   BOOL     (* GetScrChar) ( HB_GT_PTR, int, int, BYTE *, BYTE *, USHORT * );
   BOOL     (* PutScrChar) ( HB_GT_PTR, int, int, BYTE, BYTE, USHORT );
   void     (* DispBegin) ( HB_GT_PTR );
   void     (* DispEnd) ( HB_GT_PTR );
   int      (* DispCount) ( HB_GT_PTR );
   BOOL     (* GetChar) ( HB_GT_PTR, int, int, BYTE *, BYTE *, USHORT * );
   BOOL     (* PutChar) ( HB_GT_PTR, int, int, BYTE, BYTE, USHORT );
   long     (* RectSize) ( HB_GT_PTR, int, int, int, int );
   void     (* Save) ( HB_GT_PTR, int, int, int, int, BYTE * );
   void     (* Rest) ( HB_GT_PTR, int, int, int, int, BYTE * );
   void     (* PutText) ( HB_GT_PTR, int, int, BYTE, BYTE *, ULONG );
   void     (* Replicate) ( HB_GT_PTR, int, int, BYTE, BYTE, USHORT, ULONG );
   void     (* WriteAt) ( HB_GT_PTR, int, int, BYTE *, ULONG );
   void     (* Write) ( HB_GT_PTR, BYTE *, ULONG );
   void     (* WriteCon) ( HB_GT_PTR, BYTE *, ULONG );
   void     (* SetAttribute) ( HB_GT_PTR, int, int, int, int, BYTE );
   void     (* DrawShadow) ( HB_GT_PTR, int, int, int, int, BYTE );
   void     (* Scroll) ( HB_GT_PTR, int, int, int, int, BYTE, BYTE, int, int );
   void     (* ScrollUp) ( HB_GT_PTR, int, BYTE, BYTE );
   void     (* Box) ( HB_GT_PTR, int, int, int, int, BYTE *, BYTE );
   void     (* BoxD) ( HB_GT_PTR, int, int, int, int, BYTE *, BYTE );
   void     (* BoxS) ( HB_GT_PTR, int, int, int, int, BYTE *, BYTE );
   void     (* HorizLine) ( HB_GT_PTR, int, int, int, BYTE, BYTE );
   void     (* VertLine) ( HB_GT_PTR, int, int, int, BYTE, BYTE );
   BOOL     (* GetBlink) ( HB_GT_PTR );
   void     (* SetBlink) ( HB_GT_PTR, BOOL );
   void     (* SetSnowFlag) ( HB_GT_PTR, BOOL );
   const char * (* Version) ( HB_GT_PTR, int );
   BOOL     (* Suspend) ( HB_GT_PTR );
   BOOL     (* Resume) ( HB_GT_PTR );
   BOOL     (* PreExt) ( HB_GT_PTR );
   BOOL     (* PostExt) ( HB_GT_PTR );
   void     (* OutStd) ( HB_GT_PTR, BYTE *, ULONG );
   void     (* OutErr) ( HB_GT_PTR, BYTE *, ULONG );
   void     (* Tone) ( HB_GT_PTR, double, double );
   void     (* Bell) ( HB_GT_PTR );
   BOOL     (* Info) ( HB_GT_PTR, int, PHB_GT_INFO );
   int      (* Alert) ( HB_GT_PTR, PHB_ITEM, PHB_ITEM, int, int, double );
   int      (* SetFlag) ( HB_GT_PTR, int, int );

   /* internationalization */
   BOOL     (* SetDispCP) ( HB_GT_PTR, char *, char *, BOOL );
   BOOL     (* SetKeyCP) ( HB_GT_PTR, char *, char * );

   /* keyboard */
   int      (* ReadKey) ( HB_GT_PTR, int );

   int      (* InkeyGet) ( HB_GT_PTR, BOOL fWait, double dSeconds, int iEventMask );
   void     (* InkeyPut) ( HB_GT_PTR, int iKey );
   void     (* InkeyIns) ( HB_GT_PTR, int iKey );
   int      (* InkeyLast) ( HB_GT_PTR, int iEventMask );
   int      (* InkeyNext) ( HB_GT_PTR, int iEventMask );
   void     (* InkeyPoll) ( HB_GT_PTR );
   void     (* InkeySetText) ( HB_GT_PTR, const char * szText, ULONG ulLen );
   int      (* InkeySetLast) ( HB_GT_PTR, int iKey );
   void     (* InkeyReset) ( HB_GT_PTR );
   void     (* InkeyExit) ( HB_GT_PTR );

   /* mouse */
   void     (* MouseInit) ( HB_GT_PTR );
   void     (* MouseExit) ( HB_GT_PTR );
   BOOL     (* MouseIsPresent) ( HB_GT_PTR );
   void     (* MouseShow) ( HB_GT_PTR );
   void     (* MouseHide) ( HB_GT_PTR );
   BOOL     (* MouseGetCursor) ( HB_GT_PTR );
   void     (* MouseSetCursor) ( HB_GT_PTR, BOOL );
   int      (* MouseCol) ( HB_GT_PTR );
   int      (* MouseRow) ( HB_GT_PTR );
   void     (* MouseGetPos) ( HB_GT_PTR, int *, int * );
   void     (* MouseSetPos) ( HB_GT_PTR, int, int );
   void     (* MouseSetBounds) ( HB_GT_PTR, int, int, int, int );
   void     (* MouseGetBounds) ( HB_GT_PTR, int *, int *, int *, int * );
   int      (* MouseStorageSize) ( HB_GT_PTR );
   void     (* MouseSaveState) ( HB_GT_PTR, BYTE * );
   void     (* MouseRestoreState) ( HB_GT_PTR, BYTE * );
   int      (* MouseGetDoubleClickSpeed) ( HB_GT_PTR );
   void     (* MouseSetDoubleClickSpeed) ( HB_GT_PTR, int );
   int      (* MouseCountButton) ( HB_GT_PTR );
   BOOL     (* MouseButtonState) ( HB_GT_PTR, int );
   BOOL     (* MouseButtonPressed) ( HB_GT_PTR, int, int *, int * );
   BOOL     (* MouseButtonReleased) ( HB_GT_PTR, int, int *, int * );
   int      (* MouseReadKey) ( HB_GT_PTR, int );

   /* Graphics API */
   int      (* GfxPrimitive) ( HB_GT_PTR, int, int, int, int, int, int );
   void     (* GfxText) ( HB_GT_PTR, int, int, char *, int, int, int );

#if 0
    /* keyboard */
    int     (* ExtendedKeySupport) ( HB_GT_PTR );

    /* GT CLIPBOARD functions */
    void    (* GetClipboard) ( HB_GT_PTR, char *, ULONG * );
    void    (* SetClipboard) ( HB_GT_PTR, char *, ULONG );
    ULONG   (* GetClipboardSize) ( HB_GT_PTR );

    void    (* ProcessMessages) ( HB_GT_PTR );

    /* GT to DRIVER communication functions */
    void    (* update ) ( HB_GT_PTR, int );
    int     (* info ) ( HB_GT_PTR, int, BOOL , int , void * );

#endif

   void    (* WhoCares) ( HB_GT_PTR, void * );

} HB_GT_FUNCS, * PHB_GT_FUNCS;

typedef int ( * GTENTRYP_V )( void );

#define GTFUNCSCOUNT   ( sizeof( HB_GT_FUNCS ) / sizeof( GTENTRYP_V ) )

#define HB_GT_MAX_      32
#define HB_GT_NAME_MAX_ 8

typedef struct _HB_GT_INIT
{
   const char     * id;
   BOOL           (* init) ( PHB_GT_FUNCS );
   PHB_GT_FUNCS   pSuperTable;
   int *          pGtId;
} HB_GT_INIT, * PHB_GT_INIT;


typedef union
{
   struct
   {
      UINT16   usChar;
      BYTE     bColor;
      BYTE     bAttr;
   } c;
   UINT32   uiValue;
} HB_SCREENCELL;
typedef HB_SCREENCELL * PHB_SCREENCELL;


typedef struct _HB_GT_BASE
{
   PHB_GT_FUNCS   pFuncTable;

   int            iRow;             /* cursor row position */
   int            iCol;             /* cursor column position */

   int            iHeight;          /* window height */
   int            iWidth;           /* window width */

   PHB_SCREENCELL screenBuffer;     /* window foreground (board) current buffer */
   PHB_SCREENCELL prevBuffer;       /* window foreground (board) previous buffer */

   BOOL *         pLines;           /* Touched Window lines */
   BOOL           fRefresh;         /* Should Window be refreshed */

   BOOL           fVgaCell;
   BOOL           fIsColor;
   BOOL           fBlinking;
   BOOL           fStdOutCon;
   BOOL           fStdErrCon;
   int            iCursorShape;
   USHORT         uiDispCount;
   USHORT         uiExtCount;
   USHORT         uiClearChar;
   BYTE           bClearColor;
   HB_FHANDLE     hStdIn;
   HB_FHANDLE     hStdOut;
   HB_FHANDLE     hStdErr;

   BOOL           fDispTrans;
   PHB_CODEPAGE   cdpTerm;
   PHB_CODEPAGE   cdpHost;

   int            iColorIndex;
   int            iColorCount;
   int *          pColor;

   int            iDoubleClickSpeed; /* In milliseconds */
   BOOL           fMouseVisible;
   int            iMouseLastRow;
   int            iMouseLastCol;
   HB_LONG        iMouseLeftTimer;
   HB_LONG        iMouseRightTimer;
   HB_LONG        iMouseMiddleTimer;

   int            defaultKeyBuffer[ HB_DEFAULT_INKEY_BUFSIZE + 1 ];

   int *          inkeyBuffer;
   int            inkeyBufferSize;
   int            inkeyHead;
   int            inkeyTail;
   int            iLastPut;
   int            inkeyLast;
   BYTE *         StrBuffer;
   ULONG          StrBufferSize;
   ULONG          StrBufferPos;

   PHB_ITEM       pNotifierBlock;

   void *         pGTData[HB_GT_MAX_];    /* local GT data */

} HB_GT_BASE, * PHB_GT_BASE, * PHB_GT;

extern PHB_GT hb_gt_Base( void );
extern void hb_gt_BaseFree( PHB_GT pGT );

#define HB_GTLOCAL(g)   (g)->pGTData[*HB_GTID_PTR]

#define HB_GTSELF_INIT(g,i,o,e)                 (g)->pFuncTable->Init(g,i,o,e)
#define HB_GTSELF_EXIT(g)                       (g)->pFuncTable->Exit(g)
#define HB_GTSELF_NEW(g)                        (g)->pFuncTable->New(g)
#define HB_GTSELF_FREE(g)                       (g)->pFuncTable->Free(g)
#define HB_GTSELF_RESIZE(g,r,c)                 (g)->pFuncTable->Resize(g,r,c)
#define HB_GTSELF_SETMODE(g,r,c)                (g)->pFuncTable->SetMode(g,r,c)
#define HB_GTSELF_GETSIZE(g,pr,pc)              (g)->pFuncTable->GetSize(g,pr,pc)
#define HB_GTSELF_SEMICOLD(g)                   (g)->pFuncTable->SemiCold(g)
#define HB_GTSELF_COLDAREA(g,t,l,b,r)           (g)->pFuncTable->ColdArea(g,t,l,b,r)
#define HB_GTSELF_EXPOSEAREA(g,t,l,b,r)         (g)->pFuncTable->ExposeArea(g,t,l,b,r)
#define HB_GTSELF_SCROLLAREA(g,t,l,b,r,m,u,v,h) (g)->pFuncTable->ScrollArea(g,t,l,b,r,m,u,v,h)
#define HB_GTSELF_TOUCHCELL(g,r,c)              (g)->pFuncTable->TouchCell(g,r,c)
#define HB_GTSELF_REDRAW(g,r,c,l)               (g)->pFuncTable->Redraw(g,r,c,l)
#define HB_GTSELF_REFRESH(g)                    (g)->pFuncTable->Refresh(g)
#define HB_GTSELF_FLUSH(g)                      (g)->pFuncTable->Flush(g)
#define HB_GTSELF_MAXCOL(g)                     (g)->pFuncTable->MaxCol(g)
#define HB_GTSELF_MAXROW(g)                     (g)->pFuncTable->MaxRow(g)
#define HB_GTSELF_CHECKPOS(g,r,c,l)             (g)->pFuncTable->CheckPos(g,r,c,l)
#define HB_GTSELF_SETPOS(g,r,c)                 (g)->pFuncTable->SetPos(g,r,c)
#define HB_GTSELF_GETPOS(g,pr,pc)               (g)->pFuncTable->GetPos(g,pr,pc)
#define HB_GTSELF_ISCOLOR(g)                    (g)->pFuncTable->IsColor(g)
#define HB_GTSELF_GETCOLORSTR(g,s)              (g)->pFuncTable->GetColorStr(g,s)
#define HB_GTSELF_SETCOLORSTR(g,s)              (g)->pFuncTable->SetColorStr(g,s)
#define HB_GTSELF_COLORSELECT(g,c)              (g)->pFuncTable->ColorSelect(g,c)
#define HB_GTSELF_GETCOLOR(g)                   (g)->pFuncTable->GetColor(g)
#define HB_GTSELF_COLORNUM(g,s)                 (g)->pFuncTable->ColorNum(g,s)
#define HB_GTSELF_COLORSTOSTRING(g,pc,i,ps,n)   (g)->pFuncTable->ColorsToString(g,pc,i,ps,n)
#define HB_GTSELF_STRINGTOCOLORS(g,ps,pc,pi)    (g)->pFuncTable->StringToColors(g,ps,pc,pi)
#define HB_GTSELF_GETCOLORDATA(g,pc,pn,pi)      (g)->pFuncTable->GetColorData(g,pc,pn,pi)
#define HB_GTSELF_GETCLEARCOLOR(g)              (g)->pFuncTable->GetClearColor(g)
#define HB_GTSELF_SETCLEARCOLOR(g,c)            (g)->pFuncTable->SetClearColor(g,c)
#define HB_GTSELF_GETCLEARCHAR(g)               (g)->pFuncTable->GetClearChar(g)
#define HB_GTSELF_SETCLEARCHAR(g,c)             (g)->pFuncTable->SetClearChar(g,c)
#define HB_GTSELF_GETCURSORSTYLE(g)             (g)->pFuncTable->GetCursorStyle(g)
#define HB_GTSELF_SETCURSORSTYLE(g,s)           (g)->pFuncTable->SetCursorStyle(g,s)
#define HB_GTSELF_GETSCRCURSOR(g,pr,pc,ps)      (g)->pFuncTable->GetScrCursor(g,pr,pc,ps)
#define HB_GTSELF_GETSCRCHAR(g,r,c,pm,pa,pc)    (g)->pFuncTable->GetScrChar(g,r,c,pm,pa,pc)
#define HB_GTSELF_PUTSCRCHAR(g,r,c,m,a,u)       (g)->pFuncTable->PutScrChar(g,r,c,m,a,u)
#define HB_GTSELF_DISPBEGIN(g)                  (g)->pFuncTable->DispBegin(g)
#define HB_GTSELF_DISPEND(g)                    (g)->pFuncTable->DispEnd(g)
#define HB_GTSELF_DISPCOUNT(g)                  (g)->pFuncTable->DispCount(g)
#define HB_GTSELF_GETCHAR(g,r,c,pm,pa,pc)       (g)->pFuncTable->GetChar(g,r,c,pm,pa,pc)
#define HB_GTSELF_PUTCHAR(g,r,c,m,a,u)          (g)->pFuncTable->PutChar(g,r,c,m,a,u)
#define HB_GTSELF_RECTSIZE(g,t,l,b,r)           (g)->pFuncTable->RectSize(g,t,l,b,r)
#define HB_GTSELF_SAVE(g,t,l,b,r,p)             (g)->pFuncTable->Save(g,t,l,b,r,p)
#define HB_GTSELF_REST(g,t,l,b,r,p)             (g)->pFuncTable->Rest(g,t,l,b,r,p)
#define HB_GTSELF_PUTTEXT(g,r,c,m,s,l)          (g)->pFuncTable->PutText(g,r,c,m,s,l)
#define HB_GTSELF_REPLICATE(g,r,c,m,a,u,l)      (g)->pFuncTable->Replicate(g,r,c,m,a,u,l)
#define HB_GTSELF_WRITEAT(g,r,c,s,l)            (g)->pFuncTable->WriteAt(g,r,c,s,l)
#define HB_GTSELF_WRITE(g,s,l)                  (g)->pFuncTable->Write(g,s,l)
#define HB_GTSELF_WRITECON(g,s,l)               (g)->pFuncTable->WriteCon(g,s,l)
#define HB_GTSELF_SETATTRIBUTE(g,t,l,b,r,m)     (g)->pFuncTable->SetAttribute(g,t,l,b,r,m)
#define HB_GTSELF_DRAWSHADOW(g,t,l,b,r,m)       (g)->pFuncTable->DrawShadow(g,t,l,b,r,m)
#define HB_GTSELF_SCROLL(g,t,l,b,r,m,u,v,h)     (g)->pFuncTable->Scroll(g,t,l,b,r,m,u,v,h)
#define HB_GTSELF_SCROLLUP(g,r,m,u)             (g)->pFuncTable->ScrollUp(g,r,m,u)
#define HB_GTSELF_BOX(g,t,l,b,r,f,m)            (g)->pFuncTable->Box(g,t,l,b,r,f,m)
#define HB_GTSELF_BOXD(g,t,l,b,r,f,m)           (g)->pFuncTable->BoxD(g,t,l,b,r,f,m)
#define HB_GTSELF_BOXS(g,t,l,b,r,f,m)           (g)->pFuncTable->BoxS(g,t,l,b,r,f,m)
#define HB_GTSELF_HORIZLINE(g,h,l,r,u,m)        (g)->pFuncTable->HorizLine(g,h,l,r,u,m)
#define HB_GTSELF_VERTLINE(g,c,t,b,u,m)         (g)->pFuncTable->VertLine(g,c,t,b,u,m)
#define HB_GTSELF_GETBLINK(g)                   (g)->pFuncTable->GetBlink(g)
#define HB_GTSELF_SETBLINK(g,b)                 (g)->pFuncTable->SetBlink(g,b)
#define HB_GTSELF_SETSNOWFLAG(g,b)              (g)->pFuncTable->SetSnowFlag(g,b)
#define HB_GTSELF_VERSION(g,i)                  (g)->pFuncTable->Version(g,i)
#define HB_GTSELF_SUSPEND(g)                    (g)->pFuncTable->Suspend(g)
#define HB_GTSELF_RESUME(g)                     (g)->pFuncTable->Resume(g)
#define HB_GTSELF_PREEXT(g)                     (g)->pFuncTable->PreExt(g)
#define HB_GTSELF_POSTEXT(g)                    (g)->pFuncTable->PostExt(g)
#define HB_GTSELF_OUTSTD(g,s,l)                 (g)->pFuncTable->OutStd(g,s,l)
#define HB_GTSELF_OUTERR(g,s,l)                 (g)->pFuncTable->OutErr(g,s,l)
#define HB_GTSELF_TONE(g,f,d)                   (g)->pFuncTable->Tone(g,f,d)
#define HB_GTSELF_BELL(g)                       (g)->pFuncTable->Bell(g)
#define HB_GTSELF_INFO(g,i,p)                   (g)->pFuncTable->Info(g,i,p)
#define HB_GTSELF_ALERT(g,m,o,n,h,d)            (g)->pFuncTable->Alert(g,m,o,n,h,d)
#define HB_GTSELF_SETFLAG(g,i,f)                (g)->pFuncTable->SetFlag(g,i,f)
#define HB_GTSELF_SETDISPCP(g,t,h,b)            (g)->pFuncTable->SetDispCP(g,t,h,b)
#define HB_GTSELF_SETKEYCP(g,t,h)               (g)->pFuncTable->SetKeyCP(g,t,h)
#define HB_GTSELF_READKEY(g,m)                  (g)->pFuncTable->ReadKey(g,m)
#define HB_GTSELF_INKEYGET(g,w,d,m)             (g)->pFuncTable->InkeyGet(g,w,d,m)
#define HB_GTSELF_INKEYPUT(g,k)                 (g)->pFuncTable->InkeyPut(g,k)
#define HB_GTSELF_INKEYINS(g,k)                 (g)->pFuncTable->InkeyIns(g,k)
#define HB_GTSELF_INKEYLAST(g,m)                (g)->pFuncTable->InkeyLast(g,m)
#define HB_GTSELF_INKEYNEXT(g,m)                (g)->pFuncTable->InkeyNext(g,m)
#define HB_GTSELF_INKEYPOLL(g)                  (g)->pFuncTable->InkeyPoll(g)
#define HB_GTSELF_INKEYSETTEXT(g,s,l)           (g)->pFuncTable->InkeySetText(g,s,l)
#define HB_GTSELF_INKEYSETLAST(g,k)             (g)->pFuncTable->InkeySetLast(g,k)
#define HB_GTSELF_INKEYRESET(g)                 (g)->pFuncTable->InkeyReset(g)
#define HB_GTSELF_INKEYEXIT(g)                  (g)->pFuncTable->InkeyExit(g)
#define HB_GTSELF_MOUSEINIT(g)                  (g)->pFuncTable->MouseInit(g)
#define HB_GTSELF_MOUSEEXIT(g)                  (g)->pFuncTable->MouseExit(g)
#define HB_GTSELF_MOUSEISPRESENT(g)             (g)->pFuncTable->MouseIsPresent(g)
#define HB_GTSELF_MOUSESHOW(g)                  (g)->pFuncTable->MouseShow(g)
#define HB_GTSELF_MOUSEHIDE(g)                  (g)->pFuncTable->MouseHide(g)
#define HB_GTSELF_MOUSEGETCURSOR(g)             (g)->pFuncTable->MouseGetCursor(g)
#define HB_GTSELF_MOUSESETCURSOR(g,v)           (g)->pFuncTable->MouseSetCursor(g,v)
#define HB_GTSELF_MOUSECOL(g)                   (g)->pFuncTable->MouseCol(g)
#define HB_GTSELF_MOUSEROW(g)                   (g)->pFuncTable->MouseRow(g)
#define HB_GTSELF_MOUSEGETPOS(g,pr,pc)          (g)->pFuncTable->MouseGetPos(g,pr,pc)
#define HB_GTSELF_MOUSESETPOS(g,r,c)            (g)->pFuncTable->MouseSetPos(g,r,c)
#define HB_GTSELF_MOUSESETBOUNDS(g,t,l,b,r)     (g)->pFuncTable->MouseSetBounds(g,t,l,b,r)
#define HB_GTSELF_MOUSEGETBOUNDS(g,t,l,b,r)     (g)->pFuncTable->MouseGetBounds(g,t,l,b,r)
#define HB_GTSELF_MOUSESTORAGESIZE(g)           (g)->pFuncTable->MouseStorageSize(g)
#define HB_GTSELF_MOUSESAVESTATE(g,p)           (g)->pFuncTable->MouseSaveState(g,p)
#define HB_GTSELF_MOUSERESTORESTATE(g,p)        (g)->pFuncTable->MouseRestoreState(g,p)
#define HB_GTSELF_MOUSEGETDOUBLECLICKSPEED(g)   (g)->pFuncTable->MouseGetDoubleClickSpeed(g)
#define HB_GTSELF_MOUSESETDOUBLECLICKSPEED(g,i) (g)->pFuncTable->MouseSetDoubleClickSpeed(g,i)
#define HB_GTSELF_MOUSECOUNTBUTTON(g)           (g)->pFuncTable->MouseCountButton(g)
#define HB_GTSELF_MOUSEBUTTONSTATE(g,b)         (g)->pFuncTable->MouseButtonState(g,b)
#define HB_GTSELF_MOUSEBUTTONPRESSED(g,b,r,c)   (g)->pFuncTable->MouseButtonPressed(g,b,r,c)
#define HB_GTSELF_MOUSEBUTTONRELEASED(g,b,r,c)  (g)->pFuncTable->MouseButtonReleased(g,b,r,c)
#define HB_GTSELF_MOUSEREADKEY(g,m)             (g)->pFuncTable->MouseReadKey(g,m)
#define HB_GTSELF_GFXPRIMITIVE(g,i,t,l,b,r,c)   (g)->pFuncTable->GfxPrimitive(g,i,t,l,b,r,c)
#define HB_GTSELF_GFXTEXT(g,t,l,s,c,h,w)        (g)->pFuncTable->GfxText(g,t,l,s,c,h,w)
#define HB_GTSELF_WHOCARES(g,p)                 (g)->pFuncTable->WhoCares(g,p)

#define HB_GTSUPER_INIT(g,i,o,e)                 (HB_GTSUPER)->Init(g,i,o,e)
#define HB_GTSUPER_EXIT(g)                       (HB_GTSUPER)->Exit(g)
#define HB_GTSUPER_NEW(g)                        (HB_GTSUPER)->New(g)
#define HB_GTSUPER_FREE(g)                       (HB_GTSUPER)->Free(g)
#define HB_GTSUPER_RESIZE(g,r,c)                 (HB_GTSUPER)->Resize(g,r,c)
#define HB_GTSUPER_SETMODE(g,r,c)                (HB_GTSUPER)->SetMode(g,r,c)
#define HB_GTSUPER_GETSIZE(g,pr,pc)              (HB_GTSUPER)->GetSize(g,pr,pc)
#define HB_GTSUPER_SEMICOLD(g)                   (HB_GTSUPER)->SemiCold(g)
#define HB_GTSUPER_COLDAREA(g,t,l,b,r)           (HB_GTSUPER)->ColdArea(g,t,l,b,r)
#define HB_GTSUPER_EXPOSEAREA(g,t,l,b,r)         (HB_GTSUPER)->ExposeArea(g,t,l,b,r)
#define HB_GTSUPER_SCROLLAREA(g,t,l,b,r,m,u,v,h) (HB_GTSUPER)->ScrollArea(g,t,l,b,r,m,u,v,h)
#define HB_GTSUPER_TOUCHCELL(g,r,c)              (HB_GTSUPER)->TouchCell(g,r,c)
#define HB_GTSUPER_REDRAW(g,r,c,l)               (HB_GTSUPER)->Redraw(g,r,c,l)
#define HB_GTSUPER_REFRESH(g)                    (HB_GTSUPER)->Refresh(g)
#define HB_GTSUPER_FLUSH(g)                      (HB_GTSUPER)->Flush(g)
#define HB_GTSUPER_MAXCOL(g)                     (HB_GTSUPER)->MaxCol(g)
#define HB_GTSUPER_MAXROW(g)                     (HB_GTSUPER)->MaxRow(g)
#define HB_GTSUPER_CHECKPOS(g,r,c,l)             (HB_GTSUPER)->CheckPos(g,r,c,l)
#define HB_GTSUPER_SETPOS(g,r,c)                 (HB_GTSUPER)->SetPos(g,r,c)
#define HB_GTSUPER_GETPOS(g,pr,pc)               (HB_GTSUPER)->GetPos(g,pr,pc)
#define HB_GTSUPER_ISCOLOR(g)                    (HB_GTSUPER)->IsColor(g)
#define HB_GTSUPER_GETCOLORSTR(g,s)              (HB_GTSUPER)->GetColorStr(g,s)
#define HB_GTSUPER_SETCOLORSTR(g,s)              (HB_GTSUPER)->SetColorStr(g,s)
#define HB_GTSUPER_COLORSELECT(g,c)              (HB_GTSUPER)->ColorSelect(g,c)
#define HB_GTSUPER_GETCOLOR(g)                   (HB_GTSUPER)->GetColor(g)
#define HB_GTSUPER_COLORNUM(g,s)                 (HB_GTSUPER)->ColorNum(g,s)
#define HB_GTSUPER_COLORSTOSTRING(g,pc,i,ps,n)   (HB_GTSUPER)->ColorsToString(g,pc,i,ps,n)
#define HB_GTSUPER_STRINGTOCOLORS(g,ps,pc,pi)    (HB_GTSUPER)->StringToColors(g,ps,pc,pi)
#define HB_GTSUPER_GETCOLORDATA(g,pc,pn,pi)      (HB_GTSUPER)->GetColorData(g,pc,pn,pi)
#define HB_GTSUPER_GETCLEARCOLOR(g)              (HB_GTSUPER)->GetClearColor(g)
#define HB_GTSUPER_SETCLEARCOLOR(g,c)            (HB_GTSUPER)->SetClearColor(g,c)
#define HB_GTSUPER_GETCLEARCHAR(g)               (HB_GTSUPER)->GetClearChar(g)
#define HB_GTSUPER_SETCLEARCHAR(g,c)             (HB_GTSUPER)->SetClearChar(g,c)
#define HB_GTSUPER_GETCURSORSTYLE(g)             (HB_GTSUPER)->GetCursorStyle(g)
#define HB_GTSUPER_SETCURSORSTYLE(g,s)           (HB_GTSUPER)->SetCursorStyle(g,s)
#define HB_GTSUPER_GETSCRCURSOR(g,pr,pc,ps)      (HB_GTSUPER)->GetScrCursor(g,pr,pc,ps)
#define HB_GTSUPER_GETSCRCHAR(g,r,c,pm,pa,pc)    (HB_GTSUPER)->GetScrChar(g,r,c,pm,pa,pc)
#define HB_GTSUPER_PUTSCRCHAR(g,r,c,m,a,u)       (HB_GTSUPER)->PutScrChar(g,r,c,m,a,u)
#define HB_GTSUPER_DISPBEGIN(g)                  (HB_GTSUPER)->DispBegin(g)
#define HB_GTSUPER_DISPEND(g)                    (HB_GTSUPER)->DispEnd(g)
#define HB_GTSUPER_DISPCOUNT(g)                  (HB_GTSUPER)->DispCount(g)
#define HB_GTSUPER_GETCHAR(g,r,c,pm,pa,pc)       (HB_GTSUPER)->GetChar(g,r,c,pm,pa,pc)
#define HB_GTSUPER_PUTCHAR(g,r,c,m,a,u)          (HB_GTSUPER)->PutChar(g,r,c,m,a,u)
#define HB_GTSUPER_RECTSIZE(g,t,l,b,r)           (HB_GTSUPER)->RectSize(g,t,l,b,r)
#define HB_GTSUPER_SAVE(g,t,l,b,r,p)             (HB_GTSUPER)->Save(g,t,l,b,r,p)
#define HB_GTSUPER_REST(g,t,l,b,r,p)             (HB_GTSUPER)->Rest(g,t,l,b,r,p)
#define HB_GTSUPER_PUTTEXT(g,r,c,m,s,l)          (HB_GTSUPER)->PutText(g,r,c,m,s,l)
#define HB_GTSUPER_REPLICATE(g,r,c,m,a,u,l)      (HB_GTSUPER)->Replicate(g,r,c,m,a,u,l)
#define HB_GTSUPER_WRITEAT(g,r,c,s,l)            (HB_GTSUPER)->WriteAt(g,r,c,s,l)
#define HB_GTSUPER_WRITE(g,s,l)                  (HB_GTSUPER)->Write(g,s,l)
#define HB_GTSUPER_WRITECON(g,s,l)               (HB_GTSUPER)->WriteCon(g,s,l)
#define HB_GTSUPER_SETATTRIBUTE(g,t,l,b,r,m)     (HB_GTSUPER)->SetAttribute(g,t,l,b,r,m)
#define HB_GTSUPER_DRAWSHADOW(g,t,l,b,r,m)       (HB_GTSUPER)->DrawShadow(g,t,l,b,r,m)
#define HB_GTSUPER_SCROLL(g,t,l,b,r,m,u,v,h)     (HB_GTSUPER)->Scroll(g,t,l,b,r,m,u,v,h)
#define HB_GTSUPER_SCROLLUP(g,r,m,u)             (HB_GTSUPER)->ScrollUp(g,r,m,u)
#define HB_GTSUPER_BOX(g,t,l,b,r,f,m)            (HB_GTSUPER)->Box(g,t,l,b,r,f,m)
#define HB_GTSUPER_BOXD(g,t,l,b,r,f,m)           (HB_GTSUPER)->BoxD(g,t,l,b,r,f,m)
#define HB_GTSUPER_BOXS(g,t,l,b,r,f,m)           (HB_GTSUPER)->BoxS(g,t,l,b,r,f,m)
#define HB_GTSUPER_HORIZLINE(g,h,l,r,u,m)        (HB_GTSUPER)->HorizLine(g,h,l,r,u,m)
#define HB_GTSUPER_VERTLINE(g,c,t,b,u,m)         (HB_GTSUPER)->VertLine(g,c,t,b,u,m)
#define HB_GTSUPER_GETBLINK(g)                   (HB_GTSUPER)->GetBlink(g)
#define HB_GTSUPER_SETBLINK(g,b)                 (HB_GTSUPER)->SetBlink(g,b)
#define HB_GTSUPER_SETSNOWFLAG(g,b)              (HB_GTSUPER)->SetSnowFlag(g,b)
#define HB_GTSUPER_VERSION(g,i)                  (HB_GTSUPER)->Version(g,i)
#define HB_GTSUPER_SUSPEND(g)                    (HB_GTSUPER)->Suspend(g)
#define HB_GTSUPER_RESUME(g)                     (HB_GTSUPER)->Resume(g)
#define HB_GTSUPER_PREEXT(g)                     (HB_GTSUPER)->PreExt(g)
#define HB_GTSUPER_POSTEXT(g)                    (HB_GTSUPER)->PostExt(g)
#define HB_GTSUPER_OUTSTD(g,s,l)                 (HB_GTSUPER)->OutStd(g,s,l)
#define HB_GTSUPER_OUTERR(g,s,l)                 (HB_GTSUPER)->OutErr(g,s,l)
#define HB_GTSUPER_TONE(g,f,d)                   (HB_GTSUPER)->Tone(g,f,d)
#define HB_GTSUPER_BELL(g)                       (HB_GTSUPER)->Bell(g)
#define HB_GTSUPER_INFO(g,i,p)                   (HB_GTSUPER)->Info(g,i,p)
#define HB_GTSUPER_ALERT(g,m,o,n,h,d)            (HB_GTSUPER)->Alert(g,m,o,n,h,d)
#define HB_GTSUPER_SETFLAG(g,i,f)                (HB_GTSUPER)->SetFlag(g,i,f)
#define HB_GTSUPER_SETDISPCP(g,t,h,b)            (HB_GTSUPER)->SetDispCP(g,t,h,b)
#define HB_GTSUPER_SETKEYCP(g,t,h)               (HB_GTSUPER)->SetKeyCP(g,t,h)
#define HB_GTSUPER_READKEY(g,m)                  (HB_GTSUPER)->ReadKey(g,m)
#define HB_GTSUPER_INKEYGET(g,w,d,m)             (HB_GTSUPER)->InkeyGet(g,w,d,m)
#define HB_GTSUPER_INKEYPUT(g,k)                 (HB_GTSUPER)->InkeyPut(g,k)
#define HB_GTSUPER_INKEYINS(g,k)                 (HB_GTSUPER)->InkeyIns(g,k)
#define HB_GTSUPER_INKEYLAST(g,m)                (HB_GTSUPER)->InkeyLast(g,m)
#define HB_GTSUPER_INKEYNEXT(g,m)                (HB_GTSUPER)->InkeyNext(g,m)
#define HB_GTSUPER_INKEYPOLL(g)                  (HB_GTSUPER)->InkeyPoll(g)
#define HB_GTSUPER_INKEYSETTEXT(g,s,l)           (HB_GTSUPER)->InkeySetText(g,s,l)
#define HB_GTSUPER_INKEYSETLAST(g,k)             (HB_GTSUPER)->InkeySetLast(g,k)
#define HB_GTSUPER_INKEYRESET(g)                 (HB_GTSUPER)->InkeyReset(g)
#define HB_GTSUPER_INKEYEXIT(g)                  (HB_GTSUPER)->InkeyExit(g)
#define HB_GTSUPER_MOUSEINIT(g)                  (HB_GTSUPER)->MouseInit(g)
#define HB_GTSUPER_MOUSEEXIT(g)                  (HB_GTSUPER)->MouseExit(g)
#define HB_GTSUPER_MOUSEISPRESENT(g)             (HB_GTSUPER)->MouseIsPresent(g)
#define HB_GTSUPER_MOUSESHOW(g)                  (HB_GTSUPER)->MouseShow(g)
#define HB_GTSUPER_MOUSEHIDE(g)                  (HB_GTSUPER)->MouseHide(g)
#define HB_GTSUPER_MOUSEGETCURSOR(g)             (HB_GTSUPER)->MouseGetCursor(g)
#define HB_GTSUPER_MOUSESETCURSOR(g,v)           (HB_GTSUPER)->MouseSetCursor(g,v)
#define HB_GTSUPER_MOUSECOL(g)                   (HB_GTSUPER)->MouseCol(g)
#define HB_GTSUPER_MOUSEROW(g)                   (HB_GTSUPER)->MouseRow(g)
#define HB_GTSUPER_MOUSEGETPOS(g,pr,pc)          (HB_GTSUPER)->MouseGetPos(g,pr,pc)
#define HB_GTSUPER_MOUSESETPOS(g,r,c)            (HB_GTSUPER)->MouseSetPos(g,r,c)
#define HB_GTSUPER_MOUSESETBOUNDS(g,t,l,b,r)     (HB_GTSUPER)->MouseSetBounds(g,t,l,b,r)
#define HB_GTSUPER_MOUSEGETBOUNDS(g,t,l,b,r)     (HB_GTSUPER)->MouseGetBounds(g,t,l,b,r)
#define HB_GTSUPER_MOUSESTORAGESIZE(g)           (HB_GTSUPER)->MouseStorageSize(g)
#define HB_GTSUPER_MOUSESAVESTATE(g,p)           (HB_GTSUPER)->MouseSaveState(g,p)
#define HB_GTSUPER_MOUSERESTORESTATE(g,p)        (HB_GTSUPER)->MouseRestoreState(g,p)
#define HB_GTSUPER_MOUSEGETDOUBLECLICKSPEED(g)   (HB_GTSUPER)->MouseGetDoubleClickSpeed(g)
#define HB_GTSUPER_MOUSESETDOUBLECLICKSPEED(g,i) (HB_GTSUPER)->MouseSetDoubleClickSpeed(g,i)
#define HB_GTSUPER_MOUSECOUNTBUTTON(g)           (HB_GTSUPER)->MouseCountButton(g)
#define HB_GTSUPER_MOUSEBUTTONSTATE(g,b)         (HB_GTSUPER)->MouseButtonState(g,b)
#define HB_GTSUPER_MOUSEBUTTONPRESSED(g,b,r,c)   (HB_GTSUPER)->MouseButtonPressed(g,b,r,c)
#define HB_GTSUPER_MOUSEBUTTONRELEASED(g,b,r,c)  (HB_GTSUPER)->MouseButtonReleased(g,b,r,c)
#define HB_GTSUPER_MOUSEREADKEY(g,m)             (HB_GTSUPER)->MouseReadKey(g,m)
#define HB_GTSUPER_GFXPRIMITIVE(g,i,t,l,b,r,c)   (HB_GTSUPER)->GfxPrimitive(g,i,t,l,b,r,c)
#define HB_GTSUPER_GFXTEXT(g,t,l,s,c,h,w)        (HB_GTSUPER)->GfxText(g,t,l,s,c,h,w)
#define HB_GTSUPER_WHOCARES(g,p)                 (HB_GTSUPER)->WhoCares(g,p)

extern HB_EXPORT void hb_gtSetDefault( const char * szGtName );
extern HB_EXPORT BOOL hb_gtRegister( const HB_GT_INIT * gtInit );
extern HB_EXPORT BOOL hb_gtLoad( const char * szGtName, PHB_GT_FUNCS pFuncTable );
extern HB_EXPORT BOOL hb_gtUnLoad( void );
extern HB_EXPORT void hb_gtStartupInit( void );


/* low level GT functions common to different GTs supported by RTL */
extern int  hb_gt_chrmapinit( int *piTransTbl, const char *pszTerm, BOOL fSetACSC );
extern BOOL hb_gt_setClipboard( char * szClipData, ULONG ulLen );
extern BOOL hb_gt_getClipboard( char ** pszClipData, ULONG *pulLen );
#if defined( HB_OS_WIN_32 )
extern BOOL hb_gt_w32_setClipboard( UINT uFormat, char * szClipData, ULONG ulLen );
extern BOOL hb_gt_w32_getClipboard( UINT uFormat, char ** pszClipData, ULONG *pulLen );
extern int  hb_gt_w32_getKbdState( void );
extern void hb_gt_w32_setKbdState( int kbdShifts );
extern void hb_gt_w32_tone( double dFrequency, double dDuration );
#endif /* HB_OS_WIN_32 */
#if defined( HB_OS_DOS ) || defined( HB_OS_WIN_32 ) || defined( HB_OS_OS2 )
int hb_gt_dos_keyCodeTranslate( int iKey );
#endif /* HB_OS_DOS || HB_OS_WIN_32 || HB_OS_OS2 */

HB_EXTERN_END

#endif /* HB_GTCORE_H_ */
c:\harbour\include\hbhash.h
/*
 * $Id: hbhash.h 6550 2005-11-14 09:47:46Z rglab $
 */

/*
 * Harbour Project source code:
 * Harbour common hash table implementation
 *
 * Copyright 1999 Ryszard Glab 
 * 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.
 *
 */

#ifndef HB_HASH_H_
#define HB_HASH_H_

#include "hbapi.h"

HB_EXTERN_BEGIN

struct HB_HASH_TABLE_;

#define HB_HASH_FUNC( hbfunc )   ULONG hbfunc( struct HB_HASH_TABLE_ *HashPtr, void *Value, void *Cargo )
typedef HB_HASH_FUNC( HB_HASH_FUNC_ );
typedef HB_HASH_FUNC_ *HB_HASH_FUNC_PTR;

typedef struct HB_HASH_ITEM_
{
   void *ValPtr;        /* value stored in the hash table */
   void *KeyPtr;
   ULONG key;
   struct HB_HASH_ITEM_ *next;
} HB_HASH_ITEM, *HB_HASH_ITEM_PTR;

typedef struct HB_HASH_TABLE_
{
   HB_HASH_ITEM_PTR *pItems;    /* pointer to items */
   ULONG ulTableSize;           /* the table size - number of slots */
   ULONG ulCount;               /* number of items stored in the table */
   ULONG ulUsed;                /* number of used slots */
   HB_HASH_FUNC_PTR pKeyFunc;   /* pointer to func that returns key value */
   HB_HASH_FUNC_PTR pDeleteItemFunc; /* ptr to func that deletes value stured in the table */
   HB_HASH_FUNC_PTR pCompFunc;       /* ptr to func that compares two itmes */
} HB_HASH_TABLE, *HB_HASH_TABLE_PTR;


extern HB_HASH_TABLE_PTR hb_hashTableCreate( ULONG ulSize, 
                                   HB_HASH_FUNC_PTR pHashFunc, 
                                   HB_HASH_FUNC_PTR pDelete,
                                   HB_HASH_FUNC_PTR pComp );
extern void hb_hashTableKill( HB_HASH_TABLE_PTR pTable ); /* release all items and the hash table */
extern BOOL hb_hashTableAdd( HB_HASH_TABLE_PTR pTable, void *pKey, void *pValue ); /* add a new item into the table */
extern void * hb_hashTableFind( HB_HASH_TABLE_PTR pTable, void *pKey ); /* return the pointer to item's value or NULL if not found */
extern HB_HASH_TABLE_PTR hb_hashTableResize( HB_HASH_TABLE_PTR pTable, ULONG ulNewSize ); /* resize the hash table */

HB_EXTERN_END

#endif /* HB_HASH_H_ */
c:\harbour\include\hbinit.h
/*
 * $Id: hbinit.h 9374 2008-09-13 16:53:45Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for automatic static initialization
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

#ifndef HB_INIT_H_
#define HB_INIT_H_

#include "hbsetup.h"

HB_EXTERN_BEGIN

extern HB_EXPORT PHB_SYMB hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols ); /* old module symbols initialization */
extern HB_EXPORT PHB_SYMB hb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiSymbols, const char * szModuleName, ULONG ulID, USHORT uiPcodeVer ); /* module symbols initialization with extended information */

#if defined(_MSC_VER) && \
    !defined(__LCC__) && !defined(__POCC__) && !defined(__XCC__) && \
    !defined(HB_STRICT_ANSI_C) && !defined(HB_STATIC_STARTUP) && \
    !defined(HB_PRAGMA_STARTUP) && !defined(HB_MSC_STARTUP)

   /* In order to maintain compatibility with other products, MSVC should
      always use this startup.  If you know that you can use HB_STATIC_STARTUP
      below, then all you need to do is define HB_STATIC_STARTUP to the
      compiler.

      Sat 07 Maj 2005 02:46:38 CEST
      This is only necessary when you want to create binary libs using
      MSC in C++ mode (-TP switch) and later this binaries will be linked
      by standard C linker with [x]Harbour programs. I strongly suggest
      to for 3-rd party developers to use MSC in standard C mode to create
      libraries which can be used with standard C compilers. This will
      eliminate the problem and we will be able to set C++ initialization
      as default for MSC in C++ mode. Druzus.
   */

   #define HB_MSC_STARTUP

#endif

#define HB_INIT_SYMBOLS_END( func ) HB_INIT_SYMBOLS_EX_END( func, __FILE__, 0L, 0x0000 )

#if defined(HB_STRICT_ANSI_C)

   #define HB_INIT_SYMBOLS_BEGIN( func ) \
      static HB_SYMB symbols_table[] = {

   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
      }; \
      static PHB_SYMB symbols = symbols_table; \
      void func( void ) \
      { \
         symbols = hb_vmProcessSymbolsEx( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
      }

   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
      func( void ) \
      {

   #define HB_CALL_ON_STARTUP_END( func ) \
      }

#elif defined(__GNUC__)

   #if defined(HB_PRAGMA_STARTUP) || defined(HB_MSC_STARTUP)
      #error Wrong macros set for startup code - clean your make/env settings.
   #endif

   #define HB_INIT_SYMBOLS_BEGIN( func ) \
      static HB_SYMB symbols_table[] = {

   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
      }; \
      static PHB_SYMB symbols = symbols_table; \
      static void __attribute__ ((constructor)) func( void ) \
      { \
         symbols = hb_vmProcessSymbolsEx( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
      }

   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
      static void __attribute__ ((constructor)) func( void ) \
      {

   #define HB_CALL_ON_STARTUP_END( func ) \
      }

#elif defined(HB_MSC_STARTUP)

   typedef int (* HB_$INITSYM)( void );

   #if _MSC_VER >= 1010
      #define HB_MSC_START_SEGMENT ".CRT$XIY"
   #else
      #define HB_MSC_START_SEGMENT "XIY"
   #endif

   #define HB_INIT_SYMBOLS_BEGIN( func ) \
      static HB_SYMB symbols_table[] = {

   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
      }; \
      static PHB_SYMB symbols = symbols_table; \
      static int func( void ) \
      { \
         symbols = hb_vmProcessSymbolsEx( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
         return 0; \
      }

   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
      static int func( void ) \
      {

   #define HB_CALL_ON_STARTUP_END( func ) \
         return 0; \
      }

   /*  After each '_END' symbol, additional 'hooks' are required See the C
       output of a generated prg for example
   */

#elif defined(HB_STATIC_STARTUP) || defined(__cplusplus)

   #if defined(HB_PRAGMA_STARTUP) || defined(HB_MSC_STARTUP)
      #error Wrong macros set for startup code - clean your make/env settings.
   #endif

   #define HB_INIT_SYMBOLS_BEGIN( func ) \
      static HB_SYMB symbols_table[] = {

   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
      }; \
      static PHB_SYMB symbols = hb_vmProcessSymbolsEx( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \

   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
      static int func( void ) \
      {

   /* this allows any macros to be preprocessed first
      so that token pasting is handled correctly */
   #define HB_CALL_ON_STARTUP_END( func ) \
          _HB_CALL_ON_STARTUP_END( func )

   #define _HB_CALL_ON_STARTUP_END( func ) \
         return 0; \
      } \
      static int static_int_##func = func();

#elif defined(HB_PRAGMA_STARTUP) || \
      defined(__BORLANDC__) || defined(__LCC__) || defined(__POCC__) || defined(__XCC__)

   #if defined(HB_MSC_STARTUP)
      #error Wrong macros set for startup code - clean your make/env settings.
   #endif

   #if !defined(HB_PRAGMA_STARTUP)
      #define HB_PRAGMA_STARTUP
   #endif

   #define HB_INIT_SYMBOLS_BEGIN( func ) \
      static HB_SYMB symbols_table[] = {

   #define HB_INIT_SYMBOLS_EX_END( func, module, id, vpcode ) \
      }; \
      static PHB_SYMB symbols = symbols_table; \
      static void func( void ) \
      { \
         symbols = hb_vmProcessSymbolsEx( symbols_table, (USHORT) ( sizeof( symbols_table ) / sizeof( HB_SYMB ) ), (module), (id), (vpcode) ); \
      }

   #define HB_CALL_ON_STARTUP_BEGIN( func ) \
      static void func( void ) \
      {

   #define HB_CALL_ON_STARTUP_END( func ) \
      }

#else
   #error Unknown initialization method.
#endif

HB_EXTERN_END

#endif /* HB_INIT_H_ */
c:\harbour\include\hbmacro.h
/*
 * $Id: hbmacro.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Macro compiler
 *
 * Copyright 1999 Ryszard Glab
 * 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.
 *
 */

#ifndef HB_MACRO_H_
#define HB_MACRO_H_

#include 
#include 
#include 
#include 
#include 
#include 

#include "hbcompdf.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbvm.h"
#include "hbexprop.h"
#include "hbpcode.h"
#include "hbmacro.ch"

HB_EXTERN_BEGIN

/* flags for compilation process
 */
#define HB_MACRO_GEN_PUSH     1   /* generate PUSH pcodes */
#define HB_MACRO_GEN_POP      2   /* generate POP pcodes */
#define HB_MACRO_GEN_ALIASED  4   /* force aliased variable */
#define HB_MACRO_GEN_TYPE     8   /* check the type of expression (from TYPE() function) */
#define HB_MACRO_GEN_PARE     16  /* generate parentesized list */
#define HB_MACRO_GEN_LIST     32  /* generate push operation for every comma separated expressions */
#define HB_MACRO_DEALLOCATE   128 /* macro structure is allocated on the heap */

/* values returned from compilation process
 */
#define HB_MACRO_OK           0   /* macro compiled successfully */
#define HB_MACRO_FAILURE      1   /* syntax error */

/* additional status of compilation
 */
#define HB_MACRO_CONT         1   /* everything is OK so far */
#define HB_MACRO_TOO_COMPLEX  2   /* compiled expression is too complex */
#define HB_MACRO_UDF          4   /* code uses UDF function (info used by TYPE function) */
#define HB_MACRO_UNKN_SYM     8   /* requested symbol was not found in runtime symbol table */
#define HB_MACRO_UNKN_VAR     16  /* requested variable doesn't exist */

/* Global functions
 */
extern void hb_macroError( int iError, HB_COMP_DECL );
extern int hb_macroYYParse( HB_MACRO_PTR pMacro );
extern ULONG hb_macroSetMacro( BOOL bSet, ULONG ulFlag );
extern ULONG hb_macroAutoSetMacro( ULONG ulFlag );
extern BOOL hb_macroLexNew( HB_MACRO_PTR pMacro );
extern void hb_macroLexDelete( HB_MACRO_PTR pMacro );

extern HB_EXPR_PTR hb_macroExprGenPush( HB_EXPR_PTR, HB_COMP_DECL );
extern HB_EXPR_PTR hb_macroExprGenPop( HB_EXPR_PTR, HB_COMP_DECL );

extern HB_EXPR_PTR hb_macroExprNewArrayAt( HB_EXPR_PTR pArray, HB_EXPR_PTR pIndex, HB_COMP_DECL );
extern HB_EXPR_PTR hb_macroExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COMP_DECL );
extern HB_EXPR_PTR hb_macroExprNewSend( HB_EXPR_PTR pObject, const char * szMessage, HB_EXPR_PTR pMessage, HB_COMP_DECL );

/* Size of pcode buffer incrementation
 */
#define HB_PCODE_SIZE  512

/* Declarations for functions macro.c */
#if defined( HB_MACRO_SUPPORT )

extern void hb_macroGenPCode1( BYTE byte, HB_COMP_DECL );
extern void hb_macroGenPCode2( BYTE byte1, BYTE byte2, HB_COMP_DECL );
extern void hb_macroGenPCode3( BYTE byte1, BYTE byte2, BYTE byte3, HB_COMP_DECL );
extern void hb_macroGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_DECL );
extern void hb_macroGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL );

extern ULONG hb_macroGenJump( LONG lOffset, HB_COMP_DECL );
extern ULONG hb_macroGenJumpFalse( LONG lOffset, HB_COMP_DECL );
extern void hb_macroGenJumpThere( ULONG ulFrom, ULONG ulTo, HB_COMP_DECL );
extern void hb_macroGenJumpHere( ULONG ulOffset, HB_COMP_DECL );
extern ULONG hb_macroGenJumpTrue( LONG lOffset, HB_COMP_DECL );

extern void hb_macroGenPushSymbol( const char * szSymbolName, BOOL bFunction, HB_COMP_DECL );
extern void hb_macroGenPushLong( HB_LONG lNumber, HB_COMP_DECL );
extern void hb_macroGenPushDate( HB_LONG lNumber, HB_COMP_DECL );
extern void hb_macroGenMessage( const char * szMsgName, BOOL bIsObject, HB_COMP_DECL );
extern void hb_macroGenMessageData( const char * szMsg, BOOL bIsObject, HB_COMP_DECL );
extern void hb_macroGenPopVar( const char * szVarName, HB_COMP_DECL );
extern void hb_macroGenPopMemvar( const char * szVarName, HB_COMP_DECL );
extern void hb_macroGenPopAliasedVar( const char * szVarName,
                                      BOOL bPushAliasValue,
                                      const char * szAlias,
                                      HB_LONG lWorkarea, HB_COMP_DECL );
extern void hb_macroGenPushVar( const char * szVarName, BOOL bMacroVar, HB_COMP_DECL );
extern void hb_macroGenPushVarRef( const char * szVarName, HB_COMP_DECL );
extern void hb_macroGenPushMemvarRef( const char * szVarName, HB_COMP_DECL );
extern void hb_macroGenPushAliasedVar( const char * szVarName,
                                       BOOL bPushAliasValue,
                                       const char * szAlias,
                                       HB_LONG lWorkarea, HB_COMP_DECL );
extern void hb_macroGenPushLogical( int iTrueFalse, HB_COMP_DECL );
extern void hb_macroGenPushDouble( double dNumber, BYTE bWidth, BYTE bDec, HB_COMP_DECL );
extern void hb_macroGenPushFunCall( const char * szFunName, HB_COMP_DECL );
extern void hb_macroGenPushFunSym( const char * szFunName, HB_COMP_DECL );
extern void hb_macroGenPushFunRef( const char * szFunName, HB_COMP_DECL );
extern void hb_macroGenPushString( const char * szText, ULONG ulStrLen, HB_COMP_DECL );

extern void hb_macroCodeBlockStart( HB_COMP_DECL );
extern void hb_macroCodeBlockEnd( HB_COMP_DECL );

extern BOOL hb_macroIsValidMacroText( const char *, ULONG );

#endif /* HB_MACRO_SUPPORT */

HB_EXTERN_END

#endif /* HB_MACRO_H_ */
c:\harbour\include\hbmath.h
/*
 * $Id: hbmath.h 9203 2008-08-21 09:12:17Z vszakats $
 */

/*
 * Harbour Project source code:
 * Harbour math functions and API
 *
 * Copyright 2001 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany
 *        Author: Martin Vogel 
 * 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.
 *
 */

#ifndef HB_MATH_H_
#define HB_MATH_H_

#include "hbapi.h"

#if defined(__DJGPP__)
#include 
#else
#include 
#endif

HB_EXTERN_BEGIN

#if defined(__WATCOMC__)
   #define HB_MATH_HANDLER
   #if (__WATCOMC__ > 1000) /* && defined(__cplusplus) */
      #define exception _exception
   #endif
#elif defined(__BORLANDC__)
   #if (__BORLANDC__ == 1328) && defined(__cplusplus)
      /* NOTE: There seem to be a bug in Borland C++ 5.3 C++ mode which prevents
               the redefinition of matherr, because nor "_exception" neither
               "exception" will work. [vszakats] */
   #else
      #define HB_MATH_HANDLER
      #define matherr _matherr
      /* NOTE: This is needed for Borland C++ 5.5 in C++/STDC mode. [vszakats] */
      #if (__BORLANDC__ >= 1360)
         #define exception _exception
      #endif
   #endif
#elif defined(__MINGW32CE__)
   #define HB_MATH_HANDLER
   #define matherr _matherr
   #define exception _exception
/* it seems that MinGW has some problem with MATH HANDLER
   use HB_MATH_ERRNO instead */
#elif defined(__MINGW32__) && 0
   #define HB_MATH_HANDLER
   #define matherr _matherr
   #define exception _exception
#elif defined(__DJGPP__)
   #define HB_MATH_HANDLER
#endif

#if !defined(HB_MATH_HANDLER) && defined(__GNUC__) /* && defined(HB_OS_UNIX) */
   #define HB_MATH_ERRNO
#endif

typedef struct _HB_MATH_EXCEPTION
{
   int            type;
   const char *   funcname;
   const char *   error;
   double         arg1;
   double         arg2;
   double         retval;
   int            retvalwidth;
   int            retvaldec;
   int            handled;
} HB_MATH_EXCEPTION;

typedef int ( * HB_MATH_HANDLERPROC )( HB_MATH_EXCEPTION * err );

extern HB_EXPORT void hb_mathResetError( HB_MATH_EXCEPTION * phb_exc );
extern HB_EXPORT BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *szFunc, double arg1, double arg2, double dResult );

extern HB_EXPORT int hb_mathSetErrMode( int imode );
extern HB_EXPORT int hb_mathGetErrMode( void );
extern HB_EXPORT int hb_matherr( HB_MATH_EXCEPTION * pexc );

extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathSetHandler( HB_MATH_HANDLERPROC handlerproc );
extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathGetHandler( void );

extern HB_EXPORT double hb_random_num( void );

/* include defines from hbmath.ch */
#include "hbmath.ch"

HB_EXTERN_END

#endif /* HB_MATH_H_ */
c:\harbour\include\hbpcode.h
/*
 * $Id: hbpcode.h 9374 2008-09-13 16:53:45Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the PCODE declarations
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

#ifndef HB_PCODE_H_
#define HB_PCODE_H_

/* NOTE:
 *
 * IMPORTANT:
 *   Always add new pcodes to the end of the list to maintain compatibility.
 *
 */

/* NOTE:
 * Please update any opcode lookup tables present in
 *  genc.c
 *  harbour.c
 * when new opcode is added
 */
typedef enum
{
   HB_P_AND,                   /*   0 performs the logical AND of two latest stack values, removes them and places result */
   HB_P_ARRAYPUSH,             /*   1 places on the virtual machine stack an array element */
   HB_P_ARRAYPOP,              /*   2 pops a value from the eval stack into an array element */
   HB_P_ARRAYDIM,              /*   3 instructs the virtual machine to build an array with some specific dimensions */
   HB_P_ARRAYGEN,              /*   4 instructs the virtual machine to build an array and load element from the stack */
   HB_P_EQUAL,                 /*   5 check if the latest two values on the stack are equal, removing them and leaving the result */
   HB_P_ENDBLOCK,              /*   6 end of a codeblock definition */
   HB_P_ENDPROC,               /*   7 instructs the virtual machine to end execution */
   HB_P_EXACTLYEQUAL,          /*   8 check if the latest two values on the stack are exactly equal, removing them and leaving the result */
   HB_P_FALSE,                 /*   9 pushes false on the virtual machine stack */
   HB_P_FORTEST,               /*  10 For STEP. If step > 1 less. If step < 1 greater. */
   HB_P_FUNCTION,              /*  11 instructs the virtual machine to execute a function saving its result */
   HB_P_FUNCTIONSHORT,         /*  12 instructs the virtual machine to execute a function saving its result */
   HB_P_FRAME,                 /*  13 instructs the virtual machine about how many parameters and locals a function uses */
   HB_P_FUNCPTR,               /*  14 returns a function address pointer */
   HB_P_GREATER,               /*  15 checks if the second latest value on the stack is greater that the lastest one */
   HB_P_GREATEREQUAL,          /*  16 checks if the second latest value on the stack is greater equal that the latest one, leaves the result only */
   HB_P_DEC,                   /*  17 decrements the latest value on the virtual machine stack */
   HB_P_DIVIDE,                /*  18 divides the latest two values on the stack, removing them and leaving the result */
   HB_P_DO,                    /*  19 instructs the virtual machine to execute a function discarding its result */
   HB_P_DOSHORT,               /*  20 instructs the virtual machine to execute a function discarding its result */
   HB_P_DUPLICATE,             /*  21 places a copy of the latest virtual machine stack value on to the stack */
   HB_P_DUPLTWO,               /*  22 places a copy of the latest two virtual machine stack value on to the stack */
   HB_P_INC,                   /*  23 increments the latest value on the virtual machine stack */
   HB_P_INSTRING,              /*  24 checks if the second latest value on the stack is a substring of the latest one */
   HB_P_JUMPNEAR,              /*  25 jumps to a relative offset 1 Byte */
   HB_P_JUMP,                  /*  26 jumps to a relative offset 2 Bytes */
   HB_P_JUMPFAR,               /*  27 jumps to a relative offset 3 Bytes */
   HB_P_JUMPFALSENEAR,         /*  28 checks a logic expression of the stack and jumps to a relative offset */
   HB_P_JUMPFALSE,             /*  29 checks a logic expression of the stack and jumps to a relative offset */
   HB_P_JUMPFALSEFAR,          /*  30 checks a logic expression of the stack and jumps to a relative offset */
   HB_P_JUMPTRUENEAR,          /*  31 checks a logic expression of the stack and jumps to a relative offset */
   HB_P_JUMPTRUE,              /*  32 checks a logic expression of the stack and jumps to a relative offset */
   HB_P_JUMPTRUEFAR,           /*  33 checks a logic expression of the stack and jumps to a relative offset */
   HB_P_LESSEQUAL,             /*  34 checks if the second latest value on the stack is less equal that the latest one, leaves the result only */
   HB_P_LESS,                  /*  35 checks if the second latest value on the stack is less that the lastest one */
   HB_P_LINE,                  /*  36 currently compiled source code line number */
   HB_P_LOCALNAME,             /*  37 sets the name of local variable */
   HB_P_MACROPOP,              /*  38 compile and run - pop a value from the stack */
   HB_P_MACROPOPALIASED,       /*  39 compile and run - pop a field value from the stack */
   HB_P_MACROPUSH,             /*  40 compile and run - leave the result on the stack */
   HB_P_MACROARRAYGEN,         /*  41 generate array from arguments set(s) on HVM stack { &var } */
   HB_P_MACROPUSHLIST,         /*  42 compile and run - leave the result on the stack */
   HB_P_MACROPUSHINDEX,        /*  43 push array items using macro array index */
   HB_P_MACROPUSHPARE,         /*  44 compile and run - leave the result on the stack */
   HB_P_MACROPUSHALIASED,      /*  45 compile and run - leave the field value on the stack */
   HB_P_MACROSYMBOL,           /*  46 compile into a symbol name (used in function calls) */
   HB_P_MACROTEXT,             /*  47 macro text substitution */
   HB_P_MESSAGE,               /*  48 sends a message to an object */
   HB_P_MINUS,                 /*  49 subs the latest two values on the stack, removing them and leaving the result */
   HB_P_MODULUS,               /*  50 calculates the modulus of the two values on the stack, removing them and leaving the result */
   HB_P_MODULENAME,            /*  51 sets the name of debugged module */
/* start: pcodes generated by the macro compiler - the symbol address is used */
   HB_P_MMESSAGE,              /*  52 */
   HB_P_MPOPALIASEDFIELD,      /*  53 */
   HB_P_MPOPALIASEDVAR,        /*  54 */
   HB_P_MPOPFIELD,             /*  55 */
   HB_P_MPOPMEMVAR,            /*  56 */
   HB_P_MPUSHALIASEDFIELD,     /*  57 */
   HB_P_MPUSHALIASEDVAR,       /*  58 */
   HB_P_MPUSHBLOCK,            /*  59 */
   HB_P_MPUSHFIELD,            /*  60 */
   HB_P_MPUSHMEMVAR,           /*  61 */
   HB_P_MPUSHMEMVARREF,        /*  62 */
   HB_P_MPUSHSYM,              /*  63 */
   HB_P_MPUSHVARIABLE,         /*  64 */
/* end: */
   HB_P_MULT,                  /*  65 multiplies the latest two values on the stack, removing them and leaving the result */
   HB_P_NEGATE,                /*  66 numerically negates the latest value on the stack */
   HB_P_NOOP,                  /*  67 no operation */
   HB_P_NOT,                   /*  68 logically negates the latest value on the stack */
   HB_P_NOTEQUAL,              /*  69 checks if the latest two stack values are equal, leaves just the result */
   HB_P_OR,                    /*  70 performs the logical OR of two latest stack values, removes them and places result */
   HB_P_PARAMETER,             /*  71 creates PRIVATE variables and assigns values to functions paramaters */
   HB_P_PLUS,                  /*  72 adds the latest two values on the stack, removing them and leaving the result */
   HB_P_POP,                   /*  73 removes the latest value from the stack */
   HB_P_POPALIAS,              /*  74 pops the item from the eval stack and selects the current workarea */
   HB_P_POPALIASEDFIELD,       /*  75 pops aliased field */
   HB_P_POPALIASEDFIELDNEAR,   /*  76 pops aliased field */
   HB_P_POPALIASEDVAR,         /*  77 pops aliased variable (either a field or a memvar) */
   HB_P_POPFIELD,              /*  78 pops unaliased field */
   HB_P_POPLOCAL,              /*  79 pops the contents of the virtual machine stack onto a local variable */
   HB_P_POPLOCALNEAR,          /*  80 pops the contents of the virtual machine stack onto a local variable */
   HB_P_POPMEMVAR,             /*  81 pops the contents of a memvar variable to the virtual machine stack */
   HB_P_POPSTATIC,             /*  82 pops the contents of the virtual machine stack onto a static variable */
   HB_P_POPVARIABLE,           /*  83 pops the contents of an undeclared variable from the virtual machine stack */
   HB_P_POWER,                 /*  84 calculates the power of the two values on the stack, removing them and leaving the result */
   HB_P_PUSHALIAS,             /*  85 saves the current workarea number on the eval stack */
   HB_P_PUSHALIASEDFIELD,      /*  86 pushes aliased field */
   HB_P_PUSHALIASEDFIELDNEAR,  /*  87 pushes aliased field */
   HB_P_PUSHALIASEDVAR,        /*  88 pushes aliased variable (either a field or a memvar) */
   HB_P_PUSHBLOCK,             /*  89 start of a codeblock definition */
   HB_P_PUSHBLOCKSHORT,        /*  90 start of a codeblock definition */
   HB_P_PUSHFIELD,             /*  91 pushes an unaliased field */
   HB_P_PUSHBYTE,              /*  92 places a 1 byte integer number on the virtual machine stack */
   HB_P_PUSHINT,               /*  93 places an integer number on the virtual machine stack */
   HB_P_PUSHLOCAL,             /*  94 pushes the contents of a local variable to the virtual machine stack */
   HB_P_PUSHLOCALNEAR,         /*  95 pushes the contents of a local variable to the virtual machine stack */
   HB_P_PUSHLOCALREF,          /*  96 pushes a local variable by reference to the virtual machine stack */
   HB_P_PUSHLONG,              /*  97 places an integer number on the virtual machine stack */
   HB_P_PUSHMEMVAR,            /*  98 pushes the contents of a memvar variable to the virtual machine stack */
   HB_P_PUSHMEMVARREF,         /*  99 pushes the a memvar variable by reference to the virtual machine stack */
   HB_P_PUSHNIL,               /* 100 places a nil on the virtual machine stack */
   HB_P_PUSHDOUBLE,            /* 101 places a double number on the virtual machine stack */
   HB_P_PUSHSELF,              /* 102 pushes Self for the current processed method */
   HB_P_PUSHSTATIC,            /* 103 pushes the contents of a static variable to the virtual machine stack */
   HB_P_PUSHSTATICREF,         /* 104 pushes the a static variable by reference to the virtual machine stack */
   HB_P_PUSHSTR,               /* 105 places a string on the virtual machine stack */
   HB_P_PUSHSTRSHORT,          /* 106 places a string on the virtual machine stack */
   HB_P_PUSHSYM,               /* 107 places a symbol on the virtual machine stack */
   HB_P_PUSHSYMNEAR,           /* 108 places a symbol on the virtual machine stack */
   HB_P_PUSHVARIABLE,          /* 109 pushes the contents of an undeclared variable to the virtual machine stack */
   HB_P_RETVALUE,              /* 110 instructs the virtual machine to return the latest stack value */
   HB_P_SEND,                  /* 111 send operator */
   HB_P_SENDSHORT,             /* 112 send operator */
   HB_P_SEQBEGIN,              /* 113 BEGIN SEQUENCE */
   HB_P_SEQEND,                /* 114 END SEQUENCE */
   HB_P_SEQRECOVER,            /* 115 RECOVER statement */
   HB_P_SFRAME,                /* 116 sets the statics frame for a function */
   HB_P_STATICS,               /* 117 defines the number of statics variables for a PRG */
   HB_P_STATICNAME,            /* 118 sets the name of static variable */
   HB_P_SWAPALIAS,             /* 119 restores the current workarea number from the eval stack */
   HB_P_TRUE,                  /* 120 pushes true on the virtual machine stack */
   HB_P_ZERO,                  /* 121 places a ZERO on the virtual machine stack */
   HB_P_ONE,                   /* 122 places a ONE on the virtual machine stack */
   HB_P_MACROFUNC,             /* 123 execute a function saving its result */
   HB_P_MACRODO,               /* 124 execute a function discarding its result */
   HB_P_MPUSHSTR,              /* 125 Macro compiled pushed string */
   HB_P_LOCALNEARADDINT,       /* 126 Add/Subtract specified int into specified local without using the stack. */
   HB_P_MACROPUSHREF,          /* 127 Reference to macro variable @&mvar */
   HB_P_PUSHLONGLONG,          /* 128 places an integer number on the virtual machine stack */
   HB_P_ENUMSTART,             /* 129 Start of FOR EACH loop */
   HB_P_ENUMNEXT,              /* 130 Next item of FOR EACH loop  */
   HB_P_ENUMPREV,              /* 131 Previous item of FOR EACH loop  */
   HB_P_ENUMEND,               /* 132 End of FOR EACH loop */
   HB_P_SWITCH,                /* 133 SWITCH using long values */
   HB_P_PUSHDATE,              /* 134 places a data constant value on the virtual machine stack */
/* optimalization of inlined math operations */   
   HB_P_PLUSEQPOP,             /* 135 adds a value to the variable reference */
   HB_P_MINUSEQPOP,            /* 136 subs a value from the variable reference */
   HB_P_MULTEQPOP,             /* 137 multiplies a variable reference by a value */
   HB_P_DIVEQPOP,              /* 138 divides the var reference by a value */
   HB_P_PLUSEQ,                /* 139 adds a value to the variable reference, leave result on the stack */
   HB_P_MINUSEQ,               /* 140 subs a value from the variable reference, leave result on the stack */
   HB_P_MULTEQ,                /* 141 multiplies a variable reference by a value, leave result on the stack */
   HB_P_DIVEQ,                 /* 142 divides the var reference by a value, leave result on the stack */
   HB_P_WITHOBJECTSTART,       /* 143 start WITH OBJECT code */
   HB_P_WITHOBJECTMESSAGE,     /* 144 push message for WITH OBJECT */
   HB_P_WITHOBJECTEND,         /* 145 end WITH OBJECT code */
   HB_P_MACROSEND,             /* 146 send operator with macrlist params */
   HB_P_PUSHOVARREF,           /* 147 pushes reference to object variable */
   HB_P_ARRAYPUSHREF,          /* 148 pushes reference to array element */
   HB_P_VFRAME,                /* 149 frame with variable number of parameters */
   HB_P_LARGEFRAME,            /* 150 frame with more then 255 locals */
   HB_P_LARGEVFRAME,           /* 151 frame with variable number of parameters and more then 255 locals */
   HB_P_PUSHSTRHIDDEN,         /* 152 places a "hidden" string on the virtual machine stack */
   HB_P_LOCALADDINT,           /* 153 Add/Subtract specified int into specified local without using the stack. */
   HB_P_MODEQPOP,              /* 154 calculates the modulus of var reference and a value */
   HB_P_EXPEQPOP,              /* 155 calculates the power of var reference and a value */
   HB_P_MODEQ,                 /* 156 calculates the modulus of var reference and a value, leave result on the stack */
   HB_P_EXPEQ,                 /* 157 calculates the power of var reference and a value, leave result on the stack */
   HB_P_DUPLUNREF,             /* 158 places a copy of the latest virtual machine stack value on to the stack and unreference the source one */
   HB_P_MPUSHBLOCKLARGE,       /* 159 code block generated by the macro compiler larger then 64kb */
   HB_P_MPUSHSTRLARGE,         /* 160 Macro compiled pushed string */
   HB_P_PUSHBLOCKLARGE,        /* 161 start of a codeblock definition */
   HB_P_PUSHSTRLARGE,          /* 162 places a string on the virtual machine stack */
   HB_P_SWAP,                  /* 163 swap n+1 times two items starting from the most top one on the virtual machine stack */
   HB_P_PUSHVPARAMS,           /* 164 push variable function/method parameters on HVM stack */
   HB_P_PUSHUNREF,             /* 165 push unreferenced top item on HVM stack */
   HB_P_SEQALWAYS,             /* 166 set BEGIN SEQUENCE/ALWAYS section */
   HB_P_ALWAYSBEGIN,           /* 167 start ALWAYS section */
   HB_P_ALWAYSEND,             /* 168 finish ALWAYS section */
   HB_P_DECEQPOP,              /* 169 decrements the var reference */
   HB_P_INCEQPOP,              /* 170 increments the var reference */
   HB_P_DECEQ,                 /* 171 decrements the var reference, leave result on the stack */
   HB_P_INCEQ,                 /* 172 increments the var reference, leave result on the stack */
   HB_P_LOCALDEC,              /* 173 decrements the local variable */
   HB_P_LOCALINC,              /* 174 increments the local variable */
   HB_P_LOCALINCPUSH,          /* 175 increments the local variable, push result on the stack */
   HB_P_PUSHFUNCSYM,           /* 176 places a symbol on the virtual machine stack */
   HB_P_HASHGEN,               /* 177 instructs the virtual machine to build a hash and load element from the stack */
   HB_P_SEQBLOCK,              /* 178 set BEQIN SEQUENCE WITH block */
   HB_P_THREADSTATICS,         /* 179 mark thread static variables */
   HB_P_LAST_PCODE             /* 180 this defines the number of defined pcodes */
} HB_PCODE;

#endif /* HB_PCODE_H_ */
c:\harbour\include\hbpp.h
/*
 * $Id: hbpp.h 9374 2008-09-13 16:53:45Z druzus $
 */

/*
 * Harbour Project source code:
 *
 *
 * Copyright 2006 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_PP_H_
#define HB_PP_H_

#include "hbapi.h"
#include "hbapifs.h"

HB_EXTERN_BEGIN

#define HB_BLOCK_MACRO     1
#define HB_BLOCK_LATEEVAL  2
#define HB_BLOCK_VPARAMS   4
#define HB_BLOCK_EXT       8

/* #pragma {__text,__stream,__cstream}|functionOut|functionEnd|functionStart */
#define HB_PP_STREAM_OFF      0 /* standard preprocessing */
#define HB_PP_STREAM_COMMENT  1 /* multiline comment */
#define HB_PP_STREAM_DUMP_C   2 /* pragma BEGINDUMP */
#define HB_PP_STREAM_CLIPPER  3 /* clipper compatible TEXT/ENDTEXT */
#define HB_PP_STREAM_PRG      4 /* TEXT/ENDTEXT lines joined with LF */
#define HB_PP_STREAM_C        5 /* TEXT/ENDTEXT lines joined and ESC seq processed */
#define HB_PP_STREAM_INLINE_C 6 /* hb_inLIne() {...} data, should not be preprocessed */

/* hb_inLine() states */
#define HB_PP_INLINE_OFF      0
#define HB_PP_INLINE_START    1
#define HB_PP_INLINE_PARAM    2
#define HB_PP_INLINE_BODY     3
#define HB_PP_INLINE_COMMENT  4
#define HB_PP_INLINE_QUOTE1   5
#define HB_PP_INLINE_QUOTE2   6

/* function to open included files */
#define HB_PP_OPEN_FUNC_( func ) FILE * func( void *, const char *, BOOL, BOOL *, char * )
typedef HB_PP_OPEN_FUNC_( HB_PP_OPEN_FUNC );
typedef HB_PP_OPEN_FUNC * PHB_PP_OPEN_FUNC;

/* function to close included files */
#define HB_PP_CLOSE_FUNC_( func ) void func( void *, FILE * )
typedef HB_PP_CLOSE_FUNC_( HB_PP_CLOSE_FUNC );
typedef HB_PP_CLOSE_FUNC * PHB_PP_CLOSE_FUNC;

/* function to generate errors */
#define HB_PP_ERROR_FUNC_( func ) void func( void *, const char **, char, int, const char *, const char * )
typedef HB_PP_ERROR_FUNC_( HB_PP_ERROR_FUNC );
typedef HB_PP_ERROR_FUNC * PHB_PP_ERROR_FUNC;

/* function to redirect stdout messages */
#define HB_PP_DISP_FUNC_( func ) void func( void *, const char * )
typedef HB_PP_DISP_FUNC_( HB_PP_DISP_FUNC );
typedef HB_PP_DISP_FUNC * PHB_PP_DISP_FUNC;

/* function for catching #pragma dump data */
#define HB_PP_DUMP_FUNC_( func ) void func( void *, char *, ULONG, int )
typedef HB_PP_DUMP_FUNC_( HB_PP_DUMP_FUNC );
typedef HB_PP_DUMP_FUNC * PHB_PP_DUMP_FUNC;

/* function for catching HB_INLINE(...){...} data */
#define HB_PP_INLINE_FUNC_( func ) void func( void *, char *, char *, ULONG, int )
typedef HB_PP_INLINE_FUNC_( HB_PP_INLINE_FUNC );
typedef HB_PP_INLINE_FUNC * PHB_PP_INLINE_FUNC;

/* function for catching #pragma dump data */
#define HB_PP_SWITCH_FUNC_( func ) BOOL func( void *, const char *, int )
typedef HB_PP_SWITCH_FUNC_( HB_PP_SWITCH_FUNC );
typedef HB_PP_SWITCH_FUNC * PHB_PP_SWITCH_FUNC;


/* preprocessor tokens */
#define HB_PP_TOKEN_NUL          0

#define HB_PP_MMARKER_REGULAR    1
#define HB_PP_MMARKER_LIST       2
#define HB_PP_MMARKER_RESTRICT   3
#define HB_PP_MMARKER_WILD       4
#define HB_PP_MMARKER_EXTEXP     5
#define HB_PP_MMARKER_NAME       6
#define HB_PP_MMARKER_OPTIONAL   7

#define HB_PP_RMARKER_REGULAR    11
#define HB_PP_RMARKER_STRDUMP    12
#define HB_PP_RMARKER_STRSTD     13
#define HB_PP_RMARKER_STRSMART   14
#define HB_PP_RMARKER_BLOCK      15
#define HB_PP_RMARKER_LOGICAL    16
#define HB_PP_RMARKER_NUL        17
#define HB_PP_RMARKER_OPTIONAL   18

/* keywords, pseudo keywords and PP only tokens */
#define HB_PP_TOKEN_KEYWORD      21
#define HB_PP_TOKEN_MACROVAR     22
#define HB_PP_TOKEN_MACROTEXT    23
#define HB_PP_TOKEN_TEXT         24
#define HB_PP_TOKEN_OTHER        25   /* non keyword, text, or operator character */
#define HB_PP_TOKEN_BACKSLASH    26   /* "\\" */
#define HB_PP_TOKEN_PIPE         27   /* "|" */
#define HB_PP_TOKEN_DOT          28   /* "." */
#define HB_PP_TOKEN_COMMA        29   /* "," */
#define HB_PP_TOKEN_EOC          30   /* ";" */
#define HB_PP_TOKEN_EOL          31   /* "\n" */
#define HB_PP_TOKEN_HASH         32   /* "#" */
#define HB_PP_TOKEN_DIRECTIVE    33   /* direct # directive first token */

/* constant values */
#define HB_PP_TOKEN_STRING       41
#define HB_PP_TOKEN_NUMBER       42
#define HB_PP_TOKEN_DATE         43
#define HB_PP_TOKEN_LOGICAL      44

/* operators */
#define HB_PP_TOKEN_LEFT_PB      50
#define HB_PP_TOKEN_RIGHT_PB     51
#define HB_PP_TOKEN_LEFT_SB      52
#define HB_PP_TOKEN_RIGHT_SB     53
#define HB_PP_TOKEN_LEFT_CB      54
#define HB_PP_TOKEN_RIGHT_CB     55
#define HB_PP_TOKEN_REFERENCE    56
#define HB_PP_TOKEN_AMPERSAND    57
#define HB_PP_TOKEN_SEND         58
#define HB_PP_TOKEN_ALIAS        59

#define HB_PP_TOKEN_ASSIGN       60
#define HB_PP_TOKEN_PLUSEQ       61
#define HB_PP_TOKEN_MINUSEQ      62
#define HB_PP_TOKEN_MULTEQ       63
#define HB_PP_TOKEN_DIVEQ        64
#define HB_PP_TOKEN_MODEQ        65
#define HB_PP_TOKEN_EXPEQ        66

#define HB_PP_TOKEN_INC          67
#define HB_PP_TOKEN_DEC          68
#define HB_PP_TOKEN_NOT          69
#define HB_PP_TOKEN_OR           70
#define HB_PP_TOKEN_AND          71
#define HB_PP_TOKEN_EQUAL        72
#define HB_PP_TOKEN_EQ           73
#define HB_PP_TOKEN_LT           74
#define HB_PP_TOKEN_GT           75
#define HB_PP_TOKEN_LE           76
#define HB_PP_TOKEN_GE           77
#define HB_PP_TOKEN_NE           78
#define HB_PP_TOKEN_IN           79
#define HB_PP_TOKEN_PLUS         80
#define HB_PP_TOKEN_MINUS        81
#define HB_PP_TOKEN_MULT         82
#define HB_PP_TOKEN_DIV          83
#define HB_PP_TOKEN_MOD          84
#define HB_PP_TOKEN_POWER        85
#define HB_PP_TOKEN_EPSILON      86
/* xhb stuff */
#if 0
#define HB_PP_TOKEN_SHIFTL       87
#define HB_PP_TOKEN_SHIFTR       88
#define HB_PP_TOKEN_BITXOR       89
#endif

#define HB_PP_TOKEN_TYPE(t)      ( (t) & 0xff )
/* bitfields */
/* #define HB_PP_TOKEN_UNARY        0x0100 */
/* #define HB_PP_TOKEN_BINARY       0x0200 */
/* #define HB_PP_TOKEN_JOINABLE     0x0400 */
#define HB_PP_TOKEN_MATCHMARKER  0x2000
#define HB_PP_TOKEN_STATIC       0x4000
#define HB_PP_TOKEN_PREDEFINED   0x8000

#define HB_PP_TOKEN_SETTYPE(t,n) do{ (t)->type = ( (t)->type & 0xff00 ) | (n); } while(0)

#define HB_PP_TOKEN_ALLOC(t)     ( ( (t) & HB_PP_TOKEN_STATIC ) == 0 )
#define HB_PP_TOKEN_ISPREDEF(t)  ( ( (t)->type & HB_PP_TOKEN_PREDEFINED ) != 0 )

/* These macros are very important for the PP behavior. They define what
   and how will be translated. Their default definitions are not strictly
   Clipper compatible to allow programmer using indirect # directive
         EOL - end of line    => '\n' or NULL
         EOC - end of command => EOL or ';'
         EOS - end of subst   => EOL or ';' + '#'
         EOP - end of pattern => EOL for direct and EOC for indirect
 */

/* End Of Line */
#define HB_PP_TOKEN_ISEOL(t)     ( (t) == NULL || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EOL )
/* End Of Command */
#define HB_PP_TOKEN_ISEOC(t)     ( HB_PP_TOKEN_ISEOL(t) || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EOC )

#ifdef HB_C52_STRICT
#  define HB_PP_TOKEN_ISEOS(t)   HB_PP_TOKEN_ISEOL(t)
#  define HB_PP_TOKEN_ISEOP(t,l) HB_PP_TOKEN_ISEOL(t)
#else
/* End Of Subst - define how many tokens in line should be translated,
                  Clipper translate whole line */
#  define HB_PP_TOKEN_ISEOS(t)   ( HB_PP_TOKEN_ISEOL(t) || \
                                   ( HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EOC && \
                                     (t)->pNext && \
                                     ( HB_PP_TOKEN_TYPE((t)->pNext->type) == HB_PP_TOKEN_HASH || \
                                       HB_PP_TOKEN_TYPE((t)->pNext->type) == HB_PP_TOKEN_DIRECTIVE ) ) )
/* End Of Pattern - the second paramter define if it's direct or indirect
                    pattern */
#  define HB_PP_TOKEN_ISEOP(t,l) ( (l) ? HB_PP_TOKEN_ISEOL(t) : HB_PP_TOKEN_ISEOC(t) )
#endif

#define HB_PP_TOKEN_ISDIRECTIVE(t)  ( HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_DIRECTIVE || \
                                      HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_HASH )

#define HB_PP_TOKEN_CANJOIN(t)   ( ! HB_PP_TOKEN_CLOSE_BR(t) && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_KEYWORD && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACROVAR && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACROTEXT && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_TEXT && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_STRING && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_NUMBER && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_DATE && \
                                   HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_LOGICAL )

#define HB_PP_TOKEN_OPEN_BR(t)   ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_LEFT_PB || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_LEFT_SB || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_LEFT_CB )

#define HB_PP_TOKEN_CLOSE_BR(t)  ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_RIGHT_PB || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_RIGHT_SB || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_RIGHT_CB )

#define HB_PP_TOKEN_ISNEUTRAL(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DEC || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_INC )

#define HB_PP_TOKEN_NEEDLEFT(t)  ( HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_ASSIGN || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_PLUSEQ || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_MINUSEQ || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_MULTEQ || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_DIVEQ || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_MODEQ || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EXPEQ || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EQUAL || \
                                   HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_EQ || \
                                   ( HB_PP_TOKEN_TYPE((t)->type) == HB_PP_TOKEN_SEND && \
                                     (t)->spaces == 0 && (t)->pNext && \
                                     ( HB_PP_TOKEN_TYPE((t)->pNext->type) == HB_PP_TOKEN_KEYWORD || \
                                       HB_PP_TOKEN_TYPE((t)->pNext->type) == HB_PP_TOKEN_MACROVAR || \
                                       HB_PP_TOKEN_TYPE((t)->pNext->type) == HB_PP_TOKEN_MACROTEXT ) ) )

/* I do not want to replicate exactly Clipper PP behavior and check if
   expression is valid.
   it's wrong and causes that potentially valid expressions are not
   properly parsed, f.e:
      ? 1 + + 2
   does not work when
      qout( 1 + + 2 )
   perfectly does.
   It this difference will be reason of some problems then please inform me
   with a code example so I'll be able if it should be implemented or not.
   Now I simply disabled HB_PP_TOKEN_NEEDRIGHT() macro.
 */
#ifndef HB_C52_STRICT
#define HB_PP_TOKEN_NEEDRIGHT(t) ( FALSE )
#else
#define HB_PP_TOKEN_NEEDRIGHT(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_PLUS || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MINUS || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MULT || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DIV || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MOD || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_POWER )
#endif

#ifdef HB_C52_STRICT
#  define HB_PP_TOKEN_ISUNARY(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MINUS || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DEC || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_INC || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_AMPERSAND )
#else
#  define HB_PP_TOKEN_ISUNARY(t) ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MINUS || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DEC || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_INC || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_AMPERSAND || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_PLUS || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_NOT || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_REFERENCE )
#endif

#define HB_PP_TOKEN_ISMATCH(t)   ( (t) && ( (t)->type & HB_PP_TOKEN_MATCHMARKER ) != 0 )

#if 0
#define HB_PP_TOKEN_ISRESULT(t)  ( HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_REGULAR || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_STRDUMP || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_STRSTD || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_STRSMART || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_BLOCK || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_LOGICAL || \
                                   HB_PP_TOKEN_TYPE(t) == HB_PP_RMARKER_NUL )
#endif

#define HB_PP_TOKEN_ISEXPVAL(t)     ( HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_KEYWORD || \
                                      HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MACROVAR || \
                                      HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_MACROTEXT || \
                                      HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_STRING || \
                                      HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_NUMBER || \
                                      HB_PP_TOKEN_TYPE(t) == HB_PP_TOKEN_DATE )
#define HB_PP_TOKEN_ISEXPTOKEN(t)   ( HB_PP_TOKEN_ISEXPVAL( (t)->type ) || \
                                      ( (t)->pNext && HB_PP_TOKEN_ISUNARY( (t)->type ) && \
                                        HB_PP_TOKEN_ISEXPVAL( (t)->pNext->type ) ) )

#ifdef HB_C52_STRICT
/* Clipper supports quoting by [] for 1-st token in the line so we
   are not checking for HB_PP_TOKEN_NUL in this macro */
#define HB_PP_TOKEN_CANQUOTE(t)     ( HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_KEYWORD && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACROVAR && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACROTEXT && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_PB && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_SB && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_CB )
#else
/* Disable string quoting by [] for next token if current one is
   constant value - it's not Clipper compatible but we need it for
   accessing string characters by array index operator or introduce
   similar extensions for other types in the future */
#define HB_PP_TOKEN_CANQUOTE(t)     ( HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_KEYWORD && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACROVAR && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_MACROTEXT && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_PB && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_SB && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_RIGHT_CB && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_STRING && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_NUMBER && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_DATE && \
                                      HB_PP_TOKEN_TYPE(t) != HB_PP_TOKEN_LOGICAL )
#endif

typedef struct _HB_PP_TOKEN
{
   struct _HB_PP_TOKEN * pNext;     /* next token pointer */
   struct _HB_PP_TOKEN * pMTokens;  /* restrict or optional marker token(s) */

   const char * value;              /* token value */
   USHORT len;                      /* token value length */
   USHORT spaces;                   /* leading spaces for stringify */
   USHORT type;                     /* token type, see HB_PP_TOKEN_* */
   USHORT index;                    /* index to match marker or 0 */
}
HB_PP_TOKEN, * PHB_PP_TOKEN;


#ifdef _HB_PP_INTERNAL

/* default maximum number of translations */
#define HB_PP_MAX_CYCLES      4096
/* maximum number of single token translations, in Clipper it's 18 + number
   of used rules, we will use also constant but increased by total number
   of rules of given type: define, [x]translate, [x]command */
#define HB_PP_MAX_REPATS      128

/* Clipper allows only 16 nested includes */
#define HB_PP_MAX_INCLUDED_FILES    64

#define HB_PP_HASHID(t)       ( ( UCHAR ) HB_PP_UPPER( (t)->value[0] ) )
#define HB_PP_HASHID_MAX      256
#define HB_PP_DEFINE          1
#define HB_PP_TRANSLATE       2
#define HB_PP_COMMAND         4

/* comparision modes */
#define HB_PP_CMP_ADDR        0 /* compare token addresses */
#define HB_PP_CMP_STD         1 /* standard comparison, ignore the case of the characters */
#define HB_PP_CMP_DBASE       2 /* dbase keyword comparison (accepts at least four character shortcuts) ignore the case of the characters */
#define HB_PP_CMP_CASE        3 /* case sensitive comparison */

#define HB_PP_CMP_MODE(t)     ( (t) & 0xff )
#define HB_PP_STD_RULE        0x8000


/* conditional compilation */
#define HB_PP_COND_ELSE       1     /* preprocessing and output stopped until corresponding #else */
#define HB_PP_COND_DISABLE    2     /* preprocessing and output stopped until corresponding #endif(s) */

/* operation precedence for #if calculation */
#define HB_PP_PREC_NUL  0
#define HB_PP_PREC_NOT  1
#define HB_PP_PREC_LOG  2
#define HB_PP_PREC_REL  3
#define HB_PP_PREC_BIT  4
#define HB_PP_PREC_PLUS 5
#define HB_PP_PREC_MULT 6
#define HB_PP_PREC_NEG  7

/* For platforms which does not use ASCII based character tables this macros
   have to be changed to use valid C functions, f.e.:
      isalpha(), isdigit(), ... */
#ifdef HB_C52_STRICT
#  define HB_PP_ISILLEGAL(c)     ( (c) < 32 || (c) >= 126 )
#else
#  define HB_PP_ISILLEGAL(c)     ( (c) < 32 || (c) == 127 )
#endif
#define HB_PP_ISTEXTCHAR(c)      ( (unsigned char) (c) >= 128 )
#define HB_PP_ISBLANK(c)         ( (c) == ' ' || (c) == '\t' )
#define HB_PP_ISDIGIT(c)         ( (c) >= '0' && (c) <= '9' )
#define HB_PP_ISHEX(c)           ( HB_PP_ISDIGIT(c) || \
                                   ( (c) >= 'A' && (c) <= 'F' ) || \
                                   ( (c) >= 'a' && (c) <= 'f' ) )
#define HB_PP_ISTRUE(c)          ( (c) == 'T' || (c) == 't' || \
                                   (c) == 'Y' || (c) == 'y' )
#define HB_PP_ISFALSE(c)         ( (c) == 'F' || (c) == 'f' || \
                                   (c) == 'N' || (c) == 'n' )
#define HB_PP_ISFIRSTIDCHAR(c)   ( ( (c) >= 'A' && (c) <= 'Z' ) || \
                                   ( (c) >= 'a' && (c) <= 'z' ) || (c) == '_' )
#define HB_PP_ISNEXTIDCHAR(c)    ( HB_PP_ISFIRSTIDCHAR(c) || HB_PP_ISDIGIT(c) )
#define HB_PP_UPPER(c)           ( (c) >= 'a' && (c) <= 'z' ? \
                                   (c) - ( 'a' - 'A' ) : (c) )
typedef struct _HB_PP_RESULT
{
   struct _HB_PP_RESULT * pNext;
   PHB_PP_TOKEN   pFirstToken;
   PHB_PP_TOKEN   pNextExpr;
}
HB_PP_RESULT, * PHB_PP_RESULT;

typedef struct _HB_PP_MARKERPTR
{
   struct _HB_PP_MARKERPTR * pNext;
   PHB_PP_TOKEN   pToken;
   PHB_PP_TOKEN   pMTokens;
   USHORT         type;
}
HB_PP_MARKERPTR, * PHB_PP_MARKERPTR;

typedef struct _HB_PP_MARKERLST
{
   struct _HB_PP_MARKERLST * pNext;
   PHB_PP_MARKERPTR  pMatchMarkers;
   USHORT            canrepeat;
   USHORT            index;
}
HB_PP_MARKERLST, * PHB_PP_MARKERLST;

typedef struct
{
   USHORT   canrepeat;
   /* filled when pattern matches for substitution, cleared after */
   USHORT   matches;
   PHB_PP_RESULT  pResult;
}
HB_PP_MARKER, * PHB_PP_MARKER;

typedef struct _HB_PP_RULE
{
   struct _HB_PP_RULE * pPrev;      /* previous rule */
   PHB_PP_TOKEN   pMatch;           /* match patern or NULL */
   PHB_PP_TOKEN   pResult;          /* result patern or NULL */
   USHORT         mode;             /* comparison mode HB_PP_CMP_* */
   USHORT         markers;          /* number of markers in marker table */
   /* filled when pattern matches for substitution, cleared after */
   PHB_PP_MARKER  pMarkers;         /* marker table */
   PHB_PP_TOKEN   pNextExpr;        /* next expression after match pattern */
}
HB_PP_RULE, * PHB_PP_RULE;

typedef struct _HB_PP_DEFRULE
{
   PHB_PP_TOKEN   pMatch;
   PHB_PP_TOKEN   pResult;
   USHORT         mode;
   USHORT         markers;
   ULONG          repeatbits;
}
HB_PP_DEFRULE, * PHB_PP_DEFRULE;

typedef struct
{
   const char *   name;       /* input name */
   ULONG          len;        /* input name length */
   const char *   value;      /* output name */
   USHORT         type;       /* HB_PP_TOKEN_* */
}
HB_PP_OPERATOR, * PHB_PP_OPERATOR;

typedef struct
{
   char *   pBufPtr;
   ULONG    ulLen;
   ULONG    ulAllocated;
}
HB_MEM_BUFFER, * PHB_MEM_BUFFER;

typedef struct _HB_PP_FILE
{
   char *   szFileName;          /* input file name */
   FILE *   file_in;             /* input file handle */
   PHB_PP_TOKEN pTokenList;      /* current line decoded to tokens */
   int      iCurrentLine;        /* current line in file */
   int      iLastLine;           /* last non empty generated line */
   int      iLastDisp;           /* last shown line number */
   int      iTokens;             /* number of decoded tokens */
   BOOL     fGenLineInfo;        /* #line information should be generated */
   BOOL     fEof;                /* the end of file reached */

   const char * pLineBuf;        /* buffer for parsing external lines */
   ULONG    ulLineBufLen;        /* size of external line buffer */

   struct _HB_PP_FILE * pPrev;   /* previous file, the one which included this file */
}
HB_PP_FILE, * PHB_PP_FILE;

typedef struct
{
   /* common for all included files */
   PHB_PP_OPERATOR pOperators;   /* user defined operators */
   PHB_PP_RULE    pDefinitions;  /* #define table */
   PHB_PP_RULE    pTranslations; /* #[x]translate table */
   PHB_PP_RULE    pCommands;     /* #[x]command table */
   int            iOperators;    /* number of user defined operators */
   int            iDefinitions;  /* number of rules in pDefinitions */
   int            iTranslations; /* number of rules in pTranslations */
   int            iCommands;     /* number of rules in pCommands */
   BYTE           pMap[ HB_PP_HASHID_MAX ]; /* translation map */

   PHB_PP_TOKEN   pTokenOut;     /* preprocessed tokens */
   PHB_PP_TOKEN * pNextTokenPtr; /* pointer to the last NULL pointer in token list */

   PHB_MEM_BUFFER pDumpBuffer;   /* buffer for dump output */
   PHB_MEM_BUFFER pOutputBuffer; /* buffer for preprocessed line */

   int      iLineTot;            /* total number of parsed lines */
   int      iCycle;              /* translation counter */
   int      iMaxCycles;          /* maximum number of translations */
   int      iHideStrings;        /* hidden string mode */
   BOOL     fTracePragmas;       /* display information about set pragmas */
   BOOL     fWritePreprocesed;   /* write preprocessed data to file (.ppo) */
   BOOL     fWriteTrace;         /* write translation to file (.ppt) */

   HB_PATHNAMES * pIncludePath;  /* search path(s) for included files */

   char *   szOutFileName;       /* output file name */
   FILE *   file_out;            /* output file handle */
   char *   szTraceFileName;     /* trace output file name */
   FILE *   file_trace;          /* trace output file handle */

   BOOL     fQuiet;              /* do not show standard information */
   BOOL     fEscStr;             /* use \ in strings as escape character */
   BOOL     fError;              /* indicates error in last operation */
   int      iErrors;             /* number of error during preprocessing */
   int      iCondCompile;        /* current conditional compilation flag, when not 0 disable preprocessing and output */
   int      iCondCount;          /* number of nested #if[n]def directive */
   int      iCondStackSize;      /* size of conditional compilation stack */
   int *    pCondStack;          /* conditional compilation stack */

   /* used to divide line per tokens and tokens manipulations */
   PHB_MEM_BUFFER pBuffer;       /* buffer for input and output line */
   int      iSpaces;             /* leading spaces for next token */
   int      iSpacesNL;           /* leading spaces ';' token (fCanNextLine) if it will not be line concatenator */
   int      iSpacesMin;          /* minimal number of leading spaces for next token */
   USHORT   usLastType;          /* last token type */
   BOOL     fCanNextLine;        /* ';' token found and we do not know yet if it's command separator or line concatenator */
   BOOL     fDirective;          /* # directives is parsed */
   BOOL     fNewStatement;       /* set to TRUE at line begining or after each ';' token */
   PHB_PP_TOKEN   pFuncOut;      /* function used for each line in HB_PP_STREAM_* dumping */
   PHB_PP_TOKEN   pFuncEnd;      /* end function for HB_PP_STREAM_* dumping */
   PHB_MEM_BUFFER pStreamBuffer; /* buffer for stream output */
   int      iStreamDump;         /* stream output, see HB_PP_STREAM_* */
   int      iDumpLine;           /* line where current dump output begins */
   int      iInLineCount;        /* number of hb_inLine() functions */
   int      iInLineState;        /* hb_inLine() state */
   int      iInLineBraces;       /* braces counter for hb_inLine() */
   int      iNestedBlock;        /* nested extended block counter */
   int      iBlockState;         /* state of extended block declaration */

   PHB_PP_FILE pFile;            /* currently preprocessed file structure */
   int      iFiles;              /* number of open files */

   void *   cargo;               /* parameter passed to user functions */
   PHB_PP_OPEN_FUNC  pOpenFunc;  /* function to open files */
   PHB_PP_CLOSE_FUNC pCloseFunc; /* function to close files */
   PHB_PP_ERROR_FUNC pErrorFunc; /* function to generate errors */
   PHB_PP_DISP_FUNC  pDispFunc;  /* function to redirect stdout messages */
   PHB_PP_DUMP_FUNC  pDumpFunc;  /* function for catching #pragma dump data */
   PHB_PP_INLINE_FUNC pInLineFunc; /* function for hb_inLine(...) {...} blocks */
   PHB_PP_SWITCH_FUNC pSwitchFunc; /* function for compiler switches with #pragma ... */
}
HB_PP_STATE, * PHB_PP_STATE;

extern void hb_pp_initRules( PHB_PP_RULE * pRulesPtr, int * piRules,
                             const HB_PP_DEFRULE pDefRules[], int iDefRules );


#else

typedef void * PHB_PP_STATE;

#endif /* _HB_PP_INTERNAL */

/* public functions */
extern PHB_PP_STATE hb_pp_new( void );
extern void   hb_pp_free( PHB_PP_STATE pState );
extern void   hb_pp_reset( PHB_PP_STATE pState );
extern void   hb_pp_init( PHB_PP_STATE pState, BOOL fQuiet,
                  int iCycles, void * cargo,
                  PHB_PP_OPEN_FUNC  pOpenFunc, PHB_PP_CLOSE_FUNC pCloseFunc,
                  PHB_PP_ERROR_FUNC pErrorFunc, PHB_PP_DISP_FUNC  pDispFunc,
                  PHB_PP_DUMP_FUNC  pDumpFunc, PHB_PP_INLINE_FUNC pInLineFunc,
                  PHB_PP_SWITCH_FUNC pSwitchFunc );
extern void   hb_pp_initDynDefines( PHB_PP_STATE pState );
extern void   hb_pp_readRules( PHB_PP_STATE pState, const char * szRulesFile );
extern void   hb_pp_setStdRules( PHB_PP_STATE pState );
extern void   hb_pp_setStdBase( PHB_PP_STATE pState );
extern void   hb_pp_setStream( PHB_PP_STATE pState, int iMode );
extern void   hb_pp_addSearchPath( PHB_PP_STATE pState, const char * szPath, BOOL fReplace );
extern BOOL   hb_pp_inBuffer( PHB_PP_STATE pState, const char * pBuffer, ULONG ulLen );
extern BOOL   hb_pp_inFile( PHB_PP_STATE pState, const char * szFileName, BOOL fSearchPath, FILE * file_in, BOOL fError );
extern BOOL   hb_pp_outFile( PHB_PP_STATE pState, const char * szOutFileName, FILE * file_out );
extern BOOL   hb_pp_traceFile( PHB_PP_STATE pState, const char * szTraceFileName, FILE * file_trace );
extern char * hb_pp_fileName( PHB_PP_STATE pState );
extern int    hb_pp_line( PHB_PP_STATE pState );
extern BOOL   hb_pp_eof( PHB_PP_STATE pState );
extern int    hb_pp_lineTot( PHB_PP_STATE pState );
extern char * hb_pp_outFileName( PHB_PP_STATE pState );
extern char * hb_pp_traceFileName( PHB_PP_STATE pState );
extern char * hb_pp_nextLine( PHB_PP_STATE pState, ULONG * pulLen );
extern char * hb_pp_parseLine( PHB_PP_STATE pState, const char * pLine, ULONG * pulLen );
extern void   hb_pp_addDefine( PHB_PP_STATE pState, const char * szDefName, const char * szDefValue );
extern void   hb_pp_delDefine( PHB_PP_STATE pState, const char * szDefName );
extern BOOL   hb_pp_lasterror( PHB_PP_STATE pState );
extern int    hb_pp_errorCount( PHB_PP_STATE pState );
extern BOOL   hb_pp_eof( PHB_PP_STATE pState );

extern void   hb_pp_tokenUpper( PHB_PP_TOKEN pToken );
extern void   hb_pp_tokenToString( PHB_PP_STATE pState, PHB_PP_TOKEN pToken );
extern char * hb_pp_tokenBlockString( PHB_PP_STATE pState, PHB_PP_TOKEN pToken, int * piType, int * piLen );
extern PHB_PP_STATE hb_pp_lexNew( const char * pString, ULONG ulLen );
extern PHB_PP_TOKEN hb_pp_lexGet( PHB_PP_STATE pState );
extern PHB_PP_TOKEN hb_pp_tokenGet( PHB_PP_STATE pState );
extern BOOL   hb_pp_tokenNextExp( PHB_PP_TOKEN * pTokenPtr );

HB_EXTERN_END

#endif /* HB_PP_H_ */
c:\harbour\include\hbrddcdx.h
/*
 * $Id: hbrddcdx.h 9530 2008-10-02 12:34:36Z druzus $
 */

/*
 * DBFCDX RDD (ver.2)
 *
 * Copyright 1999 Bruno Cantero 
 * Copyright 2003 Przemyslaw Czerpak 
 * www - http://www.xharbour.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.
 *
 */

#ifndef HB_RDDCDX_H_
#define HB_RDDCDX_H_

#include "hbapirdd.h"
#include "hbdbferr.h"
#define HB_EXTERNAL_RDDDBF_USE
#include "hbrdddbf.h"

HB_EXTERN_BEGIN

/* CDX constants and defaults */
#define CDX_INDEXEXT                              ".cdx"
#define CDX_MAXKEY                                  240
#define CDX_MAXEXP                                  255
#define CDX_MAXTAGNAMELEN                            10
#define CDX_PAGELEN                                 512
#define CDX_HEADERLEN                              1024
#define CDX_HEADEREXPLEN          (CDX_HEADERLEN - 512)
#define CDX_HEADERPAGES   ((CDX_HEADERLEN+CDX_PAGELEN-1)/CDX_PAGELEN)
#define CDX_INT_FREESPACE              (CDX_PAGELEN-12) /* 500 */
#define CDX_EXT_FREESPACE              (CDX_PAGELEN-24) /* 488 */
#define CDX_DUMMYNODE                       0xFFFFFFFFL

/* #define CDX_LOCKOFFSET                      0x7FFFFFFEL */
/* #define CDX_LOCKSIZE                                 1L */
#define CDX_STACKSIZE                                64
#define CDX_PAGECACHESIZE                             8
#define CDX_NODE_BRANCH                               0
#define CDX_NODE_ROOT                                 1
#define CDX_NODE_LEAF                                 2
#define CDX_NODE_UNUSED                            0xFF
#define CDX_IGNORE_REC_NUM                         0x0L
#define CDX_MAX_REC_NUM                     0xFFFFFFFFL
#define CDX_BALANCE_LEAFPAGES                         3
#define CDX_BALANCE_INTPAGES                          3

#define CDX_CURKEY_UNDEF                        (1<< 0)
#define CDX_CURKEY_REC                          (1<< 1)
#define CDX_CURKEY_VAL                          (1<< 2)
#define CDX_CURKEY_INPAGE                       (1<< 3)
#define CDX_CURKEY_INSTACK                      (1<< 4)
#define CDX_CURKEY_NOTEXIST                     (1<< 5)
#define CDX_CURKEY_RAWCNT                       (1<< 6)
#define CDX_CURKEY_RAWPOS                       (1<< 7)
#define CDX_CURKEY_LOGCNT                       (1<< 8)
#define CDX_CURKEY_LOGPOS                       (1<< 9)

#define TOP_RECORD                                    1
#define BTTM_RECORD                                   2
#define PREV_RECORD                                   3
#define NEXT_RECORD                                   4
#define PRVU_RECORD                                   6
#define NXTU_RECORD                                   5

#define NODE_NEWLASTKEY                               1
#define NODE_SPLIT                                    2
#define NODE_JOIN                                     4
#define NODE_BALANCE                                  8
#define NODE_EAT                                     16

#define CURKEY_RAWCNT(pTag)   (((pTag)->curKeyState & CDX_CURKEY_RAWCNT) != 0)
#define CURKEY_LOGCNT(pTag)   (((pTag)->curKeyState & CDX_CURKEY_LOGCNT) != 0)

#define CURKEY_RAWPOS(pTag)   ( ((pTag)->curKeyState & CDX_CURKEY_RAWPOS) != 0 && \
                                 (pTag)->rawKeyRec == (pTag)->CurKey->rec )
#define CURKEY_SETRAWPOS(pTag) { (pTag)->curKeyState |= CDX_CURKEY_RAWPOS; \
                                 (pTag)->rawKeyRec = (pTag)->CurKey->rec; }

#define CURKEY_LOGPOS(pTag)   ( ((pTag)->curKeyState & CDX_CURKEY_LOGPOS) != 0 && \
                                 (pTag)->logKeyRec == (pTag)->pIndex->pArea->ulRecNo )
#define CURKEY_SETLOGPOS(pTag) { (pTag)->curKeyState |= CDX_CURKEY_LOGPOS; \
                                 (pTag)->logKeyRec = (pTag)->pIndex->pArea->ulRecNo; }

/*
#define CURKEY_UNDEF(pTag)    (((pTag)->curKeyState & CDX_CURKEY_UNDEF) != 0)
#define CURKEY_NOTEXIST(pTag) (((pTag)->curKeyState & CDX_CURKEY_NOTEXIST) != 0)
#define CURKEY_ISSET(pTag)    (((pTag)->curKeyState & (CDX_CURKEY_NOTEXIST | CDX_CURKEY_UNDEF)) == 0)
#define CURKEY_REC(pTag)      ((((pTag)->curKeyState & CDX_CURKEY_REC) != 0) ? (pTag)->curKey->rec : 0)
#define CURKEY_VAL(pTag)      ((((pTag)->curKeyState & CDX_CURKEY_VAL) != 0) ? (pTag)->curKey->val : NULL)
#define CURKEY_REFRESH(pTag)
*/

#define HB_CDXMAXKEY( x )     ((USHORT) ((x) > CDX_MAXKEY ? CDX_MAXKEY : (x)))
#define HB_CDXBITMASK( x )    ((LONG) ((1L<<(x))-1))

/* #define FAST_GOCOLD( A )      (((CDXAREAP) (A))->fRecordChanged || ((CDXAREAP) (A))->fCdxAppend ? (SELF_GOCOLD((A))) : SUCCESS) */
#define FAST_GOCOLD( A )      SELF_GOCOLD(A)


#define CDX_TYPE_UNIQUE        0x01    /* unique index */
#define CDX_TYPE_TEMPORARY     0x02    /* temporary index */
#define CDX_TYPE_CUSTOM        0x04    /* custom index */
#define CDX_TYPE_FORFILTER     0x08    /* for expression present */
#define CDX_TYPE_BITVECTOR     0x10    /* SoftC? */
#define CDX_TYPE_COMPACT       0x20    /* FoxPro */
#define CDX_TYPE_COMPOUND      0x40    /* FoxPro */
#define CDX_TYPE_STRUCTURE     0x80    /* FoxPro */

/*
 SIx3 order temperature flags:
   switch ( indexOpt & ( CDX_TYPE_TEMPORARY | CDX_TYPE_CUSTOM ) )
      case CDX_TYPE_TEMPORARY:
         PARTIAL_RYO
      case CDX_TYPE_CUSTOM:
         PARTIAL_RYO | CHGONLY_RYO
      case CDX_TYPE_TEMPORARY | CDX_TYPE_CUSTOM:
         PARTIAL_RYO | NOUPDATE_RYO
         if index key begin with:
            'SXCHAR(' or 'SXNUM(' or 'SXDATE(' or 'SXLOG('
         then
            | TEMPLATE_RYO

   sx_chill()  if ( ! NOUPDATE_RYO ) then set ( CHGONLY_RYO | PARTIAL_RYO )
                  if ( indexOpt & ( CDX_TYPE_TEMPORARY | CDX_TYPE_CUSTOM ) !=
                        CDX_TYPE_TEMPORARY | CDX_TYPE_CUSTOM )
                  {
                     indexOpt &= ~CDX_TYPE_CUSTOM;
                     indexOpt |= CDX_TYPE_TEMPORARY
                  }

   sx_warm()   if ( ! NOUPDATE_RYO ) then clear CHGONLY_RYO
                  if ( indexOpt & ( CDX_TYPE_TEMPORARY | CDX_TYPE_CUSTOM ) !=
                        CDX_TYPE_TEMPORARY | CDX_TYPE_CUSTOM )
                  {
                     indexOpt |= CDX_TYPE_CUSTOM;
                     indexOpt &= ~CDX_TYPE_TEMPORARY
                  }

   sx_freeze() set NOUPDATE_RYO
                  indexOpt |= CDX_TYPE_TEMPORARY | CDX_TYPE_CUSTOM;
*/

/* CDX index node strucutres */
/* Compact Index Header Record */
typedef struct _CDXTAGHEADER
{
   BYTE     rootPtr  [ 4 ];   /* offset of the root node */
   BYTE     freePtr  [ 4 ];   /* offset of list of free pages or -1 */
   BYTE     reserved1[ 4 ];   /* Version number ??? */
   BYTE     keySize  [ 2 ];   /* key length */
   BYTE     indexOpt;         /* index options see CDX_TYPE_* */
   BYTE     indexSig;         /* index signature */
   BYTE     reserved2[ 484 ];
   BYTE     ignoreCase[ 2 ];  /* 1 = ignore case, key converted to upper */
   BYTE     ascendFlg[ 2 ];   /* 0 = ascending  1 = descending */
   BYTE     forExpPos[ 2 ];   /* offset of filter expression */
   BYTE     forExpLen[ 2 ];   /* length of filter expression */
   BYTE     keyExpPos[ 2 ];   /* offset of key expression */
   BYTE     keyExpLen[ 2 ];   /* length of key expression */
   BYTE     keyExpPool[ CDX_HEADEREXPLEN ];
} CDXTAGHEADER;
typedef CDXTAGHEADER * LPCDXTAGHEADER;

/* Compact Index Interior Node Record */
typedef struct _CDXINTNODE
{
   BYTE     attr    [ 2 ];    /* node type see CDX_NODE_* */
   BYTE     nKeys   [ 2 ];    /* number of keys */
   BYTE     leftPtr [ 4 ];    /* offset of left node or -1 */
   BYTE     rightPtr[ 4 ];    /* offset of right node or -1 */
   BYTE     keyPool [ CDX_INT_FREESPACE ];
} CDXINTNODE;
typedef CDXINTNODE * LPCDXINTNODE;
typedef CDXINTNODE CDXNODE;
typedef CDXNODE * LPCDXNODE;

/* Compact Index Exterior Node Record */
typedef struct _CDXEXTNODE
{
   BYTE     attr    [ 2 ];    /* node type see CDX_NODE_* */
   BYTE     nKeys   [ 2 ];    /* number of keys */
   BYTE     leftPtr [ 4 ];    /* offset of left node or -1 */
   BYTE     rightPtr[ 4 ];    /* offset of right node or -1 */
   BYTE     freeSpc [ 2 ];    /* free space available in a page */
   BYTE     recMask [ 4 ];    /* record number mask */
   BYTE     dupMask;          /* duplicate bytes count mask */
   BYTE     trlMask;          /* trailing bytes count mask */
   BYTE     recBits;          /* number of bits for record number */
   BYTE     dupBits;          /* number of bits for duplicate count */
   BYTE     trlBits;          /* number of bits for trailing count */
   BYTE     keyBytes;         /* total number of bytes for recnn/dup/trail info */
   BYTE     keyPool [ CDX_EXT_FREESPACE ];      /* rec/dup/trl */
} CDXEXTNODE;
typedef CDXEXTNODE * LPCDXEXTNODE;



/* CDX internal memory structures */

struct _CDXAREA;  /* forward declaration */
struct _CDXINDEX; /* forward declaration */
struct _CDXTAG;   /* forward declaration */

typedef struct _CDXKEY
{
   BYTE *   val;
   BYTE     len;
   ULONG    rec;
} CDXKEY;
typedef CDXKEY * LPCDXKEY;

typedef struct _CDXPAGE
{
   ULONG    Page;
   ULONG    Left;
   ULONG    Right;

   BYTE     PageType;
   int      iKeys;
   int      iCurKey;

   BOOL     fChanged;
   BYTE     bUsed;

   ULONG    RNMask;
   BYTE     ReqByte;
   BYTE     RNBits;
   BYTE     DCBits;
   BYTE     TCBits;
   BYTE     DCMask;
   BYTE     TCMask;
   BOOL     fBufChanged;
   union
   {
      CDXEXTNODE extNode;
      CDXINTNODE intNode;
   } node;
   BYTE     bufKeyVal[ CDX_MAXKEY ];      /* buffer for leaf key val or added branch key */
   SHORT    bufKeyNum;                    /* do not change these vars' order             */
   SHORT    bufKeyPos;                    /* they have to be just after the node         */
   SHORT    bufKeyLen;                    /* and maybe temporary overwriten when adding  */
   SHORT    iFree;                        /* new key to interior node record.            */
   BYTE *   pKeyBuf;                      /* pointer to uncompressed leaf page key pool  */
   /* SHORT    iKeyInBuf; */

   struct _CDXPAGE * Owner;
   struct _CDXPAGE * Child;
   struct _CDXTAG  * TagParent;
   struct _CDXPAGE * pPoolPrev;
   struct _CDXPAGE * pPoolNext;
} CDXPAGE;
typedef CDXPAGE * LPCDXPAGE;

typedef struct _CDXSTACK
{
   LPCDXPAGE Page;
   int       iKey;
} CDXSTACK;
typedef CDXSTACK * LPCDXSTACK;

typedef struct _CDXLIST
{
   ULONG    ulAddr;
   BOOL     fStat;
   struct _CDXLIST * pNext;
} CDXLIST;
typedef CDXLIST * LPCDXLIST;

typedef struct _CDXTAG
{
   char *   szName;           /* Name of tag */
   char *   KeyExpr;          /* a tag key expression as text */
   char *   ForExpr;          /* a tag for expression as text */
   PHB_ITEM pKeyItem;         /* item with a macro pcode for a tag key expression */
   PHB_ITEM pForItem;         /* item with a macro pcode for a tag for expression */
   USHORT   uiType;           /* a type of key expression value */
   USHORT   uiLen;            /* length of the key expression value */
   USHORT   nField;           /* Field number for simple (one field) key expersion */
   BYTE     bTrail;           /* trailing character for shorter key value */
   BYTE     OptFlags;         /* index options flag */
   BOOL     AscendKey;        /* ascending/descending order flag */
   BOOL     UniqueKey;        /* unique order flag */
   BOOL     Temporary;        /* temporary order flag */
   BOOL     Custom;           /* custom order flag */
   BOOL     Template;         /* user keyadata in ordKeyAdd()/ordKeyDel() accepted */
   BOOL     MultiKey;         /* repeated key values in custom indexes accepted */
   BOOL     Partial;          /* order is updated only partially - missing keys possible */
   BOOL     ChgOnly;          /* only existing key modifications are updated, no new key added */
   BOOL     UsrAscend;        /* user settable ascending/descending order flag */
   BOOL     UsrUnique;        /* user settable unique order flag */

   BOOL     TagChanged;
   BOOL     TagBOF;
   BOOL     TagEOF;

   BOOL     fRePos;
   int      curKeyState;      /* see: CDX_CURKEY_* */
   ULONG    rawKeyCount;
   ULONG    rawKeyPos;
   ULONG    rawKeyRec;
   ULONG    logKeyCount;
   ULONG    logKeyPos;
   ULONG    logKeyRec;

   ULONG    TagBlock;         /* a page offset where a tag header is stored */
   ULONG    RootBlock;        /* a page offset with the root of keys tree */
   USHORT   MaxKeys;          /* maximum number of keys in Interior node */

   struct _CDXINDEX * pIndex; /* a parent index info */
   struct _CDXTAG   * pNext;  /* pointer to next tag in index */

   /* CDXSTACK  PageStack[ CDX_STACKSIZE ]; */  /* stack with page path to current key */
   LPCDXPAGE RootPage;        /* pointer to root of keys tree in memory */
   LPCDXKEY  CurKey;          /* current value of key expression */
   LPCDXKEY  HotKey;          /* value of hot key expression */
   BOOL      HotFor;          /* index FOR condition for HotKey */

   PHB_ITEM  topScope;        /* Top scope HB_ITEM */
   LPCDXKEY  topScopeKey;     /* Top scope index key */
   PHB_ITEM  bottomScope;     /* Bottom scope HB_ITEM */
   LPCDXKEY  bottomScopeKey;  /* Bottom index key */

   LPCDXPAGE pagePool;        /* page buffer in memory */
} CDXTAG;
typedef CDXTAG * LPCDXTAG;

typedef struct _CDXINDEX
{
   char *      szFileName;    /* Name of index file */
   char *      szRealName;    /* Real name of index file */
   PHB_FILE    pFile;         /* Index file handle */
   struct _CDXAREA  * pArea;  /* Parent WorkArea */
   struct _CDXINDEX * pNext;  /* The next index in the list */
   LPCDXTAG    pCompound;     /* Compound tag */
   LPCDXTAG    TagList;       /* List of tags in index file */
   BOOL        fShared;       /* Shared file */
   BOOL        fReadonly;     /* Read only file */
   BOOL        fDelete;       /* delete on close flag */
   ULONG       nextAvail;     /* offset to next free page in the end of index file */
   ULONG       freePage;      /* offset to next free page inside index file */
   LPCDXLIST   freeLst;       /* list of free pages in index file */
   int         lockWrite;     /* number of write lock set */
   int         lockRead;      /* number of read lock set */
   HB_FOFFSET  ulLockPos;     /* readlock position for CL53 lock scheme */
#ifdef HB_CDX_DBGCODE
   BOOL        RdLck;
   BOOL        WrLck;
#endif
   BOOL        fChanged;      /* changes written to index, need upadte ulVersion */
   ULONG       ulVersion;     /* network version/update flag */
   BOOL        fFlush;        /* changes written to index, need upadte ulVersion */
} CDXINDEX;
typedef CDXINDEX * LPCDXINDEX;

/* for index creation */
typedef struct
{
   HB_FOFFSET  nOffset;    /* offset in temporary file */
   ULONG       ulKeys;     /* number of keys in page */
   ULONG       ulKeyBuf;   /* number of keys in memory buffer */
   ULONG       ulCurKey;   /* current key in memory buffer */
   BYTE *      pKeyPool;   /* memory buffer */
} CDXSWAPPAGE;
typedef CDXSWAPPAGE * LPCDXSWAPPAGE;

typedef struct
{
   LPCDXTAG pTag;             /* current Tag */
   HB_FHANDLE hTempFile;      /* handle to temporary file */
   char *   szTempFileName;   /* temporary file name */
   int      keyLen;           /* key length */
   BYTE     bTrl;             /* filler char for shorter keys */
   BOOL     fUnique;          /* TRUE if index is unique */
   BOOL     fReindex;         /* TRUE if reindexing is in process */
   ULONG    ulMaxRec;         /* the highest record number */
   ULONG    ulTotKeys;        /* total number of keys indexed */
   ULONG    ulKeys;           /* keys in curently created page */
   ULONG    ulPages;          /* number of pages */
   ULONG    ulCurPage;        /* current page */
   ULONG    ulPgKeys;         /* maximum number of key in page memory buffer */
   ULONG    ulMaxKey;         /* maximum number of keys in single page */
   BYTE *   pKeyPool;         /* memory buffer for current page then for pages */
   LPCDXSWAPPAGE pSwapPage;   /* list of pages */
   LPCDXPAGE NodeList[ CDX_STACKSIZE ];   /* Stack of pages */
   ULONG    ulFirst;
   ULONG *  pSortedPages;
   BYTE     pLastKey[ CDX_MAXKEY ]; /* last key val */
   ULONG    ulLastRec;
   BYTE *   pRecBuff;
#ifndef HB_CDX_PACKTRAIL
   int      iLastTrl;         /* last key trailing spaces */
#endif
} CDXSORTINFO;
typedef CDXSORTINFO * LPCDXSORTINFO;



/*
 *  DBF WORKAREA
 *  ------------
 *  The Workarea Structure of DBFCDX RDD
 *
 */

typedef struct _CDXAREA
{
   struct _RDDFUNCS * lprfsHost; /* Virtual method table for this workarea */
   USHORT uiArea;                /* The number assigned to this workarea */
   void * atomAlias;             /* Pointer to the alias symbol for this workarea */
   USHORT uiFieldExtent;         /* Total number of fields allocated */
   USHORT uiFieldCount;          /* Total number of fields used */
   LPFIELD lpFields;             /* Pointer to an array of fields */
   void * lpFieldExtents;        /* Void ptr for additional field properties */
   PHB_ITEM valResult;           /* All purpose result holder */
   BOOL fTop;                    /* TRUE if "top" */
   BOOL fBottom;                 /* TRUE if "bottom" */
   BOOL fBof;                    /* TRUE if "bof" */
   BOOL fEof;                    /* TRUE if "eof" */
   BOOL fFound;                  /* TRUE if "found" */
   DBSCOPEINFO dbsi;             /* Info regarding last LOCATE */
   DBFILTERINFO dbfi;            /* Filter in effect */
   LPDBORDERCONDINFO lpdbOrdCondInfo;
   LPDBRELINFO lpdbRelations;    /* Parent/Child relationships used */
   USHORT uiParents;             /* Number of parents for this area */
   USHORT heap;
   USHORT heapSize;
   USHORT rddID;
   USHORT uiMaxFieldNameLength;
   PHB_CODEPAGE cdPage;          /* Area's codepage pointer */

   /*
   *  DBFS's additions to the workarea structure
   *
   *  Warning: The above section MUST match WORKAREA exactly!  Any
   *  additions to the structure MUST be added below, as in this
   *  example.
   */

   PHB_FILE pDataFile;              /* Data file handle */
   PHB_FILE pMemoFile;              /* Memo file handle */
   PHB_FILE pMemoTmpFile;           /* Memo temporary file handle */
   char *   szDataFileName;         /* Name of data file */
   char *   szMemoFileName;         /* Name of memo file */
   USHORT   uiHeaderLen;            /* Size of header */
   USHORT   uiRecordLen;            /* Size of record */
   USHORT   uiMemoBlockSize;        /* Size of memo block */
   USHORT   uiNewBlockSize;         /* Size of new memo block */
   USHORT   uiMemoVersion;          /* MEMO file version */
   USHORT   uiDirtyRead;            /* Index dirty read bit filed */
   BYTE     bTableType;             /* DBF type */
   BYTE     bMemoType;              /* MEMO type used in DBF memo fields */
   BYTE     bLockType;              /* Type of locking shemes */
   BYTE     bCryptType;             /* Type of used encryption */
   DBFHEADER dbfHeader;             /* DBF header buffer */
   USHORT * pFieldOffset;           /* Pointer to field offset array */
   BYTE *   pRecord;                /* Buffer of record data */
   ULONG    ulRecCount;             /* Total records */
   ULONG    ulRecNo;                /* Current record */
   BOOL     fAutoInc;               /* WorkArea with auto increment fields */
   BOOL     fHasMemo;               /* WorkArea with Memo fields */
   BOOL     fHasTags;               /* WorkArea with MDX or CDX index */
   BOOL     fModStamp;              /* WorkArea with modification autoupdate fields */
   BOOL     fDataFlush;             /* data was written to DBF and not commited */
   BOOL     fMemoFlush;             /* data was written to MEMO and not commited */
   BOOL     fShared;                /* Shared file */
   BOOL     fReadonly;              /* Read only file */
   BOOL     fValidBuffer;           /* State of buffer */
   BOOL     fPositioned;            /* Positioned record */
   BOOL     fRecordChanged;         /* Record changed */
   BOOL     fAppend;                /* TRUE if new record is added */
   BOOL     fDeleted;               /* TRUE if record is deleted */
   BOOL     fEncrypted;             /* TRUE if record is encrypted */
   BOOL     fTableEncrypted;        /* TRUE if table is encrypted */
   BOOL     fUpdateHeader;          /* Update header of file */
   BOOL     fFLocked;               /* TRUE if file is locked */
   BOOL     fHeaderLocked;          /* TRUE if DBF header is locked */
   BOOL     fPackMemo;              /* Pack memo file in pack operation */
   BOOL     fTrigger;               /* Execute trigger function */
   LPDBOPENINFO lpdbOpenInfo;       /* Pointer to current dbOpenInfo structure in OPEN/CREATE methods */
   LPDBRELINFO lpdbPendingRel;      /* Pointer to parent rel struct */
   ULONG *  pLocksPos;              /* List of records locked */
   ULONG    ulNumLocksPos;          /* Number of records locked */
   BYTE *   pCryptKey;              /* Pointer to encryption key */
   PHB_DYNS pTriggerSym;            /* DynSym pointer to trigger function */

   /*
   *  CDX's additions to the workarea structure
   *
   *  Warning: The above section MUST match DBFAREA exactly! Any
   *  additions to the structure MUST be added below, as in this
   *  example.
   */

   BOOL           fCdxAppend;    /* Appended record changed */
   LPCDXINDEX     lpIndexes;     /* Pointer to indexes array  */
   USHORT         uiTag;         /* current tag focus */
   LPCDXSORTINFO  pSort;         /* Index build structure */
   BYTE *         bCdxSortTab;   /* Table with storted characters */

} CDXAREA;

typedef CDXAREA * LPCDXAREA;

#ifndef CDXAREAP
#define CDXAREAP LPCDXAREA
#endif


/*
 * -- DBFCDX METHODS --
 */

#define SUPERTABLE                         ( &cdxSuper )

#define hb_cdxBof                                  NULL
#define hb_cdxEof                                  NULL
#define hb_cdxFound                                NULL
static ERRCODE hb_cdxGoBottom( CDXAREAP pArea );
#define hb_cdxGoTo                                 NULL
#define hb_cdxGoToId                               NULL
static ERRCODE hb_cdxGoTop( CDXAREAP pArea );
static ERRCODE hb_cdxSeek( CDXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLast );
static ERRCODE hb_cdxSkip( CDXAREAP pArea, LONG lToSkip );
#define hb_cdxSkipFilter                           NULL
static ERRCODE hb_cdxSkipRaw( CDXAREAP pArea, LONG lToSkip );
#define hb_cdxAddField                             NULL
#define hb_cdxAppend                               NULL
#define hb_cdxCreateFields                         NULL
#define hb_cdxDeleteRec                            NULL
#define hb_cdxDeleted                              NULL
#define hb_cdxFieldCount                           NULL
#define hb_cdxFieldDisplay                         NULL
#define hb_cdxFieldInfo                            NULL
#define hb_cdxFieldName                            NULL
static ERRCODE hb_cdxFlush( CDXAREAP pArea );
#define hb_cdxGetRec                               NULL
#define hb_cdxGetValue                             NULL
#define hb_cdxGetVarLen                            NULL
static ERRCODE hb_cdxGoCold( CDXAREAP pArea );
static ERRCODE hb_cdxGoHot( CDXAREAP pArea );
#define hb_cdxPutRec                               NULL
#define hb_cdxPutValue                             NULL
#define hb_cdxRecall                               NULL
#define hb_cdxRecCount                             NULL
#define hb_cdxRecInfo                              NULL
#define hb_cdxRecNo                                NULL
#define hb_cdxRecId                                NULL
#define hb_cdxSetFieldExtent                       NULL
#define hb_cdxAlias                                NULL
static ERRCODE hb_cdxClose( CDXAREAP pArea );
#define hb_cdxCreate                               NULL
#define hb_cdxInfo                                 NULL
#define hb_cdxNewArea                              NULL
static ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo );
#define hb_cdxRelease                              NULL
static ERRCODE hb_cdxStructSize( CDXAREAP pArea, USHORT * uiSize );
#define hb_cdxSysName                              NULL
#define hb_cdxEval                                 NULL
static ERRCODE hb_cdxPack ( CDXAREAP pArea );
#define hb_cdxPackRec                              NULL
#define hb_cdxSort                                 NULL
#define hb_cdxTrans                                NULL
#define hb_cdxTransRec                             NULL
static ERRCODE hb_cdxZap ( CDXAREAP pArea );
#define hb_cdxChildEnd                             NULL
#define hb_cdxChildStart                           NULL
#define hb_cdxChildSync                            NULL
#define hb_cdxSyncChildren                         NULL
#define hb_cdxClearRel                             NULL
#define hb_cdxForceRel                             NULL
#define hb_cdxRelArea                              NULL
#define hb_cdxRelEval                              NULL
#define hb_cdxRelText                              NULL
#define hb_cdxSetRel                               NULL
static ERRCODE hb_cdxOrderListAdd( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
static ERRCODE hb_cdxOrderListClear( CDXAREAP pArea );
static ERRCODE hb_cdxOrderListDelete( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
static ERRCODE hb_cdxOrderListFocus( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
static ERRCODE hb_cdxOrderListRebuild( CDXAREAP pArea );
#define hb_cdxOrderCondition                       NULL
static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo );
static ERRCODE hb_cdxOrderDestroy( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
static ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrderInfo );
static ERRCODE hb_cdxClearFilter( CDXAREAP pArea );
#define hb_cdxClearLocate                          NULL
#define hb_cdxClearScope                           NULL
static ERRCODE hb_cdxCountScope( CDXAREAP pArea, void * pPtr, LONG * plRec );
#define hb_cdxFilterText                           NULL
#define hb_cdxScopeInfo                            NULL
static ERRCODE hb_cdxSetFilter( CDXAREAP pArea, LPDBFILTERINFO pFilterInfo );
#define hb_cdxSetLocate                            NULL
#define hb_cdxSetScope                             NULL
#define hb_cdxSkipScope                            NULL
#define hb_cdxLocate                               NULL
#define hb_cdxCompile                              NULL
#define hb_cdxError                                NULL
#define hb_cdxEvalBlock                            NULL
#define hb_cdxRawLock                              NULL
#define hb_cdxLock                                 NULL
#define hb_cdxUnLock                               NULL
#define hb_cdxCloseMemFile                         NULL
#define hb_cdxCreateMemFile                        NULL
#define hb_cdxGetValueFile                         NULL
#define hb_cdxOpenMemFile                          NULL
#define hb_cdxPutValueFile                         NULL
#define hb_cdxReadDBHeader                         NULL
#define hb_cdxWriteDBHeader                        NULL
#define hb_cdxInit                                 NULL
#define hb_cdxExit                                 NULL
#define hb_cdxDrop                                 NULL
#define hb_cdxExists                               NULL
static ERRCODE hb_cdxRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, PHB_ITEM pItem );
#define hb_cdxWhoCares                             NULL

HB_EXTERN_END

#endif /* HB_RDDCDX_H_ */
c:\harbour\include\hbrdddbf.h
/*
 * $Id: hbrdddbf.h 9530 2008-10-02 12:34:36Z druzus $
 */

/*
 * Harbour Project source code:
 * DBF RDD module
 *
 * Copyright 1999 Bruno Cantero 
 * 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.
 *
 */

#ifndef HB_RDDDBF_H_
#define HB_RDDDBF_H_

#include "hbapirdd.h"
#include "hbdbferr.h"
#include "hbdbf.h"

HB_EXTERN_BEGIN

/* DBF default file extensions */
#define DBF_TABLEEXT                      ".dbf"

/* DBF locking schemes */
#define DBF_LOCKPOS_CLIP                  1000000000UL
#define DBF_LOCKPOS_CL53                  1000000000UL
#define DBF_LOCKPOS_VFP                   0x40000000UL
#define DBF_LOCKPOS_VFPX                  0x7ffffffeUL
#define DBF_LOCKPOS_CL53EXT               4000000000UL
#define DBF_LOCKPOS_XHB64                 HB_LL( 0x7FFFFFFF00000001 )

#define DBF_LOCKDIR_CLIP                  1
#define DBF_LOCKDIR_CL53                  1
#define DBF_LOCKDIR_VFP                   2  /* lock forward at at record offset */
#define DBF_LOCKDIR_VFPX                  -1
#define DBF_LOCKDIR_CL53EXT               1
#define DBF_LOCKDIR_XHB64                 1

#define DBF_FLCKSIZE_CLIP                 1000000000UL
#define DBF_FLCKSIZE_CL53                 1000000000UL
#define DBF_FLCKSIZE_VFP                  0x3ffffffdUL
#define DBF_FLCKSIZE_VFPX                 0x07ffffffUL
#define DBF_FLCKSIZE_CL53EXT              294967295UL
#define DBF_FLCKSIZE_XHB64                0x7ffffffeUL

#define DBF_RLCKSIZE_CLIP                 1UL
#define DBF_RLCKSIZE_CL53                 1UL
#define DBF_RLCKSIZE_VFP                  1UL
#define DBF_RLCKSIZE_VFPX                 1UL
#define DBF_RLCKSIZE_CL53EXT              1UL
#define DBF_RLCKSIZE_XHB64                1UL

#define IDX_LOCKPOS_CLIP                  1000000000UL
#define IDX_LOCKPOS_CL53                  0xfffeffffUL
#define IDX_LOCKPOS_VFP                   0x7ffffffeUL
#define IDX_LOCKPOS_CL53EXT               0xfffeffffUL
#define IDX_LOCKPOS_XHB64                 HB_LL( 0x7FFFFFFF00000001 )

#define IDX_LOCKPOOL_CLIP                 0UL
#define IDX_LOCKPOOL_CL53                 0x00010000UL
#define IDX_LOCKPOOL_VFP                  0UL
#define IDX_LOCKPOOL_CL53EXT              0x00010000UL
#define IDX_LOCKPOOL_XHB64                0UL


/* Index dirty read flags */
#define HB_IDXREAD_CLEAN      0
#define HB_IDXREAD_DEFAULT    1
#define HB_IDXREAD_DIRTY      2

#define HB_IDXREAD_CLEANMASK  HB_IDXREAD_DIRTY
#define HB_IDXREAD_DIRTYMASK  (HB_IDXREAD_DIRTY|HB_IDXREAD_DEFAULT)

#define HB_DIRTYREAD(w)       ( ( ( ( LPDBFDATA ) SELF_RDDNODE( w )-> \
                                    lpvCargo )->uiDirtyRead & \
                                           (w)->uiDirtyRead ) != 0 )


/*
 * Private DBF* RDD data kept in RDDNODE
 */
typedef struct _DBFDATA
{
   char     szTableExt[ HB_MAX_FILE_EXT + 1 ];
   char     szIndexExt[ HB_MAX_FILE_EXT + 1 ];
   char     szMemoExt[ HB_MAX_FILE_EXT + 1 ];

   char *   szPasswd;
   char *   szPendingPasswd;
   char *   szTrigger;
   char *   szPendingTrigger;

   BYTE     bLockType;        /* 0 */
   BYTE     bTableType;       /* DB_DBF_STD */
   BYTE     bCryptType;       /* DB_CRYPT_NONE */
   BYTE     bMemoType;        /* DB_MEMO_FPT */
   BYTE     bMemoExtType;     /* DB_MEMOVER_FLEX */
   USHORT   uiDirtyRead;      /* HB_IDXREAD_CLEANMASK */
   USHORT   uiMemoBlockSize;  /* 0 */

   BOOL     fSortRecNo;
   BOOL     fMultiKey;
   BOOL     fStruct;
   BOOL     fStrictStruct;
   BOOL     fMultiTag;
} DBFDATA;

typedef DBFDATA * LPDBFDATA;



/*
 *  DBF WORKAREA
 *  ------------
 *  The Workarea Structure of DBF RDD
 *
 */

typedef struct _DBFAREA
{
   struct _RDDFUNCS * lprfsHost; /* Virtual method table for this workarea */
   USHORT uiArea;                /* The number assigned to this workarea */
   void * atomAlias;             /* Pointer to the alias symbol for this workarea */
   USHORT uiFieldExtent;         /* Total number of fields allocated */
   USHORT uiFieldCount;          /* Total number of fields used */
   LPFIELD lpFields;             /* Pointer to an array of fields */
   void * lpFieldExtents;        /* Void ptr for additional field properties */
   PHB_ITEM valResult;           /* All purpose result holder */
   BOOL fTop;                    /* TRUE if "top" */
   BOOL fBottom;                 /* TRUE if "bottom" */
   BOOL fBof;                    /* TRUE if "bof" */
   BOOL fEof;                    /* TRUE if "eof" */
   BOOL fFound;                  /* TRUE if "found" */
   DBSCOPEINFO dbsi;             /* Info regarding last LOCATE */
   DBFILTERINFO dbfi;            /* Filter in effect */
   LPDBORDERCONDINFO lpdbOrdCondInfo;
   LPDBRELINFO lpdbRelations;    /* Parent/Child relationships used */
   USHORT uiParents;             /* Number of parents for this area */
   USHORT heap;
   USHORT heapSize;
   USHORT rddID;
   USHORT uiMaxFieldNameLength;
   PHB_CODEPAGE cdPage;          /* Area's codepage pointer */

   /*
   *  DBFS's additions to the workarea structure
   *
   *  Warning: The above section MUST match WORKAREA exactly!  Any
   *  additions to the structure MUST be added below, as in this
   *  example.
   */

   PHB_FILE pDataFile;              /* Data file handle */
   PHB_FILE pMemoFile;              /* Memo file handle */
   PHB_FILE pMemoTmpFile;           /* Memo temporary file handle */
   char *   szDataFileName;         /* Name of data file */
   char *   szMemoFileName;         /* Name of memo file */
   USHORT   uiHeaderLen;            /* Size of header */
   USHORT   uiRecordLen;            /* Size of record */
   USHORT   uiMemoBlockSize;        /* Size of memo block */
   USHORT   uiNewBlockSize;         /* Size of new memo block */
   USHORT   uiMemoVersion;          /* MEMO file version */
   USHORT   uiDirtyRead;            /* Index dirty read bit filed */
   BYTE     bTableType;             /* DBF type */
   BYTE     bMemoType;              /* MEMO type used in DBF memo fields */
   BYTE     bLockType;              /* Type of locking shemes */
   BYTE     bCryptType;             /* Type of used encryption */
   DBFHEADER dbfHeader;             /* DBF header buffer */
   USHORT * pFieldOffset;           /* Pointer to field offset array */
   BYTE *   pRecord;                /* Buffer of record data */
   ULONG    ulRecCount;             /* Total records */
   ULONG    ulRecNo;                /* Current record */
   BOOL     fAutoInc;               /* WorkArea with auto increment fields */
   BOOL     fHasMemo;               /* WorkArea with Memo fields */
   BOOL     fHasTags;               /* WorkArea with MDX or CDX index */
   BOOL     fModStamp;              /* WorkArea with modification autoupdate fields */
   BOOL     fDataFlush;             /* data was written to DBF and not commited */
   BOOL     fMemoFlush;             /* data was written to MEMO and not commited */
   BOOL     fShared;                /* Shared file */
   BOOL     fReadonly;              /* Read only file */
   BOOL     fValidBuffer;           /* State of buffer */
   BOOL     fPositioned;            /* Positioned record */
   BOOL     fRecordChanged;         /* Record changed */
   BOOL     fAppend;                /* TRUE if new record is added */
   BOOL     fDeleted;               /* TRUE if record is deleted */
   BOOL     fEncrypted;             /* TRUE if record is encrypted */
   BOOL     fTableEncrypted;        /* TRUE if table is encrypted */
   BOOL     fUpdateHeader;          /* Update header of file */
   BOOL     fFLocked;               /* TRUE if file is locked */
   BOOL     fHeaderLocked;          /* TRUE if DBF header is locked */
   BOOL     fPackMemo;              /* Pack memo file in pack operation */
   BOOL     fTrigger;               /* Execute trigger function */
   LPDBOPENINFO lpdbOpenInfo;       /* Pointer to current dbOpenInfo structure in OPEN/CREATE methods */
   LPDBRELINFO lpdbPendingRel;      /* Pointer to parent rel struct */
   ULONG *  pLocksPos;              /* List of records locked */
   ULONG    ulNumLocksPos;          /* Number of records locked */
   BYTE *   pCryptKey;              /* Pointer to encryption key */
   PHB_DYNS pTriggerSym;            /* DynSym pointer to trigger function */
} DBFAREA;

typedef DBFAREA * LPDBFAREA;

#ifndef DBFAREAP
#define DBFAREAP LPDBFAREA
#endif

#ifndef HB_EXTERNAL_RDDDBF_USE

/*
 * -- DBF METHODS --
 */

#define SUPERTABLE                         ( &dbfSuper )

static ERRCODE hb_dbfBof( DBFAREAP pArea, BOOL * pBof );
static ERRCODE hb_dbfEof( DBFAREAP pArea, BOOL * pEof );
static ERRCODE hb_dbfFound( DBFAREAP pArea, BOOL * pFound );
static ERRCODE hb_dbfGoBottom( DBFAREAP pArea );
static ERRCODE hb_dbfGoTo( DBFAREAP pArea, ULONG ulRecNo );
static ERRCODE hb_dbfGoToId( DBFAREAP pArea, PHB_ITEM pItem );
static ERRCODE hb_dbfGoTop( DBFAREAP pArea );
#define hb_dbfSeek                                 NULL
static ERRCODE hb_dbfSkip( DBFAREAP pArea, LONG lToSkip );
#define hb_dbfSkipFilter                           NULL
static ERRCODE hb_dbfSkipRaw( DBFAREAP pArea, LONG lToSkip );
static ERRCODE hb_dbfAddField( DBFAREAP pArea, LPDBFIELDINFO pFieldInfo );
static ERRCODE hb_dbfAppend( DBFAREAP pArea, BOOL bUnLockAll );
#define hb_dbfCreateFields                         NULL
static ERRCODE hb_dbfDeleteRec( DBFAREAP pArea );
static ERRCODE hb_dbfDeleted( DBFAREAP pArea, BOOL * pDeleted );
#define hb_dbfFieldCount                           NULL
#define hb_dbfFieldDisplay                         NULL
#define hb_dbfFieldInfo                            NULL
#define hb_dbfFieldName                            NULL
static ERRCODE hb_dbfFlush( DBFAREAP pArea );
static ERRCODE hb_dbfGetRec( DBFAREAP pArea, BYTE ** pBuffer );
static ERRCODE hb_dbfGetValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
static ERRCODE hb_dbfGetVarLen( DBFAREAP pArea, USHORT uiIndex, ULONG * pLength );
static ERRCODE hb_dbfGoCold( DBFAREAP pArea );
static ERRCODE hb_dbfGoHot( DBFAREAP pArea );
static ERRCODE hb_dbfPutRec( DBFAREAP pArea, BYTE * pBuffer );
static ERRCODE hb_dbfPutValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
static ERRCODE hb_dbfRecall( DBFAREAP pArea );
static ERRCODE hb_dbfRecCount( DBFAREAP pArea, ULONG * pRecCount );
static ERRCODE hb_dbfRecInfo( DBFAREAP pArea, PHB_ITEM pRecID, USHORT uiInfoType, PHB_ITEM pInfo );
static ERRCODE hb_dbfRecNo( DBFAREAP pArea, ULONG * pRecNo );
static ERRCODE hb_dbfRecId( DBFAREAP pArea, PHB_ITEM pRecNo );
static ERRCODE hb_dbfSetFieldExtent( DBFAREAP pArea, USHORT uiFieldExtent );
#define hb_dbfAlias                                NULL
static ERRCODE hb_dbfClose( DBFAREAP pArea );
static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo );
static ERRCODE hb_dbfInfo( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
static ERRCODE hb_dbfNewArea( DBFAREAP pArea );
static ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo );
#define hb_dbfRelease                              NULL
static ERRCODE hb_dbfStructSize( DBFAREAP pArea, USHORT * uiSize );
#define hb_dbfSysName                              NULL
#define hb_dbfEval                                 NULL
static ERRCODE hb_dbfPack( DBFAREAP pArea );
static ERRCODE hb_dbfPackRec( DBFAREAP pArea, ULONG ulRecNo, BOOL *fWritten );
static ERRCODE hb_dbfSort( DBFAREAP pArea, LPDBSORTINFO pSortInfo );
static ERRCODE hb_dbfTrans( DBFAREAP pArea, LPDBTRANSINFO pTransInfo );
#define hb_dbfTransRec                             NULL
static ERRCODE hb_dbfZap( DBFAREAP pArea );
static ERRCODE hb_dbfChildEnd( DBFAREAP pArea, LPDBRELINFO pRelInfo );
static ERRCODE hb_dbfChildStart( DBFAREAP pArea, LPDBRELINFO pRelInfo );
static ERRCODE hb_dbfChildSync( DBFAREAP pArea, LPDBRELINFO pRelInfo );
#define hb_dbfSyncChildren                         NULL
#define hb_dbfClearRel                             NULL
static ERRCODE hb_dbfForceRel( DBFAREAP pArea );
#define hb_dbfRelArea                              NULL
#define hb_dbfRelEval                              NULL
#define hb_dbfRelText                              NULL
#define hb_dbfSetRel                               NULL
#define hb_dbfOrderListAdd                         NULL
#define hb_dbfOrderListClear                       NULL
#define hb_dbfOrderListDelete                      NULL
#define hb_dbfOrderListFocus                       NULL
#define hb_dbfOrderListRebuild                     NULL
#define hb_dbfOrderCondition                       NULL
#define hb_dbfOrderCreate                          NULL
#define hb_dbfOrderDestroy                         NULL
#define hb_dbfOrderInfo                            NULL
#define hb_dbfClearFilter                          NULL
#define hb_dbfClearLocate                          NULL
#define hb_dbfClearScope                           NULL
#define hb_dbfCountScope                           NULL
#define hb_dbfFilterText                           NULL
#define hb_dbfScopeInfo                            NULL
static ERRCODE hb_dbfSetFilter( DBFAREAP pArea, LPDBFILTERINFO pFilterInfo );
#define hb_dbfSetLocate                            NULL
#define hb_dbfSetScope                             NULL
#define hb_dbfSkipScope                            NULL
#define hb_dbfLocate                               NULL
#define hb_dbfCompile                              NULL
#define hb_dbfError                                NULL
#define hb_dbfEvalBlock                            NULL
static ERRCODE hb_dbfRawLock( DBFAREAP pArea, USHORT uiAction, ULONG lRecNo );
static ERRCODE hb_dbfLock( DBFAREAP pArea, LPDBLOCKINFO pLockInfo );
static ERRCODE hb_dbfUnLock( DBFAREAP pArea, PHB_ITEM pRecNo );
#define hb_dbfCloseMemFile                         NULL
static ERRCODE hb_dbfCreateMemFile( DBFAREAP pArea, LPDBOPENINFO pCreateInfo );
static ERRCODE hb_dbfGetValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode );
static ERRCODE hb_dbfOpenMemFile( DBFAREAP pArea, LPDBOPENINFO pOpenInfo );
static ERRCODE hb_dbfPutValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode );

static ERRCODE hb_dbfReadDBHeader( DBFAREAP pArea );
static ERRCODE hb_dbfWriteDBHeader( DBFAREAP pArea );

static ERRCODE hb_dbfInit( LPRDDNODE pRDD );
static ERRCODE hb_dbfExit( LPRDDNODE pRDD );
static ERRCODE hb_dbfDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItemIndex, ULONG ulConnect );
static ERRCODE hb_dbfExists( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItemIndex, ULONG ulConnect );
static ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, PHB_ITEM pItem );

#define hb_dbfWhoCares                             NULL

#endif /* HB_EXTERNAL_RDDDBF_USE */

extern HB_EXPORT ULONG   hb_dbfGetMemoBlock( DBFAREAP pArea, USHORT uiIndex );
extern HB_EXPORT void    hb_dbfPutMemoBlock( DBFAREAP pArea, USHORT uiIndex,
                                             ULONG ulBlock );
extern HB_EXPORT ERRCODE hb_dbfGetMemoData( DBFAREAP pArea, USHORT uiIndex,
                                            ULONG * pulBlock, ULONG * pulSize,
                                            ULONG * pulType );
extern HB_EXPORT ERRCODE hb_dbfSetMemoData( DBFAREAP pArea, USHORT uiIndex,
                                            ULONG ulBlock, ULONG ulSize,
                                            ULONG ulType );
extern HB_EXPORT ERRCODE hb_dbfGetEGcode( ERRCODE errCode );
extern HB_EXPORT BOOL    hb_dbfLockIdxFile( PHB_FILE pFile, BYTE bScheme, USHORT usMode, HB_FOFFSET *pPoolPos );
extern HB_EXPORT BOOL    hb_dbfLockIdxGetData( BYTE bScheme, HB_FOFFSET *ulPos, HB_FOFFSET *ulPool );

#ifndef HB_CDP_SUPPORT_OFF
extern HB_EXPORT void hb_dbfTranslateRec( DBFAREAP pArea, BYTE * pBuffer, PHB_CODEPAGE cdp_src, PHB_CODEPAGE cdp_dest );
#endif

HB_EXTERN_END

#endif /* HB_RDDDBF_H_ */
c:\harbour\include\hbrdddel.h
/*
 * $Id: hbrdddel.h 9530 2008-10-02 12:34:36Z druzus $
 */

/*
 * Harbour Project source code:
 *    DELIM RDD
 *
 * Copyright 2006 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_RDDDEL_H_
#define HB_RDDDEL_H_

#include "hbapirdd.h"

HB_EXTERN_BEGIN

/* DELIMITED default file extensions */
#define DELIM_TABLEEXT                    ".txt"


/*
 *  DELIM WORKAREA
 *  ------------
 *  The Workarea Structure of DELIM RDD
 *
 */

typedef struct _DELIMAREA
{
   struct _RDDFUNCS * lprfsHost; /* Virtual method table for this workarea */
   USHORT uiArea;                /* The number assigned to this workarea */
   void * atomAlias;             /* Pointer to the alias symbol for this workarea */
   USHORT uiFieldExtent;         /* Total number of fields allocated */
   USHORT uiFieldCount;          /* Total number of fields used */
   LPFIELD lpFields;             /* Pointer to an array of fields */
   void * lpFieldExtents;        /* Void ptr for additional field properties */
   PHB_ITEM valResult;           /* All purpose result holder */
   BOOL fTop;                    /* TRUE if "top" */
   BOOL fBottom;                 /* TRUE if "bottom" */
   BOOL fBof;                    /* TRUE if "bof" */
   BOOL fEof;                    /* TRUE if "eof" */
   BOOL fFound;                  /* TRUE if "found" */
   DBSCOPEINFO dbsi;             /* Info regarding last LOCATE */
   DBFILTERINFO dbfi;            /* Filter in effect */
   LPDBORDERCONDINFO lpdbOrdCondInfo;
   LPDBRELINFO lpdbRelations;    /* Parent/Child relationships used */
   USHORT uiParents;             /* Number of parents for this area */
   USHORT heap;
   USHORT heapSize;
   USHORT rddID;
   USHORT uiMaxFieldNameLength;
   PHB_CODEPAGE cdPage;          /* Area's codepage pointer */

   /*
   *  DELIM's additions to the workarea structure
   *
   *  Warning: The above section MUST match WORKAREA exactly!  Any
   *  additions to the structure MUST be added below, as in this
   *  example.
   */

   PHB_FILE pFile;                  /* Data file handle */
   char *   szFileName;             /* Name of data file */
   char *   szEol;                  /* EOL marker */
   USHORT   uiEolLen;               /* Size of EOL marker */
   char     cDelim;                 /* Character field delimiter */
   char     cSeparator;             /* Field separator */
   USHORT   uiRecordLen;            /* Size of record */
   USHORT * pFieldOffset;           /* Pointer to field offset array */
   BYTE *   pRecord;                /* Buffer of record data */
   BYTE *   pBuffer;                /* Read/Write */
   ULONG    ulBufferSize;           /* IO buffer size */
   ULONG    ulBufferRead;           /* Number of bytes in read buffer */
   ULONG    ulBufferIndex;          /* Index to read read buffer */
   HB_FOFFSET ulRecordOffset;       /* Current record offest */
   HB_FOFFSET ulNextOffset;         /* Next record offest */
   HB_FOFFSET ulFileSize;           /* File table size in export mode */
   HB_FOFFSET ulBufferStart;        /* Start offset of read buffer */
   ULONG    ulRecNo;                /* Current record */
   ULONG    ulRecCount;             /* Number of records (in export) */
   BOOL     fTransRec;              /* Can put whole records */
   BOOL     fFlush;                 /* Data was written to table and not commited */
   BOOL     fShared;                /* Shared file */
   BOOL     fReadonly;              /* Read only file */
   BOOL     fPositioned;            /* Positioned record */
   BOOL     fRecordChanged;         /* Record changed */
} DELIMAREA;

typedef DELIMAREA * LPDELIMAREA;

#ifndef DELIMAREAP
#define DELIMAREAP LPDELIMAREA
#endif

HB_EXTERN_END

#endif /* HB_RDDDEL_H_ */
c:\harbour\include\hbrddfpt.h
/*
 * $Id: hbrddfpt.h 7838 2007-10-18 21:55:39Z druzus $
 */

/*
 * xHarbour Project source code:
 * DBFFPT RDD
 *
 * Copyright 2003 Przemyslaw Czerpak 
 * www - http://www.xharbour.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.
 *
 */

#ifndef HB_RDDFPT_H_
#define HB_RDDFPT_H_

#include "hbdbf.h"
#include "hbdbferr.h"
#include "hbapirdd.h"
#define HB_EXTERNAL_RDDDBF_USE
#include "hbrdddbf.h"

HB_EXTERN_BEGIN

/* MEMO constants and defaults */
#define DBT_MEMOEXT                          ".dbt"
#define FPT_MEMOEXT                          ".fpt"
#define SMT_MEMOEXT                          ".smt"
#define DBV_MEMOEXT                          ".dbv"
#define DBT_DEFBLOCKSIZE                        512
#define FPT_DEFBLOCKSIZE                         64
#define SMT_DEFBLOCKSIZE                         32

#define FPT_LOCKPOS                     0x00000000L
#define FPT_LOCKSIZE                    0x00000001L

#define FPT_ROOTBLOCK_OFFSET                  0x218 /* Clipper 5.3 ROOT data block offset */

#define SIX_ITEM_BUFSIZE                         14
#define FLEX_ITEM_BUFSIZE                         8
#define MAX_SIXFREEBLOCKS                        82
#define MAX_FLEXFREEBLOCKS                      126
#define FLEXGCPAGE_SIZE                        1010

/* "V" filed types */
#define HB_VF_CHAR            64000
#define HB_VF_DATE            64001
#define HB_VF_INT             64002
#define HB_VF_LOG             64003
#define HB_VF_DNUM            64004
#define HB_VF_ARRAY           64005
#define HB_VF_BLOB            64006
#define HB_VF_BLOBCOMPRESS    64007
#define HB_VF_BLOBENCRYPT     64008

/* SMT types */
#define SMT_IT_NIL            0
#define SMT_IT_CHAR           1
#define SMT_IT_INT            2
#define SMT_IT_DOUBLE         3
#define SMT_IT_DATE           4
#define SMT_IT_LOGICAL        5
#define SMT_IT_ARRAY          6

#define FPTIT_DUMMY        0xDEADBEAF
#define FPTIT_BINARY       0x0000
#define FPTIT_PICT         0x0000      /* Picture */
#define FPTIT_TEXT         0x0001      /* Text    */
#define FPTIT_OBJ          0x0002      /* Object  */

#define FPTIT_SIX_NIL      0x0000      /* NIL VALUE (USED ONLY IN ARRAYS) */
#define FPTIT_SIX_LNUM     0x0002      /* LONG LE */
#define FPTIT_SIX_DNUM     0x0008      /* DOUBLE LE */
#define FPTIT_SIX_LDATE    0x0020      /* DATE (LONG LE) */
#define FPTIT_SIX_LOG      0x0080      /* LOGIC */
#define FPTIT_SIX_CHAR     0x0400      /* CHAR */
#define FPTIT_SIX_ARRAY    0x8000      /* ARRAY */

/* #define FPTIT_SIX_BLOCK    0x1000 */
/* #define FPTIT_SIX_VREF     0x2000 */
/* #define FPTIT_SIX_MREF     0x4000 */

#define FPTIT_FLEX_GC      0x03E8   /* 1000   */
#define FPTIT_FLEX_UNUSED  0x03E9   /* 1001   */
#define FPTIT_FLEX_ARRAY   0x03EA   /* 1002   */
#define FPTIT_FLEX_OBJECT  0x03EB   /* 1003 ! */
#define FPTIT_FLEX_VOARR   0x03EC   /* 1004 ! */
#define FPTIT_FLEX_VOOBJ   0x03ED   /* 1005 ! */
#define FPTIT_FLEX_NIL     0x03EE   /* 1006   */
#define FPTIT_FLEX_TRUE    0x03EF   /* 1007   */
#define FPTIT_FLEX_FALSE   0x03F0   /* 1008   */
#define FPTIT_FLEX_LDATE   0x03F1   /* 1009   */
#define FPTIT_FLEX_CHAR    0x03F2   /* 1010   */
#define FPTIT_FLEX_UCHAR   0x03F3   /* 1011   */
#define FPTIT_FLEX_SHORT   0x03F4   /* 1012   */
#define FPTIT_FLEX_USHORT  0x03F5   /* 1013   */
#define FPTIT_FLEX_LONG    0x03F6   /* 1014   */
#define FPTIT_FLEX_ULONG   0x03F7   /* 1015   */
#define FPTIT_FLEX_DOUBLE  0x03F8   /* 1016   */
#define FPTIT_FLEX_LDOUBLE 0x03F9   /* 1017 ! */
#define FPTIT_FLEX_COMPRCH 0x03FA   /* 1018 ! */

/* Flex II types */
#define FPTIT_FLEX_DBLITEM 0x2710   /* 10000 14-bytes Clipper double item */
#define FPTIT_FLEX_LOGICAL 0x2711   /* 10001 4-bytes logical value  */
#define FPTIT_FLEX_NULSTR  0x2722   /* 10002 empty string */


#define FPTIT_FLEXAR_NIL      0x00  /* () */
#define FPTIT_FLEXAR_UCHAR    0x01  /* uchar */
#define FPTIT_FLEXAR_CHAR     0x02  /* char */
#define FPTIT_FLEXAR_SHORT    0x03  /* short[2] */
#define FPTIT_FLEXAR_USHORT   0x04  /* ushort[2] */
#define FPTIT_FLEXAR_LONG     0x05  /* long[4] */
                           /* 0x06 - unknown */
#define FPTIT_FLEXAR_STR      0x07  /* len[2], char[n] */
                           /* 0x08 - unknown */
#define FPTIT_FLEXAR_DOUBLE   0x09  /* double[8] */
#define FPTIT_FLEXAR_DATEX    0x0A  /* long[4] */
#define FPTIT_FLEXAR_LOGIC    0x0B  /* val[1] */
#define FPTIT_FLEXAR_ARAY     0x0C  /* len[2], ... */
                           /* 0x0D - unknown */
#define FPTIT_FLEXAR_DATEJ    0x0E  /* long[4] */
#define FPTIT_FLEXAR_DOUBLE2  0x0F  /* len, dec, double[8] */
                           /* 0x10 - unknown */
#define FPTIT_FLEXAR_UCHAR1   0x11  /* byte, dec */
#define FPTIT_FLEXAR_CHAR1    0x12  /* char, dec */
#define FPTIT_FLEXAR_SHORT1   0x13  /* short[2], len */
#define FPTIT_FLEXAR_USHORT1  0x14  /* ushort[2], len */
#define FPTIT_FLEXAR_LONG1    0x15  /* long[4], len */
                           /* 0x16 - unknown */
                           /* 0x17 - unknown */
#define FPTIT_FLEXAR_NUL      0x18  /* () */
#define FPTIT_FLEXAR_TRUE     0x19  /* () */
#define FPTIT_FLEXAR_FALSE    0x1A  /* () */
#define FPTIT_FLEXAR_LDOUBLE  0x1B  /* longdouble[10] */
#define FPTIT_FLEXAR_UCHAR2   0x1C  /* byte[1], len, dec */
#define FPTIT_FLEXAR_CHAR2    0x1D  /* char[1], len, dec */
#define FPTIT_FLEXAR_SHORT2   0x1E  /* short[2], len, dec */
#define FPTIT_FLEXAR_USHORT2  0x1F  /* ushort[2], len, dec */
#define FPTIT_FLEXAR_LONG2    0x20  /* long[4], len, dec */
#define FPTIT_FLEXAR_ULONG2   0x21  /* ulong[4], len, dec */


/* MEMO file strucutres */
typedef struct _FPTHEADER
{
   BYTE  nextBlock[ 4 ];            /* Next free block in the file */
   BYTE  blockSize[ 4 ];            /* Size of block */
   BYTE  signature1[ 10 ];          /* Signature: "SixMemo", "Harbour", "Made by CLIP"-overwrites next bytes*/
   BYTE  nGCitems[ 2 ];             /* number of GC items in reserved2 (max 82)*/
   BYTE  reserved2[ 492 ];          /* */
   BYTE  signature2[ 12 ];          /* Signature: "FlexFile3\003" */
   BYTE  flexRev[ 4 ];              /* Offset of reversed GC page */
   BYTE  flexDir[ 4 ];              /* Offset of GC page */
   BYTE  counter[ 4 ];              /* cyclic counter to sign changes in network env. */
   BYTE  rootBlock[ 4 ];            /* Clipper 5.3 ROOT data block */
   BYTE  flexSize[ 2 ];             /* FlexFile3 alternative block size */
   BYTE  reserved4[ 482 ];          /* */
} FPTHEADER;
typedef FPTHEADER * LPFPTHEADER;

typedef struct _FPTBLOCK
{
   BYTE  type[ 4 ];                 /* see: FPTIT_ */
   BYTE  size[ 4 ];                 /* length of data in bytes */
} FPTBLOCK;
typedef FPTBLOCK * LPFPTBLOCK;


/* MEMO internal memory structures */
typedef struct _MEMOGCITEM
{
   ULONG ulOffset;                  /* Number of blocks */
   ULONG ulSize;                    /* Block number */
   BOOL  fChanged;                  /* Mark the free page as changed */
} MEMOGCITEM;
typedef MEMOGCITEM * LPMEMOGCITEM;

typedef struct _MEMOGCTABLE
{
   BYTE   bType;                    /* MEMO_FPT_SIX or MEMO_FPT_FLEX */
   BYTE   bChanged;                 /* Should we write GC data to disk */
   ULONG  ulNextBlock;              /* Next free block in the file */
   ULONG  ulPrevBlock;              /* Previous next free block in the file */
   ULONG  ulRevPage;                /* FLEX Rev GC page offset */
   ULONG  ulDirPage;                /* FLEX Dir GC page offset */
   ULONG  ulCounter;                /* FLEX cyclic counter */
   ULONG  ulSize;                   /* FLEX GC page size in bytes */
   USHORT usMaxItem;                /* max number of items in pGCitems */
   USHORT usItems;                  /* number of items in pGCitems */
   LPMEMOGCITEM pGCitems;           /* free block list */
   FPTHEADER fptHeader;             /* FPT file header */
} MEMOGCTABLE;
typedef MEMOGCTABLE * LPMEMOGCTABLE;


/*
 *  DBFFPT WORKAREA
 *  ------------
 *  The Workarea Structure of DBFFPT RDD
 *
 */

/* we don't have to change DBFAREA to create FPTAREA */
typedef DBFAREA FPTAREA;
typedef FPTAREA * LPFPTAREA;
#ifndef FPTAREAP
#define FPTAREAP LPFPTAREA
#endif

/*
 * -- DBFFPT METHODS --
 */

#define SUPERTABLE                         ( &fptSuper )

#define hb_fptBof                                  NULL
#define hb_fptEof                                  NULL
#define hb_fptFound                                NULL
#define hb_fptGoBottom                             NULL
#define hb_fptGoTo                                 NULL
#define hb_fptGoToId                               NULL
#define hb_fptGoTop                                NULL
#define hb_fptSeek                                 NULL
#define hb_fptSkip                                 NULL
#define hb_fptSkipFilter                           NULL
#define hb_fptSkipRaw                              NULL
#define hb_fptAddField                             NULL
#define hb_fptAppend                               NULL
#define hb_fptCreateFields                         NULL
#define hb_fptDeleteRec                            NULL
#define hb_fptDeleted                              NULL
#define hb_fptFieldCount                           NULL
#define hb_fptFieldDisplay                         NULL
static ERRCODE hb_fptFieldInfo( FPTAREAP pArea, USHORT uiIndex, USHORT uiType, PHB_ITEM pItem );
#define hb_fptFieldName                            NULL
#define hb_fptFlush                                NULL
#define hb_fptGetRec                               NULL
static ERRCODE hb_fptGetValue( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
static ERRCODE hb_fptGetVarLen( FPTAREAP pArea, USHORT uiIndex, ULONG * pLength );
#define hb_fptGoCold                               NULL
#define hb_fptGoHot                                NULL
#define hb_fptPutRec                               NULL
static ERRCODE hb_fptPutValue( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
#define hb_fptRecall                               NULL
#define hb_fptRecCount                             NULL
#define hb_fptRecInfo                              NULL
#define hb_fptRecNo                                NULL
#define hb_fptRecId                                NULL
#define hb_fptSetFieldExtent                       NULL
#define hb_fptAlias                                NULL
#define hb_fptClose                                NULL
#define hb_fptCreate                               NULL
static ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
#define hb_fptNewArea                              NULL
#define hb_fptOpen                                 NULL
#define hb_fptRelease                              NULL
static ERRCODE hb_fptStructSize( FPTAREAP pArea, USHORT * uiSize );
#define hb_fptSysName                              NULL
#define hb_fptEval                                 NULL
static ERRCODE hb_fptPack( FPTAREAP pArea );
static ERRCODE hb_fptPackRec( FPTAREAP pArea, ULONG ulRecNo, BOOL *pfWritten );
#define hb_fptSort                                 NULL
#define hb_fptTrans                                NULL
#define hb_fptTransRec                             NULL
#define hb_fptZap                                  NULL
#define hb_fptChildEnd                             NULL
#define hb_fptChildStart                           NULL
#define hb_fptChildSync                            NULL
#define hb_fptSyncChildren                         NULL
#define hb_fptClearRel                             NULL
#define hb_fptForceRel                             NULL
#define hb_fptRelArea                              NULL
#define hb_fptRelEval                              NULL
#define hb_fptRelText                              NULL
#define hb_fptSetRel                               NULL
#define hb_fptOrderListAdd                         NULL
#define hb_fptOrderListClear                       NULL
#define hb_fptOrderListDelete                      NULL
#define hb_fptOrderListFocus                       NULL
#define hb_fptOrderListRebuild                     NULL
#define hb_fptOrderCondition                       NULL
#define hb_fptOrderCreate                          NULL
#define hb_fptOrderDestroy                         NULL
#define hb_fptOrderInfo                            NULL
#define hb_fptClearFilter                          NULL
#define hb_fptClearLocate                          NULL
#define hb_fptClearScope                           NULL
#define hb_fptCountScope                           NULL
#define hb_fptFilterText                           NULL
#define hb_fptScopeInfo                            NULL
#define hb_fptSetFilter                            NULL
#define hb_fptSetLocate                            NULL
#define hb_fptSetScope                             NULL
#define hb_fptSkipScope                            NULL
#define hb_fptLocate                               NULL
#define hb_fptCompile                              NULL
#define hb_fptError                                NULL
#define hb_fptEvalBlock                            NULL
#define hb_fptRawLock                              NULL
#define hb_fptLock                                 NULL
#define hb_fptUnLock                               NULL
#define hb_fptCloseMemFile                         NULL
static ERRCODE hb_fptCreateMemFile( FPTAREAP pArea, LPDBOPENINFO pCreateInfo );
static ERRCODE hb_fptGetValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode );
static ERRCODE hb_fptOpenMemFile( FPTAREAP pArea, LPDBOPENINFO pOpenInfo );
static ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode );
#define hb_fptReadDBHeader                         NULL
#define hb_fptWriteDBHeader                        NULL
#define hb_fptInit                                 NULL
#define hb_fptExit                                 NULL
#define hb_fptDrop                                 NULL
#define hb_fptExists                               NULL
static ERRCODE hb_fptRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, PHB_ITEM pItem );
#define hb_fptWhoCares                             NULL

HB_EXTERN_END

#endif /* HB_RDDFPT */
c:\harbour\include\hbrddntx.h
/*
 * $Id: hbrddntx.h 9530 2008-10-02 12:34:36Z druzus $
 */

/*
 * Harbour Project source code:
 * DBFNTX RDD
 *
 * Copyright 2000 Alexander Kresin 
 * 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.
 *
 */

#ifndef HB_RDDNTX_H_
#define HB_RDDNTX_H_

#include "hbapirdd.h"
#include "hbdbferr.h"
#define HB_EXTERNAL_RDDDBF_USE
#include "hbrdddbf.h"

HB_EXTERN_BEGIN

/* DBFNTX default extensions */
#define NTX_INDEXEXT                             ".ntx"

/* DBFNTX constants declarations */

#define NTX_IGNORE_REC_NUM                        0x0UL
#define NTX_MAX_REC_NUM                    0xFFFFFFFFUL

#define NTX_DUMMYNODE                      0xFFFFFFFFUL

#define NTX_FLAG_DEFALUT         0x0006
#define NTX_FLAG_OLDDEFALUT      0x0003
#define NTX_FLAG_FORITEM         0x0001
#define NTX_FLAG_PARTIAL         0x0008
#define NTX_FLAG_EXTLOCK         0x0010
#define NTX_FLAG_CUSTOM          0x0020
#define NTX_FLAG_CHGONLY         0x0040
#define NTX_FLAG_TEMPLATE        0x0080
#define NTX_FLAG_SORTRECNO       0x0100
#define NTX_FLAG_LARGEFILE       0x0200
#define NTX_FLAG_MULTIKEY        0x0400
#define NTX_FLAG_COMPOUND        0x8000
#define NTX_FLAG_MASK            0x87FF

#define CTX_MAX_TAGS                 63

#define NTX_MAX_KEY                     256     /* Max len of key */
#define NTX_MAX_EXP                     256     /* Max len of KEY/FOR expression */
#define NTXBLOCKBITS                     10     /* Size of NTX block in bits */
#define NTXBLOCKSIZE      (1<
c:\harbour\include\hbrddsdf.h
/*
 * $Id: hbrddsdf.h 9530 2008-10-02 12:34:36Z druzus $
 */

/*
 * Harbour Project source code:
 *    SDF RDD
 *
 * Copyright 2006 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_RDDSDF_H_
#define HB_RDDSDF_H_

#include "hbapirdd.h"

HB_EXTERN_BEGIN

/* SDF default file extensions */
#define SDF_TABLEEXT                      ".txt"


/*
 *  SDF WORKAREA
 *  ------------
 *  The Workarea Structure of SDF RDD
 *
 */

typedef struct _SDFAREA
{
   struct _RDDFUNCS * lprfsHost; /* Virtual method table for this workarea */
   USHORT uiArea;                /* The number assigned to this workarea */
   void * atomAlias;             /* Pointer to the alias symbol for this workarea */
   USHORT uiFieldExtent;         /* Total number of fields allocated */
   USHORT uiFieldCount;          /* Total number of fields used */
   LPFIELD lpFields;             /* Pointer to an array of fields */
   void * lpFieldExtents;        /* Void ptr for additional field properties */
   PHB_ITEM valResult;           /* All purpose result holder */
   BOOL fTop;                    /* TRUE if "top" */
   BOOL fBottom;                 /* TRUE if "bottom" */
   BOOL fBof;                    /* TRUE if "bof" */
   BOOL fEof;                    /* TRUE if "eof" */
   BOOL fFound;                  /* TRUE if "found" */
   DBSCOPEINFO dbsi;             /* Info regarding last LOCATE */
   DBFILTERINFO dbfi;            /* Filter in effect */
   LPDBORDERCONDINFO lpdbOrdCondInfo;
   LPDBRELINFO lpdbRelations;    /* Parent/Child relationships used */
   USHORT uiParents;             /* Number of parents for this area */
   USHORT heap;
   USHORT heapSize;
   USHORT rddID;
   USHORT uiMaxFieldNameLength;
   PHB_CODEPAGE cdPage;          /* Area's codepage pointer */

   /*
   *  SDFS's additions to the workarea structure
   *
   *  Warning: The above section MUST match WORKAREA exactly!  Any
   *  additions to the structure MUST be added below, as in this
   *  example.
   */

   PHB_FILE pFile;                  /* Data file handle */
   char *   szFileName;             /* Name of data file */
   char *   szEol;                  /* EOL marker */
   USHORT   uiEolLen;               /* Size of EOL marker */
   USHORT   uiRecordLen;            /* Size of record */
   USHORT * pFieldOffset;           /* Pointer to field offset array */
   BYTE *   pRecord;                /* Buffer of record data */
   HB_FOFFSET ulRecordOffset;       /* Current record offest */
   HB_FOFFSET ulNextOffset;         /* Next record offest */
   HB_FOFFSET ulFileSize;           /* File table size in export mode */
   ULONG    ulRecNo;                /* Current record */
   ULONG    ulRecCount;             /* Number of records (in export) */
   BOOL     fTransRec;              /* Can put whole records */
   BOOL     fFlush;                 /* Data was written to SDF and not commited */
   BOOL     fShared;                /* Shared file */
   BOOL     fReadonly;              /* Read only file */
   BOOL     fPositioned;            /* Positioned record */
   BOOL     fRecordChanged;         /* Record changed */
} SDFAREA;

typedef SDFAREA * LPSDFAREA;

#ifndef SDFAREAP
#define SDFAREAP LPSDFAREA
#endif

HB_EXTERN_END

#endif /* HB_RDDSDF_H_ */
c:\harbour\include\hbregex.h
/*
 * $Id: hbregex.h 7530 2007-06-06 13:40:09Z druzus $
 */

/*
 * Harbour Project source code:
 * 
 *
 * Copyright 2007 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_REGEX_H_
#define HB_REGEX_H_

#include "hbapi.h"

#if defined( _HB_REGEX_INTERNAL_ )

#if defined( HB_PCRE_REGEX_BCC )
#  include 
#  undef HB_PCRE_REGEX
#  if !defined( HB_POSIX_REGEX )
#     define HB_POSIX_REGEX
#  endif
#elif defined( HB_PCRE_REGEX )
#  include 
#  undef HB_POSIX_REGEX
#elif defined( HB_POSIX_REGEX )
#  include 
#  include 
#else
#  define HB_PCRE_REGEX
#  define PCRE_STATIC
#  if defined(__XCC__) || defined(__LCC__)
#     include "source\hbpcre\pcre.h"
#  else
#     include "../source/hbpcre/pcre.h"
#  endif
#endif

typedef struct
{
   BOOL        fFree;
   int         iFlags;
   int         iEFlags;
#if defined( HB_PCRE_REGEX )
   pcre        * re_pcre;
#elif defined( HB_POSIX_REGEX )
   regex_t     reg;
#endif
} HB_REGEX;
typedef HB_REGEX * PHB_REGEX;

#if defined( HB_PCRE_REGEX )
   #define HB_REGMATCH              int
   #define HB_REGMATCH_SIZE( n )    ( ( n ) * 3 )
   #define HB_REGMATCH_SO( p, n )   ( p )[ ( n ) * 2 ]
   #define HB_REGMATCH_EO( p, n )   ( p )[ ( n ) * 2 + 1 ]
#elif defined( HB_POSIX_REGEX )
   #define HB_REGMATCH              regmatch_t
   #define HB_REGMATCH_SIZE( n )    ( n )
   #define HB_REGMATCH_SO( p, n )   ( p )[ n ].rm_so
   #define HB_REGMATCH_EO( p, n )   ( p )[ n ].rm_eo
#else
   #define HB_REGMATCH              int
   #define HB_REGMATCH_SIZE( n )    ( ( n ) * 2 )
   #define HB_REGMATCH_SO( p, n )   ( p )[ ( n ) * 2 ]
   #define HB_REGMATCH_EO( p, n )   ( p )[ ( n ) * 2 + 1 ]
#endif

typedef void ( * HB_REG_FREE )( PHB_REGEX );
typedef int  ( * HB_REG_COMP )( PHB_REGEX, const char * );
typedef int  ( * HB_REG_EXEC )( PHB_REGEX, const char *, ULONG, int, HB_REGMATCH * );

extern void hb_regexInit( HB_REG_FREE pFree, HB_REG_COMP pComp, HB_REG_EXEC pExec );
extern HB_GARBAGE_FUNC( hb_regexRelease );

#ifndef REG_EXTENDED
#  define REG_EXTENDED  0x00
#endif
#ifndef REG_NOSUB
#  define REG_NOSUB     0x00
#endif

#else

typedef void * PHB_REGEX;

#endif /* _HB_REGEX_INTERNAL_ */

#define HBREG_ICASE     0x01
#define HBREG_NEWLINE   0x02
#define HBREG_NOTBOL    0x04
#define HBREG_NOTEOL    0x08
#define HBREG_EXTENDED  0x10
#define HBREG_NOSUB     0x20
#define HBREG_DOTALL    0x40

#ifndef REGEX_MAX_GROUPS
#  define REGEX_MAX_GROUPS 16
#endif

HB_EXTERN_BEGIN

extern HB_EXPORT PHB_REGEX hb_regexCompile( const char * szRegEx, ULONG ulLen, int iFlags );
extern HB_EXPORT PHB_REGEX hb_regexGet( PHB_ITEM pRegExItm, int iFlags );
extern HB_EXPORT void      hb_regexFree( PHB_REGEX pRegEx );
extern HB_EXPORT BOOL      hb_regexMatch( PHB_REGEX pRegEx, const char * szString, ULONG UlLen, BOOL fFull );

HB_EXTERN_END

#endif /* HB_REGEX_H_ */
c:\harbour\include\hbset.h
/*
 * $Id: hbset.h 9517 2008-09-29 15:42:21Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Set API
 *
 * Copyright 1999-2003 David G. Holm 
 * 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.
 *
 */

#ifndef HB_SET_H_
#define HB_SET_H_

#include "hbapi.h"
#include "hbapigt.h"
#include "hbapifs.h"

HB_EXTERN_BEGIN

typedef enum
{
   HB_SET_INVALID_      = 0,

   HB_SET_EXACT         = 1,
   HB_SET_FIXED         = 2,
   HB_SET_DECIMALS      = 3,
   HB_SET_DATEFORMAT    = 4,
   HB_SET_EPOCH         = 5,
   HB_SET_PATH          = 6,
   HB_SET_DEFAULT       = 7,

   HB_SET_EXCLUSIVE     = 8,
   HB_SET_SOFTSEEK      = 9,
   HB_SET_UNIQUE        = 10,
   HB_SET_DELETED       = 11,

   HB_SET_CANCEL        = 12,
   HB_SET_DEBUG         = 13,
   HB_SET_TYPEAHEAD     = 14,

   HB_SET_COLOR         = 15,
   HB_SET_CURSOR        = 16,
   HB_SET_CONSOLE       = 17,
   HB_SET_ALTERNATE     = 18,
   HB_SET_ALTFILE       = 19,
   HB_SET_DEVICE        = 20,
   HB_SET_EXTRA         = 21,
   HB_SET_EXTRAFILE     = 22,
   HB_SET_PRINTER       = 23,
   HB_SET_PRINTFILE     = 24,
   HB_SET_MARGIN        = 25,

   HB_SET_BELL          = 26,
   HB_SET_CONFIRM       = 27,
   HB_SET_ESCAPE        = 28,
   HB_SET_INSERT        = 29,
   HB_SET_EXIT          = 30,
   HB_SET_INTENSITY     = 31,
   HB_SET_SCOREBOARD    = 32,
   HB_SET_DELIMITERS    = 33,
   HB_SET_DELIMCHARS    = 34,

   HB_SET_WRAP          = 35,
   HB_SET_MESSAGE       = 36,
   HB_SET_MCENTER       = 37,
   HB_SET_SCROLLBREAK   = 38,

   HB_SET_EVENTMASK     = 39,

   HB_SET_VIDEOMODE     = 40,

   HB_SET_MBLOCKSIZE    = 41,
   HB_SET_MFILEEXT      = 42,

   HB_SET_STRICTREAD    = 43,
   HB_SET_OPTIMIZE      = 44,
   HB_SET_AUTOPEN       = 45,
   HB_SET_AUTORDER      = 46,
   HB_SET_AUTOSHARE     = 47,

   /* Harbour SET extensions start at 100 */
   HB_SET_LANGUAGE      = 100,
   HB_SET_IDLEREPEAT    = 101,
   HB_SET_FILECASE      = 102,
   HB_SET_DIRCASE       = 103,
   HB_SET_DIRSEPARATOR  = 104,
   HB_SET_EOF           = 105,
   HB_SET_HARDCOMMIT    = 106,
   HB_SET_FORCEOPT      = 107,
   HB_SET_DBFLOCKSCHEME = 108,
   HB_SET_DEFEXTENSIONS = 109,
   HB_SET_EOL           = 110,
   HB_SET_TRIMFILENAME  = 111,
   HB_SET_HBOUTLOG      = 112,
   HB_SET_HBOUTLOGINFO  = 113,
   HB_SET_CODEPAGE      = 114

} HB_set_enum;

#if defined( _HB_SET_INTERNAL_ ) || defined( _HB_API_INTERNAL_ )
typedef struct
{
   /* Lower case members are indirectly related to a SET */
   HB_FHANDLE     hb_set_althan;
   BOOL           hb_set_century;
   HB_FHANDLE     hb_set_extrahan;
   HB_FHANDLE     hb_set_printhan;
   HB_PATHNAMES * hb_set_path;
   void *         hb_set_listener;

   /* Upper case members are directly related to a SET */
   BOOL       HB_SET_ALTERNATE;
   char *     HB_SET_ALTFILE;
   BOOL       HB_SET_AUTOPEN;
   int        HB_SET_AUTORDER;
   int        HB_SET_AUTOSHARE;
   BOOL       HB_SET_BELL;
   BOOL       HB_SET_CANCEL;
   char *     HB_SET_COLOR;
   BOOL       HB_SET_CONFIRM;
   BOOL       HB_SET_CONSOLE;
   char *     HB_SET_DATEFORMAT;
   BOOL       HB_SET_DEBUG;
   int        HB_SET_DECIMALS;
   char *     HB_SET_DEFAULT;
   BOOL       HB_SET_DELETED;
   char *     HB_SET_DELIMCHARS;
   BOOL       HB_SET_DELIMITERS;
   char *     HB_SET_DEVICE;
   BOOL       HB_SET_EOF;
   int        HB_SET_EPOCH;
   BOOL       HB_SET_ESCAPE;
   int        HB_SET_EVENTMASK;
   BOOL       HB_SET_EXACT;
   BOOL       HB_SET_EXCLUSIVE;
   BOOL       HB_SET_EXIT;
   BOOL       HB_SET_EXTRA;
   char *     HB_SET_EXTRAFILE;
   BOOL       HB_SET_FIXED;
   BOOL       HB_SET_IDLEREPEAT;
   BOOL       HB_SET_INSERT;
   BOOL       HB_SET_INTENSITY;
   char *     HB_SET_PATH;
   int        HB_SET_MARGIN;
   int        HB_SET_MBLOCKSIZE;
   BOOL       HB_SET_MCENTER;
   int        HB_SET_MESSAGE;
   char *     HB_SET_MFILEEXT;
   BOOL       HB_SET_OPTIMIZE;
   BOOL       HB_SET_PRINTER;
   char *     HB_SET_PRINTFILE;
   BOOL       HB_SET_SCOREBOARD;
   BOOL       HB_SET_SCROLLBREAK;
   BOOL       HB_SET_SOFTSEEK;
   BOOL       HB_SET_STRICTREAD;
   int        HB_SET_TYPEAHEAD;
   BOOL       HB_SET_UNIQUE;
   int        HB_SET_FILECASE;
   int        HB_SET_DIRCASE;
   int        HB_SET_DIRSEPARATOR;
   int        HB_SET_VIDEOMODE;
   BOOL       HB_SET_WRAP;
   int        HB_SET_DBFLOCKSCHEME;
   BOOL       HB_SET_HARDCOMMIT;
   BOOL       HB_SET_FORCEOPT;
   BOOL       HB_SET_DEFEXTENSIONS;
   char *     HB_SET_EOL;
   BOOL       HB_SET_TRIMFILENAME;
   char *     HB_SET_HBOUTLOG;
   char *     HB_SET_HBOUTLOGINFO;

} HB_SET_STRUCT, * PHB_SET_STRUCT;

extern void hb_setInitialize( PHB_SET_STRUCT pSet );
extern void hb_setRelease( PHB_SET_STRUCT pSet );
extern PHB_SET_STRUCT hb_setClone( PHB_SET_STRUCT pSet );

#else

typedef void * PHB_SET_STRUCT;

#endif /* _HB_SET_INTERNAL_ || _HB_API_INTERNAL_ */

#define HB_SET_CASE_MIXED  0
#define HB_SET_CASE_LOWER  1
#define HB_SET_CASE_UPPER  2

#define HB_SET_DBFLOCK_DEFAULT    0
#define HB_SET_DBFLOCK_CLIP       1
#define HB_SET_DBFLOCK_CL53       2
#define HB_SET_DBFLOCK_VFP        3

typedef enum
{
   HB_SET_LISTENER_BEFORE,
   HB_SET_LISTENER_AFTER
} HB_set_listener_enum;
typedef void HB_SET_LISTENER_CALLBACK( HB_set_enum, HB_set_listener_enum );

extern int hb_setListenerAdd( HB_SET_LISTENER_CALLBACK * );
extern void hb_setListenerNotify( HB_set_enum, HB_set_listener_enum );
extern int hb_setListenerRemove( int );

extern HB_EXPORT BOOL       hb_setGetL( HB_set_enum set_specifier );
extern HB_EXPORT char *     hb_setGetCPtr( HB_set_enum set_specifier );
extern HB_EXPORT int        hb_setGetNI( HB_set_enum set_specifier );
extern HB_EXPORT long       hb_setGetNL( HB_set_enum set_specifier );

extern HB_EXPORT BOOL       hb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem );

extern HB_EXPORT HB_PATHNAMES * hb_setGetFirstSetPath( void );

extern HB_EXPORT HB_FHANDLE hb_setGetAltHan( void );
extern HB_EXPORT BOOL       hb_setGetCentury( void );
extern HB_EXPORT BOOL       hb_setSetCentury( BOOL );
extern HB_EXPORT HB_FHANDLE hb_setGetExtraHan( void );
extern HB_EXPORT HB_FHANDLE hb_setGetPrintHan( void );
extern HB_EXPORT BOOL       hb_setGetAlternate( void );
extern HB_EXPORT char *     hb_setGetAltFile( void );
extern HB_EXPORT BOOL       hb_setGetAutOpen( void );
extern HB_EXPORT int        hb_setGetAutOrder( void );
extern HB_EXPORT int        hb_setGetAutoShare( void );
extern HB_EXPORT BOOL       hb_setGetBell( void );
extern HB_EXPORT BOOL       hb_setGetCancel( void );
extern HB_EXPORT char *     hb_setGetColor( void );
extern HB_EXPORT BOOL       hb_setGetConfirm( void );
extern HB_EXPORT BOOL       hb_setGetConsole( void );
extern HB_EXPORT char *     hb_setGetDateFormat( void );
extern HB_EXPORT BOOL       hb_setGetDebug( void );
extern HB_EXPORT int        hb_setGetDecimals( void );
extern HB_EXPORT char *     hb_setGetDefault( void );
extern HB_EXPORT BOOL       hb_setGetDeleted( void );
extern HB_EXPORT char *     hb_setGetDelimChars( void );
extern HB_EXPORT BOOL       hb_setGetDelimiters( void );
extern HB_EXPORT char *     hb_setGetDevice( void );
extern HB_EXPORT BOOL       hb_setGetEOF( void );
extern HB_EXPORT int        hb_setGetEpoch( void );
extern HB_EXPORT BOOL       hb_setGetEscape( void );
extern HB_EXPORT int        hb_setGetEventMask( void );
extern HB_EXPORT BOOL       hb_setGetExact( void );
extern HB_EXPORT BOOL       hb_setGetExclusive( void );
extern HB_EXPORT BOOL       hb_setGetExit( void );
extern HB_EXPORT BOOL       hb_setGetExtra( void );
extern HB_EXPORT char *     hb_setGetExtraFile( void );
extern HB_EXPORT BOOL       hb_setGetFixed( void );
extern HB_EXPORT BOOL       hb_setGetIdleRepeat( void );
extern HB_EXPORT BOOL       hb_setGetInsert( void );
extern HB_EXPORT BOOL       hb_setGetIntensity( void );
extern HB_EXPORT char *     hb_setGetPath( void );
extern HB_EXPORT int        hb_setGetMargin( void );
extern HB_EXPORT int        hb_setGetMBlockSize( void );
extern HB_EXPORT BOOL       hb_setGetMCenter( void );
extern HB_EXPORT int        hb_setGetMessage( void );
extern HB_EXPORT char *     hb_setGetMFileExt( void );
extern HB_EXPORT BOOL       hb_setGetOptimize( void );
extern HB_EXPORT BOOL       hb_setGetPrinter( void );
extern HB_EXPORT char *     hb_setGetPrintFile( void );
extern HB_EXPORT BOOL       hb_setGetScoreBoard( void );
extern HB_EXPORT BOOL       hb_setGetScrollBreak( void );
extern HB_EXPORT BOOL       hb_setGetSoftSeek( void );
extern HB_EXPORT BOOL       hb_setGetStrictRead( void );
extern HB_EXPORT int        hb_setGetTypeAhead( void );
extern HB_EXPORT BOOL       hb_setGetUnique( void );
extern HB_EXPORT int        hb_setGetFileCase( void );
extern HB_EXPORT int        hb_setGetDirCase( void );
extern HB_EXPORT int        hb_setGetDirSeparator( void );
extern HB_EXPORT int        hb_setGetVideoMode( void );
extern HB_EXPORT BOOL       hb_setGetWrap( void );
extern HB_EXPORT int        hb_setGetDBFLockScheme( void );
extern HB_EXPORT BOOL       hb_setGetHardCommit( void );
extern HB_EXPORT BOOL       hb_setGetForceOpt( void );
extern HB_EXPORT BOOL       hb_setGetDefExtension( void );
extern HB_EXPORT char *     hb_setGetEOL( void );
extern HB_EXPORT BOOL       hb_setGetTrimFileName( void );
extern HB_EXPORT char *     hb_setGetHBOUTLOG( void );
extern HB_EXPORT char *     hb_setGetHBOUTLOGINFO( void );

HB_EXTERN_END

#endif /* HB_SET_H_ */
c:\harbour\include\hbsetup.h
/*
 * $Id: hbsetup.h 9492 2008-09-24 10:52:12Z vszakats $
 */

/*
 * Harbour Project source code:
 * Header file for compiler and runtime configuration
 *
 * Copyright 1999 Ryszard Glab 
 * 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.
 *
 */

#ifndef HB_SETUP_H_
#define HB_SETUP_H_

#include 

/* ***********************************************************************
 * Include settings common for .prg and .c files
 */
#include "hbsetup.ch"

/* ***********************************************************************
 * Define PCODE version number
 * HB_PCODE_VER_MIN define minimum supported PCODE by HVM
 */

#define HB_PCODE_VER          0x0002
#define HB_PCODE_VER_MIN      0x0002

/* ***********************************************************************
 * NOTE: You can select the default language modul used by Harbour, by
 *       defining this to a valid language modul identifier.
 */

#ifndef HB_LANG_DEFAULT
   #define HB_LANG_DEFAULT       EN
#endif

/* ***********************************************************************
 * NOTE: You can select the default codepage used by Harbour, by
 *       defining this to a valid codepage modul identifier.
 */

#ifndef HB_CODEPAGE_DEFAULT
   #define HB_CODEPAGE_DEFAULT   EN
#endif

/* ***********************************************************************
 * If you turn this on, the memory subsystem will collect trace information
 * and several statistical data about memory management, it will show
 * these on exit if memory seem to have been leaked. The memory subsystem
 * will also do pointer checks. [vszakats]
 * This should be normally turned off in a final release.
 *
 * Note that if you turn this on, Harbour will be slighlty slower, larger
 * and will consume more memory.
 *
 * By default this is turned on. Define HB_FM_STATISTICS_OFF to turn it off.
 */
#if defined( HB_FM_STATISTICS_OFF )
   #undef HB_FM_STATISTICS
#elif !defined( HB_FM_STATISTICS )
   #define HB_FM_STATISTICS
#endif

/* ***********************************************************************
 * Enable profiler support in HVM
 * By default this is turned off. Define HB_USE_PROFILER to turn it on.
 */

#ifndef HB_USE_PROFILER
   #define HB_NO_PROFILER
#endif

/* ***********************************************************************
 * Use system PCRE library instead of build in. I'm setting it sometimes
 * when I want to use exactly the same PCRE version as installed in     
 * a system.                                                            
 */
/* #define HB_PCRE_REGEX */

/* ***********************************************************************
 * Use old PCRE library which is part of BCC CRTL used to emulate 
 * POSIX regex.
 */
/* #define HB_PCRE_REGEX_BCC */

/* ***********************************************************************
 * Use POSIX regex library which should be part of each POSIX compatible
 * system / C compiler I also use this when I want to support exactly   
 * the same regular expressions as other tools installed in the system  
 */
/* #define HB_POSIX_REGEX */

/* ***********************************************************************
 * This symbol defines if Harbour is compiled using C compiler
 * that support strict ANSI C only
 *
 * The only non ANSI C feature that we are using is an ability
 * to call functions before the 'main' module is called.
 * This trick is used to automatically join all symbol tables defined
 * in run-time support modules and in user defined modules.
 *   If strict ANSI C compability is required then all symbol tables
 * have to be joined manually by calling special function named
 * hb_vm_SymbolInit_
 * (for example for myfirst.prg it will be: 'hb_vm_SymbolInit_MYFIRST'
 * The generation of this function is performed by the macro called
 * HB_CALL_ON_STARTUP that is defined in 'hbinit.h'
 *
 * By default we are using extensions to ANSI C (symbol is not defined)
 */
/* #define HB_STRICT_ANSI_C */

/* ***********************************************************************
 * Define this option if you want the /y YACC trace option to be available
 * in the Harbour compiler.
 *
 * Note that if you turn this on, the compiler will slighly grow in size.
 *
 * By default this is turned off.
 */
/* #define HB_YYDEBUG */

/* ***********************************************************************
 * Use native Windows memory allocation functions (HB_OS_WIN_32)
 * This option can disable compiler memory allocation optimization
 * so you should really have a good reason to enable it
 */

/* #define HB_FM_WIN32_ALLOC */

/* ***********************************************************************
 * You can select here, what type of main entry will be used in the
 * application (main() or WinMain()).
 *
 * By default the standard C main() function will be used.
 */
/* #define HB_MAIN_STD */
/* #define HB_MAIN_WIN */

/* ***********************************************************************
 * You can set here the maximum symbol name length handled by Harbour
 * compiler and runtime. You can override this setting in the make process.
 * Setting this too low, may result in clashing symbols in Harbour 
 * itself. For strict CA-Cl*pper compatibility a value of 10 would have 
 * to be used, but Harbour won't properly compile using this setting.
 *
 * By default this value is 63
 */
#ifndef HB_SYMBOL_NAME_LEN
   #define HB_SYMBOL_NAME_LEN   63
#endif

/* ***********************************************************************
 * You can enable here support for multiline strings concatenated by ';'
 * f.e.:
 *       cVar := "line 1;
 *       line 2;
 *       line 3"
 * It's not Clipper compatible extension and it's not enabled by default
 * anyhow old Harbour PP worked in such way and people may have some code
 * which needs it
 */
/* #define HB_PP_MULTILINE_STRING */

/* ***********************************************************************
 * Operating system specific definitions
 */
#if ( defined(__GNUC__) && \
      ! ( defined(__DJGPP__) || defined(__EMX__) || defined(__RSXNT__) || \
          defined(_Windows) || defined(_WIN32) || defined(_WINCE) ) ) || \
    ( defined(__WATCOMC__) && defined(__LINUX__) )
   #define HB_OS_UNIX_COMPATIBLE
   #define HB_OS_PATH_LIST_SEP_CHR      ':'
   #define HB_OS_PATH_DELIM_CHR         '/'
   #define HB_OS_PATH_DELIM_CHR_STRING  "/"
   #define HB_OS_PATH_DELIM_CHR_LIST    "/"
   #define HB_OS_ALLFILE_MASK           "*"
   #undef  HB_OS_DRIVE_DELIM_CHR
   #undef  HB_OS_HAS_DRIVE_LETTER
   #define HB_OS_OPT_DELIM_LIST         "-"
   #define HB_OS_EOL_LEN                1
#else
   /* we are assuming here the DOS compatible OS */
   #define HB_OS_PATH_LIST_SEP_CHR      ';'
   #define HB_OS_PATH_DELIM_CHR         '\\'
   #define HB_OS_PATH_DELIM_CHR_STRING  "\\"
   #define HB_OS_PATH_DELIM_CHR_LIST    "\\/:"
   #define HB_OS_ALLFILE_MASK           "*.*"
   #define HB_OS_DRIVE_DELIM_CHR        ':'
   #define HB_OS_HAS_DRIVE_LETTER
   #define HB_OS_OPT_DELIM_LIST         "/-"
   #define HB_OS_EOL_LEN                2  /* # of bytes in End of Line marker */
#endif

#ifndef _POSIX_PATH_MAX
   #define _POSIX_PATH_MAX    255
#endif

#define HB_ISOPTSEP( c ) ( strchr( HB_OS_OPT_DELIM_LIST, ( c ) ) != NULL )

/* NOTE:
   Compiler                                _MSC_VER value
   --------                                --------------
   C Compiler version 6.0                  600
   C/C++ compiler version 7.0              700
   Visual C++, Windows, version 1.0        800
   Visual C++, 32-bit, version 1.0         800
   Visual C++, Windows, version 2.0        900
   Visual C++, 32-bit, version 2.x         900
   Visual C++, 32-bit, version 4.0         1000
   Visual C++, 32-bit, version 5.0         1100
   Visual C++, 32-bit, version 6.0         1200
   Visual Studio .NET, version 7.0         1300
   Visual Studio .NET 2003, version 7.1    1310
   Visual Studio 2005, version 8.0         1400
   Visual Studio 2008, version 9.0         1500
*/

/* ***********************************************************************
 * Platform detection
 */

#if defined(__WATCOMC__)
   #if defined(__OS2__)
      #define HB_OS_OS2
   #elif defined(__NT__) || defined(__WINDOWS_386__) || defined(__WINDOWS__)
      #define HB_OS_WIN_32
   #elif defined(__LINUX__)
      #define HB_OS_LINUX
   #elif defined(__386__)
      #define HB_OS_DOS
      #define HB_OS_DOS_32
   #else
      #define HB_OS_DOS
      #define HB_OS_DOS_16
   #endif
#endif

#ifndef HB_OS_DOS
   #if defined(DOS) || defined(_QC) || defined(__DOS__) || defined(MSDOS) || defined(__MSDOS__) || defined(__RSX32__)
      #define HB_OS_DOS
      #if defined(__386__) || defined(__DJGPP__)
         #define HB_OS_DOS_32
      #else
         #define HB_OS_DOS_16
      #endif
   #endif
#endif

#if defined(__EMX__) && ! defined(__RSXNT__)
   #define HB_OS_OS2_GCC
#endif
#ifndef HB_OS_OS2
   #if defined(OS2) || defined(__OS2__) || defined(OS_2) || defined(HB_OS_OS2_GCC)
      #define HB_OS_OS2
   #endif
#endif

#ifndef HB_OS_WIN_32
   #if defined(WINNT) || defined(_Windows) || defined(__NT__) || defined(_WIN32) || defined(_WINDOWS_) || defined(__WINDOWS_386__) || defined(__WIN32__) || defined(__CYGWIN__)
      #define HB_OS_WIN_32
   #endif
#endif

/* Sub-option inside HB_OS_WIN_32 */
#ifndef HB_OS_WIN_64
   #if defined(_WIN64)
      #define HB_OS_WIN_64
   #endif
#endif

/* Sub-option inside HB_OS_WIN_32 */
#ifndef HB_WINCE
   #if defined(_WINCE) || defined(__CEGCC__) || defined(__MINGW32CE__) || (defined(__POCC_TARGET__) && __POCC_TARGET__ == 2)
      #define HB_WINCE
   #endif
#endif

#ifndef HB_OS_LINUX
   #if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
      #define HB_OS_LINUX
   #endif
#endif

#ifndef HB_OS_SUNOS
   #if defined(sun) || defined(__sun) || defined(__sun__)
      #define HB_OS_SUNOS
   #endif
#endif

#ifndef HB_OS_HPUX
   /* HP cc in ANSI mode defines __hpux. GCC defines __hpux__ */
   #if defined(__hpux) || defined(__hpux__)
      #define HB_OS_HPUX
   #endif
#endif

#ifndef HB_OS_DARWIN
   #if defined(__APPLE__)
      #define HB_OS_DARWIN
   #endif
#endif

#ifndef HB_OS_BSD
   #if defined( __FreeBSD__ ) || defined( __NetBSD__ ) || defined( __OpenBSD__ ) || \
       defined( HB_OS_DARWIN )
      #define HB_OS_BSD
   #endif
#endif

#ifndef HB_OS_UNIX
   #if defined(HB_OS_UNIX_COMPATIBLE) || \
       defined(HB_OS_LINUX) || \
       defined(HB_OS_DARWIN) || \
       defined(HB_OS_BSD) || \
       defined(HB_OS_SUNOS) || \
       defined(HB_OS_HPUX)
      #define HB_OS_UNIX
   #endif
#endif

/* ***********************************************************************
 * Here you can force the EOL string to be CRLF
 *
 * By default, the EOL string depends upon the detected platform.
 */
/* #define HB_EOL_CRLF */
#ifdef HB_EOL_CRLF
   #undef HB_OS_EOL_LEN
   #define HB_OS_EOL_LEN 2
#endif

/* Compatibility #defines. These will be removed, so 
   please use the new names in your code. */
#ifdef HB_LEGACY_LEVEL
   #define OS_PATH_DELIMITER            HB_OS_PATH_DELIM_CHR
   #ifdef HB_OS_UNIX_COMPATIBLE
      #define OS_UNIX_COMPATIBLE
   #endif
#endif

#if defined(HB_WINCE) && defined(HB_MT_VM)
   #undef HB_MT_VM
#endif

/* ***********************************************************************
 * See also the following files for task specific definitions/settings
 *
 * hbmath.h    - math errors handling
 */

/* ***********************************************************************
 * some fixes in compiler header files
 */

#if defined( __DJGPP__ )
   /* Fix DJGPP in call to: toupper(), tolower(), is...()
    */
   #include "hbfixdj.h"

   /* Substitute snprintf() by sprintf() for DJGPP <= 2.03.
    * This is a temporary hack, should implement a C99 snprintf() ourselves.
    */
   #if ( __DJGPP__ < 2 || ( __DJGPP__ == 2 && __DJGPP_MINOR__ <= 3 ) )
      #define snprintf(s, len, args...) sprintf( (s), ##args )
   #endif
#elif defined( _MSC_VER ) || defined( __DMC__ ) && !defined( __XCC__ )
   #define snprintf _snprintf
#elif defined( __WATCOMC__ )
   #if __WATCOMC__ < 1200
      #define snprintf _bprintf
   #endif
#endif

/* ***********************************************************************
 * Extern "C" detection
 */

#if defined(__cplusplus) && !defined(__IBMCPP__)
   #define HB_EXTERN_C
   #define HB_EXTERN_BEGIN    extern "C" {
   #define HB_EXTERN_END      }
#else
   #define HB_EXTERN_BEGIN
   #define HB_EXTERN_END
#endif

#endif /* HB_SETUP_H_ */
c:\harbour\include\hbstack.h
/*
 * $Id: hbstack.h 9535 2008-10-02 19:12:30Z druzus $
 */

/*
 * Harbour Project source code:
 * The eval stack
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

/* TOFIX: There are several things in this file which are not part of the
          standard Harbour API, in other words these things are not
          guaranteed to remain unchanged. To avoid confusion these should be
          moved to somewhere else (like hbrtl.h). [vszakats] */

#ifndef HB_STACK_H_
#define HB_STACK_H_

#include "hbvmpub.h"

HB_EXTERN_BEGIN

#if defined( HB_MT_VM )
#  include "hbthread.h"
#  if !defined( HB_USE_TLS ) && !defined( HB_OS_OS2 ) && 0
#     undef HB_STACK_MACROS
#  endif
#endif

/* thread specific data */
typedef void (*PHB_TSD_FUNC)(void *);
typedef struct
{
   int      iHandle;
   int      iSize;
   PHB_TSD_FUNC pInitFunc;
   PHB_TSD_FUNC pCleanFunc;
}
HB_TSD, * PHB_TSD;
#define HB_TSD_NEW(name,size,init,clean)  \
        HB_TSD name = { 0, size, init, clean }
#define HB_TSD_INIT(name,size,init,clean) do { \
            (name)->iHandle = 0; \
            (name)->iSize = (size); \
            (name)->pInitFunc = (init); \
            (name)->pCleanFunc = (clean); \
         } while( 0 )

typedef struct
{
   USHORT   uiFError;
   USHORT   uiErrorLast;
   USHORT   uiOsErrorLast;
}
HB_IOERRORS, * PHB_IOERRORS;

typedef struct
{
   const char *   szDefaultRDD;     /* default RDD */
   BOOL           fNetError;        /* current NETERR() flag */

   void **        waList;           /* Allocated WorkAreas */
   USHORT         uiWaMax;          /* Number of allocated WA */
   USHORT         uiWaSpace;        /* Number of allocated WA */

   USHORT *       waNums;           /* Allocated WorkAreas */
   USHORT         uiWaNumMax;       /* Number of allocated WA */

   USHORT         uiCurrArea;       /* Current WokrArea number */
   void *         pCurrArea;        /* Current WorkArea pointer */
}
HB_STACKRDD, * PHB_STACKRDD;

#ifdef _HB_API_INTERNAL_

#include "hbset.h"

typedef struct
{
   PHB_TSD  pTSD;
   void *   value;
}
HB_TSD_HOLDER, * PHB_TSD_HOLDER;

typedef struct
{
   PHB_DYNS    pDynSym;
   PHB_ITEM    pPrevMemvar;
}
HB_PRIVATE_ITEM, * PHB_PRIVATE_ITEM;

typedef struct
{
   PHB_PRIVATE_ITEM stack;
   ULONG       size;
   ULONG       count;
   ULONG       base;
}
HB_PRIVATE_STACK, * PHB_PRIVATE_STACK;

#if defined( HB_MT_VM )
typedef struct
{
   void *   pMemvar;       /* memvar pointer ( publics & privates ) */
   USHORT   uiArea;        /* Workarea number */
}
HB_DYN_HANDLES, * PHB_DYN_HANDLES;
#endif

/* stack managed by the virtual machine */
typedef struct
{
   PHB_ITEM * pItems;         /* pointer to the stack items */
   PHB_ITEM * pPos;           /* pointer to the latest used item */
   PHB_ITEM * pEnd;           /* pointer to the end of stack items */
   LONG       wItems;         /* total items that may be holded on the stack */
   HB_ITEM    Return;         /* latest returned value */
   PHB_ITEM * pBase;          /* stack frame position for the current function call */
   LONG       lStatics;       /* statics base for the current function call */
   LONG       lWithObject;    /* stack offset to base current WITH OBJECT item */
   LONG       lRecoverBase;   /* current SEQUENCE envelope offset or 0 if no SEQUENCE is active */
   USHORT     uiActionRequest;/* request for some action - stop processing of opcodes */
   USHORT     uiQuitState;    /* HVM is quiting */
   HB_STACK_STATE state;      /* first (default) stack state frame */
   HB_STACKRDD rdd;           /* RDD related data */
   char       szDate[ 9 ];    /* last returned date from _pards() yyyymmdd format */
   void *     pCDP;           /* current codepage module */
   void *     pLang;          /* current language module */
   const char * szDefaultRDD; /* default RDD */
   int        iArea;          /* current workarea number */
   int        iAreaCount;     /* number of allocated workareas number */
   void **    pWorkAreas;     /* workareas pool */
   BOOL       fNetErr;        /* current NETERR() flag */
   int        iTSD;           /* number of allocated TSD holders */
   PHB_TSD_HOLDER pTSD;       /* thread specific data holder */
   HB_PRIVATE_STACK privates; /* private variables stack */
   HB_SET_STRUCT set;
#if defined( HB_MT_VM )
   int        iUnlocked;      /* counter for nested hb_vmUnlock() calls */
   PHB_DYN_HANDLES pDynH;     /* dynamic symbol handles */
   int        iDynH;          /* number of dynamic symbol handles */
   void *     pStackLst;      /* this stack entry in stack linked list */
   HB_IOERRORS IOErrors;      /* MT safe buffer for IO errors */
   BYTE *     byDirBuffer;    /* MT safe buffer for hb_fsCurDir() results */
#endif
} HB_STACK, * PHB_STACK;

#if defined( HB_STACK_MACROS )
#  if defined( HB_MT_VM )
#     if defined( HB_USE_TLS )
#        if defined( __BORLANDC__ )
            extern PHB_STACK HB_TLS_ATTR hb_stack_ptr;
#        else
            extern HB_TLS_ATTR PHB_STACK hb_stack_ptr;
#        endif
#     else
         extern HB_TLS_KEY hb_stack_key;
#        if defined( __BORLANDC__ )
            static __inline void* hb_stack_ptr_from_tls( void )
            {
               /* mov ecx,hb_stack_key */
               _ECX = hb_stack_key;
               /* mov eax,dword ptr fs:[00000018h] */
               __emit__( 0x64, 0xA1, 0x18, 0x00, 0x00, 0x00 );
               /* mov eax,[eax+ecx*4+00000E10h] */
               __emit__( 0x8B, 0x84, 0x88, 0x10, 0x0E, 0x00, 0x00 );
               /* ret (if function is not inlined) */
               return (void*) _EAX;
            }
#        elif defined( __MINGW32__ )
            static __inline__  __attribute__ ((pure, malloc)) void * hb_stack_ptr_from_tls( void )
            {
               void * p;
               __asm__ (
                  "movl  %%fs:(0x18), %0\n\t"
                  "movl  0x0e10(%0,%1,4), %0\n\t"
                  :"=a" (p)
                  :"c" (hb_stack_key)
               );
               return p;
            }
#           define hb_stack_ptr  ( ( PHB_STACK ) hb_stack_ptr_from_tls() )
#        endif
#        if !defined( hb_stack_ptr )
#           define hb_stack_ptr  ( ( PHB_STACK ) hb_tls_get( hb_stack_key ) )
#        endif
#     endif
#     if defined( HB_STACK_PRELOAD ) && !defined( HB_USE_TLS )
#        if defined( __BORLANDC__ ) || defined( __MINGW32__ )
#           define HB_STACK_TLS_PRELOAD   PHB_STACK _hb_stack_ptr_ = ( PHB_STACK ) hb_stack_ptr_from_tls();
#           undef hb_stack_ptr
#        else
#           define HB_STACK_TLS_PRELOAD   PHB_STACK _hb_stack_ptr_ = hb_stack_ptr;
#        endif
#        define hb_stack      ( * _hb_stack_ptr_ )
#     else
#        define hb_stack      ( * hb_stack_ptr )
#     endif
#  else
      extern HB_STACK hb_stack;
#  endif
#endif
#if !defined( HB_STACK_TLS_PRELOAD ) && defined( HB_STACK_PRELOAD )
#  define HB_STACK_TLS_PRELOAD
#  undef  HB_STACK_PRELOAD
#endif

#endif /* _HB_API_INTERNAL_ */

extern HB_ITEM_PTR hb_stackItemFromTop( int nFromTop );
extern HB_ITEM_PTR hb_stackItemFromBase( int nFromBase );
extern LONG        hb_stackTopOffset( void );
extern LONG        hb_stackBaseOffset( void );
extern LONG        hb_stackTotalItems( void );
extern HB_ITEM_PTR hb_stackBaseItem( void );
extern HB_ITEM_PTR hb_stackItem( LONG iItemPos );
extern HB_ITEM_PTR hb_stackSelfItem( void );   /* returns Self object at C function level */
extern HB_ITEM_PTR hb_stackReturnItem( void ); /* returns RETURN Item from stack */
extern char *      hb_stackDateBuffer( void );
extern void *      hb_stackId( void );

extern void        hb_stackDec( void );        /* pops an item from the stack without clearing it's contents */
extern void        hb_stackPop( void );        /* pops an item from the stack */
extern void        hb_stackPush( void );       /* pushes an item on to the stack */
extern HB_ITEM_PTR hb_stackAllocItem( void );  /* allocates new item on the top of stack, returns pointer to it */
extern void        hb_stackPushReturn( void );
extern void        hb_stackPopReturn( void );
extern void        hb_stackRemove( LONG lUntilPos );

/* stack management functions */
extern int        hb_stackCallDepth( void );
extern LONG       hb_stackBaseProcOffset( int iLevel );
extern void       hb_stackBaseProcInfo( char * szProcName, USHORT * puiProcLine ); /* get current .prg function name and line number */
extern void       hb_stackDispLocal( void );  /* show the types of the items on the stack for debugging purposes */
extern void       hb_stackDispCall( void );
extern void       hb_stackFree( void );       /* releases all memory used by the stack */
extern void       hb_stackInit( void );       /* initializes the stack */
extern void       hb_stackIncrease( void );   /* increase the stack size */

/* thread specific data */
extern void *     hb_stackGetTSD( PHB_TSD pTSD );
extern void *     hb_stackTestTSD( PHB_TSD pTSD );

extern BYTE *     hb_stackDirBuffer( void );
extern PHB_IOERRORS hb_stackIOErrors( void );
extern PHB_STACKRDD hb_stackRDD( void );

#ifdef _HB_API_INTERNAL_
extern void        hb_stackDecrease( ULONG ulItems );
extern HB_ITEM_PTR hb_stackNewFrame( PHB_STACK_STATE pFrame, USHORT uiParams );
extern void        hb_stackOldFrame( PHB_STACK_STATE pFrame );
extern void        hb_stackClearMevarsBase( void );

extern HB_ITEM_PTR hb_stackLocalVariable( int *piFromBase );
extern PHB_ITEM ** hb_stackItemBasePtr( void );

extern LONG        hb_stackGetRecoverBase( void );
extern void        hb_stackSetRecoverBase( LONG lBase );
extern USHORT      hb_stackGetActionRequest( void );
extern void        hb_stackSetActionRequest( USHORT uiAction );

extern void        hb_stackSetStaticsBase( LONG lBase );
extern LONG        hb_stackGetStaticsBase( void );

extern PHB_ITEM    hb_stackWithObjectItem( void );
extern LONG        hb_stackWithObjectOffset( void );
extern void        hb_stackWithObjectSetOffset( LONG );

extern void        hb_stackDestroyTSD( void );

extern PHB_PRIVATE_STACK hb_stackGetPrivateStack( void );
extern void *      hb_stackGetCDP( void );
extern void        hb_stackSetCDP( void * );
extern void *      hb_stackGetLang( void );
extern void        hb_stackSetLang( void * );

extern void        hb_stackIsStackRef( void *, PHB_TSD_FUNC );

#if defined( HB_MT_VM )
   extern void *           hb_stackList( void );
   extern void             hb_stackListSet( void * pStackLst );
   extern void             hb_stackIdSetActionRequest( void * pStackID, USHORT uiAction );
   extern PHB_DYN_HANDLES  hb_stackGetDynHandle( PHB_DYNS pDynSym );
   extern BOOL             hb_stackQuitState( void );
   extern void             hb_stackSetQuitState( USHORT uiState );
   extern int              hb_stackUnlock( void );
   extern int              hb_stackLock( void );
#endif

#endif /* _HB_API_INTERNAL_ */

#if defined( _HB_API_INTERNAL_ ) || defined( _HB_SET_INTERNAL_ )
   extern PHB_SET_STRUCT hb_stackSetStruct( void );
#endif


#if defined( HB_STACK_MACROS )

#define hb_stackItemFromTop( n )    ( * ( hb_stack.pPos + ( int ) (n) ) )
#define hb_stackItemFromBase( n )   ( * ( hb_stack.pBase + ( int ) (n) + 1 ) )
#define hb_stackTopOffset( )        ( hb_stack.pPos - hb_stack.pItems )
#define hb_stackBaseOffset( )       ( hb_stack.pBase - hb_stack.pItems + 1 )
#define hb_stackTotalItems( )       ( hb_stack.wItems )
#define hb_stackBaseItem( )         ( * hb_stack.pBase )
#define hb_stackSelfItem( )         ( * ( hb_stack.pBase + 1 ) )
#define hb_stackItem( iItemPos )    ( * ( hb_stack.pItems + ( iItemPos ) ) )
#define hb_stackReturnItem( )       ( &hb_stack.Return )
#define hb_stackDateBuffer( )       ( hb_stack.szDate )
#define hb_stackItemBasePtr( )      ( &hb_stack.pItems )
#define hb_stackGetStaticsBase( )   ( hb_stack.lStatics )
#define hb_stackSetStaticsBase( n ) do { hb_stack.lStatics = ( n ); } while ( 0 )
#define hb_stackGetRecoverBase( )   ( hb_stack.lRecoverBase )
#define hb_stackSetRecoverBase( n ) do { hb_stack.lRecoverBase = ( n ); } while( 0 )
#define hb_stackGetActionRequest( ) ( hb_stack.uiActionRequest )
#define hb_stackSetActionRequest( n )     do { hb_stack.uiActionRequest = ( n ); } while( 0 )
#define hb_stackWithObjectItem( )   ( hb_stack.lWithObject ? * ( hb_stack.pItems + hb_stack.lWithObject ) : NULL )
#define hb_stackWithObjectOffset( ) ( hb_stack.lWithObject )
#define hb_stackWithObjectSetOffset( n )  do { hb_stack.lWithObject = ( n ); } while( 0 )
#define hb_stackGetCDP( )           ( hb_stack.pCDP )
#define hb_stackSetCDP( p )         do { hb_stack.pCDP = ( p ); } while ( 0 )
#define hb_stackGetLang( )          ( hb_stack.pLang )
#define hb_stackSetLang( p )        do { hb_stack.pLang = ( p ); } while ( 0 )

#define hb_stackId( )               ( ( void * ) &hb_stack )
#if defined( HB_MT_VM )
#  define hb_stackList( )           ( hb_stack.pStackLst )
#  define hb_stackListSet( p )      do { hb_stack.pStackLst = ( p ); } while ( 0 )
#  define hb_stackQuitState( )      ( hb_stack.uiQuitState != 0 )
#  define hb_stackSetQuitState( n ) do { hb_stack.uiQuitState = ( n ); } while( 0 )
#  define hb_stackUnlock()          ( ++hb_stack.iUnlocked )
#  define hb_stackLock()            ( --hb_stack.iUnlocked )
#endif

#define hb_stackAllocItem( )        ( ( ++hb_stack.pPos == hb_stack.pEnd ? \
                                        hb_stackIncrease() : (void) 0 ), \
                                      * ( hb_stack.pPos - 1 ) )

#ifdef HB_STACK_SAFEMACROS

#define hb_stackDecrease( n )       do { \
                                       if( ( hb_stack.pPos -= (n) ) <= hb_stack.pBase ) \
                                          hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
                                    } while ( 0 )

#define hb_stackDec( )              do { \
                                       if( --hb_stack.pPos <= hb_stack.pBase ) \
                                          hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
                                    } while ( 0 )

#define hb_stackPop( )              do { \
                                       if( --hb_stack.pPos <= hb_stack.pBase ) \
                                          hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
                                       if( HB_IS_COMPLEX( * hb_stack.pPos ) ) \
                                          hb_itemClear( * hb_stack.pPos ); \
                                    } while ( 0 )

#define hb_stackPopReturn( )        do { \
                                       if( HB_IS_COMPLEX( &hb_stack.Return ) ) \
                                          hb_itemClear( &hb_stack.Return ); \
                                       if( --hb_stack.pPos <= hb_stack.pBase ) \
                                          hb_errInternal( HB_EI_STACKUFLOW, NULL, NULL, NULL ); \
                                       hb_itemRawMove( &hb_stack.Return, * hb_stack.pPos ); \
                                    } while ( 0 )

#else

#define hb_stackDecrease( n )       do { hb_stack.pPos -= (n); } while ( 0 )
#define hb_stackDec( )              do { --hb_stack.pPos; } while ( 0 )
#define hb_stackPop( )              do { --hb_stack.pPos; \
                                       if( HB_IS_COMPLEX( * hb_stack.pPos ) ) \
                                          hb_itemClear( * hb_stack.pPos ); \
                                    } while ( 0 )
#define hb_stackPopReturn( )        do { \
                                       if( HB_IS_COMPLEX( &hb_stack.Return ) ) \
                                          hb_itemClear( &hb_stack.Return ); \
                                       --hb_stack.pPos; \
                                       hb_itemRawMove( &hb_stack.Return, * hb_stack.pPos ); \
                                    } while ( 0 )

#endif

#define hb_stackPush( )             do { \
                                       if( ++hb_stack.pPos == hb_stack.pEnd ) \
                                          hb_stackIncrease(); \
                                    } while ( 0 )

#define hb_stackPushReturn( )       do { \
                                       hb_itemRawMove( * hb_stack.pPos, &hb_stack.Return ); \
                                       if( ++hb_stack.pPos == hb_stack.pEnd ) \
                                          hb_stackIncrease(); \
                                    } while ( 0 )

#define hb_stackLocalVariable( p )  ( ( ( ( *hb_stack.pBase )->item.asSymbol.paramcnt > \
                                          ( * hb_stack.pBase )->item.asSymbol.paramdeclcnt ) && \
                                        ( * (p) ) > ( * hb_stack.pBase )->item.asSymbol.paramdeclcnt ) ? \
                                      ( * ( hb_stack.pBase + ( int ) ( * (p) += \
                                          ( * hb_stack.pBase )->item.asSymbol.paramcnt - \
                                          ( * hb_stack.pBase )->item.asSymbol.paramdeclcnt ) + 1 ) ) : \
                                      ( * ( hb_stack.pBase + ( int ) ( * (p) ) + 1 ) ) )

#define hb_stackGetPrivateStack( )  ( &hb_stack.privates )
#define hb_stackSetStruct( )        ( &hb_stack.set )

#endif


HB_EXTERN_END

#endif /* HB_STACK_H_ */
c:\harbour\include\hbsxfunc.h
/*
 * $Id: hbsxfunc.h 9252 2008-08-26 11:33:03Z vszakats $
 */

/*
 * xHarbour Project source code:
 *    header file for SIX compatible functions
 *
 * Copyright 2005 Przemyslaw Czerpak 
 * www - http://www.xharbour.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.
 *
 */

#ifndef HB_SXFUNC_H_
#define HB_SXFUNC_H_

#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapifs.h"
#include "hbapirdd.h"
#include "hbapierr.h"
#include "hbdate.h"

HB_EXTERN_BEGIN

char * hb_sxDtoP( char * pDate, LONG lJulian );
LONG hb_sxPtoD( char * pDate );

void hb_sxEnCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen );
void hb_sxDeCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen );

BOOL hb_LZSSxDecompressMem( BYTE * pSrcBuf, ULONG ulSrcLen, BYTE * pDstBuf, ULONG ulDstLen );
BOOL hb_LZSSxCompressMem( BYTE * pSrcBuf, ULONG ulSrcLen, BYTE * pDstBuf, ULONG ulDstLen, ULONG * pulSize );
BOOL hb_LZSSxCompressFile( HB_FHANDLE hInput, HB_FHANDLE hOutput, ULONG * pulSize );
BOOL hb_LZSSxDecompressFile( HB_FHANDLE hInput, HB_FHANDLE hOutput );

HB_EXTERN_END

#endif /* HB_SXFUNC_H_ */
c:\harbour\include\hbthread.h
/*
 * $Id: hbthread.h 9514 2008-09-29 09:19:46Z druzus $
 */

/*
 * Harbour Project source code:
 *    header file with MT mode functions
 *
 * Copyright 2008 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_THREAD_H_
#define HB_THREAD_H_

#include "hbapi.h"
#include "hbset.h"

#if defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
#  include 
#  define HB_PTHREAD_API
#elif defined( HB_OS_WIN_32 )
#  include 
#  include 
#endif

HB_EXTERN_BEGIN

/* Inline assembler version of atomic operations on memory reference counters */
#if HB_COUNTER_SIZE == 4 && defined( __GNUC__ ) && \
    ( defined( i386 ) || defined( __i386__ ) || defined( __x86_64__ ) )

   static __inline__ void hb_atomic_inc32( volatile int * p )
   {
      __asm__ __volatile__(
         "lock; incl %0\n"
         :"=m" (*p) :"m" (*p)
      );
   }

   static __inline__ int hb_atomic_dec32( volatile int * p )
   {
      unsigned char c;
      __asm__ __volatile__(
         "lock; decl %0\n"
         "sete %1\n"
         :"=m" (*p), "=qm" (c) :"m" (*p) : "memory"
      );
      return c == 0;
   }

#  define HB_ATOM_INC( p )    ( hb_atomic_inc32( ( volatile int * ) (p) ) )
#  define HB_ATOM_DEC( p )    ( hb_atomic_dec32( ( volatile int * ) (p) ) )
#  define HB_ATOM_GET( p )    (*(int volatile *)(p))
#  define HB_ATOM_SET( p, n ) do { (*(int volatile *)(p)) = (n); } while(0)

#endif


#if defined( HB_PTHREAD_API )

   typedef pthread_t       HB_THREAD_ID;
   typedef pthread_t       HB_THREAD_T;
   typedef pthread_mutex_t HB_RAWCRITICAL_T;
   typedef pthread_cond_t  HB_RAWCOND_T;

#  define HB_THREAD_STARTFUNC( func )     void * func( void * Cargo )
#  define HB_THREAD_END                   return NULL;
#  define HB_THREAD_RAWEND                return NULL;

#  define HB_THREAD_SELF()          pthread_self()
#  define HB_THREAD_EQUAL( x, y )   pthread_equal( x, y )

#  define HB_CRITICAL_LOCK(v)       pthread_mutex_lock( &(v) )
#  define HB_CRITICAL_UNLOCK(v)     pthread_mutex_unlock( &(v) )
#  define HB_COND_SIGNAL(v)         pthread_cond_signal( &(v) )
#  define HB_COND_SIGNALN(v,n)      pthread_cond_broadcast( &(v) )

#  if defined( PTHREAD_MUTEX_INITIALIZER )
      typedef pthread_mutex_t          HB_CRITICAL_T;
#     define HB_CRITICAL_NEW( name )   HB_CRITICAL_T name = PTHREAD_MUTEX_INITIALIZER
#     define HB_CRITICAL_GET(v)        ( v )
#  else     /* platform does not support static mutex initialization */
#     define HB_CRITICAL_INIT(v)       pthread_mutex_init( &(v), NULL )
#     define HB_CRITICAL_DESTROY(v)    pthread_mutex_destroy( &(v) )
#     define HB_CRITICAL_GET(v)        ( &( (v)->critical ) )
#  endif

#  if defined( PTHREAD_COND_INITIALIZER )
      typedef pthread_cond_t           HB_COND_T;
#     define HB_COND_NEW( name )       HB_COND_T name = PTHREAD_COND_INITIALIZER
#     define HB_COND_GET(v)            ( v )
#  else     /* platform does not support static condition var initialization */
#     define HB_COND_INIT(v)           pthread_cond_init( &(v), NULL )
#     define HB_COND_GET(v)            ( &( (v)->cond ) )
#  endif

#elif defined( HB_OS_WIN_32 )

# define HB_MAX_THREAD  32768

   typedef unsigned           HB_THREAD_ID;
   typedef HANDLE             HB_THREAD_T;
   typedef CRITICAL_SECTION   HB_RAWCRITICAL_T;
   typedef HANDLE             HB_RAWCOND_T;

#  define HB_THREAD_STARTFUNC( func )     unsigned __stdcall func( void * Cargo )
#  define HB_THREAD_END                   _endthreadex( 0 ); return 0;
#  define HB_THREAD_RAWEND                return 0;

#  define HB_CRITICAL_INITVAL       { 0, 0, 0, 0, 0, 0 }
#  define HB_COND_INITVAL           ( ( HANDLE ) NULL )
#  define HB_THREAD_SELF()          GetCurrentThreadId()

#  define HB_CRITICAL_INIT(v)       InitializeCriticalSection( &(v) )
#  define HB_CRITICAL_DESTROY(v)    DeleteCriticalSection( &(v) )
#  define HB_CRITICAL_LOCK(v)       EnterCriticalSection( &(v) )
#  define HB_CRITICAL_UNLOCK(v)     LeaveCriticalSection( &(v) )
#  define HB_COND_INIT(v)           do { (v) = CreateSemaphore( NULL, 0, HB_MAX_THREAD, NULL ); } while(0)
#  define HB_COND_DESTROY(v)        CloseHandle( v )
#  define HB_COND_SIGNAL(v)         ReleaseSemaphore( (v), 1, NULL )
#  define HB_COND_SIGNALN(v,n)      ReleaseSemaphore( (v), (n), NULL )
#  define HB_COND_WAIT(v)           ( WaitForSingleObject( (v), INFINITE ) != WAIT_FAILED )
#  define HB_COND_TIMEDWAIT(v,n)    ( WaitForSingleObject( (v), (n) ) != WAIT_FAILED )

   /* Atomic operations on memory reference counters */
#  if !defined( HB_ATOM_INC ) || !defined( HB_ATOM_DEC )
#     undef HB_ATOM_DEC
#     undef HB_ATOM_INC
#     undef HB_ATOM_GET
#     undef HB_ATOM_SET
#     if HB_COUNTER_SIZE == 8
#        define HB_ATOM_INC( p )    (InterlockedIncrement64((LONGLONG *)(p)))
#        define HB_ATOM_DEC( p )    (InterlockedDecrement64((LONGLONG *)(p)))
#        define HB_ATOM_GET( p )    (*(LONGLONG volatile *)(p))
#        define HB_ATOM_SET( p, n ) do { (*(LONGLONG volatile *)(p)) = (n); } while(0)
#     else
#        define HB_ATOM_INC( p )    (InterlockedIncrement((LONG *)(p)))
#        define HB_ATOM_DEC( p )    (InterlockedDecrement((LONG *)(p)))
#        define HB_ATOM_GET( p )    (*(LONG volatile *)(p))
#        define HB_ATOM_SET( p, n ) do { (*(LONG volatile *)(p)) = (n); } while(0)
#     endif
#  endif


#elif defined( HB_OS_OS2 )

   typedef TID                HB_THREAD_ID;
   typedef TID                HB_THREAD_T;
   typedef HMTX               HB_RAWCRITICAL_T;
   typedef HEV                HB_RAWCOND_T;

#  define HB_THREAD_STARTFUNC( func )     void func( void * Cargo )
#  define HB_THREAD_END                   _endthread(); return;
#  define HB_THREAD_RAWEND                return;

#  define HB_CRITICAL_INITVAL ( ( HMTX ) 0 )
#  define HB_COND_INITVAL     ( ( HEV ) 0 )
#  define HB_THREAD_SELF()    ( ( TID ) _gettid() )

#  define HB_CRITICAL_INIT(v)       DosCreateMutexSem( NULL, &(v), 0L, FALSE )
#  define HB_CRITICAL_DESTROY(v)    DosCloseMutexSem( v )
#  define HB_CRITICAL_LOCK(v)       DosRequestMutexSem( (v), SEM_INDEFINITE_WAIT )
#  define HB_CRITICAL_UNLOCK(v)     DosReleaseMutexSem( v )
#  define HB_COND_INIT(v)           DosCreateEventSem( NULL, &(v), 0L, FALSE );
#  define HB_COND_DESTROY(v)        DosCloseEventSem( v )
#  define HB_COND_SIGNAL(v)         DosPostEventSem( v )
#  define HB_COND_SIGNALN(v,n)      do { int i = (n); while( --i >= 0 ) DosPostEventSem( v ); } while(0)
#  define HB_COND_WAIT(v)           ( DosWaitEventSem( (v), SEM_INDEFINITE_WAIT ) == NO_ERROR )
#  define HB_COND_TIMEDWAIT(v,n)    ( DosWaitEventSem( (v), (n) ) == NO_ERROR )

#else

   typedef int HB_THREAD_ID;
   typedef int HB_THREAD_T;
   typedef int HB_CRITICAL_T;
   typedef int HB_RAWCRITICAL_T;
   typedef int HB_COND_T;
   typedef int HB_RAWCOND_T;

#  define HB_THREAD_STARTFUNC( func )     void func( void * Cargo )
#  define HB_THREAD_END                   return;
#  define HB_THREAD_RAWEND                return;

#  define HB_CRITICAL_NEW( name )      HB_CRITICAL_T name = 0
#  define HB_COND_NEW( name )          HB_COND_T name = 0
#  define HB_THREAD_SELF()             (-1)

#  define HB_CRITICAL_LOCK(v)
#  define HB_CRITICAL_UNLOCK(v)
#  define HB_COND_SIGNAL(v)
#  define HB_COND_SIGNALN(v,n)
#  define HB_COND_WAIT(v)           ( FALSE )
#  define HB_COND_TIMEDWAIT(v,n)    ( FALSE )

#endif

#ifdef HB_CRITICAL_INIT
   typedef struct
   {
      BOOL  fInit;
      HB_RAWCRITICAL_T  critical;
   } HB_CRITICAL_T;
#  define HB_CRITICAL_NEW( name )   HB_CRITICAL_T name = { FALSE, HB_CRITICAL_INITVAL }
#endif /* HB_CRITICAL_INIT */

#ifdef HB_COND_INIT
   typedef struct
   {
      BOOL     fInit;
      int      waiters;
      HB_RAWCOND_T      cond;
      HB_RAWCRITICAL_T  critical;
   } HB_COND_T;
#  define HB_COND_NEW( name )       HB_COND_T name = { FALSE, 0, HB_COND_INITVAL, HB_CRITICAL_INITVAL }
#endif /* HB_COND_INIT */

#ifndef HB_THREAD_EQUAL
#  define HB_THREAD_EQUAL( x, y )   ( (x) == (y) )
#endif


typedef HB_THREAD_STARTFUNC( PHB_THREAD_STARTFUNC );

typedef struct _HB_THREADSTATE
{
   const char *   pszCDP;
   const char *   pszLang;
   const char *   pszDefRDD;
   PHB_SET_STRUCT pSet;
   void *         pStackId;
   BOOL           fActive;
   PHB_ITEM       pParams;
   PHB_ITEM       pMemvars;
   PHB_ITEM       pResult;
   PHB_ITEM       pThItm;
   HB_THREAD_T    th_id;
   struct _HB_THREADSTATE * pPrev;
   struct _HB_THREADSTATE * pNext;
} HB_THREADSTATE, * PHB_THREADSTATE;

extern void hb_threadInit( void );
extern void hb_threadExit( void );

extern PHB_THREADSTATE hb_threadStateNew( void );

/* Critical sections or fast non recursive MUTEXes */
extern void hb_threadEnterCriticalSection( HB_CRITICAL_T * critical );
extern void hb_threadLeaveCriticalSection( HB_CRITICAL_T * critical );

extern BOOL hb_threadCondSignal( HB_COND_T * cond );
extern BOOL hb_threadCondBroadcast( HB_COND_T * cond );
extern BOOL hb_threadCondWait( HB_COND_T * cond, HB_CRITICAL_T * mutex );
extern BOOL hb_threadCondTimedWait( HB_COND_T * cond, HB_CRITICAL_T * mutex, ULONG ulMilliSec );

extern HB_THREAD_T hb_threadCreate( PHB_THREAD_STARTFUNC start_func, void * Cargo );
extern BOOL        hb_threadJoin( HB_THREAD_T th_id );
extern BOOL        hb_threadDetach( HB_THREAD_T th_id );

/* used by .prg code */
extern PHB_ITEM hb_threadMutexCreate( BOOL fSync );
extern BOOL     hb_threadMutexLock( PHB_ITEM pItem );
extern BOOL     hb_threadMutexTimedLock( PHB_ITEM pItem, ULONG ulMilliSec );
extern BOOL     hb_threadMutexUnlock( PHB_ITEM pItem );
extern void     hb_threadMutexNotify( PHB_ITEM pItem, PHB_ITEM pNotifier, BOOL fWaiting );
extern PHB_ITEM hb_threadMutexSubscribe( PHB_ITEM pItem, BOOL fClear );
extern PHB_ITEM hb_threadMutexTimedSubscribe( PHB_ITEM pItem, ULONG ulMilliSec, BOOL fClear );

#if defined( HB_MT_VM ) && defined( _HB_API_INTERNAL_ )

extern void hb_threadMutexUnlockAll( void );

#if defined( HB_NO_TLS )
#  undef HB_USE_TLS
#elif !defined( HB_USE_TLS )
   /* enable native compiler TLS support be default for this compilers
    * which are known that it will work correctly
    */
#  if defined( _MSC_VER )
#     define HB_USE_TLS
#  elif defined( __GNUC__ ) && __GNUC__ >= 3 && \
        defined( __GLIBC__ ) && defined( __GLIBC_MINOR__ ) && \
        ( __GLIBC__ > 2 || ( __GLIBC__ == 2 && __GLIBC_MINOR__ >= 6 ) ) && \
        defined( HB_OS_LINUX ) && \
        ( defined( __i386__ ) || defined( __x86_64__ ) )
#     define HB_USE_TLS
#  endif
#endif

#ifdef HB_USE_TLS
#  if ( defined( __GNUC__ ) && __GNUC__ >= 3 ) || defined( __BORLANDC__ )
#     define HB_TLS_ATTR      __thread
#  elif defined( _MSC_VER ) || defined( __WATCOMC__ ) || defined( __DMC__ )
#     define HB_TLS_ATTR      __declspec( thread )
#  else
#     undef HB_USE_TLS
#     error "TLS support undefined for this compiler" /* */
#  endif
#endif

#ifndef HB_USE_TLS
#  if defined( HB_PTHREAD_API )
#     define HB_TLS_KEY       pthread_key_t
#     define hb_tls_init(k)   pthread_key_create( &k, NULL )
#     define hb_tls_set(k,v)  pthread_setspecific( k, ( void * ) (v) )
#     define hb_tls_get(k)    pthread_getspecific( k )
#  elif defined( HB_OS_WIN_32 )
#     define HB_TLS_KEY       DWORD
#     define hb_tls_init(k)   do { k = TlsAlloc(); } while( 0 )
#     define hb_tls_set(k,v)  TlsSetValue( k, ( void * ) (v) )
#     define hb_tls_get(k)    TlsGetValue( k )
#  elif defined( HB_OS_OS2 )
#     define HB_TLS_KEY       PULONG
#     define hb_tls_init(k)   DosAllocThreadLocalMemory( 1, &k )
#     define hb_tls_set(k,v)  do { *k = ( ULONG ) (v); } while( 0 )
#     define hb_tls_get(k)    ( *k )
#  endif
#endif

#endif

HB_EXTERN_END

#endif /* HB_THREAD_H_ */
c:\harbour\include\hbtrace.h
/*
 * $Id: hbtrace.h 9374 2008-09-13 16:53:45Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for trace macros and functions.
 *
 * Copyright 1999 Gonzalo Diethelm 
 * 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.
 *
 */

#ifndef HB_TRACE_H_
#define HB_TRACE_H_

#include "hbsetup.h"

HB_EXTERN_BEGIN

/*
 * Tracing levels.
 */
#define HB_TR_ALWAYS     0
#define HB_TR_FATAL      1
#define HB_TR_ERROR      2
#define HB_TR_WARNING    3
#define HB_TR_INFO       4
#define HB_TR_DEBUG      5
#define HB_TR_LAST       6

/*
 * Default tracing level.
 */
#define HB_TR_DEFAULT   HB_TR_WARNING

/*
 * If we compiled without specifying a -DHB_TR_LEVEL, use the value
 * for HB_TR_DEFAULT.
 */

#ifdef HB_TR_LEVEL_ALWAYS
#define HB_TR_LEVEL     HB_TR_ALWAYS
#endif
#ifdef HB_TR_LEVEL_FATAL
#define HB_TR_LEVEL     HB_TR_FATAL
#endif
#ifdef HB_TR_LEVEL_ERROR
#define HB_TR_LEVEL     HB_TR_ERROR
#endif
#ifdef HB_TR_LEVEL_WARNING
#define HB_TR_LEVEL     HB_TR_WARNING
#endif
#ifdef HB_TR_LEVEL_INFO
#define HB_TR_LEVEL     HB_TR_INFO
#endif
#ifdef HB_TR_LEVEL_DEBUG
#define HB_TR_LEVEL     HB_TR_DEBUG
#endif

#ifndef HB_TR_LEVEL
#define HB_TR_LEVEL     HB_TR_DEFAULT
#endif


/*
 * This is black magic...
 * What we do here is to generate calls to HB_ECHO_CREATE only for those
 * levels that are less or equal to the COMPILATION time HB_TR_LEVEL.
 */

#define HB_ECHO_CREATE( l, x )  do \
                                { \
                                   if( hb_tr_level() >= l ) \
                                   { \
                                      hb_tr_file_ = __FILE__; \
                                      hb_tr_line_ = __LINE__; \
                                      hb_tr_level_ = l; \
                                      hb_tr_trace x ; \
                                   } \
                                } while( 0 )

#if HB_TR_LEVEL >= HB_TR_DEBUG
#define HB_ECHO_TRACE_HB_TR_DEBUG(x)    HB_ECHO_CREATE(HB_TR_DEBUG, x)
#else
#define HB_ECHO_TRACE_HB_TR_DEBUG(x)
#endif

#if HB_TR_LEVEL >= HB_TR_INFO
#define HB_ECHO_TRACE_HB_TR_INFO(x)     HB_ECHO_CREATE(HB_TR_INFO, x)
#else
#define HB_ECHO_TRACE_HB_TR_INFO(x)
#endif

#if HB_TR_LEVEL >= HB_TR_WARNING
#define HB_ECHO_TRACE_HB_TR_WARNING(x)  HB_ECHO_CREATE(HB_TR_WARNING, x)
#else
#define HB_ECHO_TRACE_HB_TR_WARNING(x)
#endif

#if HB_TR_LEVEL >= HB_TR_ERROR
#define HB_ECHO_TRACE_HB_TR_ERROR(x)    HB_ECHO_CREATE(HB_TR_ERROR, x)
#else
#define HB_ECHO_TRACE_HB_TR_ERROR(x)
#endif

#if HB_TR_LEVEL >= HB_TR_FATAL
#define HB_ECHO_TRACE_HB_TR_FATAL(x)    HB_ECHO_CREATE(HB_TR_FATAL, x)
#else
#define HB_ECHO_TRACE_HB_TR_FATAL(x)
#endif

#if 1  /* always! */
#define HB_ECHO_TRACE_HB_TR_ALWAYS(x)   HB_ECHO_CREATE(HB_TR_ALWAYS, x)
#else
#define HB_ECHO_TRACE_HB_TR_ALWAYS(x)
#endif


#define HB_TRACE(l, x)                HB_ECHO_TRACE_##l(x)

/* NOTE: This will print tracing info without changing current
 * filename/linenum information - this is usefull if we want to
 * trace the source of unreleased memory blocks
 */
#define HB_ECHO_STEALTH( l, x ) do \
                                { \
                                   if( hb_tr_level() >= l ) \
                                   { \
                                      hb_tr_level_ = l; \
                                      hb_tr_trace x ; \
                                   } \
                                } while( 0 )

#if HB_TR_LEVEL >= HB_TR_DEBUG
#define HB_ECHO_STEALTH_HB_TR_DEBUG(x)    HB_ECHO_STEALTH(HB_TR_DEBUG, x)
#else
#define HB_ECHO_STEALTH_HB_TR_DEBUG(x)
#endif

#if HB_TR_LEVEL >= HB_TR_INFO
#define HB_ECHO_STEALTH_HB_TR_INFO(x)     HB_ECHO_STEALTH(HB_TR_INFO, x)
#else
#define HB_ECHO_STEALTH_HB_TR_INFO(x)
#endif

#if HB_TR_LEVEL >= HB_TR_WARNING
#define HB_ECHO_STEALTH_HB_TR_WARNING(x)  HB_ECHO_STEALTH(HB_TR_WARNING, x)
#else
#define HB_ECHO_STEALTH_HB_TR_WARNING(x)
#endif

#if HB_TR_LEVEL >= HB_TR_ERROR
#define HB_ECHO_STEALTH_HB_TR_ERROR(x)    HB_ECHO_STEALTH(HB_TR_ERROR, x)
#else
#define HB_ECHO_STEALTH_HB_TR_ERROR(x)
#endif

#if HB_TR_LEVEL >= HB_TR_FATAL
#define HB_ECHO_STEALTH_HB_TR_FATAL(x)    HB_ECHO_STEALTH(HB_TR_FATAL, x)
#else
#define HB_ECHO_STEALTH_HB_TR_FATAL(x)
#endif

#if 1  /* always! */
#define HB_ECHO_STEALTH_HB_TR_ALWAYS(x)   HB_ECHO_STEALTH(HB_TR_ALWAYS, x)
#else
#define HB_ECHO_STEALTH_HB_TR_ALWAYS(x)
#endif

/* NOTE: This will print tracing info without changing current
 * filename/linenum information
 */
#define HB_TRACE_STEALTH(l, x)            HB_ECHO_STEALTH_##l(x)

extern const char * hb_tr_file_;
extern int          hb_tr_line_;
extern int          hb_tr_level_;

extern int    hb_tracestate( int new_state );
extern int    hb_tracelevel( int new_level );

extern int    hb_tr_level( void );
extern void   hb_tr_trace( const char * fmt, ... );

HB_EXTERN_END

#endif /* HB_TRACE_H_ */
c:\harbour\include\hbtypes.h
/*
 * $Id: hbtypes.h 7041 2007-03-22 12:28:14Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for typedef for maindllp.c
 *
 * Copyright 2001-2002 Luiz Rafael Culik 
 * 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.
 *
 */

#ifndef HB_TYPES_H_
#define HB_TYPES_H_

#ifdef HB_API_MACROS
   #undef HB_API_MACROS
#endif

#include "hbvm.h"
#include "hbapiitm.h"

HB_EXTERN_BEGIN

typedef PHB_SYMB ( * VM_PROCESS_DLL_SYMBOLS ) ( PHB_SYMB pModuleSymbols,
                                                USHORT uiModuleSymbols );
typedef PHB_SYMB ( * VM_PROCESS_SYMBOLS_EX )
                        ( PHB_SYMB pModuleSymbols, USHORT uiModuleSymbols,
                          char * szModuleName, ULONG ulID, USHORT uiPcodeVer );

typedef void ( * VM_DLL_EXECUTE ) ( const BYTE * pCode, PHB_SYMB pSymbols );

typedef BOOL     ( * EXT_IS_ARRAY ) ( int iParam );
typedef char *   ( * EXT_PARC1 )  ( int iParam );
typedef char *   ( * EXT_PARC2 )  ( int iParam, ULONG ulArrayIndex );
typedef PHB_ITEM ( * HB_PARAM)( int iParam, long lMask );
typedef PHB_ITEM ( * HB_PARAMERROR)( int iParam );
typedef int      ( * HB_PCOUNTS )( void );
typedef void     ( * HB_RET)( void );
typedef void     ( * HB_RETC)( const char * szText );
typedef void     ( * HB_RETCLEN)( const char * szText, ULONG ulLen );
typedef void     ( * HB_RETDS)( const char * szDate );
typedef void     ( * HB_RETD)( int iYear, int iMonth, int iDay );
typedef void     ( * HB_RETDL)( long lJulian );
typedef void     ( * HB_RETL)( int iTrueFalse );
typedef void     ( * HB_RETND)( double dNumber );
typedef void     ( * HB_RETNI)( int iNumber );
typedef void     ( * HB_RETNL)( long lNumber );
typedef void     ( * HB_RETNLEN)( double dNumber, int iWidth, int iDec );
typedef void     ( * HB_RETNDLEN)( double dNumber, int iWidth, int iDec );
typedef void     ( * HB_RETNILEN)( int iNumber, int iWidth );
typedef void     ( * HB_RETNLLEN)( long lNumber, int iWidth );
typedef void     ( * HB_RETA)( ULONG ulLen );
typedef ULONG    ( * HB_PARINFA)( int iParamNum, ULONG uiArrayIndex );
typedef ULONG    ( * HB_PARINFO)( int iParam );
typedef ULONG    ( * HB_PARCLEN)( int iParam );
typedef ULONG    ( * HB_PARCSIZ)( int iParam );
typedef char *   ( * HB_PARDS)( int iParam );
typedef char *   ( * HB_PARDSBUFF)( char * szDate,int iParam);
typedef int      ( * HB_PARL)( int iParam );
typedef double   ( * HB_PARND)( int iParam );
typedef int      ( * HB_PARNI)( int iParam );
typedef long     ( * HB_PARNL)( int iParam );
typedef ULONG    ( * HB_PARCLEN2)( int iParam, ULONG ulArrayIndex );
typedef ULONG    ( * HB_PARCSIZ2)( int iParam, ULONG ulArrayIndex );
typedef char *   ( * HB_PARDS2)( int iParam, ULONG ulArrayIndex );
typedef char *   ( * HB_PARDSBUFF2)( char * szDate,int iParam, ULONG ulArrayIndex );
typedef int      ( * HB_PARL2)( int iParam, ULONG ulArrayIndex );
typedef double   ( * HB_PARND2)( int iParam, ULONG ulArrayIndex );
typedef int      ( * HB_PARNI2)( int iParam, ULONG ulArrayIndex );
typedef long     ( * HB_PARNL2)( int iParam, ULONG ulArrayIndex );
typedef int      ( * HB_STORC)( char * szText, int iParam );
typedef int      ( * HB_STORCLEN)( char * szText, ULONG ulLength, int iParam);
typedef int      ( * HB_STORDS)( char * szDate, int iParam) ;
typedef int      ( * HB_STORL)( int iLogical, int iParam );
typedef int      ( * HB_STORNI)( int iValue, int iParam );
typedef int      ( * HB_STORNL)( long lValue, int iParam );
typedef int      ( * HB_STORND)( double dValue, int iParam );
typedef int      ( * HB_STORC2)( char * szText, int iParam , ULONG ulArrayIndex);
typedef int      ( * HB_STORCLEN2)( char * szText, ULONG ulLength, int iParam , ULONG ulArrayIndex);
typedef int      ( * HB_STORDS2)( char * szDate, int iParam , ULONG ulArrayIndex) ;
typedef int      ( * HB_STORL2)( int iLogical, int iParam , ULONG ulArrayIndex);
typedef int      ( * HB_STORNI2)( int iValue, int iParam , ULONG ulArrayIndex);
typedef int      ( * HB_STORNL2)( long lValue, int iParam , ULONG ulArrayIndex);
typedef int      ( * HB_STORND2)( double dValue, int iParam , ULONG ulArrayIndex);
typedef BOOL     ( * HB_ARRAYNEW)( PHB_ITEM pItem, ULONG ulLen );
typedef ULONG    ( * HB_ARRAYLEN)( PHB_ITEM pArray );
typedef BOOL     ( * HB_ARRAYISOBJECT)( PHB_ITEM pArray );
typedef BOOL     ( * HB_ARRAYADD)( PHB_ITEM pArray, PHB_ITEM pItemValue );
typedef BOOL     ( * HB_ARRAYINS)( PHB_ITEM pArray, ULONG ulIndex );
typedef BOOL     ( * HB_ARRAYDEL)( PHB_ITEM pArray, ULONG ulIndex );
typedef BOOL     ( * HB_ARRAYSIZE)( PHB_ITEM pArray, ULONG ulLen );
typedef BOOL     ( * HB_ARRAYLAST)( PHB_ITEM pArray, PHB_ITEM pResult );
typedef BOOL     ( * HB_ARRAYSET)( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem );
typedef BOOL     ( * HB_ARRAYGET)( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem );
typedef void     ( * HB_XINIT)( void );                         /* Initialize fixed memory subsystem */
typedef void     ( * HB_XEXIT)( void );                         /* Deinitialize fixed memory subsystem */
typedef void *   ( * HB_XALLOC)( ULONG ulSize );                /* allocates memory, returns NULL on failure */
typedef void *   ( * HB_XGRAB)( ULONG ulSize );                 /* allocates memory, exits on failure */
typedef void     ( * HB_XFREE)( void * pMem );                  /* frees memory */
typedef void *   ( * HB_XREALLOC)( void * pMem, ULONG ulSize ); /* reallocates memory */
typedef ULONG    ( * HB_XSIZE)( void * pMem );                  /* returns the size of an allocated memory block */

HB_EXTERN_END

#endif /* HB_TYPES_H_ */
c:\harbour\include\hbver.h
/*
 * $Id: hbver.h 9379 2008-09-14 10:36:50Z vszakats $
 */

/*
 * Harbour Project source code:
 * Header file for version information
 *
 * Copyright 1999 David G. Holm 
 * 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.
 *
 */

/* NOTE: This file is also used by Harbour .prg code. */

#ifndef HB_VER_H_
#define HB_VER_H_

#ifdef __HARBOUR__
   #undef __HARBOUR__
#endif

#define HB_VER_MAJOR    1        /* Major version number */
#define HB_VER_MINOR    1        /* Minor version number */
#define HB_VER_REVISION 0        /* Revision number */
#define HB_VER_STATUS   "dev"    /* Build status */
#define __HARBOUR__     0x010100 /* Three bytes: Major + Minor + Revision. This is recommented for 3rd party .c and .prg level code. */

#endif /* HB_VER_H_ */
c:\harbour\include\hbvm.h
/*
 * $Id: hbvm.h 9514 2008-09-29 09:19:46Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Virtual Machine API
 *
 * Copyright 1999 Antonio Linares 
 * 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.
 *
 */

#ifndef HB_VM_H_
#define HB_VM_H_

#include "hbapi.h"

HB_EXTERN_BEGIN

/* Harbour virtual machine init/exit functions */
extern HB_EXPORT void     hb_vmInit( BOOL bStartMainProc );
extern HB_EXPORT int      hb_vmQuit( void ); /* Immediately quits the virtual machine, return ERRORLEVEL code */

/* registration AtInit and AtExit functions - they are executed
 * just before (after) .prg INIT (EXIT) procedures.
 */
extern HB_EXPORT void     hb_vmAtInit( HB_INIT_FUNC pFunc, void * cargo );
extern HB_EXPORT void     hb_vmAtExit( HB_INIT_FUNC pFunc, void * cargo );

/* Harbour virtual machine functions */
extern HB_EXPORT void     hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols );  /* invokes the virtual machine */
extern HB_EXPORT PHB_SYMB hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbols ); /* old module symbols initialization */
extern HB_EXPORT PHB_SYMB hb_vmProcessSymbolsEx( PHB_SYMB pSymbols, USHORT uiSymbols, const char * szModuleName, ULONG ulID, USHORT uiPcodeVer ); /* module symbols initialization with extended information */

#ifdef _HB_API_INTERNAL_
   typedef struct _HB_SYMBOLS
   {
      PHB_SYMB pModuleSymbols;      /* pointer to module symbol table */
      USHORT   uiModuleSymbols;     /* number of symbols on that table */
      struct _HB_SYMBOLS * pNext;   /* pointer to the next SYMBOLS structure */
      HB_SYMBOLSCOPE hScope;        /* scope collected from all symbols in module used to speed initialization code */
      void *   hDynLib;             /* handler to dynamic library */
      BOOL     fAllocated;          /* the symbol table is dynamically allocated and should be freed on HVM exit */
      BOOL     fActive;             /* the symbol table is currently active */
      BOOL     fInitStatics;        /* static initialization should be executed */
      char *   szModuleName;        /* module name */
      ULONG    ulID;                /* module unique identifier */
   } HB_SYMBOLS, * PHB_SYMBOLS;     /* structure to keep track of all modules symbol tables */

   extern PHB_SYMBOLS hb_vmRegisterSymbols( PHB_SYMB pModuleSymbols, USHORT uiSymbols, const char * szModuleName, ULONG ulID, BOOL fDynLib, BOOL fClone );
   extern void        hb_vmFreeSymbols( PHB_SYMBOLS pSymbols );
   extern void        hb_vmBeginSymbolGroup( void * hDynLib, BOOL fClone );
   extern void        hb_vmInitSymbolGroup( void * hNewDynLib, int argc, char * argv[] );
   extern void        hb_vmExitSymbolGroup( void * hDynLib );
   extern char *      hb_vmFindModuleSymbolName( PHB_SYMB pSym );
   extern BOOL        hb_vmFindModuleSymbols( PHB_SYMB pSym, PHB_SYMB * pSymbols, USHORT * puiSymbols );
   extern PHB_SYMB    hb_vmGetRealFuncSym( PHB_SYMB pSym );

   extern void        hb_vmEnumRelease( PHB_ITEM pBase, PHB_ITEM pValue );
   extern BOOL        hb_vmMsgReference( PHB_ITEM pObject, PHB_DYNS pMessage, PHB_DYNS pAccMsg ); /* create extended message reference */
#endif

extern void hb_vmSetExceptionHandler( void );
extern void hb_vmUnsetExceptionHandler( void );

extern HB_EXPORT void     hb_vmSymbolInit_RT( void );   /* initialization of runtime support symbols */

/* Harbour virtual machine escaping API */
extern HB_EXPORT void     hb_vmRequestDebug( void );
extern HB_EXPORT void     hb_vmRequestBreak( PHB_ITEM pItem );
extern HB_EXPORT void     hb_vmRequestCancel( void );
extern HB_EXPORT void     hb_vmRequestQuit( void );
extern HB_EXPORT void     hb_vmRequestEndProc( void );
extern HB_EXPORT USHORT   hb_vmRequestQuery( void );
extern HB_EXPORT BOOL     hb_vmRequestReenter( void );
extern HB_EXPORT void     hb_vmRequestRestore( void );

/* Return values of hb_vmRequestQuery() */
#define HB_QUIT_REQUESTED       1   /* immediately quit the application */
#define HB_BREAK_REQUESTED      2   /* break to nearest RECOVER/END sequence */
#define HB_ENDPROC_REQUESTED    4   /* immediately return from procedure (error handler in macro evaluation) */

/* Public PCode functions */

/* Execution */
extern HB_EXPORT void     hb_vmDo( USHORT uiParams );      /* invoke the virtual machine */
extern HB_EXPORT void     hb_vmFunction( USHORT uiParams ); /* executes a function */
extern HB_EXPORT void     hb_vmSend( USHORT uiParams ); /* sends a message to an object */
extern HB_EXPORT PHB_ITEM hb_vmEvalBlock( PHB_ITEM pBlockItem ); /* executes passed codeblock with no arguments */
/* executes passed codeblock with variable number of arguments */
extern HB_EXPORT PHB_ITEM hb_vmEvalBlockV( PHB_ITEM pBlockItem, ULONG ulArgCount, ... );
extern HB_EXPORT PHB_ITEM hb_vmEvalBlockOrMacro( PHB_ITEM pItem ); /* executes codeblock or macro pointed by given item */
extern HB_EXPORT void     hb_vmDestroyBlockOrMacro( PHB_ITEM pItem ); /* destroy codeblock or macro in given item */

/* Push */
extern HB_EXPORT void     hb_vmPush( PHB_ITEM pItem );     /* pushes a generic item onto the stack */
extern HB_EXPORT void     hb_vmPushNil( void );            /* in this case it places nil at self */
extern HB_EXPORT void     hb_vmPushNumber( double dNumber, int iDec ); /* pushes a number on to the stack and decides if it is integer, long or double */
extern HB_EXPORT void     hb_vmPushInteger( int iNumber ); /* pushes a integer number onto the stack */
extern HB_EXPORT void     hb_vmPushLong( long lNumber ); /* pushes a long number onto the stack */
extern HB_EXPORT void     hb_vmPushDouble( double lNumber, int iDec ); /* pushes a double number onto the stack */
extern HB_EXPORT void     hb_vmPushNumInt( HB_LONG lNumber );  /* pushes a number on to the stack and decides if it is integer or HB_LONG */
extern HB_EXPORT void     hb_vmPushLogical( BOOL bValue );    /* pushes a logical value onto the stack */
extern HB_EXPORT void     hb_vmPushString( const char * szText, ULONG length );  /* pushes a string on to the stack */
extern HB_EXPORT void     hb_vmPushStringPcode( const char * szText, ULONG length );  /* pushes a string from pcode on to the stack */
extern HB_EXPORT void     hb_vmPushDate( long lDate );   /* pushes a long date onto the stack */
extern HB_EXPORT void     hb_vmPushSymbol( PHB_SYMB pSym ); /* pushes a function pointer onto the stack */
extern HB_EXPORT void     hb_vmPushDynSym( PHB_DYNS pDynSym ); /* pushes a function/method pointer onto the stack */
extern HB_EXPORT void     hb_vmPushEvalSym( void ); /* pushes a codeblock eval symbol onto the stack */
extern HB_EXPORT void     hb_vmPushPointer( void * ); /* push an item of HB_IT_POINTER type */
extern HB_EXPORT void     hb_vmPushState( void ); /* push current VM state on stack */
extern HB_EXPORT void     hb_vmPopState( void ); /* pop current VM state from stack */
extern HB_EXPORT void     hb_vmPushItemRef( PHB_ITEM pItem ); /* push item reference */

extern HB_EXPORT BOOL     hb_vmIsMt( void ); /* return TRUE if HVM is compiled with thread support */
extern HB_EXPORT void     hb_vmLock( void ); /* lock VM blocking GC execution by other threads */
extern HB_EXPORT void     hb_vmUnlock( void ); /* unlock VM, allow GC execution */
#ifdef _HB_API_INTERNAL_
extern HB_EXPORT BOOL     hb_vmSuspendThreads( BOOL fWait ); /* (try to) stop all threads except current one */
extern HB_EXPORT void     hb_vmResumeThreads( void ); /* unblock execution of threads stopped by hb_vmSuspendThreads() */
#endif
extern HB_EXPORT BOOL     hb_vmThreadRegister( void * ); /* Register new thread without local thread HVM stack */
extern HB_EXPORT void     hb_vmThreadRelease( void * ); /* Remove registered thread which does not have local thread HVM stack yet */
extern HB_EXPORT void     hb_vmThreadInit( void * ); /* allocate local thread HVM stack */
extern HB_EXPORT void     hb_vmThreadQuit( void ); /* destroy local thread HVM stack */
extern HB_EXPORT void     hb_vmThreadQuitRequest( void * ); /* send QUIT request to given thread */
extern HB_EXPORT void     hb_vmWaitForThreads( void ); /* wait for all threads to terminate can be called only by main HVM thread */
extern HB_EXPORT void     hb_vmTerminateThreads( void ); /* send QUIT request to all threads except current one and wait for their termination, should be called only by main HVM thread */
extern HB_EXPORT void *   hb_vmThreadState( void );

/* various flags for supported features */
#define  HB_VMFLAG_HARBOUR    1     /* enable Harbour extension */
#define  HB_VMFLAG_ARRSTR    16     /* support for string as array of bytes -ks */
extern HB_EXPORT ULONG  hb_vmFlagEnabled( ULONG flags );
extern HB_EXPORT void   hb_vmFlagSet( ULONG flags );
extern HB_EXPORT void   hb_vmFlagClear( ULONG flags );

HB_EXTERN_END

#endif /* HB_VM_H_ */
c:\harbour\include\hbvmint.h
/*
 * $Id: hbvmint.h 9523 2008-09-30 09:37:58Z druzus $
 */

/*
 * xHarbour Project source code:
 * Header files to force macro inlining for HVM build
 *
 * Copyright 2008 Przemyslaw Czerpak 
 * 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.
 *
 */

/*
 * This header file enable macro inlining of some functions.
 * It should be included before any other hb*.h files.
 * !!! Be careful - including this file cause that the final binaries
 * can be linked only with exactly the same HVM version for which
 * it was compiled and only if exactly the same C compiler switches
 * which interacts with alignment are used. [druzus]
 */

#undef HB_API_MACROS
#undef HB_STACK_MACROS

#if !defined( _HB_API_INTERNAL_ )
#  define _HB_API_INTERNAL_
#endif
c:\harbour\include\hbvmopt.h
/*
 * $Id: hbvmopt.h 6583 2006-02-04 16:16:48Z druzus $
 */

/*
 * xHarbour Project source code:
 * Header files to force macro inlining for HVM build
 *
 * Copyright 2005 Przemyslaw Czerpak 
 * 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.
 *
 */

/*
 * This header file enable macro inlining of some functions.
 * It should be included before any other hb*.h files.
 * !!! Be careful - including this file cause that the final binaries
 * can be linked only with exactly the same HVM version for which
 * it was compiled and only if exactly the same C compiler switches
 * which interacts with alignment are used. [druzus]
 */
#if !defined( HB_NO_DEFAULT_API_MACROS ) && !defined( HB_API_MACROS )
#  define HB_API_MACROS
#endif

#if !defined( HB_NO_DEFAULT_STACK_MACROS ) && !defined( HB_STACK_MACROS )
#  define HB_STACK_MACROS
#endif

#if !defined( _HB_API_INTERNAL_ )
#  define _HB_API_INTERNAL_
#endif
c:\harbour\include\hbvmpub.h
/*
 * $Id: hbvmpub.h 9374 2008-09-13 16:53:45Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the generated C language source code
 *
 * Copyright 1999-2001 Viktor Szakats 
 * 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.
 *
 */

#ifndef HB_VMPUB_H_
#define HB_VMPUB_H_

#include "hbdefs.h"

HB_EXTERN_BEGIN

#ifdef _HB_API_INTERNAL_

struct _HB_SYMB;

#  define HB_ITEM_TYPERAW( p )   ( ( p )->type )
#  define HB_ITEM_TYPE( p )      ( HB_ITEM_TYPERAW( p ) & ~ HB_IT_DEFAULT )
#  define HB_OBJ_CLASS( p )      ( ( p )->item.asArray.value->uiClass )
#  define HB_ARRAY_OBJ( p )      ( ( p )->item.asArray.value->uiClass != 0 )

#  if defined(__GNUC__)
#     define HB_ITEM_NIL         { HB_IT_NIL, {} }
#  else
#     define HB_ITEM_NIL         { HB_IT_NIL, NULL }
#  endif

#  define HB_ITEM_GET_NUMINTRAW( p )  ( HB_IS_INTEGER( p ) ? \
                                        ( HB_LONG ) p->item.asInteger.value : \
                                        ( HB_LONG ) p->item.asLong.value )

#  define HB_ITEM_PUT_NUMINTRAW( p, v )  \
               do { \
                  if( HB_LIM_INT( v ) ) \
                  { \
                     (p)->type = HB_IT_INTEGER; \
                     (p)->item.asInteger.length = HB_INT_EXPLENGTH( v ); \
                     (p)->item.asInteger.value = ( int ) (v); \
                  } \
                  else \
                  { \
                     (p)->type = HB_IT_LONG; \
                     (p)->item.asLong.value = (v); \
                     (p)->item.asLong.length = HB_LONG_EXPLENGTH( v ); \
                  } \
               } while( 0 )

   /* dynamic symbol structure */
   typedef struct _HB_DYNS
   {
      struct _HB_SYMB * pSymbol; /* pointer to its relative local symbol */
#if !defined( HB_MT_VM )
      void *   pMemvar;          /* memvar pointer ( publics & privates ) */
      USHORT   uiArea;           /* Workarea number */
#endif
      USHORT   uiSymNum;         /* dynamic symbol number */
#ifndef HB_NO_PROFILER
      ULONG    ulCalls;          /* profiler support */
      ULONG    ulTime;           /* profiler support */
      ULONG    ulRecurse;        /* profiler support */
#endif
   } HB_DYNS, * PHB_DYNS, * HB_DYNS_PTR;

   /* pCode dynamic function - HRB */
   typedef struct _HB_PCODEFUNC
   {
      BYTE *      pCode;         /* function body - PCODE */
      struct _HB_SYMB * pSymbols;/* module symbol table */
   } HB_PCODEFUNC, * PHB_PCODEFUNC;

#else

#  undef HB_API_MACROS
#  undef HB_STACK_MACROS

/* This is ugly trick but works without speed overhead */
#  define HB_ITEM_TYPERAW( p )   ( * ( HB_TYPE * ) ( p ) )
/* if you do not like it then use this definition */
/* #  define HB_ITEM_TYPERAW( p )   ( hb_itemType( p ) ) */

#  define HB_ITEM_TYPE( p )      ( HB_ITEM_TYPERAW( p ) & ~HB_IT_DEFAULT )

#  define HB_OBJ_CLASS( p )   ( hb_objGetClass( p ) )
#  define HB_ARRAY_OBJ( p )   ( hb_arrayIsObject( p ) )

   /* basic types */
   typedef void *  PHB_ITEM;
   typedef void *  HB_ITEM_PTR;
   typedef void *  HB_CODEBLOCK_PTR;
   typedef void *  PHB_PCODEFUNC;

   typedef void    HB_STACK;

   /*
    * The first version reduce the number of modification in existing 3-rd
    * party code but in longer terms I'd prefer to disable it and left
    * only the second one where PHB_DYNS is mapped to void*.
    * This will allow us to fully redesign dynamic symbol internals
    * in the future if it will be necessary. [druzus]
    */
#if 0
   struct _HB_SYMB;
   typedef struct
   {
      struct _HB_SYMB * pSymbol; /* pointer to its relative local symbol */
   } _HB_DYNS, * PHB_DYNS, * HB_DYNS_PTR;
#else
   typedef void *  PHB_DYNS;
   typedef void *  PHB_DYNS_PTR;
#endif

#endif

/* symbol support structure */
typedef struct _HB_SYMB
{
   const char *   szName;           /* the name of the symbol */
   union
   {
      HB_SYMBOLSCOPE value;         /* the scope of the symbol */
      void *         pointer;       /* filler to force alignment */
   } scope;
   union
   {
      PHB_FUNC       pFunPtr;       /* machine code function address for function symbol table entries */
      PHB_PCODEFUNC  pCodeFunc;     /* PCODE function address */
      LONG           lStaticsBase;  /* base offset to array of statics */
   } value;
   PHB_DYNS       pDynSym;          /* pointer to its dynamic symbol if defined */
} HB_SYMB, * PHB_SYMB;

#define HB_DYNS_FUNC( hbfunc )   BOOL hbfunc( PHB_DYNS pDynSymbol, void * Cargo )
typedef HB_DYNS_FUNC( PHB_DYNS_FUNC );

typedef void (*HB_INIT_FUNC)(void *);
/* List of functions used by hb_vmAtInit()/hb_vmAtExit() */
typedef struct _HB_FUNC_LIST
{
   HB_INIT_FUNC   pFunc;
   void *         cargo;
   struct _HB_FUNC_LIST * pNext;
} HB_FUNC_LIST, * PHB_FUNC_LIST;

/* Harbour Functions scope ( HB_SYMBOLSCOPE ) */
#define HB_FS_PUBLIC    ( ( HB_SYMBOLSCOPE ) 0x0001 )
#define HB_FS_STATIC    ( ( HB_SYMBOLSCOPE ) 0x0002 )
#define HB_FS_FIRST     ( ( HB_SYMBOLSCOPE ) 0x0004 )
#define HB_FS_INIT      ( ( HB_SYMBOLSCOPE ) 0x0008 )
#define HB_FS_EXIT      ( ( HB_SYMBOLSCOPE ) 0x0010 )
#define HB_FS_MESSAGE   ( ( HB_SYMBOLSCOPE ) 0x0020 )
#define HB_FS_MEMVAR    ( ( HB_SYMBOLSCOPE ) 0x0080 )
#define HB_FS_PCODEFUNC ( ( HB_SYMBOLSCOPE ) 0x0100 )
#define HB_FS_LOCAL     ( ( HB_SYMBOLSCOPE ) 0x0200 )
#define HB_FS_DYNCODE   ( ( HB_SYMBOLSCOPE ) 0x0400 )
#define HB_FS_DEFERRED  ( ( HB_SYMBOLSCOPE ) 0x0800 )

#define HB_FS_INITEXIT ( HB_FS_INIT | HB_FS_EXIT )

extern HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols );  /* invokes the virtual machine */

HB_EXTERN_END

#endif /* HB_VMPUB_H_ */
c:\harbour\include\hbwince.h
/*
 * $Id: hbwince.h 9434 2008-09-18 05:23:49Z druzus $
 */

/*
 * Harbour Project source code:
 *
 *
 * Copyright 2007 Przemyslaw Czerpak 
 * 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.
 *
 */

#ifndef HB_WINCE_H_
#define HB_WINCE_H_

#if defined(HB_OS_WIN_32)

HB_EXTERN_BEGIN

#if defined(HB_WINCE)
#  undef  HB_OS_HAS_DRIVE_LETTER

/* defined(__CEGCC__) || defined(__MINGW32CE__) */

#if defined(__MINGW32CE__) && 0
typedef long clock_t;
extern clock_t clock( void );
#endif

extern int remove( const char *filename );
extern int access( const char *pathname, int mode );
extern int system( const char *string );
extern char *strerror( int errnum );

#if defined( HB_OS_WIN_32_USED ) && defined( _MSC_VER )

   #ifndef MAX_COMPUTERNAME_LENGTH
      #define MAX_COMPUTERNAME_LENGTH           31
      #define SEM_FAILCRITICALERRORS            0x0001
      #define FILE_TYPE_CHAR                    0x0002
      #define STD_INPUT_HANDLE                  ((DWORD)-10)
      #define STD_OUTPUT_HANDLE                 ((DWORD)-11)
      #define STD_ERROR_HANDLE                  ((DWORD)-12)
      #define LOCKFILE_FAIL_IMMEDIATELY         0x00000001
      #define LOCKFILE_EXCLUSIVE_LOCK           0x00000002
      #define OEM_FIXED_FONT                    SYSTEM_FONT
      #define WM_NCMOUSEMOVE                    0x00A0
      #define WM_QUERYENDSESSION                0x0011
      #define WM_ENTERIDLE                      0x0121
      #define SM_CMOUSEBUTTONS                  43
      #define PROOF_QUALITY                     2
      #define LR_LOADFROMFILE                   0x0010
      #ifndef DRIVE_UNKNOWN
         #define DRIVE_UNKNOWN                     0
      #endif
   #endif

   DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size );
   LPSTR WINAPI GetEnvironmentStringsA( void );
   BOOL WINAPI GetProcessTimes( HANDLE hprocess,
                                LPFILETIME lpCreationTime, LPFILETIME lpExitTime,
                                LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
   BOOL WINAPI GetUserNameA( LPSTR buffer, LPDWORD len );
   BOOL WINAPI GetComputerNameA( LPSTR buffer, LPDWORD len );
   DWORD WINAPI GetCurrentDirectoryA( DWORD len, LPSTR buffer );
   BOOL WINAPI SetCurrentDirectoryA( LPCSTR dirname );
   BOOL WINAPI LockFile( HANDLE hFile,
                         DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
                         DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh );
   BOOL WINAPI LockFileEx( HANDLE hFile,
                           DWORD dwFlags, DWORD dwReserved,
                           DWORD nNumberOfBytesToLockLow,
                           DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped );
   BOOL WINAPI UnlockFile( HANDLE hFile,
                           DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
                           DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh );
   BOOL WINAPI UnlockFileEx( HANDLE hFile, DWORD dwReserved,
                             DWORD nNumberOfBytesToUnlockLow,
                             DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped );
   BOOL WINAPI GetVolumeInformationA( LPCSTR p1, LPSTR p2, DWORD p3, PDWORD p4,
                                      PDWORD p5, PDWORD p6, LPSTR p7, DWORD p8 );
   UINT WINAPI SetErrorMode( UINT mode );
   HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access,
                       DWORD sharing, LPSECURITY_ATTRIBUTES sa,
                       DWORD creation, DWORD attributes, HANDLE tmplt );
   BOOL WINAPI MoveFileA( LPCSTR fn1, LPCSTR fn2 );
   BOOL WINAPI DeleteFileA( LPCSTR path );
   BOOL WINAPI RemoveDirectoryA( LPCSTR path );
   BOOL WINAPI CreateDirectoryA( LPCSTR path, LPSECURITY_ATTRIBUTES attr );
   BOOL WINAPI SetFileAttributesA( LPCSTR filename, DWORD attr );
   BOOL WINAPI CharToOemBuffA( LPCSTR src, LPSTR dst, DWORD len );
   BOOL WINAPI OemToCharBuffA( LPCSTR src, LPSTR dst, DWORD len );
   HANDLE WINAPI FindFirstFileA( LPCSTR path, WIN32_FIND_DATAA * data );
   BOOL WINAPI FindNextFileA( HANDLE handle, WIN32_FIND_DATAA * data );
   BOOL WINAPI GetVersionExA( OSVERSIONINFOA * v );
   HANDLE WINAPI GetStdHandle( DWORD nStdHandle );
   DWORD WINAPI GetFileType( HANDLE handle );
   HMODULE WINAPI GetModuleHandleA( LPCSTR modulename );
   HINSTANCE WINAPI LoadLibraryA( LPCSTR libname );
   DWORD WINAPI GetTempPathA( DWORD size, LPSTR buffer );
   UINT WINAPI GetTempFileNameA( LPCSTR tmpdir, LPCSTR prefix, UINT unique, LPSTR filename );
   BOOL WINAPI GetDiskFreeSpaceA( LPCSTR path, PDWORD pdwSectorsPerCluster,
                                  PDWORD pdwBytesPerSector,
                                  PDWORD pdwNumberOfFreeClusters, PDWORD pdwTotalNumberOfClusters );
   BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDurat );
   int WINAPI SetTextCharacterExtra( HDC hdc, int i );
   BOOL WINAPI GetKeyboardState( PBYTE p );
   BOOL WINAPI SetKeyboardState( PBYTE p );

   int WINAPI FrameRect( HDC hDC, CONST RECT *lprc, HBRUSH hbr );
   BOOL WINAPI FloodFill( HDC hdc, int x, int y, COLORREF color);
   BOOL  WINAPI Arc( HDC hdc, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);

   #if defined( __POCC__ ) || defined( __XCC__ )
      #ifndef GlobalAlloc
      #define GlobalAlloc(flags, cb)      LocalAlloc(flags, cb)
      #endif
      #ifndef GlobalLock
      #define GlobalLock(lp)              LocalLock(lp)
      #endif
      #ifndef GlobalUnlock
      #define GlobalUnlock(lp)            LocalUnlock(lp)
      #endif
      #ifndef GlobalSize
      #define GlobalSize(lp)              LocalSize(lp)
      #endif
      #ifndef GlobalFree
      #define GlobalFree(h)               LocalFree(h)
      #endif
      #ifndef GlobalReAlloc
      #define GlobalReAlloc(h, cb, flags) LocalReAlloc(h, cb, flags)
      #endif
      #ifndef GlobalHandle
      #define GlobalHandle(lp)            LocalHandle(lp)
      #endif
      #ifndef GlobalFlags
      #define GlobalFlags(lp)             LocalFlags(lp)
   #endif
   #endif
#endif /* HB_OS_WIN_32_USED && _MSC_VER */

#endif /* HB_WINCE */

extern wchar_t * hb_mbtowc( const char *srcA );
extern char * hb_wctomb( const wchar_t *srcW );
extern wchar_t * hb_mbntowc( const char *srcA, unsigned long ulLen );
extern char * hb_wcntomb( const wchar_t *srcW, unsigned long ulLen );
extern void hb_mbtowccpy( wchar_t *dstW, const char *srcA, unsigned long ulLen );
extern void hb_mbtowcset( wchar_t *dstW, const char *srcA, unsigned long ulLen );
extern void hb_wctombget( char *dstA, const wchar_t *srcW, unsigned long ulLen );

#if defined(UNICODE)

   #define HB_TCHAR_CPTO(d,s,l)        hb_mbtowccpy(d,s,l)
   #define HB_TCHAR_GETFROM(d,s,l)     hb_wctombget(d,s,l)
   #define HB_TCHAR_SETTO(d,s,l)       hb_mbtowcset(d,s,l)
   #define HB_TCHAR_CONVTO(s)          hb_mbtowc(s)
   #define HB_TCHAR_CONVFROM(s)        hb_wctomb(s)
   #define HB_TCHAR_CONVNTO(s,l)       hb_mbntowc(s,l)
   #define HB_TCHAR_CONVNFROM(s,l)     hb_wcntomb(s,l)
   #define HB_TCHAR_CONVNREV(d,s,l)    do { hb_wctombget(d,s,l); hb_xfree(s); } while( 0 )
   #define HB_TCHAR_FREE(s)            hb_xfree(s)

#else

   #define HB_TCHAR_CPTO(d,s,l)        hb_strncpy(d,s,l)
   #define HB_TCHAR_SETTO(d,s,l)       memcpy(d,s,l)
   #define HB_TCHAR_GETFROM(d,s,l)     memcpy(d,s,l)
   #define HB_TCHAR_CONVTO(s)          ((char *)(s))
   #define HB_TCHAR_CONVFROM(s)        ((char *)(s))
   #define HB_TCHAR_CONVNTO(s,l)       ((char *)(s))
   #define HB_TCHAR_CONVNFROM(s,l)     ((char *)(s))
   #define HB_TCHAR_CONVNREV(d,s,l)    do { ; } while( 0 )
   #define HB_TCHAR_FREE(s)            HB_SYMBOL_UNUSED(s)

#endif /* UNICODE */

HB_EXTERN_END

#endif /* HB_OS_WIN_32 */

#endif /* HB_WINCE_H_ */
c:\harbour\include\hbxvm.h
/*
 * $Id: hbxvm.h 9374 2008-09-13 16:53:45Z druzus $
 */

/*
 * Harbour Project source code:
 * Header file for the Internal Terminal API
 *
 * Copyright 2006 Przemyslaw Czerpak < druzus /at/ priv.onet.pl >
 * 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.
 *
 */

/* NOTE: The declaration of hb_gtSetPos(), hb_gtGetPos(), hb_gtWrite(),
         hb_gtWriteAt(), hb_gtRepChar(), hb_gtBox(), hb_gtBoxS(), hb_gtBoxD() 
         hb_gtInit() differs in parameter types from the original CA-Cl*pper 
         versions. [vszakats] */

#ifndef HB_XVM_H_
#define HB_XVM_H_

#include "hbapi.h"
#include "hbapiitm.h"
#include "hbvm.h"
#include "hbstack.h"

HB_EXTERN_BEGIN

/*
 * Functions below which return BOLL value can cause error handler
 * executing so we have to check for break request flag. The return
 * value is TRUE when break request is set.
 * other functions does not execute error handler and we do not have
 * to check HVM state so they are simply declared as void.
 */

extern HB_EXPORT void   hb_xvmExitProc( void );
extern HB_EXPORT void   hb_xvmEndProc( void );
extern HB_EXPORT void   hb_xvmSeqBegin( void );
extern HB_EXPORT BOOL   hb_xvmSeqEnd( void );
extern HB_EXPORT BOOL   hb_xvmSeqEndTest( void );
extern HB_EXPORT BOOL   hb_xvmSeqRecover( void );
extern HB_EXPORT void   hb_xvmSeqAlways( void );
extern HB_EXPORT BOOL   hb_xvmAlwaysBegin( void );
extern HB_EXPORT BOOL   hb_xvmAlwaysEnd( void );
extern HB_EXPORT BOOL   hb_xvmSeqBlock( void );

extern HB_EXPORT BOOL   hb_xvmEnumStart( BYTE, BYTE );            /* prepare FOR EACH loop */
extern HB_EXPORT BOOL   hb_xvmEnumNext( void );                   /* increment FOR EACH loop counter */
extern HB_EXPORT BOOL   hb_xvmEnumPrev( void );                   /* decrement FOR EACH loop counter */
extern HB_EXPORT void   hb_xvmEnumEnd( void );                    /* rewind the stack after FOR EACH loop counter */

extern HB_EXPORT void   hb_xvmWithObjectStart( void );            /* prepare WITH OBJECT statement */
extern HB_EXPORT void   hb_xvmWithObjectEnd( void );              /* rewind the stack after normal WITH OBJECT */
extern HB_EXPORT void   hb_xvmWithObjectMessage( PHB_SYMB );      /* send WITH OBJECT message to current WITH OBJECT control variable */

extern HB_EXPORT void   hb_xvmSetLine( USHORT uiLine );           /* set .prg line number information */

extern HB_EXPORT void   hb_xvmFrame( int iLocals, int iParams );  /* increases the stack pointer for the amount of locals and params suplied */
extern HB_EXPORT void   hb_xvmVFrame( int iLocals, int iParams ); /* increases the stack pointer for the amount of locals and variable params */
extern HB_EXPORT void   hb_xvmSFrame( PHB_SYMB pSymbol );
extern HB_EXPORT void   hb_xvmStatics( PHB_SYMB pSymbol, USHORT uiStatics );
extern HB_EXPORT void   hb_xvmThreadStatics( USHORT uiStatics, const BYTE * statics );
extern HB_EXPORT void   hb_xvmParameter( PHB_SYMB pSymbol, int iParams );
extern HB_EXPORT void   hb_xvmRetValue( void );                   /* pops the latest stack value into stack.Return */
extern HB_EXPORT BOOL   hb_xvmDo( USHORT uiParams );
extern HB_EXPORT BOOL   hb_xvmFunction( USHORT uiParams );
extern HB_EXPORT BOOL   hb_xvmSend( USHORT uiParams );
extern HB_EXPORT BOOL   hb_xvmPushObjectVarRef( void );
extern HB_EXPORT void   hb_xvmPushStatic( USHORT uiStatic );
extern HB_EXPORT void   hb_xvmPushStaticByRef( USHORT uiStatic );
extern HB_EXPORT void   hb_xvmPopStatic( USHORT uiStatic );
extern HB_EXPORT BOOL   hb_xvmPushVariable( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPopVariable( PHB_SYMB pSymbol );
extern HB_EXPORT void   hb_xvmPushBlock( const BYTE * pCode, PHB_SYMB pSymbols ); /* creates a codeblock */
extern HB_EXPORT void   hb_xvmPushBlockShort( const BYTE * pCode, PHB_SYMB pSymbols ); /* creates a codeblock */
extern HB_EXPORT void   hb_xvmPushBlockLarge( const BYTE * pCode, PHB_SYMB pSymbols ); /* creates a codeblock */
extern HB_EXPORT void   hb_xvmPushSelf( void );
extern HB_EXPORT void   hb_xvmPushVParams( void );
extern HB_EXPORT void   hb_xvmPushLocal( SHORT iLocal );          /* pushes the containts of a local onto the stack */
extern HB_EXPORT void   hb_xvmPushLocalByRef( SHORT iLocal );     /* pushes a local by refrence onto the stack */
extern HB_EXPORT void   hb_xvmPopLocal( SHORT iLocal );           /* pops the stack latest value onto a local */
extern HB_EXPORT BOOL   hb_xvmPushField( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPopField( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPushMemvar( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPushMemvarByRef( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPopMemvar( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPushAliasedField( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPopAliasedField( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPushAliasedVar( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPopAliasedVar( PHB_SYMB pSymbol );
extern HB_EXPORT BOOL   hb_xvmPushAlias( void );
extern HB_EXPORT BOOL   hb_xvmPopAlias( void );                   /* select the workarea using a given item or a substituted value */
extern HB_EXPORT BOOL   hb_xvmPopLogical( BOOL * );               /* pops the stack latest value and returns its logical value */
extern HB_EXPORT BOOL   hb_xvmSwapAlias( void );                  /* swaps items on the eval stack and pops the workarea number */
extern HB_EXPORT BOOL   hb_xvmLocalAddInt( int iLocal, LONG lAdd ); /* add integer to given local variable */
extern HB_EXPORT BOOL   hb_xvmLocalInc( int iLocal );             /* increment given local variable */
extern HB_EXPORT BOOL   hb_xvmLocalDec( int iLocal );             /* decrement given local variable */
extern HB_EXPORT BOOL   hb_xvmLocalIncPush( int iLocal );         /* increment given local variable and pussh it on HVM stack */

extern HB_EXPORT BOOL   hb_xvmAnd( void );
extern HB_EXPORT BOOL   hb_xvmOr( void );
extern HB_EXPORT BOOL   hb_xvmNot( void );
extern HB_EXPORT BOOL   hb_xvmNegate( void );
extern HB_EXPORT void   hb_xvmDuplicate( void );
extern HB_EXPORT void   hb_xvmDuplUnRef( void );
extern HB_EXPORT void   hb_xvmDuplTwo( void );
extern HB_EXPORT void   hb_xvmPushUnRef( void );
extern HB_EXPORT void   hb_xvmSwap( int iCount );
extern HB_EXPORT BOOL   hb_xvmForTest( void );
extern HB_EXPORT void   hb_xvmFuncPtr( void );
extern HB_EXPORT BOOL   hb_xvmEqual( void );                      /* checks if the two latest values on the stack are equal, removes both and leaves result */
extern HB_EXPORT BOOL   hb_xvmExactlyEqual( void );               /* checks if the two latest values on the stack are exactly equal, removes both and leaves result */
extern HB_EXPORT BOOL   hb_xvmNotEqual( void );                   /* checks if the two latest values on the stack are not equal, removes both and leaves result */
extern HB_EXPORT BOOL   hb_xvmLess( void );                       /* checks if the latest - 1 value is less than the latest, removes both and leaves result */
extern HB_EXPORT BOOL   hb_xvmLessEqual( void );                  /* checks if the latest - 1 value is less than or equal the latest, removes both and leaves result */
extern HB_EXPORT BOOL   hb_xvmGreater( void );                    /* checks if the latest - 1 value is greater than the latest, removes both and leaves result */
extern HB_EXPORT BOOL   hb_xvmGreaterEqual( void );               /* checks if the latest - 1 value is greater than or equal the latest, removes both and leaves result */
extern HB_EXPORT BOOL   hb_xvmInstring( void );                   /* check whether string 1 is contained in string 2 */
extern HB_EXPORT BOOL   hb_xvmPlus( void );                       /* sums the latest two values on the stack, removes them and leaves the result */
extern HB_EXPORT BOOL   hb_xvmPlusEq( void );
extern HB_EXPORT BOOL   hb_xvmPlusEqPop( void );
extern HB_EXPORT BOOL   hb_xvmMinus( void );                      /* substracts the latest two values on the stack, removes them and leaves the result */
extern HB_EXPORT BOOL   hb_xvmMinusEq( void );
extern HB_EXPORT BOOL   hb_xvmMinusEqPop( void );
extern HB_EXPORT BOOL   hb_xvmMult( void );                       /* multiplies the latest two values on the stack, removes them and leaves the result */
extern HB_EXPORT BOOL   hb_xvmMultEq( void );
extern HB_EXPORT BOOL   hb_xvmMultEqPop( void );
extern HB_EXPORT BOOL   hb_xvmDivide( void );                     /* divides the latest two values on the stack, removes them and leaves the result */
extern HB_EXPORT BOOL   hb_xvmDivEq( void );
extern HB_EXPORT BOOL   hb_xvmDivEqPop( void );
extern HB_EXPORT BOOL   hb_xvmModulus( void );                    /* calculates the modulus of latest two values on the stack, removes them and leaves the result */
extern HB_EXPORT BOOL   hb_xvmModEq( void );
extern HB_EXPORT BOOL   hb_xvmModEqPop( void );
extern HB_EXPORT BOOL   hb_xvmPower( void );
extern HB_EXPORT BOOL   hb_xvmExpEq( void );
extern HB_EXPORT BOOL   hb_xvmExpEqPop( void );
extern HB_EXPORT BOOL   hb_xvmInc( void );
extern HB_EXPORT BOOL   hb_xvmIncEq( void );
extern HB_EXPORT BOOL   hb_xvmIncEqPop( void );
extern HB_EXPORT BOOL   hb_xvmDec( void );
extern HB_EXPORT BOOL   hb_xvmDecEq( void );
extern HB_EXPORT BOOL   hb_xvmDecEqPop( void );

extern HB_EXPORT void   hb_xvmArrayDim( USHORT uiDimensions );    /* generates an uiDimensions Array and initialize those dimensions from the stack values */
extern HB_EXPORT void   hb_xvmArrayGen( ULONG ulElements );       /* generates an ulElements Array and fills it from the stack values */
extern HB_EXPORT BOOL   hb_xvmArrayPush( void );                  /* pushes an array element to the stack, removing the array and the index from the stack */
extern HB_EXPORT BOOL   hb_xvmArrayPushRef( void );               /* pushes a reference to an array element to the stack, removing the array and the index from the stack */
extern HB_EXPORT BOOL   hb_xvmArrayPop( void );                   /* pops a value from the stack */
extern HB_EXPORT void   hb_xvmHashGen( ULONG ulElements );        /* generates an ulElements Hash and fills it from the stack values */

extern HB_EXPORT void   hb_xvmLocalName( USHORT uiLocal, char * szLocalName );
extern HB_EXPORT void   hb_xvmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName );
extern HB_EXPORT void   hb_xvmModuleName( char * szModuleName );

extern HB_EXPORT BOOL   hb_xvmMacroDo( USHORT uiArgSets );
extern HB_EXPORT BOOL   hb_xvmMacroFunc( USHORT uiArgSets );
extern HB_EXPORT BOOL   hb_xvmMacroSend( USHORT uiArgSets );
extern HB_EXPORT BOOL   hb_xvmMacroArrayGen( USHORT uiArgSets );
extern HB_EXPORT BOOL   hb_xvmMacroPush( BYTE bFlags );
extern HB_EXPORT BOOL   hb_xvmMacroPushRef( void );
extern HB_EXPORT BOOL   hb_xvmMacroPushIndex( void );
extern HB_EXPORT BOOL   hb_xvmMacroPushArg( PHB_SYMB pSymbol, BYTE bFlags );
extern HB_EXPORT BOOL   hb_xvmMacroPushList( BYTE bFlags );
extern HB_EXPORT BOOL   hb_xvmMacroPushAliased( BYTE bFlags );
extern HB_EXPORT BOOL   hb_xvmMacroPushPare( BYTE bFlags );
extern HB_EXPORT BOOL   hb_xvmMacroPop( BYTE bFlags );
extern HB_EXPORT BOOL   hb_xvmMacroPopAliased( BYTE bFlags );
extern HB_EXPORT BOOL   hb_xvmMacroSymbol( void );
extern HB_EXPORT BOOL   hb_xvmMacroText( void );

extern HB_EXPORT void   hb_xvmPushStringHidden( char * szText, ULONG length );
extern HB_EXPORT void   hb_xvmPushDouble( double dNumber, int iWidth, int iDec );
#ifdef HB_LONG_LONG_OFF
extern HB_EXPORT void   hb_xvmPushLongLong( double dNumber );
#else
extern HB_EXPORT void   hb_xvmPushLongLong( LONGLONG llNumber );
#endif

#define hb_xvmPushLogical( f )            hb_vmPushLogical( f )
#define hb_xvmPushInteger( i )            hb_vmPushInteger( i )
#define hb_xvmPushLong( l )               hb_vmPushLong( l )
#define hb_xvmPushNil()                   hb_vmPushNil()
#define hb_xvmPushStringConst( psz, ul )  hb_vmPushStringPcode( psz, ul )
#define hb_xvmPushSymbol( p )             hb_vmPushSymbol( p )
#define hb_xvmPushDate( p )               hb_vmPushDate( p )


/*
 * additional multi PCODE operations
 */
extern HB_EXPORT BOOL hb_xvmArrayItemPush( ULONG ulIndex );
extern HB_EXPORT BOOL hb_xvmArrayItemPop( ULONG ulIndex );
extern HB_EXPORT BOOL hb_xvmMultByInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmDivideByInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmAddInt( LONG lValue );
extern HB_EXPORT void hb_xvmLocalSetInt( int iLocal, LONG lValue );
/*extern HB_EXPORT void hb_xvmLocalSetStr( int iLocal, const char * pValue, ULONG ulLen );*/
extern HB_EXPORT void hb_xvmPushFuncSymbol( PHB_SYMB pSym );

extern HB_EXPORT BOOL hb_xvmLessThenInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmLessThenIntIs( LONG lValue, BOOL *fValue );
extern HB_EXPORT BOOL hb_xvmLessEqualThenInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmLessEqualThenIntIs( LONG lValue, BOOL *fValue );
extern HB_EXPORT BOOL hb_xvmGreaterThenInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmGreaterThenIntIs( LONG lValue, BOOL *fValue );
extern HB_EXPORT BOOL hb_xvmGreaterEqualThenInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmGreaterEqualThenIntIs( LONG lValue, BOOL *fValue );
extern HB_EXPORT BOOL hb_xvmEqualInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmEqualIntIs( LONG lValue, BOOL *fValue );
extern HB_EXPORT BOOL hb_xvmNotEqualInt( LONG lValue );
extern HB_EXPORT BOOL hb_xvmNotEqualIntIs( LONG lValue, BOOL *fValue );

extern HB_EXPORT BOOL hb_xvmLocalAdd( int iLocal );
extern HB_EXPORT BOOL hb_xvmStaticAdd( USHORT uiStatic );
extern HB_EXPORT BOOL hb_xvmMemvarAdd( PHB_SYMB pSymbol );

extern HB_EXPORT PHB_ITEM hb_xvmStaticPtr( int iStatic );
extern HB_EXPORT PHB_ITEM hb_xvmLocalPtr( int iLocal );
extern HB_EXPORT void hb_xvmCopyLocals( int iDest, int iSource );

HB_EXTERN_END

#endif /* HB_XVM_H_ */
c:\harbour\include\hbzlib.h
/*
 * $Id: hbzlib.h 8511 2008-05-28 14:37:33Z druzus $
 */

/*
 * Harbour Project source code:
 * Wrapper for zlib.h
 *
 * Copyright 2008 Viktor Szakats 
 * 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.
 *
 */

#if defined( HB_EXT_ZLIB )
#  include 
#else
#  if defined(__XCC__) || defined(__LCC__)
#     include "source\hbzlib\zlib.h"
#  else
#     include "../source/hbzlib/zlib.h"
#  endif
#endif
c:\harbour\include\hb_io.h
/*
 * $Id: hb_io.h 9186 2008-08-17 07:39:25Z vszakats $
 */

/*
 * Harbour Project source code:
 * A platform indpendent include file to include unistd.h and/or io.h
 *
 * Copyright 2001 Harbour Project
 * 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.
 *
 */

#ifndef HB__IO_H_
#define HB__IO_H_

#if defined(HB_OS_UNIX_COMPATIBLE) || \
    ( defined(__GNUC__) && ! defined(__MINGW32__) )
   #include 
   #if defined(__DJGPP__) || defined(__CYGWIN__) || defined(__EMX__)
      #include 
   #endif
#elif !defined(HB_WINCE)
   #include 
#endif
#if defined(HB_OS_DOS) && !defined(__RSX32__)
   #include 
#endif

#endif

Page url: http://www.yourdomain.com/help/index.html?h_files.htm