├── Changelog ├── tests ├── letoudf.hrb ├── letoudf.hbp ├── hbmk.hbm ├── runall.bat ├── buildall.sh ├── runall.sh ├── buildall.bat ├── rddleto.txt ├── c_lang │ ├── bldc.sh │ ├── bldc.bat │ ├── elsof.c │ ├── test1.c │ └── test_var.c ├── basic.prg ├── plug_ver.hb ├── excltest.prg ├── bug_info.prg ├── php │ └── testleto1.php ├── test_ta.prg ├── ron.prg └── test_file.prg ├── utils ├── manager │ ├── manage.prg │ ├── console.prg │ ├── console.hbp │ ├── replicat.hbp │ ├── manage.hbp │ └── replicat.prg ├── uhura │ ├── detect.hbp │ ├── uhudeb.hbp │ ├── uhura.hbp │ └── detect.prg ├── olesrv │ ├── letosrv.hbp │ └── letosrv.prg └── backup │ ├── letobackup.hbp │ ├── srv_win.ini │ └── srv_linux.ini ├── include ├── leto_rev.ch ├── PMurHash.h ├── letocdp.ch ├── cmdleto.h ├── rddleto.ch └── letofile.ch ├── letodb.hbc ├── .gitignore ├── source ├── 3rd │ ├── lz4 │ │ ├── lib │ │ │ ├── liblz4.pc.in │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── lz4frame_static.h │ │ │ ├── Makefile │ │ │ └── xxhash.h │ │ ├── LICENSE │ │ ├── README.md │ │ └── lz4_Block_format.md │ ├── readme.txt │ └── lz4c.diff ├── server │ ├── errint.c │ ├── letobm.prg │ ├── leto_lnx.c │ └── errorsys.prg ├── client │ └── letobmcl.prg ├── common │ └── common.prg └── phpclient │ └── letocl.php ├── bin ├── leto.sh └── letodb.ini ├── plugrand.hb ├── test_mem.exe.xbp ├── apileto.hbp ├── rddleto.lib.xbp ├── rddleto.hbp ├── makefile.gc ├── makefile.gcc ├── make_b32.bat ├── make_vc.bat ├── rddletoaddon.hbp ├── letodbsvc.hbp ├── letodb.hbp ├── letodbaddon.hbp ├── README.md ├── makefile.bc └── makefile.vc /Changelog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elchs/LetoDBf/HEAD/Changelog -------------------------------------------------------------------------------- /tests/letoudf.hrb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elchs/LetoDBf/HEAD/tests/letoudf.hrb -------------------------------------------------------------------------------- /utils/manager/manage.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elchs/LetoDBf/HEAD/utils/manager/manage.prg -------------------------------------------------------------------------------- /utils/manager/console.prg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elchs/LetoDBf/HEAD/utils/manager/console.prg -------------------------------------------------------------------------------- /include/leto_rev.ch: -------------------------------------------------------------------------------- 1 | /* do not edit --- automated created file */ 2 | #define __SRV_REVISION__ "unknown" 3 | #define __RDD_REVISION__ "unknown" 4 | -------------------------------------------------------------------------------- /tests/letoudf.hbp: -------------------------------------------------------------------------------- 1 | 2 | # output path does not work with .hrb ? 3 | -o../bin 4 | 5 | -W3 6 | -es0 7 | -n 8 | -gh 9 | 10 | letoudf.prg 11 | -------------------------------------------------------------------------------- /utils/uhura/detect.hbp: -------------------------------------------------------------------------------- 1 | detect.prg 2 | 3 | ../letodb.hbc 4 | -W3 5 | -es0 6 | -n 7 | -mt 8 | -gtxwc{unix} 9 | -gtwvt{win} 10 | #-strip 11 | -------------------------------------------------------------------------------- /tests/hbmk.hbm: -------------------------------------------------------------------------------- 1 | ../letodb.hbc 2 | -W3 3 | -es0 4 | -n 5 | -mt 6 | -gtxwc{unix} 7 | -gtwvt{win} 8 | #-strip 9 | 10 | -plugin=plug_ver.hb 11 | 12 | -------------------------------------------------------------------------------- /letodb.hbc: -------------------------------------------------------------------------------- 1 | incpaths=include 2 | libpaths=lib 3 | 4 | headers=include/rddleto.ch include/leto_std.ch 5 | requests=LETO 6 | 7 | libs=${_HB_DYNPREF}rddleto${_HB_DYNSUFF} 8 | 9 | mt=yes 10 | -------------------------------------------------------------------------------- /utils/olesrv/letosrv.hbp: -------------------------------------------------------------------------------- 1 | -hbdynvm 2 | -w 3 | 4 | {bcc}-l..\..\lib\mingw\rddleto.lib 5 | {mingw}-l..\..\lib\mingw\librddleto.a 6 | 7 | # copy hbolesrv.hbc and. *.def file from /harbour/contrib/hbwin folder 8 | hbolesrv.hbc 9 | 10 | letosrv.prg 11 | -------------------------------------------------------------------------------- /utils/uhura/uhudeb.hbp: -------------------------------------------------------------------------------- 1 | # uhura 2 | 3 | -W2 4 | -es0 5 | -st 6 | #-static 7 | #-gc3 8 | #-strip 9 | -b 10 | -mt 11 | 12 | hbunix.hbc{unix} 13 | -DDEBUG=1 14 | 15 | -gtxwc{unix} 16 | -lXpm{unix} 17 | -gtwvt{!unix} 18 | hbwin.hbc{!unix} 19 | uhura.prg 20 | -------------------------------------------------------------------------------- /utils/uhura/uhura.hbp: -------------------------------------------------------------------------------- 1 | # uhura 2 | 3 | -o../../bin/uhura 4 | -W3 5 | -es0 6 | -st 7 | {!win}-static 8 | {win}-fullstatic 9 | -gc3 10 | -strip 11 | -mt 12 | #-p+ 13 | 14 | hbunix.hbc{unix} 15 | 16 | -gtxwc{unix} 17 | -gtwvt{!unix} 18 | hbwin.hbc{!unix} 19 | uhura.prg 20 | -------------------------------------------------------------------------------- /utils/backup/letobackup.hbp: -------------------------------------------------------------------------------- 1 | -n 2 | -w3 3 | -q0 4 | -es0 5 | -mt 6 | -strip 7 | 8 | {!win}-static 9 | {win}-fullstatic 10 | {mingw64}-pic 11 | 12 | {linux}-gtxwc 13 | {win}-gtwvt 14 | 15 | ../../letodb.hbc 16 | 17 | letobackup.prg 18 | ../../source/common/common.prg 19 | 20 | -------------------------------------------------------------------------------- /tests/runall.bat: -------------------------------------------------------------------------------- 1 | IF "%1." == "." ( 2 | set ADDR="127.0.0.1:2812" 3 | ) ELSE ( 4 | set ADDR="%1" 5 | ) 6 | 7 | ron %ADDR% 8 | test_dbf %ADDR% 9 | test_dbfe %ADDR% 10 | test_file %ADDR% 11 | test_filt %ADDR% 12 | test_ta %ADDR% 13 | test_tr %ADDR% 14 | test_var %ADDR% 15 | test_var %ADDR% 16 | -------------------------------------------------------------------------------- /tests/buildall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | hbmk2 nenadi.prg 4 | hbmk2 ron.prg 5 | hbmk2 test_dbf.prg 6 | hbmk2 test_dbfe.prg 7 | hbmk2 test_file.prg 8 | hbmk2 test_filt.prg 9 | hbmk2 test_ta.prg 10 | hbmk2 test_tr.prg 11 | hbmk2 test_var.prg 12 | hbmk2 test_mem.prg -D__MEMIO__=1 13 | hbmk2 letoudf 14 | hbmk2 bug_info 15 | 16 | -------------------------------------------------------------------------------- /tests/runall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$1." = "." ]; then 4 | ADDR="127.0.0.1:2812" 5 | else 6 | ADDR="$1" 7 | fi 8 | 9 | ./ron $ADDR 10 | ./test_dbf $ADDR 11 | ./test_dbfe $ADDR 12 | ./test_file $ADDR 13 | ./test_filt $ADDR 14 | ./test_ta $ADDR 15 | ./test_tr $ADDR 16 | ./test_var $ADDR 17 | ./test_var $ADDR 18 | 19 | -------------------------------------------------------------------------------- /tests/buildall.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | hbmk2 nenadi.prg 4 | hbmk2 ron.prg 5 | hbmk2 test_dbf.prg 6 | hbmk2 test_dbfe.prg 7 | hbmk2 test_file.prg 8 | hbmk2 test_filt.prg 9 | hbmk2 test_ta.prg 10 | hbmk2 test_tr.prg 11 | hbmk2 test_var.prg 12 | hbmk2 test_mem.prg -D__MEMIO__=1 13 | hbmk2 letoudf 14 | hbmk2 bug_info 15 | 16 | -------------------------------------------------------------------------------- /utils/manager/console.hbp: -------------------------------------------------------------------------------- 1 | -o../../bin/console 2 | 3 | -n 4 | -w3 5 | -q0 6 | -es0 7 | -mt 8 | -strip 9 | 10 | {!win}-static 11 | {win}-fullstatic 12 | {mingw64}-pic 13 | 14 | {linux}-gtxwc 15 | {win}-gtwvt 16 | 17 | {bcc}-lhbct 18 | {!bcc}hbct.hbc 19 | ../../letodb.hbc 20 | 21 | console.prg 22 | ../../source/common/common.prg 23 | 24 | -------------------------------------------------------------------------------- /tests/rddleto.txt: -------------------------------------------------------------------------------- 1 | ; LetoDBf application config with file extension: .ini 2 | 3 | ;Server = DETECT[:service] | [//]DNSname|IP[:port][/] 4 | Server = localhost 5 | ;User = UnPaid 6 | ;TimeOut = -1 7 | ;Cache_Timeout = 100 8 | ;Date_Format = yyyymmdd 9 | ;Path_Default = 10 | ;Path_Search = 11 | ;SMB_Server = DNSname|IP 12 | ;SMB_Port = 2814 13 | -------------------------------------------------------------------------------- /utils/manager/replicat.hbp: -------------------------------------------------------------------------------- 1 | -o../../bin/replicat 2 | 3 | -n 4 | -w3 5 | -q0 6 | -es0 7 | -mt 8 | -strip 9 | 10 | {!win}-static 11 | {win}-fullstatic 12 | {mingw64}-pic 13 | 14 | {linux}-gtxwc 15 | {win}-gtwvt 16 | 17 | {bcc}-lhbct 18 | {!bcc}hbct.hbc 19 | ../../letodb.hbc 20 | 21 | replicat.prg 22 | ../../source/common/common.prg 23 | 24 | -------------------------------------------------------------------------------- /utils/manager/manage.hbp: -------------------------------------------------------------------------------- 1 | # adapt path to base directory of HwGUI 2 | -env:HWGUI_DIR=D:\hwgui 3 | 4 | -o../../bin/manage 5 | -n 6 | -w 7 | -q0 8 | -es2 9 | 10 | -gui 11 | -mt 12 | -strip 13 | 14 | -i${HWGUI_DIR}/include 15 | -L${HWGUI_DIR}/lib 16 | -lhbxml 17 | -lhwgui 18 | -lprocmisc 19 | ../../letodb.hbc 20 | 21 | manage.prg 22 | {win}-manifest=${HWGUI_DIR}/image/WindowsXP.Manifest 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | -------------------------------------------------------------------------------- /source/3rd/lz4/lib/liblz4.pc.in: -------------------------------------------------------------------------------- 1 | # LZ4 - Fast LZ compression algorithm 2 | # Copyright (C) 2011-2014, Yann Collet. 3 | # BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 4 | 5 | prefix=@PREFIX@ 6 | libdir=@LIBDIR@ 7 | includedir=@INCLUDEDIR@ 8 | 9 | Name: lz4 10 | Description: fast lossless compression algorithm library 11 | URL: http://code.google.com/p/lz4/ 12 | Version: @VERSION@ 13 | Libs: -L@LIBDIR@ -llz4 14 | Cflags: -I@INCLUDEDIR@ 15 | -------------------------------------------------------------------------------- /bin/leto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # following '281' checks for socket ports: 281x 4 | # aka for LetoDBf default two ports 2812 & 2813 5 | 6 | while ss -tan state time-wait | grep -q 281 7 | do 8 | sleep 3s 9 | done 10 | 11 | while ss -tan state last-ack | grep -q 281 12 | do 13 | sleep 3s 14 | done 15 | 16 | 17 | if ss -tl | grep -q 281 18 | then 19 | echo "LetoDB already started" 20 | else 21 | if [ -f letodbf.log ]; then 22 | rm letodbf.log 23 | fi 24 | 25 | if [ $# -gt 0 ]; then 26 | ./letodb config $1 27 | else 28 | ./letodb 29 | fi 30 | echo "LetoDB runs" 31 | fi 32 | 33 | # beep -f 2500 -l 1000 34 | 35 | -------------------------------------------------------------------------------- /source/3rd/readme.txt: -------------------------------------------------------------------------------- 1 | About LZ4 compression: 2 | 3 | this is used alternatively to else used ZLIB compression. 4 | Very! recommended, ultra-fast compression algorithm best suited for the task 5 | to compress network traffic. 6 | 7 | Not needed, but theoretically you can refresh LZ4 distro, 8 | by cloning an (when !) updated repository into this location with: 9 | git clone https://github.com/Cyan4973/lz4 lz4 10 | 11 | Note, that a very slighly patched version is used, see lz4.c.dif and lz4.h.dif, 12 | but it shell work without that for LetoDBf. 13 | Also note, that only the pure 'lib' directory of the distro is distributed, 14 | without the bunch of test applications etc. 15 | If you are additional interested in that, checkout given above link. -------------------------------------------------------------------------------- /source/3rd/lz4/LICENSE: -------------------------------------------------------------------------------- 1 | This repository uses 2 different licenses : 2 | - all files in the `lib` directory use a BSD 2-Clause license 3 | - all other files use a GPLv2 license, unless explicitly stated otherwise 4 | 5 | Relevant license is reminded at the top of each source file, 6 | and with the presence of COPYING or LICENSE file. 7 | 8 | This model emphasizes the fact that 9 | only files in the `lib` directory are designed to be included into 3rd party projects. 10 | 11 | Other files, such as those from `programs` or `examples` directory, 12 | are not intended to be compiled outside of their context. 13 | They can serve as source of inspiration, 14 | but they should not be copy/pasted into 3rd party projects, 15 | as this scenario is not supported. 16 | -------------------------------------------------------------------------------- /plugrand.hb: -------------------------------------------------------------------------------- 1 | 2 | FUNCTION hbmk_plugin_rand( hbmk ) 3 | 4 | LOCAL tmp 5 | 6 | SWITCH hbmk[ "cSTATE" ] 7 | 8 | CASE "pre_all" 9 | tmp := RandomString( 42 ) 10 | hbmk_AddOption_PRG( hbmk, "-D__RANDOM_STRING__=" + CHR( 34 ) + tmp + CHR( 34 ) ) 11 | hbmk_AddOption_C( hbmk, "-D__RANDOM_STRING__='" + CHR( 34 ) + tmp + CHR( 34 ) + "'" ) 12 | EXIT 13 | 14 | ENDSWITCH 15 | 16 | RETURN NIL 17 | 18 | STATIC FUNCTION RandomString( nLen ) 19 | LOCAL tmp := "" 20 | LOCAL i := 1 21 | LOCAL aInvalid := { 92, 96, 239 } 22 | LOCAL n 23 | 24 | hb_randomSeed( hb_milliseconds() ) 25 | DO WHILE i < nLen 26 | n := INT( hb_random() * 254 ) 27 | If n > 39 .AND. ASCAN( aInvalid, n ) == 0 28 | tmp += CHR( n ) 29 | i++ 30 | ENDIF 31 | ENDDO 32 | RETURN tmp 33 | -------------------------------------------------------------------------------- /test_mem.exe.xbp: -------------------------------------------------------------------------------- 1 | CINI = 2 | C_OUTPUTFOLDER = 3 | DEFFILE = 4 | INCLUDEFOLDERS = include;c:\xhb\include;c:\xhb\c_include;c:\xhb\c_include\win; 5 | LAUTORUN = 6 | LDEBUG = .F. 7 | LGUI = .F. 8 | LIBFOLDERS = lib;c:\xHB\lib;C:\xHB\c_lib;C:\xHB\c_lib\win 9 | LMT = .F. 10 | LNOAUTOFWH = .F. 11 | LPRG_CLASSICDEBUG = .T. 12 | LPRG_DEBUG = .T. 13 | LUSEDLL = .F. 14 | MAPFILE = 15 | MYC_FLAGS = 16 | MYDEFINES = 17 | MYLINK_FLAGS = 18 | MYPRG_FLAGS = /l /n /u+leto_std.ch /u+rddleto.ch 19 | MYRC_FLAGS = 20 | MYSLY_FLAGS = 21 | OUTPUTFOLDER = obj 22 | PRG_OUTPUTFOLDER = 23 | RC_OUTPUTFOLDER = 24 | RUNARGUMENTS = 127.0.0.1 25 | SLY_OUTPUTFOLDER = 26 | STARTIN = 27 | TARGETFOLDER = 28 | 29 | [tests\test_mem.prg] 30 | MYC_FLAGS = 31 | MYDEFINES = 32 | MYPRG_FLAGS = 33 | 34 | [lib\rddleto.lib] 35 | 36 | [C:\xHB\c_lib\crtmt.lib] 37 | -------------------------------------------------------------------------------- /tests/c_lang/bldc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # batch for GCC 3 | 4 | ### need to adapt 5 | HB_DIR=/usr 6 | HB_LIB=$HB_DIR/lib/harbour 7 | HB_INC=$HB_DIR/include/harbour 8 | 9 | ### in harbour/addon/letodb directory 10 | #OS_TYPE=linux 11 | #HB_DIR=../.. 12 | #HB_LIB=$HRB_DIR/lib/$OS_TYPE/gcc 13 | #HB_INC=$HRB_DIR/include/harbour 14 | 15 | ### no adapt below needed 16 | 17 | LETO_DIR=../.. 18 | LETO_INC=$LETO_DIR/include 19 | LETO_LIB=$LETO_DIR/lib 20 | 21 | HARBOUR_LIBS="-lhbvm -lhbrtl -lhbcommon -lhbmacro -lgttrm -lhbrdd -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcommon" 22 | SYSTEM_LIBS="-lm -ldl -lrt" 23 | 24 | ### static build 25 | gcc $1.c -O3 -I$LETO_INC -I$HB_INC -L$LETO_LIB -L$HB_LIB -lleto -Wl,--start-group $HARBOUR_LIBS $SYSTEM_LIBS -Wl,--end-group -o $1 26 | 27 | ### dynamic build 28 | #gcc $1.c -O3 -I$LETO_INC -I$HB_INC -L$LETO_LIB -L$HB_LIB -lleto -lharbour -lhbzlib -o $1 29 | 30 | -------------------------------------------------------------------------------- /tests/c_lang/bldc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM ## batch for Borland BCC 3 | 4 | REM ## adapt paths to C-compiler and Harbour bin directory 5 | rem SET PATH=C:\BCC55\BIN;F:\hbbcc\bin 6 | rem SET HB_PATH=F:\hbbcc 7 | 8 | set HB_DIR=%HB_PATH% 9 | set HB_INC=%HB_DIR%\include 10 | set HB_LIB=%HB_DIR%\lib\win\bcc 11 | 12 | REM ## no adapt below needed 13 | 14 | set LETO_DIR=..\.. 15 | set LETO_INC=%LETO_DIR%\include 16 | set LETO_LIB=%LETO_DIR%\lib 17 | 18 | set HARBOUR_LIBS=gtwin.lib hbvm.lib hbrtl.lib hbcommon.lib hbrdd.lib hbmacro.lib rddntx.lib rddcdx.lib rddnsx.lib rddfpt.lib hbsix.lib hbhsx.lib hbzlib.lib 19 | set BORLAND_LIBS=ws2_32.lib PSDK\iphlpapi.lib 20 | 21 | REM ## static build 22 | bcc32 -O2 -d -I%HB_INC%;%LETO_INC% -L%LETO_LIB%;%HB_LIB% %1.c leto.lib %HARBOUR_LIBS% %BORLAND_LIBS% 23 | 24 | REM ## dynmic build 25 | rem bcc32 -O2 -d -I%HB_INC%;%LETO_INC% -L%LETO_LIB%;%HB_LIB% %1.c leto.lib harbour-32-bcc.lib hbzlib.lib %BORLAND_LIBS% 26 | 27 | del %1.obj 28 | del %1.tds 29 | -------------------------------------------------------------------------------- /bin/letodb.ini: -------------------------------------------------------------------------------- 1 | ;Server = 192.168.2.47 2 | ;IP = 192.168.2.47 3 | Port = 2812 4 | DataPath = /mnt/sun/PRO-CNC/DATEN 5 | ;LogPath = /tmp 6 | Default_Driver = CDX 7 | ;Lock_Scheme = 6 8 | ;Memo_Type = FPT 9 | Share_Tables = 0 10 | No_Save_WA = 1 11 | Lower_Path = 0 12 | EnableFileFunc = 1 13 | EnableAnyExt = 1 14 | Allow_UDF = 1 15 | Pass_for_Login = 0 16 | Pass_for_Manage = 0 17 | Pass_for_Data = 0 18 | ;Pass_File = leto_users 19 | Cache_Records = 21 20 | ;Max_Vars_Number = 1000 21 | ;Max_Var_Size = 67108864 22 | ;Tables_Max = 999 23 | ;Users_Max = 99 24 | Debug = 1 25 | Optimize = 1 26 | ;AutOrder = 0 27 | ;ForceOpt = 0 28 | ;TimeOut = 360 29 | ;Zombie_Check = 0 30 | ;Server_User = advantage 31 | ;Server_UID = 1000 32 | ;Server_GID = 4 33 | ;BC_Services = letodb; 34 | ;BC_Interface = eth2 35 | ;BC_Port = 2812 36 | ;SMB_SERVER = 1 37 | Crypt_Traffic = 0 38 | DataBase = / 39 | Backup = /tmp/backup 40 | Mask = *.dbf,*.dbt,*.ntx 41 | Lock = 1 42 | Seconds = 30 43 | Wait = 1 44 | ArcCmd = tar -cvzf /tmp/backup/leto.tar.gz /tmp/backup/* 45 | 46 | -------------------------------------------------------------------------------- /tests/basic.prg: -------------------------------------------------------------------------------- 1 | /* a snippet to show the basic structure of an application using LetoDBf */ 2 | 3 | REQUEST LETO 4 | 5 | /* by using 'letodb.hbc', example: hbmk2 basic.prg letodb.hbc 6 | * this will automatic include rdddleto.ch */ 7 | #include "rddleto.ch" 8 | 9 | PROCEDURE main( cAddress ) /* pure IP-address */ 10 | 11 | //SET DEFAULT TO data 12 | //SET PATH TO system;tmp 13 | 14 | SET( _SET_DATEFORMAT, "dd.mm.yyyy" ) 15 | HB_CDPselect( "DE850" ) 16 | 17 | IF Empty( cAddress ) 18 | cAddress := "//127.0.0.1:2812/" 19 | ELSE 20 | cAddress := "//" + cAddress + IIF( ":" $ cAddress, "", ":2812" ) 21 | cAddress += IIF( Right( cAddress, 1 ) == "/", "", "/" ) 22 | ENDIF 23 | 24 | IF leto_Connect( cAddress ) < 0 25 | ALERT( "NO LETODB SERVER FOUND - ERROR: " + leto_Connect_Err( .T. ) ) 26 | QUIT 27 | ELSE 28 | // RDDSETDEFAULT( "LETO" ) /* automatic set by: REQUEST LETO */ 29 | // LETO_DBDRIVER( "DBFCDX" ) /* to choose your DBF driver independent of the server default */ 30 | LETO_TOGGLEZIP( 1 ) /* switch compressed network traffic */ 31 | ENDIF 32 | 33 | // DbUseArea( .T., /* "LETO" */, "test", "TEST", .T. ) 34 | // ... 35 | 36 | /* no special logout needed, all is automically done */ 37 | RETURN 38 | -------------------------------------------------------------------------------- /apileto.hbp: -------------------------------------------------------------------------------- 1 | # 2 | # to create the C-API lib, for access LetoDBf with pure-C [ ! not PRG ! ] 3 | # most times "rddleto.hbp" is what you are looking for 4 | # 5 | 6 | #-env:__BM=yes 7 | {!bcc}-env:__LZ4=yes 8 | -env:__PMURHASH=yes 9 | 10 | -olib/leto 11 | 12 | -cflag=-D__LETO_C_API__=1 13 | 14 | # need single threaded 15 | -cflag=-DLETO_NO_MT=1 16 | -cflag=-DLETO_NO_THREAD=1 17 | -st 18 | 19 | # static lib flags 20 | -hblib 21 | -nodefgt 22 | 23 | # dynamic lib flags ( .dll | .so -- outcomment static flags ) 24 | #-hbdynvm 25 | #-cflag=-DLETO_DYNLIB=1 26 | #-gtnul 27 | 28 | 29 | # executable must provide HB 30 | #-shared 31 | 32 | -n 33 | -w3 34 | -q0 35 | -es2 36 | -gc3 37 | -strip 38 | -rebuild 39 | -inc- 40 | 41 | -iinclude 42 | {__LZ4}-isource/3rd/lz4/lib 43 | 44 | #-cflag=-D__HARBOUR30__=1 45 | 46 | -cflag={allmsvc}-D_CRT_SECURE_NO_DEPRECATE 47 | -cflag={clang}-W 48 | -cflag={clang}-Wall 49 | -cflag={clang}-pedantic 50 | # to avoid spin locks 51 | #-cflag={win}-DHB_HELGRIND_FRIENDLY=1 52 | #-cflag=-DLETO_CLIENTLOG=1 53 | {__PMURHASH}-cflag=-DUSE_PMURHASH=1 54 | {__BM}-cflag=-D__BM=1 55 | {__LZ4}-cflag=-DUSE_LZ4=1 56 | 57 | source/client/letocl.c 58 | 59 | source/common/blowfish.c 60 | source/common/common_c.c 61 | {__LZ4}source/3rd/lz4/lib/lz4.c 62 | {__LZ4}source/common/lz4net.c 63 | {__PMURHASH}source/common/PMurHash.c 64 | 65 | -------------------------------------------------------------------------------- /rddleto.lib.xbp: -------------------------------------------------------------------------------- 1 | CINI = 2 | C_OUTPUTFOLDER = 3 | DEFFILE = 4 | INCLUDEFOLDERS = include;source\3rd\lz4\lib;c:\xhb\include;c:\xhb\c_include;c:\xhb\c_include\win; 5 | LAUTORUN = 6 | LDEBUG = .F. 7 | LGUI = .F. 8 | LIBFOLDERS = 9 | LMT = .F. 10 | LNOAUTOFWH = .F. 11 | LPRG_CLASSICDEBUG = .F. 12 | LPRG_DEBUG = .F. 13 | LUSEDLL = .F. 14 | MAPFILE = 15 | MYC_FLAGS = 16 | MYDEFINES = USE_PMURHASH=1 ;USE_LZ4=1 ;LETO_NO_MT=1 ;__NO_LZ4_WARN__=1 ;LZ4_DUMMY ;LETO_NO_THREAD=1 17 | MYLINK_FLAGS = -NOEXPOBJ -MAP -FORCE:MULTIPLE 18 | MYPRG_FLAGS = /l /n /q 19 | MYRC_FLAGS = 20 | MYSLY_FLAGS = 21 | OUTPUTFOLDER = obj\xhb 22 | PRG_OUTPUTFOLDER = 23 | RC_OUTPUTFOLDER = 24 | RUNARGUMENTS = 127.0.0.1 25 | SLY_OUTPUTFOLDER = 26 | STARTIN = 27 | TARGETFOLDER = lib 28 | 29 | [source\client\rddsys.prg] 30 | MYC_FLAGS = 31 | MYDEFINES = 32 | MYPRG_FLAGS = 33 | 34 | [source\client\letomgmn.c] 35 | MYC_FLAGS = 36 | MYDEFINES = 37 | 38 | [source\client\letocl.c] 39 | MYC_FLAGS = 40 | MYDEFINES = 41 | 42 | [source\common\common_c.c] 43 | MYC_FLAGS = 44 | MYDEFINES = 45 | 46 | [source\common\blowfish.c] 47 | MYC_FLAGS = 48 | MYDEFINES = 49 | 50 | [source\client\leto1.c] 51 | MYC_FLAGS = 52 | MYDEFINES = 53 | 54 | [source\common\PMurHash.c] 55 | MYC_FLAGS = 56 | MYDEFINES = 57 | 58 | [source\common\lz4net.c] 59 | MYC_FLAGS = 60 | MYDEFINES = 61 | -------------------------------------------------------------------------------- /source/3rd/lz4/lib/LICENSE: -------------------------------------------------------------------------------- 1 | LZ4 Library 2 | Copyright (c) 2011-2014, Yann Collet 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, this 12 | list of conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /rddleto.hbp: -------------------------------------------------------------------------------- 1 | #-env:__BM=yes 2 | -env:__LZ4=yes 3 | -env:__PMURHASH=yes 4 | 5 | -olib/rddleto 6 | 7 | # static lib 8 | -hblib 9 | 10 | # shared lib: .dll or .so -- outcomment above, remove '#' in next 2 lines 11 | #-hbdynvm 12 | #-shared 13 | 14 | 15 | -n 16 | -w3 17 | -q0 18 | -es2 19 | -gc3 20 | -strip 21 | -rebuild 22 | -inc- 23 | -hbx=letodb.hbx 24 | 25 | -iinclude 26 | {__LZ4}-isource/3rd/lz4/lib 27 | 28 | #-cflag=-D__HARBOUR30__=1 29 | 30 | # remove '#' for special actions to fix concurrency with a Samba server 31 | #-cflag=-DLETO_SMBSERVER=1 32 | 33 | # next two lines to force single threaded communication with a single socket 34 | #-cflag=-DLETO_NO_THREAD=1 35 | #-prgflag=-DLETO_NO_THREAD=1 36 | 37 | # CPP flags to pacify 'modern' new C-compiler 38 | #-cflag=-Wno-c++11-long-long 39 | #-cflag=-Wno-old-style-cast 40 | 41 | -cflag={allmsvc}-D_CRT_SECURE_NO_DEPRECATE 42 | -cflag={clang}-W 43 | -cflag={clang}-Wall 44 | -cflag={clang}-pedantic 45 | # to avoid spin locks 46 | #-cflag={win}-DHB_HELGRIND_FRIENDLY=1 47 | {__PMURHASH}-cflag=-DUSE_PMURHASH=1 48 | {__BM}-cflag=-D__BM=1 49 | {__LZ4}-cflag=-DUSE_LZ4=1 50 | 51 | source/client/letocl.c 52 | source/client/leto1.c 53 | source/client/letomgmn.c 54 | source/client/rddsys.prg 55 | {__BM}source/client/letobmcl.prg 56 | 57 | source/common/blowfish.c 58 | source/common/common_c.c 59 | {__LZ4}source/3rd/lz4/lib/lz4.c 60 | {__LZ4}source/common/lz4net.c 61 | {__PMURHASH}source/common/PMurHash.c 62 | 63 | -------------------------------------------------------------------------------- /source/3rd/lz4/lib/README.md: -------------------------------------------------------------------------------- 1 | LZ4 - Library Files 2 | ================================ 3 | 4 | The __lib__ directory contains several files, but you don't necessarily need them all. 5 | 6 | To integrate fast LZ4 compression/decompression into your program, you basically just need "**lz4.c**" and "**lz4.h**". 7 | 8 | For more compression at the cost of compression speed (while preserving decompression speed), use **lz4hc** on top of regular lz4. `lz4hc` only provides compression functions. It also needs `lz4` to compile properly. 9 | 10 | If you want to produce files or data streams compatible with `lz4` command line utility, use **lz4frame**. This library encapsulates lz4-compressed blocks into the [official interoperable frame format]. In order to work properly, lz4frame needs lz4 and lz4hc, and also **xxhash**, which provides error detection algorithm. 11 | (_Advanced stuff_ : It's possible to hide xxhash symbols into a local namespace. This is what `liblz4` does, to avoid symbol duplication in case a user program would link to several libraries containing xxhash symbols.) 12 | 13 | A more complex "lz4frame_static.h" is also provided, although its usage is not recommended. It contains definitions which are not guaranteed to remain stable within future versions. Use for static linking ***only***. 14 | 15 | The other files are not source code. There are : 16 | 17 | - LICENSE : contains the BSD license text 18 | - Makefile : script to compile or install lz4 library (static or dynamic) 19 | - liblz4.pc.in : for pkg-config (make install) 20 | 21 | [official interoperable frame format]: ../lz4_Frame_format.md 22 | -------------------------------------------------------------------------------- /utils/backup/srv_win.ini: -------------------------------------------------------------------------------- 1 | # full address: //IP:port/ -- or only IP address 2 | Server = 192.168.2.231 3 | 4 | ;Port = 2812 5 | ;User = 6 | 7 | # use ? for interactive enter 8 | ;Password = ? 9 | 10 | # a sub-directoy at server DataPath 11 | BackupPath = backup 12 | 13 | # comma seperated list of file-masks of files for backup 14 | MaskInclude = *.dbf, *.fpt, *.dbt, *.smt, *.ntx, *.cdx 15 | 16 | # comman seperated list of file-masks to exclude from backup 17 | ;MaskExclude = 18 | 19 | # seconds to wait for successful server lock, 0 = no server lock 20 | LockWait = 20 21 | 22 | # seconds a user can refuse to go into locked mode 23 | LockDelay = 15 24 | 25 | # amount of tries to lock the server in case of no success 26 | RetryLock = 10 27 | 28 | # timespan in seconds between multiple LockRetry 29 | RetryDelay = 120 30 | 31 | # create a report about backup in BackupPath, default 1 32 | LogFile = backup_%date%.log 33 | 34 | # if activated, each found table will be SHARED opened with Flock() 35 | ;ThirdParty = 1 36 | 37 | # if given the archive is moved from server into this local path 38 | LocalPath = . 39 | 40 | # the resulting archive name ( with wildcards ) plus file extension 41 | ArcFile = letoback_%date%.7z 42 | 43 | # THE ARCHIVATOR COMMAND line ( with wildcards ) 44 | # %dst% = BackupPath 45 | # %date% = DToS( Date() ); %time% = Time() 46 | # %target% = cArcFile after possible wildcard replace 47 | # %mask% = MaskInclude 48 | # %xmask% = MaskExclude 49 | # { %mask% } ==> string inside {} repeated for each mask in MaskInclude 50 | # { %xmask% } ==> dito for each mask in MaskExclude 51 | 52 | ArcCmd = cmd /C "7za.exe a -r %dst%\%target% { %mask%}" 53 | ;ArcCmd = cmd /C "dir *.* > %dst%\%target%" 54 | 55 | # an extra command to be done after the ArcCmd 56 | ;ExtraCmd = 57 | -------------------------------------------------------------------------------- /makefile.gc: -------------------------------------------------------------------------------- 1 | # Building of librddleto.a for xharbour, Windows, minGW' gcc C-Compiler 2 | # assumes an installed Harbour in /xharbour -- or set HB_PATH 3 | 4 | ifeq ($(HB_PATH),) 5 | HRB_DIR = /xharbour 6 | else 7 | HRB_DIR = $(HB_PATH) 8 | endif 9 | 10 | 11 | HRB_LIBS = -ldebug -lvmmt -lrtl -llang -lrdd -lmacro -lpp -ldbfntx -ldbfcdx -ldbffpt -lhbsix -lcommon -lcodepage -lpcrepos 12 | 13 | LIB_DIR = $(HRB_DIR)/lib 14 | OBJ_DIR = obj/gcc 15 | INC_DIR = include 16 | LZ4_DIR = source/3rd/lz4/lib 17 | CLIENT_DIR=source/client 18 | COMMON_DIR=source/common 19 | LETO_LIB_DIR = lib 20 | 21 | CFLAGS = -Wall -Wpedantic -c -O3 -DUSE_PMURHASH=1 -DUSE_LZ4=1 -D__NO_LZ4_WARN__ -DLETO_NO_MT=1 22 | # -DLETO_NO_THREAD=1 23 | 24 | vpath %.a $(LIB_DIR) 25 | vpath %.o $(OBJ_DIR) 26 | vpath %.c $(OBJ_DIR):$(CLIENT_DIR):$(COMMON_DIR):$(LZ4_DIR) 27 | 28 | %.o : %.c 29 | gcc $(CFLAGS) -c -I$(INC_DIR) -I$(LZ4_DIR) -I$(HRB_DIR)/include -o $@ $< 30 | 31 | $(OBJ_DIR)/%.c : $(CLIENT_DIR)/%.prg 32 | harbour -n -w3 -q0 -es2 -DUSE_LZ4=1 -o$@ -n1 $< 33 | gcc $(CFLAGS) -c -I$(INC_DIR) -I$(LZ4_DIR) -I$(HRB_DIR)/include -o $(OBJ_DIR)/$*.o $(OBJ_DIR)/$*.c 34 | 35 | $(OBJ_DIR)/%.o : %.c 36 | gcc $(CFLAGS) -c -I$(INC_DIR) -I$(LZ4_DIR) -I$(HRB_DIR)/include -o $@ $< 37 | 38 | $(LETO_LIB_DIR)/%.a :: 39 | ar rcs $@ $^ 40 | 41 | all: \ 42 | $(LETO_LIB_DIR)/librddleto.a 43 | 44 | install: \ 45 | $(LIB_DIR)/librddleto.a 46 | copy $(LETO_LIB_DIR)/librddleto.a $(LIB_DIR)/ 47 | copy $(INC_DIR)/*.ch $(HRB_DIR)/include 48 | 49 | $(LETO_LIB_DIR)/librddleto.a : \ 50 | $(OBJ_DIR)/rddsys.o \ 51 | $(OBJ_DIR)/leto1.o \ 52 | $(OBJ_DIR)/letocl.o \ 53 | $(OBJ_DIR)/letomgmn.o \ 54 | $(OBJ_DIR)/common_c.o \ 55 | $(OBJ_DIR)/blowfish.o \ 56 | $(OBJ_DIR)/PMurHash.o \ 57 | $(OBJ_DIR)/lz4net.o \ 58 | $(OBJ_DIR)/lz4.o 59 | 60 | # eof 61 | -------------------------------------------------------------------------------- /makefile.gcc: -------------------------------------------------------------------------------- 1 | # Building of libleto.a for C-api access 2 | # assumes an installed Harbour in /usr -- or set HB_PATH 3 | 4 | ifeq ($(HB_PATH),) 5 | HRB_DIR = /usr 6 | # HRB_DIR = .. 7 | else 8 | HRB_DIR = $(HB_PATH) 9 | endif 10 | 11 | 12 | HRB_LIBS= -lhbvmmt -lhbrtl -lhbcpage -lhblang -lhbrdd -lhbrtl -lhbvm -lhbmacro -lhbpp -lgtstd -lhbzlib -lrddntx -lrddcdx -lrddfpt -lhbcommon -lhbsix 13 | 14 | LIB_DIR = $(HRB_DIR)/lib/harbour 15 | OBJ_DIR = obj 16 | INC_DIR = include 17 | LZ4_DIR = source/3rd/lz4/lib 18 | CLIENT_DIR=source/client 19 | COMMON_DIR=source/common 20 | LETO_LIB_DIR = lib 21 | 22 | # ar rcs lib/librddleto.a '/tmp/hbmk_VsCVfi.dir/rddsys.o' '/tmp/hbmk_VsCVfi.dir/letodb.o' '/tmp/hbmk_VsCVfi.dir/letocl.o' '/tmp/hbmk_VsCVfi.dir/leto1.o' '/tmp/hbmk_VsCVfi.dir/letomgmn.o' '/tmp/hbmk_VsCVfi.dir/blowfish.o' '/tmp/hbmk_VsCVfi.dir/common_c.o' '/tmp/hbmk_VsCVfi.dir/lz4.o' '/tmp/hbmk_VsCVfi.dir/lz4net.o' '/tmp/hbmk_VsCVfi.dir/PMurHash.o' 23 | 24 | CFLAGS = -Wall -Wpedantic -g -O3 -DUSE_PMURHASH=1 -DUSE_LZ4=1 -D__LETO_C_API__=1 -DLETO_NO_MT=1 -DLETO_NO_THREAD=1 25 | 26 | vpath %.a $(LIB_DIR) 27 | vpath %.o $(OBJ_DIR) 28 | vpath %.c $(OBJ_DIR):$(CLIENT_DIR):$(COMMON_DIR):$(LZ4_DIR) 29 | 30 | %.o : %.c 31 | gcc $(CFLAGS) -c -I$(INC_DIR) -I$(LZ4_DIR) -I$(HRB_DIR)/include/harbour -o $@ $< 32 | 33 | $(OBJ_DIR)/%.o : %.c 34 | @mkdir -p $(@D) 35 | gcc $(CFLAGS) -c -I$(INC_DIR) -I$(LZ4_DIR) -I$(HRB_DIR)/include/harbour -o $@ $< 36 | 37 | $(LETO_LIB_DIR)/%.a :: 38 | @mkdir -p $(@D) 39 | ar rcs $@ $^ 40 | 41 | all: \ 42 | $(LETO_LIB_DIR)/libleto.a 43 | 44 | $(LETO_LIB_DIR)/libleto.a : \ 45 | $(OBJ_DIR)/letocl.o \ 46 | $(OBJ_DIR)/common_c.o \ 47 | $(OBJ_DIR)/blowfish.o \ 48 | $(OBJ_DIR)/lz4.o \ 49 | $(OBJ_DIR)/lz4net.o \ 50 | $(OBJ_DIR)/PMurHash.o 51 | 52 | clean: \ 53 | -(rm -fR obj/gcc/* lib/libleto.a ) 54 | -------------------------------------------------------------------------------- /utils/backup/srv_linux.ini: -------------------------------------------------------------------------------- 1 | # full address: //IP:port/ -- or only IP address 2 | Server = 192.168.2.47 3 | 4 | ;Port = 2812 5 | ;User = 6 | 7 | # use ? for interactive enter 8 | ;Password = ? 9 | 10 | # a sub-directoy at server DataPath 11 | BackupPath = backup 12 | 13 | # comma seperated list of file-masks of files for backup 14 | MaskInclude = *.dbf, *.fpt, *.dbt, *.smt, *.ntx, *.cdx 15 | 16 | # comman seperated list of file-masks to exclude from backup 17 | ;MaskExclude = backup 18 | 19 | # seconds to wait for successful server lock, 0 = no server lock 20 | LockWait = 20 21 | 22 | # seconds a user can refuse to go into locked mode 23 | LockDelay = 15 24 | 25 | # amount of tries to lock the server in case of no success 26 | RetryLock = 10 27 | 28 | # timespan in seconds between multiple LockRetry 29 | RetryDelay = 120 30 | 31 | # create a report about backup in BackupPath, default 1 32 | LogFile = backup_%date%.log 33 | 34 | # if activated, each found table will be SHARED opened with Flock() 35 | ;ThirdParty = 1 36 | 37 | # if given the archive is moved from server into this local path 38 | LocalPath = /tmp 39 | 40 | # the resulting archive name ( with wildcards ) plus file extension 41 | ArcFile = letoback_%date%.tar.gz 42 | 43 | # THE ARCHIVATOR COMMAND line ( with wildcards ) 44 | # %dst% = BackupPath 45 | # %date% = DToS( Date() ); %time% = Time() 46 | # %target% = cArcFile after possible wildcard replace 47 | # %mask% = MaskInclude 48 | # %xmask% = MaskExclude 49 | # { %mask% } ==> string inside {} repeated for each mask in MaskInclude 50 | # { %xmask% } ==> dito for each mask in MaskExclude 51 | 52 | ArcCmd = /bin/bash -c "tar --ignore-failed-read -cvzf %dst%/%target% { %mask%}" 53 | ;ArcCmd = /bin/bash -c "rsync -ra { --exclude=%xmask%} { %mask%} /tmp/backup" 54 | 55 | # an extra command to be done after the ArcCmd 56 | ;ExtraCmd = 57 | -------------------------------------------------------------------------------- /make_b32.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM 3 | REM check file "Readme.txt", chapter: 2.0 ff -- Harbour user use hbmk2 by Szakats 4 | REM 5 | 6 | rem Adapt search paths for C-Compiler and Harbour: 7 | SET PATH=C:\BCC58\BIN;C:\xharbour\bin 8 | rem the root path to harbour: 9 | SET HB_PATH=C:\xharbour 10 | 11 | SET HARBOUR_EXE= 12 | if exist %HB_PATH%\bin\harbour.exe SET HARBOUR_EXE=harbour 13 | if exist %HB_PATH%\bin\xHB.exe SET HARBOUR_EXE=xHb 14 | 15 | if "%HARBOUR_EXE%." == "." ( 16 | @echo ! Please verify the paths herein for Harbour! 17 | @echo . 18 | goto EXIT 19 | ) 20 | 21 | SET arg1=%1 22 | if "%arg1%." == "." SET arg1=rdd 23 | ) 24 | if "%arg1%" == "clean" goto CLEAN 25 | 26 | if not exist lib md lib 27 | if not exist obj md obj 28 | if not exist obj\bcc md obj\bcc 29 | if not exist obj\api md obj\api 30 | 31 | if "%arg1%" == "rdd" goto BUILD 32 | if "%arg1%" == "api" goto BUILD 33 | if "%arg1%" == "all" goto BUILD 34 | @echo . 35 | @echo rdd for RDD lib (default) 36 | @echo api for C-API lib 37 | @echo all for RDD and C-API 38 | @echo Clean for clean-up 39 | @echo . 40 | goto EXIT 41 | 42 | 43 | :BUILD 44 | make -l OBJ_DIR=obj\bcc API_DIR=obj\api -fmakefile.bc %arg1% %2 %3 > make_bcc.log 2> make_bcc.err 45 | if errorlevel 1 goto BUILD_ERR 46 | if "%arg1%" == "rdd" ( 47 | @echo ... copying RDD and headers into place for %HARBOUR_EXE% 48 | copy lib\rddleto.lib %HB_PATH%\lib\rddleto.lib 49 | copy include\leto_std.ch %HB_PATH%\include 50 | copy include\rddleto.ch %HB_PATH%\include 51 | copy include\letofile.ch %HB_PATH%\include 52 | ) 53 | goto BUILD_OK 54 | 55 | :BUILD_OK 56 | @echo Hooray! ...;-) 57 | goto EXIT 58 | 59 | :BUILD_ERR 60 | type make_b32.log 61 | goto EXIT 62 | 63 | :CLEAN 64 | del lib\*.lib 2>NUL 65 | del lib\*.bak 2>NUL 66 | del obj\bcc\*.obj 2>NUL 67 | del obj\api\*.obj 2>NUL 68 | del obj\bcc\*.c 2>NUL 69 | del make_bcc.log 2>NUL 70 | 71 | goto EXIT 72 | 73 | :EXIT 74 | 75 | -------------------------------------------------------------------------------- /make_vc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM 3 | REM check file "Readme.txt", chapter: 2.1 -- this file is commonly not what you want 4 | REM 5 | 6 | REM SET PATH=F:\MsVc8\VC\bin;F:\MsVc8\SDK\v2.0\bin;f:\HbVc8\bin 7 | REM SET PATH=F:\MsVc9\VC\bin;F:\MsVc9\SDK\v3.5\bin;f:\HbVc9\bin 8 | 9 | REM SET HB_PATH=F:\HbVc8 10 | SET HB_PATH=C:\xharbour 11 | 12 | @echo off 13 | if "%1" == "clean" goto CLEAN 14 | if "%1" == "CLEAN" goto CLEAN 15 | 16 | if not exist lib md lib 17 | if not exist obj md obj 18 | if not exist obj\vc md obj\vc 19 | if not exist obj\api md obj\api 20 | 21 | REM SET VSINSTALLDIR=F:\MsVc8 22 | REM SET VCINSTALLDIR=F:\MsVc8\VC 23 | REM SET PATH=F:\MsVc8\VC\BIN;F:\MsVc8\Common7\IDE;F:\MsVc8\Common7\Tools;F:\MsVc8\SDK\v2.0\bin;%PATH% 24 | REM SET INCLUDE=F:\MsVc8\VC\include;F:\MsVc8\SDK\v2.0\include 25 | REM SET LIB=F:\MsVc8\VC\lib;F:\MsVc8\SDK\v2.0\lib 26 | REM SET LIBPATH=F:\MsVc8\VC\lib;F:\MsVc8\SDK\v2.0\lib 27 | 28 | REM SET VSINSTALLDIR=F:\MsVc9 29 | REM SET VCINSTALLDIR=F:\MsVc9\VC 30 | REM SET PATH=F:\MsVc9\VC\BIN;F:\MsVc9\Common7\IDE;F:\MsVc9\Common7\Tools;F:\MsVc9\SDK\v3.5\bin;%PATH% 31 | REM SET INCLUDE=F:\MsVc9\VC\include;F:\MsVc9\SDK\v3.5\include 32 | REM SET LIB=F:\MsVc9\VC\lib;F:\MsVc9\SDK\v3.5\lib 33 | REM SET LIBPATH=F:\MsVc9\VC\lib;F:\MsVc9\SDK\v3.5\lib 34 | 35 | :BUILD 36 | nmake /I /Fmakefile.vc %1 %2 %3 > make_vc.log 2> make_vc.err 37 | if errorlevel 1 goto BUILD_ERR 38 | if "%1" == "full" ( 39 | copy lib\rddleto.lib %HB_PATH%\lib\rddleto.lib 40 | copy include\leto_std.ch %HB_PATH%\include 41 | copy include\letofile.ch %HB_PATH%\include 42 | copy include\rddleto.ch %HB_PATH%\include 43 | ) ELSE ( 44 | copy lib\leto.lib %HB_PATH%\lib\leto.lib 45 | ) 46 | goto BUILD_OK 47 | 48 | :BUILD_OK 49 | goto EXIT 50 | 51 | :BUILD_ERR 52 | notepad make_vc.log 53 | goto EXIT 54 | 55 | :CLEAN 56 | del lib\*.lib 57 | del obj\vc\*.obj 58 | del obj\vc\*.c 59 | del obj\api\*.obj 60 | del make_vc.log 61 | 62 | goto EXIT 63 | 64 | :EXIT 65 | 66 | -------------------------------------------------------------------------------- /rddletoaddon.hbp: -------------------------------------------------------------------------------- 1 | #-env:__BM=yes 2 | -env:__LZ4=yes 3 | -env:__PMURHASH=yes 4 | 5 | -olib/rddleto 6 | 7 | # static lib 8 | -hblib 9 | 10 | # shared lib: .dll or .so -- outcomment above, remove '#' in next 2 lines 11 | #-hbdynvm 12 | #-shared 13 | 14 | 15 | -n 16 | -w3 17 | -q0 18 | -es2 19 | -gc3 20 | -strip 21 | -rebuild 22 | -inc- 23 | -hbx=letodb.hbx 24 | 25 | -iinclude 26 | {__LZ4}-isource/3rd/lz4/lib 27 | 28 | #-cflag=-D__HARBOUR30__=1 29 | 30 | # remove '#' for special actions to fix concurrency with a Samba server 31 | #-cflag=-DLETO_SMBSERVER=1 32 | 33 | # next two lines to force single threaded communication with a single socket 34 | #-cflag=-DLETO_NO_THREAD=1 35 | #-prgflag=-DLETO_NO_THREAD=1 36 | 37 | # CPP flags to pacify 'modern' compiler 38 | #-cflag=-Wno-c++11-long-long 39 | #-cflag=-Wno-old-style-cast 40 | 41 | -cflag={allmsvc}-D_CRT_SECURE_NO_DEPRECATE 42 | -cflag={clang}-W 43 | -cflag={clang}-Wall 44 | -cflag={clang}-pedantic 45 | # to avoid spin locks 46 | #-cflag={win}-DHB_HELGRIND_FRIENDLY=1 47 | {__PMURHASH}-cflag=-DUSE_PMURHASH=1 48 | {__BM}-cflag=-D__BM=1 49 | {__LZ4}-cflag=-DUSE_LZ4=1 50 | 51 | source/client/letocl.c 52 | source/client/leto1.c 53 | source/client/letomgmn.c 54 | source/client/rddsys.prg 55 | {__BM}source/client/letobmcl.prg 56 | 57 | source/common/blowfish.c 58 | source/common/common_c.c 59 | {__LZ4}source/3rd/lz4/lib/lz4.c 60 | {__LZ4}source/common/lz4net.c 61 | {__PMURHASH}source/common/PMurHash.c 62 | 63 | 64 | # install files and paths 65 | -instfile=misc:*.hb 66 | -instfile=misc:*.hbc 67 | -instfile=misc:*.hbx 68 | -instfile=misc:*.md 69 | -instfile=misc:*.txt 70 | -instfile=inc:*.ch 71 | -instfile=inc_sub:include/*.ch 72 | -instfile=inc_sub:include/funcleto.h 73 | -instfile=tests:tests/*.* 74 | 75 | # static library & dynamic library on *nix 76 | {hblib}-instpath=${hb_lib}/ 77 | # dynamic library on non-*nix 78 | {(hbdyn|hbdynvm)&!unix}-instpath=${hb_bin}/ 79 | {(hbdyn|hbdynvm)&unix}-instpath=${hb_lib}/ 80 | 81 | # misc files, public headers, tests 82 | -instpath=misc:${hb_addons}/letodb/ 83 | -instpath=inc:${hb_addons}/letodb/ 84 | -instpath=inc_sub:${hb_addons}/letodb/include/ 85 | -instpath=tests:${hb_addons}/letodb/tests/ 86 | 87 | -------------------------------------------------------------------------------- /include/PMurHash.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * MurmurHash3 was written by Austin Appleby, and is placed in the public 3 | * domain. 4 | * 5 | * This implementation was written by Shane Day, and is also public domain. 6 | * 7 | * This is a portable ANSI C implementation of MurmurHash3_x86_32 (Murmur3A) 8 | * with support for progressive processing. 9 | */ 10 | 11 | /* ------------------------------------------------------------------------- */ 12 | /* Determine what native type to use for uint32_t */ 13 | 14 | /* We can't use the name 'uint32_t' here because it will conflict with 15 | * any version provided by the system headers or application. */ 16 | 17 | /* First look for special cases */ 18 | #if defined(_MSC_VER) 19 | #define MH_UINT32 unsigned long 20 | #endif 21 | 22 | /* If the compiler says it's C99 then take its word for it */ 23 | #if !defined(MH_UINT32) && ( \ 24 | defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) 25 | #include 26 | #define MH_UINT32 uint32_t 27 | #endif 28 | 29 | /* Otherwise try testing against max value macros from limit.h */ 30 | #if !defined(MH_UINT32) 31 | #include 32 | #if (USHRT_MAX == 0xffffffffUL) 33 | #define MH_UINT32 unsigned short 34 | #elif (UINT_MAX == 0xffffffffUL) 35 | #define MH_UINT32 unsigned int 36 | #elif (ULONG_MAX == 0xffffffffUL) 37 | #define MH_UINT32 unsigned long 38 | #endif 39 | #endif 40 | 41 | #if !defined(MH_UINT32) 42 | #error Unable to determine type name for unsigned 32-bit int 43 | #endif 44 | 45 | /* I'm yet to work on a platform where 'unsigned char' is not 8 bits */ 46 | #define MH_UINT8 unsigned char 47 | 48 | 49 | /* ------------------------------------------------------------------------- */ 50 | /* Prototypes */ 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | void PMurHash32_Process(MH_UINT32 *ph1, MH_UINT32 *pcarry, const void *key, int len); 57 | MH_UINT32 PMurHash32_Result(MH_UINT32 h1, MH_UINT32 carry, MH_UINT32 total_length); 58 | MH_UINT32 PMurHash32(MH_UINT32 seed, const void *key, int len); 59 | 60 | void PMurHash32_test(const void *key, int len, MH_UINT32 seed, void *out); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /letodbsvc.hbp: -------------------------------------------------------------------------------- 1 | #-env:__BM=yes 2 | -env:__LZ4=yes 3 | -env:__PMURHASH=yes 4 | 5 | # alternative to recommended adaption of: source/include//letocdp.ch 6 | # outcomment following line to enable all by Harbour known codepages in LetoDBf 7 | #-prgflag=-D__HB_EXT_CDP__=yes 8 | 9 | # to enable full Harbour command set useable for UDF functions 10 | #-prgflag=-DLETO_FULLCMDSET_HB=1 11 | # to enable full CT contrib command set useable for UDF functions 12 | #-prgflag=-DLETO_FULLCMDSET_CT=1 13 | 14 | # Uncomment "plugrand" line for a random password used by server to encrypt the 15 | # users/passwords/rights file. Then 'nobody' know the password, 16 | # but with each new server build the file must be deleted/ new created. 17 | #-plugin=plugrand.hb 18 | 19 | #-cflag=-D__HARBOUR30__=1 20 | #-prgflag=-D__HARBOUR30__=1 21 | 22 | 23 | # --- down here you should not modify without deeper knowledge about why --- 24 | -l 25 | -strip 26 | -gc3 27 | -mt 28 | {!win}-static 29 | {win}-fullstatic 30 | -nodefgt 31 | -obin/letodb 32 | -iinclude 33 | {__LZ4}-isource/3rd/lz4/lib 34 | -n 35 | -w3 36 | -q0 37 | -es0 38 | 39 | {bcc}-lhbmemio 40 | {bcc}-lhbct 41 | {!bcc}hbmemio.hbc 42 | {!bcc}hbct.hbc 43 | 44 | {bcc&__BM}-lrddbm 45 | {!bcc&__BM}rddbm.hbc 46 | 47 | 48 | -prgflag={unix}-D__LINUX_DAEMON__ 49 | #-prgflag={unix}-D__CONSOLE__ 50 | #-prgflag={win}-D__WIN_DAEMON__ 51 | -prgflag={win}-D__WIN_SERVICE__ 52 | -cflag={win}-D__WIN_SERVICE__ 53 | -cflag={allmsvc}-D_CRT_SECURE_NO_DEPRECATE 54 | -cflag={clang}-W 55 | -cflag={clang}-Wall 56 | -cflag={clang}-pedantic 57 | #-cflag={win}-DHB_HELGRIND_FRIENDLY=1 58 | {__BM}-prgflag=-D__BM 59 | {__BM}-cflag=-D__BM=1 60 | {__LZ4}-prgflag=-DUSE_LZ4=1 61 | {__LZ4}-cflag=-DUSE_LZ4=1 62 | {__PMURHASH}-cflag=-DUSE_PMURHASH=1 63 | 64 | source/server/server.prg 65 | source/server/errorsys.prg 66 | source/server/errint.c 67 | {unix}source/server/leto_lnx.c 68 | {win}source/server/leto_win.c 69 | source/server/letoacc.c 70 | source/server/letovars.c 71 | source/server/letofunc.c 72 | source/server/letolist.c 73 | source/server/leto_2.c 74 | {__BM}source/server/letobm.prg 75 | 76 | source/common/blowfish.c 77 | source/common/common_c.c 78 | source/common/common.prg 79 | {__LZ4}source/3rd/lz4/lib/lz4.c 80 | {__LZ4}source/common/lz4net.c 81 | {__PMURHASH}source/common/PMurHash.c 82 | 83 | -------------------------------------------------------------------------------- /letodb.hbp: -------------------------------------------------------------------------------- 1 | #-env:__BM=yes 2 | -env:__LZ4=yes 3 | -env:__PMURHASH=yes 4 | 5 | # alternative to recommended adaption of: source/include//letocdp.ch 6 | # outcomment following line to enable all by Harbour known codepages in LetoDBf 7 | #-prgflag=-D__HB_EXT_CDP__=yes 8 | 9 | # to enable full Harbour command set useable for UDF functions 10 | #-prgflag=-DLETO_FULLCMDSET_HB=1 11 | # to enable full CT contrib command set useable for UDF functions 12 | #-prgflag=-DLETO_FULLCMDSET_CT=1 13 | 14 | # Uncomment "plugrand" line for a random password used by server to encrypt the 15 | # users/passwords/rights file. Then 'nobody' know the password, 16 | # but with each new server build the file must be deleted/ new created. 17 | #-plugin=plugrand.hb 18 | 19 | #-cflag=-D__HARBOUR30__=1 20 | #-prgflag=-D__HARBOUR30__=1 21 | 22 | 23 | # --- down here you should not modify without deeper knowledge about why --- 24 | -l 25 | -strip 26 | -gc3 27 | -mt 28 | {!win}-static 29 | {win}-fullstatic 30 | {unix}-nodefgt 31 | -obin/letodb 32 | -iinclude 33 | {__LZ4}-isource/3rd/lz4/lib 34 | -n 35 | -w3 36 | -q0 37 | -es0 38 | 39 | {bcc}-lhbmemio 40 | {bcc}-lhbct 41 | {!bcc}hbmemio.hbc 42 | {!bcc}hbct.hbc 43 | 44 | {bcc&__BM}-lrddbm 45 | {!bcc&__BM}rddbm.hbc 46 | 47 | 48 | -prgflag={unix}-D__LINUX_DAEMON__ 49 | #-prgflag={unix}-D__CONSOLE__ 50 | -prgflag={win}-D__WIN_DAEMON__ 51 | #-prgflag={win}-D__WIN_SERVICE__ 52 | #-cflag={win}-D__WIN_SERVICE__ 53 | -cflag={allmsvc}-D_CRT_SECURE_NO_DEPRECATE 54 | -cflag={clang}-W 55 | -cflag={clang}-Wall 56 | -cflag={clang}-pedantic 57 | #-cflag={win}-DHB_HELGRIND_FRIENDLY=1 58 | {__BM}-prgflag=-D__BM 59 | {__BM}-cflag=-D__BM=1 60 | {__LZ4}-prgflag=-DUSE_LZ4=1 61 | {__LZ4}-cflag=-DUSE_LZ4=1 62 | {__PMURHASH}-cflag=-DUSE_PMURHASH=1 63 | 64 | source/server/server.prg 65 | source/server/errorsys.prg 66 | source/server/errint.c 67 | {unix}source/server/leto_lnx.c 68 | #{win}source/server/leto_win.c 69 | source/server/letoacc.c 70 | source/server/letovars.c 71 | source/server/letofunc.c 72 | source/server/letolist.c 73 | source/server/leto_2.c 74 | {__BM}source/server/letobm.prg 75 | 76 | source/common/blowfish.c 77 | source/common/common_c.c 78 | source/common/common.prg 79 | {__LZ4}source/3rd/lz4/lib/lz4.c 80 | {__LZ4}source/common/lz4net.c 81 | {__PMURHASH}source/common/PMurHash.c 82 | 83 | -------------------------------------------------------------------------------- /letodbaddon.hbp: -------------------------------------------------------------------------------- 1 | #-env:__BM=yes 2 | -env:__LZ4=yes 3 | -env:__PMURHASH=yes 4 | 5 | # alternative to recommended adaption of: source/include//letocdp.ch 6 | # outcomment following line to enable all by Harbour known codepages in LetoDBf 7 | #-prgflag=-D__HB_EXT_CDP__=yes 8 | 9 | # to enable full Harbour command set useable for UDF functions 10 | #-prgflag=-DLETO_FULLCMDSET_HB=1 11 | # to enable full CT contrib command set useable for UDF functions 12 | #-prgflag=-DLETO_FULLCMDSET_CT=1 13 | 14 | # Uncomment "plugrand" line for a random password used by server to encrypt the 15 | # users/passwords/rights file. Then 'nobody' know the password, 16 | # but with each new server build the file must be deleted/ new created. 17 | #-plugin=plugrand.hb 18 | 19 | #-cflag=-D__HARBOUR30__=1 20 | 21 | 22 | # --- down here you should not modify without deeper knowledge about why --- 23 | -l 24 | -strip 25 | -gc3 26 | -mt 27 | {!win}-static 28 | {win}-fullstatic 29 | -obin/letodb 30 | -iinclude 31 | {__LZ4}-isource/3rd/lz4/lib 32 | -n 33 | -w3 34 | -q0 35 | -es0 36 | -rebuild 37 | 38 | hbmemio.hbc 39 | hbct.hbc 40 | {__BM}rddbm.hbc 41 | 42 | -prgflag={unix}-D__LINUX_DAEMON__ 43 | #-prgflag={unix}-D__CONSOLE__ 44 | -prgflag={win}-D__WIN_DAEMON__ 45 | #-cflag={win}-D__WIN_SERVICE__ 46 | #-prgflag={win}-D__WIN_SERVICE__ 47 | -cflag={allmsvc}-D_CRT_SECURE_NO_DEPRECATE 48 | -cflag={clang}-W 49 | -cflag={clang}-Wall 50 | -cflag={clang}-pedantic 51 | #-cflag={win}-DHB_HELGRIND_FRIENDLY=1 52 | {__BM}-prgflag=-D__BM 53 | {__BM}-cflag=-D__BM=1 54 | {__LZ4}-cflag=-DUSE_LZ4=1 55 | {__PMURHASH}-cflag=-DUSE_PMURHASH=1 56 | 57 | source/server/server.prg 58 | source/server/errorsys.prg 59 | source/server/errint.c 60 | {unix}source/server/leto_lnx.c 61 | {win}source/server/leto_win.c 62 | source/server/letoacc.c 63 | source/server/letovars.c 64 | source/server/letofunc.c 65 | source/server/letolist.c 66 | source/server/leto_2.c 67 | {__BM}source/server/letobm.prg 68 | 69 | source/common/blowfish.c 70 | source/common/common_c.c 71 | source/common/common.prg 72 | {__LZ4}source/3rd/lz4/lib/lz4.c 73 | {__LZ4}source/common/lz4net.c 74 | {__PMURHASH}source/common/PMurHash.c 75 | 76 | # move exectuable and ini file 77 | -instfile=misc:bin/letodb.ini 78 | {win}-instpath=misc:${hb_bin}/ 79 | {unix}-instpath=misc:/etc/ 80 | {hbexe}-instpath=${hb_bin}/ 81 | 82 | -------------------------------------------------------------------------------- /tests/plug_ver.hb: -------------------------------------------------------------------------------- 1 | /* hbmk2 plugin to determine lastest filedate for LetoDBf server/ RDD sources */ 2 | 3 | #define REVISION_FILE "../include/leto_rev.ch" 4 | #define _EOL_ CHR( 10 ) 5 | #if defined( HB_OS_WIN ) 6 | #define _FILE_MASK_ "*.*" 7 | #else 8 | #define _FILE_MASK_ "*" 9 | #endif 10 | 11 | FUNCTION hbmk_plugin_rand( hbmk ) 12 | 13 | IF VALTYPE( hbmk[ "cOUTPUTNAME" ] ) == "C" .AND. "bug_info" $ hbmk[ "cOUTPUTNAME" ] 14 | IF hbmk[ "cSTATE" ] == "pre_all" 15 | VersionString( .T. ) 16 | VersionString( .F. ) 17 | ENDIF 18 | ENDIF 19 | 20 | RETURN NIL 21 | 22 | STATIC FUNCTION VersionString( lServer ) 23 | LOCAL dDate := DATE() - 36525 24 | LOCAL cTime := "00:00:00" 25 | LOCAL aDir, i, cTmp, cResult 26 | 27 | IF lServer 28 | aDir := Directory( "../source/server/" + _FILE_MASK_ ) 29 | ELSE 30 | aDir := Directory( "../source/client/" + _FILE_MASK_ ) 31 | ENDIF 32 | FOR i := 1 TO LEN( aDir ) 33 | IF aDir[ i ][ 3 ] > dDate 34 | dDate := aDir[ i ][ 3 ] 35 | IF aDir[ i ][ 4 ] > cTime 36 | cTime := aDir[ i ][ 4 ] 37 | ENDIF 38 | ENDIF 39 | NEXT i 40 | 41 | aDir := Directory( "../source/common/" + _FILE_MASK_ ) 42 | FOR i := 1 TO LEN( aDir ) 43 | IF aDir[ i ][ 3 ] > dDate 44 | dDate := aDir[ i ][ 3 ] 45 | IF aDir[ i ][ 4 ] > cTime 46 | cTime := aDir[ i ][ 4 ] 47 | ENDIF 48 | ENDIF 49 | NEXT i 50 | 51 | IF ! EMPTY( dDate ) 52 | IF FILE( REVISION_FILE ) 53 | cTmp := MemoRead( REVISION_FILE ) 54 | IF lServer 55 | i := AT( "#define __RDD_REVISION__", cTmp ) 56 | ELSE 57 | i := AT( "#define __SRV_REVISION__", cTmp ) 58 | ENDIF 59 | IF i > 0 /* fetch the other setting */ 60 | cTmp := SUBSTR( cTmp, i ) 61 | cTmp := LEFT( cTmp, AT( _EOL_, cTmp ) - 1 ) + _EOL_ 62 | ENDIF 63 | ELSE 64 | cTmp := "" 65 | ENDIF 66 | 67 | cResult := "/* do not edit --- automated created file */" + _EOL_ + cTmp 68 | IF lServer 69 | cResult += "#define __SRV_REVISION__ " 70 | ELSE 71 | cResult += "#define __RDD_REVISION__ " 72 | ENDIF 73 | cResult += CHR( 34 ) + DTOS( dDate ) + " " + cTime + CHR( 34 ) + _EOL_ 74 | 75 | MemoWrit( REVISION_FILE, cResult ) 76 | 77 | ENDIF 78 | 79 | RETURN cResult 80 | 81 | -------------------------------------------------------------------------------- /tests/excltest.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * this connect to a LetoDBf server and query for opened DBFs, 3 | * to compare if the DBF given by param is in the list and exclusive opened. 4 | * Address:port to connect is read of an .ini, below used with LETO_SMBSERVER() 5 | * --> set the OS ErrorLevel as return value 6 | * 0 means OK, 1 == fail, your open table is in usage. 7 | * 8 | * Most basic usage: 9 | * IF DbUseArea( ,, cFile,, lShared ) 10 | * IF lShared .AND. hb_ProcessRun( THIS_EXECUTABLE + " " + cFile,,,, .F. ) == 1 11 | * DbCloseArea() 12 | * NetErr( .T. ) 13 | * ENDIF 14 | * ENDIF 15 | /* 16 | 17 | 18 | /* --- no changes need below - 2018 Rolf 'elch' Beckmann --- */ 19 | 20 | ANNOUNCE HB_GTSYS 21 | REQUEST HB_GT_NUL_DEFAULT 22 | 23 | PROCEDURE main( cFile ) 24 | LOCAL nErrorLevel := 0 25 | LOCAL i, aArr, nLen, nTmp 26 | 27 | IF ! EMPTY( cFile ) .AND. Leto_Connect( LETO_SMBSERVER() ) >= 0 28 | 29 | /* beautify path and file */ 30 | IF SUBSTR( cFile, 2, 1 ) == ":" 31 | cFile := SUBSTR( cFile, 3 ) 32 | ENDIF 33 | IF LEFT( cFile, 1 ) == "." 34 | IF SUBSTR( cFile, 2, 1 ) == "." /* a hiding elk ".." :-) */ 35 | cFile := SUBSTR( cFile, 3 ) 36 | ELSE 37 | cFile := SUBSTR( cFile, 2 ) 38 | ENDIF 39 | ENDIF 40 | i := AT( "\", cFile ) 41 | DO WHILE i > 0 42 | cFile := LEFT( cFile, i - 1 ) + "/" + SUBSTR( cFile, i + 1 ) 43 | i := AT( "\", cFile ) 44 | ENDDO 45 | DO WHILE LEFT( cFile, 1 ) == "/" 46 | cFile := SUBSTR( cFile, 2 ) 47 | ENDDO 48 | cFile := LOWER( cFile ) 49 | 50 | /* ask for the DataPath to (partly) extract of filename */ 51 | aArr := Leto_MgGetInfo() 52 | IF VALTYPE( aArr ) == "A" .AND. LEN( aArr ) >= 11 53 | nTmp := 1 54 | DO WHILE ( i := AT( "/", SUBSTR( aArr[ 11 ], nTmp + 1 ) ) ) > 0 55 | nTmp += i 56 | nLen := LEN( SUBSTR( aArr[ 11 ], nTmp + 1 ) ) 57 | IF LOWER( SUBSTR( aArr[ 11 ], nTmp + 1 ) ) == LEFT( cFile, nLen ) 58 | cFile := SUBSTR( cFile, nLen + 2 ) 59 | EXIT 60 | ENDIF 61 | ENDDO 62 | ENDIF 63 | 64 | /* ask the server for open files */ 65 | aArr := leto_MgGetTables( -1 ) 66 | IF VALTYPE( aArr ) == "A" 67 | i := 0 68 | DO WHILE i++ < LEN( aArr ) 69 | IF cFile $ LOWER( aArr[ i, 2 ] ) 70 | IF ! aArr[ i, 5 ] /* exclusive */ 71 | nErrorLevel := 1 72 | ENDIF 73 | EXIT 74 | ENDIF 75 | ENDDO 76 | ENDIF 77 | 78 | Leto_Disconnect() 79 | ENDIF 80 | 81 | ERRORLEVEL( nErrorlevel ) 82 | RETURN 83 | -------------------------------------------------------------------------------- /include/letocdp.ch: -------------------------------------------------------------------------------- 1 | /* 2 | * Header file for external codepages 3 | * 4 | * Copyright 2010 Pavel Tsarenko 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 19 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 20 | * 21 | * As a special exception, the Harbour Project gives permission for 22 | * additional uses of the text contained in its release of Harbour. 23 | * 24 | * The exception is that, if you link the Harbour libraries with other 25 | * files to produce an executable, this does not by itself cause the 26 | * resulting executable to be covered by the GNU General Public License. 27 | * Your use of that executable is in no way restricted on account of 28 | * linking the Harbour library code into it. 29 | * 30 | * This exception does not however invalidate any other reasons why 31 | * the executable file might be covered by the GNU General Public License. 32 | * 33 | * This exception applies only to the code released by the Harbour 34 | * Project under the name Harbour. If you copy code from other 35 | * Harbour Project or Free Software Foundation releases into a copy of 36 | * Harbour, as the General Public License permits, the exception does 37 | * not apply to the code that you add in this way. To avoid misleading 38 | * anyone as to the status of such modified files, you must delete 39 | * this exception notice from them. 40 | * 41 | * If you write modifications of your own for Harbour, it is your choice 42 | * whether to permit this exception to apply to your modifications. 43 | * If you do not wish that, delete this exception notice. 44 | * 45 | */ 46 | 47 | REQUEST HB_CODEPAGE_UTF8, ; 48 | HB_CODEPAGE_DE850, HB_CODEPAGE_DEISO, HB_CODEPAGE_DEWIN 49 | 50 | REQUEST HB_CODEPAGE_ELWIN, HB_CODEPAGE_ESWIN, ; 51 | HB_CODEPAGE_HR852, ; 52 | HB_CODEPAGE_HU852, HB_CODEPAGE_HUWIN, HB_CODEPAGE_HUISO, ; 53 | HB_CODEPAGE_IT437, HB_CODEPAGE_IT850, ; 54 | HB_CODEPAGE_PL852, HB_CODEPAGE_PLWIN, ; 55 | HB_CODEPAGE_PT850, HB_CODEPAGE_PTISO, ; 56 | HB_CODEPAGE_RU866, HB_CODEPAGE_RUKOI8, HB_CODEPAGE_RU1251, ; 57 | HB_CODEPAGE_SL852, HB_CODEPAGE_SLISO, HB_CODEPAGE_SLWIN, ; 58 | HB_CODEPAGE_SV850, HB_CODEPAGE_SVWIN, ; 59 | HB_CODEPAGE_UA866, HB_CODEPAGE_UAKOI8, HB_CODEPAGE_UA1251 60 | 61 | -------------------------------------------------------------------------------- /source/3rd/lz4c.diff: -------------------------------------------------------------------------------- 1 | --- lz4.c 2016-06-05 15:56:53.020773446 +0200 2 | +++ lz4.c.org 2016-04-08 12:31:10.000000000 +0200 3 | @@ -102,15 +102,9 @@ 4 | /************************************** 5 | * Memory routines 6 | **************************************/ 7 | -#ifdef __HARBOUR__ /* still unused, prbly later for streaming functions */ 8 | - #include "hbapi.h" 9 | - #define ALLOCATOR(n,s) hb_xgrabz( n * s ) 10 | - #define FREEMEM hb_xfree 11 | -#else 12 | - #include /* malloc, calloc, free */ 13 | - #define ALLOCATOR(n,s) calloc(n,s) 14 | - #define FREEMEM free 15 | -#endif 16 | +#include /* malloc, calloc, free */ 17 | +#define ALLOCATOR(n,s) calloc(n,s) 18 | +#define FREEMEM free 19 | #include /* memset, memcpy */ 20 | #define MEM_INIT memset 21 | 22 | @@ -207,16 +201,14 @@ 23 | 24 | static void LZ4_copy4(void* dstPtr, const void* srcPtr) { memcpy(dstPtr, srcPtr, 4); } 25 | 26 | -/* static void LZ4_copy8(void* dstPtr, const void* srcPtr) { memcpy(dstPtr, srcPtr, 8); } */ 27 | -#define LZ4_copy8(dstPtr, srcPtr) memcpy(dstPtr, srcPtr, 8) 28 | - 29 | +static void LZ4_copy8(void* dstPtr, const void* srcPtr) { memcpy(dstPtr, srcPtr, 8); } 30 | 31 | /* customized version of memcpy, which may overwrite up to 7 bytes beyond dstEnd */ 32 | static void LZ4_wildCopy(void* dstPtr, const void* srcPtr, void* dstEnd) 33 | { 34 | BYTE* d = (BYTE*)dstPtr; 35 | const BYTE* s = (const BYTE*)srcPtr; 36 | - const BYTE* e = (const BYTE*)dstEnd; 37 | + BYTE* e = (BYTE*)dstEnd; 38 | do { LZ4_copy8(d,s); d+=8; s+=8; } while (d (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */ 52 | switch(dict) 53 | { 54 | + case noDict: 55 | + default: 56 | + base = (const BYTE*)source; 57 | + lowLimit = (const BYTE*)source; 58 | + break; 59 | case withPrefix64k: 60 | base = (const BYTE*)source - dictPtr->currentOffset; 61 | lowLimit = (const BYTE*)source - dictPtr->dictSize; 62 | @@ -484,11 +481,6 @@ 63 | base = (const BYTE*)source - dictPtr->currentOffset; 64 | lowLimit = (const BYTE*)source; 65 | break; 66 | - /* case noDict: */ 67 | - default: 68 | - base = (const BYTE*)source; 69 | - lowLimit = (const BYTE*)source; 70 | - break; 71 | } 72 | if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */ 73 | if (inputSize 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | int main( const int argc, const char * argv[] ) 19 | { 20 | char szLink[ 256 ], szProc[ 64 ] = { '/', 'p', 'r', 'o', 'c', '/' }; 21 | DIR * procfd, * proc = opendir( "/proc" ); 22 | struct dirent * ent, * entfd; 23 | int iLenLink, iFound = 2; 24 | char * ptr, * ptr2; 25 | const char * ptr3; 26 | 27 | if( proc == NULL || argc < 2 ) 28 | exit( EXIT_FAILURE ); 29 | if( argc > 2 ) 30 | { 31 | iFound = atoi( argv[ 2 ] ); 32 | if( iFound < 1 ) 33 | iFound = 2; 34 | } 35 | 36 | while( ( ent = readdir( proc ) ) != NULL ) 37 | { 38 | ptr3 = ent->d_name; 39 | if( ! isdigit( *ptr3 ) ) 40 | continue; 41 | else 42 | { 43 | ptr = szProc + 6; 44 | do 45 | { 46 | *ptr++ = *ptr3++; 47 | } 48 | while( *ptr3 != '\0' ); 49 | *ptr++ = '/'; 50 | *ptr++ = 'f'; 51 | *ptr++ = 'd'; 52 | *ptr = '\0'; 53 | 54 | if( ( procfd = opendir( szProc ) ) != NULL ) 55 | { 56 | *ptr++ = '/'; 57 | while( ( entfd = readdir( procfd ) ) != NULL ) 58 | { 59 | ptr3 = entfd->d_name; 60 | if( *ptr3 == '.' ) 61 | continue; 62 | ptr2 = ptr; 63 | do 64 | { 65 | *ptr2++ = *ptr3++; 66 | } 67 | while( *ptr3 != '\0' ); 68 | *ptr2 = '\0'; 69 | iLenLink = readlink( szProc, szLink, 255 ); 70 | if( iLenLink < 1 || *szLink != '/' ) 71 | continue; 72 | szLink[ iLenLink ] = '\0'; 73 | 74 | ptr2 = szLink; 75 | ptr3 = argv[ 1 ]; 76 | do 77 | { 78 | if( *ptr2 == *ptr3 ) 79 | { 80 | if( ! *( ++ptr3 ) ) 81 | break; 82 | } 83 | else 84 | ptr3 = argv[ 1 ]; 85 | } 86 | while( *( ++ptr2 ) != '\0' ); 87 | 88 | if( ! *ptr3 ) /* strstr( szLink, argv[ 1 ] ) */ 89 | { 90 | printf( "%s:%s\n", ent->d_name, szLink ); 91 | if( --iFound == 0 ) 92 | { 93 | closedir( procfd ); 94 | closedir( proc ); 95 | exit( EXIT_SUCCESS ); 96 | } 97 | } 98 | } 99 | 100 | closedir( procfd ); 101 | } 102 | else /* missing root access ? */ 103 | { 104 | closedir( proc ); 105 | exit( EXIT_FAILURE ); 106 | } 107 | } 108 | } 109 | 110 | closedir( proc ); 111 | exit( EXIT_SUCCESS ); 112 | } 113 | 114 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | __ __ ____ ____ __ 4 | / / ___ / /_____ / __ \/ __ )/ _| 5 | / / / _ \/ __/ __ \/ / / / __ | |_ 6 | / /___/ __/ /_/ /_/ / /_/ / /_/ /| _| 7 | /_____/\___/\__/\____/_____/_____/ |_| 8 | 9 | 10 | ### Welcome to LetoDBf 11 | please note the trailing *f*, this is the *elch fork* of the famous LetoDB Database Server, 12 | for the origin see: https://sourceforge.net/p/letodb/code/ci/master/tree/ 13 | or visit the original inventor: http://kresin.ru/en/letodb.html 14 | 15 | LetoDBf is like the origin a multiplatform, high performance database server with data stored in DBF 16 | tables. It is programmed mostly in pure 'Ansi-C' by extensively using the underlaying Harbour database 17 | engine ( https://harbour.github.io ) 18 | 19 | The cause of this fork was to get the freedom of removing over many years accumulated legacy technics, 20 | and to continue, to improve and to enhance based on latest development status, without the strain to 21 | keep internal backward compatibility to older versions. 22 | Main goal of this fork is to use LetoDBf with newest Harbour and to max out its possibilities. 23 | 24 | Aside a sligthly, but overall rework of the internal communication between Client and Server, 25 | a bunch of new features and capabilities is added, to let Harbour DBF engine show its' muscles. 26 | Expect extended locking schemes, share- and lock-able DBF tables in RAM ( HbMemIO ), all DBF on demand 27 | combine-able with 3 memofield types, new extended field attributes like autoincrement, etc ... 28 | 29 | The LetoDBf server file open mode: No_Save_WA is fully reworked: now the workareas are opened in exact 30 | same workarea-ID and ALIAS as at client side, plus client relations are active at server: 31 | this will e.g. allow indexing keys/ filtering rules on relationed fields of other workareas in this mode. 32 | Improved and extended is the use of the server variables system, it allows really tricky filter conditions 33 | to be evaluated at server side, which leads to very fast 'optimized' filtering records. 34 | This mode shell be the mode, if you need to execute server side UDF functions, where you now even can 35 | start an UDF in its own thread, working from then on independent from your connection as a new 36 | 'headless connection' 37 | 38 | 'Under the hood' works now a *TWO-socket* TCP connection ( if client application is MultiThread compiled ), 39 | enabling e,g, much faster data writes to the server. 40 | Available is on demand an extreme fast LZ4 compress- and Blowfish-encrypt-able network traffic. 41 | LetoDBf client lib ( used by your application ) became fully MultiThread save, each thread opens its own 42 | connection to the server. Threads, threads threads .., wherever you look. 43 | 44 | You should be able to use this fork likely you already used LetoDB -- BUT YOU CAN NOT MIX THEM. 45 | As the internal communication had changed, this LetoDBf server will only 'understand' client 46 | applications linked with this LetoDBf client library. 47 | 48 | ! Most important: NO WARRANTY from me on nothing -- decide yourself if LetoDBf fulfills your needs !. 49 | For the case you wish ( reliable quick ) personal! support from me, we should talk about 'donation' :-) 50 | So far YOU are the only responsible one for all what happens with and around LetoDBf at your places. 51 | 52 | 53 | Check Readme.txt for detailed help. Wish much fun. 54 | elch -------------------------------------------------------------------------------- /source/3rd/lz4/lib/lz4frame_static.h: -------------------------------------------------------------------------------- 1 | /* 2 | LZ4 auto-framing library 3 | Header File for static linking only 4 | Copyright (C) 2011-2015, Yann Collet. 5 | 6 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the following disclaimer 16 | in the documentation and/or other materials provided with the 17 | distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | You can contact the author at : 32 | - LZ4 source repository : https://github.com/Cyan4973/lz4 33 | - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c 34 | */ 35 | 36 | #pragma once 37 | 38 | #if defined (__cplusplus) 39 | extern "C" { 40 | #endif 41 | 42 | /* lz4frame_static.h should be used solely in the context of static linking. 43 | * It contains definitions which may still change overtime. 44 | * Never use it in the context of DLL linking. 45 | * */ 46 | 47 | 48 | /************************************** 49 | * Includes 50 | **************************************/ 51 | #include "lz4frame.h" 52 | 53 | 54 | /************************************** 55 | * Error management 56 | * ************************************/ 57 | #define LZ4F_LIST_ERRORS(ITEM) \ 58 | ITEM(OK_NoError) ITEM(ERROR_GENERIC) \ 59 | ITEM(ERROR_maxBlockSize_invalid) ITEM(ERROR_blockMode_invalid) ITEM(ERROR_contentChecksumFlag_invalid) \ 60 | ITEM(ERROR_compressionLevel_invalid) \ 61 | ITEM(ERROR_headerVersion_wrong) ITEM(ERROR_blockChecksum_unsupported) ITEM(ERROR_reservedFlag_set) \ 62 | ITEM(ERROR_allocation_failed) \ 63 | ITEM(ERROR_srcSize_tooLarge) ITEM(ERROR_dstMaxSize_tooSmall) \ 64 | ITEM(ERROR_frameHeader_incomplete) ITEM(ERROR_frameType_unknown) ITEM(ERROR_frameSize_wrong) \ 65 | ITEM(ERROR_srcPtr_wrong) \ 66 | ITEM(ERROR_decompressionFailed) \ 67 | ITEM(ERROR_headerChecksum_invalid) ITEM(ERROR_contentChecksum_invalid) \ 68 | ITEM(ERROR_maxCode) 69 | 70 | //#define LZ4F_DISABLE_OLD_ENUMS 71 | #ifndef LZ4F_DISABLE_OLD_ENUMS 72 | #define LZ4F_GENERATE_ENUM(ENUM) LZ4F_##ENUM, ENUM = LZ4F_##ENUM, 73 | #else 74 | #define LZ4F_GENERATE_ENUM(ENUM) LZ4F_##ENUM, 75 | #endif 76 | typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) } LZ4F_errorCodes; /* enum is exposed, to handle specific errors; compare function result to -enum value */ 77 | 78 | 79 | #if defined (__cplusplus) 80 | } 81 | #endif 82 | -------------------------------------------------------------------------------- /tests/c_lang/test1.c: -------------------------------------------------------------------------------- 1 | 2 | /* set it before ! */ 3 | #define __LETO_C_API__ 4 | #include "letocl.h" 5 | 6 | /* needed for LetoUdf() */ 7 | #include "hbapi.h" 8 | #include "hbapiitm.h" 9 | 10 | #if defined( HB_OS_WIN ) 11 | #define _EOL_ "\r\n" 12 | #else 13 | #define _EOL_ "\n" 14 | #endif 15 | 16 | int main( int argc, char *argv[] ) 17 | { 18 | LETOCONNECTION * pConnection; 19 | int iPort; 20 | char szAddr[ 128 ]; 21 | 22 | LetoInit(); 23 | LetoSetAddress( argc, argv, szAddr, &iPort ); 24 | 25 | printf( "Connecting to %s:%d ..." _EOL_, szAddr, iPort ); 26 | if( ( pConnection = LetoConnectionNew( szAddr, iPort, NULL, NULL, 0, 0 ) ) != NULL ) 27 | { 28 | const char * ptr, * ptrEnd; 29 | char szData[ 64 ]; 30 | PHB_ITEM pItem = hb_itemNew( NULL ); /* at least empty item, or hb_itemArrayNew( 0 ) */ 31 | 32 | printf( "Connected!" _EOL_ ); 33 | printf( "%s" _EOL_, LetoGetServerVer( pConnection ) ); 34 | if( ( ptr = LetoMgGetInfo( pConnection ) ) != NULL && *( ptr - 1 ) == '+' ) 35 | { 36 | ptrEnd = strchr( ptr, ';' ); memcpy( szData, ptr, ptrEnd - ptr ); szData[ ptrEnd - ptr ] = '\0'; ptr = ptrEnd + 1; 37 | printf( "Users current: %s\t\t", szData ); 38 | ptrEnd = strchr( ptr, ';' ); memcpy( szData, ptr, ptrEnd - ptr ); szData[ ptrEnd - ptr ] = '\0'; ptr = ptrEnd + 1; 39 | printf( "max: %s" _EOL_, szData ); 40 | 41 | ptrEnd = strchr( ptr, ';' ); memcpy( szData, ptr, ptrEnd - ptr ); szData[ ptrEnd - ptr ] = '\0'; ptr = ptrEnd + 1; 42 | printf( "Tables current: %s\t\t", szData ); 43 | ptrEnd = strchr( ptr, ';' ); memcpy( szData, ptr, ptrEnd - ptr ); szData[ ptrEnd - ptr ] = '\0'; 44 | printf( "max: %s" _EOL_, szData ); 45 | } 46 | 47 | printf( _EOL_ "remote execution test" _EOL_ ); 48 | 49 | /* kidding a bit with LetoDBf server */ 50 | if( ! LetoUdf( pConnection, NULL, HB_FALSE, "Truly_Nonsense", NULL ) ) 51 | printf( "Executed safely a not existing function" _EOL_ ); 52 | 53 | /* without function params and no return value */ 54 | if( LetoUdf( pConnection, NULL, HB_FALSE, "HB_MILLISECONDS", NULL ) ) 55 | printf( "hb_MilliSeconds() successful ( not fetching result )" _EOL_ ); 56 | 57 | /* without function params but return value */ 58 | hb_arrayNew( pItem, 0 ); 59 | if( LetoUdf( pConnection, NULL, HB_FALSE, "HB_MILLISECONDS", &pItem ) ) 60 | printf( "hb_MilliSeconds(): <%lu>" _EOL_, hb_itemGetNL( pItem ) ); 61 | 62 | hb_arrayNew( pItem, 0 ); 63 | if( LetoUdf( pConnection, NULL, HB_FALSE, "DATE", &pItem ) ) 64 | { 65 | char szDate[ 11 ]; 66 | 67 | hb_itemGetDS( pItem, szDate ); 68 | printf( "Date(): <%s>" _EOL_, szDate ); 69 | } 70 | 71 | hb_arrayNew( pItem, 1 ); /* one param for the remote func */ 72 | hb_arraySetNI( pItem, 1, 666 ); 73 | if( LetoUdf( pConnection, NULL, HB_FALSE, "STR", &pItem ) ) 74 | printf( "STR(666): <%s>" _EOL_, hb_itemGetCPtr( pItem ) ); 75 | 76 | hb_arrayNew( pItem, 3 ); /* three params for the remote func */ 77 | hb_arraySetC( pItem, 1, "xxxelchxxx" ); 78 | hb_arraySetNI( pItem, 2, 4 ); 79 | hb_arraySetNI( pItem, 3, 4 ); 80 | if( LetoUdf( pConnection, NULL, HB_FALSE, "SUBSTR", &pItem ) ) 81 | printf( "SUBSTR('xxxelchxxx',4,4): <%s>" _EOL_, hb_itemGetCPtr( pItem ) ); 82 | 83 | /* and don't forget ! */ 84 | hb_itemRelease( pItem ); 85 | 86 | printf( _EOL_ "logging out ..." _EOL_ ); 87 | LetoConnectionClose( pConnection ); 88 | } 89 | else 90 | printf( "Connection failure" _EOL_ ); 91 | 92 | LetoExit( 1 ); 93 | } 94 | -------------------------------------------------------------------------------- /tests/bug_info.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * bug_info[.exe] [ IP|name ] [ logfile ] 3 | * 4 | * Support function to report a bug: 5 | * function try to retrieve info from server and client 6 | * to only display it or to write this info into file . 7 | * If file exists, this info will be added at front of it. 8 | */ 9 | 10 | #include "leto_rev.ch" 11 | #include "rddleto.ch" 12 | 13 | REQUEST LETO 14 | 15 | 16 | PROCEDURE main( cPar1, cPar2, cPar3 ) 17 | AltD() 18 | LETO_BUGREPORT( cPar1, cPar2, cPar3 ) 19 | RETURN 20 | 21 | FUNCTION LETO_BUGREPORT( cSrvAddr, cLogFile, cOptions ) 22 | LOCAL nConnect := LETO_CONNECT() 23 | LOCAL cInfo := "" 24 | LOCAL cTmp, nTmp 25 | 26 | #ifndef __XHARBOUR__ /* there is no useable LETO_UDF :-( */ 27 | IF nConnect < 0 .AND. ! EMPTY( cSrvAddr ) 28 | nConnect := LETO_CONNECT( cSrvAddr ) 29 | ENDIF 30 | #endif 31 | 32 | IF nConnect >= 0 33 | cTmp := leto_udf( "OS" ) 34 | ELSE 35 | cInfo += "Server revision: " + __SRV_REVISION__ + HB_EOL() + HB_EOL() 36 | ENDIF 37 | IF ! EMPTY( cTmp ) .AND. VALTYPE( cTmp ) == "C" 38 | cInfo := "Server revision: " + __SRV_REVISION__ + HB_EOL() + cTmp + HB_EOL() 39 | 40 | cTmp := leto_udf( "VERSION" ) /* Harbour version */ 41 | IF ! EMPTY( cTmp ) .AND. VALTYPE( cTmp ) == "C" 42 | cInfo += cTmp + HB_EOL() 43 | ENDIF 44 | cTmp := leto_udf( "HB_VERSION", 1 ) /* C-compiler aka HB_VERSION_COMPILER */ 45 | IF ! EMPTY( cTmp ) .AND. VALTYPE( cTmp ) == "C" 46 | cInfo += cTmp + HB_EOL() 47 | ENDIF 48 | cInfo += HB_EOL() 49 | ENDIF 50 | 51 | cInfo += "Client revision: " + __RDD_REVISION__ + HB_EOL() + OS() + HB_EOL() 52 | cInfo += VERSION() + HB_EOL() 53 | cTmp := HB_VERSION( 1 ) /* C-compiler aka HB_VERSION_COMPILER */ 54 | IF ! EMPTY( cTmp ) .AND. VALTYPE( cTmp ) == "C" 55 | cInfo += cTmp + HB_EOL() 56 | ENDIF 57 | 58 | IF nConnect >= 0 .AND. ! EMPTY( cOptions ) 59 | IF VAL( cOptions ) >=0 .AND. LEFT( cOptions, 1 ) $ "0123456789" 60 | nTmp := VAL( cOptions ) 61 | IF leto_mgID() != nTmp /* ele we have just overwritten the log */ 62 | cTmp := leto_MgLog( nConnect, nTmp ) 63 | ELSE 64 | cTmp := "" 65 | ENDIF 66 | ELSE 67 | nTmp := -1 68 | cTmp := leto_MgLog( nConnect, -1 ) 69 | ENDIF 70 | IF ! EMPTY( cTmp ) 71 | cInfo += "- -[ " + STR( nTmp, 4, 0 ) + " ]" + REPL( "- ", 15 ) 72 | cInfo += + HB_EOL() + cTmp + REPL( "- ", 42 ) + HB_EOL() 73 | ENDIF 74 | ENDIF 75 | 76 | cInfo += HB_EOL() 77 | 78 | IF ! EMPTY( cLogFile ) .AND. VALTYPE( cLogFile ) == "C" 79 | IF FILE( cLogFile ) 80 | IF ".gz" $ LOWER( cLogFile ) 81 | cTmp := HB_ZUNCOMPRESS( MEMOREAD( cLogFile ) ) 82 | ELSE 83 | cTmp := MEMOREAD( cLogFile ) 84 | ENDIF 85 | cInfo += cTmp 86 | IF ".gz" $ LOWER( cLogFile ) 87 | cTmp := HB_GZCOMPRESS( cInfo ) 88 | IF ! EMPTY( cTmp ) 89 | MEMOWRIT( cLogFile, cTmp ) 90 | ELSE 91 | MEMOWRIT( cLogFile + ".txt", cInfo ) 92 | ENDIF 93 | ELSE 94 | MEMOWRIT( cLogFile, cInfo + MEMOREAD( cLogFile ) ) 95 | ENDIF 96 | ELSE 97 | IF ".gz" $ LOWER( cLogFile ) 98 | cTmp := HB_GZCOMPRESS( cInfo ) 99 | IF ! EMPTY( cTmp ) 100 | MEMOWRIT( cLogFile, cTmp ) 101 | ELSE 102 | MEMOWRIT( cLogFile + ".txt", cInfo ) 103 | ENDIF 104 | ELSE 105 | MEMOWRIT( cLogFile, cInfo ) 106 | ENDIF 107 | ENDIF 108 | ELSE 109 | ALERT( cInfo ) 110 | ENDIF 111 | 112 | RETURN cInfo 113 | -------------------------------------------------------------------------------- /source/server/errint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The Error API (internal error) 3 | * 4 | * Copyright 1999-2004 Viktor Szakats 5 | * 6 | * Copyright 2009 Alexander S. Kresin 7 | * updated for Leto db server 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2, or (at your option) 12 | * any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this software; see the file COPYING. If not, write to 21 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 22 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 23 | * 24 | * As a special exception, the Harbour Project gives permission for 25 | * additional uses of the text contained in its release of Harbour. 26 | * 27 | * The exception is that, if you link the Harbour libraries with other 28 | * files to produce an executable, this does not by itself cause the 29 | * resulting executable to be covered by the GNU General Public License. 30 | * Your use of that executable is in no way restricted on account of 31 | * linking the Harbour library code into it. 32 | * 33 | * This exception does not however invalidate any other reasons why 34 | * the executable file might be covered by the GNU General Public License. 35 | * 36 | * This exception applies only to the code released by the Harbour 37 | * Project under the name Harbour. If you copy code from other 38 | * Harbour Project or Free Software Foundation releases into a copy of 39 | * Harbour, as the General Public License permits, the exception does 40 | * not apply to the code that you add in this way. To avoid misleading 41 | * anyone as to the status of such modified files, you must delete 42 | * this exception notice from them. 43 | * 44 | * If you write modifications of your own for Harbour, it is your choice 45 | * whether to permit this exception to apply to your modifications. 46 | * If you do not wish that, delete this exception notice. 47 | * 48 | */ 49 | 50 | #include "hbapi.h" 51 | #include "hbapifs.h" 52 | 53 | static HB_BOOL s_bErrHandlerRun = 0; 54 | 55 | extern void leto_errInternal( HB_ULONG ulIntCode, const char * szText, const char * szPar1, const char * szPar2 ); 56 | extern HB_BOOL leto_errServerCrash( HB_ULONG ulIntCode ); 57 | 58 | /* NOTE: Use as minimal calls from here, as possible. 59 | Don't allocate memory from this function. [vszakats] */ 60 | 61 | static void hb_errInternalRaw( HB_ERRCODE ulIntCode, const char * szText, const char * szPar1, const char * szPar2 ) 62 | { 63 | 64 | if( szPar1 == NULL ) 65 | szPar1 = ""; 66 | 67 | if( szPar2 == NULL ) 68 | szPar2 = ""; 69 | 70 | if( ! s_bErrHandlerRun ) 71 | { 72 | s_bErrHandlerRun++; 73 | leto_errInternal( ( HB_ULONG ) ulIntCode, szText, szPar1, szPar2 ); 74 | } 75 | else 76 | { 77 | FILE * hLog; 78 | hLog = hb_fopen( "letodbf_crash.log", "a+" ); 79 | 80 | s_bErrHandlerRun++; 81 | if( hLog ) 82 | { 83 | fprintf( hLog, "Unrecoverable error %lu: ", ( HB_ULONG ) ulIntCode ); 84 | if( szText ) 85 | fprintf( hLog, "%s %s %s\n", szText, szPar1, szPar2 ); 86 | fclose( hLog ); 87 | } 88 | } 89 | } 90 | 91 | void hb_errInternal( HB_ERRCODE ulIntCode, const char * szText, const char * szPar1, const char * szPar2 ) 92 | { 93 | hb_errInternalRaw( ulIntCode, szText, szPar1, szPar2 ); 94 | if( ! leto_errServerCrash( ulIntCode ) && s_bErrHandlerRun == 1 ) 95 | { 96 | s_bErrHandlerRun = 0; 97 | return; 98 | } 99 | 100 | /* release console settings */ 101 | hb_conRelease(); 102 | 103 | exit( EXIT_FAILURE ); 104 | } 105 | -------------------------------------------------------------------------------- /source/3rd/lz4/README.md: -------------------------------------------------------------------------------- 1 | LZ4 - Extremely fast compression 2 | ================================ 3 | 4 | LZ4 is lossless compression algorithm, 5 | providing compression speed at 400 MB/s per core, 6 | scalable with multi-cores CPU. 7 | It also features an extremely fast decoder, 8 | with speed in multiple GB/s per core, 9 | typically reaching RAM speed limits on multi-core systems. 10 | 11 | Speed can be tuned dynamically, selecting an "acceleration" factor 12 | which trades compression ratio for more speed up. 13 | On the other end, a high compression derivative, LZ4_HC, is also provided, 14 | trading CPU time for improved compression ratio. 15 | All versions feature the same excellent decompression speed. 16 | 17 | 18 | |Branch |Status | 19 | |------------|---------| 20 | |master | [![Build Status][travisMasterBadge]][travisLink] [![Build status][AppveyorMasterBadge]][AppveyorLink] [![coverity][coverBadge]][coverlink] | 21 | |dev | [![Build Status][travisDevBadge]][travisLink] [![Build status][AppveyorDevBadge]][AppveyorLink] | 22 | 23 | [travisMasterBadge]: https://travis-ci.org/Cyan4973/lz4.svg?branch=master "Continuous Integration test suite" 24 | [travisDevBadge]: https://travis-ci.org/Cyan4973/lz4.svg?branch=dev "Continuous Integration test suite" 25 | [travisLink]: https://ci.appveyor.com/project/YannCollet/lz4 26 | [AppveyorMasterBadge]: https://ci.appveyor.com/api/projects/status/v6kxv9si529477cq/branch/master?svg=true "Visual test suite" 27 | [AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/v6kxv9si529477cq/branch/dev?svg=true "Visual test suite" 28 | [AppveyorLink]: https://ci.appveyor.com/project/YannCollet/lz4 29 | [coverBadge]: https://scan.coverity.com/projects/4735/badge.svg "Static code analysis of Master branch" 30 | [coverlink]: https://scan.coverity.com/projects/4735 31 | 32 | > **Branch Policy:** 33 | 34 | > - The "master" branch is considered stable, at all times. 35 | > - The "dev" branch is the one where all contributions must be merged 36 | before being promoted to master. 37 | > + If you plan to propose a patch, please commit into the "dev" branch, 38 | or its own feature branch. 39 | Direct commit to "master" are not permitted. 40 | 41 | Benchmarks 42 | ------------------------- 43 | 44 | The benchmark uses the [Open-Source Benchmark program by m^2 (v0.14.3)] 45 | compiled with GCC v4.8.2 on Linux Mint 64-bits v17. 46 | The reference system uses a Core i5-4300U @1.9GHz. 47 | Benchmark evaluates the compression of reference [Silesia Corpus] 48 | in single-thread mode. 49 | 50 | | Compressor | Ratio | Compression | Decompression | 51 | | ---------- | ----- | ----------- | ------------- | 52 | | memcpy | 1.000 | 4200 MB/s | 4200 MB/s | 53 | |**LZ4 fast 17 (r129)**| 1.607 |**690 MB/s** | **2220 MB/s** | 54 | |**LZ4 default (r129)**|**2.101**|**385 MB/s** | **1850 MB/s** | 55 | | LZO 2.06 | 2.108 | 350 MB/s | 510 MB/s | 56 | | QuickLZ 1.5.1.b6 | 2.238 | 320 MB/s | 380 MB/s | 57 | | Snappy 1.1.0 | 2.091 | 250 MB/s | 960 MB/s | 58 | | LZF v3.6 | 2.073 | 175 MB/s | 500 MB/s | 59 | | zlib 1.2.8 -1 | 2.730 | 59 MB/s | 250 MB/s | 60 | |**LZ4 HC (r129)** |**2.720**| 22 MB/s | **1830 MB/s** | 61 | | zlib 1.2.8 -6 | 3.099 | 18 MB/s | 270 MB/s | 62 | 63 | 64 | Documentation 65 | ------------------------- 66 | 67 | The raw LZ4 block compression format is detailed within [lz4_Block_format]. 68 | 69 | To compress an arbitrarily long file or data stream, multiple blocks are required. 70 | Organizing these blocks and providing a common header format to handle their content 71 | is the purpose of the Frame format, defined into [lz4_Frame_format]. 72 | Interoperable versions of LZ4 must respect this frame format. 73 | 74 | 75 | Other source versions 76 | ------------------------- 77 | 78 | Beyond the C reference source, 79 | many contributors have created versions of lz4 in multiple languages 80 | (Java, C#, Python, Perl, Ruby, etc.). 81 | A list of known source ports is maintained on the [LZ4 Homepage]. 82 | 83 | 84 | [Open-Source Benchmark program by m^2 (v0.14.3)]: http://encode.ru/threads/1371-Filesystem-benchmark?p=34029&viewfull=1#post34029 85 | [Silesia Corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia 86 | [lz4_Block_format]: lz4_Block_format.md 87 | [lz4_Frame_format]: lz4_Frame_format.md 88 | [LZ4 Homepage]: http://www.lz4.org -------------------------------------------------------------------------------- /source/client/letobmcl.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * Harbour Project source code: 3 | * Leto BMDBF* functions 4 | * 5 | * Copyright 2013 Pavel Tsarenko 6 | * www - http://www.harbour-project.org 7 | * 2016 Rolf 'elch' Beckmann 8 | * return values, remove dangerous LETO_PARSEREC() --> DbGoTo() 9 | * removed array to string conversions 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2, or (at your option) 14 | * any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this software; see the file COPYING. If not, write to 23 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 24 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 25 | * 26 | * As a special exception, the Harbour Project gives permission for 27 | * additional uses of the text contained in its release of Harbour. 28 | * 29 | * The exception is that, if you link the Harbour libraries with other 30 | * files to produce an executable, this does not by itself cause the 31 | * resulting executable to be covered by the GNU General Public License. 32 | * Your use of that executable is in no way restricted on account of 33 | * linking the Harbour library code into it. 34 | * 35 | * This exception does not however invalidate any other reasons why 36 | * the executable file might be covered by the GNU General Public License. 37 | * 38 | * This exception applies only to the code released by the Harbour 39 | * Project under the name Harbour. If you copy code from other 40 | * Harbour Project or Free Software Foundation releases into a copy of 41 | * Harbour, as the General Public License permits, the exception does 42 | * not apply to the code that you add in this way. To avoid misleading 43 | * anyone as to the status of such modified files, you must delete 44 | * this exception notice from them. 45 | * 46 | * If you write modifications of your own for Harbour, it is your choice 47 | * whether to permit this exception to apply to your modifications. 48 | * If you do not wish that, delete this exception notice. 49 | * 50 | */ 51 | 52 | STATIC FUNCTION IsLeto 53 | RETURN Used() .AND. rddName() == "LETO" 54 | 55 | FUNCTION LBM_DbGetFilterArray() 56 | 57 | LOCAL aFilterRec := {} 58 | 59 | IF IsLeto() 60 | aFilterRec := leto_UDF( "LBM_DbGetFilterArray" ) 61 | ENDIF 62 | 63 | RETURN IIF( VALTYPE( aFilterRec ) == "A", aFilterRec, {} ) 64 | 65 | FUNCTION LBM_DbSetFilterArray( aFilterRec ) 66 | 67 | LOCAL xRet := .F. 68 | 69 | IF IsLeto() .AND. ValType( aFilterRec ) == "A" .AND. LEN( aFilterRec ) > 0 70 | xRet := leto_UDF( "LBM_DbSetFilterArray", aFilterRec ) 71 | IF VALTYPE( xRet ) == "L" .AND. xRet 72 | leto_SetBM() 73 | ENDIF 74 | ENDIF 75 | 76 | RETURN xRet 77 | 78 | FUNCTION LBM_DbSetFilterArrayAdd( aFilterRec ) 79 | 80 | LOCAL xRet := .F. 81 | 82 | IF IsLeto() .AND. ValType( aFilterRec ) == "A" .AND. LEN( aFilterRec ) > 0 83 | xRet := leto_UDF( "LBM_DbSetFilterArrayAdd", aFilterRec ) 84 | IF VALTYPE( xRet ) == "L" .AND. xRet 85 | leto_SetBM() 86 | ENDIF 87 | ENDIF 88 | 89 | RETURN xRet 90 | 91 | FUNCTION LBM_DbSetFilterArrayDel( aFilterRec ) 92 | 93 | LOCAL xRet := .F. 94 | 95 | IF IsLeto() .AND. ValType( aFilterRec ) == "A" .AND. LEN( aFilterRec ) > 0 96 | xRet := leto_UDF( "LBM_DbSetFilterArrayDel", aFilterRec ) 97 | IF VALTYPE( xRet ) == "L" .AND. xRet 98 | leto_SetBM() 99 | ENDIF 100 | ENDIF 101 | 102 | RETURN xRet 103 | 104 | /* ToDo much too dangerous, SCOPE and FILTER need pre-validation */ 105 | FUNCTION LBM_DbSetFilter( xScope, xScopeBottom, cFilter ) 106 | 107 | LOCAL nRecno, xRet := .F. 108 | 109 | IF IsLeto() 110 | nRecno := leto_Udf( "LBM_DbSetFilter", xScope, xScopeBottom, OrdName( 0 ), cFilter, Set( _SET_DELETED ) ) 111 | IF VALTYPE( nRecno ) == "N" .AND. nRecno > 0 112 | leto_SetBM() 113 | DBGOTO( nRecno ) 114 | xRet := .T. 115 | ENDIF 116 | ENDIF 117 | 118 | RETURN xRet 119 | 120 | -------------------------------------------------------------------------------- /tests/php/testleto1.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | Leto test 6 | 11 | 12 | 13 |

