hbsix

  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\source\rdd\hbsix
sxcompr.c
TypeFunctionSourceLine
STATIC VOIDhb_LZSSxExit( PHB_LZSSX_COMPR pCompr )
static void hb_LZSSxExit( PHB_LZSSX_COMPR pCompr )
{
   if( pCompr->fInFree )
      hb_xfree( pCompr->inBuffer );
   if( pCompr->fOutFree )
      hb_xfree( pCompr->outBuffer );
   hb_xfree( pCompr );
}
sxcompr.c204
STATIC PHB_LZSSX_COMPRhb_LZSSxInit( HB_FHANDLE hInput, BYTE * pSrcBuf, ULONG ulSrcBuf, HB_FHANDLE hOutput, BYTE * pDstBuf, ULONG ulDstBuf )
static PHB_LZSSX_COMPR hb_LZSSxInit( 
                              HB_FHANDLE hInput, BYTE * pSrcBuf, ULONG ulSrcBuf,
                              HB_FHANDLE hOutput, BYTE * pDstBuf, ULONG ulDstBuf )
{
   PHB_LZSSX_COMPR pCompr = ( PHB_LZSSX_COMPR ) hb_xgrab( sizeof( HB_LZSSX_COMPR ) );

   if( hInput != FS_ERROR && ulSrcBuf == 0 )
      ulSrcBuf = LZSS_IOBUFLEN;
   if( hOutput != FS_ERROR && ulDstBuf == 0 )
      ulDstBuf = LZSS_IOBUFLEN;

   pCompr->hInput      = hInput;
   pCompr->inBuffer    = pSrcBuf;
   pCompr->inBuffSize  = ulSrcBuf;
   pCompr->inBuffPos   = 0;
   pCompr->inBuffRead  = ( hInput == FS_ERROR ) ? ulSrcBuf : 0;
   pCompr->fInFree     = ( hInput != FS_ERROR && pSrcBuf == NULL );
   pCompr->hOutput     = hOutput;
   pCompr->outBuffer   = pDstBuf;
   pCompr->outBuffSize = ulDstBuf;
   pCompr->outBuffPos  = 0;
   pCompr->fOutFree    = ( hOutput != FS_ERROR && pDstBuf == NULL );

   pCompr->ulMaxSize   = 0;
   pCompr->ulOutSize   = 0;
   pCompr->fResult     = TRUE;
   pCompr->fContinue   = FALSE;

   if( pCompr->fInFree )
      pCompr->inBuffer    = ( BYTE * ) hb_xgrab( ulDstBuf );
   if( pCompr->fOutFree )
      pCompr->outBuffer   = ( BYTE * ) hb_xgrab( ulDstBuf );

   /* initialize the ring buffer with spaces, because SIX uses
      dynamic ring buffer then we do not have to fill last MAXLENGTH
      characters */
   memset( pCompr->ring_buffer, ' ', RBUFLENGTH - MAXLENGTH );

   return pCompr;
}
sxcompr.c213
STATIC BOOLhb_LZSSxFlush( PHB_LZSSX_COMPR pCompr )
static BOOL hb_LZSSxFlush( PHB_LZSSX_COMPR pCompr )
{
   if( pCompr->fResult && pCompr->hOutput != FS_ERROR )
   {
      if( hb_fsWriteLarge( pCompr->hOutput, pCompr->outBuffer,
                           pCompr->outBuffPos ) != pCompr->outBuffPos )
      {
         pCompr->fResult = FALSE;
      }
      else
      {
         pCompr->ulOutSize += pCompr->outBuffPos;
         pCompr->outBuffPos = 0;
      }
   }
   return pCompr->fResult;
}
sxcompr.c254
STATIC BOOLhb_LZSSxWrite( PHB_LZSSX_COMPR pCompr, BYTE bVal )
static BOOL hb_LZSSxWrite( PHB_LZSSX_COMPR pCompr, BYTE bVal )
{
   if( pCompr->fResult )
   {
      if( pCompr->outBuffPos == pCompr->outBuffSize )
         hb_LZSSxFlush( pCompr );
      if( pCompr->outBuffPos < pCompr->outBuffSize )
         pCompr->outBuffer[pCompr->outBuffPos] = bVal;
      else
         pCompr->fResult = FALSE;
   }
   pCompr->outBuffPos++;
   return pCompr->fResult || pCompr->fContinue;
}
sxcompr.c272
STATIC INThb_LZSSxRead( PHB_LZSSX_COMPR pCompr )
static int hb_LZSSxRead( PHB_LZSSX_COMPR pCompr )
{
   if( pCompr->inBuffPos < pCompr->inBuffRead )
      return pCompr->inBuffer[ pCompr->inBuffPos++ ];

   if( pCompr->hInput != FS_ERROR )
   {
      pCompr->inBuffRead = hb_fsReadLarge( pCompr->hInput, pCompr->inBuffer,
                                           pCompr->inBuffSize );
      pCompr->inBuffPos = 0;
      if( pCompr->inBuffPos < pCompr->inBuffRead )
         return pCompr->inBuffer[ pCompr->inBuffPos++ ];
   }
   return -1;
}
sxcompr.c287
STATIC BOOLhb_LZSSxDecode( PHB_LZSSX_COMPR pCompr )
static BOOL hb_LZSSxDecode( PHB_LZSSX_COMPR pCompr )
{
   BOOL fResult = TRUE;
   USHORT itemMask;
   int offset, length, index, c, h;

   index = RBUFLENGTH - MAXLENGTH;
   itemMask = 0;

   do
   {
      itemMask >>= 1;
      /* Is the next character bitfield with type of next 8 items ? */
      if( ( itemMask & 0x0100 ) == 0 )
      {
         if( ( c = hb_LZSSxRead( pCompr ) ) == -1 )
            break;
         /* simple trick to reduce number of shift operations */
         itemMask = c | 0xff00;
      }
      if( ( c = hb_LZSSxRead( pCompr ) ) == -1 )
         break;

      if( itemMask & 1 ) /* Is the next character normal byte ? */
      {
         if( ! hb_LZSSxWrite( pCompr, ( BYTE ) c ) )
         {
            fResult = FALSE;
            break;
         }
         pCompr->ring_buffer[ index ] = ( BYTE ) c;
         index = RBUFINDEX( index + 1 );
      }
      else /* we have an item pair (ring buffer offset : match length) */
      {
         if( ( h = hb_LZSSxRead( pCompr ) ) == -1 )
         {
            /* fResult = FALSE; */
            break;
         }
         offset = LZSS_OFFSET( c, h );   /* get offset to ring buffer */
         length = LZSS_LENGTH( c, h );   /* get match length */
         for( h = 0; h < length; h++ )
         {
            c = pCompr->ring_buffer[ RBUFINDEX( offset + h ) ];
            if( ! hb_LZSSxWrite( pCompr, ( BYTE ) c ) )
            {
               fResult = FALSE;
               break;
            }
            /* SIX does not use additional buffers and dynamically
               overwrite the ring buffer - we have to make exactly
               the same or our results will be differ when
               abs( offset - index ) < length */
            pCompr->ring_buffer[ index ] = ( BYTE ) c;
            index = RBUFINDEX( index + 1 );
         }
      }
   }
   while( fResult );

   if( fResult )
      fResult = hb_LZSSxFlush( pCompr );
   return fResult;
}
sxcompr.c303
STATIC VOIDhb_LZSSxNodeInsert( PHB_LZSSX_COMPR pCompr, int r )
static void hb_LZSSxNodeInsert( PHB_LZSSX_COMPR pCompr, int r )
{
   int i, p, cmp;
   unsigned char *key;

   cmp = 1;
   key = &pCompr->ring_buffer[ r ];
   p   = RBUFLENGTH + 1 + key[ 0 ];
   pCompr->right[ r ] = pCompr->left[ r ] = DUMMYNODE;
   pCompr->match_length = 0;

   for( ; ; )
   {
      if( cmp >= 0 )
      {
         if( pCompr->right[ p ] != DUMMYNODE )
            p = pCompr->right[ p ];
         else
         {
            pCompr->right[ p ] = r;
            pCompr->parent[ r ] = p;
            return;
         }
      }
      else
      {
         if( pCompr->left[ p ] != DUMMYNODE )
            p = pCompr->left[ p ];
         else
         {
            pCompr->left[ p ] = r;
            pCompr->parent[ r ] = p;
            return;
         }
      }
      for( i = 1; i < MAXLENGTH; i++ )
      {
         if( ( cmp = key[ i ] - pCompr->ring_buffer[ p + i ] ) != 0 )
            break;
      }
      if( i > pCompr->match_length )
      {
         pCompr->match_offset = p;
         pCompr->match_length = i;
         if( i >= MAXLENGTH )
             break;
      }
   }
   pCompr->parent[ r ] = pCompr->parent[ p ];
   pCompr->left[ r ]   = pCompr->left[ p ];
   pCompr->right[ r ]  = pCompr->right[ p ];
   pCompr->parent[ pCompr->left[ p ] ]  = r;
   pCompr->parent[ pCompr->right[ p ] ] = r;
   if( pCompr->right[ pCompr->parent[ p ] ] == p )
      pCompr->right[ pCompr->parent[ p ] ] = r;
   else
      pCompr->left[ pCompr->parent[ p ] ] = r;
   pCompr->parent[ p ] = DUMMYNODE;
}
sxcompr.c369
STATIC VOIDhb_LZSSxNodeDelete( PHB_LZSSX_COMPR pCompr, int p )
static void hb_LZSSxNodeDelete( PHB_LZSSX_COMPR pCompr, int p )
{
   if( pCompr->parent[ p ] != DUMMYNODE )
   {
      int  q;
      if( pCompr->right[ p ] == DUMMYNODE )
         q = pCompr->left[ p ];
      else if( pCompr->left[ p ] == DUMMYNODE )
         q = pCompr->right[ p ];
      else
      {
         q = pCompr->left[ p ];
         if( pCompr->right[ q ] != DUMMYNODE )
         {
            do
            {
               q = pCompr->right[ q ];
            }
            while( pCompr->right[ q ] != DUMMYNODE );
            pCompr->right[ pCompr->parent[ q ] ] = pCompr->left[ q ];
            pCompr->parent[ pCompr->left[ q ] ] = pCompr->parent[ q ];
            pCompr->left[ q ] = pCompr->left[ p ];
            pCompr->parent[ pCompr->left[ p ] ] = q;
         }
         pCompr->right[ q ] = pCompr->right[ p ];
         pCompr->parent[ pCompr->right[ p ] ] = q;
      }
      pCompr->parent[ q ] = pCompr->parent[ p ];
      if( pCompr->right[ pCompr->parent[ p ] ] == p )
         pCompr->right[ pCompr->parent[ p ] ] = q;
      else
         pCompr->left[ pCompr->parent[ p ] ] = q;
      pCompr->parent[ p ] = DUMMYNODE;
   }
}
sxcompr.c429
STATIC ULONGhb_LZSSxEncode( PHB_LZSSX_COMPR pCompr )
static ULONG hb_LZSSxEncode( PHB_LZSSX_COMPR pCompr )
{
   BYTE itemSet[ITEMSETSIZE];
   BYTE itemMask;
   ULONG ulSize = 0;
   int iItem;
   short int  i, c, len, r, s, last_match_length;

   for( i = RBUFLENGTH + 1; i < RBUFLENGTH + 257; i++ )
      pCompr->right[i] = DUMMYNODE;
   for( i = 0; i < RBUFLENGTH; i++ )
      pCompr->parent[ i ] = DUMMYNODE;

   itemSet[ 0 ] = 0;
   iItem = itemMask = 1;
   s = 0;
   r = RBUFLENGTH - MAXLENGTH;

   for( len = 0; len < MAXLENGTH; len++ )
   {
      if( ( c = hb_LZSSxRead( pCompr ) ) == -1 )
         break;
      pCompr->ring_buffer[ r + len ] = ( BYTE ) c;
   }
   if( len == 0 )
      return ulSize;

   for( i = 1; i <= MAXLENGTH; i++ )
      hb_LZSSxNodeInsert( pCompr, r - i );
   hb_LZSSxNodeInsert( pCompr, r );

   do
   {
      if( pCompr->match_length > len )
         pCompr->match_length = len;
      if( pCompr->match_length < MINLENGTH )
      {
         pCompr->match_length = 1;
         itemSet[ 0 ] |= itemMask;
         itemSet[ iItem++ ] = pCompr->ring_buffer[ r ];
      }
      else
      {
         itemSet[iItem++] = LZSS_ITMLO( pCompr->match_offset,
                                        pCompr->match_length );
         itemSet[iItem++] = LZSS_ITMHI( pCompr->match_offset,
                                        pCompr->match_length );
      }
      if( ( itemMask <<= 1 ) == 0 )
      {
         for( i = 0; i < iItem; i++ )
         {
            if( !hb_LZSSxWrite( pCompr, itemSet[ i ] ) )
               return ( ULONG ) -1;
         }
         ulSize += iItem;
         itemSet[ 0 ] = 0;
         iItem = itemMask = 1;
      }
      last_match_length = pCompr->match_length;
      for( i = 0; i < last_match_length &&
                        ( c = hb_LZSSxRead( pCompr ) ) != -1; i++ )
      {
         hb_LZSSxNodeDelete( pCompr, s );
         pCompr->ring_buffer[ s ] = ( BYTE ) c;
         if( s < MAXLENGTH - 1 )
            pCompr->ring_buffer[ s + RBUFLENGTH ] = ( BYTE ) c;
         s = ( short int ) RBUFINDEX( s + 1 );
         r = ( short int ) RBUFINDEX( r + 1 );
         hb_LZSSxNodeInsert( pCompr, r );
      }
      while( i++ < last_match_length )
      {
         hb_LZSSxNodeDelete( pCompr, s );
         s = ( short int ) RBUFINDEX( s + 1 );
         r = ( short int ) RBUFINDEX( r + 1 );
         if( --len )
            hb_LZSSxNodeInsert( pCompr, r );
      }
   } while( len > 0 );

   if( iItem > 1 )
   {
      for( i = 0; i < iItem; i++ )
      {
         if( !hb_LZSSxWrite( pCompr, itemSet[ i ] ) )
            return ( ULONG ) -1;
      }
      ulSize += iItem;
   }

   if( !hb_LZSSxFlush( pCompr ) )
      return ( ULONG ) -1;

   return ulSize;
}
sxcompr.c465
BOOLhb_LZSSxCompressMem( BYTE * pSrcBuf, ULONG ulSrcLen, BYTE * pDstBuf, ULONG ulDstLen, ULONG * pulSize )
BOOL hb_LZSSxCompressMem( BYTE * pSrcBuf, ULONG ulSrcLen,
                          BYTE * pDstBuf, ULONG ulDstLen,
                          ULONG * pulSize )
{
   PHB_LZSSX_COMPR pCompr;
   ULONG ulSize;

   pCompr = hb_LZSSxInit( FS_ERROR, pSrcBuf, ulSrcLen,
                          FS_ERROR, pDstBuf, ulDstLen );
   ulSize = hb_LZSSxEncode( pCompr );
   hb_LZSSxExit( pCompr );
   if( pulSize )
      *pulSize = ulSize;
   return ( ulSize <= ulDstLen );
}
sxcompr.c563
BOOLhb_LZSSxDecompressMem( BYTE * pSrcBuf, ULONG ulSrcLen, BYTE * pDstBuf, ULONG ulDstLen )
BOOL hb_LZSSxDecompressMem( BYTE * pSrcBuf, ULONG ulSrcLen,
                            BYTE * pDstBuf, ULONG ulDstLen )
{
   PHB_LZSSX_COMPR pCompr;
   BOOL fResult;

   pCompr = hb_LZSSxInit( FS_ERROR, pSrcBuf, ulSrcLen,
                          FS_ERROR, pDstBuf, ulDstLen );
   fResult = hb_LZSSxDecode( pCompr );
   hb_LZSSxExit( pCompr );
   return fResult;
}
sxcompr.c579
BOOLhb_LZSSxCompressFile( HB_FHANDLE hInput, HB_FHANDLE hOutput, ULONG * pulSize )
BOOL hb_LZSSxCompressFile( HB_FHANDLE hInput, HB_FHANDLE hOutput, ULONG * pulSize )
{
   PHB_LZSSX_COMPR pCompr;
   ULONG ulSize;

   pCompr = hb_LZSSxInit( hInput, NULL, 0, hOutput, NULL, 0 );
   ulSize = hb_LZSSxEncode( pCompr );
   hb_LZSSxExit( pCompr );
   if( pulSize )
      *pulSize = ulSize;
   return ulSize != ( ULONG ) -1;
}
sxcompr.c592
BOOLhb_LZSSxDecompressFile( HB_FHANDLE hInput, HB_FHANDLE hOutput )
BOOL hb_LZSSxDecompressFile( HB_FHANDLE hInput, HB_FHANDLE hOutput )
{
   PHB_LZSSX_COMPR pCompr;
   BOOL fResult;

   pCompr = hb_LZSSxInit( hInput, NULL, 0, hOutput, NULL, 0 );
   fResult = hb_LZSSxDecode( pCompr );
   hb_LZSSxExit( pCompr );
   return fResult;
}
sxcompr.c605
HB_FUNCSX_FCOMPRESS(void)
HB_FUNC( SX_FCOMPRESS )
{
   BOOL fRet = FALSE;
   HB_FHANDLE hInput, hOutput;
   char * szSource = hb_parc( 1 ), * szDestin = hb_parc( 2 );
   BYTE buf[ 4 ];
   ULONG ulSize;

   if( szSource && *szSource && szDestin && *szDestin )
   {
      hInput = hb_fsExtOpen( ( BYTE * ) szSource, NULL, FO_READ | FO_DENYNONE |
                              FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL );
      if( hInput != FS_ERROR )
      {
         hOutput = hb_fsExtOpen( ( BYTE * ) szDestin, NULL, FO_READWRITE |
                                 FO_EXCLUSIVE | FXO_TRUNCATE |
                                 FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL );
         if( hOutput != FS_ERROR )
         {
            /* store uncompressed file size in first 4 bytes of destination
             * file in little endian order - for SIX3 compatibility
             */
            ulSize = hb_fsSeek( hInput, 0, FS_END );
            if( hb_fsSeek( hInput, 0, FS_SET ) == 0 )
            {
               HB_PUT_LE_UINT32( buf, ulSize );
               if( hb_fsWrite( hOutput, buf, 4 ) == 4 )
                  fRet = hb_LZSSxCompressFile( hInput, hOutput, NULL );
            }
            hb_fsClose( hOutput );
         }
         hb_fsClose( hInput );
      }
   }
   hb_retl( fRet );
}
sxcompr.c616
HB_FUNCSX_FDECOMPRESS(void)
HB_FUNC( SX_FDECOMPRESS )
{
   BOOL fRet = FALSE;
   HB_FHANDLE hInput, hOutput;
   char * szSource = hb_parc( 1 ), * szDestin = hb_parc( 2 );

   if( szSource && *szSource && szDestin && *szDestin )
   {
      hInput = hb_fsExtOpen( ( BYTE * ) szSource, NULL, FO_READ | FO_DENYNONE |
                              FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL );
      if( hInput != FS_ERROR )
      {
         hOutput = hb_fsExtOpen( ( BYTE * ) szDestin, NULL, FO_READWRITE |
                                 FO_EXCLUSIVE | FXO_TRUNCATE |
                                 FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL );
         if( hOutput != FS_ERROR )
         {
            /* skip the four bytes with original file length */
            if( hb_fsSeek( hInput, 4, FS_SET ) == 4 )
               fRet = hb_LZSSxDecompressFile( hInput, hOutput );
            hb_fsClose( hOutput );
         }
         hb_fsClose( hInput );
      }
   }
   hb_retl( fRet );
}
sxcompr.c653
HB_FUNC_SX_STRCOMPRESS(void)
HB_FUNC( _SX_STRCOMPRESS )
{
   BYTE * pStr = ( BYTE * ) hb_parc( 1 ), * pBuf;

   if( pStr )
   {
      ULONG ulLen = hb_parclen( 1 ), ulBuf, ulDst;

      /* this is for strict SIX compatibility - in general very bad idea */
      ulBuf = ulLen + 257;
      pBuf = ( BYTE * ) hb_xgrab( ulBuf );
      HB_PUT_LE_UINT32( pBuf, ulLen );
      if( ! hb_LZSSxCompressMem( pStr, ulLen, pBuf + 4, ulBuf - 4, &ulDst ) )
      {
         /* It's not six compatible - it's a workaround for wrongly defined SIX behavior */
         HB_PUT_LE_UINT32( pBuf, HB_SX_UNCOMPRESED );
         memcpy( pBuf + 4, pStr, ulLen );
         ulDst = ulLen;
      }
      hb_retclen( ( char * ) pBuf, ulDst + 4 );
      hb_xfree( pBuf );
   }
   else
      hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
}
sxcompr.c681
HB_FUNC_SX_STRDECOMPRESS(void)
HB_FUNC( _SX_STRDECOMPRESS )
{
   BOOL fOK = FALSE;
   BYTE * pStr = ( BYTE * ) hb_parc( 1 ), * pBuf;

   if( pStr )
   {
      ULONG ulLen = hb_parclen( 1 ), ulBuf;

      if( ulLen >= 4 )
      {
         ulBuf = HB_GET_LE_UINT32( pStr );
         if( ulBuf == HB_SX_UNCOMPRESED )
         {
            hb_retclen( ( char * ) pStr + 4, ulLen - 4 );
            fOK = TRUE;
         }
         else
         {
            pBuf = ( BYTE * ) hb_xalloc( ulBuf + 1 );
            if( pBuf )
            {
               fOK = hb_LZSSxDecompressMem( pStr + 4, ulLen - 4, pBuf, ulBuf );
               if( fOK )
                  hb_retclen_buffer( ( char * ) pBuf, ulBuf );
               else
                  hb_xfree( pBuf );
            }
            else
            {
               PHB_ITEM pItem = hb_errRT_SubstParams( "SIXCOMPRESS", EG_MEM, 0, "possible compressed string corruption", "_SX_STRDECOMPRESS" );
               if( pItem )
                  hb_itemReturnRelease( pItem );
               return;
            }
         }
      }
   }

   if( !fOK )
      hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
}
sxcompr.c707
sxcrypt.c
TypeFunctionSourceLine
STATIC UINT32hb_sxInitSeed( BYTE * pKeyVal, UINT16 * puiKey )
static UINT32 hb_sxInitSeed( BYTE * pKeyVal, UINT16 * puiKey )
{
   UINT32 ulSeed = 0;
   int i;

   for( i = 0; i < 7; i++ )
   {
      ulSeed = ( ( ( ulSeed >> 16 ) + ( ulSeed << 16 ) ) * 17 ) +
               HB_GET_LE_UINT16( &pKeyVal[i] );
   }
   ulSeed |= 1;
   *puiKey = ( UINT16 ) ulSeed;
   return ( ulSeed << 16 ) + ( ulSeed >> 16 );
}
sxcrypt.c63
STATIC UINT32hb_sxNextSeed( UINT32 ulSeed, BYTE * pKeyVal, UINT16 * puiKey )
static UINT32 hb_sxNextSeed( UINT32 ulSeed, BYTE * pKeyVal, UINT16 * puiKey )
{
   UINT32 ulTemp1, ulTemp2;
   UINT16 uiSeedLo, uiSeedHi;

   uiSeedLo = ( UINT16 ) ulSeed;
   ulTemp1  = ( UINT32 ) rnd_mul1 * ( UINT32 ) uiSeedLo;
   ulTemp2  = ( UINT32 ) rnd_mul2 * ( UINT32 ) uiSeedLo + ( ulTemp1 >> 16 );
   uiSeedLo = ( UINT16 ) ulTemp1;
   ulTemp1  = ( UINT32 ) rnd_mul1 * ( ulSeed >> 16 );
   uiSeedHi = ( UINT16 ) ( ulTemp1 + ulTemp2 );
   ulSeed   = ( ( UINT32 ) uiSeedHi << 16 ) + ( UINT32 ) uiSeedLo;
   uiSeedHi |= 1;
   *puiKey  = uiSeedHi + HB_GET_LE_UINT16( pKeyVal );
   return ulSeed;
}
sxcrypt.c78
VOIDhb_sxEnCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen )
void hb_sxEnCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen )
{
   UINT32 ulSeed;
   UINT16 uiKey;
   BYTE uChar, uShft;
   ULONG ul;
   int i;

   ulSeed = hb_sxInitSeed( pKeyVal, &uiKey );
   for( ul = 0, i = 0; ul < ulLen; ul++ )
   {
      uChar = pSrc[ul];
      uShft = uiKey & 0x07;
      pDst[ul] = ( uChar >> uShft ) + ( uChar << ( 8 - uShft ) ) +
                 ( uiKey & 0xFF );
      ulSeed = hb_sxNextSeed( ulSeed, &pKeyVal[i], &uiKey );
      if( ++i == 7 )
         i = 0;
   }
}
sxcrypt.c95
VOIDhb_sxDeCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen )
void hb_sxDeCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen )
{
   UINT32 ulSeed;
   UINT16 uiKey;
   BYTE uChar, uShft;
   ULONG ul;
   int i;

   ulSeed = hb_sxInitSeed( pKeyVal, &uiKey );
   for( ul = 0, i = 0; ul < ulLen; ul++ )
   {
      uChar = pSrc[ul] - ( uiKey & 0xFF );
      uShft = uiKey & 0x07;
      pDst[ul] = ( uChar << uShft ) + ( uChar >> ( 8 - uShft ) );
      ulSeed = hb_sxNextSeed( ulSeed, &pKeyVal[i], &uiKey );
      if( ++i == 7 )
         i = 0;
   }
}
sxcrypt.c116
STATIC BOOL_hb_sxGetKey( PHB_ITEM pKeyItem, BYTE * pKeyVal )
static BOOL _hb_sxGetKey( PHB_ITEM pKeyItem, BYTE * pKeyVal )
{
   BOOL fResult = FALSE;
   PHB_ITEM pItem = NULL;
   ULONG ulKey;

   if( ! ( hb_itemType( pKeyItem ) & HB_IT_STRING ) )
   {
      AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

      if( pArea )
      {
         pItem = hb_itemNew( NULL );
         if( SELF_INFO( pArea, DBI_PASSWORD, pItem ) == SUCCESS )
            pKeyItem = pItem;
      }
   }
   if( hb_itemType( pKeyItem ) & HB_IT_STRING )
   {
      ulKey = hb_itemGetCLen( pKeyItem );
      if( ulKey )
         memcpy( pKeyVal, hb_itemGetCPtr( pKeyItem ), HB_MIN( ulKey, 8 ) );
      if( ulKey < 8 )
         memset( pKeyVal + ulKey, 0, 8 - ulKey );
      fResult = TRUE;
   }
   if( pItem )
      hb_itemRelease( pItem );
   return fResult;
}
sxcrypt.c136
HB_FUNCSX_ENCRYPT(void)
HB_FUNC( SX_ENCRYPT )
{
   if( hb_pcount() > 0 )
   {
      BYTE keyBuf[ 8 ];
      ULONG ulLen = hb_parclen( 1 );

      if( ulLen > 0 && _hb_sxGetKey( hb_param( 2, HB_IT_ANY ), keyBuf ) )
      {
         BYTE * pDst = ( BYTE * ) hb_xgrab( ulLen + 1 );
         hb_sxEnCrypt( ( BYTE * ) hb_parc( 1 ), pDst, keyBuf, ulLen );
         pDst[ ulLen ] = 0;
         hb_retclen_buffer( ( char * ) pDst, ulLen );
      }
      else
      {
         hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
      }
   }
}
sxcrypt.c167
HB_FUNCSX_DECRYPT(void)
HB_FUNC( SX_DECRYPT )
{
   if( hb_pcount() > 0 )
   {
      BYTE keyBuf[ 8 ];
      ULONG ulLen = hb_parclen( 1 );

      if( ulLen > 0 && _hb_sxGetKey( hb_param( 2, HB_IT_ANY ), keyBuf ) )
      {
         BYTE * pDst = ( BYTE * ) hb_xgrab( ulLen + 1 );
         hb_sxDeCrypt( ( BYTE * ) hb_parc( 1 ), pDst, keyBuf, ulLen );
         pDst[ ulLen ] = 0;
         hb_retclen_buffer( ( char * ) pDst, ulLen );
      }
      else
      {
         hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
      }
   }
}
sxcrypt.c188
sxdate.c
TypeFunctionSourceLine
CHAR *hb_sxDtoP( char * pDate, LONG lJulian )
char * hb_sxDtoP( char * pDate, LONG lJulian )
{
   int iYear, iMonth, iDay;
   LONG lPDate;

   HB_TRACE(HB_TR_DEBUG, ("hb_sxDtoP(%p, %ld)", pDate, lJulian));

   hb_dateDecode( lJulian, &iYear, &iMonth, &iDay );
   lPDate = ( ( ( iYear << 1 ) | ( iMonth >> 3 ) ) << 8 ) |
            ( ( iMonth & 7 ) << 5 ) | iDay;
   HB_PUT_BE_UINT24( pDate, lPDate );

   return pDate;
}
sxdate.c60
LONGhb_sxPtoD( char * pDate )
LONG hb_sxPtoD( char * pDate )
{
   int iYear, iMonth, iDay;
   LONG lPDate;

   HB_TRACE(HB_TR_DEBUG, ("hb_sxPtoD(%p)", pDate));

   if( pDate )
   {
      lPDate = HB_GET_BE_UINT24( pDate );
      iDay = lPDate & 0x1f;
      iMonth = ( lPDate >> 5 ) & 0x0f;
      iYear = ( lPDate >> 9 );

      return hb_dateEncode( iYear, iMonth, iDay );
   }
   return 0;
}
sxdate.c75
HB_FUNCSX_DTOP(void)
HB_FUNC( SX_DTOP )
{
   char pDate[ 3 ];
   hb_retclen( hb_sxDtoP( pDate, hb_pardl( 1 ) ), 3 );
}
sxdate.c94
HB_FUNCSX_PTOD(void)
HB_FUNC( SX_PTOD )
{
   hb_retdl( hb_sxPtoD( hb_parclen( 1 ) < 3 ? NULL : hb_parc( 1 ) ) );
}
sxdate.c100
sxfname.c
TypeFunctionSourceLine
HB_FUNCSX_FNAMEPARSER(void)
HB_FUNC( SX_FNAMEPARSER )
{
   char * szFileName = hb_parc( 1 );

   if( szFileName )
   {
      char szPathBuf[ _POSIX_PATH_MAX + 1 ];
      PHB_FNAME pFileName;
      ULONG ulLen;
      BOOL fFree;

      szFileName = ( char * ) hb_fsNameConv( ( BYTE * ) szFileName, &fFree );

      pFileName = hb_fsFNameSplit( szFileName );

      if( !ISLOG( 2 ) || !hb_parl( 2 ) )
         pFileName->szPath = NULL;
      if( !ISLOG( 3 ) || !hb_parl( 3 ) )
         pFileName->szExtension = NULL;

      if( !hb_setGetTrimFileName() )
      {
         if( pFileName->szName )
         {
            ulLen = strlen( pFileName->szName );
            ulLen = hb_strRTrimLen( pFileName->szName, ulLen, FALSE );
            pFileName->szName = hb_strLTrim( pFileName->szName, &ulLen );
            ( ( char * ) pFileName->szName )[ulLen] = '\0';
         }
         if( pFileName->szExtension )
         {
            ulLen = strlen( pFileName->szExtension );
            ulLen = hb_strRTrimLen( pFileName->szExtension, ulLen, FALSE );
            pFileName->szExtension = hb_strLTrim( pFileName->szExtension, &ulLen );
            ( ( char * ) pFileName->szExtension )[ulLen] = '\0';
         }
      }

      if( fFree )
         hb_retc_buffer( hb_fsFNameMerge( szFileName, pFileName ) );
      else
         hb_retc( hb_fsFNameMerge( szPathBuf, pFileName ) );

      hb_xfree( pFileName );
   }
   else
      hb_retc( NULL );
}
sxfname.c58
sxord.c
TypeFunctionSourceLine
STATIC BOOLhb_sxOrdParam( LPDBORDERINFO pInfo )
static BOOL hb_sxOrdParam( LPDBORDERINFO pInfo )
{
   memset( pInfo, 0, sizeof( DBORDERINFO ) );

   if( ISCHAR( 1 ) )
   {
      pInfo->itmOrder = hb_param( 1, HB_IT_STRING );
      pInfo->atomBagName = hb_param( 2, HB_IT_STRING );
   }
   else if( ISNUM( 1 ) )
   {
      pInfo->itmOrder = hb_param( 1, HB_IT_NUMERIC );
      if( ! ISNIL( 2 ) ) /* hb_pcount() > 2 */
      {
         pInfo->atomBagName = hb_param( 2, HB_IT_NUMERIC );
         if( hb_parni( 2 ) <= 0 )
            return FALSE;
      }
   }
   return TRUE;
}
sxord.c90
HB_FUNCSX_TAGORDER(void)
HB_FUNC( SX_TAGORDER )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   int iOrder = 0;

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemPutNI( NULL, 0 );
         SELF_ORDINFO( pArea, DBOI_NUMBER, &Info );
         iOrder = hb_itemGetNI( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }

   hb_retni( iOrder );
}
sxord.c112
HB_FUNCSX_TAGNO(void)
HB_FUNC( SX_TAGNO )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   int iBagOrder = 0, iOrder;

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemPutNI( NULL, 0 );
         if( SELF_ORDINFO( pArea, DBOI_NUMBER, &Info ) == SUCCESS )
         {
            iOrder = hb_itemGetNI( Info.itmResult );
            if( iOrder )
            {
               Info.itmOrder = hb_itemPutNI( NULL, iOrder );
               Info.atomBagName = NULL;
               hb_itemClear( Info.itmResult );
               if( SELF_ORDINFO( pArea, DBOI_FULLPATH, &Info ) == SUCCESS &&
                   hb_itemGetCLen( Info.itmResult ) > 0 )
               {
                  Info.atomBagName = Info.itmResult;
                  Info.itmResult = Info.itmOrder;
                  Info.itmOrder = NULL;
                  hb_itemClear( Info.itmResult );
                  if( SELF_ORDINFO( pArea, DBOI_BAGORDER, &Info ) == SUCCESS )
                     iBagOrder = iOrder - hb_itemGetNI( Info.itmResult ) + 1;
                  Info.itmOrder = Info.atomBagName;
               }
               hb_itemRelease( Info.itmOrder );
            }
         }
         hb_itemRelease( Info.itmResult );
      }
   }

   hb_retni( iBagOrder );
}
sxord.c133
HB_FUNCSX_FREEZE(void)
HB_FUNC( SX_FREEZE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         BOOL fResult = FALSE;
         Info.itmNewVal = hb_itemPutL( NULL, TRUE );
         Info.itmResult = hb_itemNew( NULL );
         if( SELF_ORDINFO( pArea, DBOI_CUSTOM, &Info ) == SUCCESS )
            fResult = HB_IS_LOGICAL( Info.itmResult ) &&
                      hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmNewVal );
         hb_itemRelease( Info.itmResult );
         hb_retl( fResult );
      }
   }
}
sxord.c178
HB_FUNCSX_WARM(void)
HB_FUNC( SX_WARM )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         BOOL fResult = FALSE;
         Info.itmNewVal = hb_itemPutL( NULL, FALSE );
         Info.itmResult = hb_itemNew( NULL );
         if( SELF_ORDINFO( pArea, DBOI_CHGONLY, &Info ) == SUCCESS )
            fResult = HB_IS_LOGICAL( Info.itmResult ) &&
                      !hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmNewVal );
         hb_itemRelease( Info.itmResult );
         hb_retl( fResult );
      }
   }
}
sxord.c201
HB_FUNCSX_CHILL(void)
HB_FUNC( SX_CHILL )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         BOOL fResult = FALSE;
         Info.itmNewVal = hb_itemPutL( NULL, TRUE );
         Info.itmResult = hb_itemNew( NULL );
         if( SELF_ORDINFO( pArea, DBOI_CHGONLY, &Info ) == SUCCESS )
            fResult = HB_IS_LOGICAL( Info.itmResult ) &&
                      hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmNewVal );
         hb_itemRelease( Info.itmResult );
         hb_retl( fResult );
      }
   }
}
sxord.c224
HB_FUNCSX_THERMOMETER(void)
HB_FUNC( SX_THERMOMETER )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   int iTemperature = -1, i;

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemPutNI( NULL, 0 );
         SELF_ORDINFO( pArea, DBOI_NUMBER, &Info );
         i = hb_itemGetNI( Info.itmResult );
         if( i )
         {
            static const USHORT s_iStates[] = 
                     { DBOI_CUSTOM, DBOI_CHGONLY, DBOI_PARTIAL };
            iTemperature = 4;
            for( i = 0; i < 3; ++i, --iTemperature )
            {
               hb_itemClear( Info.itmResult );
               if( SELF_ORDINFO( pArea, s_iStates[i], &Info ) == SUCCESS &&
                   HB_IS_LOGICAL( Info.itmResult ) &&
                   hb_itemGetL( Info.itmResult ) )
                  break;
            }
         }
         hb_itemRelease( Info.itmResult );
      }
   }

   hb_retni( iTemperature );
}
sxord.c247
HB_FUNCSX_CLRSCOPE(void)
HB_FUNC( SX_CLRSCOPE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         int iScope = ISNUM( 1 ) ? hb_parni( 1 ) : 2;
         Info.itmResult = hb_itemNew( NULL );
         if( iScope )
            SELF_ORDINFO( pArea, DBOI_SCOPEBOTTOMCLEAR, &Info );
         if( iScope == 0 || iScope == 2 )
            SELF_ORDINFO( pArea, DBOI_SCOPETOPCLEAR, &Info );
         hb_itemRelease( Info.itmResult );
      }
   }
}
sxord.c289
HB_FUNCSX_SETSCOPE(void)
HB_FUNC( SX_SETSCOPE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;

      if( hb_sxOrdParam( &Info ) )
      {
         int iScope = hb_parni( 1 );
         Info.itmResult = hb_itemNew( NULL );
         if( !ISNIL( 2 ) )
            Info.itmNewVal = hb_param( 2, HB_IT_ANY );
         SELF_ORDINFO( pArea, ( USHORT ) ( iScope ? DBOI_SCOPEBOTTOM : DBOI_SCOPETOP ), &Info );
         hb_itemReturnRelease( Info.itmResult );
      }
   }
}
sxord.c310
HB_FUNCSX_ISREINDEX(void)
HB_FUNC( SX_ISREINDEX )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fReindex = FALSE;

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmResult = hb_itemNew( NULL );
      SELF_ORDINFO( pArea, DBOI_ISREINDEX, &Info );
      fReindex = hb_itemGetL( Info.itmResult );
      hb_itemRelease( Info.itmResult );
   }

   hb_retl( fReindex );
}
sxord.c330
HB_FUNCSX_STEP(void)
HB_FUNC( SX_STEP )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   LONG lStep = 0;

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmResult = hb_itemNew( NULL );
      SELF_ORDINFO( pArea, DBOI_EVALSTEP, &Info );
      lStep = hb_itemGetNL( Info.itmResult );
      hb_itemRelease( Info.itmResult );
   }

   hb_retnint( lStep );
}
sxord.c348
HB_FUNCSX_KEYSINCLUDED(void)
HB_FUNC( SX_KEYSINCLUDED )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   ULONG ulKeys = 0;

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmResult = hb_itemNew( NULL );
      SELF_ORDINFO( pArea, DBOI_KEYSINCLUDED, &Info );
      ulKeys = hb_itemGetNL( Info.itmResult );
      hb_itemRelease( Info.itmResult );
   }

   hb_retnint( ulKeys );
}
sxord.c366
HB_FUNCSX_I_INDEXNAME(void)
HB_FUNC( SX_I_INDEXNAME )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmResult = hb_itemNew( NULL );
      SELF_ORDINFO( pArea, DBOI_I_BAGNAME, &Info );
      hb_itemReturnRelease( Info.itmResult );
      return;
   }

   hb_retc( NULL );
}
sxord.c384
HB_FUNCSX_I_TAGNAME(void)
HB_FUNC( SX_I_TAGNAME )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmResult = hb_itemNew( NULL );
      SELF_ORDINFO( pArea, DBOI_I_TAGNAME, &Info );
      hb_itemReturnRelease( Info.itmResult );
      return;
   }

   hb_retc( NULL );
}
sxord.c401
HB_FUNCSX_INDEXCOUNT(void)
HB_FUNC( SX_INDEXCOUNT )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   int iCount = 0;

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmResult = hb_itemNew( NULL );
      SELF_ORDINFO( pArea, DBOI_BAGCOUNT, &Info );
      iCount = hb_itemGetNI( Info.itmResult );
      hb_itemRelease( Info.itmResult );
   }

   hb_retni( iCount );
}
sxord.c418
HB_FUNCSX_INDEXNAME(void)
HB_FUNC( SX_INDEXNAME )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         SELF_ORDINFO( pArea, DBOI_FULLPATH, &Info );
         hb_itemReturnRelease( Info.itmResult );
      }
      else
         hb_retc( NULL );
   }
}
sxord.c436
HB_FUNCSX_INDEXTYPE(void)
HB_FUNC( SX_INDEXTYPE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   int iType = DBOI_TYPE_UNDEF;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         if( hb_pcount() == 1 && ISCHAR( 1 ) )
         {
            Info.atomBagName = Info.itmOrder;
            Info.itmOrder = NULL;
         }
         Info.itmResult = hb_itemNew( NULL );
         if( SELF_ORDINFO( pArea, DBOI_INDEXTYPE, &Info ) == SUCCESS )
            iType = hb_itemGetNI( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }
   hb_retni( iType );
}
sxord.c454
HB_FUNCSX_DESCEND(void)
HB_FUNC( SX_DESCEND )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         if( SELF_ORDINFO( pArea, DBOI_ISDESC, &Info ) == SUCCESS )
         {
            Info.itmNewVal = hb_itemPutL( NULL, !hb_itemGetL( Info.itmResult ) );
            SELF_ORDINFO( pArea, DBOI_ISDESC, &Info );
            hb_itemRelease( Info.itmNewVal );
         }
         hb_itemRelease( Info.itmResult );
      }
   }
}
sxord.c478
HB_FUNCSX_KEYADD(void)
HB_FUNC( SX_KEYADD )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemPutL( NULL, FALSE );
         Info.itmNewVal = hb_param( 3 , HB_IT_ANY );
         SELF_ORDINFO( pArea, DBOI_KEYADD, &Info );
         fResult = hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }
   hb_retl( fResult );
}
sxord.c499
HB_FUNCSX_KEYDROP(void)
HB_FUNC( SX_KEYDROP )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemPutL( NULL, FALSE );
         Info.itmNewVal = hb_param( 3 , HB_IT_ANY );
         SELF_ORDINFO( pArea, DBOI_KEYDELETE, &Info );
         fResult = hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }
   hb_retl( fResult );
}
sxord.c519
HB_FUNCSX_KEYDATA(void)
HB_FUNC( SX_KEYDATA )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         SELF_ORDINFO( pArea, DBOI_KEYVAL, &Info );
         hb_itemReturnRelease( Info.itmResult );
      }
   }
}
sxord.c539
HB_FUNCSX_KEYSKIP(void)
HB_FUNC( SX_KEYSKIP )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE, fBEof = FALSE;

   if( pArea )
   {
      if( SELF_SKIPRAW( pArea, ISNUM( 1 ) ? hb_parnl( 1 ) : 1 ) == SUCCESS )
      {
         if( SELF_EOF( pArea, &fBEof ) == SUCCESS && !fBEof )
            fResult = SELF_BOF( pArea, &fBEof ) == SUCCESS && !fBEof;
      }
   }
   hb_retl( fResult );
}
sxord.c555
HB_FUNCSX_KEYCOUNT(void)
HB_FUNC( SX_KEYCOUNT )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   ULONG ulKeys = 0;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         SELF_ORDINFO( pArea, DBOI_KEYCOUNT, &Info );
         ulKeys = hb_itemGetNL( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }

   hb_retnint( ulKeys );
}
sxord.c571
HB_FUNCSX_KEYNO(void)
HB_FUNC( SX_KEYNO )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   ULONG ulKeyNo = 0;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         SELF_ORDINFO( pArea, DBOI_POSITION, &Info );
         ulKeyNo = hb_itemGetNL( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }

   hb_retnint( ulKeyNo );
}
sxord.c591
HB_FUNCSX_KEYGOTO(void)
HB_FUNC( SX_KEYGOTO )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE;

   if( pArea && hb_parnl( 3 ) != 0 )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmNewVal = hb_param( 3 , HB_IT_NUMERIC );
         Info.itmResult = hb_itemNew( NULL );
         SELF_ORDINFO( pArea, DBOI_POSITION, &Info );
         fResult = hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }

   hb_retl( fResult );
}
sxord.c611
HB_FUNCSX_SKIPUNIQUE(void)
HB_FUNC( SX_SKIPUNIQUE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmNewVal = hb_param( 1, HB_IT_ANY );
      Info.itmResult = hb_itemNew( NULL );
      SELF_ORDINFO( pArea, DBOI_SKIPUNIQUE, &Info );
      hb_itemRelease( Info.itmResult );
   }
}
sxord.c632
HB_FUNCSX_SEEKLAST(void)
HB_FUNC( SX_SEEKLAST )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fFound = FALSE;

   if( pArea && hb_pcount() > 0 )
   {
      PHB_ITEM pKey = hb_param( 1, HB_IT_ANY );
      BOOL bSoftSeek = ISLOG( 2 ) && hb_parl( 2 );

      if( SELF_SEEK( pArea, bSoftSeek, pKey, TRUE ) == SUCCESS )
      {
         if( SELF_FOUND( pArea, &fFound ) != SUCCESS )
            fFound = FALSE;
      }
   }
   hb_retl( fFound );
}
sxord.c647
HB_FUNCSX_TAGUNIQUE(void)
HB_FUNC( SX_TAGUNIQUE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemPutL( NULL, FALSE );
         SELF_ORDINFO( pArea, DBOI_UNIQUE, &Info );
         hb_itemReturnRelease( Info.itmResult );
      }
   }
}
sxord.c666
HB_FUNCSX_WILDSEEK(void)
HB_FUNC( SX_WILDSEEK )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   char * szPattern = hb_parc( 1 );
   BOOL fCont = ISLOG( 2 ) && hb_parl( 2 );
   BOOL fFound = FALSE;
   int iOrder = 0;

   if( pArea )
   {
      DBORDERINFO Info;
      memset( &Info, 0, sizeof( DBORDERINFO ) );
      Info.itmResult = hb_itemNew( NULL );

      if( szPattern && szPattern[0] )
      {
         if( SELF_ORDINFO( pArea, DBOI_NUMBER, &Info ) == SUCCESS )
            iOrder = hb_itemGetNI( Info.itmResult );
      }
      if( iOrder > 0 )
      {
         ERRCODE errCode = SUCCESS;
         if( !fCont )
         {
            errCode = SELF_GOTOP( pArea );
            if( errCode == SUCCESS )
            {
               errCode = SELF_ORDINFO( pArea, DBOI_KEYVAL, &Info );
               if( errCode == SUCCESS )
               {
                  char * szKey = hb_itemGetCPtr( Info.itmResult );
                  fFound = hb_strMatchWild( szKey, szPattern );
               }
            }
         }
         if( !fFound && errCode == SUCCESS )
         {
            Info.itmNewVal = hb_param( 1, HB_IT_STRING );
            if( SELF_ORDINFO( pArea, DBOI_SKIPWILD, &Info ) == SUCCESS )
               fFound = HB_IS_LOGICAL( Info.itmResult ) &&
                        hb_itemGetL( Info.itmResult );
         }
      }
      else
         SELF_GOTO( pArea, 0 );
      hb_itemReturnRelease( Info.itmResult );
   }

   hb_retl( fFound );
}
sxord.c682
HB_FUNCSX_ROXLOCK(void)
HB_FUNC( SX_ROXLOCK )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fLocked = FALSE;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmNewVal = hb_itemPutL( NULL, TRUE );
         Info.itmResult = hb_itemPutL( NULL, FALSE );
         if( SELF_ORDINFO( pArea, DBOI_READLOCK, &Info ) == SUCCESS )
            fLocked = hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmNewVal );
         hb_itemRelease( Info.itmResult );
      }
   }
   hb_retl( fLocked );
}
sxord.c733
HB_FUNCSX_ROXUNLOCK(void)
HB_FUNC( SX_ROXUNLOCK )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmNewVal = hb_itemPutL( NULL, FALSE );
         Info.itmResult = hb_itemPutL( NULL, FALSE );
         SELF_ORDINFO( pArea, DBOI_READLOCK, &Info );
         hb_itemRelease( Info.itmNewVal );
         hb_itemRelease( Info.itmResult );
      }
   }
}
sxord.c754
HB_FUNCSX_ISMYROX(void)
HB_FUNC( SX_ISMYROX )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fLocked = FALSE;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         if( SELF_ORDINFO( pArea, DBOI_READLOCK, &Info ) == SUCCESS )
            fLocked = hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }
   hb_retl( fLocked );
}
sxord.c772
HB_FUNCSX_ISROXLOCK(void)
HB_FUNC( SX_ISROXLOCK )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fLocked = FALSE;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         if( SELF_ORDINFO( pArea, DBOI_READLOCK, &Info ) == SUCCESS )
            fLocked = hb_itemGetL( Info.itmResult );
         if( !fLocked )
         {
            Info.itmNewVal = hb_itemPutL( NULL, TRUE );
            if( SELF_ORDINFO( pArea, DBOI_READLOCK, &Info ) == SUCCESS )
               fLocked = hb_itemGetL( Info.itmResult );
            if( fLocked )
            {
               hb_itemPutL( Info.itmNewVal, FALSE );
               SELF_ORDINFO( pArea, DBOI_READLOCK, &Info );
            }
            hb_itemRelease( Info.itmNewVal );
         }
         hb_itemRelease( Info.itmResult );
      }
   }
   hb_retl( fLocked );
}
sxord.c791
HB_FUNCSX_SORTOPTION(void)
HB_FUNC( SX_SORTOPTION )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fUseCurrent = TRUE;

   if( pArea )
   {
      DBORDERINFO Info;
      if( hb_sxOrdParam( &Info ) )
      {
         Info.itmResult = hb_itemNew( NULL );
         Info.itmNewVal = hb_param( 1, HB_IT_LOGICAL );
         if( SELF_ORDINFO( pArea, DBOI_USECURRENT, &Info ) == SUCCESS )
            fUseCurrent = hb_itemGetL( Info.itmResult );
         hb_itemRelease( Info.itmResult );
      }
   }
   hb_retl( fUseCurrent );
}
sxord.c822
sxredir.c
TypeFunctionSourceLine
HB_FUNCSX_FINDREC(void)
HB_FUNC( SX_FINDREC )
{
   HB_FUNC_EXEC( ORDFINDREC );
}


