// Copyright (c) 1993-2005 "Компания БЭСТ". Все права сохраняются.

//
// V 3.5.9 22.04.05
//
#pragma BEGINDUMP
extern void hb_threadSleep( int millisec );
#ifdef __PLATFORM__Linux
#define MAX_PATH 1024
#define RIGHT_ALT_PRESSED     0x0001 // the right alt key is pressed.
#define LEFT_ALT_PRESSED      0x0002 // the left alt key is pressed.
#define RIGHT_CTRL_PRESSED    0x0004 // the right ctrl key is pressed.
#define LEFT_CTRL_PRESSED     0x0008 // the left ctrl key is pressed.
#define SHIFT_PRESSED         0x0010 // the shift key is pressed.
#define NUMLOCK_ON            0x0020 // the numlock light is on.
#define SCROLLLOCK_ON         0x0040 // the scrolllock light is on.
#define CAPSLOCK_ON           0x0080 // the capslock light is on.
#define ENHANCED_KEY          0x0100 // the key is enhanced.
#else
#include <windows.h>
#include <wincon.h>
#include <winnt.h>
#include <winioctl.h>
#include <iphlpapi.h>
#endif

#include "hbapi.h"
#include "hbapifs.h"
#include "hbapigt.h"
#include "hbapifs.h"
#include "hbapiitm.h"

#include "hbapierr.h"

#include "hbrddwrk.h"
#include "hbapirdd.h"
#include "hbrddcdx.h"

#include "hbvm.h"

#include "hbstack.h"
#define MAX_FILE_NAME 1024

#define LEN_GUID 22
BOOL genguid22(char *s);

#define LEN_GUID0 38
BOOL genguid38(char *s);

static HB_ITEM_PTR * s_pStack = NULL;
static ULONG s_ulStack = 0;

static void xh_stackPush( PHB_ITEM pItem )
{

   ++s_ulStack;

s_pStack = s_pStack ? ( HB_ITEM_PTR * ) hb_xrealloc( s_pStack, sizeof( HB_ITEM_PTR ) * s_ulStack ) :
                      ( HB_ITEM_PTR * ) hb_xgrab( sizeof( HB_ITEM_PTR ) );
      s_pStack[ s_ulStack - 1 ] = hb_itemNew( pItem );

}

static void tempfilezap( char *szFile,char *szExt,BOOL bDelete )
{

PHB_FNAME pFileName;
char cPathTemp [MAX_PATH + 1];

     pFileName = hb_fsFNameSplit( szFile );
     pFileName->szExtension = szExt;
     hb_fsFNameMerge( cPathTemp, pFileName );
     if ( bDelete && hb_spFile(cPathTemp,NULL) )
        hb_fsDelete(cPathTemp);
     if ( pFileName != NULL )
          hb_xfree( pFileName );
}


HB_FUNC( B4_GETTEMPPATH )
{
   char szBuffer[ MAX_PATH + 1 ] = {0} ;
#ifdef __PLATFORM__Linux
   strcpy( szBuffer,"/tmp/" );
#else
   GetTempPath(MAX_PATH, szBuffer);
#endif
   hb_retc(szBuffer);
}


HB_FUNC( TEMPFILEDELETE )
{
char *szFile;
BOOL bDelete = ISLOG( 1 ) ? hb_parl( 1 ) : TRUE ;

          while( s_ulStack )
            {
            szFile = hb_itemGetC( s_pStack[ s_ulStack - 1 ] );
            if ( bDelete && hb_spFile(szFile,NULL) ) hb_fsDelete(szFile);
            tempfilezap( szFile,".cdx", bDelete );
            tempfilezap( szFile,".CDX", bDelete );
            tempfilezap( szFile,".txt", bDelete );
            tempfilezap( szFile,".TXT", bDelete );
            tempfilezap( szFile,".dbf", bDelete );
            tempfilezap( szFile,".DBF", bDelete );
            tempfilezap( szFile,".idx", bDelete );
            tempfilezap( szFile,".IDX", bDelete );
            tempfilezap( szFile,".rep", bDelete );
            tempfilezap( szFile,".REP", bDelete );
            hb_xfree(szFile);
            hb_itemRelease( s_pStack[ s_ulStack - 1 ] );
#ifdef __PLATFORM__Linux
#else
            if ( GetVersion() & 0x80000000 ) // 98
               hb_threadSleep( 30);
#endif
            s_ulStack = HB_MAX(s_ulStack--,0);
              if ( s_ulStack )
                 s_pStack = ( HB_ITEM_PTR * ) hb_xrealloc( s_pStack, sizeof( HB_ITEM_PTR ) * s_ulStack );
               else
                 {
                  hb_xfree( s_pStack );
                  s_pStack = NULL;
                 }
             }
}


