2009-07-30 06:35 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* source/common/hbdate.c
    ! Fixed for some systems where tm->tm_gmtoff isn't available.
      (like sunos). Thanks to Tamas Tevesz for report and pointer.

  * contrib/rddads/adsfunc.c
    + ADSCREATESAVEPOINT()
      ADSROLLBACKSAVEPOINT()
      Added support for 3rd optional parameter on Harbour level.

  * include/hbapi.h
  * source/vm/extend.c
    + hb_parnidef(), hb_parnldef() to give a faster and shorter
      alternative to HB_ISNUM( x ) ? hb_parn[i|l]( x ) : <value>
      construct, which quite often occure in C interface code.
      We may also add a hb_parl() version which returns TRUE,
      this covers most real-life usages.

  * examples/uhttpd2/socket.c
  * examples/httpsrv/socket.c
    % Deleted local hb_parnidef() wrapper.
This commit is contained in:
Viktor Szakats
2009-07-30 04:36:35 +00:00
parent d518e481c5
commit ecb56859df
7 changed files with 92 additions and 17 deletions

View File

@@ -17,6 +17,28 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-07-30 06:35 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* source/common/hbdate.c
! Fixed for some systems where tm->tm_gmtoff isn't available.
(like sunos). Thanks to Tamas Tevesz for report and pointer.
* contrib/rddads/adsfunc.c
+ ADSCREATESAVEPOINT()
ADSROLLBACKSAVEPOINT()
Added support for 3rd optional parameter on Harbour level.
* include/hbapi.h
* source/vm/extend.c
+ hb_parnidef(), hb_parnldef() to give a faster and shorter
alternative to HB_ISNUM( x ) ? hb_parn[i|l]( x ) : <value>
construct, which quite often occure in C interface code.
We may also add a hb_parl() version which returns TRUE,
this covers most real-life usages.
* examples/uhttpd2/socket.c
* examples/httpsrv/socket.c
% Deleted local hb_parnidef() wrapper.
2009-07-30 00:43 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* include/hbextern.ch
* source/rtl/dateshb.c

View File

@@ -2196,7 +2196,7 @@ HB_FUNC( ADSCREATESAVEPOINT )
#if ADS_LIB_VERSION >= 800
hb_retnl( AdsCreateSavepoint( HB_ADS_PARCONNECTION( 1 ) /* hConnect */,
( UNSIGNED8 * ) hb_parc( 2 ) /* pucSavepoint */,
ADS_DEFAULT /* ulOptions */ ) );
( UNSIGNED32 ) ( HB_ISNUM( 3 ) ? hb_parnl( 3 ) : ADS_DEFAULT ) /* ulOptions */ ) );
#else
hb_retnl( 0 );
#endif
@@ -2207,7 +2207,7 @@ HB_FUNC( ADSROLLBACKSAVEPOINT )
#if ADS_LIB_VERSION >= 800
hb_retnl( AdsRollbackTransaction80( HB_ADS_PARCONNECTION( 1 ) /* hConnect */,
( UNSIGNED8 * ) hb_parc( 2 ) /* pucSavepoint */,
ADS_DEFAULT /* ulOptions */ ) );
( UNSIGNED32 ) ( HB_ISNUM( 3 ) ? hb_parnl( 3 ) : ADS_DEFAULT ) /* ulOptions */ ) );
#else
hb_retnl( 0 );
#endif

View File