HB_FUNC_EXTERN( ORDBAGCLEAR );
sxredir.c60
HB_FUNCSX_CLEARORDER(void)
HB_FUNC( SX_CLEARORDER )
{
   HB_FUNC_EXEC( ORDBAGCLEAR );
}


HB_FUNC_EXTERN( SX_SETTRIGGER );
sxredir.c68
HB_FUNCSX_SETTRIG(void)
HB_FUNC( SX_SETTRIG )
{
   HB_FUNC_EXEC( SX_SETTRIGGER );
}
sxredir.c76
sxsem.c
TypeFunctionSourceLine
STATIC BOOLhb_sxSemName( char * szFileName )
static BOOL hb_sxSemName( char * szFileName )
{
   char * szName = hb_parc( 1 );
   BOOL fResult = FALSE;

   if( szName && szName[0] )
   {
      hb_strncpy( szFileName, szName, _POSIX_PATH_MAX );
      hb_strLower( szFileName, strlen( szFileName ) );
      fResult = TRUE;
   }
   else
   {
      AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
      if( pArea )
      {
         DBORDERINFO pOrderInfo;

         memset( &pOrderInfo, 0, sizeof( DBORDERINFO ) );
         pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC );
         if( pOrderInfo.itmOrder && hb_itemGetNI( pOrderInfo.itmOrder ) == 0 )
            pOrderInfo.itmOrder = NULL;
         pOrderInfo.itmResult = hb_itemPutC( NULL, NULL );
         SELF_ORDINFO( pArea, DBOI_NAME, &pOrderInfo );
         szName = hb_itemGetCPtr( pOrderInfo.itmResult );
         if( szName && szName[0] )
         {
            hb_strncpy( szFileName, szName, _POSIX_PATH_MAX );
            hb_strLower( szFileName, strlen( szFileName ) );
            fResult = TRUE;
         }
         hb_itemRelease( pOrderInfo.itmResult );
      }
   }

   return fResult;
}
sxsem.c62
STATIC HB_FHANDLEhb_sxSemOpen( BYTE * szFileName, BOOL * pfNewFile )
static HB_FHANDLE hb_sxSemOpen( BYTE * szFileName, BOOL * pfNewFile )
{
   HB_FHANDLE hFile;
   int i = 0;

   do
   {
      hFile = hb_fsExtOpen( szFileName, ( BYTE * ) ".sem",
                            FO_READWRITE | FO_EXCLUSIVE | FXO_DEFAULTS |
                            FXO_SHARELOCK | FXO_COPYNAME, NULL, NULL );
      if( hFile != FS_ERROR )
         break;

      if( pfNewFile )
      {
         hFile = hb_fsExtOpen( szFileName, ( BYTE * ) ".sem", FXO_UNIQUE |
                               FO_READWRITE | FO_EXCLUSIVE | FXO_DEFAULTS |
                               FXO_SHARELOCK | FXO_COPYNAME, NULL, NULL );
         if( hFile != FS_ERROR )
         {
            *pfNewFile = TRUE;
            break;
         }
      }
      else
      {
         USHORT uiError = hb_fsError();
         if( uiError != 5 && uiError != 32 && uiError != 33 )
            break;
      }

      hb_idleSleep( 0.01 );
   }
   while( ++i < 25 );

   return hFile;
}
sxsem.c100
HB_FUNCSX_MAKESEM(void)
HB_FUNC( SX_MAKESEM )
{
   BYTE szFileName[_POSIX_PATH_MAX + 1], buffer[2];
   int iUsers = -1;
   BOOL fError = FALSE, fNewFile = FALSE;

   if( hb_sxSemName( ( char * ) szFileName ) )
   {
      HB_FHANDLE hFile = hb_sxSemOpen( szFileName, &fNewFile );
      if( hFile != FS_ERROR )
      {
         if( fNewFile )
            iUsers = 1;
         else
         {
            hb_fsSeek( hFile, 0, FS_SET );
            if( hb_fsRead( hFile, buffer, 2 ) != 2 )
               fError = TRUE;
            else
               iUsers = HB_GET_LE_INT16( buffer ) + 1;
         }
         if( ! fError )
         {
            HB_PUT_LE_UINT16( buffer, iUsers );
            hb_fsSeek( hFile, 0, FS_SET );
            if( hb_fsWrite( hFile, buffer, 2 ) != 2 )
               fError = TRUE;
         }
         hb_fsClose( hFile );
      }
   }
   if( fError )
      iUsers = -1;
   hb_retni( iUsers );
}
sxsem.c139
HB_FUNCSX_KILLSEM(void)
HB_FUNC( SX_KILLSEM )
{
   BYTE szFileName[_POSIX_PATH_MAX + 1], buffer[2];
   int iUsers = -1;

   if( hb_sxSemName( ( char * ) szFileName ) )
   {
      HB_FHANDLE hFile = hb_sxSemOpen( szFileName, NULL );
      if( hFile != FS_ERROR )
      {
         if( hb_fsRead( hFile, buffer, 2 ) == 2 )
         {
            iUsers = HB_GET_LE_INT16( buffer ) - 1;
            hb_fsSeek( hFile, 0, FS_SET );
            HB_PUT_LE_UINT16( buffer, iUsers );
            hb_fsWrite( hFile, buffer, 2 );
         }
         hb_fsClose( hFile );
         if( iUsers == 0 )
            hb_fsDelete( szFileName );
      }
   }
   hb_retni( iUsers );
}
sxsem.c176
HB_FUNCSX_ISSEM(void)
HB_FUNC( SX_ISSEM )
{
   BYTE szFileName[_POSIX_PATH_MAX + 1];
   HB_FHANDLE hFile = FS_ERROR;

   if( hb_sxSemName( ( char * ) szFileName ) )
   {
      hFile = hb_sxSemOpen( szFileName, NULL );
      if( hFile != FS_ERROR )
         hb_fsClose( hFile );
   }

   hb_retl( hFile != FS_ERROR );
}
sxsem.c202
sxtable.c
TypeFunctionSourceLine
HB_FUNCSX_GETLOCKS(void)
HB_FUNC( SX_GETLOCKS )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      PHB_ITEM pList = hb_itemArrayNew( 0 );
      SELF_INFO( pArea, DBI_GETLOCKARRAY, pList );
      hb_itemReturnRelease( pList );
   }
}
sxtable.c77
HB_FUNCSX_ISFLOCKED(void)
HB_FUNC( SX_ISFLOCKED )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fLocked = FALSE;

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemNew( NULL );
      SELF_INFO( pArea, DBI_ISFLOCK, pItem );
      fLocked = hb_itemGetL( pItem );
      hb_itemRelease( pItem );
   }

   hb_retl( fLocked );
}
sxtable.c89
HB_FUNCSX_ISREADONLY(void)
HB_FUNC( SX_ISREADONLY )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fReadOnly = FALSE;

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemNew( NULL );
      SELF_INFO( pArea, DBI_ISREADONLY, pItem );
      fReadOnly = hb_itemGetL( pItem );
      hb_itemRelease( pItem );
   }

   hb_retl( fReadOnly );
}
sxtable.c105
HB_FUNCSX_ISSHARED(void)
HB_FUNC( SX_ISSHARED )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fShared = FALSE;

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemNew( NULL );
      SELF_INFO( pArea, DBI_SHARED, pItem );
      fShared = hb_itemGetL( pItem );
      hb_itemRelease( pItem );
   }

   hb_retl( fShared );
}
sxtable.c121
HB_FUNCSX_IDTYPE(void)
HB_FUNC( SX_IDTYPE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   int iType = 0;

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemNew( NULL );
      if( SELF_RECINFO( pArea, NULL, DBRI_ENCRYPTED, pItem ) == SUCCESS )
         iType = hb_itemGetL( pItem ) ? 2 : 1;
      hb_itemRelease( pItem );
   }

   hb_retni( iType );
}
sxtable.c137
HB_FUNCSX_TABLETYPE(void)
HB_FUNC( SX_TABLETYPE )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   int iType = 0;

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemNew( NULL );
      if( SELF_INFO( pArea, DBI_ISENCRYPTED, pItem ) == SUCCESS )
         iType = hb_itemGetL( pItem ) ? 2 : 1;
      hb_itemRelease( pItem );
   }

   hb_retni( iType );
}
sxtable.c153
HB_FUNCSX_TABLENAME(void)
HB_FUNC( SX_TABLENAME )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      PHB_ITEM pList = hb_itemNew( NULL );
      SELF_INFO( pArea, DBI_FULLPATH, pList );
      hb_itemReturnRelease( pList );
   }
   else
      hb_retc( NULL );
}
sxtable.c169
STATIC VOIDhb_sxRollBackChild( AREAP pArea, PHB_ITEM pItem )
static void hb_sxRollBackChild( AREAP pArea, PHB_ITEM pItem )
{
   LPDBRELINFO lpdbRelation = pArea->lpdbRelations;

   while( lpdbRelation )
   {
      if( SELF_INFO( lpdbRelation->lpaChild, DBI_ROLLBACK, pItem ) != SUCCESS )
         break;
      hb_sxRollBackChild( lpdbRelation->lpaChild, pItem );
      lpdbRelation = lpdbRelation->lpdbriNext;
   }
}
sxtable.c183
HB_FUNCSX_ROLLBACK(void)
HB_FUNC( SX_ROLLBACK )
{
   BOOL fResult = FALSE, fRollChild = FALSE;
   int iArea = 0;
   AREAP pArea;

   if( ISNUM( 1 ) )
   {
      iArea = hb_parni( 1 );
      fRollChild = iArea == 0;
   }

   if( iArea )
      pArea = ( AREAP ) hb_rddGetWorkAreaPointer( iArea );
   else
      pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemNew( NULL );
      fResult = SELF_INFO( pArea, DBI_ROLLBACK, pItem ) == SUCCESS;
      if( fResult && fRollChild )
         hb_sxRollBackChild( pArea, pItem );
      hb_itemRelease( pItem );
   }

   hb_retl( fResult );
}
sxtable.c196
HB_FUNCSX_RLOCK(void)
HB_FUNC( SX_RLOCK )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE;
   PHB_ITEM pResult = NULL, pRecords;

   if( pArea )
   {
      DBLOCKINFO dbLockInfo;
      dbLockInfo.fResult = FALSE;
      dbLockInfo.uiMethod = DBLM_MULTIPLE;
      pRecords = hb_param( 1, HB_IT_ARRAY );
      if( pRecords )
      {
         ULONG ul, ulLen = hb_arrayLen( pRecords );
         pResult = hb_itemArrayNew( ulLen );
         for( ul = 1; ul <= ulLen; ++ul )
         {
            dbLockInfo.itmRecID = hb_arrayGetItemPtr( pRecords, ul );
            SELF_LOCK( pArea, &dbLockInfo );
            hb_arraySetL( pResult, ul, dbLockInfo.fResult );
         }
      }
      else
      {
         dbLockInfo.itmRecID = hb_param( 1, HB_IT_ANY );
         SELF_LOCK( pArea, &dbLockInfo );
         fResult = dbLockInfo.fResult;
      }
   }

   if( pResult )
      hb_itemReturnRelease( pResult );
   else
      hb_retl( fResult );
}
sxtable.c225
HB_FUNCSX_UNLOCK(void)
HB_FUNC( SX_UNLOCK )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      PHB_ITEM pRecords = hb_param( 1, HB_IT_ARRAY );
      if( pRecords )
      {
         ULONG ul, ulLen = hb_arrayLen( pRecords );
         for( ul = 1; ul <= ulLen; ++ul )
         {
            SELF_UNLOCK( pArea, hb_arrayGetItemPtr( pRecords, ul ) );
         }
      }
      else
      {
         SELF_UNLOCK( pArea, hb_param( 1, HB_IT_ANY ) );
      }
   }
}
sxtable.c262
HB_FUNCSX_SETPASS(void)
HB_FUNC( SX_SETPASS )
{
   int iPCount = hb_pcount();
   BOOL fResult = FALSE;
   PHB_ITEM pItem;

   if( iPCount >=1 )
   {
      if( ISCHAR( 1 ) )
      {
         AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
         if( pArea )
         {
            pItem = hb_itemParam( 1 );
            if( SELF_INFO( pArea, DBI_PASSWORD, pItem ) == SUCCESS )
               fResult = TRUE;
            hb_itemRelease( pItem );
         }
      }
   }
   else if( iPCount >= 2 || iPCount <= 4 )
   {
      if( ISCHAR( 1 ) && ISNUM( 2 ) && ( iPCount < 3 || ISCHAR( 3 ) ) &&
          ( iPCount < 4 || ISNUM( 4 ) ) )
      {
         /* Set pending password for table which will be open
          * 3-rd and 4-th parameters are optional Harbour extensions
          * with RDD name and connection number.
          */
         LPRDDNODE  pRDDNode;
         USHORT     uiRddID;
         const char * szDriver;

         if( iPCount == 2 ) /* no RDD parameter, use default */
            szDriver = hb_rddDefaultDrv( NULL );
         else
            szDriver = hb_parc( 3 );
         pRDDNode = hb_rddFindNode( szDriver, &uiRddID );   /* find the RDDNODE */
         if( pRDDNode )
         {
            pItem = hb_itemParam( 1 );
            if( SELF_RDDINFO( pRDDNode, RDDI_PENDINGPASSWORD, hb_parnl( 4 ), pItem ) == SUCCESS )
               fResult = TRUE;
            hb_itemRelease( pItem );
         }
      }
      else if( iPCount == 2 && ISNUM( 1 ) && ISCHAR( 2 ) )
      {
         AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
         if( pArea )
         {
            /* Undocumented SIX3 extension */
            switch( hb_parni( 1 ) )
            {
               case 1:  /* return current password key in raw form */
                  pItem = hb_itemNew( NULL );
                  if( SELF_INFO( pArea, DBI_PASSWORD, pItem ) == SUCCESS )
                     hb_itemReturn( pItem );
                  hb_itemRelease( pItem );
                  break;
               case 2:  /* set raw password key */
                  /* not implemented */
                  break;
               case 3:  /* mark table as encrypted */
                  /* intentionally not implemented */
                  break;
               case 4:  /* mark table as decrypted */
                  /* intentionally not implemented */
                  break;
            }
            return;
         }
      }
   }

   hb_retl( fResult );
}
sxtable.c284
HB_FUNCSX_DBFENCRYPT(void)
HB_FUNC( SX_DBFENCRYPT )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE;

   if( pArea )
   {
      /* Optional parameter with password is Harbour extension */
#ifdef HB_SIX3_STRICT
      PHB_ITEM pItem = hb_itemNew( NULL );
#else
      PHB_ITEM pItem = hb_itemParam( 1 );
#endif
      if( SELF_INFO( pArea, DBI_ENCRYPT, pItem ) == SUCCESS )
         fResult = hb_itemGetL( pItem );
      hb_itemRelease( pItem );
   }
   hb_retl( fResult );
}
sxtable.c362
HB_FUNCSX_DBFDECRYPT(void)
HB_FUNC( SX_DBFDECRYPT )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE;

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemParam( 1 );
      if( SELF_INFO( pArea, DBI_DECRYPT, pItem ) == SUCCESS )
         fResult = hb_itemGetL( pItem );
      hb_itemRelease( pItem );
   }
   hb_retl( fResult );
}
sxtable.c382
HB_FUNCSX_MEMOPACK(void)
HB_FUNC( SX_MEMOPACK )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
   BOOL fResult = FALSE;

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemArrayNew( 3 );
      int i, iPCount = hb_pcount();
      for( i = 1; i <= iPCount; ++i )
         hb_arraySet( pItem, i, hb_param( i, HB_IT_ANY ) );
      fResult = SELF_INFO( pArea, DBI_MEMOPACK, pItem ) == SUCCESS;
      hb_itemRelease( pItem );
   }
   hb_retl( fResult );
}
sxtable.c397
HB_FUNCSX_TURBOAREA(void)
HB_FUNC( SX_TURBOAREA )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      PHB_ITEM pItem = hb_itemParam( 1 );
      if( hb_pcount() > 0 && HB_IS_NIL( pItem ) )
         hb_itemPutNI( pItem, 0 );
      if( SELF_INFO( pArea, DBI_DIRTYREAD, pItem ) != SUCCESS )
         hb_itemPutL( pItem, FALSE );
      hb_itemReturnRelease( pItem );
   }
   else
      hb_retl( FALSE );
}
sxtable.c414
HB_FUNCSX_SETTURBO(void)
HB_FUNC( SX_SETTURBO )
{
   LPRDDNODE  pRDDNode;
   USHORT     uiRddID;
   const char * szDriver;

   szDriver = hb_parc( 2 );
   if( !szDriver ) /* no VIA RDD parameter, use default */
      szDriver = hb_rddDefaultDrv( NULL );

   pRDDNode = hb_rddFindNode( szDriver, &uiRddID );  /* find the RDDNODE */
   if( !pRDDNode )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME,
                            HB_ERR_ARGS_BASEPARAMS );
   else
   {
      PHB_ITEM pItem = hb_itemParam( 1 );
      if( hb_pcount() > 0 && HB_IS_NIL( pItem ) )
         hb_itemPutNI( pItem, 0 );
      if( SELF_RDDINFO( pRDDNode, RDDI_DIRTYREAD, 0, pItem ) != SUCCESS )
         hb_itemPutL( pItem, FALSE );
      hb_itemReturnRelease( pItem );
   }
}
sxtable.c431
HB_FUNC_SXOPENINIT(void)
HB_FUNC( _SXOPENINIT )
{
   AREAP pArea = NULL;
   int iArea = hb_parni( 1 );

   if( iArea )
      pArea = ( AREAP ) hb_rddGetWorkAreaPointer( iArea );

   if( pArea )
   {
      LPDBOPENINFO pInfo = NULL;
      PHB_ITEM pItem = hb_itemNew( NULL );

      if( SELF_INFO( pArea, DBI_OPENINFO, pItem ) )
         pInfo = ( LPDBOPENINFO ) hb_itemGetPtr( pItem );
      hb_itemRelease( pItem );
      if( pInfo )
      {
         if( ISLOG( 2 ) )
            pInfo->fShared = hb_parl( 2 );
         if( ISLOG( 3 ) )
            pInfo->fReadonly = hb_parl( 2 );
         if( ISCHAR( 4 ) )
         {
            char * szAlias = hb_parc( 1 );
            if( szAlias && szAlias[ 0 ] )
               pInfo->atomAlias = ( BYTE * ) hb_dynsymName( hb_dynsymGet( szAlias ) );
            else
               pInfo->atomAlias = ( BYTE * ) "";
         }
      }
   }
}
sxtable.c456
sxutil.c
TypeFunctionSourceLine
HB_FUNCSX_SLIMFAST(void)
HB_FUNC( SX_SLIMFAST )
{
   char * szExp = hb_parc( 1 );

   if( szExp && *szExp )
   {
      char * szExp = hb_parc( 1 ), * szDst;
      char cQuote = 0, c;
      ULONG ulDst;

      szDst = ( char * ) hb_xgrab( hb_parclen( 1 ) + 1 );
      ulDst = 0;

      while( ( c = *szExp++ ) != 0 )
      {
         if( c == cQuote )
            cQuote = 0;
         else if( c == '"' || c == '\'' )
            cQuote = c;
         else if( !cQuote )
         {
            if( c == ' ' && ulDst && szDst[ulDst - 1] == ' ' )
               continue;
            c = ( char ) hb_charUpper( ( UCHAR ) c );
         }
         szDst[ulDst++] = c;
      }

      hb_retclen_buffer( szDst, ulDst );
   }
   else
      hb_retc( NULL );
}
sxutil.c59
HB_FUNCSX_WILDMATCH(void)
HB_FUNC( SX_WILDMATCH )
{
   char * szPattern = hb_parc( 1 ), * szValue = hb_parc( 2 );
   BOOL fMatch = FALSE;

   if( szPattern && szPattern[0] && szValue )
      fMatch = hb_strMatchWild( szValue, szPattern );

   hb_retl( fMatch );
}
sxutil.c93
HB_FUNCSX_VERSION(void)
HB_FUNC( SX_VERSION )
{
   switch( hb_parni( 1 ) )
   {
      case 1:
         hb_retds( HB_SX_DAY );
         break;
      case 2:
         hb_retc( HB_SX_TIME );
         break;
      case 3:
         hb_retc( HB_SX_FULL );
         break;
      default:
         hb_retc( HB_SX_VER );
         break;
   }
}
sxutil.c109
HB_FUNCSX_ERROR(void)
HB_FUNC( SX_ERROR )
{
   /* not use by Harbour */
   hb_retni( 0 );
}
sxutil.c128
sxcompat.prg
TypeFunctionSourceLine
FUNCTIONsxChar( nLen, xKeyVal )
function sxChar( nLen, xKeyVal )

   switch valType( xKeyVal )
      case "C"
      case "M"
         exit
      case "N"
         xKeyVal := str( xKeyVal )
         exit
      case "D"
         xKeyVal := dtos( xKeyVal )
         exit
      case "L"
         xKeyVal := iif( xKeyVal, "T", "F" )
         exit
      otherwise
         xKeyVal := iif( valType( nLen ) == "N", "", space( 10 ) )
         exit
   endswitch

