Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xHarbour compatibility restored #27

Open
elchs opened this issue May 23, 2023 · 9 comments
Open

xHarbour compatibility restored #27

elchs opened this issue May 23, 2023 · 9 comments

Comments

@elchs
Copy link
Owner

elchs commented May 23, 2023

Hi Numerabilis,

xHarbour 'downward' compatibility have got lost over the time,
No wonder, as there wasn't any feedback from them since Patrick Mast asked me years ago.
it caused me significant work to restore it ...
But now again i can produce a rddleto.lib with 'no real warnings' ... ;-)

#) As there is no 'hb_znet' for z-lib compressed network traffic in xHarbour,
they * must * use my LZ4 implementation for that.
Network encrypted traffic is bound in LetoDBf to traffic compression,
as else you can easyily live without compression for that.
Data compression is else applied at some very specific points in LetoDBf, so in the end you will want to have that.

**
Until now LZ4 is NOT working for xHarbour - it works absolutely great for Harbour,
even for BCC 5.8.2.
In xHarbour it leads to a GPF crash of the app when activated.
I still haven't found the origin cause for that - sadly there is no Valgrind for Windows.
The problem could be bound to specific C-compilers for xHarbour,
or more propably the problem is inside LetoDBf/ LZ4.
Could be even an easy silly bug, and i just don't recognize it -- need more time to find the bug, tips extremely welcome.
**

So for testing purpose, to let us go on, i created dummy LZ4 functions so that the app can build.
This is done by setting the 'LZ4_DUMMY' flag for c-source and leaving away the lz4.c so far.

I uploaded a new xBuilder rddleto.lib.xbp definition for xHB,
as also a new make_b32.bat for BCC >= 5.8.2 for xharbour -- use it without any argument to get a rddleto.lib.

PellesC makes me headaches, even newest Harbour itself can not be build from source with it out the box.
The C-compiler have some serious problems, at very least about complex 'pre-processor directives',
[ that are e.g. these '#if defined ( xxx ) && ( xxx > y ) .. and more complex ones ]
Older versions of PellesC just produce garbage from lz4.c.

--
The whole section in the Readme.txt for xHarbour needs rework -- suggestions welcome !
Also i would be kindly interested about how you are building the final app,
as no xHarbour version has this abolutely famous 'hbmk2' make tool by Szakats from Harbour.

By the way, you are using xHB or xharbour ?

best regards
elch

@Numerabilis
Copy link

I´m very excited to download it again and give it another try to compile with xharbour, very happy to hear that news!
I´m using xharbour v1.2.3 with BCC 5.8. I downloaded it from http://www.xharbour.org/index.asp?page=download/windows/binaries_win
But now they are on a new version and not using BCC 5.8 anymore, only bcc 7. Then I decided to make this last version with BCC58 avaiable in my site: https://linguagemclipper.com.br/dicas/xharbour/download

@Numerabilis
Copy link

Numerabilis commented Jun 7, 2023

Hooray! ...;-)

make_b32 all
I got it! leto.lib and rddleto.lib are done!!! Aleluia!!!!
Unafortunatelly it seems that there is something missing when I compiled my program with the libs as seen below:

Imagem do WhatsApp de 2023-06-07 à(s) 22 58 06

Well, in my system I did this before FUNCTION MAIN():

