Files
harbour-core/harbour/source/vm/extend.c
Przemyslaw Czerpak 26a11bd859 2009-03-21 16:07 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/bin/hb-func.sh
    ! restored default optimization flag (-O3) in hb* scripts

  * harbour/harbour.spec
    ! fixed recent modification

  * harbour/contrib/rddads/ads1.c
  * harbour/contrib/rddads/adsfunc.c
  * harbour/contrib/hbmisc/strfmt.c
  * harbour/contrib/hbcrypt/sha1.c
    ! fixed wrongly used C reference operator

  * harbour/contrib/hbwin/win_prn2.c
  * harbour/contrib/hbwin/wapi_commctrl.c
  * harbour/source/vm/maindllp.c
    ! fixes for unicode builds

  * harbour/include/std.ch
    + added SET TIME FORMAT [TO] <f>

  * harbour/include/set.ch
  * harbour/include/hbset.h
  * harbour/source/vm/set.c
    + added _SET_TIMEFORMAT
      The folowing modifiers are supported:
         hh - hours
         mm - minutes
         ss - seconds
         fff - fraction part of seconds
         p - 1-st letter from PM / AM signature. When used time is shown
             in 12 hour format otherwise 24 hour format is used
      ex: Set( __SET_TIMEFORMAT, "hh:mm pm" )
      default _SET_TIMEFORMAT value is "hh:mm:ss:fff"
    + added C function: char * hb_setGetTimeFormat( void );

  * harbour/include/hbpp.h
  * harbour/source/pp/ppcore.c
    + added support for timestamp constant values in the form:
         t"YYYY-MM-DD HH:MM:SS.fff"
      The exact accepted timestamp pattern is is:
         YYYY-MM-DD [H[H][:M[M][:S[S][.f[f[f[f]]]]]]] [PM|AM]
      i.e.:
         tValue := t"2009-03-21 5:31:45.437 PM"
      or:
         YYYY-MM-DDT[H[H][:M[M][:S[S][.f[f[f[f]]]]]]] [PM|AM]
      with literal "T" as date and time part delimiters (XML timestamp
      format), i.e.:
         tValue := t"2009-03-21T17:31:45.437"
      The folowing characters can be used as date delimiters: "-", "/", "."
      if PM or AM is used HH is in range < 1 : 12 > otherwise
      in range < 0 : 23 >

  * harbour/source/compiler/complex.c
  * harbour/source/compiler/harbour.y
  * harbour/source/compiler/harbour.yyc
  * harbour/source/compiler/harbour.yyh
    + added support for t"YYYY-MM-DD HH:MM:SS.fff" time stamp constant
      to compiler
    + added support for VFP datetime constant values:
         { ^ [ YYYY-MM-DD [,] ] [ HH[:MM[:SS][.FFF]] [AM|PM] ] }
      The following characters can be used as date delimiters: "-", "/".
      Dot "." as date delimiter is not supported.
      There is no limit on number of characters in YYYY, MM, DD, HH, MM,
      SS, FFF parts. Important is only their value. This is the format
      in semi PP notation:
         { ^ <YEAR> <sep:/-> <MONTH> <sep:/-> <DAY> [[<sep2:,>]
           [ <HOUR> [ : <MIN> [ : <SEC> [ . <FRAQ> ] ] ] [AM|PP] ] }
      In practice it allows to also parse xHarbour datetime constant
      values with compatible conditions though xHarbour support onlu "/"
      as date delimiter.
      NOTE: there is one important difference to VFP and xHarbour in
      decoding above format. In VFP and xHarbour when date part is
      missing then it's set by default to: 1899-12-30 so this code:
         { ^ 12:00 }
      gived the same results as:
         { ^ 1899/12/30 12:00 }
      Harbour does not set any default date value when timestamp
      constant value contains only time part.
      If you want we can change it for strict VFP compatiblity.
      Now this extension is enabled by default for testing. In the future
      it will be probably covered by HB_COMPAT_FOXPRO macro.

  * harbour/source/macro/macro.yyc
  * harbour/source/macro/macro.y
  * harbour/source/macro/macro.yyh
  * harbour/source/macro/macrolex.c
    + added support for t"YYYY-MM-DD HH:MM:SS.fff" time stamp constant
      to macro compiler

  * harbour/include/hbmacro.h
  * harbour/source/vm/macro.c
    + added new function:
      void hb_macroGenPushTimeStamp( LONG lDate, LONG lTime, HB_COMP_DECL );

  * harbour/include/hberrors.h
  * harbour/source/compiler/hbgenerr.c
    + added new compile time error: "Invalid timestamp constant '%s'"

  * harbour/source/compiler/cmdcheck.c
    * use Harbour API timestamp functions instead of calling system
      functions

  * harbour/include/hbpcode.h
  * harbour/source/compiler/hbfix.c
  * harbour/source/compiler/hbpcode.c
  * harbour/source/compiler/hbdead.c
  * harbour/source/compiler/genc.c
  * harbour/source/compiler/gencc.c
  * harbour/source/compiler/hblbl.c
  * harbour/source/compiler/hbstripl.c
  * harbour/source/compiler/hbopt.c
    + added new PCODE HB_P_PUSHTIMESTAMP (replaced one unused PCODE value)
      to store timestamp constant values in the PCODE

  * harbour/include/hbcomp.h
  * harbour/source/compiler/hbmain.c
    + added new function:
      void hb_compGenPushTimeStamp( LONG lDate, LONG lTime, HB_COMP_DECL );

  * harbour/include/hbexprop.h
  * harbour/source/common/expropt1.c
    + added new C functions:
      HB_EXPR_PTR hb_compExprNewTimeStamp( LONG, LONG, HB_COMP_DECL );

  * harbour/include/hbexprb.c
  * harbour/include/hbcompdf.h
  * harbour/source/common/expropt2.c
    + added timestamp expressions support
    + added compile time optimization for timestamp expressions
    * updated function optimization for timestamp expressions

  * harbour/include/hbdate.h
  * harbour/source/common/hbdate.c
    * changed hb_dateMilliSeconds() to return UTC julian timestamp in
      milliseconds
    * changed existing seconds, time and timestamp functions to operate
      on common OS specific functions to eliminate possible problems
      with different OS time counters
    + added new functions to operates on time and timestamp values.
      See source code for details.

  + harbour/source/rtl/cputime.c
    * moved double hb_secondsCPU( int n ) function to separate file

  * harbour/source/rtl/seconds.c
    - removed old version of date/seconds functions

  * harbour/source/vm/hashes.c
  * harbour/source/vm/arrays.c
    + added support for timestamp values as hash item indexes

  * harbour/source/vm/hashfunc.c
    + added support for find timestamp values in hash and array items
      by simple date value in AScan(), hb_HScan(), hb_AScan() and hb_RAScan()
      functions when exact comparison is not used.

  * harbour/source/vm/asort.c
    + added support for sorting timestamp values

  * harbour/source/vm/classes.c
    + added support for timestamp scallar classes
    + added support for timestamp typed instance variables

  * harbour/source/vm/memvars.c
    + added support for timestamp values in .mem files

  * harbour/source/vm/estack.c
    + show timestamp values in stack dump

  * harbour/include/hbapi.h
  * harbour/source/vm/arrays.c
    + added new C functions:
      double hb_arrayGetTD( PHB_ITEM pArray, ULONG ulIndex );
      BOOL hb_arraySetTD( PHB_ITEM pArray, ULONG ulIndex, double dTimeStamp )
      BOOL hb_arrayGetTDT( PHB_ITEM pArray, ULONG ulIndex,
                           LONG * plJulian, LONG * plMilliSec );
      BOOL hb_arraySetTDT( PHB_ITEM pArray, ULONG ulIndex,
                           LONG lJulian, LONG lMilliSec );

  * harbour/include/hbapi.h
  * harbour/source/vm/extend.c
    + accept timestamp items in date functions - use only date part of
      timestamp value
    + added new C functions:
      double hb_partd( int iParam, ... );
      BOOL hb_partdt( LONG * plJulian, LONG * plMilliSec , int iParam, ... );
      void hb_rettd( double dTimeStamp );
      void hb_rettdt( LONG lJulian, LONG lMilliSec );
      int hb_stortd( double dTimeStamp, int iParam, ... );
      int hb_stortdt( LONG lJulian, LONG lMilliSec, int iParam, ... );

  * harbour/include/hbapiitm.h
  * harbour/source/vm/itemapi.c
    + accept timestamp items in date functions - use only date part of
      timestamp value
    + added new C functions:
      char * hb_itemGetTS( PHB_ITEM pItem, char * szDateTime );
      PHB_ITEM hb_itemPutTS( PHB_ITEM pItem, const char * szDateTime );
      double hb_itemGetTD( PHB_ITEM pItem );
      PHB_ITEM hb_itemPutTD( PHB_ITEM pItem, double dTimeStamp )
      BOOL hb_itemGetTDT( PHB_ITEM pItem, LONG * plJulian, LONG * plMilliSec );
      PHB_ITEM hb_itemPutTDT( PHB_ITEM pItem, LONG lJulian, LONG lMilliSec );
    + support for timestamp items in hb_itemString(), hb_itemPadConv() and
      hb_itemTypeStr() functions

  * harbour/include/hbvm.h
  * harbour/include/hbxvm.h
  * harbour/include/hbapi.h
  * harbour/source/vm/hvm.c
    + added HB_IT_TIMESTAMP items
    * modified HB_IT_DATE internal item structure to use common structure
      with HB_IT_TIMESTAMP - it  simplifies HVM code and eliminates additional
      RT conditions.
    + added HB_IS_TIMESTAMP() and ISTIMESTAMP() macros
    + added HB_IS_DATETIME() and ISDATETIME() macros - they return true
      if item/parameter is DATE or TIMESTAMP type.
    + added void hb_vmPushTimeStamp( long lJulian, long lMilliSec );
      and xhb_vmPushTimeStamp()
    + added support for timestamp values in relational operators:
         <, <=, >, >=, =, ==
      When two timestamp values are compared then VM compares date and
      time parts in both values.
      When date and timestamp values are used in <, <=, >, >=, = operations
      then VM compares only date part in both values.
      When date and timestamp values are used in == operation then VM
      compares date part in both values and then check if time part
      of timestamp value is 0.
    + added support for timestamp values in + and - math operations.
      The following rules are used in timestamp arithmetic:
         <t> + <t> => <t>
         <t> - <t> => <n>
         <t> + <n> => <t>
         <n> + <t> => <t>
         <t> - <n> => <t>
         <d> + <t> => <t>
         <t> + <d> => <t>
         <d> - <t> => <n>
         <t> - <d> => <n>
      When number is result or argument of timestamp operation then the
      its integer part is a number of day and fractional part is the time.

  * harbour/source/rtl/dateshb.c
    + added new .prg functions to mange date and timestamp values:
      HB_DATETIME() -> <tTimeStamp>
      HB_CTOD( <cDate> [, <cDateFormat> ] ) -> <dDate>
      HB_DTOC( <dDate> [, <cDateFormat> ] ) -> <cDate>
      HB_NTOT( <nValue> ) -> <tTimeStamp>
      HB_TTON( <tTimeStamp> ) -> <nValue>
      HB_TTOC( <tTimeStamp>, [ <cDateFormat> ] [, <cTimeFormat> ] ) ->
                                                            <cTimeStamp>
      HB_CTOT( <cTimeStamp>, [ <cDateFormat> ] [, <cTimeFormat> ] ) ->
                                                            <tTimeStamp>
      HB_TTOS( <tTimeStamp> ) -> <cYYYYMMDDHHMMSSFFF>
      HB_STOT( <cDateTime> ) -> <tTimeStamp>
         <cDateTime> should be in one of the above form:
            - "YYYYMMDDHHMMSSFFF"
            - "YYYYMMDDHHMMSSFF"
            - "YYYYMMDDHHMMSSF"
            - "YYYYMMDDHHMMSS"
            - "YYYYMMDDHHMM"
            - "YYYYMMDDHH"
            - "YYYYMMDD"
            - "HHMMSSFFF"
            - "HHMMSSF"
            - "HHMMSS"
            - "HHMM"
            - "HH"
         Important is number of digits.
      HB_TSTOSTR( <tTimeStamp> ) -> <cTimeStamp> // YYYY-MM-DD HH:MM:SS.fff
      HB_STRTOTS( <cTimeStamp> ) -> <tTimeStamp>
         <cTimeStamp> should be in one of the above form:
            YYYY-MM-DD [H[H][:M[M][:S[S][.f[f[f[f]]]]]]] [PM|AM]
            YYYY-MM-DDT[H[H][:M[M][:S[S][.f[f[f[f]]]]]]] [PM|AM]
         The folowing characters can be used as date delimiters: "-", "/", "."
         T - is literal "T" - it's for XML timestamp format
         if PM or AM is used HH is in range < 1 : 12 > otherwise
         in range < 0 : 23 >
      HB_HOUR( <tTimeStamp> ) -> <nHour>
      HB_MINUTE( <tTimeStamp> ) -> <nMinute>
      HB_SEC( <tTimeStamp> ) -> <nSeconds>   // with milliseconds

  * harbour/source/rtl/datec.c
    + accept timestamp parameters in CMONTH() and CDOW() functions

  * harbour/source/rtl/empty.c
    + added support for timestamp items

  * harbour/source/rtl/itemseri.c
    + added support for timestamp items serialization

  * harbour/source/rtl/minmax.c
    + added support for timestamp values to MIN() and MAX() functions.
      when only one of given parameters is timestamp value and other
      is date value and date parts are equal then always date item
      is returned as both MIN() or MAX() value.

  * harbour/source/rtl/dates.c
    + added new C functions: hb_timeFormat(), hb_timeUnformat(),
      hb_timeStampFormat(), hb_timeStampUnformat()

  * harbour/source/rtl/valtype.c
    + added .prg functions: HB_ISDATETIME(), HB_ISTIMESTAMP()

  * harbour/source/rtl/transfrm.c
    + added support for timestamp items formatting.
    + added new function modifier @T.
      When @T is used without @D then only time part of timestamp value
      is formatted and return.
      When @D is used without @T then only date part of timestamp value
      is formatted and return.

  * harbour/source/rtl/tbrowse.prg
    + display timestamp values

  * harbour/source/rtl/philes.c
    + accept timestamp value as second parameter of HB_FSETDATETIME()
      function
    + store file data and time in second parameter of HB_FGETDATETIME()
      as timestamp value.
    Old parameters (2-dDate, 3-cTime) are still supported but please think
    about removing them - they are redundant.

  * harbour/source/rtl/filesys.c
    * updated function names


  * harbour/source/rdd/dbf1.c
    + added native support for time and timestamp fields

  * harbour/include/hbrddcdx.h
  * harbour/include/hbrddnsx.h
  * harbour/source/rdd/dbfntx/dbfntx1.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
  * harbour/source/rdd/dbfnsx/dbfnsx1.c
  * harbour/source/rdd/dbffpt/dbffpt1.c
    + added support for indexing timestamp fields
    + added support for using DATE values with timestamp fields
      which replicate HVM behavior.
      SEEK and SEEKLAST with date value when active index is on
      timestamp positions to 1-st or last record where date part
      of indexed timesamp value is equal.
      Settings scopes to date values when active index is on timestamp
      value reduce the visible record range to these ones which have
      date part of timestamp value in the range of dates values used
      for scopes. It possible to mix date and timestamp values in scope
      and set one scope to date value and the second to timesamp.

  * harbour/source/rdd/sdf1.c
  * harbour/source/rdd/delim1.c
    + added support for exporting timestamp fields

  * harbour/source/rdd/dbsql.c
    ! fixed typo in logical value export
    + export timestamp fields.
      Please update the format to given SQL syntax.


  * harbour/contrib/hbct/files.c
    + changed SETFDATI() to optionally accept timestamp parameter
      instead of two parameters dDate and cTime

  * harbour/contrib/hbct/misc1.c
    + added timestamp support to XTOC() function

  * harbour/contrib/hbct/misc2.c
    + added timestamp support to COMPLEMENT() function

  * harbour/contrib/hbct/dattime2.c
    + accept timestamp values in ADDMONTH(), DOY(), ISLEAP(), QUARTER()
      LASTDAYOM(), WEEK() functions

  * harbour/contrib/hbmzip/hbmzip.c
    + updated HB_ZipFileCreate( hZip, cZipName, tDateTime, cTime, ... )
      functions to optionaly accept timestamp value in 3-rd parameter
      instead od dDate, and cTime in 3-rd and 4-th parameters.
    + updated HB_UnzipFileInfo( hUnzip, @cZipName, @tDateTime, @cTime, ... )
      to return timestamp value in 3-rd parameter instead of date value.
      TODO: Please think about removing 4-th parameter from:
               HB_ZipFileCreate( hZip, cZipName, tDateTime, cTime, ... )
               HB_UnzipFileInfo( hUnzip, @cZipName, @tDateTime, @cTime, ... )
            Now it's redundant.
  * harbour/contrib/hbmzip/readme.txt
    * updated parameters description for above functions

  * harbour/contrib/hbnf/descendn.c
    + added timestamp support to FT_DESCEND() function

  * harbour/contrib/hbclipsm/date.c
    + accept timestamp values in DATEASAGE(), DATEASARRAY() and DATEISLEAP()
      functions

  * harbour/contrib/hbmisc/dates2.c
    + accept timestamp values in ISLEAPYEAR(), DAYSINMONTH(), EOM(), BOM(),
      WOM(), WOY(), EOY() and BOY() functions


   The following contrib files should be updated but I'm leaving it to
   other developers who want to keep this code alive:
         contrib/hbtip/utils.c
         contrib/hbvpdf/hbvpdf.prg
         contrib/hbvpdf/hbvpdft.prg
         contrib/hbwin/win_dll.c
            some minor cleanups if necessary and authors will find
            timestamp values usable

         contrib/hbole/ole2.c
         contrib/hbwin/win_ole.c
            add support for timestamp values in OLE

         contrib/rddado/adordd.prg
         contrib/rddads/ads1.c
         contrib/rddads/adsx.c
         contrib/rddsql/...
            add support for timestamp values in RDDs

   Warning: this implementation is not xHarbour compatible. There are many
   important differences. Mostly on C level and used API. Please be careful
   in porting xHarbour source code to Harbour.
2009-03-21 15:04:43 +00:00

1484 lines
37 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* The Extend API
*
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
*
* Copyright 1999-2001 Viktor Szakats <viktor.szakats@syenar.hu>
* hb_retnlen()
* hb_retnilen()
* hb_retnllen()
* hb_retndlen()
* hb_retdl()
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* hb_retd()
*
* See doc/license.txt for licensing terms.
*
*/
#include "hbvmopt.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbset.h"
#include "hbdate.h"
#include "hbstack.h"
/* NOTE: iParam = -1 can be used to access the return value. */
/* NOTE: iParam = 0 can be used to access the SELF object. */
PHB_ITEM hb_param( int iParam, long lMask )
{
HB_TRACE(HB_TR_DEBUG, ("hb_param(%d, %ld)", iParam, lMask));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
if( pItem->type & HB_IT_BYREF )
{
pItem = hb_itemUnRef( pItem );
if( ( HB_TYPE ) lMask == HB_IT_BYREF )
return pItem;
}
if( ( pItem->type & ( HB_TYPE ) lMask ) || ( HB_TYPE ) lMask == HB_IT_ANY )
return pItem;
}
return NULL;
}
PHB_ITEM hb_paramError( int iParam )
{
static HB_ITEM s_NIL;
PHB_ITEM pParam = hb_param( iParam, HB_IT_ANY );
if( pParam == NULL )
{
hb_itemClear( &s_NIL );
pParam = &s_NIL;
}
return pParam;
}
/* function to be called from pcode DLLs to detect if the extend system
* is going to use an array item */
BOOL hb_extIsArray( int iParam )
{
PHB_ITEM pItem;
if( iParam == -1 )
pItem = hb_stackReturnItem();
else if( iParam >= 0 && iParam <= hb_pcount() )
pItem = hb_stackItemFromBase( iParam );
else
return FALSE;
if( HB_IS_BYREF( pItem ) )
pItem = hb_itemUnRef( pItem );
return HB_IS_ARRAY( pItem ) && !HB_ARRAY_OBJ( pItem );
}
/* function to be called from pcode DLLs to detect if the extend system
* is going to use an object item */
BOOL hb_extIsObject( int iParam )
{
PHB_ITEM pItem;
if( iParam == -1 )
pItem = hb_stackReturnItem();
else if( iParam >= 0 && iParam <= hb_pcount() )
pItem = hb_stackItemFromBase( iParam );
else
return FALSE;
if( HB_IS_BYREF( pItem ) )
pItem = hb_itemUnRef( pItem );
return HB_IS_OBJECT( pItem );
}
/* NOTE: Caller should not modify the buffer returned by this function.
[vszakats] */
char * hb_parc( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parc(%d, ...)", iParam));
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_STRING( pItem ) )
return pItem->item.asString.value;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetCPtr( pItem, ulArrayIndex );
}
}
return ( char * ) NULL;
}
char * hb_parcx( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parcx(%d, ...)", iParam));
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_STRING( pItem ) )
return pItem->item.asString.value;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetCPtr( pItem, ulArrayIndex );
}
}
return ( char * ) "";
}
ULONG hb_parclen( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parclen(%d, ...)", iParam));
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_STRING( pItem ) )
return pItem->item.asString.length;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetCLen( pItem, ulArrayIndex );
}
}
return 0;
}
/* NOTE: Similar to _parclen() but returns the length including the
terminating zero byte, and it only works for parameters passed by
reference. [vszakats] */
ULONG hb_parcsiz( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parcsiz(%d, ...)", iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
/* NOTE: hb_parcsiz() will only work for strings passed by reference.
CA-Cl*pper works like this. [vszakats] */
if( HB_IS_BYREF( pItem ) )
{
pItem = hb_itemUnRef( pItem );
if( HB_IS_STRING( pItem ) )
return pItem->item.asString.length + 1;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetCLen( pItem, ulArrayIndex ) + 1;
}
}
}
return 0;
}
/* NOTE: Using hb_stackDateBuffer() a temporary date buffer guaranties
good behavior when multithreading. */
char * hb_pards( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_pards(%d, ...)", iParam));
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_DATETIME( pItem ) )
return hb_dateDecStr( hb_stackDateBuffer(), pItem->item.asDateTime.julian );
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetDS( pItem, ulArrayIndex, hb_stackDateBuffer() );
}
}
return hb_dateDecStr( hb_stackDateBuffer(), 0 );
}
/* NOTE: szDate must be a 9 chars wide buffer. [vszakats] */
char * hb_pardsbuff( char * szDate, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_pardsbuff(%p, %d, ...)", szDate, iParam));
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_DATETIME( pItem ) )
return hb_dateDecStr( szDate, pItem->item.asDateTime.julian );
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetDS( pItem, ulArrayIndex, szDate );
}
}
return hb_dateDecStr( szDate, 0 );
}
/* retrieve a date as long integer - number of days from Julian's day */
LONG hb_pardl( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_pardl(%d, ...)", iParam));
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_DATETIME( pItem ) )
{
return pItem->item.asDateTime.julian;
}
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetDL( pItem, ulArrayIndex );
}
}
return hb_itemGetDL( NULL );
}
double hb_partd( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_partd(%d, ...)", iParam));
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_DATETIME( pItem ) )
{
return hb_timeStampPackDT( pItem->item.asDateTime.julian,
pItem->item.asDateTime.time );
}
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetTD( pItem, ulArrayIndex );
}
}
return 0;
}
BOOL hb_partdt( LONG * plJulian, LONG * plMilliSec , int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_partdt(%p,%p,%d, ...)", plJulian, plMilliSec, iParam));
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_DATETIME( pItem ) )
{
*plJulian = pItem->item.asDateTime.julian;
*plMilliSec = pItem->item.asDateTime.time;
return TRUE;
}
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetTDT( pItem, ulArrayIndex, plJulian, plMilliSec );
}
}
return FALSE;
}
int hb_parl( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parl(%d, ...)", iParam));
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_LOGICAL( pItem ) )
return pItem->item.asLogical.value ? 1 : 0;
else if( HB_IS_INTEGER( pItem ) )
return pItem->item.asInteger.value != 0 ? 1 : 0;
else if( HB_IS_LONG( pItem ) )
return pItem->item.asLong.value != 0 ? 1 : 0;
else if( HB_IS_DOUBLE( pItem ) )
return pItem->item.asDouble.value != 0.0 ? 1 : 0;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetL( pItem, ulArrayIndex ) ? 1 : 0;
}
}
return 0;
}
double hb_parnd( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parnd(%d, ...)", iParam));
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_DOUBLE( pItem ) )
return pItem->item.asDouble.value;
else if( HB_IS_INTEGER( pItem ) )
return ( double ) pItem->item.asInteger.value;
else if( HB_IS_LONG( pItem ) )
return ( double ) pItem->item.asLong.value;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetND( pItem, ulArrayIndex );
}
}
return 0;
}
int hb_parni( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parni(%d, ...)", iParam));
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 ) )
return ( int ) pItem->item.asDouble.value;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetNI( pItem, ulArrayIndex );
}
}
return 0;
}
long hb_parnl( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parnl(%d, ...)", iParam));
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
/* DATETIME TODO: remove it */
else if( HB_IS_DATETIME( pItem ) )
return ( long ) pItem->item.asDateTime.julian;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetNL( pItem, ulArrayIndex );
}
}
return 0;
}
#ifndef HB_LONG_LONG_OFF
LONGLONG hb_parnll( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parnll(%d, ...)", iParam));
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 ( LONGLONG ) pItem->item.asLong.value;
else if( HB_IS_INTEGER( pItem ) )
return ( LONGLONG ) pItem->item.asInteger.value;
else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
return ( LONGLONG ) ( ULONGLONG ) pItem->item.asDouble.value;
#else
return ( LONGLONG ) pItem->item.asDouble.value;
#endif
/* DATETIME TODO: remove it */
else if( HB_IS_DATETIME( pItem ) )
return ( LONGLONG ) pItem->item.asDateTime.julian;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetNLL( pItem, ulArrayIndex );
}
}
return 0;
}
#endif
HB_LONG hb_parnint( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parnint(%d, ...)", iParam));
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 ( HB_LONG ) pItem->item.asLong.value;
else if( HB_IS_INTEGER( pItem ) )
return ( HB_LONG ) pItem->item.asInteger.value;
else if( HB_IS_DOUBLE( pItem ) )
#ifdef __GNUC__
return ( HB_LONG ) ( HB_ULONG ) pItem->item.asDouble.value;
#else
return ( HB_LONG ) pItem->item.asDouble.value;
#endif
/* DATETIME TODO: remove it */
else if( HB_IS_DATETIME( pItem ) )
return ( HB_LONG ) pItem->item.asDateTime.julian;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetNInt( pItem, ulArrayIndex );
}
}
return 0;
}
void * hb_parptr( int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parptr(%d, ...)", iParam));
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_POINTER( pItem ) )
return pItem->item.asPointer.value;
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
return hb_arrayGetPtr( pItem, ulArrayIndex );
}
}
return NULL;
}
void * hb_parptrGC( HB_GARBAGE_FUNC_PTR pFunc, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parptrGC(%p,%d, ...)", pFunc, iParam));
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_POINTER( pItem ) )
{
if( pItem->item.asPointer.collect &&
hb_gcFunc( pItem->item.asPointer.value ) == pFunc )
return pItem->item.asPointer.value;
}
else if( HB_IS_ARRAY( pItem ) )
{
va_list va;
ULONG ulArrayIndex;
va_start( va, iParam );
ulArrayIndex = va_arg( va, ULONG );
va_end( va );
pItem = hb_arrayGetItemPtr( pItem, ulArrayIndex );
if( pItem && HB_IS_POINTER( pItem ) &&
pItem->item.asPointer.collect &&
hb_gcFunc( pItem->item.asPointer.value ) == pFunc )
return pItem->item.asPointer.value;
}
}
return NULL;
}
ULONG hb_parinfa( int iParamNum, ULONG uiArrayIndex )
{
PHB_ITEM pArray;
HB_TRACE(HB_TR_DEBUG, ("hb_parinfa(%d, %lu)", iParamNum, uiArrayIndex));
pArray = hb_param( iParamNum, HB_IT_ARRAY );
if( pArray )
{
if( uiArrayIndex == 0 )
return hb_arrayLen( pArray );
else
return ( long ) hb_arrayGetType( pArray, uiArrayIndex );
}
else
return 0;
}
ULONG hb_parinfo( int iParam )
{
HB_TRACE(HB_TR_DEBUG, ("hb_parinfo(%d)", iParam));
if( iParam == 0 )
return ( ULONG ) hb_pcount();
else
{
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
HB_TYPE uiType = HB_ITEM_TYPE( pItem );
if( uiType & HB_IT_BYREF )
uiType |= HB_ITEM_TYPE( hb_itemUnRef( pItem ) );
return ( ULONG ) uiType;
}
else
return 0;
}
}
#undef hb_ret
void hb_ret( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ret()"));
hb_itemClear( hb_stackReturnItem() );
}
#undef hb_reta
void hb_reta( ULONG ulLen ) /* undocumented hb_reta() */
{
HB_TRACE(HB_TR_DEBUG, ("hb_reta(%lu)", ulLen));
hb_arrayNew( hb_stackReturnItem(), ulLen );
}
#undef hb_retc
void hb_retc( const char * szText )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retc(%s)", szText));
hb_itemPutC( hb_stackReturnItem(), szText );
}
#undef hb_retc_null
void hb_retc_null( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retc_null()"));
hb_itemPutC( hb_stackReturnItem(), NULL );
}
#undef hb_retc_buffer
void hb_retc_buffer( char * szText )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retc_buffer(%s)", szText));
hb_itemPutCPtr2( hb_stackReturnItem(), szText );
}
#undef hb_retc_const
void hb_retc_const( const char * szText )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retc_const(%s)", szText));
hb_itemPutCConst( hb_stackReturnItem(), szText );
}
#undef hb_retclen
void hb_retclen( const char * szText, ULONG ulLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retclen(%s, %lu)", szText, ulLen));
hb_itemPutCL( hb_stackReturnItem(), szText, ulLen );
}
#undef hb_retclen_buffer
void hb_retclen_buffer( char * szText, ULONG ulLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retclen_buffer(%s, %lu)", szText, ulLen));
hb_itemPutCLPtr( hb_stackReturnItem(), szText, ulLen );
}
/* szDate must have YYYYMMDD format */
#undef hb_retds
void hb_retds( const char * szDate )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retds(%s)", szDate));
hb_itemPutDS( hb_stackReturnItem(), szDate );
}
#undef hb_retd
void hb_retd( int iYear, int iMonth, int iDay )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retd(%04i, %02i, %02i)", iYear, iMonth, iDay));
hb_itemPutD( hb_stackReturnItem(), iYear, iMonth, iDay );
}
#undef hb_retdl
void hb_retdl( long lJulian )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retdl(%ld)", lJulian));
hb_itemPutDL( hb_stackReturnItem(), lJulian );
}
#undef hb_rettd
void hb_rettd( double dTimeStamp )
{
HB_TRACE(HB_TR_DEBUG, ("hb_rettd(%lf)", dTimeStamp));
hb_itemPutTD( hb_stackReturnItem(), dTimeStamp );
}
#undef hb_rettdt
void hb_rettdt( LONG lJulian, LONG lMilliSec )
{
HB_TRACE(HB_TR_DEBUG, ("hb_rettdt(%ld, %ld)", lJulian, lMilliSec));
hb_itemPutTDT( hb_stackReturnItem(), lJulian, lMilliSec );
}
#undef hb_retl
void hb_retl( int iLogical )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retl(%d)", iLogical));
hb_itemPutL( hb_stackReturnItem(), iLogical ? TRUE : FALSE );
}
#undef hb_retnd
void hb_retnd( double dNumber )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnd(%lf)", dNumber));
hb_itemPutND( hb_stackReturnItem(), dNumber );
}
#undef hb_retni
void hb_retni( int iNumber )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retni(%d)", iNumber));
hb_itemPutNI( hb_stackReturnItem(), iNumber );
}
#undef hb_retnl
void hb_retnl( long lNumber )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnl(%ld)", lNumber));
hb_itemPutNL( hb_stackReturnItem(), lNumber );
}
#ifndef HB_LONG_LONG_OFF
#undef hb_retnll
void hb_retnll( LONGLONG llNumber )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnll(%" PFLL "d)", llNumber));
hb_itemPutNLL( hb_stackReturnItem(), llNumber );
}
#endif
#undef hb_retnint
void hb_retnint( HB_LONG lNumber )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnl(%" PFHL "d )", lNumber));
hb_itemPutNInt( hb_stackReturnItem(), lNumber );
}
#undef hb_retnlen
void hb_retnlen( double dNumber, int iWidth, int iDec )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnlen(%lf, %d, %d)", dNumber, iWidth, iDec));
hb_itemPutNLen( hb_stackReturnItem(), dNumber, iWidth, iDec );
}
#undef hb_retndlen
void hb_retndlen( double dNumber, int iWidth, int iDec )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retndlen(%lf, %d, %d)", dNumber, iWidth, iDec));
hb_itemPutNDLen( hb_stackReturnItem(), dNumber, iWidth, iDec );
}
#undef hb_retnilen
void hb_retnilen( int iNumber, int iWidth )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnilen(%d, %d)", iNumber, iWidth));
hb_itemPutNILen( hb_stackReturnItem(), iNumber, iWidth );
}
#undef hb_retnllen
void hb_retnllen( long lNumber, int iWidth )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnllen(%ld, %d)", lNumber, iWidth));
hb_itemPutNLLen( hb_stackReturnItem(), lNumber, iWidth );
}
#ifndef HB_LONG_LONG_OFF
#undef hb_retnlllen
void hb_retnlllen( LONGLONG llNumber, int iWidth )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnlllen(%" PFLL "d, %d)", llNumber, iWidth));
hb_itemPutNLLLen( hb_stackReturnItem(), llNumber, iWidth );
}
#endif
#undef hb_retnintlen
void hb_retnintlen( HB_LONG lNumber, int iWidth )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retnintlen(%" PFHL "d, %d)", lNumber, iWidth));
hb_itemPutNIntLen( hb_stackReturnItem(), lNumber, iWidth );
}
#undef hb_retptr
void hb_retptr( void * pointer )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retptr(%p)", pointer));
hb_itemPutPtr( hb_stackReturnItem(), pointer );
}
#undef hb_retptrGC
void hb_retptrGC( void * pointer )
{
HB_TRACE(HB_TR_DEBUG, ("hb_retptrGC(%p)", pointer));
hb_itemPutPtrGC( hb_stackReturnItem(), pointer );
}
int hb_storc( const char * szText, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_storc(%s, %d, ...)", szText, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetC( pItem, va_arg( va, ULONG ), szText ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutC( pItem, szText );
return 1;
}
}
return 0;
}
int hb_storclen( const char * szText, ULONG ulLen, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_storclen(%s, %lu, %d, ...)", szText, ulLen, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetCL( pItem, va_arg( va, ULONG ), szText, ulLen ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutCL( pItem, szText, ulLen );
return 1;
}
}
return 0;
}
int hb_storclen_buffer( char * szText, ULONG ulLen, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_storclen_buffer(%s, %lu, %d, ...)", szText, ulLen, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetCPtr( pItem, va_arg( va, ULONG ), szText, ulLen ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutCLPtr( pItem, szText, ulLen );
return 1;
}
}
return 0;
}
/* szDate must have YYYYMMDD format */
int hb_stords( const char * szDate, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stords(%s, %d, ...)", szDate, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetDS( pItem, va_arg( va, ULONG ), szDate ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutDS( pItem, szDate );
return 1;
}
}
return 0;
}
int hb_stordl( long lJulian, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stordl(%ld, %d, ...)", lJulian, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetDL( pItem, va_arg( va, ULONG ), lJulian ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutDL( pItem, lJulian );
return 1;
}
}
return 0;
}
int hb_stortd( double dTimeStamp, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stortd(%lf, %d, ...)", dTimeStamp, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetTD( pItem, va_arg( va, ULONG ), dTimeStamp ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutTD( pItem, dTimeStamp );
return 1;
}
}
return 0;
}
int hb_stortdt( LONG lJulian, LONG lMilliSec, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stortd(%ld, %ld, %d, ...)", lJulian, lMilliSec, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetTDT( pItem, va_arg( va, ULONG ), lJulian, lMilliSec ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutTDT( pItem, lJulian, lMilliSec );
return 1;
}
}
return 0;
}
int hb_storl( int iLogical, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_storl(%d, %d, ...)", iLogical, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetL( pItem, va_arg( va, ULONG ), iLogical ? TRUE : FALSE ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutL( pItem, iLogical ? TRUE : FALSE );
return 1;
}
}
return 0;
}
int hb_storni( int iValue, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_storni(%d, %d, ...)", iValue, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetNI( pItem, va_arg( va, ULONG ), iValue ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutNI( pItem, iValue );
return 1;
}
}
return 0;
}
int hb_stornl( long lValue, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stornl(%ld, %d, ...)", lValue, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetNL( pItem, va_arg( va, ULONG ), lValue ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutNL( pItem, lValue );
return 1;
}
}
return 0;
}
#ifndef HB_LONG_LONG_OFF
int hb_stornll( LONGLONG llValue, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stornll(%" PFLL "d, %d, ...)", llValue, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetNLL( pItem, va_arg( va, ULONG ), llValue ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutNLL( pItem, llValue );
return 1;
}
}
return 0;
}
#endif
int hb_stornint( HB_LONG lValue, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stornint(%" PFHL "d, %d, ...)", lValue, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetNInt( pItem, va_arg( va, ULONG ), lValue ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutNInt( pItem, lValue );
return 1;
}
}
return 0;
}
int hb_stornd( double dNumber, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_stornd(%lf, %d, ...)", dNumber, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetND( pItem, va_arg( va, ULONG ), dNumber ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutND( pItem, dNumber );
return 1;
}
}
return 0;
}
int hb_storptr( void * pointer, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_storptr(%p, %d, ...)", pointer, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetPtr( pItem, va_arg( va, ULONG ), pointer ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutPtr( pItem, pointer );
return 1;
}
}
return 0;
}
int hb_storptrGC( void * pointer, int iParam, ... )
{
HB_TRACE(HB_TR_DEBUG, ("hb_storptrGC(%p, %d, ...)", pointer, iParam));
if( iParam >= -1 && iParam <= hb_pcount() )
{
PHB_ITEM pItem = ( iParam == -1 ) ? hb_stackReturnItem() : hb_stackItemFromBase( iParam );
BOOL bByRef = HB_IS_BYREF( pItem );
if( bByRef )
pItem = hb_itemUnRef( pItem );
if( HB_IS_ARRAY( pItem ) )
{
int iRetVal;
va_list va;
va_start( va, iParam );
iRetVal = hb_arraySetPtrGC( pItem, va_arg( va, ULONG ), pointer ) ? 1 : 0;
va_end( va );
return iRetVal;
}
else if( bByRef || iParam == -1 )
{
hb_itemPutPtrGC( pItem, pointer );
return 1;
}
}
return 0;
}
#undef hb_pcount
int hb_pcount( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_pcount()"));
return ( int ) ( hb_stackBaseItem() )->item.asSymbol.paramcnt;
}