HB_FUNC( TEMPFILE )
{

   char cPath[ MAX_PATH + 1 ] = {0};
   char cPathNew[ MAX_PATH + 1 ] = {0};
   char *szPath   = ISCHAR( 1 ) ? hb_parcx( 1 ) : NULL;
   char *szPrefix = ISCHAR( 3 ) ? hb_parcx( 3 ) : "b4p";
   BOOL lGrab = FALSE;
   BOOL bDelete = ISLOG( 4 ) ? hb_parl( 4 ) : TRUE ;
   PHB_FNAME pFileName;
   PHB_ITEM Temp;

   FHANDLE fhnd;
      if (!szPath)
         {
          szPath = hb_xgrab( MAX_PATH + 1 );
          lGrab = TRUE;
#ifdef __PLATFORM__Linux
          strcpy( szPath,"/tmp/" );
//          szPath[0] = '.';
//          szPath[0] = '\0';
#else
          GetTempPath(MAX_PATH, szPath);
#endif
         }

     do
      {
      #ifdef __PLATFORM__Linux
      hb_fsCreateTemp( szPath, szPrefix, 0, (BYTE*) cPath );
      #else
      GetTempFileName( szPath,szPrefix,0,(LPSTR) cPath);
      #endif
      pFileName = hb_fsFNameSplit( cPath );
      pFileName->szExtension = ISCHAR( 2 ) ? hb_parcx( 2 ) : ".";
      hb_fsFNameMerge( cPathNew, pFileName );
           if ( ISCHAR( 2 ) )
             {
              if (hb_strnicmp( pFileName->szExtension, "TMP", 3 ))
                 {
                  if (!hb_spFile(cPathNew,NULL) )
                    break;
                 }
                else
                 {
                  break;
                 }
             }
             else
             {
                pFileName->szExtension = ".cdx";
                hb_fsFNameMerge( cPathNew, pFileName );
                if (!hb_spFile(cPathNew,NULL) )
                  {
                    pFileName->szExtension = ".CDX";
                    hb_fsFNameMerge( cPathNew, pFileName );
                    if (!hb_spFile(cPathNew,NULL) )
                      {
                        pFileName->szExtension = ".txt";
                        hb_fsFNameMerge( cPathNew, pFileName );
                        if (!hb_spFile(cPathNew,NULL) )
                          {
                            pFileName->szExtension = ".TXT";
                            hb_fsFNameMerge( cPathNew, pFileName );
                            if (!hb_spFile(cPathNew,NULL) )
                              {
                                pFileName->szExtension = ".dbf";
                                hb_fsFNameMerge( cPathNew, pFileName );
                                if (!hb_spFile(cPathNew,NULL) )
                                  {
                                    pFileName->szExtension = ".DBF";
                                    hb_fsFNameMerge( cPathNew, pFileName );
                                    if (!hb_spFile(cPathNew,NULL) )
                                      {
                                        pFileName->szExtension = ".idx";
                                        hb_fsFNameMerge( cPathNew, pFileName );
                                        if (!hb_spFile(cPathNew,NULL) )
                                          {
                                            pFileName->szExtension = ".IDX";
                                            hb_fsFNameMerge( cPathNew, pFileName );
                                            if (!hb_spFile(cPathNew,NULL) )
                                              {
                                                pFileName->szExtension = ".rep";
                                                hb_fsFNameMerge( cPathNew, pFileName );
                                                if (!hb_spFile(cPathNew,NULL) )
                                                  {
                                                    pFileName->szExtension = ".REP";
                                                    hb_fsFNameMerge( cPathNew, pFileName );
                                                    if (!hb_spFile(cPathNew,NULL) )
                                                      {
                                                        pFileName->szExtension = ".";
                                                        hb_fsFNameMerge( cPathNew, pFileName );
                                                        break;
                                                      }
                                                  }
                                              }
                                          }
                                      }
                                  }


                              }
                          }
                      }
                  }
             }
      }
      while ( TRUE );

      hb_fsRename( cPath, cPathNew );

      hb_xfree( pFileName );
      hb_retc(cPathNew);
      if (lGrab) hb_xfree( szPath);
      Temp = hb_itemPutC( NULL, cPathNew );
     if ( bDelete )
       xh_stackPush(Temp );
      hb_itemRelease(Temp);
#ifdef __PLATFORM__Linux
#else
      if ( GetVersion() & 0x80000000 )
         hb_threadSleep( 200 );
#endif
}