"; 22 | echo ""; 23 | echo ""; 24 | echo ""; 25 | echo ""; 26 | echo "
"; 21 | echo $conn["ver"]."
Users current".$arr[0]."Users max".$arr[1]."
Tables current".$arr[2]."Tables max".$arr[3]."
Operations".$arr[5]."  
Kbytes sent".strval(round(intval($arr[6])/1024))."Kbytes read".strval(round(intval($arr[7])/1024))."

"; 27 | 28 | letoVarSet($conn,"g_1","var0","2",987654321.123456789,1); 29 | $n1 = letoVarGet($conn,"g_1","var0"); 30 | if( $n1 ) { 31 | echo "var0 = ".$n1."
"; 32 | letoVarSum($conn,"g_1","var0",0,-321.123); 33 | $n1 = letoVarGet($conn,"g_1","var0"); 34 | if( $n1 ) 35 | echo "var0 + -321.123 = ".$n1."
"; 36 | } 37 | else 38 | echo "var0 = Error
"; 39 | 40 | letoVarSet($conn,"g_1","var1","2",101,1); 41 | $n1 = letoVarGet($conn,"g_1","var1"); 42 | if( $n1 ) 43 | echo "var1 = ".$n1."
"; 44 | else 45 | echo "var1 = Error
"; 46 | 47 | letoVarIncr($conn,"g_1","var1",0); 48 | $n1 = letoVarGet($conn,"g_1","var1"); 49 | echo "After increment "; 50 | if( $n1 ) 51 | echo "var1 = ".$n1."
"; 52 | else 53 | echo "var1 = Error
"; 54 | 55 | letoVarDecr($conn,"g_1","var1",0); 56 | $n1 = letoVarGet($conn,"g_1","var1"); 57 | echo "After decrement "; 58 | if( $n1 ) 59 | echo "var1 = ".$n1."
"; 60 | else 61 | echo "var1 = Error
"; 62 | 63 | letoVarSum($conn,"g_1","var1",0,-10); 64 | letoVarSum($conn,"g_1","var1",0,+20.111); 65 | $n1 = letoVarGet($conn,"g_1","var1"); 66 | echo "After sum -10/ sum +20 "; 67 | if( $n1 ) 68 | echo "var1 = ".$n1."
"; 69 | else 70 | echo "var1 = Error
"; 71 | 72 | letoVarSet($conn,"g_1","var2","3","Leto_DBf in PHP",1); 73 | $n2 = letoVarGet($conn,"g_1","var2"); 74 | if( $n2 ) 75 | echo "var2 = '".$n2."'
"; 76 | else 77 | echo "var2 = Error
"; 78 | 79 | letoVarSet($conn,"g_1","var3","5","T",1); 80 | $n3 = letoVarGet($conn,"g_1","var3"); 81 | if( $n3 ) 82 | echo "var3 = #true#
"; 83 | else 84 | echo "var3 = Error
"; 85 | 86 | letoVarSet($conn,"g_1","var4","5","2019/01/25",1); 87 | $n2 = letoVarGet($conn,"g_1","var4"); 88 | if( $n2 ) 89 | echo "var4 = '".$n2."'
"; 90 | else 91 | echo "var4 = Error
"; 92 | 93 | letoVarDel($conn,"g_1","var0"); 94 | letoVarDel($conn,"g_1","var1"); 95 | letoVarDel($conn,"g_1","var2"); 96 | letoVarDel($conn,"g_1","var3"); 97 | letoVarDel($conn,"g_1","var4"); 98 | 99 | 100 | echo "
Leto_UDF action ...
"; 101 | $udf = "TRANSFORM"; 102 | $udfexist = letoUdfExist($conn,$udf); 103 | if( $udfexist ) 104 | echo "function '".$udf."' available at LetoDBf
"; 105 | else 106 | echo "Error with UDF test
"; 107 | 108 | $udf = "DATE"; 109 | $udfexec = letoUdf($conn,$udf,true,false); 110 | if( $udfexec ) 111 | echo "function '".$udf."' executed at LetoDBf
"; 112 | else 113 | echo "Error with UDF exec
"; 114 | 115 | } 116 | 117 | if(isset($conn)) 118 | socket_close($conn["sock"]); 119 | } 120 | ?> 121 | 122 | 123 | -------------------------------------------------------------------------------- /source/server/letobm.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * Leto db server BMDBF* functions 3 | * 4 | * Copyright 2013 Pavel Tsarenko 5 | * 2016 Rolf 'elch' Beckmann 6 | * boolean return values, removed array to string conversions 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this software; see the file COPYING. If not, write to 20 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 22 | * 23 | * As a special exception, the Harbour Project gives permission for 24 | * additional uses of the text contained in its release of Harbour. 25 | * 26 | * The exception is that, if you link the Harbour libraries with other 27 | * files to produce an executable, this does not by itself cause the 28 | * resulting executable to be covered by the GNU General Public License. 29 | * Your use of that executable is in no way restricted on account of 30 | * linking the Harbour library code into it. 31 | * 32 | * This exception does not however invalidate any other reasons why 33 | * the executable file might be covered by the GNU General Public License. 34 | * 35 | * This exception applies only to the code released by the Harbour 36 | * Project under the name Harbour. If you copy code from other 37 | * Harbour Project or Free Software Foundation releases into a copy of 38 | * Harbour, as the General Public License permits, the exception does 39 | * not apply to the code that you add in this way. To avoid misleading 40 | * anyone as to the status of such modified files, you must delete 41 | * this exception notice from them. 42 | * 43 | * If you write modifications of your own for Harbour, it is your choice 44 | * whether to permit this exception to apply to your modifications. 45 | * If you do not wish that, delete this exception notice. 46 | * 47 | */ 48 | 49 | FUNCTION LBM_DbGetFilterArray() 50 | 51 | LOCAL aFilterRec 52 | 53 | leto_BMRestore() 54 | aFilterRec := BM_DbGetFilterArray() 55 | leto_BMSave() 56 | 57 | RETURN aFilterRec 58 | 59 | FUNCTION LBM_DbSetFilterArray( aFilterRec ) 60 | 61 | LOCAL xRet := .F. 62 | 63 | IF ValType( aFilterRec ) == "A" .AND. LEN( aFilterRec ) > 0 64 | leto_BMRestore( .T. ) 65 | BM_DbSetFilterArray( aFilterRec ) 66 | xRet := leto_BMSave() 67 | ENDIF 68 | 69 | RETURN xRet 70 | 71 | FUNCTION LBM_DbSetFilterArrayAdd( aFilterRec ) 72 | 73 | LOCAL xRet := .F. 74 | 75 | IF ValType( aFilterRec ) == "A" .AND. LEN( aFilterRec ) > 0 76 | leto_BMRestore() 77 | BM_DbSetFilterArrayAdd( ) 78 | xRet := leto_BMSave() 79 | ENDIF 80 | 81 | RETURN xRet 82 | 83 | FUNCTION LBM_DbSetFilterArrayDel( aFilterRec ) 84 | 85 | LOCAL xRet := .F. 86 | 87 | IF ValType( aFilterRec ) == "A" .AND. LEN( aFilterRec ) > 0 88 | leto_BMRestore() 89 | BM_DbSetFilterArrayDel( aFilterRec ) 90 | aFilterRec := BM_DbGetFilterArray() 91 | IF ValType( aFilterRec ) != "A" .OR. LEN( aFilterRec ) < 1 92 | leto_BMRestore( .T. ) 93 | ELSE 94 | xRet := leto_BMSave() 95 | ENDIF 96 | ENDIF 97 | 98 | RETURN xRet 99 | 100 | /* 101 | * LBM_DbSetFilter set bitmap filter by order , and for condition, 102 | * defined in , , , parameters 103 | * Returns buffer with first filtered record 104 | * Function call from client: 105 | * 106 | * DbGoto( leto_Udf('LBM_DbSetFilter', , , , , ) ) 107 | */ 108 | FUNCTION LBM_DbSetFilter( xScope, xScopeBottom, xOrder, cFilter, lDeleted ) 109 | 110 | LOCAL nRec := 0, aFilterRec := {} 111 | LOCAL lOpt := Set( _SET_FORCEOPT, .F. ) 112 | 113 | leto_SetEnv( xScope, xScopeBottom, xOrder, cFilter, lDeleted ) 114 | DbGoTop() 115 | IF ! Eof() 116 | nRec := RecNo() 117 | ENDIF 118 | WHILE ! Eof() 119 | AAdd( aFilterRec, RecNo() ) 120 | SKIP 121 | ENDDO 122 | leto_ClearEnv( xScope, xScopeBottom, xOrder, cFilter ) 123 | IF LEN( aFilterRec ) > 0 124 | LBM_DbSetFilterArray( aFilterRec ) 125 | ENDIF 126 | SET( _SET_FORCEOPT, lOpt ) 127 | 128 | RETURN nRec 129 | 130 | -------------------------------------------------------------------------------- /source/common/common.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * Ini files reading procedure 3 | * 4 | * Copyright 2008 Alexander S. Kresin 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 19 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 20 | * 21 | * As a special exception, the Harbour Project gives permission for 22 | * additional uses of the text contained in its release of Harbour. 23 | * 24 | * The exception is that, if you link the Harbour libraries with other 25 | * files to produce an executable, this does not by itself cause the 26 | * resulting executable to be covered by the GNU General Public License. 27 | * Your use of that executable is in no way restricted on account of 28 | * linking the Harbour library code into it. 29 | * 30 | * This exception does not however invalidate any other reasons why 31 | * the executable file might be covered by the GNU General Public License. 32 | * 33 | * This exception applies only to the code released by the Harbour 34 | * Project under the name Harbour. If you copy code from other 35 | * Harbour Project or Free Software Foundation releases into a copy of 36 | * Harbour, as the General Public License permits, the exception does 37 | * not apply to the code that you add in this way. To avoid misleading 38 | * anyone as to the status of such modified files, you must delete 39 | * this exception notice from them. 40 | * 41 | * If you write modifications of your own for Harbour, it is your choice 42 | * whether to permit this exception to apply to your modifications. 43 | * If you do not wish that, delete this exception notice. 44 | * 45 | */ 46 | 47 | #include "fileio.ch" 48 | #define STR_BUFLEN 4096 49 | 50 | FUNCTION RDINI( fname ) 51 | 52 | LOCAL han, stroka, strfull, poz1, vname, arr 53 | LOCAL strbuf := Space( STR_BUFLEN ), poz := STR_BUFLEN + 1 54 | 55 | IF ( han := FOpen( fname, FO_READ + FO_SHARED ) ) != - 1 56 | arr := {} 57 | strfull := "" 58 | DO WHILE .T. 59 | IF Len( stroka := RDSTR( han, @strbuf, @poz, STR_BUFLEN ) ) == 0 60 | EXIT 61 | ENDIF 62 | IF Right( stroka, 1 ) == '&' 63 | strfull += Left( stroka, Len( stroka ) -1 ) 64 | LOOP 65 | ELSE 66 | IF !Empty( strfull ) 67 | stroka := strfull + stroka 68 | ENDIF 69 | strfull := "" 70 | ENDIF 71 | 72 | IF Left( stroka, 1 ) == "[" 73 | stroka := Upper( SubStr( stroka, 2, At( "]", stroka ) - 2 ) ) 74 | AAdd( arr, { stroka, {} } ) 75 | ELSEIF Left( stroka, 1 ) <> ";" 76 | poz1 := At( "=", stroka ) 77 | IF poz1 != 0 78 | IF Empty( arr ) 79 | AAdd( arr, { "MAIN", {} } ) 80 | ENDIF 81 | vname := AllTrim( Left( stroka, poz1 - 1 ) ) 82 | stroka := AllTrim( SubStr( stroka, poz1 + 1 ) ) 83 | IF Left( stroka, 1 ) == '"' .AND. Right( stroka, 1 ) == '"' 84 | stroka := SubStr( stroka, 2, Len( stroka ) - 2 ) 85 | ENDIF 86 | AAdd( arr[ Len( arr ), 2 ], { Upper( vname ), stroka } ) 87 | ENDIF 88 | ENDIF 89 | ENDDO 90 | FClose( han ) 91 | ENDIF 92 | 93 | RETURN arr 94 | 95 | STATIC FUNCTION RDSTR( han, strbuf, poz, buflen ) 96 | 97 | LOCAL stro := "", rez, oldpoz, poz1 98 | 99 | oldpoz := poz 100 | poz := At( Chr( 10 ), SubStr( strbuf, poz ) ) 101 | IF poz = 0 102 | IF han <> Nil 103 | stro += SubStr( strbuf, oldpoz ) 104 | rez := FRead( han, @strbuf, buflen ) 105 | IF rez = 0 106 | RETURN "" 107 | ELSEIF rez < buflen 108 | strbuf := SubStr( strbuf, 1, rez ) + Chr( 10 ) + Chr( 13 ) 109 | ENDIF 110 | poz := At( Chr( 10 ), strbuf ) 111 | stro += SubStr( strbuf, 1, poz ) 112 | ELSE 113 | stro += RTrim( SubStr( strbuf, oldpoz ) ) 114 | poz := oldpoz + Len( stro ) 115 | IF Len( stro ) == 0 116 | RETURN "" 117 | ENDIF 118 | ENDIF 119 | ELSE 120 | stro += SubStr( strbuf, oldpoz, poz ) 121 | poz += oldpoz - 1 122 | ENDIF 123 | poz ++ 124 | poz1 := Len( stro ) 125 | IF poz1 > 2 .AND. Right( stro, 1 ) $ Chr( 13 ) + Chr( 10 ) 126 | IF SubStr( stro, poz1 - 1, 1 ) $ Chr( 13 ) + Chr( 10 ) 127 | poz1 -- 128 | ENDIF 129 | stro := SubStr( stro, 1, poz1 - 1 ) 130 | ENDIF 131 | 132 | RETURN stro 133 | 134 | -------------------------------------------------------------------------------- /include/cmdleto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Header file for Leto command set 3 | * 4 | * Copyright 2014-2016 Rolf 'elch' Beckmann 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 19 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 20 | * 21 | * As a special exception, the Harbour Project gives permission for 22 | * additional uses of the text contained in its release of Harbour. 23 | * 24 | * The exception is that, if you link the Harbour libraries with other 25 | * files to produce an executable, this does not by itself cause the 26 | * resulting executable to be covered by the GNU General Public License. 27 | * Your use of that executable is in no way restricted on account of 28 | * linking the Harbour library code into it. 29 | * 30 | * This exception does not however invalidate any other reasons why 31 | * the executable file might be covered by the GNU General Public License. 32 | * 33 | * This exception applies only to the code released by the Harbour 34 | * Project under the name Harbour. If you copy code from other 35 | * Harbour Project or Free Software Foundation releases into a copy of 36 | * Harbour, as the General Public License permits, the exception does 37 | * not apply to the code that you add in this way. To avoid misleading 38 | * anyone as to the status of such modified files, you must delete 39 | * this exception notice from them. 40 | * 41 | * If you write modifications of your own for Harbour, it is your choice 42 | * whether to permit this exception to apply to your modifications. 43 | * If you do not wish that, delete this exception notice. 44 | * 45 | */ 46 | 47 | 48 | /* request marked with '+' does not send positive feedback if second socket available */ 49 | 50 | /* note: this .h include file also used for server.prg */ 51 | 52 | #define LETOCMD_OFFSET 64 /* offset base value */ 53 | #define LETOCMD_SETLEN 64 /* length of arrays with functions/ descriptions */ 54 | 55 | /* still not used char */ 56 | /* [ \ ] ^ _ 91-95 */ 57 | /* avoid: ` == 96 */ 58 | 59 | 60 | /* without ulAreaID */ 61 | /* reserved for @A - Z */ 62 | /* 0x40-0x5A // 64-90 */ 63 | /* FREE: G H @ */ 64 | /* 'S' is PRESEVED ! */ 65 | 66 | #define LETOCMD_admin 'A' 67 | #define LETOCMD_creat_i 'B' 68 | #define LETOCMD_close 'C' // + note: also transmits a 0x ulAreaID 69 | #define LETOCMD_drop 'D' 70 | #define LETOCMD_exists 'E' 71 | #define LETOCMD_file 'F' 72 | #define LETOCMD_open_i 'I' 73 | #define LETOCMD_intro 'J' 74 | #define LETOCMD_udf_rel 'K' 75 | #define LETOCMD_closall 'L' // + 76 | #define LETOCMD_mgmt 'M' 77 | #define LETOCMD_creat 'N' 78 | #define LETOCMD_open 'O' 79 | #define LETOCMD_ping 'P' 80 | #define LETOCMD_quit 'Q' 81 | #define LETOCMD_rename 'R' 82 | #define LETOCMD_sql 'S' 83 | #define LETOCMD_ta 'T' 84 | #define LETOCMD_udf_fun 'U' 85 | #define LETOCMD_var 'V' 86 | #define LETOCMD_set 'W' // + 87 | #define LETOCMD_stop 'X' 88 | #define LETOCMD_rddinfo 'Y' 89 | #define LETOCMD_zip 'Z' 90 | 91 | 92 | /* with ulAreaID */ 93 | /* a - z { | } ~ */ 94 | /* 0x61-0x7e 97 -126 */ 95 | /* FREE: v | } ~ */ 96 | 97 | #define LETOCMD_add 'a' 98 | #define LETOCMD_dbi 'b' 99 | #define LETOCMD_dboi 'c' 100 | #define LETOCMD_scop 'd' 101 | #define LETOCMD_seek 'e' 102 | #define LETOCMD_flush 'f' // + 103 | #define LETOCMD_goto 'g' 104 | #define LETOCMD_group 'h' 105 | #define LETOCMD_filt 'i' // clear filter: + 106 | #define LETOCMD_sum 'j' 107 | #define LETOCMD_unlock 'k' // + 108 | #define LETOCMD_lock 'l' 109 | #define LETOCMD_memo 'm' // put/add + 110 | #define LETOCMD_udf_dbf 'n' 111 | #define LETOCMD_ord 'o' 112 | #define LETOCMD_pack 'p' 113 | #define LETOCMD_sort 'q' 114 | #define LETOCMD_islock 'r' 115 | #define LETOCMD_skip 's' 116 | #define LETOCMD_cmta 't' 117 | #define LETOCMD_upd 'u' // not bAppend, else + 118 | #define LETOCMD_dbeval 'v' 119 | #define LETOCMD_rela 'w' 120 | #define LETOCMD_cmtu 'x' 121 | #define LETOCMD_rcou 'y' 122 | #define LETOCMD_zap 'z' 123 | #define LETOCMD_trans '{' 124 | #define LETOCMD_locate '}' 125 | 126 | /* - sub command values - */ 127 | 128 | /* for memo */ 129 | #define LETOSUB_add 'a' 130 | #define LETOSUB_get 'g' 131 | #define LETOSUB_put 'p' 132 | 133 | /* vars -- also use 'get' */ 134 | #define LETOSUB_set 's' 135 | #define LETOSUB_inc 'i' 136 | #define LETOSUB_dec 'd' 137 | #define LETOSUB_del 'r' 138 | #define LETOSUB_list 'l' 139 | 140 | -------------------------------------------------------------------------------- /source/3rd/lz4/lz4_Block_format.md: -------------------------------------------------------------------------------- 1 | LZ4 Block Format Description 2 | ============================ 3 | Last revised: 2015-05-07. 4 | Author : Yann Collet 5 | 6 | 7 | This specification is intended for developers 8 | willing to produce LZ4-compatible compressed data blocks 9 | using any programming language. 10 | 11 | LZ4 is an LZ77-type compressor with a fixed, byte-oriented encoding. 12 | There is no entropy encoder back-end nor framing layer. 13 | The latter is assumed to be handled by other parts of the system (see [LZ4 Frame format]). 14 | This design is assumed to favor simplicity and speed. 15 | It helps later on for optimizations, compactness, and features. 16 | 17 | This document describes only the block format, 18 | not how the compressor nor decompressor actually work. 19 | The correctness of the decompressor should not depend 20 | on implementation details of the compressor, and vice versa. 21 | 22 | [LZ4 Frame format]: LZ4_Frame_format.md 23 | 24 | 25 | 26 | Compressed block format 27 | ----------------------- 28 | An LZ4 compressed block is composed of sequences. 29 | A sequence is a suite of literals (not-compressed bytes), 30 | followed by a match copy. 31 | 32 | Each sequence starts with a token. 33 | The token is a one byte value, separated into two 4-bits fields. 34 | Therefore each field ranges from 0 to 15. 35 | 36 | 37 | The first field uses the 4 high-bits of the token. 38 | It provides the length of literals to follow. 39 | 40 | If the field value is 0, then there is no literal. 41 | If it is 15, then we need to add some more bytes to indicate the full length. 42 | Each additional byte then represent a value from 0 to 255, 43 | which is added to the previous value to produce a total length. 44 | When the byte value is 255, another byte is output. 45 | There can be any number of bytes following the token. There is no "size limit". 46 | (Side note : this is why a not-compressible input block is expanded by 0.4%). 47 | 48 | Example 1 : A length of 48 will be represented as : 49 | 50 | - 15 : value for the 4-bits High field 51 | - 33 : (=48-15) remaining length to reach 48 52 | 53 | Example 2 : A length of 280 will be represented as : 54 | 55 | - 15 : value for the 4-bits High field 56 | - 255 : following byte is maxed, since 280-15 >= 255 57 | - 10 : (=280 - 15 - 255) ) remaining length to reach 280 58 | 59 | Example 3 : A length of 15 will be represented as : 60 | 61 | - 15 : value for the 4-bits High field 62 | - 0 : (=15-15) yes, the zero must be output 63 | 64 | Following the token and optional length bytes, are the literals themselves. 65 | They are exactly as numerous as previously decoded (length of literals). 66 | It's possible that there are zero literal. 67 | 68 | 69 | Following the literals is the match copy operation. 70 | 71 | It starts by the offset. 72 | This is a 2 bytes value, in little endian format 73 | (the 1st byte is the "low" byte, the 2nd one is the "high" byte). 74 | 75 | The offset represents the position of the match to be copied from. 76 | 1 means "current position - 1 byte". 77 | The maximum offset value is 65535, 65536 cannot be coded. 78 | Note that 0 is an invalid value, not used. 79 | 80 | Then we need to extract the match length. 81 | For this, we use the second token field, the low 4-bits. 82 | Value, obviously, ranges from 0 to 15. 83 | However here, 0 means that the copy operation will be minimal. 84 | The minimum length of a match, called minmatch, is 4. 85 | As a consequence, a 0 value means 4 bytes, and a value of 15 means 19+ bytes. 86 | Similar to literal length, on reaching the highest possible value (15), 87 | we output additional bytes, one at a time, with values ranging from 0 to 255. 88 | They are added to total to provide the final match length. 89 | A 255 value means there is another byte to read and add. 90 | There is no limit to the number of optional bytes that can be output this way. 91 | (This points towards a maximum achievable compression ratio of about 250). 92 | 93 | With the offset and the matchlength, 94 | the decoder can now proceed to copy the data from the already decoded buffer. 95 | On decoding the matchlength, we reach the end of the compressed sequence, 96 | and therefore start another one. 97 | 98 | 99 | Parsing restrictions 100 | ----------------------- 101 | There are specific parsing rules to respect in order to remain compatible 102 | with assumptions made by the decoder : 103 | 104 | 1. The last 5 bytes are always literals 105 | 2. The last match must start at least 12 bytes before end of block. 106 | Consequently, a block with less than 13 bytes cannot be compressed. 107 | 108 | These rules are in place to ensure that the decoder 109 | will never read beyond the input buffer, nor write beyond the output buffer. 110 | 111 | Note that the last sequence is also incomplete, 112 | and stops right after literals. 113 | 114 | 115 | Additional notes 116 | ----------------------- 117 | There is no assumption nor limits to the way the compressor 118 | searches and selects matches within the source data block. 119 | It could be a fast scan, a multi-probe, a full search using BST, 120 | standard hash chains or MMC, well whatever. 121 | 122 | Advanced parsing strategies can also be implemented, such as lazy match, 123 | or full optimal parsing. 124 | 125 | All these trade-off offer distinctive speed/memory/compression advantages. 126 | Whatever the method used by the compressor, its result will be decodable 127 | by any LZ4 decoder if it follows the format specification described above. 128 | -------------------------------------------------------------------------------- /source/server/leto_lnx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Leto db server (linux) functions 3 | * 4 | * Copyright 2008 Alexander S. Kresin 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 19 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 20 | * 21 | * As a special exception, the Harbour Project gives permission for 22 | * additional uses of the text contained in its release of Harbour. 23 | * 24 | * The exception is that, if you link the Harbour libraries with other 25 | * files to produce an executable, this does not by itself cause the 26 | * resulting executable to be covered by the GNU General Public License. 27 | * Your use of that executable is in no way restricted on account of 28 | * linking the Harbour library code into it. 29 | * 30 | * This exception does not however invalidate any other reasons why 31 | * the executable file might be covered by the GNU General Public License. 32 | * 33 | * This exception applies only to the code released by the Harbour 34 | * Project under the name Harbour. If you copy code from other 35 | * Harbour Project or Free Software Foundation releases into a copy of 36 | * Harbour, as the General Public License permits, the exception does 37 | * not apply to the code that you add in this way. To avoid misleading 38 | * anyone as to the status of such modified files, you must delete 39 | * this exception notice from them. 40 | * 41 | * If you write modifications of your own for Harbour, it is your choice 42 | * whether to permit this exception to apply to your modifications. 43 | * If you do not wish that, delete this exception notice. 44 | * 45 | */ 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | #include "srvleto.h" 59 | 60 | 61 | static void leto_pwnam( const char * username, uid_t * pw_uid, gid_t * pw_gid ) 62 | { 63 | struct passwd * pwd = NULL; 64 | 65 | *pw_uid = 0; 66 | *pw_gid = 0; 67 | 68 | if( username && *username ) 69 | pwd = getpwnam( username ); 70 | if( pwd ) 71 | { 72 | *pw_uid = pwd->pw_uid; 73 | *pw_gid = pwd->pw_gid; 74 | } 75 | } 76 | 77 | HB_FUNC( LETO_DAEMON ) 78 | { 79 | int iPID, i, numFiles; 80 | HB_FHANDLE hNull; 81 | uid_t pw_uid; 82 | gid_t pw_gid; 83 | 84 | iPID = fork(); 85 | 86 | switch( iPID ) 87 | { 88 | case 0: /* we are the child process */ 89 | break; 90 | 91 | case -1: /* error - bail out (fork failing is very bad) */ 92 | fprintf( stderr, "Error: initial fork failed: %s\n", strerror( errno ) ); 93 | leto_writelog( NULL, -1, "ERROR: initial fork failed: %s\n", strerror( errno ) ); 94 | hb_retl( HB_FALSE ); 95 | return; 96 | 97 | default: /* we are the parent, so exit */ 98 | hb_retl( HB_TRUE ); 99 | hb_vmRequestQuit(); 100 | return; 101 | } 102 | 103 | if( setsid() < 0 ) 104 | { 105 | hb_retl( HB_FALSE ); 106 | return; 107 | } 108 | 109 | numFiles = sysconf( _SC_OPEN_MAX ); /* how many file descriptors? */ 110 | for( i = numFiles - 1; i >= 0; --i ) /* close all open files except lock */ 111 | { 112 | close( i ); 113 | } 114 | 115 | /* redirect stdin|stdout|stderr to /dev/null */ 116 | for( i = 0; i <= 2; i++ ) 117 | { 118 | hNull = open( "/dev/null", i == 0 ? O_RDONLY : O_WRONLY ); 119 | if( hNull < ( HB_FHANDLE ) 0 || dup2( hNull, i ) != i ) 120 | { 121 | hb_retl( HB_FALSE ); 122 | return; 123 | } 124 | } 125 | 126 | umask( 0x02 ); /* rw-rw-r-- set this to whatever is appropriate for you */ 127 | 128 | #if defined( __GNUC__ ) && ( ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406 ) 129 | # pragma GCC diagnostic push 130 | # pragma GCC diagnostic ignored "-Wunused-result" 131 | #endif 132 | 133 | /* fetch UID/ GOD from optional given user */ 134 | leto_pwnam( hb_parc( 3 ), &pw_uid, &pw_gid ); 135 | if( ! pw_uid || ! pw_gid ) 136 | { 137 | if( HB_IS_INTEGER( hb_param( 1, HB_IT_NUMERIC ) ) && hb_parni( 1 ) > 0 ) 138 | pw_uid = hb_parni( 1 ); 139 | if( HB_IS_INTEGER( hb_param( 2, HB_IT_NUMERIC ) ) && hb_parni( 2 ) > 0 ) 140 | pw_gid = hb_parni( 2 ); 141 | } 142 | 143 | /* order seem important, and commonly need root rights to change */ 144 | if( pw_gid ) 145 | ( void ) setgid( pw_gid ); 146 | if( pw_uid ) 147 | ( void ) setuid( pw_uid ); 148 | 149 | #if defined( __GNUC__ ) && ( ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406 ) 150 | # pragma GCC diagnostic pop 151 | #endif 152 | 153 | /* setpgrp(); */ 154 | hb_retl( HB_TRUE ); 155 | return; 156 | } 157 | 158 | HB_FUNC( LETO_UMASK ) 159 | { 160 | if( HB_ISNUM( 1 ) ) 161 | { 162 | mode_t mask = ( mode_t ) hb_parni( 1 ); 163 | umask( mask ); 164 | } 165 | } 166 | 167 | 168 | -------------------------------------------------------------------------------- /makefile.bc: -------------------------------------------------------------------------------- 1 | # $Id: makefile.bc,v 1.15.2.6 2013/12/13 16:40:26 alkresin Exp $ 2 | # makefile for Borland C/C++ 32 bits 3 | # useful for building the RDD lib for xHarbour, needs BCC >= v5.8.2 as v5.5 fails with LZ4 4 | 5 | .AUTODEPEND 6 | 7 | # adapt ! if HB_PATH/ executable is still not set as root path of harbour: 8 | HRB_DIR = $(HB_PATH) 9 | HRB_EXE = $(HRB_DIR)\bin\$(HARBOUR_EXE) 10 | 11 | # comment next line for not using LZ4 dummy functions aka with encrypted (needs compressed) traffic 12 | USE_LZ4_DUMMY = yes 13 | 14 | 15 | # ------ 16 | 17 | # needs a special build multi-thread executable - still don't know how for xHarbour 18 | # check 'test_file' example for RTE * MUST * happen at end - then permanently comment it out 19 | USE_SINGLE_SOCKET = yes 20 | 21 | # xHarbour NOT yet uncomment next line if you want to build letodbf client lib with BMDBF* support 22 | # __BM = yes 23 | 24 | !if !$d(ECHO) 25 | ECHO = echo. 26 | !endif 27 | !if !$d(DEL) 28 | DEL = del 29 | !endif 30 | 31 | HARBOUR_LIBS = debug.lib vm.lib rtl.lib $(HB_GT_LIB) lang.lib rdd.lib macro.lib pp.lib common.lib codepage.lib pcrepos.lib 32 | HARBOUR_LIBS = $(HARBOUR_LIBS) dbfntx.lib dbfcdx.lib dbffpt.lib hbsix.lib 33 | CC = BCC32 34 | LINKER = TLIB 35 | 36 | # This is needed, otherwise the libs may overflow when 37 | # debug info is requested with -v -y 38 | # if debug info is requested, set ARFLAGS to /P64 in your environment 39 | !if !$d(ARFLAGS) 40 | ARFLAGS = /0 41 | !endif 42 | 43 | !if !$d(BCC_NOOPTIM) 44 | CFLAGS = -O2 $(CFLAGS) 45 | !endif 46 | 47 | # 48 | # Directory macros. These should never have to change. 49 | ## 50 | LETO_LIB_DIR = lib 51 | INCLUDE_DIR = include;$(HRB_DIR)\include;C:\BCC58\include; 52 | CLIENT_DIR = source\client 53 | COMMON_DIR = source\common 54 | LZ4_DIR = source\3rd\lz4\lib 55 | OBJ_DIR = obj\bcc 56 | API_DIR = obj\api 57 | 58 | # 59 | # C compiler definition and C flags. These should never have to change. 60 | # 61 | 62 | CFLAGS = -I$(INCLUDE_DIR) -I$(LZ4_DIR) -d $(C_USR) $(CFLAGS) -tWM -D__WIN32__ 63 | CLIBFLAGS = -c $(CFLAGS) $(CLIBFLAGS) 64 | CLIBFLAGSDEBUG = -v $(CLIBFLAGS) 65 | HARBOURFLAGS = -i$(INCLUDE_DIR) -n -q0 -w3 -es2 -dUSE_LZ4 $(HARBOURFLAGS) 66 | LDFLAGS = $(LDFLAGS) 67 | 68 | !if $d(USE_SINGLE_SOCKET) 69 | SINGLESOCKET = -DLETO_NO_THREAD=1 70 | !endif 71 | 72 | !if $d(USE_LZ4_DUMMY) 73 | LZ4_DUMMY = -DLZ4_DUMMY 74 | !endif 75 | 76 | !if $d(__BM) 77 | CLIBFLAGS = $(CLIBFLAGS) -D__BM 78 | HARBOURFLAGS = $(HARBOURFLAGS) -D__BM 79 | !endif 80 | 81 | !if ! $d(HB_MT) 82 | CLIBFLAGS = $(CLIBFLAGS) $(SINGLETHREAD) 83 | !endif 84 | 85 | CLIBFLAGS = $(CLIBFLAGS) $(LZ4_DUMMY) $(SINGLESOCKET) -D__NO_LZ4_WARN__ -DUSE_LZ4 -DUSE_PMURHASH=1 -DLETO_NO_MT=1 86 | CAPIFLAGS = $(CLIBFLAGS) $(LZ4_DUMMY) $(SINGLESOCKET) -D__NO_LZ4_WARN__ -DUSE_LZ4 -DUSE_PMURHASH=1 -D__LETO_C_API__=1 -DLETO_NO_MT=1 87 | 88 | CC_CMD = $(CC) $(CLIBFLAGS) -o$@ $** 89 | CC_API = $(CC) $(CAPIFLAGS) -o$@ $** 90 | CC_LZ4 = $(CC) $(CLIBFLAGS) -o$@ $** 91 | HB_CMD = $(HRB_EXE) $(HARBOURFLAGS) $** -o$@ 92 | 93 | # 94 | # Macros to access our library names 95 | # 96 | 97 | CLIENT_RDD_LIB = $(LETO_LIB_DIR)\rddleto.lib 98 | CLIENT_LIB = $(LETO_LIB_DIR)\leto.lib 99 | 100 | # 101 | # RDDLETO.LIB rules 102 | # 103 | 104 | CLIENT_RDD_LIB_OBJS = \ 105 | $(OBJ_DIR)\letocl.obj \ 106 | $(OBJ_DIR)\leto1.obj \ 107 | $(OBJ_DIR)\letomgmn.obj \ 108 | $(OBJ_DIR)\common_c.obj \ 109 | $(OBJ_DIR)\blowfish.obj \ 110 | $(OBJ_DIR)\PMurHash.obj \ 111 | $(OBJ_DIR)\rddsys.obj \ 112 | $(OBJ_DIR)\lz4net.obj 113 | 114 | !if ! $d(USE_LZ4_DUMMY) 115 | CLIENT_RDD_LIB_OBJS = $(CLIENT_RDD_LIB_OBJS) \ 116 | $(OBJ_DIR)\lz4.obj 117 | !endif 118 | 119 | !if $d(__BM) 120 | CLIENT_RDD_LIB_OBJS = $(CLIENT_RDD_LIB_OBJS) \ 121 | $(OBJ_DIR)\letobmcl.obj 122 | !endif 123 | 124 | # 125 | # LETO.LIB rules 126 | # 127 | 128 | CLIENT_LIB_OBJS = \ 129 | $(API_DIR)\letocl.obj \ 130 | $(API_DIR)\common_c.obj \ 131 | $(API_DIR)\blowfish.obj \ 132 | $(API_DIR)\PMurHash.obj \ 133 | $(API_DIR)\lz4net.obj 134 | 135 | !if ! $d(USE_LZ4_DUMMY) 136 | CLIENT_LIB_OBJS = $(CLIENT_LIB_OBJS) \ 137 | $(API_DIR)\lz4.obj 138 | !endif 139 | 140 | # 141 | # Our default target 142 | # 143 | 144 | PROJECT = \ 145 | $(CLIENT_RDD_LIB) \ 146 | $(CLIENT_LIB) 147 | 148 | rdd: $(CLIENT_RDD_LIB) 149 | api: $(CLIENT_LIB) 150 | all: $(PROJECT) 151 | 152 | # 153 | # Library dependencies and build rules 154 | # 155 | 156 | $(CLIENT_RDD_LIB) : $(CLIENT_RDD_LIB_OBJS) 157 | IF EXIST "$(CLIENT_RDD_LIB)" $(DEL) "$(CLIENT_RDD_LIB)" > NUL 158 | $(LINKER) "$(CLIENT_RDD_LIB)" $(ARFLAGS) @&&! 159 | +$(**: = &^ 160 | +) 161 | 162 | ! 163 | 164 | $(CLIENT_LIB) : $(CLIENT_LIB_OBJS) 165 | IF EXIST "$(CLIENT_LIB)" $(DEL) "$(CLIENT_LIB)" > NUL 166 | $(LINKER) "$(CLIENT_LIB)" $(ARFLAGS) @&&! 167 | +$(**: = &^ 168 | +) 169 | 170 | ! 171 | 172 | # --------------------------- 173 | # CLIENT_RDD.LIB Dependencies 174 | # --------------------------- 175 | 176 | {$(CLIENT_DIR)}.prg{$(OBJ_DIR)}.c: 177 | $(HB_CMD) 178 | 179 | .c.obj: 180 | $(CC_CMD) 181 | 182 | {$(CLIENT_DIR)}.c{$(OBJ_DIR)}.obj: 183 | $(CC_CMD) 184 | 185 | {$(COMMON_DIR)}.c{$(OBJ_DIR)}.obj: 186 | $(CC_CMD) 187 | 188 | {$(LZ4_DIR)}.c{$(OBJ_DIR)}.obj: 189 | $(CC_LZ4) 190 | 191 | # --------------------------- 192 | # CLIENT.LIB Dependencies 193 | # --------------------------- 194 | 195 | .c.obj: 196 | $(CC_API) 197 | 198 | {$(CLIENT_DIR)}.c{$(API_DIR)}.obj: 199 | IF EXIST "$@" $(DEL) $@ 200 | $(CC_API) 201 | 202 | {$(COMMON_DIR)}.c{$(API_DIR)}.obj: 203 | IF EXIST "$@" $(DEL) $@ 204 | $(CC_API) 205 | 206 | {$(LZ4_DIR)}.c{$(API_DIR)}.obj: 207 | IF EXIST "$@" $(DEL) $@ 208 | $(CC_LZ4) 209 | 210 | -------------------------------------------------------------------------------- /source/3rd/lz4/lib/Makefile: -------------------------------------------------------------------------------- 1 | # ################################################################ 2 | # LZ4 library - Makefile 3 | # Copyright (C) Yann Collet 2011-2015 4 | # All rights reserved. 5 | # 6 | # BSD license 7 | # Redistribution and use in source and binary forms, with or without modification, 8 | # are permitted provided that the following conditions are met: 9 | # 10 | # * Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # * Redistributions in binary form must reproduce the above copyright notice, this 14 | # list of conditions and the following disclaimer in the documentation and/or 15 | # other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | # You can contact the author at : 29 | # - LZ4 source repository : https://github.com/Cyan4973/lz4 30 | # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c 31 | # ################################################################ 32 | 33 | # Version numbers 34 | VERSION ?= 129 35 | LIBVER_MAJOR=`sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h` 36 | LIBVER_MINOR=`sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h` 37 | LIBVER_PATCH=`sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h` 38 | LIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH) 39 | 40 | DESTDIR?= 41 | PREFIX ?= /usr/local 42 | CFLAGS ?= -O3 43 | CFLAGS += -I. -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes -pedantic -DXXH_NAMESPACE=LZ4_ 44 | 45 | LIBDIR?= $(PREFIX)/lib 46 | INCLUDEDIR=$(PREFIX)/include 47 | 48 | 49 | # OS X linker doesn't support -soname, and use different extension 50 | # see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html 51 | ifeq ($(shell uname), Darwin) 52 | SHARED_EXT = dylib 53 | SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT) 54 | SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT) 55 | SONAME_FLAGS = -install_name $(PREFIX)/lib/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) 56 | else 57 | SONAME_FLAGS = -Wl,-soname=liblz4.$(SHARED_EXT).$(LIBVER_MAJOR) 58 | SHARED_EXT = so 59 | SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR) 60 | SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER) 61 | endif 62 | 63 | default: liblz4 64 | 65 | all: liblz4 66 | 67 | liblz4: lz4.c lz4hc.c lz4frame.c xxhash.c 68 | @echo compiling static library 69 | @$(CC) $(CPPFLAGS) $(CFLAGS) -c $^ 70 | @$(AR) rcs liblz4.a lz4.o lz4hc.o lz4frame.o xxhash.o 71 | @echo compiling dynamic library $(LIBVER) 72 | @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared $^ -fPIC $(SONAME_FLAGS) -o $@.$(SHARED_EXT_VER) 73 | @echo creating versioned links 74 | @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT_MAJOR) 75 | @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT) 76 | 77 | clean: 78 | @rm -f core *.o *.a *.$(SHARED_EXT) *.$(SHARED_EXT).* liblz4.pc 79 | @echo Cleaning library completed 80 | 81 | 82 | #------------------------------------------------------------------------ 83 | #make install is validated only for Linux, OSX, kFreeBSD and Hurd targets 84 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU)) 85 | 86 | liblz4.pc: liblz4.pc.in Makefile 87 | @echo creating pkgconfig 88 | @sed -e 's|@PREFIX@|$(PREFIX)|' \ 89 | -e 's|@LIBDIR@|$(LIBDIR)|' \ 90 | -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \ 91 | -e 's|@VERSION@|$(VERSION)|' \ 92 | $< >$@ 93 | 94 | install: liblz4 liblz4.pc 95 | @install -d -m 755 $(DESTDIR)$(LIBDIR)/pkgconfig/ $(DESTDIR)$(INCLUDEDIR)/ 96 | @install -m 755 liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) 97 | @cp -a liblz4.$(SHARED_EXT_MAJOR) $(DESTDIR)$(LIBDIR) 98 | @cp -a liblz4.$(SHARED_EXT) $(DESTDIR)$(LIBDIR) 99 | @cp -a liblz4.pc $(DESTDIR)$(LIBDIR)/pkgconfig/ 100 | @install -m 644 liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a 101 | @install -m 644 lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h 102 | @install -m 644 lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h 103 | @install -m 644 lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h 104 | @echo lz4 static and shared library installed 105 | 106 | uninstall: 107 | @rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) 108 | @rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) 109 | @rm -f $(DESTDIR)$(LIBDIR)/pkgconfig/liblz4.pc 110 | @[ -x $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) 111 | @[ -f $(DESTDIR)$(LIBDIR)/liblz4.a ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.a 112 | @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4.h 113 | @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4hc.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4hc.h 114 | @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4frame.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4frame.h 115 | @echo lz4 libraries successfully uninstalled 116 | 117 | endif 118 | -------------------------------------------------------------------------------- /makefile.vc: -------------------------------------------------------------------------------- 1 | # $Id: makefile.vc,v 1.5.2.4 2013/12/13 16:40:26 alkresin Exp $ 2 | # makefile for Visual C++ 32 bits 3 | # Building of Leto binaries 4 | 5 | #.SUFFIXESS: .prg .lib .c .obj 6 | 7 | # uncomment this line if you want to build letodb with xharbour 8 | XHARBOUR = yes 9 | 10 | !ifndef HRB_DIR 11 | HRB_DIR = $(HB_PATH) 12 | !endif 13 | INC_DIR = include 14 | LZ4_DIR = source\3rd\lz4\lib 15 | OBJ_DIR = obj/vc 16 | API_DIR = obj/api 17 | LIB_DIR = lib 18 | BIN_DIR = bin 19 | INC_ALL_DIR = /I$(INC_DIR) /I$(HRB_DIR)/include /I$(LZ4_DIR) 20 | 21 | SERVER_DIR = source\server 22 | CLIENT_DIR = source\client 23 | COMMON_DIR = source\common 24 | 25 | CFLAGS = -Ot2b1 -EHs-c- -FD -Gs -W3 -nologo -D__WINDOWS__ -DWIN32 -D__WIN32__ -D_CRT_SECURE_NO_DEPRECATE -DUSE_PMURHASH=1 -DUSE_LZ4=1 26 | CAPIFLAGS = $(CFLAGS) -DUSE_LZ4=1 -D__LETO_C_API__=1 -DLETO_NO_MT=1 -DLETO_NO_THREAD=1 27 | 28 | #!if $d(XHARBOUR) 29 | #HARBOUR_LIBS = debug.lib vm.lib rtl.lib gtgui.lib lang.lib rdd.lib macro.lib pp.lib dbfntx.lib dbfcdx.lib dbffpt.lib hbsix.lib common.lib codepage.lib pcrepos.lib 30 | #!else 31 | HARBOUR_LIBS = hbdebug.lib hbvmmt.lib hbrtl.lib gtgui.lib hblang.lib hbrdd.lib hbmacro.lib hbpp.lib rddntx.lib rddcdx.lib rddfpt.lib hbsix.lib hbcommon.lib hbcpage.lib hbpcre.lib hbzlib.lib rddnsx.lib hbmemio.lib hbextern.lib hbhsx.lib 32 | #!endif 33 | 34 | WINDOWS_LIBS = user32.lib winspool.lib WSock32.lib WinMM.lib AdvApi32.lib IPHlpApi.lib Ws2_32.lib 35 | 36 | all: \ 37 | $(LIB_DIR)\leto.lib 38 | 39 | #!if $d(XHARBOUR) 40 | #full: \ 41 | # $(LIB_DIR)\rddleto.lib \ 42 | # $(LIB_DIR)\leto.lib 43 | #!else 44 | full: \ 45 | $(LIB_DIR)\rddleto.lib \ 46 | $(LIB_DIR)\leto.lib 47 | #!endif 48 | 49 | 50 | $(BIN_DIR)\letodb.exe : \ 51 | $(OBJ_DIR)\server.obj \ 52 | $(OBJ_DIR)\common.obj \ 53 | $(OBJ_DIR)\common_c.obj \ 54 | $(OBJ_DIR)\blowfish.obj \ 55 | $(OBJ_DIR)\lz4.obj \ 56 | $(OBJ_DIR)\lz4net.obj \ 57 | $(OBJ_DIR)\PMurHash.obj \ 58 | $(OBJ_DIR)\leto_2.obj \ 59 | $(OBJ_DIR)\letofunc.obj \ 60 | $(OBJ_DIR)\letolist.obj \ 61 | $(OBJ_DIR)\letoacc.obj \ 62 | $(OBJ_DIR)\letovars.obj \ 63 | $(OBJ_DIR)\leto_win.obj \ 64 | $(OBJ_DIR)\errint.obj \ 65 | $(OBJ_DIR)\errorsys.obj 66 | link /OUT:bin\letodb.exe -SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC /NODEFAULTLIB:LIBCP -LIBPATH:$(HRB_DIR)\lib\win\msvc $(HARBOUR_LIBS) $(WINDOWS_LIBS) $** 67 | 68 | $(OBJ_DIR)\server.obj : $(OBJ_DIR)\server.c 69 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 70 | 71 | $(OBJ_DIR)\common.obj : $(OBJ_DIR)\common.c 72 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 73 | 74 | $(OBJ_DIR)\errorsys.obj : $(OBJ_DIR)\errorsys.c 75 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 76 | 77 | $(OBJ_DIR)\common_c.obj : $(COMMON_DIR)\common_c.c 78 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 79 | 80 | $(OBJ_DIR)\blowfish.obj : $(COMMON_DIR)\blowfish.c 81 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 82 | 83 | $(OBJ_DIR)\PMurHash.obj : $(COMMON_DIR)\PMurHash.c 84 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 85 | 86 | $(OBJ_DIR)\lz4.obj : $(LZ4_DIR)\lz4.c 87 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 88 | 89 | $(OBJ_DIR)\lz4net.obj : $(COMMON_DIR)\lz4net.c 90 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 91 | 92 | $(OBJ_DIR)\leto_2.obj : $(SERVER_DIR)\leto_2.c 93 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 94 | 95 | $(OBJ_DIR)\letofunc.obj : $(SERVER_DIR)\letofunc.c 96 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 97 | 98 | $(OBJ_DIR)\letolist.obj : $(SERVER_DIR)\letolist.c 99 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 100 | 101 | $(OBJ_DIR)\letoacc.obj : $(SERVER_DIR)\letoacc.c 102 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 103 | 104 | $(OBJ_DIR)\letovars.obj : $(SERVER_DIR)\letovars.c 105 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 106 | 107 | $(OBJ_DIR)\leto_win.obj : $(SERVER_DIR)\leto_win.c 108 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 109 | 110 | $(OBJ_DIR)\server.c : $(SERVER_DIR)\server.prg 111 | $(HRB_DIR)\bin\harbour.exe $** -q -n -w -I$(HRB_DIR)\include -i$(INC_DIR) -i$(LZ4_DIR) -d__WIN_DAEMON__ -o$@ 112 | 113 | $(OBJ_DIR)\common.c : $(COMMON_DIR)\common.prg 114 | $(HRB_DIR)\bin\harbour.exe $** -q -n -w -I$(HRB_DIR)\include -i$(INC_DIR) -i$(LZ4_DIR) -d__WIN_DAEMON__ -o$@ 115 | 116 | $(OBJ_DIR)\errorsys.c : $(SERVER_DIR)\errorsys.prg 117 | $(HRB_DIR)\bin\harbour.exe $** -q -n -w $(INC_ALL_DIR) -o$@ 118 | 119 | 120 | $(LIB_DIR)\rddleto.lib : \ 121 | $(OBJ_DIR)\letocl.obj \ 122 | $(OBJ_DIR)\leto1.obj \ 123 | $(OBJ_DIR)\letomgmn.obj \ 124 | $(OBJ_DIR)\common_c.obj \ 125 | $(OBJ_DIR)\lz4.obj \ 126 | $(OBJ_DIR)\lz4net.obj \ 127 | $(OBJ_DIR)\PMurHash.obj \ 128 | $(OBJ_DIR)\blowfish.obj 129 | lib /out:$@ $** 130 | 131 | 132 | {$(SERVER_DIR)}.prg{$(OBJ_DIR)}.c: 133 | $(HRB_DIR)\bin\harbour.exe $** -n -w -i$(HRB_DIR)\include -i$(INC_DIR) -i$(LZ4_DIR) -d__WIN_DAEMON__ -o$@ 134 | 135 | {$(COMMON_DIR)}.prg{$(OBJ_DIR)}.c: 136 | $(HRB_DIR)\bin\harbour.exe $** -n -w -i$(HRB_DIR)\include -i$(INC_DIR) -i$(LZ4_DIR) -d__WIN_DAEMON__ -o$@ 137 | 138 | {$(SERVER_DIR)}.c{$(OBJ_DIR)}.obj: 139 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 140 | 141 | {$(COMMON_DIR)}.c{$(OBJ_DIR)}.obj: 142 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 143 | 144 | {$(CLIENT_DIR)}.c{$(OBJ_DIR)}.obj: 145 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 146 | 147 | {$(OBJ_DIR)}.c{$(OBJ_DIR)}.obj: 148 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 149 | 150 | .c.obj: 151 | cl $(CFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 152 | 153 | $(LIB_DIR)\leto.lib : \ 154 | $(API_DIR)\letocl.obj \ 155 | $(API_DIR)\common_c.obj \ 156 | $(API_DIR)\lz4.obj \ 157 | $(API_DIR)\lz4net.obj \ 158 | $(API_DIR)\PMurHash.obj \ 159 | $(API_DIR)\blowfish.obj 160 | lib /out:$@ $** 161 | 162 | 163 | 164 | {$(COMMON_DIR)}.c{$(API_DIR)}.obj: 165 | cl $(CAPIFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 166 | 167 | {$(CLIENT_DIR)}.c{$(API_DIR)}.obj: 168 | cl $(CAPIFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 169 | 170 | {$(LZ4_DIR)}.c{$(API_DIR)}.obj: 171 | cl $(CAPIFLAGS) /c $(INC_ALL_DIR) /Fo$@ $** 172 | 173 | -------------------------------------------------------------------------------- /source/server/errorsys.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * The default error handler 3 | * 4 | * Copyright 1999 Antonio Linares 5 | * 6 | * Copyright 2008 Alexander S. Kresin 7 | * updated for Leto db server 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2, or (at your option) 12 | * any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this software; see the file COPYING. If not, write to 21 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 22 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 23 | * 24 | * As a special exception, the Harbour Project gives permission for 25 | * additional uses of the text contained in its release of Harbour. 26 | * 27 | * The exception is that, if you link the Harbour libraries with other 28 | * files to produce an executable, this does not by itself cause the 29 | * resulting executable to be covered by the GNU General Public License. 30 | * Your use of that executable is in no way restricted on account of 31 | * linking the Harbour library code into it. 32 | * 33 | * This exception does not however invalidate any other reasons why 34 | * the executable file might be covered by the GNU General Public License. 35 | * 36 | * This exception applies only to the code released by the Harbour 37 | * Project under the name Harbour. If you copy code from other 38 | * Harbour Project or Free Software Foundation releases into a copy of 39 | * Harbour, as the General Public License permits, the exception does 40 | * not apply to the code that you add in this way. To avoid misleading 41 | * anyone as to the status of such modified files, you must delete 42 | * this exception notice from them. 43 | * 44 | * If you write modifications of your own for Harbour, it is your choice 45 | * whether to permit this exception to apply to your modifications. 46 | * If you do not wish that, delete this exception notice. 47 | * 48 | */ 49 | 50 | #include "common.ch" 51 | #include "error.ch" 52 | 53 | REQUEST WUsLog 54 | 55 | PROCEDURE ErrorSys 56 | 57 | ErrorBlock( {| oError | DefError( oError ) } ) 58 | 59 | RETURN 60 | 61 | STATIC FUNCTION DefError( oError ) 62 | 63 | LOCAL nFlags := 0 64 | 65 | // By default, division by zero results in zero 66 | IF ValType( oError ) == "O" .AND. oError:genCode == EG_ZERODIV .AND. oError:canSubstitute 67 | RETURN 0 68 | ENDIF 69 | 70 | // By default, retry on RDD lock error failure */ 71 | IF oError:genCode == EG_LOCK .AND. oError:canRetry 72 | // oError:tries++ 73 | RETURN .T. 74 | ENDIF 75 | 76 | // Set NetErr() of there was a database open error 77 | IF oError:genCode == EG_OPEN .AND. oError:osCode == 32 .AND. oError:canDefault 78 | NetErr( .T. ) 79 | RETURN .F. 80 | ENDIF 81 | 82 | // Set NetErr() if there was a lock error on dbAppend() 83 | IF oError:genCode == EG_APPENDLOCK .AND. oError:canDefault 84 | NetErr( .T. ) 85 | RETURN .F. 86 | ENDIF 87 | 88 | IF oError:canRetry 89 | nFlags += 1 /* EF_CANRETRY */ 90 | ENDIF 91 | IF oError:canSubstitute 92 | nFlags += 2 /* EF_CANSUBSTITUTE */ 93 | ENDIF 94 | IF oError:canDefault 95 | nFlags += 4 /* EF_CANDEFAULT */ 96 | ENDIF 97 | 98 | wUsLog( Leto_ErrorMessage( oError ) + iif( Empty( oError:osCode ), "", ; 99 | " (DOS Error " + LTrim( Str( oError:osCode ) ) + ")" ) ) 100 | 101 | Leto_SetHrbError( oError:genCode, oError:subCode, oError:osCode, nFlags, IIF( Empty( oError:filename ), .F., .T. ),; 102 | IIF( ! Empty( oError:filename ), oError:filename, oError:description + " " + oError:operation ) ) 103 | IF .T. 104 | Break( oError ) 105 | ENDIF 106 | 107 | RETURN .F. 108 | 109 | /* used for letodb.log */ 110 | FUNCTION Leto_ErrorMessage( oError ) 111 | 112 | LOCAL cMessage 113 | 114 | // start error message 115 | cMessage := iif( oError:severity > ES_WARNING, "Error", "Warning" ) + " " 116 | 117 | // add subsystem name if available 118 | cMessage += iif( ISCHARACTER( oError:subsystem ), oError:subsystem(), "???" ) 119 | 120 | // add subsystem's error code if available 121 | cMessage += iif( ISNUMBER( oError:subCode ), "/" + LTrim( Str( oError:subCode ) ), "/???" ) 122 | 123 | // add error description if available 124 | IF ISCHARACTER( oError:description ) 125 | cMessage += " " + oError:description 126 | ENDIF 127 | 128 | // add either filename or operation 129 | 130 | IF ! Empty( oError:filename ) 131 | cMessage += ": " + oError:filename 132 | ELSEIF ! Empty( oError:operation ) 133 | cMessage += ": " + oError:operation 134 | ENDIF 135 | 136 | IF ValType( oError:Args ) == "A" 137 | cMessage += ( hb_eol() + " Arguments: (" + Arguments( oError ) + ")" ) 138 | ENDIF 139 | 140 | RETURN cMessage 141 | 142 | STATIC FUNCTION Arguments( oErr ) 143 | 144 | LOCAL xArg, cArguments := "", i 145 | 146 | IF ValType( oErr:Args ) == "A" 147 | FOR i := 1 TO Len( oErr:Args ) 148 | xArg := oErr:Args[ i ] 149 | cArguments += " [" + Str( i, 2 ) + "] = Type: " + ValType( xArg ) 150 | IF xArg != NIL 151 | cArguments += " Val: " + hb_ValToStr( xArg ) 152 | ENDIF 153 | IF i < Len( oErr:Args ) 154 | cArguments += "," 155 | ENDIF 156 | NEXT 157 | ENDIF 158 | 159 | RETURN cArguments 160 | 161 | FUNCTION WUsLog( cText ) // user log 162 | 163 | leto_wUsLog( " " + cText + hb_eol() ) 164 | 165 | RETURN .T. 166 | 167 | FUNCTION WRLog( cText ) // server log 168 | 169 | leto_wRlog( " " + cText + hb_eol() ) 170 | 171 | RETURN .T. 172 | -------------------------------------------------------------------------------- /include/rddleto.ch: -------------------------------------------------------------------------------- 1 | /* 2 | * Header file for Leto RDD 3 | * 4 | * Copyright 2008 Alexander S. Kresin 5 | * 2017 Rolf 'elch' Beckmann ( additions ) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this software; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 21 | * 22 | * As a special exception, the Harbour Project gives permission for 23 | * additional uses of the text contained in its release of Harbour. 24 | * 25 | * The exception is that, if you link the Harbour libraries with other 26 | * files to produce an executable, this does not by itself cause the 27 | * resulting executable to be covered by the GNU General Public License. 28 | * Your use of that executable is in no way restricted on account of 29 | * linking the Harbour library code into it. 30 | * 31 | * This exception does not however invalidate any other reasons why 32 | * the executable file might be covered by the GNU General Public License. 33 | * 34 | * This exception applies only to the code released by the Harbour 35 | * Project under the name Harbour. If you copy code from other 36 | * Harbour Project or Free Software Foundation releases into a copy of 37 | * Harbour, as the General Public License permits, the exception does 38 | * not apply to the code that you add in this way. To avoid misleading 39 | * anyone as to the status of such modified files, you must delete 40 | * this exception notice from them. 41 | * 42 | * If you write modifications of your own for Harbour, it is your choice 43 | * whether to permit this exception to apply to your modifications. 44 | * If you do not wish that, delete this exception notice. 45 | * 46 | */ 47 | 48 | 49 | /* ! also used in C source ! */ 50 | 51 | #ifndef RDDLETO_CH_ 52 | #define RDDLETO_CH_ 53 | 54 | #include "dbinfo.ch" 55 | 56 | #ifndef LETO_DEFAULT_PORT 57 | #define LETO_DEFAULT_PORT 2812 58 | #endif 59 | 60 | /* login error conditions */ 61 | #define LETO_ERR_CONNECT 1 62 | #define LETO_ERR_LOGIN 2 63 | #define LETO_ERR_ACCESS 3 64 | #define LETO_ERR_RECV 4 65 | #define LETO_ERR_SEND 5 66 | #define LETO_ERR_MANY_CONN 6 67 | #define LETO_ERR_SOCKET 7 68 | #define LETO_ERR_PROTO 8 69 | #define LETO_ERR_LOCKED 9 70 | #define LETO_ERR_RESTORE 10 71 | 72 | #define LETO_DBF 73 | #define LETO_CDX 0 74 | #define LETO_NTX 1 75 | 76 | /* LETO_VAR*() flags */ 77 | #define LETO_VCREAT 1 78 | #define LETO_VOWN 2 79 | #define LETO_VDENYWR 4 80 | #define LETO_VDENYRD 8 81 | #define LETO_VPREVIOUS 16 82 | #define LETO_VNOCREAT 64 83 | 84 | /* C-level var types */ 85 | #define LETOVAR_LOG '1' 86 | #define LETOVAR_NUM '2' 87 | #define LETOVAR_STR '3' 88 | #define LETOVAR_ARR '4' 89 | #define LETOVAR_DAT '5' 90 | 91 | /* #define LETO_VPREFIX "S_" deprecate, use group name 'My' */ 92 | 93 | /* LetoDBf specific rddinfo() */ 94 | #define RDDI_REFRESHCOUNT 101 95 | #define RDDI_BUFKEYNO 102 96 | #define RDDI_BUFKEYCOUNT 103 97 | #define RDDI_VERSION 104 98 | #define RDDI_BUFREFRESHTIME 105 99 | #define RDDI_DEBUGLEVEL 110 100 | #define RDDI_LOCKTIMEOUT 111 101 | #define RDDI_CLEARBUFFER 112 102 | #define RDDI_DBEVALCOMPAT 113 103 | #define RDDI_DBEVALTIMEOUT 114 104 | 105 | #define DBI_BUFREFRESHTIME 1001 106 | #define DBI_CLEARBUFFER 1002 107 | #define DBI_DBS_COUNTER 1003 108 | #define DBI_DBS_STEP 1004 109 | #define DBI_AUTOREFRESH 1005 110 | #define DBI_CHILDPARENT 1006 111 | 112 | /* dbinfo.ch must be loaded beforehand */ 113 | /* not existing in harbour, 133 in xHb collides with DBOI_RESETPOS in harbour */ 114 | #ifdef DBOI_TEMPORARY 115 | #undef DBOI_TEMPORARY 116 | #endif 117 | #define DBOI_TEMPORARY 1001 118 | #define DBOI_INTERNAL 1002 119 | 120 | /* server config options */ 121 | #define LETOOPT_DATAPATH 1 // C 122 | #define LETOOPT_INDEXTYPE 2 // N 123 | #define LETOOPT_FILEFUNC 3 // L 124 | #define LETOOPT_ANYEXT 4 // L 125 | #define LETOOPT_PASS4L 5 // L 126 | #define LETOOPT_PASS4M 6 // L 127 | #define LETOOPT_PASS4D 7 // L 128 | #define LETOOPT_ACCPATH 8 // C 129 | #define LETOOPT_CRYPT 9 // L 130 | #define LETOOPT_SHARETABLES 10 // L 131 | #define LETOOPT_NOSAVEWA 11 // L 132 | #define LETOOPT_VARMAX 12 // N 133 | #define LETOOPT_VARLENMAX 13 // N 134 | #define LETOOPT_CACHERECORDS 14 // N 135 | #define LETOOPT_TABLEMAX 15 // N 136 | #define LETOOPT_USERMAX 16 // N 137 | #define LETOOPT_DEBUGLEVEL 17 // N 138 | #define LETOOPT_OPTIMIZE 18 // L 139 | #define LETOOPT_AUTOORDER 19 // N 140 | #define LETOOPT_MEMOTYPE 20 // N 141 | #define LETOOPT_FORCEOPT 21 // L 142 | #define LETOOPT_LOCKCHEME 22 // N 143 | #define LETOOPT_UDFENABLED 23 // L 144 | #define LETOOPT_MEMOSIZE 24 // N 145 | #define LETOOPT_LOWERPATH 25 // L 146 | #define LETOOPT_TRIGGER 26 // P 147 | #define LETOOPT_HARDCOMMIT 27 // L 148 | 149 | /* determine if compiler behave case sensitive */ 150 | #define CASESENSITIVE 151 | #ifdef CaseSensitive 152 | #undef CASESENSITIVE 153 | #endif 154 | 155 | /* redirect for 4 options handled in LETO_SET(), others forward to SET() */ 156 | #ifdef CASESENSITIVE 157 | #define set( _HB_SETTING, XSET ) LETO_SET( _HB_SETTING, XSET ) 158 | #define Set( _HB_SETTING, XSET ) LETO_SET( _HB_SETTING, XSET ) 159 | #endif 160 | #define SET( _HB_SETTING, XSET ) LETO_SET( _HB_SETTING, XSET ) 161 | 162 | #endif /* RDDLETO_CH_ */ 163 | -------------------------------------------------------------------------------- /tests/test_ta.prg: -------------------------------------------------------------------------------- 1 | REQUEST LETO 2 | REQUEST rddinfo 3 | 4 | #ifdef __XHARBOUR__ 5 | #define hb_milliseconds LETO_MILLISEC 6 | #endif 7 | 8 | Function Main( cPath ) 9 | LOCAL nRec 10 | LOCAL nTrans 11 | LOCAL lRet := .T. 12 | LOCAL nSec 13 | Field NORD, DORD, NPROD, SUMMA, NORM 14 | 15 | RDDSETDEFAULT( "LETO" ) 16 | 17 | ALTD() 18 | IF Empty( cPath ) 19 | cPath := "//127.0.0.1:2812/" 20 | ELSE 21 | cPath := "//" + cPath + IiF( ":" $ cPath, "", ":2812" ) 22 | cPath += Iif( Right(cPath,1) == "/", "", "/" ) 23 | ENDIF 24 | ? "Start" 25 | dbCreate( cPath + "nakl1", { {"NORD","N",10,0},{"DORD","D",8,0},{"SUMMA","N",12,2},{"NORM","M",10,0} } ) 26 | dbCreate( cPath + "nakl2", { {"NORD","N",10,0},{"DORD","D",8,0},{"NPROD","N",3,0},{"SUMMA","N",12,2},{"NORM","M",10,0} } ) 27 | ? "Files has been created" 28 | 29 | use ( cPath+"nakl1" ) Shared New 30 | index on Dtos(DORD)+Str(NORD,10,0) TAG DATA 31 | use ( cPath+"nakl2" ) Shared New 32 | index on Dtos(DORD)+Str(NORD,10,0)+Str(NPROD,3,0) TAG DATA 33 | ? "Files has been opened and indexed" 34 | 35 | // ? " compressed network traffic ", Leto_ToggleZip( 1 ) 36 | 37 | ? "processing 500 transactions, 250 intentional rollbacks" 38 | ? "" 39 | nSec := hb_milliseconds() 40 | FOR nTrans := 1 TO 250 41 | nRec := AddNakl( nTrans, Date(), { 1400.5, 28632.28, 800.51 } ) /* 30833.29 */ 42 | IF ! ChkNakl( nRec, nTrans, Date(), { 1400.5, 28632.28, 800.51 } ) 43 | ? "internal Transaction problem " 44 | lRet := .F. 45 | ENDIF 46 | 47 | //? "Records has been added" 48 | ?? "+" 49 | 50 | select NAKL2 51 | if dbSeek( Dtos(Date())+Str(nTrans,10)+Str(2,3) ) 52 | if ChangeNakl( 35688.24 ) 53 | //? "Records has been changed" 54 | ?? "+" 55 | else 56 | ? "Failure - Rollback" 57 | lRet := .F. 58 | endif 59 | 60 | if NoChangeNakl( 35688.24 ) 61 | //? "Rollback successfull" 62 | ?? "-" 63 | else 64 | ? "Failure in Rollback" 65 | lRet := .F. 66 | endif 67 | endif 68 | IF ! lRet 69 | EXIT 70 | ENDIF 71 | NEXT nTrans 72 | 73 | ? "Done", STR( ( hb_milliseconds() - nSec ) / 1000, 7, 2 ), "s" 74 | ? 75 | 76 | DbCloseAll() 77 | WAIT 78 | 79 | IF hb_dbdrop(cPath+"nakl1") .AND. hb_dbdrop(cPath+"nakl2") 80 | ? "files have been successful dropped" 81 | ELSE 82 | ? "Failure: files are NOT dropped" 83 | WAIT 84 | ENDIF 85 | 86 | Return Nil 87 | 88 | Function AddNakl( n_ord, d_ord, aSumm ) 89 | Local i, sumAll := 0.00 90 | Local nRec := 0 91 | Field NORD, DORD, SUMMA, NORM 92 | 93 | leto_BeginTransaction() 94 | 95 | select NAKL2 96 | 97 | for i := 1 to Len( aSumm ) 98 | append blank 99 | replace NORD with n_ord, DORD with d_ord, NPROD with i, SUMMA with aSumm[i],; 100 | NORM with "elk-mtest" + STR( n_ord, 10, 0 ) 101 | sumAll += aSumm[i] 102 | nRec++ 103 | next 104 | 105 | select NAKL1 106 | append blank 107 | replace NORD with n_ord, DORD with d_ord, SUMMA with sumAll, NORM with "elk-test" + STR( n_ord, 10, 0 ) 108 | 109 | leto_CommitTransaction() 110 | 111 | Return nRec 112 | 113 | 114 | Function ChkNakl( nRec, n_ord, d_ord, aSumm ) 115 | Local i, sumAll := 0.00 116 | Local lRet 117 | Field NORD, DORD, SUMMA, NORM 118 | 119 | select NAKL2 120 | lRet := DbSeek( Dtos(DORD)+Str(NORD,10,0)+Str(1,3,0), .T. ) 121 | IF lRet 122 | for i := 1 to nRec 123 | IF DoRlock( 3 ) 124 | IF NORD != n_ord .OR. DORD != d_ord .OR. SUMMA != aSumm[ i ] .OR. NORM != "elk-mtest" + STR( n_ord, 10 ,0 ) 125 | lRet := .F. 126 | ENDIF 127 | DBUNLOCK() 128 | ENDIF 129 | sumAll += aSumm[i] 130 | DbSkip(1) 131 | next 132 | ENDIF 133 | 134 | IF lRet 135 | select NAKL1 136 | lRet := DbSeek( Dtos(DORD)+Str(NORD,10,0) ) 137 | IF lRet 138 | IF NORD != n_ord .OR. DORD != d_ord .OR. SUMMA != ROUND( sumAll, 2 ) .OR. NORM != "elk-test" + STR( n_ord, 10, 0 ) 139 | lRet := .F. 140 | ENDIF 141 | ENDIF 142 | ENDIF 143 | 144 | Return lRet 145 | 146 | 147 | Function ChangeNakl( nSummNew ) 148 | Local nDelta 149 | Local lRet := .T. 150 | Field NORD, DORD, NPROD, SUMMA, NORM 151 | 152 | leto_BeginTransaction( .T. ) 153 | 154 | select NAKL1 155 | IF ! dbSeek( Dtos( NAKL2->DORD ) + STR( NAKL2->NORD, 10, 0 ) ) .OR. ! DoRlock( 3 ) 156 | leto_Rollback(.F.) 157 | Return .F. 158 | ENDIF 159 | 160 | select NAKL2 161 | /* test file lock, should keep set after commit */ 162 | IF DoFlock( 3 ) 163 | nDelta := nSummNew - SUMMA 164 | replace SUMMA with nSummNew, NORM with "elch tested" 165 | ELSE 166 | leto_Rollback() 167 | Return .F. 168 | ENDIF 169 | 170 | select NAKL1 171 | nSummNew := SUMMA 172 | replace SUMMA with SUMMA + nDelta, NORM with "elch tested" 173 | 174 | leto_CommitTransaction( .F. ) 175 | 176 | IF SUMMA != nSummNew + nDelta .OR. NORM != "elch tested" 177 | lRet := .F. 178 | ENDIF 179 | 180 | /* check existent file lock, will crash if not */ 181 | select NAKL2 182 | replace NORM with "elch tested filelock" 183 | DBUNLOCK() 184 | 185 | Return lRet 186 | 187 | 188 | Function NoChangeNakl( nSummNew ) 189 | Local nDelta 190 | Local lRet := .T. 191 | Local nTmp 192 | Field NORD, DORD, NPROD, SUMMA, NORM 193 | 194 | leto_BeginTransaction() 195 | 196 | select NAKL1 197 | if !dbSeek( Dtos(NAKL2->DORD)+STR(NAKL2->NORD,10,0) ) .or. !DoRlock( 3 ) 198 | leto_Rollback(.F.) 199 | Return .F. 200 | endif 201 | 202 | select NAKL2 203 | if DoRlock( 3 ) 204 | nTmp := SUMMA 205 | nDelta := nSummNew - SUMMA 206 | replace SUMMA with nSummNew, NORM with "no_elch" 207 | endif 208 | 209 | select NAKL1 210 | replace SUMMA with SUMMA + nDelta, NORM with "no_elch" 211 | 212 | leto_Rollback() 213 | 214 | select NAKL2 215 | IF DoRlock( 3 ) 216 | if SUMMA != ROUND( nTmp, 2 ) .OR. NORM != "elch tested" 217 | lRet := .F. 218 | endif 219 | DbUnlock() 220 | ENDIF 221 | 222 | Return lRet 223 | 224 | 225 | Function DoRLock( n ) 226 | Local i := 0 227 | 228 | do while i < n 229 | if Rlock() 230 | exit 231 | endif 232 | Inkey( 0.1 ) 233 | i ++ 234 | enddo 235 | 236 | Return ( i < n ) 237 | 238 | Function DoFLock( n ) 239 | Local i := 0 240 | 241 | do while i < n 242 | if Flock() 243 | exit 244 | endif 245 | Inkey( 0.1 ) 246 | i ++ 247 | enddo 248 | 249 | Return ( i < n ) 250 | 251 | -------------------------------------------------------------------------------- /utils/uhura/detect.prg: -------------------------------------------------------------------------------- 1 | #include "hbsocket.ch" 2 | /* 3 | * 4221 == free port 4 | * http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml 5 | */ 6 | #define UDP_PORT 4221 7 | 8 | REQUEST LETO 9 | 10 | /* by using 'letodb.hbc', example: hbmk2 basic.prg letodb.hbc 11 | * this will automatic include rdddleto.ch */ 12 | #include "rddleto.ch" 13 | 14 | PROCEDURE main( cAddress ) /* pure IP-address */ 15 | ALTD() 16 | IF Empty( cAddress ) 17 | cAddress := detectServer( "letodb" ) 18 | cAddress := "//" + cAddress + ":2812/" 19 | ELSE 20 | cAddress := "//" + cAddress + IIF( ":" $ cAddress, "", ":2812" ) 21 | cAddress += IIF( Right( cAddress, 1 ) == "/", "", "/" ) 22 | ENDIF 23 | 24 | IF leto_Connect( cAddress ) < 0 25 | ALERT( "NO LETODB SERVER FOUND - ERROR: " + leto_Connect_Err( .T. ) ) 26 | QUIT 27 | ELSE 28 | // RDDSETDEFAULT( "LETO" ) /* is automatic set by: REQUEST LETO */ 29 | // LETO_DBDRIVER( "DBFCDX" ) /* to choose your DBF driver independent of the server default */ 30 | LETO_TOGGLEZIP( 1 ) /* for compressed traffic */ 31 | ENDIF 32 | 33 | // DbUseArea( .T., /* LETO */, "test", "TEST", .T. ) 34 | // ... 35 | 36 | /* no special logout needed, all is automically done */ 37 | RETURN 38 | 39 | 40 | */ --- helper functions --- */ 41 | 42 | /* nNrOfPossible: optional, if a service is available at multiple interface/ server, take the n-th' */ 43 | FUNC detectServer( cService, nNrOfPossible ) 44 | LOCAL cIP := "", aIP 45 | LOCAL cBroadcastIP 46 | LOCAL nIFace 47 | LOCAL aIFace := hb_socketGetIFaces( HB_SOCKET_AF_INET, .T. ) 48 | LOCAL aBroadCasted := {} 49 | LOCAL nFound := 0 50 | 51 | hb_default( @nNrOfPossible, 1 ) 52 | 53 | IF VALTYPE( aIFace ) == "A" .AND. LEN( aIFace ) > 0 54 | nIFace := 1 55 | DO WHILE nIFACE <= LEN( aIFace ) 56 | /* outcomment last two conditions to use also interfaces without MAC address (e.g. loopback ) */ 57 | IF ! EMPTY( aIFace[ nIFace, HB_SOCKET_IFINFO_ADDR ] ) .AND.; 58 | ! EMPTY( aIFace[ nIFace, HB_SOCKET_IFINFO_NETMASK ] ) .AND.; 59 | ! EMPTY( aIFace[ nIFace, HB_SOCKET_IFINFO_HWADDR ] ) .AND.; 60 | ! aIFace[ nIFace, HB_SOCKET_IFINFO_HWADDR ] == "00:00:00:00:00:00" 61 | 62 | cBroadcastIP := broadcastIP( aIFace[ nIFace, HB_SOCKET_IFINFO_ADDR ],; 63 | aIFace[ nIFace, HB_SOCKET_IFINFO_NETMASK ] ) 64 | /* broadcast a identical subnet only one time */ 65 | IF ASCAN( aBroadCasted, cBroadcastIP ) < 1 66 | AADD( aBroadcasted, cBroadcastIP ) 67 | aIP := hb_udpds_Request( UDP_PORT, cService, cBroadcastIP, nNrOfPossible < 2 ) 68 | IF LEN( aIP ) + nFound >= nNrOfPossible 69 | cIP := aIP[ nNrOfPossible - nFound ] 70 | EXIT 71 | ELSE 72 | nFound += LEN( aIP ) 73 | ENDIF 74 | ENDIF 75 | 76 | ENDIF 77 | nIFace++ 78 | ENDDO 79 | ENDIF 80 | RETURN cIP 81 | 82 | 83 | /* translate address with netmask to a valid broadcast IP4: broadcast = ip | ( ~ netmask ) */ 84 | FUNC broadcastIP( cAddr, cNetm ) 85 | LOCAL cBroadcast := "" 86 | LOCAL nEndAddr, nEndNetm 87 | LOCAL nTuple := 1 88 | 89 | DO WHILE nTuple <= 4 90 | nEndAddr := AT( ".", cAddr ) 91 | nEndNetm := AT( ".", cNetm ) 92 | cBroadcast += hb_ntos( hb_bitOr( VAL( SUBSTR( cAddr, 1, nEndAddr - 1 ) ),; 93 | hb_bitAnd( hb_bitNot( VAL( SUBSTR( cNetm, 1, nEndNetm - 1 ) ) ), 255 ) ) ) 94 | IF nTuple < 4 95 | cBroadcast += "." 96 | cAddr := SUBSTR( cAddr, nEndAddr + 1 ) 97 | cNetm := SUBSTR( cNetm, nEndNetm + 1 ) 98 | ENDIF 99 | 100 | nTuple++ 101 | ENDDO 102 | RETU cBroadcast 103 | 104 | 105 | /* validate IP: only digits, at least one digit between/ after dots, and 3 dots */ 106 | FUNCTION isValidIP4( cAddr ) 107 | LOCAL nDot := 0 108 | LOCAL nNum := 0 109 | LOCAL cNUm := "" 110 | LOCAL nLen, cTmp, lValid 111 | 112 | IF ! EMPTY( cAddr ) 113 | nLen := LEN( cAddr ) 114 | lValid := .T. 115 | ELSE 116 | nLen := 0 117 | lValid := .F. 118 | ENDIF 119 | 120 | DO WHILE nLen > 0 121 | cTmp := LEFT( cAddr, 1 ) 122 | IF ! cTmp $ "0123456789." 123 | lValid := .F. 124 | EXIT 125 | ENDIF 126 | IF cTmp == "." 127 | /* no digit between dots ? -or- value too big ? */ 128 | IF nNum == 0 .OR. VAL( cNum ) > 255 129 | lValid := .F. 130 | EXIT 131 | ENDIF 132 | nDot++ 133 | nNum := 0 134 | cNum := "" 135 | ELSE 136 | cNum += cTmp 137 | nNum++ 138 | ENDIF 139 | cAddr := SUBSTR( cAddr, 2 ) 140 | nLen-- 141 | ENDDO 142 | 143 | IF lValid .AND. ( nDot != 3 .OR. nNum == 0 .OR. VAL( cNum ) > 255 ) 144 | lValid := .F. 145 | ENDIF 146 | 147 | RETURN lValid 148 | 149 | 150 | /* send the broadcast packet and analyse possible answer to catch IP */ 151 | FUNCTION hb_udpds_Request( nPort, cService, cBroadcastIP, lOnlyFirstAnswer ) 152 | LOCAL hSocket, cBuffer, nLen, aAddr 153 | LOCAL cFoundIP// := "" 154 | LOCAL aFoundIP := {} 155 | 156 | hb_default( @lOnlyFirstAnswer, .T. ) 157 | 158 | IF ! Empty( hSocket := hb_socketOpen( HB_SOCKET_AF_INET, HB_SOCKET_PT_DGRAM ) ) 159 | hb_socketSetBroadcast( hSocket, .T. ) 160 | cService := hb_StrToUTF8( cService ) 161 | IF hb_socketSendTo( hSocket, hb_BChar( 5 ) + cService + hb_BChar( 0 ), , , { HB_SOCKET_AF_INET, cBroadcastIP, nPort } ) == hb_BLen( cService ) + 2 162 | cBuffer := Space( 2000 ) 163 | DO WHILE .T. 164 | nLen := hb_socketRecvFrom( hSocket, @cBuffer, , , @aAddr, 100 ) /* timeout 0.1 s enough ? */ 165 | IF nLen > 0 166 | IF hb_BLeft( cBuffer, hb_BLen( cService ) + 2 ) == hb_BChar( 6 ) + cService + hb_BChar( 0 ) 167 | /* an IP given in content ? --> if a valid IP4, prefer that ! */ 168 | IF nLen >= hb_BLen( cService ) + 2 + 7 /* cService + 2 + min: "1.1.1.1" */ 169 | cFoundIP := hb_BSubStr( cBuffer, hb_BLen( cService ) + 3, nLen - hb_BLen( cService ) - 2 ) 170 | IF ! isvalidIP4( cFoundIP ) 171 | cFoundIP := aAddr[ 2 ] 172 | ENDIF 173 | AADD( aFoundIP, cFoundIP ) 174 | IF lOnlyFirstAnswer 175 | EXIT 176 | ENDIF 177 | ELSE 178 | AADD( aFoundIP, aAddr[ 2 ] ) 179 | IF lOnlyFirstAnswer 180 | EXIT 181 | ENDIF 182 | ENDIF 183 | ENDIF 184 | ELSE 185 | EXIT 186 | ENDIF 187 | ENDDO 188 | ENDIF 189 | hb_socketClose( hSocket ) 190 | ENDIF 191 | 192 | RETURN aFoundIP -------------------------------------------------------------------------------- /tests/ron.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * This sample tests working with a dbf file in many threads as you have CPU cores 3 | * Just change the cPath value to that one you need. 4 | */ 5 | 6 | REQUEST LETO 7 | REQUEST DBFCDX 8 | 9 | /* outcomment to let slower running demo log into a file */ 10 | //#define LOG_IN_TXT_FILE yes 11 | 12 | PROCEDURE Main( cPath ) 13 | 14 | LOCAL aNames := { "Petr", "Ivan", "Alexander", "Pavel", "Alexey", "Fedor", ; 15 | "Konstantin", "Vladimir", "Nikolay", "Andrey", "Dmitry", "Sergey" } 16 | LOCAL i, aStru // ,lUseLeto:=.f. 17 | LOCAL nHandle, ncounter 18 | LOCAL tStamp 19 | LOCAL nSrvMode 20 | FIELD NAME, NUM, INFO, DINFO, STAMP 21 | 22 | AltD() 23 | SET DATE FORMAT "yyyy.mm.dd" 24 | 25 | IF ValType( cPath ) == "C" 26 | rddSetDefault( "LETO" ) 27 | cPath := "//" + cPath + iif( ":" $ cPath, "", ":2812" ) 28 | cPath += iif( Right( cPath, 1 ) $ "/\", "", "/" ) 29 | ELSE 30 | rddSetDefault( "DBFCDX" ) 31 | cPath := "" 32 | ENDIF 33 | 34 | IF rddSetDefault() == "LETO" 35 | IF leto_Connect( cPath, "anonymous", "anonymous", 42000 /*timeout*/, /*hot buffer*/ ) == -1 36 | RETURN 37 | ENDIF 38 | LETO_DBDRIVER( "DBFCDX", "SMT", 1024 ) 39 | nSrvMode := LETO_GETSERVERMODE() 40 | ELSE 41 | nSrvMode := 5 42 | ENDIF 43 | 44 | dbCreate( cPath + "test1", { { "NAME", "C", 10, 0 }, { "NUM", "N", 4, 0 }, { "INFO", "C", 32, 0 }, { "DINFO", "D", 8, 0 }, { "STAMP", "@", 8, 0 } } ) 45 | SetColor( "w+/b" ) 46 | CLS 47 | nHandle := FCreate( "testmt.log", 0 ) 48 | FClose( nHandle ) 49 | nHandle := FOpen( "testmt.log", 33 ) 50 | IF nHandle > 0 51 | hb_DispOutAt( 1, 0, "File has been created" ) 52 | ENDIF 53 | dbSelectArea( 1 ) 54 | dbUseArea( .T., , cPath + "test1", , .T. ) 55 | hb_DispOutAt( 2, 0, "File has been opened" ) 56 | aStru := dbStruct() 57 | hb_DispOutAt( 3, 0, "Fields: " ) 58 | FOR i := 1 TO Len( aStru ) 59 | hb_DispOutAt( i + 3, 0, Str( i, 2 ) + " " + aStru[ i, 1 ] ) 60 | hb_DispOutAt( i + 3, 20, aStru[ i, 2 ] + " " + Str( aStru[ i, 3 ], 3 ) + Str( aStru[ i, 4 ], 4 ) ) 61 | NEXT 62 | 63 | FOR i := 1 TO Len( aNames ) 64 | IF i == 5 65 | hb_idleSleep( 0.1 ) 66 | ENDIF 67 | IF DbAppend() 68 | REPLACE NAME WITH aNames[ i ], NUM WITH i + 1000, ; 69 | INFO WITH "This is a record number " + LTrim( Str( i ) ), ; 70 | DINFO WITH Date() + i - 1, ; 71 | STAMP WITH hb_DateTime() 72 | ENDIF 73 | NEXT 74 | dbUnlock() 75 | 76 | hb_DispOutAt( 10, 0, hb_nToS( RecCount() ) + " Records have been added" ) 77 | INDEX ON NAME TAG NAME 78 | INDEX ON Stamp TAG STAMP 79 | INDEX ON Str( NUM, 4 ) TAG NUM 80 | hb_DispOutAt( 10, 30, ", File has been indexed" ) 81 | IF nSrvMode >= 2 // share tables or No_Save_WA = 1 82 | IF dbUseArea( .T., , cPath + "test1", "TESTY", .T. ) 83 | hb_DispOutAt( 11, 0, "DBF opend second time with different ALIAS " + Alias() ) 84 | ENDIF 85 | ENDIF 86 | ordSetFocus( 2 ) 87 | dbGoto( 5 ) 88 | tStamp := STAMP 89 | dbGoTop() 90 | dbSeek( tStamp, .T. ) 91 | IF RecNo() == 5 92 | hb_DispOutAt( 12, 0, "Timestamp seek successfull" ) 93 | ENDIF 94 | ordSetFocus( 3 ) 95 | ordScope( 1, "1001" ) 96 | ordSetFocus( 1 ) 97 | dbGoTop() 98 | nCounter := 1 99 | hb_DispOutAt( 13, 0, "Main thread running..." ) 100 | DO WHILE LastKey() != 27 101 | hb_DispOutAt( 14, 0, name ) 102 | testlog( nHandle, "Main thread at record " + AllTrim( Str( RecNo(), 4 ) ) ) 103 | dbSkip() 104 | IF Eof() 105 | testlog( nHandle, "Main thread calling dbgoTop()" ) 106 | dbGoTop() 107 | IF nSrvMode >= 2 // share tables or No_Save_WA = 1 108 | IF Alias() == "TEST1" 109 | dbSelectArea( "TESTY" ) 110 | ELSE 111 | dbSelectArea( "TEST1" ) 112 | ENDIF 113 | testlog( nHandle, "Primary thread changed to area " + Alias() ) 114 | ENDIF 115 | ENDIF 116 | #ifdef LOG_IN_TXT_FILE 117 | Inkey( 0.01 ) 118 | #else 119 | IF NextKey() != 0 120 | Inkey( 0.01 ) 121 | ENDIF 122 | #endif 123 | nCounter++ 124 | IF nCounter <= IIF( Leto_CPUCores() < 2, 1, Leto_CPUCores() - 1 ) * 10 .AND. nCounter % 10 == 0 125 | hb_threadStart( @thFunc(), cPath, nHandle, Int( nCounter / 10 ) + 1 ) 126 | ENDIF 127 | ENDDO 128 | FClose( nHandle ) 129 | SET COLOR TO "w/n" 130 | 131 | WAIT 132 | CLS 133 | dbCloseAll() 134 | dbDrop( cPath + "test1" ) 135 | QUIT 136 | 137 | RETURN 138 | 139 | 140 | PROC thFunc( cPath, nHandle, nCounter ) 141 | 142 | LOCAL nSrvMode, cThreadName 143 | 144 | IF nCounter == 2 145 | cThreadName := "Secondary" 146 | ELSE 147 | cThreadName := hb_ntos( nCounter ) + iif( nCounter < 4, "rd", "th" ) 148 | ENDIF 149 | 150 | hb_DispOutAt( 13 + ( nCounter * 2 ), 0, cThreadName + " thread starting..." ) 151 | IF rddSetDefault() == "LETO" 152 | IF leto_Connect( cPath, cThreadName, "anonymous", 42000 /*timeout*/, /*hot buffer*/ ) == -1 153 | RETURN 154 | ENDIF 155 | LETO_DBDRIVER( "DBFCDX", "SMT", 1024 ) 156 | nSrvMode := LETO_GETSERVERMODE() 157 | ELSE 158 | nSrvMode := 5 159 | ENDIF 160 | 161 | testlog( nHandle, "CurrentConnectio: " + LETO_GETCURRENTCONNECTION() ) 162 | dbUseArea( .T., , cPath + "test1", "TEST1", .T. ) 163 | IF nSrvMode >= 2 // share tables or No_Save_WA = 1 164 | dbUseArea( .T., , cPath + "test1", "TESTX", .T. ) 165 | ENDIF 166 | DO WHILE LastKey() != 27 167 | hb_DispOutAt( 14 + ( nCounter * 2 ), 0, field->name ) 168 | testlog( nHandle, "Secondary thread at record " + AllTrim( Str( RecNo(), 4 ) ) ) 169 | dbSkip( -1 ) 170 | IF Bof() 171 | testlog( nHandle, cThreadName + " thread calling dbGoBottom" ) 172 | dbGoBottom() 173 | IF nSrvMode >= 2 // share tables or No_Save_WA = 1 174 | IF Alias() == "TEST1" 175 | dbSelectArea( "TESTX" ) 176 | ELSE 177 | dbSelectArea( "TEST1" ) 178 | ENDIF 179 | testlog( nHandle, cThreadName + " thread changed to area " + Alias() ) 180 | ENDIF 181 | ENDIF 182 | #ifdef LOG_IN_TXT_FILE 183 | Inkey( 0.01 ) 184 | #else 185 | IF NextKey() != 0 186 | Inkey( 0.01 ) 187 | ENDIF 188 | #endif 189 | ENDDO 190 | 191 | RETURN 192 | 193 | 194 | FUNCTION testlog( nHandle, cString ) 195 | 196 | #ifdef LOG_IN_TXT_FILE 197 | FWrite( nHandle, cString + hb_eol() ) 198 | #else 199 | HB_SYMBOL_UNUSED( nHandle ) 200 | HB_SYMBOL_UNUSED( cString ) 201 | #endif 202 | 203 | RETURN NIL 204 | -------------------------------------------------------------------------------- /utils/olesrv/letosrv.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * Harbour Project source code: 3 | * LetoDB COM server 4 | * 5 | * Copyright 2012 Pavel Tsarenko 6 | * www - http://www.harbour-project.org 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2, or (at your option) 11 | * any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this software; see the file COPYING. If not, write to 20 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 22 | * 23 | * As a special exception, the Harbour Project gives permission for 24 | * additional uses of the text contained in its release of Harbour. 25 | * 26 | * The exception is that, if you link the Harbour libraries with other 27 | * files to produce an executable, this does not by itself cause the 28 | * resulting executable to be covered by the GNU General Public License. 29 | * Your use of that executable is in no way restricted on account of 30 | * linking the Harbour library code into it. 31 | * 32 | * This exception does not however invalidate any other reasons why 33 | * the executable file might be covered by the GNU General Public License. 34 | * 35 | * This exception applies only to the code released by the Harbour 36 | * Project under the name Harbour. If you copy code from other 37 | * Harbour Project or Free Software Foundation releases into a copy of 38 | * Harbour, as the General Public License permits, the exception does 39 | * not apply to the code that you add in this way. To avoid misleading 40 | * anyone as to the status of such modified files, you must delete 41 | * this exception notice from them. 42 | * 43 | * If you write modifications of your own for Harbour, it is your choice 44 | * whether to permit this exception to apply to your modifications. 45 | * If you do not wish that, delete this exception notice. 46 | * 47 | */ 48 | 49 | /* 50 | 51 | * To register LetoDB com server, type: 52 | 53 | regsvr32.exe letosrv.dll 54 | 55 | Connecting with LetoDB COM server: 56 | 57 | Harbour: 58 | oLeto := win_oleCreateObject( "LetoDB" ) 59 | or xHarbour: 60 | oLeto := TOleAuto():new( "LetoDB" ) 61 | 62 | cSrv := "//127.0.0.1:2812" 63 | ? oLeto:Connect( cSrv ) 64 | ? oLeto:version 65 | oTable := oLeto:Open( cSrv + "/customer" ) 66 | ? oTable:RecordCount() 67 | ? oTable:MoveFirst() 68 | ? oTable:FieldGet( "CODE" ) 69 | oTable:Close() 70 | oLeto:Close() 71 | 72 | */ 73 | 74 | #define CLS_Name "LetoDB" 75 | #define CLS_ID "{4C65746F-4442-3230-985F-8BA5E2AE8481}" 76 | 77 | #include "error.ch" 78 | #include "hbclass.ch" 79 | 80 | PROCEDURE DllMain() 81 | 82 | REQUEST leto, dbfcdx 83 | rddSetDefault( "LETO" ) 84 | set deleted off 85 | 86 | WIN_OleServerInit( CLS_ID, CLS_Name, {|| LetoDBSrv():new() } ) 87 | 88 | RETURN 89 | 90 | CREATE CLASS LetoDBSrv 91 | 92 | HIDDEN: 93 | 94 | VAR nConn 95 | VAR cAddress 96 | VAR cVersion INIT "" 97 | 98 | EXPORTED: 99 | 100 | METHOD Connect( cAddress ) 101 | METHOD Close INLINE leto_disconnect() 102 | METHOD Version INLINE leto_GetServerVersion() 103 | METHOD Open( cName ) 104 | 105 | ENDCLASS 106 | 107 | METHOD Connect( cAddress ) CLASS LetoDBSrv 108 | ::nConn := leto_Connect( cAddress ) 109 | RETURN ::nConn 110 | 111 | METHOD Open( cName ) CLASS LetoDBSrv 112 | RETURN letoTable():new( cName ) 113 | 114 | 115 | CREATE CLASS letoTable 116 | HIDDEN: 117 | VAR nConn 118 | VAR cName 119 | VAR cAlias 120 | EXPORTED: 121 | 122 | METHOD New( cName ) CONSTRUCTOR 123 | METHOD Close INLINE (::cAlias)->( dbCloseArea() ) 124 | METHOD GetStruct INLINE (::cAlias)->( dbStruct() ) 125 | METHOD FieldCount INLINE (::cAlias)->( FCount() ) 126 | 127 | METHOD Eof INLINE (::cAlias)->( Eof() ) 128 | METHOD Bof INLINE (::cAlias)->( Eof() ) 129 | METHOD RecNo INLINE (::cAlias)->( RecNo() ) 130 | METHOD RecordCount INLINE (::cAlias)->( RecCount() ) 131 | 132 | METHOD FieldPos( cField ) INLINE (::cAlias)->( FieldPos( cField ) ) 133 | METHOD FieldGet( uParam ) 134 | METHOD FieldPut( uParam, uValue ) 135 | 136 | METHOD MoveFirst INLINE (::cAlias)->( dbGoTop() ) 137 | METHOD MoveLast INLINE (::cAlias)->( dbGoBottom() ) 138 | METHOD Move( nSkip ) INLINE (::cAlias)->( dbSkip( nSkip ) ) 139 | METHOD Seek( xKey, lPartial, lLast ) INLINE (::cAlias)->( dbSeek( xKey, lPartial, lLast ) ) 140 | METHOD Goto( nRecord ) INLINE (::cAlias)->( dbGoto( nRecord ) ) 141 | 142 | ERROR HANDLER OnError( uParam ) 143 | 144 | ENDCLASS 145 | 146 | METHOD New( cName ) CLASS letoTable 147 | LOCAL lSuccess := .T., oError 148 | BEGIN SEQUENCE WITH { |e|break( e ) } 149 | dbUseArea( .t.,, cName) 150 | ::cAlias := Alias() 151 | RECOVER USING oError 152 | lSuccess := .F. 153 | END SEQUENCE 154 | RETURN if(lSuccess, Self, Nil) 155 | 156 | METHOD FieldGet( uParam ) CLASS letoTable 157 | LOCAL uValue 158 | IF hb_isNumeric( uParam ) 159 | uValue := (::cAlias)->(FieldGet( uParam )) 160 | ELSEIF hb_isString( uParam ) 161 | uValue := (::cAlias)->(FieldGet( FieldPos( uParam ) )) 162 | ENDIF 163 | RETURN uValue 164 | 165 | METHOD FieldPut( uParam, uValue ) CLASS letoTable 166 | IF hb_isNumeric( uParam ) 167 | uValue := (::cAlias)->(FieldPut( uParam, uValue )) 168 | ELSEIF hb_isString( uParam ) 169 | uValue := (::cAlias)->(FieldPut( FieldPos( uParam ), uValue )) 170 | ENDIF 171 | RETURN uValue 172 | 173 | METHOD OnError( uParam ) CLASS letoTable 174 | 175 | LOCAL cMsg := __GetMessage() 176 | LOCAL nPos 177 | LOCAL uRet, oErr 178 | 179 | if uParam != nil .and. LEFT( cMsg, 1 ) == '_' 180 | cMsg := SubStr( cMsg, 2 ) 181 | endif 182 | nPos := (::cAlias)->( FieldPos(cMsg) ) 183 | 184 | if nPos != 0 185 | uRet := (::cAlias)->( if(uParam == nil, FieldGet(nPos), FieldPut(nPos, uParam)) ) 186 | else 187 | 188 | oErr := ErrorNew() 189 | oErr:Args := { Self, cMsg, uParam } 190 | oErr:CanDefault := .F. 191 | oErr:CanRetry := .F. 192 | oErr:CanSubstitute := .T. 193 | oErr:Description := "Invalid class member" 194 | oErr:GenCode := EG_NOVARMETHOD 195 | oErr:Operation := "letoTable:" + cMsg 196 | oErr:Severity := ES_ERROR 197 | oErr:SubCode := -1 198 | oErr:SubSystem := "letoTable" 199 | uRet := Eval( ErrorBlock(), oErr ) 200 | 201 | endif 202 | 203 | RETURN uRet 204 | 205 | ANNOUNCE GT_SYS 206 | REQUEST HB_GT_GUI_DEFAULT 207 | -------------------------------------------------------------------------------- /utils/manager/replicat.prg: -------------------------------------------------------------------------------- 1 | #define SRV_TIMEOUT 42 2 | /* #define __REPLICATE_DEBUG__ 1 */ 3 | 4 | #include "inkey.ch" 5 | #include "box.ch" 6 | 7 | 8 | FUNCTION Main( cPrimary, cSecondary, cRestart ) 9 | LOCAL lReset := .F. 10 | LOCAL nKey := 0 11 | LOCAL cSyncData, cSyncLog, nSyncSize, nSyncResult, nSynced, nBlocks, nErrors 12 | LOCAL cFile := "leto_syncdata.log" 13 | LOCAL nToggleMax, nToggler := 0 14 | LOCAL nPrimary, nSecondary 15 | LOCAL lLocked 16 | LOCAL cActions := "", cAct, nExcludeUser 17 | LOCAL i 18 | LOCAL nHnd 19 | 20 | ALTD() 21 | 22 | SET CURSOR OFF 23 | SETCOLOR( "W+/B,W+/G" ) 24 | SetMode( 7, 42 ) 25 | nToggleMax := MAXCOL() 26 | CLS 27 | IF EMPTY( cPrimary ) .OR. EMPTY( cSecondary ) 28 | TimedALERT( " replicat[.exe] Primary_IP Secondary_IP", 5 ) 29 | RETURN Nil 30 | ENDIF 31 | IF LEFT( cPrimary, 2 ) != "//" 32 | cPrimary := "//" + cPrimary 33 | ENDIF 34 | IF RIGHT( cPrimary,1 ) != "/" 35 | cPrimary += "/" 36 | ENDIF 37 | IF LEFT( cSecondary, 2 ) != "//" 38 | cSecondary := "//" + cSecondary 39 | ENDIF 40 | IF RIGHT( cSecondary,1 ) != "/" 41 | cSecondary += "/" 42 | ENDIF 43 | 44 | IF leto_Connect( cPrimary, /*cUser*/, /*cPasswd*/, SRV_TIMEOUT * 1000, , .T. ) == -1 45 | TimedALERT( "Primary Server: " + leto_Connect_Err( .T. ), 3 ) 46 | ErrorLevel( leto_Connect_Err( .F. ) ) 47 | RETURN Nil 48 | ELSEIF leto_Connect( cSecondary, /*cUser*/, /*cPasswd*/, SRV_TIMEOUT * 1000, , .T. ) == -1 49 | TimedALERT( "Secondary Server: " + leto_Connect_Err( .T. ), 3 ) 50 | ErrorLevel( leto_Connect_Err( .F. ) ) 51 | RETURN Nil 52 | ELSE 53 | Leto_SetCurrentConnection( cPrimary ) 54 | ENDIF 55 | 56 | IF cPrimary == cSecondary 57 | lLocked := Leto_LockLock( .T., 10, 0 ) 58 | IF ! lLocked 59 | TimedALERT( "Fail to lock primary server", 3 ) 60 | QUIT 61 | ENDIF 62 | ENDIF 63 | 64 | IF ! EMPTY( cRestart ) 65 | lReset := .T. 66 | IF VAL( cRestart ) > 0 67 | nExcludeUser := VAL( cRestart ) 68 | ENDIF 69 | FOR i := 1 TO LEN( cRestart ) 70 | cAct := SUBSTR( cRestart, i, 1 ) 71 | IF cAct $ "+*ARMCDIOST" 72 | cActions += cAct 73 | ENDIF 74 | NEXT i 75 | ENDIF 76 | 77 | @ 0, 1 SAY "LetoDBf" COLOR "R/G" 78 | @ 0, 11 SAY "replication" 79 | @ 1, 1 SAY "Primary " + cPrimary 80 | @ 2, 1 SAY "Secondary " + cSecondary 81 | 82 | nSynced := 0 83 | nBlocks := 0 84 | nErrors := 0 85 | 86 | DO WHILE nKey != K_ESC 87 | @ MAXROW(), nToggler++ SAY " " 88 | @ MAXROW(), IIF( nToggler > nToggleMax, nToggler := 0, nToggler ) SAY CHR( 64 ) 89 | 90 | IF ( nPrimary := UserCount( cPrimary ) ) < 1 91 | TimedALERT( "primary server down" , 2 ) 92 | EXIT 93 | ENDIF 94 | IF ( nSecondary := UserCount( cSecondary ) ) < 1 95 | TimedALERT( "secondary server down" , 2 ) 96 | EXIT 97 | ENDIF 98 | @ 1, MAXCOL() - 7 SAY STR( nPrimary, 6, 0 ) 99 | @ 2, MAXCOL() - 7 SAY STR( nSecondary, 6, 0 ) 100 | 101 | cSyncData := Leto_LogRequest( IIF( lReset, 0, -1 ) ) 102 | IF lReset 103 | lReset := .F. 104 | ENDIF 105 | nSyncSize := LEN( cSyncData ) 106 | 107 | IF nSyncSize > 0 108 | @ MAXROW(), nToggler SAY CHR( 64 ) COLOR "G/B" 109 | nBlocks++ 110 | #ifdef __REPLICATE_DEBUG__ 111 | nHnd := FCREATE( "good_syncdata." + hb_ntos( nBlocks ) ) 112 | IF nHnd >= 0 113 | FWRITE( nHnd, cSyncData ) 114 | FCLOSE( nHnd ) 115 | ENDIF 116 | #endif 117 | Leto_SetCurrentConnection( cSecondary ) 118 | IF Leto_FileWrite( cFile, 0, cSyncData ) 119 | nSyncResult := Leto_LogReplay( cFile, cActions,,, nExcludeUser ) 120 | IF VALTYPE( nSyncResult ) != "N" .OR. nSyncResult >= 1 121 | IF VALTYPE( nSyncResult ) != "N" 122 | TimedALERT( "TimeOut replicate secondary: " + hb_ntos( nSyncResult ), 2 ) 123 | nErrors++ 124 | ELSE 125 | TimedALERT( "Problem replicate secondary: " + hb_ntos( nSyncResult ), 2 ) 126 | nErrors += INT( nSyncResult ) 127 | cSyncLog := Leto_MgLog( NIL, 0, .T. ) 128 | nHnd := FCREATE( "bad_synclog." + hb_ntos( nBlocks ) ) 129 | IF nHnd >= 0 130 | FWRITE( nHnd, cSyncLog ) 131 | FCLOSE( nHnd ) 132 | ENDIF 133 | ENDIF 134 | #ifdef __REPLICATE_DEBUG__ 135 | nHnd := FCREATE( "bad_syncdata." + hb_ntos( nBlocks ) ) 136 | IF nHnd >= 0 137 | FWRITE( nHnd, cSyncData ) 138 | FCLOSE( nHnd ) 139 | ENDIF 140 | #endif 141 | ELSE 142 | nSynced += nSyncSize 143 | @ 4, 3 SAY STR( nSynced, 15, 0 ) + " Bytes" 144 | @ 5, 3 SAY STR( nBlocks, 15, 0 ) + " Block" 145 | #ifdef __REPLICATE_DEBUG__ 146 | cSyncLog := Leto_MgLog( NIL, 0, .T. ) 147 | IF LEN( cSyncLog ) > 0 148 | nHnd := FCREATE( "good_synclog." + hb_ntos( nBlocks ) ) 149 | IF nHnd >= 0 150 | FWRITE( nHnd, cSyncLog ) 151 | FCLOSE( nHnd ) 152 | ENDIF 153 | ENDIF 154 | #endif 155 | ENDIF 156 | IF nErrors > 0 157 | @ 4, MAXCOL() - 11 SAY "Error: " + STR( nErrors, 3, 0 ) 158 | ENDIF 159 | Leto_FErase( cFile ) 160 | ENDIF 161 | Leto_SetCurrentConnection( cPrimary ) 162 | IF nSyncSize < 8192 /* extra delay for less ongoing action */ 163 | nKey := Inkey( 0.5 ) 164 | ENDIF 165 | ELSE 166 | IF nPrimary < 2 167 | nKey := INKEY( 30 ) 168 | ELSE 169 | nKey := INKEY( 3 ) 170 | ENDIF 171 | ENDIF 172 | IF NEXTKEY() <> 0 173 | nKey := Inkey( 0.1 ) 174 | ENDIF 175 | ENDDO 176 | 177 | RETURN .T. 178 | 179 | 180 | STATIC FUNCTION UserCount( cServer ) 181 | LOCAL cOldConnect := Leto_SetCurrentConnection( cServer, .T. ) 182 | LOCAL nUser := 0 183 | LOCAL aInfo := leto_MgGetInfo() 184 | 185 | IF VALTYPE( aInfo ) == "A" 186 | nUser := VAL( aInfo[ 1 ] ) 187 | ENDIF 188 | Leto_SetCurrentConnection( cOldConnect ) 189 | RETURN nUser 190 | 191 | STATIC FUNCTION TimedAlert( cText, nSec, cColor ) 192 | LOCAL nX1 := ( ( MAXCOL() - LEN( cText ) ) / 2 ) - 2 193 | LOCAL nX2 := ( ( MAXCOL() - LEN( cText ) ) / 2 ) + LEN( cText ) + 2 194 | LOCAL nY1 := ( MAXROW() / 2 ) - 2 195 | LOCAL nY2 := ( MAXROW() / 2 ) + 2 196 | LOCAL cSave := SAVESCREEN( nY1, nX1, nY2, nX2 ) 197 | LOCAL oldcolor := SETCOLOR( IIF( ! EMPTY( cColor ), cColor, "W+/R" ) ) 198 | 199 | @ nY1, nX1, nY2, nX2 BOX B_DOUBLE + " " 200 | @ nY1 + 2, nX1 + 2 SAY cText 201 | IF nSec > 0 202 | DO WHILE Inkey( nSec ) >= K_MINMOUSE 203 | ENDDO 204 | RESTSCREEN( nY1, nX1, nY2, nX2, cSave ) 205 | ENDIF 206 | SETCOLOR( oldcolor ) 207 | RETURN IIF( nSec > 0, .T., { nY1, nX1, nY2, nX2, cSave } ) -------------------------------------------------------------------------------- /tests/c_lang/test_var.c: -------------------------------------------------------------------------------- 1 | 2 | /* set it before ! */ 3 | #define __LETO_C_API__ 4 | #include "letocl.h" 5 | #include "rddleto.ch" 6 | 7 | #if defined( HB_OS_WIN ) 8 | #define _EOL_ "\r\n" 9 | #else 10 | #define _EOL_ "\n" 11 | #endif 12 | 13 | int main( int argc, char *argv[] ) 14 | { 15 | LETOCONNECTION * pConnection; 16 | int iPort; 17 | char szAddr[ 128 ]; 18 | 19 | LetoInit(); 20 | LetoSetAddress( argc, argv, szAddr, &iPort ); 21 | 22 | printf( "Connecting to %s:%d ..." _EOL_, szAddr, iPort ); 23 | if( ( pConnection = LetoConnectionNew( szAddr, iPort, NULL, NULL, 0, 0 ) ) != NULL ) 24 | { 25 | const char * ptr; 26 | char szData[ 256 ], szDate[ 9 ]; 27 | unsigned long ulLen; 28 | int iRes; 29 | long lData = 0; 30 | double dData = 0.0; 31 | HB_BOOL fData = HB_FALSE; 32 | 33 | printf( "Connected!" _EOL_ ); 34 | printf( "%s\r\n", LetoGetServerVer( pConnection ) ); 35 | 36 | 37 | /* adding vars */ 38 | printf( "Adding 'var_int' = 100 to [main] [Err ( 0 )] " ); 39 | iRes = LetoVarSet( pConnection, "main", "var_int", LETOVAR_NUM, "100", 0, LETO_VNOCREAT, NULL ); 40 | if( iRes ) 41 | printf( "Ok" _EOL_ ); 42 | else 43 | printf( "Err( %d )" _EOL_, LetoGetError() ); 44 | 45 | printf( "Adding 'var_int' = 100 to [main] [Ok] " ); 46 | iRes = LetoVarSet( pConnection, "main", "var_int", LETOVAR_NUM, "100", 3, LETO_VCREAT, NULL ); 47 | if( iRes ) 48 | printf( "Ok" _EOL_ ); 49 | else 50 | printf( "Err( %d )" _EOL_, LetoGetError() ); 51 | 52 | printf( "Adding 'var_dec' = 123.456 to [main] [Ok] " ); 53 | iRes = LetoVarSet( pConnection, "main", "var_dec", LETOVAR_NUM, "123.456", 0, LETO_VCREAT, NULL ); 54 | if( iRes ) 55 | printf( "Ok" _EOL_ ); 56 | else 57 | printf( "Err( %d )" _EOL_, LetoGetError() ); 58 | 59 | printf( "Adding 'var_log' = 1 to [main] [Ok] " ); 60 | iRes = LetoVarSet( pConnection, "main", "var_log", LETOVAR_LOG, "1", 0, LETO_VCREAT, NULL ); 61 | if( iRes ) 62 | printf( "Ok" _EOL_ ); 63 | else 64 | printf( "Err( %d )" _EOL_, LetoGetError() ); 65 | 66 | printf( "Adding 'var_char' = 'Just a test;' to [main] [Ok] " ); 67 | iRes = LetoVarSet( pConnection, "main", "var_char", LETOVAR_STR, "Just a test;", 0, LETO_VCREAT, NULL ); 68 | if( iRes ) 69 | printf( "Ok" _EOL_ ); 70 | else 71 | printf( "Err( %d )" _EOL_, LetoGetError() ); 72 | 73 | printf( "Adding 'var_binary' containing: 'CHR(0);CHR(1);CHR(0)' to [main] [Ok] " ); 74 | iRes = LetoVarSet( pConnection, "main", "var_binary", LETOVAR_STR, "\0;\1;\0", 5, LETO_VCREAT + LETO_VOWN, NULL ); 75 | if( iRes ) 76 | printf( "Ok" _EOL_ ); 77 | else 78 | printf( "Err( %d )" _EOL_, LetoGetError() ); 79 | 80 | printf( "Adding 'var_date' containing: '20230102' to [main] [Ok] " ); 81 | iRes = LetoVarSet( pConnection, "main", "var_date", LETOVAR_DAT, "20230102", 0, LETO_VCREAT + LETO_VOWN, NULL ); 82 | if( iRes ) 83 | printf( "Ok" _EOL_ ); 84 | else 85 | printf( "Err( %d )" _EOL_, LetoGetError() ); 86 | 87 | /* retrieve vars */ 88 | printf( _EOL_ ); 89 | 90 | ptr = LetoVarGet( pConnection, "main", "var_int", NULL ); 91 | printf( "var_int = [100] %s" _EOL_, ( ptr ) ? ptr + 2 : "Err" ); 92 | iRes = LetoVarGetC( pConnection, "main", "var_int", &lData, NULL ); 93 | 94 | ptr = LetoVarGet( pConnection, "main", "var_dec", NULL ); 95 | printf( "var_dec = [123.345] %s" _EOL_, ( ptr ) ? ptr + 2 : "Err" ); 96 | iRes = LetoVarGetC( pConnection, "main", "var_dec", &dData, NULL ); 97 | 98 | printf( "LetoVarGetC into long: %ld, double: %f " _EOL_, lData, dData ); 99 | 100 | ptr = LetoVarGet( pConnection, "main", "var_char", NULL ); 101 | printf( "var_char = (Just a test;) %s" _EOL_, ( ptr ) ? ptr + 2 : "Err" ); 102 | ulLen = 256; 103 | iRes = LetoVarGetC( pConnection, "main", "var_char", szData, &ulLen ); 104 | printf( "var_char = (Just a test;) %s (len: %lu)" _EOL_, szData, ulLen ); 105 | 106 | ptr = LetoVarGet( pConnection, "main", "var_binary", NULL ); 107 | if( ptr && *( ptr + 2 ) == '\0' && *( ptr + 3 ) == ';' && 108 | *( ptr + 4 ) == '\1' && *( ptr + 5 ) == ';' && 109 | *( ptr + 6 ) == '\0' ) 110 | printf( "var_binary = CHR(0);CHR(1);CHR(0) %s" _EOL_, "Ok" ); 111 | else 112 | printf( "var_binary != CHR(0);CHR(1);CHR(0) %s" _EOL_, "Err" ); 113 | 114 | ulLen = 256; 115 | iRes = LetoVarGetC( pConnection, "main", "var_binary", szData, &ulLen ); 116 | ptr = szData; 117 | if( iRes && *( ptr + 2 ) == '\0' && *( ptr + 3 ) == ';' && 118 | *( ptr + 4 ) == '\1' && *( ptr + 5 ) == ';' && 119 | ulLen == 5 ) 120 | printf( "var_binary = CHR(0);CHR(1);CHR(0) %s (len: %lu)" _EOL_, "Ok", ulLen ); 121 | else 122 | printf( "var_binary != CHR(0);CHR(1);CHR(0) %s (len: %lu)" _EOL_, "Err", ulLen ); 123 | 124 | ptr = LetoVarGet( pConnection, "main", "var_log", NULL ); 125 | iRes = LetoVarGetC( pConnection, "main", "var_log", &fData, NULL ); 126 | printf( "var_log = [1] %s true: %s" _EOL_, ( ptr ? ptr + 2 : "Err" ), fData ? "true" : "false" ); 127 | 128 | ptr = LetoVarGet( pConnection, "main", "var_date", NULL ); 129 | /* min length 9 must be ensured ! */ 130 | iRes = LetoVarGetC( pConnection, "main", "var_date", szDate, NULL ); 131 | printf( "var_date = (20230102) %s (%s)" _EOL_, ptr + 2, szDate ); 132 | 133 | 134 | /* delete vars */ 135 | printf( _EOL_ ); 136 | printf( "Delete var_char [Ok] " ); 137 | iRes = LetoVarDel( pConnection, "main", "var_char" ); 138 | if( iRes ) 139 | printf( "Ok" _EOL_ ); 140 | else 141 | printf( "Err( %d )" _EOL_, LetoGetError() ); 142 | 143 | printf( "Delete var_binary [Ok] " ); 144 | iRes = LetoVarDel( pConnection, "main", "var_binary" ); 145 | if( iRes ) 146 | printf( "Ok" _EOL_ ); 147 | else 148 | printf( "Err( %d )" _EOL_, LetoGetError() ); 149 | 150 | printf( "Delete var_log [Ok] " ); 151 | iRes = LetoVarDel( pConnection, "main", "var_log" ); 152 | if( iRes ) 153 | printf( "Ok" _EOL_ ); 154 | else 155 | printf( "Err( %d )" _EOL_, LetoGetError() ); 156 | 157 | printf( "Delete var_int [Ok] " ); 158 | iRes = LetoVarDel( pConnection, "main", "var_int" ); 159 | if( iRes ) 160 | printf( "Ok" _EOL_ ); 161 | else 162 | printf( "Err( %d )" _EOL_, LetoGetError() ); 163 | 164 | printf( "Delete var_dec [Ok] " ); 165 | iRes = LetoVarDel( pConnection, "main", "var_dec" ); 166 | if( iRes ) 167 | printf( "Ok" _EOL_ ); 168 | else 169 | printf( "Err( %d )" _EOL_, LetoGetError() ); 170 | 171 | printf( "Delete var_date [Ok] " ); 172 | iRes = LetoVarDel( pConnection, "main", "var_date" ); 173 | if( iRes ) 174 | printf( "Ok" _EOL_ ); 175 | else 176 | printf( "Err( %d )" _EOL_, LetoGetError() ); 177 | 178 | printf( _EOL_ "logging out ..." _EOL_ ); 179 | LetoConnectionClose( pConnection ); 180 | } 181 | else 182 | printf( "Connection failure" _EOL_ ); 183 | 184 | LetoExit( 1 ); 185 | } 186 | -------------------------------------------------------------------------------- /source/phpclient/letocl.php: -------------------------------------------------------------------------------- 1 | 5 | * adaption for LetoDBf 2019 Rolf 'elch' Beckmann 6 | * www - http://www.kresin.ru 7 | */ 8 | 9 | $leto_debug1 = false; 10 | $leto_dateform = "dd/mm/yy"; 11 | $leto_language = "EN"; 12 | 13 | /* variable type */ 14 | const LETOVAR_LOG = "1"; 15 | const LETOVAR_NUM = "2"; 16 | const LETOVAR_STR = "3"; 17 | const LETOVAR_DAT = "5"; 18 | 19 | /* variable flags */ 20 | const LETO_VCREAT = 1; 21 | const LETO_VOWN = 2; 22 | const LETO_VDENYWR = 4; 23 | const LETO_VDENYRD = 8; 24 | const LETO_VPREVIOUS = 16; 25 | 26 | 27 | function letoRead( $conn ) { 28 | if( $conn["proto"] == 1 ) { 29 | $awr = socket_read( $conn["sock"], 1024 ); 30 | } 31 | else { 32 | $awr = socket_read( $conn["sock"], 4 ); 33 | $a1 = unpack( "V", $awr ); 34 | $awr = socket_read( $conn["sock"], $a1[1] ); 35 | } 36 | if( $GLOBALS['leto_debug1'] ) 37 | echo $awr."
"; 38 | return $awr; 39 | } 40 | 41 | function letoDataSend( $conn, $data, $datalen ) { 42 | if( $GLOBALS['leto_debug1'] ) 43 | echo "Send to server: ".$data."
"; 44 | if( $conn["proto"] == 1 ) 45 | socket_write( $conn["sock"], $data, $datalen ); 46 | else 47 | socket_write( $conn["sock"], pack( "V", $datalen ).$data, $datalen + 4 ); 48 | return letoRead( $conn ); 49 | } 50 | 51 | function letoConnect( $addr, $port, $user, $passwd ) { 52 | $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 53 | if( $socket >= 0 ) { 54 | if( ! isset( $addr ) ) 55 | $addr = "127.0.0.1"; 56 | if( ! isset( $port ) ) 57 | $port = 2812; 58 | if( ! isset( $user ) ) 59 | $user = ""; 60 | if( ! isset( $passwd ) ) 61 | $passwd = ""; 62 | if( ! socket_connect( $socket, $addr, $port ) ) { 63 | socket_close( $socket ); 64 | $socket = -1; 65 | } 66 | } 67 | if( $socket < 0 ) { 68 | echo "Error : ".socket_strerror(socket_last_error())."
"; 69 | return NULL; 70 | } 71 | 72 | if( $GLOBALS['leto_debug1'] ) 73 | echo "OK: "; 74 | $conn = array( 'sock' => $socket, 'proto' => 1, 'ver' => '' ); 75 | $awr = socket_read( $socket, 4 ); 76 | if( strcmp( $awr, "Leto" ) == 0 ) 77 | $awr = $awr.socket_read( $socket, 1024 ); 78 | else { 79 | $conn["proto"] = 3; 80 | $a1 = unpack( "V", $awr ); 81 | $awr = socket_read( $socket, $a1[1] ); 82 | } 83 | $a1 = explode( ";",$awr ); 84 | $conn["ver"] = $a1[0]; 85 | if( $GLOBALS['leto_debug1'] ) 86 | echo $awr."
"; 87 | 88 | $msg = "J;3.00;WWW;PHPClient;".$user.";".$passwd.";".$leto_language.";TTT0;".$leto_dateform.";1900;;"; 89 | /* LETOCMD_intro */ 90 | $awr = letoDataSend( $conn, $msg, strlen($msg) ); 91 | if( substr( $awr, 0, 1 ) == "+" ) { 92 | return $conn; 93 | } 94 | else 95 | return NULL; 96 | } 97 | 98 | function letoMgInfo( $conn ) { 99 | $msg = "M;00;"; 100 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 101 | if( substr( $awr, 0, 1 ) == "+" ) { 102 | return explode( ";", substr( $awr, 1 ) ); 103 | } 104 | else 105 | return NULL; 106 | } 107 | 108 | function letoVarGet( $conn, $group, $var ) { 109 | /* LETOCMD_var */ 110 | $msg = "V;g;".$group.";".$var.";"; 111 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 112 | if( substr( $awr, 0, 1 ) == "+" ) { 113 | $type = substr( $awr, 1, 1 ); /* TYPE character -- followed by ';' */ 114 | if( $type == LETOVAR_STR or $type == LETOVAR_DAT ) 115 | return substr( $awr, 3 ); 116 | elseif( $type == LETOVAR_LOG ) { 117 | if( substr( $awr, 3, 1 ) == "1" ) 118 | return true; 119 | else 120 | return false; 121 | } 122 | elseif( $type == LETOVAR_NUM ) { 123 | return strval( substr( $awr, 3 ) ); 124 | } 125 | else { 126 | return NULL; 127 | } 128 | } 129 | else 130 | return NULL; 131 | } 132 | 133 | function addLen( $len ) { 134 | if( $len < 256 ) { 135 | $msg = chr( 1 ); 136 | $msg .= chr( $len ); 137 | } 138 | else { 139 | $msg = chr( 2 ); 140 | $msg .= chr( $len & 255 ); 141 | $msg .= chr( ( $$len >> 8 ) & 255 ); 142 | } 143 | return $msg; 144 | } 145 | 146 | function letoVarFlag( $flags, $nflag ) { 147 | if( $nflag == 1 ) 148 | $flag = 32 | ( $flags & ( LETO_VCREAT | LETO_VOWN | LETO_VDENYWR | LETO_VDENYRD ) ); 149 | else 150 | $flag = 32 | ( $flags & LETO_VPREVIOUS ); 151 | return chr( $flag ); 152 | } 153 | 154 | function letoVarSet( $conn, $group, $var, $type, $value, $flags ) { 155 | $fl1 = letoVarFlag( $flags, 1 ); 156 | $fl2 = letoVarFlag( $flags, 2 ); 157 | $addlen = addLen( strlen( $value ) ); 158 | $msg = "V;s;".$group.";".$var.";".$type.$fl1.$fl2.";".$addlen.$value; 159 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 160 | if( substr( $awr, 0, 1 ) == "+" ) { 161 | return true; 162 | } 163 | else 164 | return false; 165 | } 166 | 167 | function letoVarSum( $conn, $group, $var, $flags, $incr ) { 168 | $fl1 = letoVarFlag( $flags, 1 ); 169 | $fl2 = letoVarFlag( $flags, 2 ); 170 | $msg = "V;i;".$group.";".$var.";2".$fl1.$fl2.";".$incr.";"; 171 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 172 | if( substr( $awr, 0, 1 ) == "+" ) { 173 | $pos = strpos( $awr, ';' ); 174 | if( $pos === false ) 175 | return NULL; 176 | else 177 | return intval( substr( $awr, 1, $pos - 1 ) ); 178 | } 179 | else 180 | return NULL; 181 | } 182 | 183 | function letoVarIncr( $conn, $group, $var, $flags ) { 184 | $fl1 = letoVarFlag( $flags, 1 ); 185 | $fl2 = letoVarFlag( $flags, 2 ); 186 | $msg = "V;i;".$group.";".$var.";2".$fl1.$fl2.";1;"; 187 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 188 | if( substr( $awr, 0, 1 ) == "+" ) { 189 | $pos = strpos( $awr, ';' ); 190 | if( $pos === false ) 191 | return NULL; 192 | else 193 | return intval( substr( $awr, 1, $pos - 1 ) ); 194 | } 195 | else 196 | return NULL; 197 | } 198 | 199 | function letoVarDecr( $conn, $group, $var, $flags ) { 200 | $fl1 = letoVarFlag( $flags, 1 ); 201 | $fl2 = letoVarFlag( $flags, 2 ); 202 | $msg = "V;d;".$group.";".$var.";2".$fl1.$fl2.";1;"; 203 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 204 | if( substr( $awr, 0, 1 ) == "+" ) { 205 | $pos = strpos( $awr, ';' ); 206 | if( $pos === false ) 207 | return NULL; 208 | else 209 | return intval( substr( $awr, 1, $pos-1 ) ); 210 | } 211 | else 212 | return NULL; 213 | } 214 | 215 | function letoVarDel( $conn, $group, $var ) { 216 | $msg = "V;r;".$group.";".$var.";"; 217 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 218 | if( substr( $awr, 0, 1 ) == "+" ) 219 | return true; 220 | else 221 | return NULL; 222 | } 223 | 224 | function letoUdfExist( $conn, $func ) { 225 | $msg = "U;3;;;".$func.";"; 226 | /* LETOCMD_udf_fun */ 227 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 228 | if( substr( $awr, 0, 1 ) == "+" ) 229 | return true; 230 | else 231 | return false; 232 | } 233 | 234 | function letoUdf( $conn, $func, $ldeleted, $lexclusive ) { 235 | $fl1 = $ldeleted ? 'A' : '@'; 236 | $fl2 = $lexclusive ? 'T' : 'F'; 237 | $msg = "U;2;".$fl1.";0;".$func.";".$fl2.";0;"; 238 | /* LETOCMD_udf_fun */ 239 | $awr = letoDataSend( $conn, $msg, strlen( $msg ) ); 240 | if( substr( $awr, 0, 1 ) == "+" ) 241 | return true; 242 | else 243 | return false; 244 | } 245 | 246 | ?> 247 | -------------------------------------------------------------------------------- /include/letofile.ch: -------------------------------------------------------------------------------- 1 | /* 2 | * Header file for Leto file translate functions 3 | * 4 | * based on idea/ suggests from 2017 Mauricio Ventura Faria 5 | * 'formatting' 2017 Rolf 'elch' Beckmann 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this software; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). 21 | * 22 | * As a special exception, the Harbour Project gives permission for 23 | * additional uses of the text contained in its release of Harbour. 24 | * 25 | * The exception is that, if you link the Harbour libraries with other 26 | * files to produce an executable, this does not by itself cause the 27 | * resulting executable to be covered by the GNU General Public License. 28 | * Your use of that executable is in no way restricted on account of 29 | * linking the Harbour library code into it. 30 | * 31 | * This exception does not however invalidate any other reasons why 32 | * the executable file might be covered by the GNU General Public License. 33 | * 34 | * This exception applies only to the code released by the Harbour 35 | * Project under the name Harbour. If you copy code from other 36 | * Harbour Project or Free Software Foundation releases into a copy of 37 | * Harbour, as the General Public License permits, the exception does 38 | * not apply to the code that you add in this way. To avoid misleading 39 | * anyone as to the status of such modified files, you must delete 40 | * this exception notice from them. 41 | * 42 | * If you write modifications of your own for Harbour, it is your choice 43 | * whether to permit this exception to apply to your modifications. 44 | * If you do not wish that, delete this exception notice. 45 | * 46 | */ 47 | 48 | /* 49 | Include this header for translations of locally working functions. 50 | Out-comment at top groups not wanted, to keep them working at client 51 | */ 52 | 53 | 54 | #ifndef LETOFILE_CH_ 55 | #define LETOFILE_CH_ 56 | 57 | /* this activates the default set */ 58 | #define __LETO_TRANSLATE_FILE__ 59 | 60 | /* non-modifying queries for size and exist */ 61 | #if ! defined( __LETO_TRANSLATE_FILE ) && ( defined( __LETO_TRANSLATE_FILE__ ) || defined( __LETO_TRANSLATE_FILE_ALL ) ) 62 | #define __LETO_TRANSLATE_FILE 63 | #endif 64 | 65 | /* extended set of copy, delete, rename, timestamp */ 66 | #if ! defined( __LETO_TRANSLATE_FILE_MORE ) && ( defined( __LETO_TRANSLATE_FILE__ ) || defined( __LETO_TRANSLATE_FILE_ALL ) ) 67 | #define __LETO_TRANSLATE_FILE_MORE 68 | #endif 69 | 70 | /* low-level Fxxx() function set -- need allowed UDF at server */ 71 | #if ! defined( __LETO_TRANSLATE_FILE_LOW ) && defined( __LETO_TRANSLATE_FILE_ALL ) 72 | #define __LETO_TRANSLATE_FILE_LOW 73 | #endif 74 | 75 | /* memo functions to read, write */ 76 | #if ! defined( __LETO_TRANSLATE_MEMO ) && ( defined( __LETO_TRANSLATE_FILE__ ) || defined( __LETO_TRANSLATE_FILE_ALL ) ) 77 | #define __LETO_TRANSLATE_MEMO 78 | #endif 79 | 80 | /* directory function set to query, test, make, remove */ 81 | #if ! defined( __LETO_TRANSLATE_DIR ) && ( defined( __LETO_TRANSLATE_FILE__ ) || defined( __LETO_TRANSLATE_FILE_ALL ) ) 82 | #define __LETO_TRANSLATE_DIR 83 | #endif 84 | 85 | /* CT contrib functions -- need CT-contrib linked to application */ 86 | #if ! defined( __LETO_TRANSLATE_CT ) && defined( __LETO_TRANSLATE_FILE_ALL ) 87 | #define __LETO_TRANSLATE_CT 88 | #endif 89 | 90 | 91 | #if defined( __LETO_TRANSLATE_FILE ) 92 | /* DbExists() / hb_DbExists() uses LetoDBf RDD methods, need no translation */ 93 | #xtranslate FILE( ) => LETO_FILE( ) 94 | #xtranslate FILESIZE( [] ) => LETO_FILESIZE( ) 95 | #endif 96 | 97 | #if defined( __LETO_TRANSLATE_FILE_MORE ) || defined( __LETO_TRANSLATE_FILE_LOW ) 98 | /* a.) ask client side, here possible set as result of a Leto_File*() function */ 99 | /* #xtranslate FERROR( [] ) => LETO_FERROR( ) */ 100 | 101 | /* b.) query the server */ 102 | #xtranslate FERROR( [] ) => leto_Udf( "FError", ) 103 | #endif 104 | 105 | #if defined( __LETO_TRANSLATE_FILE_MORE ) 106 | #xtranslate COPY FILE <(src)> TO <(dst)> => LETO_FCOPY( <(src)>, <(dst)> ) 107 | #xtranslate __COPYFILE( [] ) => LETO_FCOPY( ) 108 | #xtranslate DELETE FILE <(f)> => LETO_FERASE( ) 109 | #xtranslate FERASE( [] ) => LETO_FERASE( ) 110 | #xtranslate FRENAME( [] ) => LETO_FRENAME( ) 111 | 112 | #xtranslate HB_FSETDATETIME( ) => LETO_FILETIME( ) 113 | #endif 114 | 115 | #if defined( __LETO_TRANSLATE_FILE_LOW ) 116 | /* all based on UDF execute at server -- not for xHb */ 117 | #xtranslate FOPEN( [] ) => leto_Udf( "Leto_FOpen", ) 118 | #xtranslate FCREATE( [] ) => leto_Udf( "Leto_FCreate", ) 119 | #xtranslate FCLOSE( [] ) => leto_Udf( "Leto_FClose", ) 120 | #xtranslate FSEEK( [] ) => leto_Udf( "FSeek", ) 121 | #xtranslate FREAD( [] ) => leto_Fread( ) 122 | #xtranslate FREADSTR( [] ) => leto_Udf( "FReadStr", ) 123 | #xtranslate FWRITE( [] ) => leto_Udf( "FWrite", ) 124 | 125 | #xtranslate HB_FCREATE( ) => leto_Udf( "Leto_FCreate", ) 126 | #endif 127 | 128 | #if defined( __LETO_TRANSLATE_MEMO ) 129 | #xtranslate MEMOREAD( [] ) => LETO_MEMOREAD( ) 130 | #xtranslate MEMOWRITE( [] ) => LETO_MEMOWRITE( ) 131 | #endif 132 | 133 | #if defined( __LETO_TRANSLATE_DIR ) 134 | // #xtranslate ADIR( cSpec, aName, aSize, aDate, aTime, aAttr ) 135 | #xtranslate ADIR( ) => LEN( LETO_DIRECTORY( ) ) 136 | #xtranslate ADIR( , ) => AEVAL( LETO_DIRECTORY( ),; 137 | { | aDir, nI | \[ nI \] := aDir\[ 1 \] } ) 138 | #xtranslate DIRECTORY( [] ) => LETO_DIRECTORY( ) 139 | #xtranslate ISDIRECTORY( [] ) => LETO_DIREXIST( ) 140 | #xtranslate ISDIR( [] ) => LETO_DIREXIST( ) 141 | #xtranslate DIRMAKE( [] ) => LETO_DIRMAKE( ) 142 | #xtranslate MAKEDIR( [] ) => LETO_DIRMAKE( ) 143 | #xtranslate DIRREMOVE( [] ) => LETO_DIRREMOVE( ) 144 | #endif 145 | 146 | #if defined( __LETO_TRANSLATE_CT ) 147 | #xtranslate FILEATTR( ) => LETO_FILEATTR( ,,.T. ) 148 | #xtranslate SETFATTR( , ) => LETO_FILEATTR( , , .T. ) 149 | #xtranslate FILEDATE( ) => LETO_FILETIME( ,,, 2 ) 150 | #xtranslate FILETIME( ) => LETO_FILETIME( ,,, 4 ) 151 | #xtranslate SETFDATI( ) => LETO_FILETIME( ) 152 | /* to catch a broken/ not yet established connection, aka no returned array */ 153 | #xtranslate DISKSPACE( [] ) => EVAL( {| a | a := Leto_MgSysInfo(), IIF( VALTYPE( a ) == "A", a\[ 1 \], 0 ) } ) 154 | #xtranslate FILECOPY( , ) => LETO_FCOPY( , ) 155 | #xtranslate FILEMOVE( , ) => LETO_FCOPY( , , .T. ) 156 | #xtranslate DELETEFILE( ) => LETO_FERASE( ) 157 | #xtranslate RENAMEFILE( , ) => LETO_FRENAME( , ) 158 | #endif 159 | 160 | 161 | #endif /* LETOFILE_CH_ */ 162 | -------------------------------------------------------------------------------- /source/3rd/lz4/lib/xxhash.h: -------------------------------------------------------------------------------- 1 | /* 2 | xxHash - Extremely Fast Hash algorithm 3 | Header File 4 | Copyright (C) 2012-2015, Yann Collet. 5 | 6 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the following disclaimer 16 | in the documentation and/or other materials provided with the 17 | distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | You can contact the author at : 32 | - xxHash source repository : https://github.com/Cyan4973/xxHash 33 | */ 34 | 35 | /* Notice extracted from xxHash homepage : 36 | 37 | xxHash is an extremely fast Hash algorithm, running at RAM speed limits. 38 | It also successfully passes all tests from the SMHasher suite. 39 | 40 | Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz) 41 | 42 | Name Speed Q.Score Author 43 | xxHash 5.4 GB/s 10 44 | CrapWow 3.2 GB/s 2 Andrew 45 | MumurHash 3a 2.7 GB/s 10 Austin Appleby 46 | SpookyHash 2.0 GB/s 10 Bob Jenkins 47 | SBox 1.4 GB/s 9 Bret Mulvey 48 | Lookup3 1.2 GB/s 9 Bob Jenkins 49 | SuperFastHash 1.2 GB/s 1 Paul Hsieh 50 | CityHash64 1.05 GB/s 10 Pike & Alakuijala 51 | FNV 0.55 GB/s 5 Fowler, Noll, Vo 52 | CRC32 0.43 GB/s 9 53 | MD5-32 0.33 GB/s 10 Ronald L. Rivest 54 | SHA1-32 0.28 GB/s 10 55 | 56 | Q.Score is a measure of quality of the hash function. 57 | It depends on successfully passing SMHasher test set. 58 | 10 is a perfect score. 59 | 60 | A 64-bits version, named XXH64, is available since r35. 61 | It offers much better speed, but for 64-bits applications only. 62 | Name Speed on 64 bits Speed on 32 bits 63 | XXH64 13.8 GB/s 1.9 GB/s 64 | XXH32 6.8 GB/s 6.0 GB/s 65 | */ 66 | 67 | #pragma once 68 | 69 | #if defined (__cplusplus) 70 | extern "C" { 71 | #endif 72 | 73 | 74 | /***************************** 75 | * Definitions 76 | *****************************/ 77 | #include /* size_t */ 78 | typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; 79 | 80 | 81 | /***************************** 82 | * Namespace Emulation 83 | *****************************/ 84 | /* Motivations : 85 | 86 | If you need to include xxHash into your library, 87 | but wish to avoid xxHash symbols to be present on your library interface 88 | in an effort to avoid potential name collision if another library also includes xxHash, 89 | 90 | you can use XXH_NAMESPACE, which will automatically prefix any symbol from xxHash 91 | with the value of XXH_NAMESPACE (so avoid to keep it NULL, and avoid numeric values). 92 | 93 | Note that no change is required within the calling program : 94 | it can still call xxHash functions using their regular name. 95 | They will be automatically translated by this header. 96 | */ 97 | #ifdef XXH_NAMESPACE 98 | # define XXH_CAT(A,B) A##B 99 | # define XXH_NAME2(A,B) XXH_CAT(A,B) 100 | # define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32) 101 | # define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64) 102 | # define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState) 103 | # define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState) 104 | # define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState) 105 | # define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState) 106 | # define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset) 107 | # define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset) 108 | # define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update) 109 | # define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update) 110 | # define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest) 111 | # define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest) 112 | #endif 113 | 114 | 115 | /***************************** 116 | * Simple Hash Functions 117 | *****************************/ 118 | 119 | unsigned int XXH32 (const void* input, size_t length, unsigned seed); 120 | unsigned long long XXH64 (const void* input, size_t length, unsigned long long seed); 121 | 122 | /* 123 | XXH32() : 124 | Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input". 125 | The memory between input & input+length must be valid (allocated and read-accessible). 126 | "seed" can be used to alter the result predictably. 127 | This function successfully passes all SMHasher tests. 128 | Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s 129 | XXH64() : 130 | Calculate the 64-bits hash of sequence of length "len" stored at memory address "input". 131 | Faster on 64-bits systems. Slower on 32-bits systems. 132 | */ 133 | 134 | 135 | 136 | /***************************** 137 | * Advanced Hash Functions 138 | *****************************/ 139 | typedef struct { long long ll[ 6]; } XXH32_state_t; 140 | typedef struct { long long ll[11]; } XXH64_state_t; 141 | 142 | /* 143 | These structures allow static allocation of XXH states. 144 | States must then be initialized using XXHnn_reset() before first use. 145 | 146 | If you prefer dynamic allocation, please refer to functions below. 147 | */ 148 | 149 | XXH32_state_t* XXH32_createState(void); 150 | XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr); 151 | 152 | XXH64_state_t* XXH64_createState(void); 153 | XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr); 154 | 155 | /* 156 | These functions create and release memory for XXH state. 157 | States must then be initialized using XXHnn_reset() before first use. 158 | */ 159 | 160 | 161 | XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned seed); 162 | XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length); 163 | unsigned int XXH32_digest (const XXH32_state_t* statePtr); 164 | 165 | XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed); 166 | XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length); 167 | unsigned long long XXH64_digest (const XXH64_state_t* statePtr); 168 | 169 | /* 170 | These functions calculate the xxHash of an input provided in multiple smaller packets, 171 | as opposed to an input provided as a single block. 172 | 173 | XXH state space must first be allocated, using either static or dynamic method provided above. 174 | 175 | Start a new hash by initializing state with a seed, using XXHnn_reset(). 176 | 177 | Then, feed the hash state by calling XXHnn_update() as many times as necessary. 178 | Obviously, input must be valid, meaning allocated and read accessible. 179 | The function returns an error code, with 0 meaning OK, and any other value meaning there is an error. 180 | 181 | Finally, you can produce a hash anytime, by using XXHnn_digest(). 182 | This function returns the final nn-bits hash. 183 | You can nonetheless continue feeding the hash state with more input, 184 | and therefore get some new hashes, by calling again XXHnn_digest(). 185 | 186 | When you are done, don't forget to free XXH state space, using typically XXHnn_freeState(). 187 | */ 188 | 189 | 190 | #if defined (__cplusplus) 191 | } 192 | #endif 193 | -------------------------------------------------------------------------------- /tests/test_file.prg: -------------------------------------------------------------------------------- 1 | /* 2 | * This sample demonstrates how to use file functions with Leto db server 3 | * EnableFileFunc = 1 must be set in server's letodb.ini 4 | */ 5 | REQUEST LETO 6 | #include "rddleto.ch" 7 | #include "fileio.ch" 8 | 9 | Function Main( cPath ) 10 | LOCAL cBuf, arr, i, lTmp, nTmp, nHandle 11 | LOCAL nPort := 2812 12 | 13 | ALTD() 14 | IF Empty( cPath ) 15 | cPath := "//127.0.0.1:2812/" 16 | ELSE 17 | cPath := "//" + cPath + IiF( ":" $ cPath, "", ":" + ALLTRIM( STR( nPort ) ) ) 18 | cPath += Iif( Right(cPath,1) == "/", "", "/" ) 19 | ENDIF 20 | 21 | ? "Hey, LetoDBf:", Leto_Ping() 22 | 23 | ? "Connect to " + cPath + " - " 24 | IF ( leto_Connect( cPath ) ) == -1 25 | ? "Error connecting to server:", leto_Connect_Err(), leto_Connect_Err( .T. ) 26 | WAIT 27 | Return Nil 28 | ELSE 29 | ?? "Ok" 30 | ENDIF 31 | 32 | ? "Hey, LetoDBf:", Leto_Ping() 33 | 34 | /* No more cPath needed after Leto_connect() */ 35 | 36 | ? 'leto_file( "test1.txt" ) - ' 37 | lTmp := leto_file( "test1.txt" ) 38 | ?? Iif( lTmp, "Ok", "No" ) 39 | i := Leto_fError() 40 | ? 'file functions working ? - ' + Iif( i == 100, "disabled",; 41 | Iif( i == IIF( lTmp, 0, 2 ), "well well", "ups, error: " + STR( leto_fError(), 5, 0 ) ) ) 42 | 43 | ? 'leto_memowrite( "test1.txt", "A test N1" ) - ' 44 | ?? Iif( leto_memowrite( "test1.txt", "A test N1" ), "Ok", "Failure" ) 45 | 46 | ? 'leto_file( "test1.txt" ) - ' 47 | ?? Iif( leto_file( "test1.txt" ), "Ok", "No" ) 48 | 49 | ? 'leto_memoread( "test1.txt" ) - ' 50 | ?? leto_memoread( "test1.txt" ) 51 | 52 | ? 'leto_frename( "test1.txt", "test2.txt" ) - ' 53 | ?? Iif( leto_frename( "test1.txt","test2.txt" ) == 0, "Ok", "Failure" ) 54 | ?? Iif( ! leto_file( "test1.txt" ), "!", " fail" ) 55 | ?? Iif( leto_file( "test2.txt" ), "!", " fail" ) 56 | 57 | ? 'leto_fcopy( "test2.txt", "test1.txt" ) - ' 58 | ?? Iif( leto_fcopy( "test2.txt", "test1.txt" ) == 0, "Ok", "Failure" ) 59 | ?? Iif( leto_file( "test1.txt" ), "!", " fail" ) 60 | 61 | ? 'leto_fileread( "test2.txt", 7, 2 ) - ' 62 | ?? Iif( leto_fileread( "test2.txt", 7, 2, @cBuf ) > 0, "'" + cBuf + "'", "Failure" ) 63 | ?? Iif( cBuf == "N1", " - Ok", " - Failure" ) 64 | 65 | ? 'leto_filewrite( "test2.txt", 7, "N2" ) - ' 66 | ?? Iif( leto_filewrite( "test2.txt", 7, "N2" ), "Ok", "Failure" ) 67 | 68 | ? 'leto_memoread( "test2.txt" ) - ' 69 | cBuf := leto_memoread( "test2.txt" ) 70 | ?? "'" + cBuf + "' - " 71 | ?? Iif( cBuf == "A test N2", "Ok", "Failure" ) 72 | 73 | ? 'leto_filesize( "test2.txt" ) - ' 74 | ?? leto_filesize( "test2.txt" ) 75 | 76 | ? 'leto_filewrite( "test2.txt", 0, 2048 * "A" ) - ' 77 | ?? Iif( leto_filewrite( "test2.txt", 0, REPLICATE( "A", 2048 ) ), "Ok", "Failure" ) 78 | 79 | ? 'leto_filesize( "test2.txt" ) - ' 80 | ?? leto_filesize( "test2.txt" ) 81 | leto_fileread( "test2.txt", 0, 0, @cBuf ) 82 | IF cBuf == REPLICATE( "A", 2048 ) 83 | ?? " fine" 84 | ENDIF 85 | 86 | #ifndef __XHARBOUR__ 87 | ? 'leto_fCopyFromSrv( "test3.txt", "test2.txt" ) - ' 88 | lTmp := leto_fCopyFromSrv( "test3.txt", "test2.txt", 1000 ) 89 | ?? Iif( lTmp, "Ok", "Failure" ) 90 | ?? Iif( FILE( "test3.txt" ), "!", "@" ) 91 | IF ! lTmp 92 | ?? FError(), Leto_FError( .F. ), Leto_Ferror( .T. ) 93 | ENDIF 94 | 95 | MemoWrit( "test3.txt", Replicate( "z", 123456 ) ) 96 | ? 'leto_fCopyToSrv( "test3.txt", "test2.txt" ) - ' 97 | lTmp := leto_fCopyToSrv( "test3.txt", "test2.txt", 1000 ) 98 | ?? Iif( lTmp, "Ok", "Failure" ) 99 | ?? Iif( leto_filesize( "test2.txt" ) == 123457, "!", "@" ) /* +1 for strg-z */ 100 | IF ! lTmp 101 | ?? FError(), Leto_FError( .F. ), Leto_Ferror( .T. ) 102 | ENDIF 103 | FErase( "test3.txt" ) 104 | #endif 105 | 106 | ? 'leto_memowrite( "test2.txt", 4095 * "B" ) - ' 107 | ?? Iif( leto_memowrite( "test2.txt", REPLICATE( "B", 4095 ) ), "Ok", "Failure" ) 108 | ?? Iif( leto_filesize( "test2.txt" ) == 4096, "!", "@" ) /* +1 for strg-z */ 109 | ? 'leto_filesize( "test2.txt" ) - ' 110 | ?? leto_filesize( "test2.txt" ) 111 | cBuf := leto_memoread( "test2.txt" ) 112 | IF cBuf == REPLICATE( "B", 4095 ) 113 | ?? " fine" 114 | else 115 | ?? " wrong" 116 | ENDIF 117 | 118 | #ifndef __XHARBOUR__ 119 | ? 'leto_FCreate( "test3.txt" ) - ' 120 | nHandle := leto_FCreate( "test3.txt" ) 121 | ?? Iif( nHandle >= 0, "Ok", "Failure -- no further tests leto_F*() test" ) 122 | IF nHandle >= 0 123 | ? "Press any key to continue..." 124 | Inkey( 0 ) 125 | ? 'leto_FClose( nHandle ) - ' 126 | ?? IiF( leto_FClose( nHandle ), "Ok", "Failure" ) 127 | ?? IiF( ! leto_FClose( nHandle ), "!", "Fail" ) 128 | ? 'leto_FOpen( "test3.txt", READWRITE ) - ' 129 | nHandle := leto_FOpen( "test3.txt", FO_READWRITE ) 130 | ?? Iif( nHandle >= 0, "Ok", "Failure" ) 131 | IF nHandle >= 0 132 | ? 'leto_FWrite( nHandle, "testx12" ) - ' 133 | nTmp := leto_FWrite( nHandle, "testx21" ) 134 | ?? Iif( nTmp == 7, "Ok", "Failure" ) 135 | ? 'leto_FSeek( nHandle, 4, 0 ) - ' 136 | nTmp := leto_FSeek( nHandle, 4, 0 ) 137 | ?? Iif( nTmp == 4, "Ok", "Failure" ) 138 | leto_FWrite( nHandle, "3" ) 139 | ? 'leto_FSeek( nHandle, 0, 2 ) - ' 140 | nTmp := leto_FSeek( nHandle, 0, 2 ) 141 | ?? Iif( nTmp == 7, "Ok", "Failure" ) 142 | ?? " --- EOF - " + IiF( LETO_FEOF( nHandle ), "Ok", "Failure" ) 143 | leto_FWrite( nHandle, "0" + CHR( 0 ) ) 144 | cBuf := SPACE( 12 ) 145 | leto_FSeek( nHandle, 0, 0 ) 146 | ? 'leto_FRead( nHandle, @cBuf, 10 ) - ' 147 | nTmp := leto_FRead( nHandle, @cBuf, 10 ) 148 | ?? Iif( nTmp == 9, "Ok", "Failure" ) 149 | ?? Iif( LEN( cBuf ) == 12 .AND. LEFT( cBuf, 9 ) == "test3210" + CHR( 0 ), " !!", "" ) 150 | leto_FSeek( nHandle, 0, 0 ) 151 | ? 'leto_FReadSTR( nHandle, 10 ) - ' 152 | cBuf := leto_FReadStr( nHandle, 10 ) 153 | ?? Iif( LEN( cBuf ) == 8 .AND. LEFT( cBuf, 8 ) == "test3210", "Ok", "Failure" ) 154 | leto_FSeek( nHandle, 0, 0 ) 155 | ? 'leto_FReadLEN( nHandle, 10 ) - ' 156 | cBuf := leto_FReadLen( nHandle, 10 ) 157 | ?? Iif( LEN( cBuf ) == 9 .AND. LEFT( cBuf, 9 ) == "test3210" + CHR( 0 ), "Ok", "Failure" ) 158 | leto_FClose( nHandle ) 159 | ? 160 | ENDIF 161 | ? "Press any key to continue..." 162 | Inkey( 0 ) 163 | leto_FErase( "test3.txt" ) 164 | ENDIF 165 | #endif 166 | 167 | ? 'leto_DirMake( "TEST" ) - ' 168 | ?? Iif( leto_DirMake( "TEST" ) == 0, "Ok", "Failure" ) 169 | ?? Iif( leto_DirExist( "TEST" ), " verified", "!" ) 170 | ? 'leto_DirRemove( "TEST" ) - ' 171 | ?? Iif( leto_DirRemove( "TEST" ) == 0, "Ok", "Failure" ) 172 | ?? Iif( ! leto_DirExist( "TEST" ), " verified", "!" ) 173 | 174 | ? "Press any key to continue..." 175 | ? 176 | #ifndef __XHARBOUR__ 177 | arr := leto_directory( "*" ) 178 | ? 'leto_directory(): (' + Ltrim(Str(Len(arr))) + ")" 179 | Inkey( 0 ) 180 | ? "found files: " 181 | FOR i := 1 TO Len( arr ) 182 | ?? arr[i,1] + "; " 183 | NEXT 184 | ? "----------" 185 | ? "Press any key to continue..." 186 | #endif 187 | 188 | ? 'leto_ferase( "test2.txt" ) - ' 189 | ?? Iif( leto_fErase( "test2.txt" ) == 0, "Ok", "Failure" ) 190 | leto_fErase( "test1.txt" ) 191 | ? 192 | 193 | IF ! "mono-socket" $ LETO_GETCLIENTMODE() .AND. LETO_UDFEXIST( "LETO_GETAPPOPTIONS" ) 194 | ? "Test of working error-message (RTE) from server" 195 | ? "You should see a RTE after next key ! - ! CHOOSE TO CONTINUE" 196 | ? "Press any key to continue ..." 197 | Inkey( 0 ) 198 | 199 | /* option 42 writes an entry in the log file at server and produces an RTE for application */ 200 | LETO_UDF( "{|| LETO_GETAPPOPTIONS(42) }" ) 201 | ELSE 202 | ? "No RTE error test possible ..." 203 | IF "mono-socket" $ LETO_GETCLIENTMODE() 204 | ? "... because of using single socket connection to server" 205 | ENDIF 206 | IF ! LETO_UDFEXIST( "LETO_GETAPPOPTIONS" ) 207 | ? "... because of UDF-functions disabled in server config .ini" 208 | ENDIF 209 | ENDIF 210 | 211 | ? "Press any key to finish..." 212 | Inkey( 0 ) 213 | 214 | Return Nil 215 | --------------------------------------------------------------------------------