return iif( valType( nLen ) == "N", padr( ltrim( xKeyVal ), nLen ), xKeyVal )
sxcompat.prg89
FUNCTIONsxNum( xKeyVal )
function sxNum( xKeyVal )

   switch valType( xKeyVal )
      case "N"
         exit
      case "C"
      case "M"
         xKeyVal := val( xKeyVal )
         exit
      case "D"
         xKeyVal := xKeyVal - ctod( "" )
         exit
      case "L"
         xKeyVal := iif( xKeyVal, 1, 0 )
         exit
      otherwise
         xKeyVal := 0.00
         exit
   endswitch

return xKeyVal
sxcompat.prg111
FUNCTIONsxDate( xKeyVal )
function sxDate( xKeyVal )

   switch valType( xKeyVal )
      case "D"
         exit
      case "C"
      case "M"
         xKeyVal := ctod( xKeyVal )
         exit
      case "N"
         xKeyVal := ctod( "" ) + xKeyVal
         exit
      otherwise
         xKeyVal := ctod( "" )
         exit
   endswitch

return xKeyVal
sxcompat.prg134
FUNCTIONsxLog( xKeyVal )
function sxLog( xKeyVal )

   switch valType( xKeyVal )
      case "L"
         exit
      case "C"
      case "M"
         switch xKeyVal
            case  "T";  case  "t";  case  "Y";  case  "y"
            case ".T."; case ".t."; case ".Y."; case ".y."
               xKeyVal := .t.
               exit
            otherwise
               xKeyVal := .f.
               exit
         endswitch
         exit
      case "N"
         xKeyVal := xKeyVal != 0
         exit
      otherwise
         xKeyVal := .f.
         exit
   endswitch