HB_FUNC( AREDUCE )
{

   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );

   if( pArray )
   {
      long int ulPos = ISNUM( 2 ) ? hb_parnl( 2 ) : 1 ;
      long int ulLen = pArray->item.asArray.value->ulLen;

      if (ulPos > 0 && ulPos <= ulLen )
         {
          hb_arrayDel( pArray, ulPos );
          hb_arraySize( pArray, --ulLen );
         }
         hb_itemReturn( pArray );
   }
}

extern int hb_gt_KbdState(void);

HB_FUNC( KBDSTAT )
{

int iFlag = 0;
int iStat = hb_gtKbdState();

if (iStat & SHIFT_PRESSED) iFlag |= 3;
if (iStat & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED ))  iFlag |= 4;
if (iStat & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED ))  iFlag |= 8;
if (iStat & SHIFT_PRESSED & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED ))  iFlag |= 8;

if (iStat & SCROLLLOCK_ON ) iFlag |= 16;
if (iStat & NUMLOCK_ON    ) iFlag |= 32;
if (iStat & CAPSLOCK_ON   ) iFlag |= 64; // 128 Insert


hb_retnl(iFlag);
}


//FILESTR(<cFile>, [<nLength>], [<nOffset>],[<lCtrl-Z>]) --> cCharacterstring
HB_FUNC( FILESTR )
{

   PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING );
   long int ulCount = ISNUM( 2 ) ? hb_parnl( 2 ) : 0 ;
   long int ulOffset = ISNUM( 3 ) ? hb_parnl( 3 ) : 0 ;
//   BOOL bEof = ISLOG( 4 ) ? hb_parl( 4 ) : FALSE ;

   if( pFileName )
   {
      FHANDLE fhnd = hb_fsOpen( ( BYTE * ) pFileName->item.asString.value, FO_READ | FO_SHARED | FO_PRIVATE );

      if( fhnd != FS_ERROR )
      {
         long int ulSize = hb_fsSeek( fhnd, 0, FS_END ) - ulOffset ;
         if ( ulCount )
            ulSize = HB_MIN(ulCount,ulSize);

         if( ulSize )
         {
            BYTE * pbyBuffer;
            hb_fsSeek( fhnd, ulOffset, FS_SET );
            pbyBuffer = ( BYTE * ) hb_xgrab( ulSize + sizeof( char ) );
            hb_fsReadLarge( fhnd, pbyBuffer, ulSize );
            hb_retclenAdopt( ( char * ) pbyBuffer, ulSize );
         }
         else hb_retc( "" );
         hb_fsClose( fhnd );
      }
      else hb_retc( "" );
   }
   else hb_retc( "" );
}

//
// RunShell( cFile, cOperation, cParams, cDir, nFlag )
//
HB_FUNC( RUNSHELL )
{
#ifdef __PLATFORM__Linux
#else
   hb_retnl( (LONG) ShellExecute( GetActiveWindow(),
              ISNIL(2) ? NULL : (LPCSTR) hb_parc(2),
              (LPCSTR) hb_parc(1),
              ISNIL(3) ? NULL : (LPCSTR) hb_parc(3),
              ISNIL(4) ? "C:\\" : (LPCSTR) hb_parc(4),
              ISNIL(5) ? 1 : hb_parni(5) ) ) ;
#endif
}

//
// FileMapping
//
// FMCreate( cFile ) -> handle
// FMOpen(  cFile )  -> handle
// FMWrite( handle, cWrite )
// FMRead( handle ) -> cRead
// FMClose( handle )
//