@@ -45,11 +45,6 @@
#include "hbsocket.h"
#include "hbapiitm.h"
static int hb_parnidef( int iParam, int iValue )
{
return HB_ISNUM( iParam ) ? hb_parni( iParam ) : iValue;
}
static HB_SOCKET hb_parsocket( int iParam )
{
return HB_ISPOINTER( iParam ) ? ( HB_SOCKET ) ( HB_PTRDIFF )

View File

@@ -45,11 +45,6 @@
#include "hbsocket.h"
#include "hbapiitm.h"
static int hb_parnidef( int iParam, int iValue )
{
return HB_ISNUM( iParam ) ? hb_parni( iParam ) : iValue;
}
static HB_SOCKET hb_parsocket( int iParam )
{
return HB_ISPOINTER( iParam ) ? ( HB_SOCKET ) ( HB_PTRDIFF )

View File

@@ -622,7 +622,9 @@ extern HB_EXPORT BOOL hb_partdt( long * plJulian, long * plMilliSec , in
extern HB_EXPORT int hb_parl( int iParam ); /* retrieve a logical parameter as an int */
extern HB_EXPORT double hb_parnd( int iParam ); /* retrieve a numeric parameter as a double */
extern HB_EXPORT int hb_parni( int iParam ); /* retrieve a numeric parameter as a integer */
extern HB_EXPORT int hb_parnidef( int iParam, int iDefValue ); /* retrieve a numeric parameter as a integer, return default value if parameter isn't numeric */
extern HB_EXPORT long hb_parnl( int iParam ); /* retrieve a numeric parameter as a long */
extern HB_EXPORT long hb_parnldef( int iParam, long lDefValue ); /* retrieve a numeric parameter as a long, return default value if parameter isn't numeric */
extern HB_EXPORT HB_LONG hb_parnint( int iParam ); /* retrieve a numeric parameter as a HB_LONG */
extern HB_EXPORT void * hb_parptr( int iParam ); /* retrieve a parameter as a pointer */
extern HB_EXPORT void * hb_parptrGC( HB_GARBAGE_FUNC_PTR pFunc, int iParam ); /* retrieve a parameter as a pointer if it's a pointer to GC allocated block */

View File

@@ -912,17 +912,20 @@ long hb_timeUTCOffset( void ) /* in seconds */
}
#else
{
struct tm tmTime;
time_t current;
struct tm * timeinfo;
time_t current, utc, local;
time( &current );
timeinfo = gmtime( &current );
utc = mktime( timeinfo );
# if defined( HB_HAS_LOCALTIME_R )
localtime_r( &current, &tmTime );
localtime_r( &current, timeinfo );
# else
tmTime = *localtime( &current );
timeinfo = localtime( &current );
# endif
local = mktime( timeinfo );
return tmTime.tm_gmtoff;
return utc - local - ( timeinfo->tm_isdst ? 1 : 0 );
}
#endif
}

View File

@@ -61,6 +61,8 @@
* hb_retnllen()
* hb_retndlen()
* hb_retdl()
* hb_parnidef() (based on idea by Mindaugas Kavaliauskas)
* hb_parnldef()
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* hb_retd()
@@ -481,6 +483,34 @@ int hb_parni( int iParam )
return 0;
}
int hb_parnidef( int iParam, int iDefValue )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_parni(%d, %d)", iParam, iDefValue));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
if( HB_IS_BYREF( pItem ) )
pItem = hb_itemUnRef( pItem );
if( HB_IS_INTEGER( pItem ) )
return pItem->item.asInteger.value;
else if( HB_IS_LONG( pItem ) )
return ( int ) pItem->item.asLong.value;
else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
return ( int ) ( unsigned int ) pItem->item.asDouble.value;
#else
return ( int ) pItem->item.asDouble.value;
#endif
}
return iDefValue;
}
long hb_parnl( int iParam )
{
HB_STACK_TLS_PRELOAD
@@ -509,6 +539,34 @@ long hb_parnl( int iParam )
return 0;
}
long hb_parnldef( int iParam, long lDefValue )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_parnldef(%d, %ld)", iParam, lDefValue));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
if( HB_IS_BYREF( pItem ) )
pItem = hb_itemUnRef( pItem );
if( HB_IS_LONG( pItem ) )
return ( long ) pItem->item.asLong.value;
else if( HB_IS_INTEGER( pItem ) )
return ( long ) pItem->item.asInteger.value;
else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
return ( long ) ( unsigned long ) pItem->item.asDouble.value;
#else
return ( long ) pItem->item.asDouble.value;
#endif
}
return lDefValue;
}
#ifndef HB_LONG_LONG_OFF
LONGLONG hb_parnll( int iParam )
{