return xKeyVal
sxcompat.prg153
FUNCTIONSx_Compress( xVal )
function Sx_Compress( xVal )
   local cType := valType( xVal ), xRetVal
   if cType $ "CM"
      xRetVal := _sx_strCompress( xVal )
   elseif cType == "A"
      xRetVal := array( len( xVal ) )
      aEval( xVal, { |x| xRetVal := Sx_Compress( x ) } )
   else
      xRetVal := xVal
   endif
return xRetVal
sxcompat.prg180
FUNCTIONSx_Decompress( xVal )
function Sx_Decompress( xVal )
   local cType := valType( xVal ), xRetVal
   if cType $ "CM"
      xRetVal := _sx_strDecompress( xVal )
   elseif cType == "A"
      xRetVal := array( len( xVal ) )
      aEval( xVal, { |x| xRetVal := Sx_Decompress( x ) } )
   else
      xRetVal := xVal
   endif
return xRetVal
sxcompat.prg192
FUNCTIONSx_TagInfo( cIndex )
function Sx_TagInfo( cIndex )
   local aInfo, nOrds, nFirst, i

   if Used() && ( nOrds := OrdCount( cIndex ) ) > 0
      aInfo := array( nOrds, 6 )
      if valType( cIndex ) == "C"
         nFirst := dbOrderInfo( DBOI_BAGORDER, cIndex )
         nOrds += nFirst - 1
      else
         nFirst := 1
      endif
      for i := nFirst to nOrds
         aInfo[ i, 1 ] := ordName( i )
         aInfo[ i, 2 ] := ordKey( i )
         aInfo[ i, 3 ] := ordFor( i )
         aInfo[ i, 4 ] := ordIsUnique( i )
         aInfo[ i, 5 ] := ordDescend( i )
         aInfo[ i, 6 ] := ordCustom( i )
      next
   else
      aInfo := {}
   endif
return aInfo
sxcompat.prg204
FUNCTIONSx_TagCount( xIndex )
function Sx_TagCount( xIndex )
   local nTags := 0, cIndex, nOrder
   if Used()
      if valtype( xIndex ) == "N"
         nOrder := Sx_TagOrder( 1, xIndex )
         if nOrder != 0
            cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )
         endif
      elseif valtype( xIndex ) == "C" .and. !Empty( xIndex )
         cIndex := xIndex
      else
         cIndex := dbOrderInfo( DBOI_FULLPATH )
      endif
      if !Empty( cIndex )
         nTags := ordCount( cIndex )
      endif
   endif
return nTags
sxcompat.prg228
FUNCTIONSx_Tags( xIndex )
function Sx_Tags( xIndex )
   local aTagNames := {}, nOrder, nTags
   if Used()
      if valtype( xIndex ) == "N"
         nOrder := Sx_TagOrder( 1, xIndex )
      elseif valtype( xIndex ) == "C" .and. !Empty( xIndex )
         nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex )
      else
         nOrder := OrdNumber()
      endif
      if nOrder != 0
         nTags := ordCount( dbOrderInfo( DBOI_FULLPATH,, nOrder ) )
         while --nTags >= 0
            aadd( aTagNames, ordName( nOrder++ ) )
         enddo
      endif
   endif
return aTagNames
sxcompat.prg247
FUNCTIONSx_SetTag( xTag, xIndex )
function Sx_SetTag( xTag, xIndex )
   local lRet := .f., nOrder := 0, nOldOrd, cIndex
   if Used() .and. valtype( xTag ) $ "CN"
      if valtype( xTag ) == "N"
         if empty( xIndex ) .or. !valtype( xIndex ) $ "CN"
            nOrder := xTag
         elseif valtype( xIndex ) == "C"
            if xTag >= 1 .and. xTag <= ordCount( xIndex )
               nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex ) + xTag - 1
            endif
         else
            nOrder := Sx_TagOrder( xTag, xIndex )
         endif
      else
         if empty( xIndex ) .or. !valtype( xIndex ) $ "CN"
            nOrder := OrdNumber( xTag )
         elseif valtype( xIndex ) == "C"
            nOrder := Sx_TagOrder( xTag, xIndex )
         else
            nOrder := Sx_TagOrder( 1, xIndex )
            if nOrder != 0
               cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )
               if empty( cIndex )
                  nOrder := 0
               else
                  nOrder := Sx_TagOrder( xTag, cIndex )
               endif
            endif
         endif
      endif
      if nOrder != 0
         nOldOrd := OrdNumber()
         OrdSetFocus( nOrder )
         lRet := nOrder == OrdSetFocus()
         if ! lRet
            OrdSetFocus( nOldOrd )
         endif
      elseif empty( xTag )
         OrdSetFocus( 0 )
         lRet := .t.
      endif
   endif
return lRet
sxcompat.prg266
FUNCTIONSx_KillTag( xTag, xIndex )
function Sx_KillTag( xTag, xIndex )
   local lRet := .f., nOrder, cIndex
   if valtype( xTag ) == "L"
      if xTag
         if empty( xIndex )
            cIndex := Sx_IndexName()
         elseif valtype( xIndex ) == "N"
            cIndex := Sx_IndexName( 1, xIndex )
         elseif valtype( xIndex ) == "C"
            nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex )
            if nOrder != 0
               cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )
            endif
         endif
         if !empty( cIndex )
            if ordBagClear( cIndex )
               lRet := ferase( cIndex ) != -1
            endif
         endif
      endif
   else
      if valtype( xTag ) == "N"
         if empty( xIndex ) .or. !valtype( xIndex ) $ "CN"
            nOrder := xTag
         elseif valtype( xIndex ) == "C"
            if xTag >= 1 .and. xTag <= ordCount( xIndex )
               nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex ) + xTag - 1
            else
               nOrder := 0
            endif
         else
            nOrder := Sx_TagOrder( xTag, xIndex )
         endif
      else
         if empty( xIndex ) .or. !valtype( xIndex ) $ "CN"
            nOrder := OrdNumber( xTag )
         elseif valtype( xIndex ) == "C"
            nOrder := Sx_TagOrder( xTag, xIndex )
         else
            nOrder := Sx_TagOrder( 1, xIndex )
            if nOrder != 0
               cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )
               if empty( cIndex )
                  nOrder := 0
               else
                  nOrder := Sx_TagOrder( xTag, cIndex )
               endif
            endif
         endif
      endif
      if nOrder != 0
         lRet := ordDestroy( nOrder )
      endif
   endif
return lRet
sxcompat.prg310
FUNCTIONSx_FileOrder()
function Sx_FileOrder()
return dbOrderInfo( DBOI_BAGNUMBER )
sxcompat.prg366
FUNCTIONSx_SetFileOrd( nIndex )
function Sx_SetFileOrd( nIndex )
return iif( valtype( nIndex ) == "N", ;
            OrdSetFocus( Sx_TagOrder( 1, nIndex ) ), ;
            OrdSetFocus() )