HB_FUNC(FMCREATE)
{
#ifdef __PLATFORM__Linux
#else
FHANDLE hMapFile;
hMapFile = CreateFileMapping((HANDLE)0xFFFFFFFF,    // Current file handle.
    NULL,                                    // Default security.
    PAGE_READWRITE,                          // Read/write permission.
    0,                                       // Max. object size.
    1024,                                       // Size of hFile.
    hb_parcx(1));                            // Name of mapping object.

hb_retnl(hMapFile);
#endif
}


HB_FUNC(FMOPEN)
{
#ifdef __PLATFORM__Linux
#else
FHANDLE hMapFile;
hMapFile = OpenFileMapping( FILE_MAP_ALL_ACCESS, FALSE,
                               hb_parcx(1));

hb_retnl( hMapFile == 0 ? -1 : hMapFile );
#endif
}

HB_FUNC(FMREAD)
{
#ifdef __PLATFORM__Linux
#else
ULONG ulOffs = ISNUM(2) ? hb_parnl(2) : 0 ;
ULONG ulCnt  = ISNUM(3) ? hb_parnl(3) : 0 ;
char *lpMapAddress = MapViewOfFile( ( HANDLE ) hb_parnl(1), FILE_MAP_ALL_ACCESS,HIWORD(ulOffs),LOWORD(ulOffs),ulCnt );
hb_retclen(lpMapAddress,ulCnt);
UnmapViewOfFile( lpMapAddress );
#endif
}

HB_FUNC(FMWRITE)
{
#ifdef __PLATFORM__Linux
#else
char *lpMapAddress = MapViewOfFile( ( HANDLE ) hb_parnl(1), FILE_MAP_ALL_ACCESS,0, 0, 0 );
hb_xmemcpy (lpMapAddress, hb_parc(2), hb_parclen(2));
UnmapViewOfFile( lpMapAddress );
hb_retnl(hb_parclen(2));
#endif
}


HB_FUNC(FMCLOSE)
{
#ifdef __PLATFORM__Linux
#else
CloseHandle( ( HANDLE ) hb_parnl(1) );
#endif
}


HB_FUNC( HWINFONETADAPTERS )
{
#ifdef __PLATFORM__Linux
#else
  typedef DWORD (WINAPI * GetAdaptersInfo_Func)(PIP_ADAPTER_INFO, PULONG);

  HINSTANCE             hLib;
  PHB_ITEM              pitmRet, pitmAdapter, pitmTmp;
  IP_ADAPTER_INFO       *pAI, *pAdapter;
  ULONG                 nLen;
  GetAdaptersInfo_Func  pGetAdaptersInfo;



  if ( (DWORD)(hLib = LoadLibrary("iphlpapi.dll")) <= 32 ||
       (pGetAdaptersInfo = (GetAdaptersInfo_Func)GetProcAddress(hLib, "GetAdaptersInfo")) == NULL )  {
    if ( (DWORD)hLib > 32 )  FreeLibrary(hLib);
    hb_ret();
    return;
  }

  pAI = (IP_ADAPTER_INFO*) hb_xgrab( nLen = sizeof(IP_ADAPTER_INFO) );
  if ( pGetAdaptersInfo(pAI, &nLen) == ERROR_BUFFER_OVERFLOW ) {
    hb_xfree(pAI);
    pAI = (IP_ADAPTER_INFO *) hb_xgrab( nLen );
  }

  if ( pGetAdaptersInfo(pAI, &nLen) != ERROR_SUCCESS )  {
    FreeLibrary(hLib);
    hb_ret();
    return;
  }
  FreeLibrary(hLib);

  nLen = 0;
  pAdapter = pAI;
  while ( pAdapter )  {
    nLen++;
    pAdapter = pAdapter->Next;
  }

  pitmRet = hb_itemArrayNew(nLen);
  nLen = 0;
  pAdapter = pAI;
  while ( pAdapter )  {
    pitmAdapter = hb_itemArrayNew(4);

    pitmTmp = hb_itemPutC(NULL, pAdapter->AdapterName);
    hb_arraySetForward(pitmAdapter, 1, pitmTmp);
    hb_itemRelease( pitmTmp );

    pitmTmp = hb_itemPutC(NULL, pAdapter->Description);
    hb_arraySetForward(pitmAdapter, 2, pitmTmp);
    hb_itemRelease( pitmTmp );

    pitmTmp = hb_itemPutCL(NULL, pAdapter->Address, pAdapter->AddressLength);
    hb_arraySetForward(pitmAdapter, 3, pitmTmp);
    hb_itemRelease( pitmTmp );

    pitmTmp = hb_itemPutNI(NULL, pAdapter->Type);
    hb_arraySetForward(pitmAdapter, 4, pitmTmp);
    hb_itemRelease( pitmTmp );

    hb_arraySetForward(pitmRet, ++nLen, pitmAdapter);
    hb_itemRelease( pitmAdapter );
    pAdapter = pAdapter->Next;
  }

  if ( pAI )
    hb_xfree( pAI );
  hb_itemRelease( hb_itemReturn( pitmRet ) );
#endif
}

#undef UNICODE

HB_FUNC( ALLDRIVES )
{

  ULONG nLength = MAX_FILE_NAME, x;
  unsigned char cDrives[MAX_FILE_NAME], cBuffer[2];
  PHB_ITEM array = hb_itemArrayNew( 0 ), temp;

  cBuffer[1] = '\0';
#ifdef __PLATFORM__Linux
#else
  nLength = GetLogicalDriveStringsA(nLength, cDrives);
#endif

  for (x=0 ; x< nLength-1 ; x+=4 )
     {
       sprintf( cBuffer, "%c", toupper(cDrives[x]) );         // Makes Null terminated sting
       temp = hb_itemPutC( NULL, cBuffer );                   // Creates an item
       hb_arrayAddForward( array, temp );                     // inserts the item into array element 1
       hb_itemRelease( temp );                                // releases memory used by temp
     }
  hb_itemReturn( array );
  hb_itemRelease( array );                                    // releases memory used by temp
}

char Byte6ToChar( BYTE b6 )
{

    if (b6 < 10) {
      return (char)((BYTE)'0' + b6); //0-9
    }
	else if (b6 < 36) {
      return (char)((BYTE)'A' + b6 - 10); //A-Z
	}
    else {
      return (char)((BYTE)'А' + b6 - 36); //А-Ы без Ё
	}
}

BOOL genguid22(char *s)
{
#ifdef __PLATFORM__Linux
#else
GUID mGuid;
byte byteGuid[18];
byte  oneNum, oneNumDop;
int i,i3;
int i4;

	CoCreateGuid(&mGuid);

/***
	// стандартный текстовый вид
	char    newline[256];
    wchar_t lpsz[256];
	int     size;

    size = StringFromGUID2( ( REFGUID ) mGuid, lpsz, 256 );
    wcstombs( newline, lpsz, size );

	MessageBox(0, newline, "111", 0);
**/

	do {
		memset(s, 0x0, LEN_GUID);

		memset(&byteGuid, 0x0, sizeof(byteGuid));

		memcpy(&byteGuid, &mGuid, sizeof(mGuid));


		/*
			Guid = 16 байт = 128 бит
			кодируем не 16-ричной системой (2 в 4), а 64-ричной (2 в 6)
			режим 128 бит на кусочки по 6 бит и каждый кусочек конвертируем
			в символ функцией Byte6ToChar.

			режим в следующем цикле.
			8 * 3 = 6 * 4 = 24 бита ==> из 3 байт гуида делаем 4 байта строки

		*/
		for(i=0;i<6;i++) {
			i3 = i*3;
			i4 = i*4;

			//{1}
			oneNum = (byteGuid[i3] & 0xFC) >> 2; //{1111 1100}
			s[i4] = Byte6ToChar(oneNum);

			//{2}
			oneNum = (byteGuid[i3] & 0x03) << 4; //{0000 0011}
			oneNumDop = (byteGuid[i3+1] & 0xF0) >> 4; //{1111 0000}
			oneNum = oneNum | oneNumDop;
			s[i4+1] = Byte6ToChar(oneNum);

			//{3}
			oneNum = (byteGuid[i3+1] & 0x0F) << 2; //{0000 1111}
			oneNumDop = (byteGuid[i3+2] & 0xC0) >> 6; //{1100 0000}
			oneNum = oneNum | oneNumDop;
			s[i4+2] = Byte6ToChar(oneNum);

			//{4}
			oneNum = (byteGuid[i3+2] & 0x3F); //{0011 1111}
			s[i4+3] = Byte6ToChar(oneNum);
		}

		s[22] = '\0';

	/* если первые 10 символов 0 то необходимо перегенерировать guid.
	   guid с такой структурой решили считать системными */

	} while (memcmp("0000000000", s, 10)==0);

//	MessageBox(0, s, "111", 0);
#endif
	return TRUE;// s;
}


HB_FUNC ( NEWGUID22 )
{
#ifdef __PLATFORM__Linux
#else
   char s[LEN_GUID];
   if(genguid22(s) )
   {
     hb_retclen( s, LEN_GUID );
   }
#endif
}



BOOL genguid38(char *s)
{
#ifdef __PLATFORM__Linux
#else
GUID mGuid;
char    newline[256];
wchar_t lpsz[256];
int     size;
CoCreateGuid(&mGuid);
size = StringFromGUID2(&mGuid, &lpsz, 256 );
wcstombs( s, lpsz, size );
#endif
return TRUE;
}


HB_FUNC ( NEWGUID38 ) //получение микрософотовского текстового гуида
{
#ifdef __PLATFORM__Linux
#else
   char s[LEN_GUID0];
   if(genguid38(s) )
   {
     hb_retclen( s, LEN_GUID0 );
   }
#endif
}











#ifdef __PLATFORM__Linux

HB_FUNC ( NETDISK )
{
   hb_retl( 0 );
}

HB_FUNC ( ANSITOOEM )
{
   hb_retc( "" );
}

HB_FUNC ( OEMTOANSI )
{
   hb_retc( "" );
}

#endif

//
// Функции для точного определения типа аргумента
// аналоги функций HB_IS...
// + HB_IT_INTEGER
// + HB_IT_FLOAT
// + HB_IT_ALIAS
// + HB_IT_MEMVAR
// + HB_IT_CHAR   -> HB_IT_MEMOFLAG .or. HB_IT_STRING
// + HB_IT_STRING -> HB_IT_STRING
// + HB_IT_MEMO   -> HB_IT_MEMOFLAG
//

HB_FUNC ( HB_IT_NUMERIC )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & ( HB_IT_INTEGER | HB_IT_LONG | HB_IT_DOUBLE) : FALSE );
}

HB_FUNC ( HB_IT_INTEGER )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & (HB_IT_INTEGER | HB_IT_LONG) : FALSE );
}

HB_FUNC ( HB_IT_FLOAT )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_DOUBLE : FALSE );
}

HB_FUNC ( HB_IT_CHAR )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & ( HB_IT_MEMOFLAG | HB_IT_STRING ) : FALSE );
}

HB_FUNC ( HB_IT_MEMO )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_MEMOFLAG : FALSE );
}

HB_FUNC ( HB_IT_STRING )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_STRING  : FALSE );
}

HB_FUNC ( HB_IT_ARRAY )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_ARRAY : FALSE );
}

HB_FUNC ( HB_IT_OBJECT )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_ARRAY : FALSE );
}

HB_FUNC ( HB_IT_LOGICAL )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_LOGICAL : FALSE );
}

HB_FUNC ( HB_IT_NIL )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_NIL : FALSE );
}

HB_FUNC ( HB_IT_DATE )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_DATE : FALSE );
}

HB_FUNC ( HB_IT_BLOCK )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_BLOCK : FALSE );
}

HB_FUNC ( HB_IT_ALIAS )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_ALIAS : FALSE );
}

HB_FUNC ( HB_IT_MEMVAR )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_MEMVAR : FALSE );
}

HB_FUNC ( HB_IT_BYREF )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_BYREF : FALSE );
}

HB_FUNC ( HB_IT_POINTER )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_POINTER : FALSE );
}

HB_FUNC ( HB_IT_HASH )
{
 PHB_ITEM pAny = hb_param( 1, HB_IT_ANY );
 hb_retl(pAny ? pAny->type & HB_IT_HASH : FALSE );
}


#pragma ENDDUMP