`*****************************************************	
*** DEFINIR TIPO DE BANCO DE DADOS PADRÃO: DBFCDX ***
*****************************************************
ANNOUNCE RDDSYS
REQUEST DBFCDX
ANNOUNCE FPTCDX
REQUEST DBFFPT
Request ordfor
**********************************
*** CODEPAGE E CHARSET
**********************************
REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_PT850 // PARA INDEXAR CAMPOS ACENTUADOS
**********************************
*** SERVIDOR DE BANCO DE DADOS ***
**********************************
#IFDEF __LETODBF
	// servidor LETODBF
	#include "rddleto.ch"
	#include "dbinfo.ch"
	REQUEST LETO
#ENDIF	

And then after FUNCTION MAIN():

***************************************************
*** CONFIGURAÇÃO DO BANCO DE DADOS PADRÃO *********
***************************************************
RDDSETDEFAULT("DBFCDX")
RDDREGISTER( "DBFCDX", 1 ) // RDT_FULL
SET AUTOPEN OFF
SET OPTIMIZE ON
SET HARDCOMMIT OFF // É MELHOR DAR UM DBCOMMIT() NO FINAL DE CADA TAREFA
SET DELETED ON
***************************************************
*** IDIOMA PORTUGUÊS, CHARSET 850 *****************
***************************************************
HB_LangSelect("PT")
HB_SetCodePage("PT850")  // PARA INDEXAR CAMPOS ACENTUADOS
SET(_SET_LANGUAGE, "PT") // XHB 100 
***************************************************

And forwards:

`* CAMINHO DO SISTEMA *
* ================== *
cAMBI   := GETENV("CONTROLI") // PASTA DE DADOS PERSONALIZADA
xPATH   := cAMBI              // PASTA DADOS
cSERVER := GETENV("SERVER")   // CAMINHO DO SERVIDOR

IF !EMPTY(cSERVER)
	// CAMINHO DA BASE DE DADOS
	xPath := "//127.0.0.1:2812/" // DEFAULT	
	xPATH := cSERVER	
    xPath := "//" + xPath + IiF( ":" $ xPath, "", ":" + ALLTRIM( STR( nPort ) ) )
    xPath += Iif( Right(xPath,1) == "/", "", "/" )
ELSE
	xPath := "//localhost:2812/"
ENDIF

cDBFUSER := ""
cDBFPASS := ""
#IFDEF __LETODBF
	** LETODBF
	**********
	RDDSETDEFAULT( "LETO" )	
	// FAZ CONEXÃO
	IF leto_Connect( xPath, cDBFUSER, cDBFPASS, nTimeOut, nHotBuf) == -1
		ALERT("Nenhum LetoDBF Server encontrado - Erro: " + leto_Connect_Err( .T. ) )
		QUIT
	ELSE
		// SERVIDOR LETODBF
		? LETO_GetServerVersion(), " at address: ", Leto_getLocalIP( .T. )
		LETO_DBDRIVER( "DBFCDX", "SMT", 512 )
		
		/* alternative: RddInfo( RDDI_MEMOTYPE, DB_MEMO_SMT ); RddInfo( RDDI_MEMOBLOCKSIZE, 512 ) */
		? "DBF DATABASE DRIVER        :", LETO_DBDRIVER()[ 1 ], "MEMOTYPE:", LETO_DBDRIVER()[ 2 ]
		
		LETO_TOGGLEZIP( 1 )
		
		? "NETWORK TRAFFIC COMPRESSION:", Iif( LETO_TOGGLEZIP() > 0, "ON", "OFF" )
		? "RDD: ", RddSetDefault(),  " , DBF EXTENSION:", hb_rddInfo( RDDI_TABLEEXT )
		? "Lockscheme    :", hb_rddInfo( RDDI_LOCKSCHEME ),;
			IiF( RddSetDefault() == "LETO", Leto_UDF( "DbInfo", DBI_LOCKSCHEME ), DbInfo( DBI_LOCKSCHEME ) )
		? "Memo extension:", Padl( hb_rddInfo( RDDI_MEMOEXT ), 10 ), Padl( DbInfo( DBI_MEMOEXT ), 10 )
		? "     blocksize:", hb_rddInfo( RDDI_MEMOBLOCKSIZE ),;
			IiF( RddSetDefault() == "LETO", Leto_UDF( "DbInfo", DBI_MEMOBLOCKSIZE ), DbInfo( DBI_MEMOBLOCKSIZE ) )		
	ENDIF
#ENDIF	