sxcompat.prg369
FUNCTIONRDD_Count()
function RDD_Count()
return len( RDDList() )
sxcompat.prg374
FUNCTIONRDD_Name( nRDD )
function RDD_Name( nRDD )
   local aRDD

   if valType( nRDD ) == "N" .and. nRDD >= 1
      aRDD := RDDList()
      if nRDD <= len( aRDD )
         return aRDD[ nRDD ]
      endif
   endif
return ""
sxcompat.prg377
FUNCTIONRDD_Info( xID )
function RDD_Info( xID )
   local aInfo, cRDD

   if valType( xID ) == "N"
      if !empty( alias( xID ) )
         ( xID )->( RDDName() )
      endif
   elseif valType( xID ) == "C"
      cRDD := upper( alltrim( xID ) )
      if ascan( RDDList(), {|x| upper( x ) == cRDD } ) == 0
         cRDD := NIL
      endif
   elseif xID == NIL
      cRDD := rddSetDefault()
   endif

   if empty( cRDD )
      aInfo := {}
   else
      aInfo := array( 6 )
      aInfo[ 1 ] := cRDD
      aInfo[ 2 ] := .t.
      aInfo[ 3 ] := rddInfo( RDDI_TABLEEXT, NIL, cRDD )
      aInfo[ 4 ] := rddInfo( RDDI_ORDBAGEXT, NIL, cRDD )
      aInfo[ 5 ] := rddInfo( RDDI_ORDEREXT, NIL, cRDD )
      aInfo[ 6 ] := rddInfo( RDDI_MEMOEXT, NIL, cRDD )
   endif
return aInfo
sxcompat.prg388
FUNCTIONSx_IsDBT( cRDD )
function Sx_IsDBT( cRDD )
return rddInfo( RDDI_MEMOTYPE, NIL, cRDD ) == DB_MEMO_DBT
sxcompat.prg417
FUNCTIONSx_MemoExt( cNewExt, cRDD )
function Sx_MemoExt( cNewExt, cRDD )
return rddInfo( RDDI_MEMOEXT, cNewExt, cRDD )
sxcompat.prg420
FUNCTIONSx_MemoBlk( nNewBlock, cRDD )
function Sx_MemoBlk( nNewBlock, cRDD )
return rddInfo( RDDI_MEMOBLOCKSIZE, nNewBlock, cRDD )
sxcompat.prg423
FUNCTIONSx_SetMemoBlock( nNewBlock, cRDD )
function Sx_SetMemoBlock( nNewBlock, cRDD )
return rddInfo( RDDI_MEMOBLOCKSIZE, nNewBlock, cRDD )
sxcompat.prg426
FUNCTIONSx_StrxCheck( lStrict, cRDD )
function Sx_StrxCheck( lStrict, cRDD )
return rddInfo( RDDI_STRICTSTRUCT, lStrict, cRDD )
sxcompat.prg429
FUNCTIONSx_LockRetry( nRetry, cRDD )
function Sx_LockRetry( nRetry, cRDD )
return rddInfo( RDDI_LOCKRETRY, nRetry, cRDD )
sxcompat.prg432
FUNCTIONSx_AutoOpen( lAuto, cRDD )
function Sx_AutoOpen( lAuto, cRDD )
return rddInfo( RDDI_AUTOOPEN, lAuto, cRDD )
sxcompat.prg435
FUNCTIONSx_AutoShare( lAuto, cRDD )
function Sx_AutoShare( lAuto, cRDD )
return rddInfo( RDDI_AUTOSHARE, lAuto, cRDD )
sxcompat.prg438
FUNCTIONSx_BLOB2File( cFileName, cFldName )
function Sx_BLOB2File( cFileName, cFldName )
return dbFileGet( cFldName, cFileName, FILEGET_OVERWRITE )
sxcompat.prg441
FUNCTIONSx_File2BLOB( cFileName, cFldName, nActionCode )
function Sx_File2BLOB( cFileName, cFldName, nActionCode )
   local nAction := 0
   if HB_BITAND( nActionCode, BLOB_FILECOMPRESS ) != 0
      nAction := HB_BITOR( nAction, FILEPUT_COMPRESS )
   endif
   if HB_BITAND( nActionCode, BLOB_FILEENCRYPT ) != 0
      nAction := HB_BITOR( nAction, FILEPUT_ENCRYPT )
   endif
return dbFileGet( cFldName, cFileName, nAction )
sxcompat.prg444
FUNCTIONSx_dbCreate( cFileName, aStruct, cRDD )
function Sx_dbCreate( cFileName, aStruct, cRDD )
   local aField, aDbStruct

   aDbStruct := AClone( aStruct )
   for each aField in aDbStruct
      switch aField[ 2 ]
         case "V"
            aField[ 3 ] += 6
            exit
         case "D"
            if aField[ 3 ] == 3
               aField[ 2 ] := "V"
            endif
            exit
         case "I"
            if aField[ 3 ] == 4
               aField[ 2 ] := "V"
            endif
            exit
      end
   next

return dbCreate( cFileName, aDbStruct, cRDD )
sxcompat.prg454
FUNCTIONSx_VSigLen( xField )
function Sx_VSigLen( xField )
   local nResult := 0, nField := 0

   if Used()
      if valtype( xField ) == "C"
         nField := FieldPos( xField )
      elseif valtype( xField ) == "N"
         nField := xField
      endif
      if nField >= 1 .and. nField <= FCount()
         nResult := FieldLen( nField )
         if FieldType( nField ) == "V" .and. nResult >= 6
            nResult -= 6
         endif
      endif
   endif

return nResult
sxcompat.prg478
FUNCTIONSx_VFGet( cExpr, nLen )
function Sx_VFGet( cExpr, nLen )

   /* Our RDDs does not use any internal flags to cut V-Fields so
    * we can simply evaluate given expression */
    */
   if Used() .and. PCount() == 2
      return padr( &cExpr, nLen )
   endif

return NIL
sxcompat.prg497
FUNCTIONSx_IsLocked( xRec )
function Sx_IsLocked( xRec )
   local lResult := .f., xRecord

   if Used()
      xRecord := IIF( xRec == NIL, RecNo(), xRec )
      /*
       * Don't be confused by function name.
       * Even if it looks strange and results are not very usable due
       * to possible race condition then this is what SIX3 exactly does.
       */
      if Sx_RLock( xRecord )
         Sx_UnLock( xRecord )
      else
         lResult := .t.
      endif
   endif

return lResult
sxcompat.prg508
FUNCTIONSx_SetTrigger( nAction, cTriggerName, cRDD )
function Sx_SetTrigger( nAction, cTriggerName, cRDD /* Harbour extensions */ )
   local cPrevTrigger := ""

   if valtype( nAction ) == "N"
      if nAction == TRIGGER_PENDING
         if valtype( cTriggerName ) == "C"
            rddInfo( RDDI_PENDINGTRIGGER, cTriggerName, cRDD )
         endif
      elseif Used()
         cPrevTrigger := dbInfo( DBI_TRIGGER )
         switch nAction
            case TRIGGER_ENABLE
               dbInfo( DBI_TRIGGER, .T. )
               exit
            case TRIGGER_DISABLE
               dbInfo( DBI_TRIGGER, .F. )
               exit
            case TRIGGER_REMOVE
               dbInfo( DBI_TRIGGER, "" )
               exit
            case TRIGGER_INSTALL
               if valtype( cTriggerName ) == "C"
                  dbInfo( DBI_TRIGGER, cTriggerName )
               endif
               exit
         end
      endif
   endif

return cPrevTrigger
sxcompat.prg527
sxini.prg
TypeFunctionSourceLine
STATIC FUNCTION_sx_INIlogical( cVal )
static function _sx_INIlogical( cVal )
   switch Upper( cVal )
      case ".T."
      case "TRUE"
      case "YES"
      case "ON"
         return .T.
      case ".F."
      case "FALSE"
      case "NO"
      case "OFF"
         return .F.
   end
return NIL
sxini.prg63
FUNCTION_sx_INIinit( nArea )
function _sx_INIinit( nArea )
   local cFile, cPath, cName, cExt, cDrive
   local xShared, xReadOnly, xAlias, xTrigger
   local hIni, item, sect, h, a

   /* SIX3 keeps information about ini sections in array[250] stored
    * in public variable called "SxIniInfo". This array is indexed
    * by workarea number. In Harbour we are using hash arrays.
    */

   if Type( "SxIniInfo" ) = "U" /* NOTE: Intentionally using '=' operator */
      public SxIniInfo := {=>}
      HB_HCaseMatch( SxIniInfo, .f. )
      HB_HAutoAdd( SxIniInfo, HB_HAUTOADD_ASSIGN )
   endif

   if nArea == NIL
      return .f.
   endif

   cFile := ( nArea )->( dbInfo( DBI_FULLPATH ) )
   hb_FNameSplit( cFile, @cPath, @cName, @cExt, @cDrive )
   cFile := hb_FNameMerge( cPath, cName, ".ini", cDrive )
   hIni := hb_IniRead( cFile, .F.,, .F. )

   if !Empty( hIni )
      if hb_HHasKey( hIni, HB_SIX_SECTION )
         for each item in hIni[ HB_SIX_SECTION ]
            switch item:__enumKey()
               case "SHARED"
                  xShared := _sx_INIlogical( item )
                  exit
               case "READONLY"
                  xReadOnly := _sx_INIlogical( item )
                  exit
               case "ALIAS"
                  xAlias := item
                  exit
               case "TRIGGER"
                  xTrigger := item
                  exit
            end
         next
         if xTrigger != NIL
            ( nArea )->( Sx_SetTrigger( TRIGGER_INSTALL, xTrigger ) )
         endif
         _sxOpenInit( nArea, xShared, xReadOnly, xAlias )
      endif

      /* convert hash array into normal array */
      for each item in hIni
         if HB_IsHash( item )
            sect := Array( Len( item ) )
            for each h, a in item, sect
               a := { h:__enumKey(), h }
            next
            item := sect
         endif
      next

      SxIniInfo[ nArea ] := hIni

   endif

return .f.
sxini.prg78
FUNCTIONSx_INIheader( cHeaderName, nArea )
function Sx_INIheader( cHeaderName, nArea )

   if nArea == NIL
      nArea := Select()
   endif

   if hb_HHasKey( SxIniInfo, nArea )
      if hb_HHasKey( SxIniInfo[ nArea ], cHeaderName )
         return SxIniInfo[ nArea, cHeaderName ]
      endif
   endif

return {}
sxini.prg144
sxtrig.prg
TypeFunctionSourceLine
FUNCTIONSx_DefTrigger( nEvent, nArea, nFieldPos, xTrigVal )
function Sx_DefTrigger( nEvent, nArea, nFieldPos, xTrigVal )

   HB_SYMBOL_UNUSED( nArea )
   HB_SYMBOL_UNUSED( nFieldPos )
   HB_SYMBOL_UNUSED( xTrigVal )

   switch nEvent
      case EVENT_PREUSE
//       _sx_INIinit( nArea )
         Sx_SetTrigger( TRIGGER_REMOVE )
         exit
      case EVENT_POSTUSE
         exit
      case EVENT_UPDATE
         exit
      case EVENT_APPEND
         exit
      case EVENT_DELETE
         exit
      case EVENT_RECALL
         exit
      case EVENT_PACK
         exit
      case EVENT_ZAP
         exit
      case EVENT_PUT
         exit
      case EVENT_GET
         exit
      case EVENT_PRECLOSE
         exit
      case EVENT_POSTCLOSE
         exit
      case EVENT_PREMEMOPACK
         exit
      case EVENT_POSTMEMOPACK
         exit
   end

return .T.
sxtrig.prg57

Page url: http://www.yourdomain.com/help/index.html?hbsix.htm