diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6ae3191d8f..ad143782e8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,28 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2008-01-14 19:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/common.mak + * replaced TAB with SPACEs + + * harbour/source/rdd/dbcmd.c + * changed hb_retnl() in LASTREC() to hb_retnint() to increase maximum + record number to 2^32 - unsigned 32bit integer instead of signed one. + + * harbour/source/rdd/dbf1.c + ! fixed possible memory leak/GPF when sx_DBFencrypt() is called when + table already has password set + * added support for password passing in sx_DBFdecrypt() - it's accepted + only when table has no password + + * harbour/source/rdd/hbsix/sxcompat.prg + - removed SX_SETPASS() + * harbour/source/rdd/hbsix/sxtable.c + + added new SX_SETPASS() implementation which supports + some undocumented SIX3 actions + ! fixed problem with setting password for currently open table + with SX_SETPASS( ) + 2008-01-12 13:19 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/ChangeLog * harbour/include/hbapiitm.h diff --git a/harbour/common.mak b/harbour/common.mak index 069aaf791e..7383537cba 100644 --- a/harbour/common.mak +++ b/harbour/common.mak @@ -1065,7 +1065,7 @@ HBDOC_EXE_OBJS = \ # PDF support for HBDOC HBDOC_EXE_OBJS = \ - $(HBDOC_EXE_OBJS) \ + $(HBDOC_EXE_OBJS) \ $(OBJ_DIR)\pdfhbdoc$(OBJEXT) \ $(OBJ_DIR)\genpdf1$(OBJEXT) \ diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index d2b8f0738e..c4754065ef 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -1018,7 +1018,7 @@ HB_FUNC( LASTREC ) if( pArea ) SELF_RECCOUNT( pArea, &ulRecCount ); - hb_retnl( ulRecCount ); + hb_retnint( ulRecCount ); } HB_FUNC( LOCK ) diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 605a6ef9da..eebe28eb38 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -647,8 +647,17 @@ static void hb_dbfTableCrypt( DBFAREAP pArea, PHB_ITEM pPasswd, BOOL fEncrypt ) BYTE * pOldCryptKey, * pNewCryptKey; pOldCryptKey = pArea->pCryptKey; + pArea->pCryptKey = NULL; hb_dbfPasswordSet( pArea, pPasswd, FALSE ); pNewCryptKey = pArea->pCryptKey; + if( !fEncrypt && pNewCryptKey ) + { + if( pOldCryptKey ) + hb_xfree( pNewCryptKey ); + else + pOldCryptKey = pNewCryptKey; + pNewCryptKey = NULL; + } for( ulRecNo = 1; ulRecNo <= ulRecords; ++ulRecNo ) { pArea->pCryptKey = pOldCryptKey; diff --git a/harbour/source/rdd/hbsix/sxcompat.prg b/harbour/source/rdd/hbsix/sxcompat.prg index 25c3c80c89..d3d47a6361 100644 --- a/harbour/source/rdd/hbsix/sxcompat.prg +++ b/harbour/source/rdd/hbsix/sxcompat.prg @@ -35,7 +35,6 @@ * Sx_LockRetry() * Sx_IsLocked() * Sx_SetTrigger() - * Sx_SetPass() * Sx_VFGet() * * Copyright 2007 Przemyslaw Czerpak @@ -555,13 +554,3 @@ function Sx_SetTrigger( nAction, cTriggerName, cRDD /* Harbour extensions */ ) endif return cPrevTrigger - -function Sx_SetPass( cPass, nMode, cRdd /* Harbour extensions */ ) - - HB_SYMBOL_UNUSED( nMode ) - - if valtype( cPass ) == "C" - rddInfo( RDDI_PENDINGPASSWORD, cPass, cRdd ) - endif - -return nil diff --git a/harbour/source/rdd/hbsix/sxtable.c b/harbour/source/rdd/hbsix/sxtable.c index 1b1b01251d..d216e9505f 100644 --- a/harbour/source/rdd/hbsix/sxtable.c +++ b/harbour/source/rdd/hbsix/sxtable.c @@ -15,6 +15,7 @@ * Sx_Rollback() * Sx_RLock() * Sx_UnLock() + * Sx_SetPass() * Sx_DBFencrypt() * Sx_DBFdecrypt() * Sx_MemoPack() @@ -280,6 +281,84 @@ HB_FUNC( SX_UNLOCK ) } } +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 ); +} + HB_FUNC( SX_DBFENCRYPT ) { AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); @@ -287,7 +366,12 @@ HB_FUNC( SX_DBFENCRYPT ) 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 );