SET DEFAULT TO (xPATH)
? "SET DEFAULT TO: "+xPATH`

@elchs
Copy link
Owner Author

elchs commented Jun 9, 2023

Hi Numerabilis,

i recently have excluded function: Leto_GetLocalIP() for xharbour, to spare 2 Windows ! libs
iphlpapi.lib and ws2_32.lib
But it seems that they are nevertheless needed to be linked for the application.
So i will re-activate the LETO function for xharbour with next upload.

You only need the rddleto.lib for [x]harbour.


Meanwhile i am on the track what goes wrong for xharbour related to LZ4.
It is about 4-bytes versus 8-bytes numeric values.
Xharbour commonly uses type 'ULONG' which is internally 4 bytes long, but also knows Harbour type 'HB_ULONG',
which is 8-bytes long for Windows 64-bit build -- and HB_ULONG type is used in LetoDBf.
When the LETO compression function is called with a 4-bytes long value, but the function expects an 8-bytes long argumernt,
the next argument in sequence for the function gets lost, as it is transferred into the upper 4-bytes of the numeric argument.
I am still thinking about how to * best * solve that length problem.
Expect in the next few days a new version upload fixing that LZ4 problem.
Do not use the actual version for production !, as there is a bug around newly LZ4_DUMMY usage in relation to MEMO fields
Also that will be fixed with next upload.


About C-compilers: these stand between your [plus xharbour] source code and your machine CPU.
So a BCC v5.8.2 already knows a Pentium-Pro ['P6] ;-)
-- and misses the capabilities of nearly 2 decades about CPU development.

best regards
elch

@elchs elchs closed this as completed Jun 9, 2023
@elchs elchs reopened this Jun 9, 2023
@Numerabilis
Copy link

May God give you wisdom! I wish you best luck!

@Numerabilis
Copy link

Numerabilis commented Jun 9, 2023

rddleto
If I link only rddleto.lib also shows these errors.

I simplified my code as below. The only function I call is leto_Connect() and leto_Connect_Err()

#IFDEF __LETODBF
	** LETODBF
	**********
	// FAZ CONEXÃO
	IF leto_Connect( xPath, cDBFUSER, cDBFPASS, nTimeOut, nHotBuf) == -1
		ALERT("Nenhum LetoDBF Server encontrado - Erro: " + leto_Connect_Err( .T. ) )
		QUIT
	ENDIF
#ENDIF	

@elchs
Copy link
Owner Author

elchs commented Jun 10, 2023

Hi Numerabilis,

as explained in last post: two Windows libraries must be linked.

Scroll down to the very bottom, there -> : Requirements : Library
https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaioctl
https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersinfo

Tl;Dr; -- Ws2_32.lib, Iphlpapi.lib in BCC58/lib/PSDK

@Numerabilis
Copy link

Numerabilis commented Jun 10, 2023

Ok, thanks!
I had to include these 2 libs with a blank space in USERLIBS with HBMAKE as shown in the image below:
leto-externals

But before I had to change my 3 CFG files from BCC58/BIN to include the "BCC58/lib/PSDK" path as shown below:
BCC32.CFG

-I"C:\bcc58\include;C:\bcc58\include\dinkumware"
-L"C:\bcc58\lib;C:\BCC58\lib\psdk"

ILINK32.CFG
-L"C:\bcc58\lib;C:\BCC58\lib\psdk"

TLINK.CFG
/LC:\BCC58\lib;C:\BCC58\lib\psdk

Then it compiled with no errors! Hooray!
Tutorial in Portuguese-BR: Tutorial LetoDBf como serviço do Windows

@Numerabilis
Copy link

Numerabilis commented Jun 10, 2023

i recently have excluded function: Leto_GetLocalIP() for xharbour, to spare 2 Windows ! libs
iphlpapi.lib and ws2_32.lib

Well, LETO_GETLOCALIP won´t exist in xHarbour but I still had to link those 2 Windows LIBs. I thought you meant I wouldn´t need them anymore.
As I had to link them so could you restore that function again?

@Numerabilis
Copy link

LETO_DIRECTORY() is not working on xharbour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants