Files
harbour-core/harbour/contrib/rdd_ads/adsfunc.c
Przemyslaw Czerpak a290c984e7 2006-02-04 17:05 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/harbour.spec
  * harbour/make_bsd.sh
  * harbour/make_drw.sh
  * harbour/make_gnu.sh
  * harbour/make_rpm.sh
  * harbour/make_tgz.sh
  * harbour/bin/hb-func.sh
  * harbour/bin/pack_src.sh
  * harbour/config/c.cf
  * harbour/config/global.cf
  * harbour/config/rules.cf
  * harbour/config/darwin/gcc.cf
  * harbour/config/darwin/global.cf
  * harbour/config/dos/djgpp.cf
  * harbour/config/dos/global.cf
  * harbour/config/dos/install.cf
  * harbour/config/dos/owatcom.cf
  * harbour/config/hpux/gcc.cf
  * harbour/config/hpux/global.cf
  * harbour/config/linux/gcc.cf
  * harbour/config/linux/global.cf
  * harbour/config/linux/owatcom.cf
  * harbour/config/sunos/gcc.cf
  * harbour/config/w32/watcom.cf
    * include ADSRDD by default in RPMs
    * updated for new RPM which does not accept some old tags
    * set -fPIC on 64bit platforms
    + added /etc/harbour/hb-charmap.def
    * updated for new GT system and drivers

  * harbour/contrib/dot/pp.prg
  * harbour/contrib/dot/pp_harb.ch
    * use _APMAIN as startup function
    * cleaned direct access to item internals

  * harbour/contrib/libct/Makefile
  + harbour/contrib/libct/ctwfunc.c
  + harbour/contrib/libct/ctwin.c
  + harbour/contrib/libct/ctwin.h
    * added CT3 like Window System - it's a GT driver which inherits
      from the existing one and adds CTW functionality

  * harbour/contrib/libct/screen1.c
    * updated for GTAPI modifications

  * harbour/contrib/libnf/Makefile
  * harbour/contrib/libnf/chdir.c
  * harbour/contrib/libnf/mkdir.c
  * harbour/contrib/libnf/rmdir.c
    * use hb_fs*() API functions instead of calling DOS interrupts
      Now NF dir functions works on all platforms - it will be nice
      to update other functions too.

  * harbour/contrib/libnf/dispc.c
  * harbour/contrib/libnf/ftattr.c
    * updated for GT API modifications, some of this code still depends
      on EGA/VGA video buffer so will work only if user will force in GT
      using it - it will be nice to rewrite them

  * harbour/contrib/odbc/odbc.c
  * harbour/contrib/ole/ole2.c
    * casting and cleaning direct access to item internals

  * harbour/contrib/rdd_ads/ads1.c
  * harbour/contrib/rdd_ads/adsfunc.c
  * harbour/contrib/rdd_ads/adsmgmnt.c
    * synced with xHarbour

  * harbour/include/Makefile
    * added new header files

  + harbour/include/hbgtinfo.ch
    + added GTI_* defintions for hb_gtInfo() function.
      This function works in similar way to dbInfo() in RDD.
      The GTI_* definitions are taken from xHarbour "as is" and
      they should be cleaned - not all functionality are supported
      in Harbour and some others should be implemented in differ
      way then in xHarbour.

  + harbour/include/hbgtcore.h
  * harbour/include/hbapigt.h
    * new GTAPI
      hbgtcore.h file should not be included by user code
      it's only for internal use in GT drivers
    * HB_inkey_enum changed to int - this is bit field not enumerated type.
      Many of C/C++ compilers forbid bit operations on enum types and
      forcing it by casting which finally exceeds the enum range is defined
      as bug because it may badly interacts with some compiler optimizations

  * harbour/include/hbapi.h
  * harbour/include/hbapicdp.h
  * harbour/include/hbapierr.h
  * harbour/include/hbapifs.h
  * harbour/include/hbapiitm.h
  * harbour/include/hbapilng.h
  * harbour/include/hbapirdd.h
  * harbour/include/hbdate.h
  * harbour/include/hbdefs.h
  * harbour/include/hbinit.h
  * harbour/include/hbpcode.h
  * harbour/include/hbrdddbf.h
  * harbour/include/hbset.h
  * harbour/include/hbstack.h
  * harbour/include/hbvm.h
  * harbour/include/hbvmopt.h
  * harbour/include/hbvmpub.h
    * separated internal and external API. Now the definitions for
      internal HVM structures and functions are excluded by default
      they could be enabled if user include hbvmopt.h before other
      header files. Such operation should be done _ONLY_ by core
      code - if 3-rd party developers make sth like that then it's
      for their own risk and such code may stop to work with next
      Harbour versions. Without hbvmopt.h the internal structures
      like HB_ITEM, HB_DYNS, ... are  mapped to 'void' so there is
      no way to access their members so we can modify them in the
      future without afford for 3-rd party code.
      There is one small exception 'type' should be the first member
      for HB_ITEM structure because I used a small ugly hack in
      HB_IS_*() macros with castin PHB_ITEM to HB_TYPE* - it works
      without speed overhead but if you think that it will be
      better/cleaner to not use such tricks then it's enough to
      change HB_ITEM_TYPE() definitions in hbvmpub.h - see note.
    * cleared the usage of HB_EXPORT - to avoid problems with some C/C++
      compilers we agreed that the only one common way of using HB_EXPORT
      is adding it ad begining of declaration - please keep this convention
      in the future.
    + added new functions:
      hb_extIsObject(), hb_codeblockId(), hb_idleSleep(),
      hb_fsGetOsHandle(),
      hb_dynsymFindSymbol(), hb_dynsymGetSymbol(),
      hb_dynsymSymbol(), hb_dynsymName(),
      hb_dynsymMemvarHandle(), hb_dynsymAreaHandle(), hb_dynsymSetAreaHandle()
    * changed hb_arrayClone() declaration to:
         PHB_ITEM hb_arrayClone( PHB_ITEM pArray )
    * changed hb_arrayFromParams() declaration to:
         PHB_ITEM hb_arrayFromParams( int iLevel )
      The previous version needed a pointer to stack relocatable area
      so any stack resizing could cause GPF.

  * harbour/include/inkey.ch
    * added definitions for extended mouse keys/events and some key
      combinations

  * harbour/source/codepage/uc1250.c
  * harbour/source/codepage/uc1251.c
  * harbour/source/codepage/uc1253.c
  * harbour/source/codepage/uc1257.c
  * harbour/source/codepage/uc737.c
  * harbour/source/codepage/uc850.c
  * harbour/source/codepage/uc852.c
  * harbour/source/codepage/uc866.c
  * harbour/source/codepage/uc88591b.c
  * harbour/source/codepage/uc8859_1.c
  * harbour/source/codepage/uc8859_2.c
  * harbour/source/codepage/uc8859_5.c
  * harbour/source/codepage/uckoi8.c
  * harbour/source/codepage/uckoi8u.c
  * harbour/source/codepage/ucmaz.c
    * updated unicode values for characters in rabge 1-31 to keep
      DOS compatibility

  * harbour/source/common/expropt1.c
  * harbour/source/common/hbarch.c
  * harbour/source/common/hbdate.c
  * harbour/source/common/hbstr.c
  * harbour/source/common/hbver.c
    * keep HB_EXPORT at the beginning of function declaration

  * harbour/include/hbpcode.h
  * harbour/include/hbcomp.h
  * harbour/source/compiler/harbour.c
  * harbour/source/compiler/harbour.y
  * harbour/source/compiler/hbfix.c
  + harbour/source/compiler/hbdead.c
  * harbour/source/compiler/hbpcode.c
  + harbour/source/compiler/hbstripl.c
    % rewritten jump optimization
      ! fixed some minor problems
      * do not optimize jumps and local variable access by shorter
        PCODE version and HB_P_NOOP when jump optimization is
        disabled, this is a note I left in source code in few places:
         /*
          * optimizing jumps here by shorting them and setting HB_P_NOOPs
          * only slow down the compilation process for three reasons:
          * 1. When it's dummy jump to next instruction we need two passes
          *    in hb_compOptimizeJumps() to fully remove it
          * 2. hb_compOptimizeJumps() also make jump shortcutting in each pass
          * 3. When Jump Optimization is disabled (-kJ) then it cause slowness
          *    at runtime because we will have more HVM loops: first  for the
          *    shorter jump and next for the HB_P_NOOP PCODE(s)
          * [druzuz]
          */

      + added support for multi passes in jump/dead code elimination
        (hb_compOptimizeJumps())
        By default is set upto three passes.
        Now hb_compOptimizeJumps() keeps all compiler internal data clean
        on exist and can be called any times and does not change other
        compiler's functions behaviors
      + added dummy jumps elimination
      + added optimization for:
            IF .T.
            IF .F.
            WHILE .T.
            WHILE .F.
         etc.
      * restored empty BEGIN/RECOVER sequence block elimination
        if Jump Optimization is enabled then it marks the block
        with HB_P_NOOPS else it cut the generated PCODE
      + added dead code eliminator (new functions hb_compCodeTraceMarkDead()/
        hb_compPCodeTrace() - it works only when Jump Optimization is
        not disabled)
      As a result of the above we have smaller and faster PCODE.

      I do not think that we will have meta code support in the reasonable
      time and because I need some valid compiler data/structures like
      updated table of all jumps for real C code (not PCODE in .c files)
      generation then I decide to make some modifications and the above
      is in practice a side effect of this work.

  * harbour/source/rdd/dbcmd.c
  * harbour/source/rdd/dbf1.c
  * harbour/source/rdd/rddord.prg
  * harbour/source/rdd/workarea.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
  * harbour/source/rdd/dbffpt/dbffpt1.c
  * harbour/source/rdd/dbfntx/dbfntx1.c
  * harbour/source/rdd/nulsys/nulsys.c
    * synced with my modifications in xHarbour
    * updated for API modifications

  * harbour/source/rtl/Makefile
    + added gtsys.c, gtfunc.c, hbgtcore.c

  * harbour/source/rtl/accept.c
  * harbour/source/rtl/alert.prg
  * harbour/source/rtl/cdpapi.c
  * harbour/source/rtl/console.c
  * harbour/source/rtl/dates.c
  * harbour/source/rtl/do.c
  * harbour/source/rtl/errorapi.c
  * harbour/source/rtl/errorsys.prg
  * harbour/source/rtl/file.c
  * harbour/source/rtl/fserror.c
  * harbour/source/rtl/fstemp.c
  * harbour/source/rtl/hbffind.c
  * harbour/source/rtl/idle.c
  * harbour/source/rtl/math.c
  * harbour/source/rtl/oldclear.c
  * harbour/source/rtl/strmatch.c
  * harbour/source/rtl/strpeek.c
  * harbour/source/rtl/valtype.c
  * harbour/source/rtl/xsavescr.c
    * updated for API modifications
    * cleaned some compiler warnings

  * harbour/source/rtl/filesys.c
    + added hb_fsGetOsHandle()
    * updated for API modifications

  * harbour/source/rtl/gt.c
  * harbour/source/rtl/gtapi.c
  * harbour/source/rtl/gtapiu.c
  + harbour/source/rtl/gtfunc.c
  + harbour/source/rtl/gtsys.c
  + harbour/source/rtl/hbgtcore.c
  * harbour/source/rtl/inkey.c
  * harbour/source/rtl/maxrow.c
  * harbour/source/rtl/mouseapi.c
  * harbour/source/rtl/setcolor.c
  * harbour/source/rtl/setposbs.c
  * harbour/source/rtl/shadow.c
    * new GT API code

  * harbour/source/rtl/saverest.c
    * changed default behavior in SEVESCREEN/RESTSCREEN with parameters
      out of screen range to be Clipper compatible. Added last logical
      parameter to keep previous behavior for programs which begins to
      use it.

  * harbour/source/rtl/seconds.c
    * include missing header file to fix C++ compilation
    * make hb_secondsCPU global function

  * harbour/source/rtl/set.c
    * make HB_SET_TYPEAHEAD Clipper compatible

  * harbour/source/rtl/gtcgi/Makefile
  * harbour/source/rtl/gtcgi/gtcgi.c
  - harbour/source/rtl/gtcgi/mousecgi.c
    * rewritten for new GT API
      some detail behaviors has been changed but I think the current
      implementation is better for CGI programs output - please check
      and fix me if necessary

  * harbour/source/rtl/gtcrs/Makefile
  - harbour/source/rtl/gtcrs/charmap.prg
  + harbour/source/rtl/gtcrs/chrmap.c
  - harbour/source/rtl/gtcrs/debug.map
  - harbour/source/rtl/gtcrs/eterm.map
  * harbour/source/rtl/gtcrs/gtcrs.c
  + harbour/source/rtl/gtcrs/gtcrs.h
  + harbour/source/rtl/gtcrs/hb-charmap.def
  - harbour/source/rtl/gtcrs/kbdcrs.c
  - harbour/source/rtl/gtcrs/keymap.prg
  - harbour/source/rtl/gtcrs/linux.map
  - harbour/source/rtl/gtcrs/mousecrs.c
    * new GTCRS based on my xHarbour and Flagship curses code
      Please not that at runtime it looks for a file
      /etc/harbour/hb-charmap.def where user can fully tune output
      for his terminal. This file is included with proper path in
      binaries created by make_rpm.sh and make_tgz.sh
      Ryszard I've removed some of your extensions which are no longer
      necessary and some other (keyboard sequence redefinition) should
      be done in a little bit differ way. I would like to talk about it
      when you test current code.
      Added support for extended mouse keys (middle button and wheel).

  * harbour/source/rtl/gtdos/Makefile
  * harbour/source/rtl/gtdos/gtdos.c
  - harbour/source/rtl/gtdos/mousedos.c
    * rewritten for new GT API
      Fixed some small problems, finished mouse code which for DJGPP
      is fully Clipper compatible with real mouse SAVE/RESTORE code.
      For other compilers it should be updated depending on memory
      model and used DPMI driver (if any).

  * harbour/source/rtl/gtos2/Makefile
  * harbour/source/rtl/gtos2/gtos2.c
  - harbour/source/rtl/gtos2/mouseos2.c
    * rewritten for new GT API
      Fixed some problems and finished the mouse code.
      Please test it - I made all modifications without OS2 and
      I was not able to make any test. I'm interesting in information
      if it works and the speed difference - f.e. results from
      tests/vidtest.prg run with previous and current version.

  * harbour/source/rtl/gtpca/Makefile
  * harbour/source/rtl/gtpca/gtpca.c
  - harbour/source/rtl/gtpca/kbdos2.gcc
  - harbour/source/rtl/gtpca/mousepca.c
    * rewritten for new GT API
      and finished so now it's full functional GT driver
      I'm interesting in keyboard sequences used by PC-ANSI drivers
      in DOS so it will be possible to implement also support for
      extended keys input.

  * harbour/source/rtl/gtsln/Makefile
  * harbour/source/rtl/gtsln/gtsln.c
  + harbour/source/rtl/gtsln/gtsln.h
  * harbour/source/rtl/gtsln/kbsln.c
  * harbour/source/rtl/gtsln/keytrans.c
  * harbour/source/rtl/gtsln/mousesln.c
    * rewritten for new GT API basing on current xHarbour code
      added support for slang 1.4x patched for UNICODE (Debian
      patches used by most of current Linux distributions) and
      slang 2.x - It's unicode ready, tries to detect terminal mode
      (utf-8/iso) at startup and switch the internal logic to
      iso/unicode mode. When compiled with slang 1.4x or 2.x
      and terminal is in UTF-8 it can display all characters like
      in DOS if only used font have them or good fall-back table is
      loaded (f.e. the one created by QRCZAK)
      Added support for extended mouse keys (middle button and wheel).

  * harbour/source/rtl/gtstd/Makefile
  * harbour/source/rtl/gtstd/gtstd.c
  - harbour/source/rtl/gtstd/mousestd.c
    * rewritten for new GT API
      Now it can work as full screen GT driver redrawing the previous
      screen contents from internal GT core buffers. I run with this
      GT some of my programs and they work quite well ;-) of course
      without colors.

  * harbour/source/rtl/gtwin/Makefile
  * harbour/source/rtl/gtwin/gtwin.c
  - harbour/source/rtl/gtwin/mousewin.c
    * updated for new GT API

  + harbour/source/rtl/gtxwc/Makefile
  + harbour/source/rtl/gtxwc/gtxwc.c
  + harbour/source/rtl/gtxwc/gtxwc.h
    * new XWindow Console GT driver based on my and Giancarlo Niccolai
      code form xHarbour - this GT can work in XWindow environment only
      and create its own window for  console output. It delays the
      initialization to the moment when user try to display anything on
      the screen so even without X Window system programs which uses this
      GT can work as long as use only outstd/outerr output.

  * harbour/source/vm/arrays.c
    * updated for API modifications
    + added hb_arrayId(),
    * changed hb_arrayClone() declaration to:
         HB_EXPORT PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
    * changed hb_arrayFromParams() declaration to:
         PHB_ITEM hb_arrayFromParams( int iLevel )

  * harbour/source/vm/arrayshb.c
    * updated for API modifications
    + added new parameter iLevel to function HB_APARAMS()

  * harbour/source/vm/classes.c
  * harbour/source/vm/cmdarg.c
  * harbour/source/vm/dynlibhb.c
  * harbour/source/vm/estack.c
  * harbour/source/vm/fm.c
  * harbour/source/vm/garbage.c
  * harbour/source/vm/maindll.c
  * harbour/source/vm/maindllh.c
  * harbour/source/vm/maindllp.c
  * harbour/source/vm/mainstd.c
  * harbour/source/vm/mainwin.c
  * harbour/source/vm/memvars.c
  * harbour/source/vm/pcount.c
  * harbour/source/vm/proc.c
    * updated for API modifications

  * harbour/source/vm/codebloc.c
    * updated for API modifications
    + added hb_codeblockId()

  * harbour/source/vm/dynsym.c
    * updated for API modifications
    + added new functions:
      hb_dynsymFindSymbol(), hb_dynsymGetSymbol(),
      hb_dynsymSymbol(), hb_dynsymName(),
      hb_dynsymMemvarHandle(), hb_dynsymAreaHandle(), hb_dynsymSetAreaHandle()

  * harbour/source/vm/eval.c
    * updated for API modifications
    * call hb_vmPushState()/hb_vmPopState() in hb_itemDo()/hb_itemDoC()
      functions - it's necessary to make HVM reentrant safe.

  * harbour/source/vm/extend.c
    * updated for API modifications
    + added hb_extIsObject() similar to existing hb_extIsArray()

  * harbour/source/vm/hvm.c
    * updated for API modifications
    + added new functions: hb_vmPushState(), hb_vmPopState()
      which save/restore HVM state (the top stack value which can be
      processed and return item and maybe sth else in the future) making
      HVM ready for reentrant.

  * harbour/source/vm/itemapi.c
    * updated for API modifications
    + added new function:
         HB_EXPORT PHB_SYMB hb_itemGetSymbol( PHB_ITEM pItem );
    ! fixed bug in hb_itemPutNInt()

  * harbour/tests/Makefile
  * harbour/utils/hbdoc/Makefile
  * harbour/utils/hbextern/Makefile
  * harbour/utils/hbmake/Makefile
  * harbour/utils/hbrun/Makefile
  * harbour/utils/hbtest/Makefile
    - removed badly added: dbfntx, dbfcdx, dbffpt, hbsix libraries.
      what broke GNU make compilation for some compilers
      This libraries should be included automatically when RDD lib
      is included by *.cf files

   Summary:
      The whole patch (cvs diff -uN) is ~1.5MB length and I cannot describe
      everything in details - sorry but it was too much modifications in
      one commit so now just some of general notes.
      The header files included as is does not have any information about
      internal HVM structures and some functions. In practice only HB_SYMB
      is public and it has to be public for .c files generated from .prg
      so I force the fixed size of this structure (alignment independent)
      by redefining some members to union with void * - it's a little bit
      ugly trick but it effectively eliminates the problem of linking
      binaries compiled with differ alignment C compiler switches.
      The structures like HB_ITEM, HB_CODEBLOCK, HB_STACK, HB_DYNS are not
      longer defined and pointers to the defined as void * - like in Clipper
      the ITEM structure. It caused that I had to add some new functions
      to make some operation still possible to implement. If I missed sth
      and any of you will have a problem with your code then please inform
      me about it and after a small discussion on Harbour developers list
      we can decide if other functions should be added.
      The internal API is still accessible. It's enough to include "hbvmopt.h"
      file before other header files to enable it. Now only files in
      source/vm directory include it.
      The 3-rd party code which does not include hbvmopt.h (or tries to
      set some internals macros) should be safe for future HVM modifications
      and will work also with new binaries so 3-rd party library developers
      should remember about it. If they won't then it's only their and
      their clients problem not Harbour developers.
      With this modifications I also create new GT model which is similar
      to the one used by RDD with multi inheritance. It can be quite easy
      extended to simultaneously load more then one GT subsystem (sth like
      work areas in RDD) but I left it for the future when someone may
      need it. hbapigt.h file now contains only information about public
      functions and does not have any code which depends on current
      internal implementation - it should be backword compatible as long
      as somone did not try to use internal GT functions.
      The internal GT system use hbgtcore.h file which should not be
      included by 3-rd party code as long as someone will not make new
      GT driver. The internal GT code is new so I expect that it will
      be changed yet in the nearest future (I'm waiting for other developers
      feedback) and in such case any 3-rd party GTs will have to be updated.
      How it works:
         The base GT driver (GTNUL) is fully functional GT driver which
         makes all operations on memory buffer. After each screen write
         Flush() method is called which check for dispcount() and if
         it's 0 then call Refresh() method to update modified area by
         Redraw() method. This method is dummy in GTNUL and external
         output with this GT can be reached by outstd()/outerr() which
         are now redirected to GT methods. A simple GT driver may overload
         only Refresh() method to give full screen output.
         Application can use only this GT driver and it seems to be very
         good choice for GUI and background daemon/service programs.
         This GT is loaded at startup then all other GTs can be loaded
         later and inherit from the previously loaded GT drivers.
         The new GT driver can overload as much method as wants/needs.
         Now all GT operations are implemented as GT method so GT driver
         can easy change their default behavior, f.e. it may fully overload
         color parsing methods and use differ or extended to Clipper color
         definitions.
         I rewrote all existing GTs to work with new GT model.
         OS2 users - please test GTOS2 which I was not able to test and
         see the note in Redraw() method. If possible please make some
         speed tests.
         In fact now there is much more internal operations then it was
         before but because they are done on memory only then current
         code is much faster in this GT drivers which so far makes all
         operations on real video area. I made some tests with GTNUL
         and tests/vidtest.prg and the total overhead is minimal. Now
         dipbegin()/dispend() in practice does not cost anything so it
         gives additional speed improvement in application which extensively
         use it.
         More then one GT driver can be linked with final binaries and
         chose on application startup by //GT<NAME> switch and/or environment
         variable HB_GT=<name>
         In the RTL is new GT function GTSYS() which works in similar way
         to RDDSYS() in RDD subsystem and for linking default GT driver
         for given platform. When RTL is compiled the default GT driver
         is set to HB_GT_DEFAULT envvar and if not exist to HB_GT_LIB
         envvar and if it also does not exist to hard coded platfom GTs
         (see source/rtl/gtsys.c and source/rtl/Makefile for rules)
         Adding to source code:
            ANNOUNCE GTSYS
         disable linking the default GT driver and:
            REQUEST HB_GT_<name>
         for linking given (<name>) GT driver, f.e.: REQUEST HB_GT_WIN
         If you are working in SH environment (Linux and other *nixes users,
         DJGPP bash, MinGW shell then it's possible to use -gt<name> switch
         in hblnk / hbmk scripts to force linking GT drivers (it could be
         repeated with different <name>) and the first one becomes the default
         one. F.e.:
            xhbmk -m -n -w -es2 -gtcrs -gtsln -gtstd -gtpca vidtest.prg
         Usually the GT driver are loaded at HVM startup but it's possible
         to load it later. I created new GT driver CTW which gives full
         CT3 like Window system. The CT3 extended driver change the behavior
         of some function in Clipper extended driver, f.e WRITECON() or
         SETPOS() with parameters out of screen range. So I implemented it
         CTW as RT GTs which is loaded when some of CTWIN function is used
         (f.e. WOPEN()/WBOARD()) and inherits from any existing GT driver.
         This is full CT3 WIN implementation with all detail behaviors I
         found (with some CT3 bug fixes). It does not have any CT3 limitations
         and can be used for any virtual screen/window size though I hardcoded
         CT3 limitation for backword compatibility. If somone will want to
         remove it then it will be enough to delete few lines from ctwin.c
         file. I'm not CTWIN Clipper user so maybe I missed some side effects
         in this driver and was not able to well test it so if you will find
         any incompatibilities then please inform me.
         THe default GT buffer uses 32bit character cell internally but
         in savescreen/restscreen it uses VGA compatible two bytes character
         cell. Some GT drivers may want to use differ character cell.
         Now GTCRS and GTSLN use 32bit character cell by default. They
         need additional information about character set (box/normal) to
         properly display box characters. It is possible to force in this
         GT drivers using Clipper compatible character cell by calling:
            hb_gtInfo( GTI_COMPATBUFFER, <lCompat> ) -> <lPreviousSeting>
         but in may cause that box drawing characters will be lost in
         some countries after RESTSCREEN(). It will depend on used code
         page.
         HB_GTINFO() is new function which works in similar way to DBINFO()
         in RDD. It allows to retrieve/change some of GT driver settings.
         GTI_* actions are defined in hbgtinfo.ch - it has all GTI_*
         definitions used in xHarbour. Now in Harbour only few of them
         are implemented.
         The new three .prg functions:
            HB_SETKEYCP( <cTermCP> [,<cHostCP>] )
            HB_SETDISPCP( <cTermCP> [,<cHostCP>] [,<lBoxChar>] )
            HB_SETTERMCP( <cTermCP> [,<cHostCP>] [,<lBoxChar>] )
         have been added. They set automatic input (HB_SETKEYCP)
         and output (HB_SETDISPCP) (or both: HB_SETTERMCP) character
         translation. They are also important for some GTs which
         informing them about used internal code page for unicode
         translation (GTXWC, GTSLN) and/or chosing proper character
         set (standard/alternate) for letters and other (f.e. box
         drawing characters) (GTCRS, GTSLN),
            <cTermCP> is encoding used on external (terminal) side
            <cHostCP> is encoding used internally, if not given then
                      current code page set HB_SETCODEPAGE() is used.
                      some of GTs which uses unicode output may
                      ignore <cTermCP>
            <lBoxChar> is optional parameter which interacts with dispbox()
                       output disabling switching to alternate character
                       set in some GTs. It effectively causes that if internal
                       (host) code page contains some letters on the box char
                       positions then they will be shown also by box drawing
                       functions like dispbox() instead of CP437 characters.
                       In some cases it could be useful. By default lBoxChar
                       is not set and GTs which can switch between standard
                       and alternate character set (GTCRS, GTSLN) will try to
                       use alternate character set for box drawing functions.

      Victor: I removed some of your functions. They can be very easy
      implemented with hb_gt_GetChar()/hb_gt_PutChar() but I do not want to
      make them part of documented external API because some GT drivers may
      want to use absolutely differ color definitions and they will stop to
      work so I do not want to make this functions documented external API.

      Ryszard: Setting alternative debug keys does not longer work.
      I like such possibilities but it should be implemented in differ
      way to f.e. using HB_GTINFO interface to allow low level GT driver
      extensions, f.e. in *nixes using CTRL+[A-Z] and SIGINT, SIGQUIT,
      SIGTSTP signals for real asynchronous setting of debug/cancel flag
      without keyboard polling from main HVM loop. I would like to discus
      about such more general solution.

   *** Please updated non GNU make files ***
2006-02-04 16:16:48 +00:00

2486 lines
59 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Advantage Database Server RDD ( additional functions )
*
* Copyright 2000 Alexander Kresin <alex@belacy.belgorod.su>
* 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.
*
*/
#define HB_OS_WIN_32_USED
#include "hbsetup.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbinit.h"
#include "hbvm.h"
#include "rddsys.ch"
#include "hbapilng.h"
#include "hbdate.h"
#include "hbapierr.h"
#include "rddads.h"
#include "hbstack.h"
#define HARBOUR_MAX_RDD_FILTER_LENGTH 256
#define MAX_STR_LEN 255
int adsFileType = ADS_CDX;
int adsLockType = ADS_PROPRIETARY_LOCKING;
int adsRights = 1;
int adsCharType = ADS_ANSI;
BOOL bTestRecLocks = FALSE; /* Debug Implicit locks */
ADSHANDLE adsConnectHandle = 0;
#if !defined( ADS_LINUX )
static PHB_ITEM s_pItmCobCallBack = NULL;
#endif
#ifdef ADS_USE_OEM_TRANSLATION
BOOL adsOEM = FALSE;
char * hb_adsOemToAnsi( char * pcString, ULONG ulLen )
{
if( adsOEM )
{
char * pszDst = ( char * ) hb_xgrab( ulLen + 1 );
OemToCharBuff( ( LPCSTR ) pcString, ( LPSTR ) pszDst, ( DWORD ) ulLen );
pszDst[ ulLen ] = '\0';
return pszDst;
}
return pcString;
}
char * hb_adsAnsiToOem( char * pcString, ULONG ulLen )
{
if( adsOEM )
{
char * pszDst = ( char * ) hb_xgrab( ulLen + 1 );
CharToOemBuff( ( LPCSTR ) pcString, ( LPSTR ) pszDst, ( DWORD ) ulLen );
pszDst[ ulLen ] = '\0';
return pszDst;
}
return pcString;
}
void hb_adsOemAnsiFree( char * pcString )
{
if( adsOEM )
{
hb_xfree( pcString );
}
}
#endif
HB_FUNC( ADSTESTRECLOCKS ) /* Debug Implicit locks Set/Get call */
{
BOOL oldSetting = bTestRecLocks;
if( ISLOG( 1 ) )
bTestRecLocks = hb_parl( 1 );
hb_retl( oldSetting );
}
HB_FUNC( ADSSETFILETYPE )
{
int fileType, oldType = adsFileType;
if( hb_pcount() > 0 )
{
fileType = hb_parni( 1 );
if( fileType > 0 && fileType < 4 )
{
adsFileType = fileType;
}
}
hb_retni( oldType );
}
HB_FUNC( ADSSETSERVERTYPE )
{
int servType;
UNSIGNED32 ulRetVal = 999999;
if( hb_pcount() > 0 )
{
servType = hb_parni( 1 );
ulRetVal = AdsSetServerType( servType );
}
hb_retnl( ulRetVal );
}
HB_FUNC( ADSSETDATEFORMAT )
{
UNSIGNED8 pucFormat[16];
UNSIGNED16 pusLen = 16;
hb_retc( "");
AdsGetDateFormat( pucFormat, &pusLen );
if( pusLen > 0 )
{
hb_retc( (char *) pucFormat );
}
if( ISCHAR( 1 ) )
{
AdsSetDateFormat( (UNSIGNED8*) hb_parcx( 1 ) );
}
}
HB_FUNC( ADSSETEPOCH )
{
UNSIGNED16 pusEpoch = 1900;
if( AdsGetEpoch ( &pusEpoch ) == AE_SUCCESS )
{
hb_retni( pusEpoch );
}
if( ISNUM( 1 ) )
{
AdsSetEpoch ( hb_parni( 1 ) );
}
}
HB_FUNC( ADSAPPLICATIONEXIT )
{
AdsApplicationExit();
}
HB_FUNC( ADSISSERVERLOADED )
{
UNSIGNED16 pbLoaded = 0;
UNSIGNED32 ulRetVal;
if( ISCHAR( 1 ) )
{
ulRetVal = AdsIsServerLoaded( (UNSIGNED8*) hb_parcx( 1 ), &pbLoaded );
if( ulRetVal != AE_SUCCESS )
{
pbLoaded = 0;
}
}
hb_retnl( pbLoaded );
}
HB_FUNC( ADSGETCONNECTIONTYPE )
{
// WARNING: This does NOT return the Type of a connection Handle-- it returns whether
// connected to ADS_REMOTE_SERVER, ADS_AIS_SERVER, or ADS_LOCAL_SERVER
UNSIGNED16 pusConnectType = 0;
UNSIGNED32 ulRetVal;
ADSHANDLE hConnToCheck = HB_ADS_PARCONNECTION( 1 );
// caller can specify a connection. Otherwise use default handle.
// The global adsConnectHandle will continue to be 0 if no adsConnect60 (Data
// Dictionary) calls are made. Simple table access uses an implicit connection
// whose handle we don't see unless you get it from an opened table
// with ADSGETTABLECONTYPE
if( hConnToCheck )
{
ulRetVal = AdsGetConnectionType ( hConnToCheck, &pusConnectType ) ;
if( ulRetVal != AE_SUCCESS )
{
// it may have set an error value, or leave as 0.
pusConnectType = AE_INVALID_CONNECTION_HANDLE;
}
}
else
{
// pusConnectType = AE_INVALID_CONNECTION_HANDLE;
pusConnectType = AE_NO_CONNECTION;
}
hb_retnl( pusConnectType );
}
HB_FUNC( ADSUNLOCKRECORD )
{
UNSIGNED32 ulRetVal;
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsUnlockRecord( pArea->hTable, hb_parnl(1) );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( TRUE );
return;
}
}
hb_retl( FALSE );
}
HB_FUNC( ADSGETTABLECONTYPE )
{
UNSIGNED16 pusConnectType = 0;
UNSIGNED32 ulRetVal;
ADSAREAP pArea;
ADSHANDLE pTableConnectHandle = 0;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsGetTableConnection( pArea->hTable, &pTableConnectHandle );
if ( pTableConnectHandle )
{
ulRetVal = AdsGetConnectionType( pTableConnectHandle, &pusConnectType ) ;
if ( ulRetVal != AE_SUCCESS )
{
pusConnectType = 0;
}
}
}
hb_retnl( pusConnectType );
}
HB_FUNC( ADSGETSERVERTIME )
{
UNSIGNED32 ulRetVal;
UNSIGNED8 pucDateBuf[ 16 ];
UNSIGNED8 pucTimeBuf[ 16 ];
UNSIGNED16 pusDateBufLen = 16;
UNSIGNED16 pusTimeBufLen = 16;
SIGNED32 plTime = 0;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 );
ulRetVal = AdsGetServerTime( hConnect, pucDateBuf, &pusDateBufLen, &plTime, pucTimeBuf, &pusTimeBufLen );
if( ulRetVal == AE_SUCCESS )
{
hb_reta( 3 ) ;
hb_storc( (char * )pucDateBuf, -1, 1 );
hb_storc( (char *) pucTimeBuf, -1, 2 );
hb_stornl( plTime, -1, 3 );
} else
{
AdsShowError( (UNSIGNED8 *) "AdsGetServerTime error:" );
hb_ret();
}
}
//----------------------------------------------------------------------------//
HB_FUNC( ADSISTABLELOCKED )
{
UNSIGNED32 ulRetVal = ~AE_SUCCESS;
UNSIGNED16 pbLocked = FALSE;
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsIsTableLocked( pArea->hTable, &pbLocked );
}
if ( ulRetVal != AE_SUCCESS )
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISTABLELOCKED" );
}
hb_retl( pbLocked );
}
HB_FUNC( ADSISRECORDLOCKED )
{
UNSIGNED32 ulRetVal = ~AE_SUCCESS;
UNSIGNED32 ulRec;
UNSIGNED16 pbLocked = FALSE;
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( ISNUM( 1 ) )
{
ulRec = hb_parnl( 1 );
}
else
{
SELF_RECNO( ( AREAP ) pArea, &ulRec );
}
ulRetVal = AdsIsRecordLocked( pArea->hTable, ulRec, &pbLocked );
}
if( ulRetVal != AE_SUCCESS )
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISRECORDLOCKED" );
}
hb_retl( pbLocked );
}
HB_FUNC( ADSLOCKING )
{
int oldType = adsLockType;
if( hb_pcount() > 0 )
{
adsLockType = hb_parl( 1 );
}
hb_retl( oldType );
}
HB_FUNC( ADSRIGHTSCHECK )
{
int oldType = ( adsRights == 1 ) ? 1 : 0;
if( hb_pcount() > 0 )
{
adsRights = ( hb_parl( 1 ) ) ? 1 : 2;
}
hb_retl( oldType );
}
HB_FUNC( ADSSETCHARTYPE )
{
int charType, oldType = adsCharType;
if( hb_pcount() > 0 )
{
charType = hb_parni( 1 );
if( charType > 0 && charType < 3 )
{
adsCharType = charType;
}
#ifdef ADS_USE_OEM_TRANSLATION
if( ISLOG( 2 ) )
{
adsOEM = hb_parnl( 2 );
}
#endif
}
hb_retni( oldType );
return;
}
// return whether the current table is opened with OEM or ANSI character set
HB_FUNC( ADSGETTABLECHARTYPE )
{
UNSIGNED16 usCharType;
ADSAREAP pArea = hb_rddGetADSWorkAreaPointer();
AdsGetTableCharType( pArea->hTable, &usCharType );
hb_retni( usCharType );
return;
}
HB_FUNC( ADSSETDEFAULT )
{
UNSIGNED8 pucDefault[ MAX_STR_LEN + 1];
UNSIGNED16 pusLen = MAX_STR_LEN + 1;
AdsGetDefault( pucDefault, &pusLen );
hb_retclen( ( char * ) pucDefault, pusLen );
if( ISCHAR( 1 ) )
{
AdsSetDefault( (UNSIGNED8*) hb_parcx( 1 ) );
}
}
HB_FUNC( ADSSETSEARCHPATH )
{
UNSIGNED8 pucPath[ MAX_STR_LEN + 1];
UNSIGNED16 pusLen = MAX_STR_LEN + 1;
AdsGetSearchPath( pucPath, &pusLen );
hb_retclen( ( char *) pucPath, pusLen );
if( ISCHAR( 1 ) )
{
AdsSetSearchPath( (UNSIGNED8*) hb_parcx( 1 ) );
}
}
HB_FUNC( ADSSETDELETED )
{
UNSIGNED16 usShowDeleted = hb_parl( 1 );
UNSIGNED16 pbShowDeleted ;
AdsGetDeleted( &pbShowDeleted ) ;
hb_retl( ! pbShowDeleted );
if( ISLOG( 1 ) )
{
AdsShowDeleted( !usShowDeleted );
}
}
HB_FUNC( ADSSETEXACT )
{
UNSIGNED16 usExact = hb_parl( 1 );
UNSIGNED16 pbExact ;
AdsGetExact( &pbExact ) ;
hb_retl( pbExact );
if( ISLOG( 1 ) )
{
AdsSetExact( usExact );
}
}
HB_FUNC( ADSBLOB2FILE )
{
char * szFileName, *szFieldName;
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
szFileName = hb_parcx( 1 );
szFieldName = hb_parcx( 2 );
if( !szFileName || !szFieldName || ( strlen( szFileName ) == 0 ) ||
( strlen( szFieldName ) == 0 ) )
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSBLOB2FILE" );
return;
}
pArea = hb_rddGetADSWorkAreaPointer();
ulRetVal = AdsBinaryToFile( pArea->hTable, (UNSIGNED8*)szFieldName, (UNSIGNED8*)szFileName );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSFILE2BLOB )
{
char * szFileName, *szFieldName;
UNSIGNED16 usBinaryType;
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
szFileName = hb_parcx( 1 );
szFieldName = hb_parcx( 2 );
if( !szFileName || !szFieldName || ( strlen( szFileName ) == 0 ) ||
( strlen( szFieldName ) == 0 ) )
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSFILE2BLOB" );
return;
}
if( hb_pcount() > 2 )
{
usBinaryType = hb_parni( 3 );
}
else
{
usBinaryType = ADS_BINARY;
}
pArea = hb_rddGetADSWorkAreaPointer();
ulRetVal = AdsFileToBinary( pArea->hTable, (UNSIGNED8*)szFieldName, usBinaryType, (UNSIGNED8*)szFileName );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSKEYNO )
{
ADSAREAP pArea;
UNSIGNED8* ordName;
UNSIGNED8 ordNum;
UNSIGNED32 pulKey = 0L;
ADSHANDLE hIndex = 0;
UNSIGNED16 usFilterOption = ADS_IGNOREFILTERS;
PHB_ITEM pxOrder = hb_param( 1, HB_IT_ANY );
/* 2nd parameter: unsupported Bag Name. */
PHB_ITEM pFilterOption = hb_param( 3, HB_IT_NUMERIC );
/* if arg 1 or 3 is bad, toss error */
if ( ( pxOrder != NULL && !HB_IS_STRING( pxOrder ) && !HB_IS_NUMBER( pxOrder ) && !HB_IS_NIL( pxOrder ) ) ||
( pFilterOption != NULL && !HB_IS_NUMBER( pFilterOption ) ) )
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSKEYNO" );
return;
}
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( pFilterOption )
{
usFilterOption = hb_itemGetNI( pFilterOption );
}
/* get an Index Handle */
if( pxOrder == NULL || HB_IS_NIL( pxOrder ) ) /* didn't pass it in; use current */
{
hIndex = pArea->hOrdCurrent;
}
else if( HB_IS_NUMBER( pxOrder ) )
{
ordNum = (UNSIGNED8) hb_itemGetNI( pxOrder );
if( ordNum > 0 ) /* otherwise leave hIndex at 0 */
{
AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex );
}
}
else /* must be number or nil since checked above */
{
if( hb_itemGetCLen( pxOrder ) == 0 ) /* passed "" */
{
hIndex = pArea->hOrdCurrent;
}
else
{
ordName = (UNSIGNED8*) hb_itemGetCPtr( pxOrder );
AdsGetIndexHandle( pArea->hTable, ordName, &hIndex );
}
}
if( hIndex == 0 ) /* no index selected */
{
AdsGetRecordNum( pArea->hTable, usFilterOption, &pulKey );
}
else
{
AdsGetKeyNum( hIndex, usFilterOption, &pulKey );
}
hb_retnl( pulKey );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSKEYNO" );
}
}
HB_FUNC( ADSKEYCOUNT )
{
ADSAREAP pArea;
UNSIGNED8* ordName;
UNSIGNED8 ordNum;
UNSIGNED32 pulKey = 0L;
ADSHANDLE hIndex = 0;
UNSIGNED16 usFilterOption = ADS_IGNOREFILTERS;
UNSIGNED8 pucScope[ADS_MAX_KEY_LENGTH + 1];
UNSIGNED8 pucFilter[HARBOUR_MAX_RDD_FILTER_LENGTH + 1];
UNSIGNED16 pusBufLen = ADS_MAX_KEY_LENGTH + 1;
PHB_ITEM pxOrder = hb_param( 1, HB_IT_ANY );
/* 2nd parameter: unsupported Bag Name. */
PHB_ITEM pFilterOption = hb_param( 3, HB_IT_NUMERIC );
if ( pxOrder != NULL && HB_IS_NIL( pxOrder ) )
{
pxOrder = NULL; // simplifies arg checks below
}
/* if arg 1 or 3 is bad, toss error */
if ( ( pxOrder != NULL && !HB_IS_STRING( pxOrder ) && !HB_IS_NUMBER( pxOrder ) ) ||
( pFilterOption != NULL && !HB_IS_NUMBER( pFilterOption ) ) )
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSKEYCOUNT" );
return;
}
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( pFilterOption != NULL )
{
usFilterOption = hb_itemGetNI( pFilterOption );
}
/* get an Index Handle */
if( pxOrder == NULL ) /* didn't pass it in; use current */
{
hIndex = pArea->hOrdCurrent;
}
else if( HB_IS_NUMBER( pxOrder ) )
{
ordNum = (UNSIGNED8) hb_itemGetNI( pxOrder );
if( ordNum > 0 ) /* otherwise leave hIndex at 0 */
{
AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex );
}
}
else /* must be String since checked above */
{
if( hb_itemGetCLen( pxOrder ) == 0 ) /* passed "" */
{
hIndex = pArea->hOrdCurrent;
}
else
{
ordName = (UNSIGNED8*) hb_itemGetCPtr( pxOrder );
AdsGetIndexHandle( pArea->hTable, ordName, &hIndex );
}
}
hIndex = ( hIndex == 0 ) ? pArea->hTable : hIndex;
if( usFilterOption == ADS_IGNOREFILTERS )
{
AdsGetRecordCount( hIndex, ADS_IGNOREFILTERS, &pulKey );
}
else /* ads scope handling is flawed; do our own */
{ /* One more optimization would be to check if there's a fully optimized AOF available so don't walk ours */
AdsGetScope( hIndex, ADS_BOTTOM, pucScope, &pusBufLen );
if( pusBufLen ) /* had a scope */
{
AdsGetAOF( pArea->hTable, pucFilter, &pusBufLen );
if( !pusBufLen ) /* had no AOF */
{
AdsGetFilter( pArea->hTable, pucFilter, &pusBufLen );
}
if( pusBufLen ) /* had a scope with AOF or filter, walk it. Skips obey filters */
{
ULONG ulRecNo;
UNSIGNED16 u16eof;
SELF_RECNO( ( AREAP ) pArea, &ulRecNo );
AdsGotoTop( hIndex );
AdsAtEOF( pArea->hTable, &u16eof );
while( AdsSkip ( hIndex, 1 ) != AE_NO_CURRENT_RECORD && !u16eof )
{
AdsAtEOF( pArea->hTable, &u16eof );
pulKey++;
}
SELF_GOTO( ( AREAP ) pArea, ulRecNo );
}
else
{
AdsGetRecordCount( hIndex, usFilterOption, &pulKey );
}
}
else /* no scope set */
{
AdsGetRecordCount( hIndex, usFilterOption, &pulKey );
}
}
hb_retnl( pulKey );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSKEYCOUNT" );
}
}
HB_FUNC( ADSADDCUSTOMKEY )
{
ADSAREAP pArea;
UNSIGNED8* ordName;
UNSIGNED8 ordNum;
ADSHANDLE hIndex;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( hb_pcount() > 0 )
{
if( ISNUM( 1 ) )
{
ordNum = hb_parni( 1 );
AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex );
}
else
{
ordName = (UNSIGNED8*) hb_parcx( 1 );
AdsGetIndexHandle( pArea->hTable, ordName, &hIndex );
}
hb_retnl( (LONG) AdsAddCustomKey( hIndex ) );
}
else
{
if( pArea->hOrdCurrent != 0 )
{
hIndex = pArea->hOrdCurrent;
hb_retnl( (LONG) AdsAddCustomKey( hIndex ) );
}
else
{
hb_errRT_DBCMD( EG_NOORDER, 2001, NULL, "ADSADDCUSTOMKEY" );
}
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSADDCUSTOMKEY" );
}
}
HB_FUNC( ADSDELETECUSTOMKEY )
{
ADSAREAP pArea;
UNSIGNED8* ordName;
UNSIGNED8 ordNum;
ADSHANDLE hIndex;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( hb_pcount() > 0 )
{
if( ISNUM( 1 ) )
{
ordNum = hb_parni( 1 );
AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex );
}
else
{
ordName = (UNSIGNED8*) hb_parcx( 1 );
AdsGetIndexHandle( pArea->hTable, ordName, &hIndex );
}
hb_retnl( (LONG) AdsDeleteCustomKey( hIndex ) );
}
else
{
if( pArea->hOrdCurrent != 0 )
{
hIndex = pArea->hOrdCurrent;
hb_retnl( (LONG) AdsDeleteCustomKey( hIndex ) );
}
else
{
hb_errRT_DBCMD( EG_NOORDER, 2001, NULL, "ADSDELETECUSTOMKEY" );
}
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSDELETECUSTOMKEY" );
}
}
HB_FUNC( ADSCLEARAOF )
{
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsClearAOF( pArea->hTable );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCLEARAOF" );
}
}
HB_FUNC( ADSEVALAOF )
{
ADSAREAP pArea;
char * pucFilter;
UNSIGNED16 pusOptLevel;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea && ISCHAR( 1 ) )
{
pucFilter = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) );
AdsEvalAOF( pArea->hTable, (UNSIGNED8*) pucFilter, &pusOptLevel );
hb_adsOemAnsiFree( pucFilter );
hb_retni( pusOptLevel );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSEVALAOF" );
}
}
HB_FUNC( ADSGETTABLEALIAS )
{
ADSAREAP pArea;
UNSIGNED8 pucAlias[HARBOUR_MAX_RDD_ALIAS_LENGTH + 1];
UNSIGNED16 pusLen = HARBOUR_MAX_RDD_ALIAS_LENGTH + 1;
UNSIGNED32 ulRetVal = FAILURE;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsGetTableAlias( pArea->hTable, pucAlias, &pusLen );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSGETTABLEALIAS" );
}
if( ulRetVal == AE_SUCCESS )
{
hb_retclen ( ( char * ) pucAlias, pusLen );
}
else
{
hb_retc( "" );
}
}
HB_FUNC( ADSGETAOF )
{
ADSAREAP pArea;
UNSIGNED8 pucFilter[HARBOUR_MAX_RDD_FILTER_LENGTH + 1];
UNSIGNED8 *pucFilter2 = NULL;
UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsGetAOF( pArea->hTable, pucFilter, &pusLen );
if( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH )
{
pucFilter2 = (UNSIGNED8*) hb_xgrab( pusLen + 1 );
ulRetVal = AdsGetAOF( pArea->hTable, pucFilter2, &pusLen );
}
if( ulRetVal == AE_SUCCESS )
{
char * szRet;
szRet = hb_adsAnsiToOem( ( char * ) ( pucFilter2 ? pucFilter2 : pucFilter ), pusLen );
hb_retc( szRet );
hb_adsOemAnsiFree( szRet );
}
else
{
hb_retc( "" );
}
if( pucFilter2 )
{
hb_xfree( pucFilter2 );
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSGETAOF" );
}
}
HB_FUNC( ADSGETAOFOPTLEVEL )
{
ADSAREAP pArea;
UNSIGNED16 pusOptLevel;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsGetAOFOptLevel( pArea->hTable, &pusOptLevel, NULL, NULL );
hb_retni( ulRetVal == AE_SUCCESS ? pusOptLevel : ADS_OPTIMIZED_NONE );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSGETAOFOPTLEVEL" );
}
}
HB_FUNC( ADSGETAOFNOOPT )
{
ADSAREAP pArea;
UNSIGNED16 pusOptLevel;
UNSIGNED8 pucNonOpt[HARBOUR_MAX_RDD_FILTER_LENGTH + 1];
UNSIGNED8 *pucNonOpt2;
UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsGetAOFOptLevel( pArea->hTable, &pusOptLevel, pucNonOpt, &pusLen );
if( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH )
{
pucNonOpt2 = (UNSIGNED8*) hb_xgrab( pusLen + 1 );
ulRetVal = AdsGetAOFOptLevel( pArea->hTable, &pusOptLevel, pucNonOpt2, &pusLen );
if( ulRetVal == AE_SUCCESS )
{
hb_retc( (char *) pucNonOpt2 );
}
else
{
hb_retc( "" );
}
hb_xfree( pucNonOpt2 );
}
else if( ulRetVal == AE_SUCCESS )
{
hb_retc( ( char * ) pucNonOpt );
}
else
{
hb_retc( "" );
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSGETAOFNOOPT" );
}
}
HB_FUNC( ADSISRECORDINAOF )
{
ADSAREAP pArea;
UNSIGNED32 ulRecordNumber = 0; /* 0 for current record */
UNSIGNED16 bIsInAOF;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( hb_pcount() > 0 )
{
ulRecordNumber = hb_parnl( 1 );
}
ulRetVal = AdsIsRecordInAOF( pArea->hTable, ulRecordNumber, &bIsInAOF );
if( ulRetVal == AE_SUCCESS && bIsInAOF )
{
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISRECORDINAOF" );
}
}
HB_FUNC( ADSISRECORDVALID ) // Does current record match any current filter?
{
AREAP pArea;
BOOL bReturn = FALSE;
PHB_ITEM pResult;
pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
if( pArea )
{
BOOL fEof;
if( SELF_EOF( ( AREAP ) pArea , &fEof ) == SUCCESS && !fEof )
{
if( ! pArea->dbfi.itmCobExpr )
{
bReturn = TRUE;
}
else
{
pResult = hb_vmEvalBlock( pArea->dbfi.itmCobExpr );
bReturn = HB_IS_LOGICAL( pResult ) && hb_itemGetL( pResult );
}
}
}
/*
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISRECORDVALID" );
}
*/
hb_retl( bReturn );
}
HB_FUNC( ADSREFRESHAOF )
{
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsRefreshAOF( pArea->hTable );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSREFRESHAOF" );
}
}
HB_FUNC( ADSSETAOF )
{
ADSAREAP pArea;
char * pucFilter;
UNSIGNED16 usResolve = ADS_RESOLVE_DYNAMIC ; /* ADS_RESOLVE_IMMEDIATE */
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( ! ISCHAR( 1 ) )
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSSETAOF" );
}
else if( pArea )
{
if( hb_pcount() > 1 )
{
usResolve = hb_parni( 2 );
}
pucFilter = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) );
ulRetVal = AdsSetAOF( pArea->hTable, (UNSIGNED8*) pucFilter, usResolve );
hb_adsOemAnsiFree( pucFilter );
hb_retl( ulRetVal == AE_SUCCESS );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSSETAOF" );
}
}
HB_FUNC( ADSGETFILTER )
{
ADSAREAP pArea;
UNSIGNED8 pucFilter[HARBOUR_MAX_RDD_FILTER_LENGTH + 1];
UNSIGNED8 *pucFilter2 = NULL;
UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsGetFilter( pArea->hTable, pucFilter, &pusLen );
if( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH )
{
pucFilter2 = (UNSIGNED8*) hb_xgrab( pusLen + 1 );
ulRetVal = AdsGetFilter( pArea->hTable, pucFilter2, &pusLen );
}
if( ulRetVal == AE_SUCCESS )
{
char * szRet;
szRet = hb_adsAnsiToOem( ( char * ) ( pucFilter2 ? pucFilter2 : pucFilter ), pusLen );
hb_retc( szRet );
hb_adsOemAnsiFree( szRet );
}
else
{
HB_TRACE(HB_TR_DEBUG, ("adsGetFilter Error %lu", ulRetVal));
hb_retc( "" );
}
if( pucFilter2 )
{
hb_xfree( pucFilter2 );
}
}
else
{
hb_retc( "" );
}
}
HB_FUNC( ADSENABLEENCRYPTION )
{
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
char * pucPassword = hb_parcx( 1 );
if( !pucPassword || ( strlen( pucPassword ) == 0 ) )
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSENABLEENCRYPTION" );
return;
}
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsEnableEncryption( pArea->hTable, ( UNSIGNED8 * ) pucPassword );
hb_retni( ulRetVal );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSENABLEENCRYPTION" );
}
}
HB_FUNC( ADSDISABLEENCRYPTION )
{
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsDisableEncryption( pArea->hTable );
hb_retni( ulRetVal );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSDISABLEENCRYPTION" );
}
}
HB_FUNC( ADSENCRYPTTABLE )
{
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsEncryptTable( pArea->hTable );
hb_retni( ulRetVal );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSENCRYPTTABLE" );
}
}
HB_FUNC( ADSDECRYPTTABLE )
{
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsDecryptTable( pArea->hTable );
hb_retni( ulRetVal );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSDECRYPTTABLE" );
}
}
HB_FUNC( ADSENCRYPTRECORD )
{
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsEncryptRecord( pArea->hTable );
hb_retni( ulRetVal );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSENCRYPTRECORD" );
}
}
HB_FUNC( ADSDECRYPTRECORD )
{
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsDecryptRecord( pArea->hTable );
hb_retni( ulRetVal );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSDECRYPTRECORD" );
}
}
HB_FUNC( ADSISENCRYPTIONENABLED )
{
ADSAREAP pArea;
UNSIGNED16 usIsEnabled;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsIsEncryptionEnabled( pArea->hTable, &usIsEnabled );
hb_retl( usIsEnabled );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISENCRYPTIONENABLED" );
}
}
HB_FUNC( ADSISRECORDENCRYPTED )
{
ADSAREAP pArea;
UNSIGNED16 usIsEnabled;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsIsRecordEncrypted( pArea->hTable, &usIsEnabled );
hb_retl( usIsEnabled );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISRECORDENCRYPTED" );
}
}
HB_FUNC( ADSISTABLEENCRYPTED )
{
ADSAREAP pArea;
UNSIGNED16 usIsEnabled;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsIsTableEncrypted( pArea->hTable, &usIsEnabled );
hb_retl( usIsEnabled );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISTABLEENCRYPTED" );
}
}
HB_FUNC( ADSCONNECT )
{
UNSIGNED32 ulRetVal;
ADSHANDLE hConnect = 0;
if( hb_pcount() > 0 && ISCHAR( 1 ) )
{
ulRetVal = AdsConnect( (UNSIGNED8*) hb_parcx( 1 ), &hConnect );
if( ulRetVal == AE_SUCCESS )
{
adsConnectHandle = hConnect;
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSDISCONNECT )
{
/* From ACE HLP:
* AdsDisconnect is used to disconnect a connection from the specified server.
* If tables are currently opened, all data is flushed, locks are released,
* and open tables are closed before the disconnect occurs.
*
* If zero is passed as the connection handle, all connections on the server
* associated with the user will be disconnected. If AdsDisconnect is called
* on a connection with a transaction active, the transaction will be rolled back.
*
*/
UNSIGNED32 ulRetVal = ~AE_SUCCESS;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 );
// Only allow disconnect of 0 if explicitly passed or adsConnectHandle is 0
// (hConnect might be 0 if caller accidentally disconnects twice; this should not close all connections!)
if ( hConnect != 0 || ISNUM( 1 ) )
{
ulRetVal = AdsDisconnect( hConnect );
}
if( ulRetVal == AE_SUCCESS )
{
if ( hConnect == adsConnectHandle )
{
adsConnectHandle = 0;
}
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSCREATESQLSTATEMENT )
{
UNSIGNED32 u32RetVal;
ADSAREAP pArea;
ADSHANDLE adsStatementHandle;
char szAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ];
BOOL fResult = FALSE;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 );
if( hConnect )
{
u32RetVal = AdsCreateSQLStatement( hConnect, &adsStatementHandle );
if( u32RetVal == AE_SUCCESS )
{
if( hb_parni( 2 ) == ADS_CDX )
{
AdsStmtSetTableType( adsStatementHandle, ADS_CDX );
}
if( !hb_rddInsertAreaNode( "ADS" ) )
{
AdsCloseSQLStatement( adsStatementHandle );
}
else
{
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
hb_strncpy( szAlias, ISCHAR( 1 ) ? hb_parc( 1 ) : "ADSSQL",
HARBOUR_MAX_RDD_ALIAS_LENGTH );
pArea->atomAlias = hb_rddAllocWorkAreaAlias( szAlias,
pArea->uiArea );
if( !pArea->atomAlias )
{
hb_rddReleaseCurrentArea();
}
else
{
pArea->hTable = 0;
pArea->hOrdCurrent = 0;
pArea->hStatement = adsStatementHandle;
fResult = TRUE;
}
}
}
}
}
hb_retl( fResult );
}
HB_FUNC( ADSEXECUTESQLDIRECT )
{
UNSIGNED32 ulRetVal;
ADSHANDLE hCursor = 0;
ADSAREAP pArea;
/* -----------------10/9/2005 2:51PM-----------------
bh removed test for adsConnectHandle as it is not actually used;
the func was just trying to confirm a real connection existed
but we're trying to remove dependence on statics;
if we saved the nConnection to a WA, that would take care of it.
As is, it requires pArea->hStatement which we only allow created if
there's Connection so we should be OK.
* --------------------------------------------------*/
if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) != 0
&& pArea->hStatement && ISCHAR( 1 ) )
{
char * pucStmt = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) );
ulRetVal = AdsExecuteSQLDirect( pArea->hStatement, (UNSIGNED8 *) pucStmt, &hCursor );
hb_adsOemAnsiFree( pucStmt );
if( ulRetVal == AE_SUCCESS )
{
if( hCursor )
{
DBOPENINFO pInfo;
memset( &pInfo, 0, sizeof( DBOPENINFO ) );
pInfo.abName = ( BYTE * ) "";
pInfo.fReadonly = TRUE;
pArea->hTable = hCursor;
SELF_OPEN( ( AREAP ) pArea, &pInfo );
}
else
{
adsCloseCursor( pArea );
}
hb_retl( TRUE );
}
else
{
AdsShowError( (UNSIGNED8 *) "ExecuteSQL error:" );
hb_retl( FALSE );
}
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSPREPARESQL )
{
UNSIGNED32 ulRetVal;
ADSAREAP pArea;
/* -----------------10/9/2005 2:51PM-----------------
bh removed test for adsConnectHandle as it is not actually used;
the func was just trying to confirm a real connection existed
but we're trying to remove dependence on statics;
if we saved the nConnection to a WA, that would take care of it.
As is, it requires pArea->hStatement which we only allow created if
there's Connection so we should be OK.
* --------------------------------------------------*/
if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) != 0
&& pArea->hStatement && ISCHAR( 1 ) )
{
char * pucStmt = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) );
ulRetVal = AdsPrepareSQL( pArea->hStatement, (UNSIGNED8 *) pucStmt );
hb_adsOemAnsiFree( pucStmt );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( TRUE );
}
else
{
AdsShowError( (UNSIGNED8 *) "PrepareSQL error:" );
hb_retl( FALSE );
}
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSEXECUTESQL )
{
UNSIGNED32 ulRetVal;
ADSHANDLE hCursor = 0;
ADSAREAP pArea;
/* -----------------10/9/2005 2:51PM-----------------
bh removed test for adsConnectHandle as it is not actually used;
the func was just trying to confirm a real connection existed
but we're trying to remove dependence on statics;
if we saved the nConnection to a WA, that would take care of it.
As is, it requires pArea->hStatement which we only allow created if
there's Connection so we should be OK.
* --------------------------------------------------*/
if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) != 0
&& pArea->hStatement )
{
ulRetVal = AdsExecuteSQL( pArea->hStatement, &hCursor );
if( ulRetVal == AE_SUCCESS )
{
if( hCursor )
{
DBOPENINFO pInfo;
memset( &pInfo, 0, sizeof( DBOPENINFO ) );
pInfo.abName = ( BYTE * ) "";
pInfo.fReadonly = TRUE;
pArea->hTable = hCursor;
SELF_OPEN( ( AREAP ) pArea, &pInfo );
}
else
{
adsCloseCursor( pArea );
}
hb_retl( 1 );
}
else
{
AdsShowError( (UNSIGNED8 *) "ExecuteSQL error:" );
hb_retl( 0 );
}
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSCLOSEALLTABLES )
{
hb_retnl( AdsCloseAllTables() );
}
HB_FUNC( ADSWRITEALLRECORDS )
{
hb_retnl( AdsWriteAllRecords() );
}
HB_FUNC( ADSREFRESHRECORD )
{
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsRefreshRecord( pArea->hTable );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSREFRESHRECORD" );
}
}
HB_FUNC( ADSCOPYTABLE )
{
// lSuccess := AdsCopyTable( cTargetFile [, nAdsFilterOption ] )
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
UNSIGNED16 usFilterOption = ADS_RESPECTFILTERS;
ADSHANDLE hIndex ;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( ISCHAR( 1 ) )
{
if( ISNUM( 2 ) )
{
usFilterOption = (UNSIGNED16) hb_parni( 2 );
}
// If an index is active copy table in indexed order
hIndex = ( pArea->hOrdCurrent ) ? pArea->hOrdCurrent : pArea->hTable;
ulRetVal = AdsCopyTable( hIndex, usFilterOption, (UNSIGNED8 *) hb_parcx( 1 ) );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( 1 );
return;
}
}
else
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSCOPYTABLE" );
return;
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCOPYTABLE" );
}
hb_retl( 0 );
}
HB_FUNC( ADSCONVERTTABLE )
{
ADSAREAP pArea;
UNSIGNED16 usTableType = ADS_ADT;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
if( ISCHAR( 1 ) )
{
if( ISNUM( 2 ) )
{
usTableType = hb_parni( 2 );
if( usTableType < 1 || usTableType > 3 )
usTableType = ADS_ADT;
}
AdsConvertTable( pArea->hTable, ADS_IGNOREFILTERS, (UNSIGNED8 *) hb_parcx( 1 ), usTableType );
}
else
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSCONVERTTABLE" );
return;
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCONVERTTABLE" );
}
}
#if !defined( ADS_LINUX )
UNSIGNED32 WINAPI ShowPercentage( UNSIGNED16 usPercentDone )
{
if( s_pItmCobCallBack && HB_IS_BLOCK( s_pItmCobCallBack ) )
{
PHB_ITEM pPercentDone = hb_itemPutNI( NULL, usPercentDone );
BOOL fResult;
fResult = hb_itemGetL( hb_vmEvalBlockV( s_pItmCobCallBack, 1, pPercentDone ) );
hb_itemRelease( pPercentDone );
return fResult;
}
else
{
HB_TRACE(HB_TR_DEBUG, ("ShowPercentage(%d) called with no codeblock set.\n", usPercentDone ));
}
return 0;
} /* ShowPercentage */
HB_FUNC( ADSREGCALLBACK )
{
UNSIGNED32 ulRetVal;
/* Note: current implementation is not thread safe.
ADS can register multiple callbacks, but one per thread/connection.
To be thread safe, we need multiple connections.
The registered function (and its codeblock s_pItmCobCallBack) should
NOT make any Advantage Client Engine calls. If it does,
it is possible to get error code 6619 "Communication Layer is busy".
*/
if( ISBLOCK( 1 ) )
{
if( s_pItmCobCallBack )
{
hb_itemRelease( s_pItmCobCallBack );
}
s_pItmCobCallBack = hb_itemNew( hb_param( 1, HB_IT_BLOCK ) );
ulRetVal = AdsRegisterProgressCallback( ShowPercentage );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( TRUE );
return;
}
else
{
hb_itemRelease( s_pItmCobCallBack );
s_pItmCobCallBack = NULL;
}
}
hb_retl( FALSE );
}
HB_FUNC( ADSCLRCALLBACK )
{
if( s_pItmCobCallBack )
{
hb_itemRelease( s_pItmCobCallBack );
s_pItmCobCallBack = NULL;
}
hb_retni( AdsClearProgressCallback() );
}
#endif
HB_FUNC( ADSISINDEXED )
{
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
hb_retl( pArea->hOrdCurrent );
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSISEXPRVALID ) /* cExpr */
{
ADSAREAP pArea;
UNSIGNED16 bValidExpr = FALSE;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea && ISCHAR( 1 ) )
{
AdsIsExprValid( pArea->hTable, (UNSIGNED8*) hb_parc( 1 ), &bValidExpr );
}
hb_retl( bValidExpr != FALSE );
}
HB_FUNC( ADSGETNUMINDEXES ) /* cExpr */
{
ADSAREAP pArea;
UNSIGNED16 pusCnt = 0;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
AdsGetNumIndexes( pArea->hTable, &pusCnt );
}
hb_retni( pusCnt );
}
HB_FUNC( ADSCONNECTION ) // Get/Set func to switch between connections
{
ADSHANDLE hOldHandle = adsConnectHandle;
adsConnectHandle = HB_ADS_PARCONNECTION( 1 );
HB_ADS_RETCONNECTION( hOldHandle );
}
HB_FUNC( ADSGETHANDLETYPE ) // DD, admin, table
{
UNSIGNED32 ulRetVal ;
UNSIGNED16 usType;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 );
ulRetVal = AdsGetHandleType( hConnect, &usType);
if( ulRetVal == AE_SUCCESS )
{
hb_retnl( usType );
}else
{
hb_retnl( AE_INVALID_HANDLE );
}
}
HB_FUNC( ADSGETLASTERROR )
{
/* nLastErr := AdsGetLastError( [ @cLastErr ] ) */
UNSIGNED32 ulLastErr;
UNSIGNED16 usLength = ADS_MAX_ERROR_LEN + 1;
UNSIGNED8 aucError[ ADS_MAX_ERROR_LEN + 1 ];
AdsGetLastError( &ulLastErr, aucError, &usLength );
if( hb_pcount() > 0 )
{
hb_storclen( ( char * ) aucError, usLength, 1 );
}
hb_retnl( ulLastErr );
}
HB_FUNC( ADSGETNUMOPENTABLES )
{
UNSIGNED16 pusNum = 0;
AdsGetNumOpenTables( &pusNum ) ;
hb_retnl( pusNum );
}
HB_FUNC( ADSSHOWERROR )
{
AdsShowError( (UNSIGNED8 *) hb_parc( 1 ) );
}
HB_FUNC( ADSBEGINTRANSACTION )
{
ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0;
if( AdsBeginTransaction( hConnect ) == AE_SUCCESS )
{
hb_retl( TRUE );
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSCOMMITTRANSACTION )
{
ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0;
if( AdsCommitTransaction( hConnect ) == AE_SUCCESS )
{
hb_retl( TRUE );
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSFAILEDTRANSACTIONRECOVERY )
{
UNSIGNED8 *pucServer = ( UNSIGNED8 *) ( ISCHAR( 1 ) ? hb_parcx( 1 ) : NULL );
if( AdsFailedTransactionRecovery( pucServer ) == AE_SUCCESS )
{
hb_retl( TRUE );
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSINTRANSACTION )
{
ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0;
UNSIGNED16 pbInTrans;
if( AdsInTransaction( hConnect, &pbInTrans ) == AE_SUCCESS )
{
hb_retl( pbInTrans );
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSROLLBACK )
{
ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0;
if( AdsRollbackTransaction( hConnect ) == AE_SUCCESS )
{
hb_retl( TRUE );
}
else
{
hb_retl( FALSE );
}
}
/*
set the number of records to read ahead, for the current work area
Call : ADSCACHERECORDS(nRecords)
Returns : True if successful
*/
HB_FUNC( ADSCACHERECORDS )
{
UNSIGNED32 ulRetVal ;
ADSAREAP pArea;
ulRetVal = FALSE;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsCacheRecords( pArea->hTable, hb_parni( 1 ) );
}
if( !pArea || ulRetVal != AE_SUCCESS )
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCACHERECORDS" );
}
hb_retl( ulRetVal );
}
/*
Reindex all tags of the currently selected table
Returns true if successful, false if fails.
Error code available by calling AdsGetLastError()
*/
HB_FUNC( ADSREINDEX )
{
UNSIGNED32 ulRetVal;
ADSAREAP pArea;
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsReindex( pArea->hTable );
}
else
{
ulRetVal = AdsReindex( ( ADSHANDLE ) -1 ); // should return error!
}
if( ulRetVal == AE_SUCCESS )
{
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSVERSION )
{
int iVersionType = ISNUM( 1 ) ? hb_parni( 1 ) : 0;
UNSIGNED32 ulMajor;
UNSIGNED32 ulMinor;
UNSIGNED8 ucLetter;
UNSIGNED8 ucDesc[128];
UNSIGNED16 usDescLen = sizeof( ucDesc ) - 1, usPos;
char ucVersion[256];
AdsGetVersion( &ulMajor, &ulMinor, &ucLetter, ucDesc, &usDescLen );
switch( iVersionType )
{
case 0:
sprintf( ucVersion, "%ld.%ld%c", ulMajor, ulMinor, ucLetter );
break;
case 3:
sprintf( ucVersion, "%s, v%ld.%ld%c", (char *) ucDesc, ulMajor, ulMinor, ucLetter );
break;
default:
ucVersion[0] = 0;
}
usPos = strlen( ucVersion ) - 1;
while( ucVersion[usPos] == 0x20 && usPos > 0 ) // remove trailing spaces
{
ucVersion[usPos--] = 0;
}
hb_retc( ucVersion );
}
HB_FUNC( ADSCACHEOPENTABLES )
{
UNSIGNED16 usOpen = hb_parni( 1 );
UNSIGNED32 ulRetVal = AdsCacheOpenTables( usOpen );
hb_retnl( ulRetVal );
}
HB_FUNC( ADSCACHEOPENCURSORS )
{
UNSIGNED16 usOpen = hb_parni( 1 );
UNSIGNED32 ulRetVal = AdsCacheOpenCursors( usOpen );
hb_retnl( ulRetVal );
}
#if ADS_REQUIRE_VERSION >= 6
HB_FUNC( ADSGETNUMACTIVELINKS ) // requires 6.2 ! Only valid for a DataDict
{
UNSIGNED16 pusNumLinks = 0;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 );
if( hConnect )
{
AdsGetNumActiveLinks( hConnect, &pusNumLinks );
}
hb_retnl( pusNumLinks );
}
HB_FUNC( ADSDDADDTABLE )
{
UNSIGNED32 ulRetVal;
UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 );
UNSIGNED8 *pTableFileName = (UNSIGNED8 *) hb_parcx( 2 );
UNSIGNED8 *pTableIndexFileName = (UNSIGNED8 *) hb_parcx( 3 );
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 );
ulRetVal = AdsDDAddTable( hConnect, pTableName, pTableFileName, adsFileType, adsCharType, pTableIndexFileName, NULL );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSDDADDUSERTOGROUP )
{
UNSIGNED32 ulRetVal;
UNSIGNED8 *pGroup = (UNSIGNED8 *) hb_parcx( 1 );
UNSIGNED8 *pName = (UNSIGNED8 *) hb_parcx( 2 );
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 );
ulRetVal = AdsDDAddUserToGroup( hConnect,
pGroup,
pName );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSCONNECT60 )
{
UNSIGNED32 ulRetVal ;
UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 1 );
UNSIGNED16 usServerTypes = (UNSIGNED16) hb_parni( 2 );
UNSIGNED8 *pucUserName = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL ;
UNSIGNED8 *pucPassword = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL ;
UNSIGNED32 ulOptions = ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT ;
ADSHANDLE hConnect = 0;
ulRetVal = AdsConnect60( pucServerPath,
usServerTypes,
pucUserName,
pucPassword,
ulOptions,
&hConnect );
if( ulRetVal == AE_SUCCESS )
{
// determine if is a DataDict
UNSIGNED16 usType;
BOOL fDictionary = FALSE;
PHB_ITEM piByRefHandle = hb_param( 6, HB_IT_BYREF );
ulRetVal = AdsGetHandleType( hConnect, &usType);
if( ulRetVal == AE_SUCCESS )
{
fDictionary = ( usType == ADS_DATABASE_CONNECTION
|| usType == ADS_SYS_ADMIN_CONNECTION );
}
adsConnectHandle = hConnect; // set new default
if ( piByRefHandle )
{
hb_stornl( hConnect, 6 );
}
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
HB_FUNC( ADSDDCREATE )
{
UNSIGNED32 ulRetVal;
UNSIGNED8 *pucDictionaryPath = (UNSIGNED8 *) hb_parcx( 1 );
UNSIGNED16 usEncrypt = (UNSIGNED16) ISNUM( 2 ) ? hb_parnl( 0 ) : 0;
UNSIGNED8 *pucDescription = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL;
ADSHANDLE hConnect = 0;
ulRetVal = AdsDDCreate( ( UNSIGNED8 *)pucDictionaryPath,
usEncrypt,
( UNSIGNED8 *)pucDescription,
&hConnect );
if( ulRetVal == AE_SUCCESS )
{
adsConnectHandle = hConnect;
hb_retl( TRUE );
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSDDCREATEUSER )
{
UNSIGNED32 ulRetVal;
UNSIGNED8 *pucGroupName = ISCHAR( 1 ) ? (UNSIGNED8 *) hb_parcx( 1 ) : NULL;
UNSIGNED8 *pucUserName = ISCHAR( 2 ) ? (UNSIGNED8 *) hb_parcx( 2 ) : NULL;
UNSIGNED8 *pucPassword = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL;
UNSIGNED8 *pucDescription = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 5 );
ulRetVal = AdsDDCreateUser( hConnect, pucGroupName,
pucUserName, pucPassword, pucDescription );
hb_retl( ulRetVal == AE_SUCCESS );
}
HB_FUNC( ADSDDGETDATABASEPROPERTY )
{
#define ADS_MAX_PARAMDEF_LEN 2048
UNSIGNED16 ulProperty = ( UNSIGNED16 ) hb_parni( 1 );
char sBuffer[ ADS_MAX_PARAMDEF_LEN ];
UNSIGNED16 ulLength;
UNSIGNED16 ulBuffer;
BOOL bChar = FALSE;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 );
switch ( ulProperty )
{
case ADS_DD_COMMENT:
case ADS_DD_DEFAULT_TABLE_PATH:
case ADS_DD_USER_DEFINED_PROP:
case ADS_DD_TEMP_TABLE_PATH:
case ADS_DD_VERSION:
{
ulLength = ADS_MAX_PARAMDEF_LEN ;
AdsDDGetDatabaseProperty( hConnect, ulProperty, &sBuffer, &ulLength );
bChar = TRUE ;
break;
}
case ADS_DD_LOG_IN_REQUIRED:
case ADS_DD_VERIFY_ACCESS_RIGHTS:
case ADS_DD_ENCRYPT_TABLE_PASSWORD:
case ADS_DD_ENCRYPT_NEW_TABLE:
{
ulLength = sizeof( UNSIGNED16 );
AdsDDGetDatabaseProperty( hConnect, ulProperty, &ulBuffer, &ulLength );
break;
}
}
if( ulProperty == ADS_DD_LOG_IN_REQUIRED || ulProperty == ADS_DD_VERIFY_ACCESS_RIGHTS || ulProperty == ADS_DD_ENCRYPT_NEW_TABLE )
{
hb_retl( ulBuffer );
}
else if( bChar )
{
hb_retclen( sBuffer, ulLength );
}
else
{
hb_retnl( ulBuffer );
}
}
HB_FUNC( ADSDDSETDATABASEPROPERTY )
{
// char * szProperty;
// UNSIGNED16 ulLength;
UNSIGNED32 ulRetVal;
UNSIGNED16 ulBuffer;
UNSIGNED16 ulProperty = ( UNSIGNED16 ) hb_parni( 1 );
PHB_ITEM pParam = hb_param( 2, HB_IT_ANY ) ;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 );
switch( ulProperty )
{
case ADS_DD_COMMENT:
case ADS_DD_DEFAULT_TABLE_PATH:
case ADS_DD_USER_DEFINED_PROP:
case ADS_DD_TEMP_TABLE_PATH:
case ADS_DD_ADMIN_PASSWORD:
case ADS_DD_ENCRYPT_TABLE_PASSWORD:
{
ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, hb_itemGetCPtr( pParam ), ( UNSIGNED16 ) hb_itemGetCLen( pParam ) );
break;
}
case ADS_DD_MAX_FAILED_ATTEMPTS:
case ADS_DD_INTERNET_SECURITY_LEVEL:
case ADS_DD_VERSION_MAJOR:
case ADS_DD_VERSION_MINOR:
{
ulBuffer = hb_itemGetNI( pParam );
ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, 2 );
break;
}
case ADS_DD_LOG_IN_REQUIRED:
case ADS_DD_VERIFY_ACCESS_RIGHTS:
case ADS_DD_ENCRYPT_NEW_TABLE:
case ADS_DD_ENABLE_INTERNET:
{
ulBuffer = hb_itemGetL( pParam );
ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, 2 );
break;
}
default:
{
ulRetVal = ~AE_SUCCESS;
break;
}
}
hb_retl( ulRetVal == AE_SUCCESS);
}
/*
UNSIGNED32 ENTRYPOINT AdsDDGetUserProperty( ADSHANDLE hObject,
UNSIGNED8 *pucUserName,
UNSIGNED16 usPropertyID,
VOID *pvProperty,
UNSIGNED16 *pusPropertyLen );
*/
HB_FUNC( ADSDDGETUSERPROPERTY )
{
UNSIGNED32 ulRetVal;
UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parcx( 1 );
UNSIGNED16 usPropertyID = hb_parni( 2 );
UNSIGNED8 *pvProperty = (UNSIGNED8 *) hb_parcx( 3 );
UNSIGNED16 usPropertyLen = hb_parni( 4 );
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 5 );
ulRetVal = AdsDDGetUserProperty( hConnect, pucUserName, usPropertyID,
pvProperty, &usPropertyLen );
hb_retl( ulRetVal == AE_SUCCESS );
}
/*
Verify if a username/password combination is valid for this database
Call : ADSTESTLOGIN(serverpath,servertypes,username,password,options,
[userproperty,buffer,bufferlength])
Returns : True if login succeeds
Notes: This creates a temporary connection only during the execution of this
function, without disturbing the stored one for any existing connection
If the optional last 3 parameters are supplied, then it queries the
requested user property and returns it in the buffer. This is useful
fo example to get the groups of which the user is a member
*/
HB_FUNC( ADSTESTLOGIN )
{
UNSIGNED32 ulRetVal ;
UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 1 );
UNSIGNED16 usServerTypes = (UNSIGNED16) hb_parni( 2 );
UNSIGNED8 *pucUserName = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL;
UNSIGNED8 *pucPassword = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL;
UNSIGNED32 ulOptions = ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT;
UNSIGNED16 usPropertyID = ISNUM( 6 ) ? hb_parni( 6 ) : 0;
UNSIGNED8 *pvProperty = ISCHAR( 7 ) ? (UNSIGNED8 *) hb_parcx( 7 ) : NULL;
UNSIGNED16 usPropertyLen = ISNUM( 8 ) ? hb_parni( 8 ) : 0;
ADSHANDLE adsTestHandle;
ulRetVal = AdsConnect60( pucServerPath,
usServerTypes,
pucUserName,
pucPassword,
ulOptions,
&adsTestHandle );
if( ulRetVal == AE_SUCCESS )
{
if( usPropertyLen > 0 )
{
AdsDDGetUserProperty( adsTestHandle, pucUserName, usPropertyID,
pvProperty, &usPropertyLen );
}
AdsDisconnect( adsTestHandle );
hb_retl( 1 ) ;
}
else
{
hb_retl( 0 ) ;
}
}
HB_FUNC( ADSRESTRUCTURETABLE )
{
// call:
// AdsRestructureTable( cTable, cAddFields, cDeleteFields, cChangeFields )
//UNSIGNED32 AdsRestructureTable( ADSHANDLE hConnect,UNSIGNED8 *pucName,
// UNSIGNED8 *pucAlias,UNSIGNED16 usTableType,UNSIGNED16 usCharType,
// UNSIGNED16 usLockType,UNSIGNED16 usCheckRights,UNSIGNED8
// *pucAddFields,UNSIGNED8 *pucDeleteFields,UNSIGNED8 *pucChangeFields );
//adsFileType ADS_DEFAULT, ADS_ADT, ADS_NTX and ADS_CDX
UNSIGNED32 ulRetVal;
UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 );
UNSIGNED8 *pucAddFields = (UNSIGNED8 *) hb_parcx( 2 );
UNSIGNED8 *pucDeleteFields = (UNSIGNED8 *) hb_parcx( 3 );
UNSIGNED8 *pucChangeFields = (UNSIGNED8 *) hb_parcx( 4 );
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 5 );
ulRetVal = AdsRestructureTable( hConnect, pTableName, NULL,
adsFileType, adsCharType, adsLockType,
adsRights,
pucAddFields,
pucDeleteFields,
pucChangeFields );
hb_retl( (long) ulRetVal );
}
HB_FUNC( ADSCOPYTABLECONTENTS )
{
ADSAREAP pArea;
ADSAREAP pDest;
UNSIGNED32 ulRetVal;
char * szAlias = hb_parcx( 1 );
pArea = hb_rddGetADSWorkAreaPointer(); // Source
if( pArea )
{
if( hb_rddSelectWorkAreaAlias( szAlias ) == SUCCESS )
{
pDest = hb_rddGetADSWorkAreaPointer(); // Destination
if( pDest )
{
ulRetVal = AdsCopyTableContents( pArea->hTable,
pDest->hTable,
ADS_IGNOREFILTERS );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCOPYTABLECONTENTS" );
}
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCOPYTABLECONTENTS" );
}
}
HB_FUNC( ADSDIRECTORY )
{
UNSIGNED32 ulRetVal;
UNSIGNED8 ucFileName[ ADS_MAX_TABLE_NAME ];
UNSIGNED16 usFileNameLen;
SIGNED32 sHandle = 0;
PHB_ITEM pitmDir, pitmFileName;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 );
pitmDir = hb_itemNew( NULL );
hb_arrayNew( pitmDir, 0 );
usFileNameLen = ADS_MAX_TABLE_NAME;
ulRetVal = AdsFindFirstTable( hConnect, ( UNSIGNED8* ) ( ISCHAR( 1 ) ? hb_parcx( 1 ) : "" ), ucFileName, &usFileNameLen, &sHandle );
if ( ulRetVal == AE_SUCCESS || ulRetVal == AE_NO_FILE_FOUND )
{
do {
pitmFileName = hb_itemPutCL( NULL, (char *) ucFileName, usFileNameLen );
hb_arrayAddForward( pitmDir, pitmFileName );
usFileNameLen = ADS_MAX_TABLE_NAME;
ulRetVal = AdsFindNextTable( hConnect, sHandle, ucFileName, &usFileNameLen );
} while( ulRetVal == AE_SUCCESS );
AdsFindClose( hConnect, sHandle );
}
hb_itemRelease( hb_itemReturn( pitmDir ) );
}
HB_FUNC( ADSCHECKEXISTENCE )
{
UNSIGNED16 usExist;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 );
hb_retl( AdsCheckExistence( hConnect, ( UNSIGNED8* ) hb_parcx( 1 ), &usExist ) == AE_SUCCESS && usExist );
}
// Function is not documented, but exists in ace32.dll version 6.x, 7.x
UNSIGNED32 ENTRYPOINT AdsDeleteFile( ADSHANDLE hConnection, UNSIGNED8* pucFileName );
HB_FUNC( ADSDELETEFILE )
{
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 );
hb_retl( AdsDeleteFile( hConnect, ( UNSIGNED8* ) hb_parcx( 1 ) ) == AE_SUCCESS );
}
HB_FUNC( ADSSTMTSETTABLEPASSWORD )
{
ADSAREAP pArea;
UNSIGNED32 ulRetVal;
char * pucTableName = hb_parcx( 1 );
char * pucPassword = hb_parcx( 2 );
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 );
if( !pucTableName || ( strlen( pucTableName ) == 0 ) || !pucPassword || ( strlen( pucPassword ) == 0 ) )
{
hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSSTMTSETTABLEPASSWORD" );
hb_retni( 0 );
}
if( !hConnect )
{
hb_errRT_DBCMD( EG_NOTABLE, AE_NO_CONNECTION, NULL, "AE_NO_CONNECTION" );
hb_retni( 0 );
}
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
ulRetVal = AdsStmtSetTablePassword( pArea->hStatement, ( UNSIGNED8 * ) pucTableName, ( UNSIGNED8 * ) pucPassword );
hb_retni( ulRetVal );
}
else
{
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSSTMTSETTABLEPASSWORD" );
}
}
#endif /* ADS_REQUIRE_VERSION >= 6 */
#if ADS_REQUIRE_VERSION >= 7
HB_FUNC( ADSCLOSECACHEDTABLES )
{
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 );
if( hConnect )
{
AdsCloseCachedTables( hConnect );
hb_retl( 1 );
}
else
{
hb_retl( 0 );
}
}
#endif /* ADS_REQUIRE_VERSION >= 7 */
/* Please add all-version functions above this block */