Files
harbour-core/contrib/hbnf/descendn.c
vszakats 9687850865 2013-03-16 02:10 UTC+0100 Viktor Szakats (harbour syenar.net)
* (all files)
    * stripped svn header
    * minor cleanups
    ; use following command to find out the history of files:
       git log
       git log --follow
       git blame
       git annotate
2013-03-16 02:11:42 +01:00

66 lines
1.5 KiB
C

/*
* Author....: Ted Means
* CIS ID....: 73067,3332
*
* This function is an original work by Ted Means and is placed in the
* public domain.
*
* Modification history:
* ---------------------
*
* Rev 1.1 01 May 1995 03:05:00 TED
* Added typecast to tame compiler warning
*
* Rev 1.0 01 Feb 1995 03:02:00 TED
* Initial release
*
*/
#include "hbapi.h"
#include "hbapiitm.h"
HB_FUNC( FT_DESCEND )
{
PHB_ITEM iP = hb_itemParam( 1 );
HB_TYPE uiType = hb_itemType( iP );
PHB_ITEM iR = NULL;
if( ( uiType & HB_IT_NUMERIC ) && ( uiType & HB_IT_DOUBLE ) )
iR = hb_itemPutND( 0, 0 - hb_itemGetND( iP ) );
else if( uiType & HB_IT_NUMERIC )
iR = hb_itemPutNL( 0, 0 - hb_itemGetNL( iP ) );
else if( uiType & HB_IT_DATE )
iR = hb_itemPutNL( 0, 0x4FD4C0L - hb_itemGetNL( iP ) );
else if( uiType & HB_IT_TIMESTAMP )
iR = hb_itemPutND( 0, 0x4FD4C0L - hb_itemGetTD( iP ) );
else if( uiType & HB_IT_LOGICAL )
iR = hb_itemPutL( 0, ( hb_itemGetL( iP ) > 0 ) ? 0 : 1 );
else if( uiType & HB_IT_STRING )
{
HB_SIZE uiLen = hb_itemSize( iP );
HB_SIZE n;
char * pDescend = ( char * ) hb_xgrab( uiLen );
hb_itemCopyC( iP, pDescend, uiLen );
for( n = 0; n < uiLen; n++ )
pDescend[ n ] = ( char ) 0 - pDescend[ n ];
iR = hb_itemPutCL( 0, pDescend, uiLen );
hb_xfree( pDescend );
}
hb_itemReturn( iR );
hb_itemRelease( iP );
hb_itemRelease( iR );
}