2009-07-20 17:45 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbwin/win_reg.prg
  * contrib/hbwin/win_regc.c
    ! GETREGISTRY() fixed to return default only if the
      registry entry doesn't exist. Previously it was
      falling back to default even if the value existed but
      was empty. In case of empty string, these weren't
      possible to write from hbwin, but could exist in registry
      when written by other tools.
    ! GETREGISTRY() fixed to return binary data as string
      for REG_BINARY types. (previously it was returning
      an unsigned int - essentially truncating everything
      beyong the first 4 bytes).
    ! GETREGISTRY() fixed to swap words for REG_DWORD_BIG_ENDIAN
      values to return correct unsigned integer results.
      (not tested)
    ! GETREGISTRY() fixed to strip only the ending Chr( 0 )
      from string values. This makes it possible to utilize
      strings containing nul chars (obviously) and also to
      parse REG_MULTI_SZ multistring values.
    ! GETREGISTRY() fixed to not RTE if WIN_REGQUERYVALUEEX()
      returned non-null length and a non-string value.
      I still have to understand how this was possible, but
      I got a report that it happened on a system.
    ! WIN_REGQUERYVALUEEX() fixed to store NIL in 5th param,
      if the registry entry doesn't exist.
    ! WIN_REGQUERYVALUEEX() fixed to store empty string when
      registry value is zero length.

  * include/hbapi.h
  * source/vm/extend.c
    + Added API hb_stor() to store a NIL into a parameter passed
      by reference.

  * source/vm/arrays.c
    * Minor formatting.
This commit is contained in:
Viktor Szakats
2009-07-20 15:48:57 +00:00
parent cd7375406b
commit e2cca2e1e6
6 changed files with 86 additions and 20 deletions

View File

@@ -17,6 +17,43 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-07-20 17:45 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_reg.prg
* contrib/hbwin/win_regc.c
! GETREGISTRY() fixed to return default only if the
registry entry doesn't exist. Previously it was
falling back to default even if the value existed but
was empty. In case of empty string, these weren't
possible to write from hbwin, but could exist in registry
when written by other tools.
! GETREGISTRY() fixed to return binary data as string
for REG_BINARY types. (previously it was returning
an unsigned int - essentially truncating everything
beyong the first 4 bytes).
! GETREGISTRY() fixed to swap words for REG_DWORD_BIG_ENDIAN
values to return correct unsigned integer results.
(not tested)
! GETREGISTRY() fixed to strip only the ending Chr( 0 )
from string values. This makes it possible to utilize
strings containing nul chars (obviously) and also to
parse REG_MULTI_SZ multistring values.
! GETREGISTRY() fixed to not RTE if WIN_REGQUERYVALUEEX()
returned non-null length and a non-string value.
I still have to understand how this was possible, but
I got a report that it happened on a system.
! WIN_REGQUERYVALUEEX() fixed to store NIL in 5th param,
if the registry entry doesn't exist.
! WIN_REGQUERYVALUEEX() fixed to store empty string when
registry value is zero length.
* include/hbapi.h
* source/vm/extend.c
+ Added API hb_stor() to store a NIL into a parameter passed
by reference.
* source/vm/arrays.c
* Minor formatting.
2009-07-20 08:45 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbqt/hbqt_slots.cpp
* contrib/hbqt/hbqt_slots.h

View File

@@ -159,26 +159,35 @@ FUNCTION QueryRegistry( nHKEY, cKeyName, cEntryName, xValue, lSetIt )
RETURN lRetVal
FUNCTION GetRegistry( nHKEY, cKeyName, cEntryName, xDefault )
LOCAL xRetVal := xDefault
LOCAL xRetVal
LOCAL pKeyHandle
LOCAL nValueType
IF win_RegOpenKeyEx( nHKEY, cKeyName, 0, KEY_QUERY_VALUE, @pKeyHandle )
/* retrieve the length of the value */
IF win_RegQueryValueEx( pKeyHandle, cEntryName, 0, @nValueType, @xRetVal ) > 0
IF nValueType == REG_DWORD .OR. ;
nValueType == REG_DWORD_LITTLE_ENDIAN .OR. ;
nValueType == REG_DWORD_BIG_ENDIAN .OR. ;
nValueType == REG_BINARY
win_RegQueryValueEx( pKeyHandle, cEntryName, 0, @nValueType, @xRetVal )
IF ISCHARACTER( xRetVal )
DO CASE
CASE nValueType == REG_DWORD .OR. nValueType == REG_DWORD_LITTLE_ENDIAN
xRetVal := Bin2U( xRetVal )
ELSE
xRetVal := StrTran( xRetVal, Chr( 0 ) )
ENDIF
CASE nValueType == REG_DWORD_BIG_ENDIAN
xRetVal := Bin2U( Right( xRetVal, 2 ) + Left( xRetVal, 2 ) )
OTHERWISE
/* Strip ending zero byte */
IF Right( xRetVal, 1 ) == Chr( 0 )
xRetVal := hb_StrShrink( xRetVal, 1 )
ENDIF
ENDCASE
ELSE
xRetVal := xDefault
ENDIF
win_RegCloseKey( pKeyHandle )
ELSE
xRetVal := xDefault
ENDIF
RETURN xRetVal

View File

@@ -143,7 +143,11 @@ HB_FUNC( WIN_REGQUERYVALUEEX )
if( ! hb_storclen_buffer( ( char * ) cValue, nSize, 5 ) )
hb_xfree( cValue );
}
else
hb_storc( NULL, 5 );
}
else
hb_stor( 5 );
hb_stornl( nType, 4 );
hb_retnl( nSize );
@@ -167,14 +171,12 @@ HB_FUNC( WIN_REGSETVALUEEX )
sizeof( REG_DWORD ) ) == ERROR_SUCCESS );
}
else
{
hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ),
lpKey,
0,
nType,
( BYTE * ) hb_parcx( 5 ) /* cValue */,
hb_parclen( 5 ) + 1 ) == ERROR_SUCCESS );
}
HB_TCHAR_FREE( lpKey );
}

View File

@@ -725,6 +725,7 @@ extern HB_EXPORT void hb_retnlllen( LONGLONG lNumber, int iWidth ); /* returns
#endif /* HB_API_MACROS */
extern HB_EXPORT int hb_stor( int iParam ); /* stores a NIL on a variable by reference */
extern HB_EXPORT int hb_storc( const char * szText, int iParam ); /* stores a szString on a variable by reference */
extern HB_EXPORT int hb_storclen( const char * szText, ULONG ulLength, int iParam ); /* stores a fixed length string on a variable by reference */
extern HB_EXPORT int hb_storclen_buffer( char * szText, ULONG ulLength, int iParam ); /* stores a fixed length string buffer on a variable by reference */

View File

@@ -1506,9 +1506,7 @@ PHB_ITEM hb_arrayFromStack( USHORT uiLen )
hb_arrayNew( pArray, uiLen );
for( uiPos = 1; uiPos <= uiLen; uiPos++ )
{
hb_arraySet( pArray, uiPos, hb_stackItemFromTop( uiPos - uiLen - 1 ) );
}
return pArray;
}
@@ -1530,9 +1528,7 @@ PHB_ITEM hb_arrayFromParams( int iLevel )
pArray = hb_itemArrayNew( uiPCount );
for( uiPos = 1; uiPos <= uiPCount; uiPos++ )
{
hb_arraySet( pArray, uiPos, hb_stackItem( lBaseOffset + uiPos + 1 ) );
}
return pArray;
}
@@ -1551,9 +1547,7 @@ PHB_ITEM hb_arrayBaseParams( void )
hb_arrayNew( pArray, uiPCount );
for( uiPos = 1; uiPos <= uiPCount; uiPos++ )
{
hb_arraySet( pArray, uiPos, hb_stackItemFromBase( uiPos ) );
}
return pArray;
}
@@ -1572,9 +1566,7 @@ PHB_ITEM hb_arraySelfParams( void )
hb_arrayNew( pArray, uiPCount + 1 );
for( uiPos = 0; uiPos <= uiPCount; uiPos++ )
{
hb_arraySet( pArray, uiPos + 1, hb_stackItemFromBase( uiPos ) );
}
return pArray;
}

View File

@@ -54,7 +54,8 @@
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
*
* Copyright 1999-2001 Viktor Szakats (harbour.01 syenar.hu)
* Copyright 1999-2009 Viktor Szakats (harbour.01 syenar.hu)
* hb_stor()
* hb_retnlen()
* hb_retnilen()
* hb_retnllen()
@@ -1491,6 +1492,30 @@ void hb_retptrGC( void * pointer )
hb_itemPutPtrGC( hb_stackReturnItem(), pointer );
}
int hb_stor( int iParam )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_stor( %d )", iParam));
if( iParam == -1 )
{
hb_itemClear( hb_stackReturnItem() );
return 1;
}
else if( iParam >= 0 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = hb_stackItemFromBase( iParam );
if( HB_IS_BYREF( pItem ) )
{
hb_itemClear( hb_itemUnRef( pItem ) );
return 1;
}
}
return 0;
}
int hb_storc( const char * szText, int iParam )
{