From 8dcaa95da6b096cd6830d870112f1307e6ce2a82 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 26 Jun 2008 10:28:07 +0000 Subject: [PATCH] 2008-06-26 12:25 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * contrib/hbmysql/mysql.c * contrib/hbmysql/tmysql.prg * contrib/hbmsql/msql.c * contrib/hbmsql/tmsql.prg ! Fixed again to use hb_parptr()/hb_retptr() instead of hb_parnl()/hb_retnl(). This fixes these libs on 64 bit systems. This is an INCOMPATIBLE change, users of these libs will have to update their code when dealing with return values of the following functions: - hbmysql / SQLCONNECT() - hbmysql / SQLSTORER() - hbmysql / SQLUSERES() - hbmsql / MSQLSTORER() - hbmsql / MSQLLISTFI() They will now return pointer type instead of a number, so error checking will have to be changed from r > 0, r ==/=/!=/> 0 to !Empty( r ). ; Please test. * contrib/hbgf/hbgfw32/win32.c * contrib/hbgf/hbgfos2/os2pm.c * contrib/hbgf/hbgfos2/os2pm.ch * Some cleanups. ; Please test for OS/2. --- harbour/ChangeLog | 27 ++++++++ harbour/contrib/hbgf/hbgfos2/os2pm.c | 90 ++++++++++++--------------- harbour/contrib/hbgf/hbgfos2/os2pm.ch | 1 - harbour/contrib/hbgf/hbgfw32/win32.c | 16 ++--- harbour/contrib/hbmsql/msql.c | 4 +- harbour/contrib/hbmsql/tmsql.prg | 4 +- harbour/contrib/hbmysql/mysql.c | 4 +- harbour/contrib/hbmysql/tmysql.prg | 6 +- 8 files changed, 84 insertions(+), 68 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6d7a648022..26b94e5bdd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,33 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-26 12:25 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * contrib/hbmysql/mysql.c + * contrib/hbmysql/tmysql.prg + * contrib/hbmsql/msql.c + * contrib/hbmsql/tmsql.prg + ! Fixed again to use hb_parptr()/hb_retptr() + instead of hb_parnl()/hb_retnl(). This fixes these libs + on 64 bit systems. + This is an INCOMPATIBLE change, users of these libs will + have to update their code when dealing with return values + of the following functions: + - hbmysql / SQLCONNECT() + - hbmysql / SQLSTORER() + - hbmysql / SQLUSERES() + - hbmsql / MSQLSTORER() + - hbmsql / MSQLLISTFI() + They will now return pointer type instead of a number, + so error checking will have to be changed from r > 0, + r ==/=/!=/> 0 to !Empty( r ). + ; Please test. + + * contrib/hbgf/hbgfw32/win32.c + * contrib/hbgf/hbgfos2/os2pm.c + * contrib/hbgf/hbgfos2/os2pm.ch + * Some cleanups. + ; Please test for OS/2. + 2008-06-26 11:47 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbmsql/msql.c ! changed msqlGetErrMsg( NULL ) => msqlErrMsg diff --git a/harbour/contrib/hbgf/hbgfos2/os2pm.c b/harbour/contrib/hbgf/hbgfos2/os2pm.c index e742119df4..36941ed846 100644 --- a/harbour/contrib/hbgf/hbgfos2/os2pm.c +++ b/harbour/contrib/hbgf/hbgfos2/os2pm.c @@ -52,8 +52,6 @@ * */ - - #define INCL_BASE #define INCL_PM #include @@ -70,12 +68,13 @@ MRESULT EXPENTRY WndProc( HWND, ULONG, MPARAM, MPARAM ); MRESULT EXPENTRY WndProc( HWND hWnd, ULONG Msg, MPARAM mp1, MPARAM mp2 ) { - static PHB_DYNS pDynSym = 0; + static PHB_DYNS s_pDynSym = 0; + MRESULT mResult; HPS hps; - if( ! pDynSym ) - pDynSym = hb_dynsymFind( "HB_GUI" ); + if( ! s_pDynSym ) + s_pDynSym = hb_dynsymFind( "HB_GUI" ); switch (Msg) { @@ -87,7 +86,7 @@ MRESULT EXPENTRY WndProc( HWND hWnd, ULONG Msg, MPARAM mp1, MPARAM mp2 ) default: hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( pDynSym ) ); + hb_vmPushSymbol( hb_dynsymSymbol( s_pDynSym ) ); hb_vmPushNil(); hb_vmPushLong( (LONG) hWnd ); hb_vmPushLong( (LONG) Msg ); @@ -102,13 +101,11 @@ MRESULT EXPENTRY WndProc( HWND hWnd, ULONG Msg, MPARAM mp1, MPARAM mp2 ) return mResult; } - } HB_FUNC( WINREGISTERCLASS ) { - hb_retl( WinRegisterClass( hb_pm_GetHab(), /* anchor block handle */ hb_parc( 1 ), /* Class Name */ ( PFNWP ) WndProc, /* default Class procedure */ @@ -119,42 +116,37 @@ HB_FUNC( WINREGISTERCLASS ) HB_FUNC(WINCREATEWINDOW) { - HWND hwnd; - - hwnd = WinCreateWindow( (HWND) hb_parnl(1), /* hWnd parent */ - (PCSZ) hb_parc(2), /* pszClass */ - (PCSZ) hb_parc(3), /* pszName */ - (ULONG) hb_parnl(4), /* flStyle */ - (LONG) hb_parnl(5), /* x */ - (LONG) hb_parnl(6), /* y */ - (LONG) hb_parnl(7), /* cx */ - (LONG) hb_parnl(8), /* cy */ - (HWND) hb_parnl(9), /* hwndOwner */ - (HWND) hb_parnl(10), /* hwndInsertBehind */ - (ULONG) hb_parnl(11), /* id */ - (PVOID) hb_parnl(12), /* pCtlData, */ - (PVOID) hb_parnl(13)); /* pPresParams */ - - hb_retnl((LONG) hwnd); + hb_retnl( (LONG) WinCreateWindow( (HWND) hb_parnl(1), /* hWnd parent */ + (PCSZ) hb_parc(2), /* pszClass */ + (PCSZ) hb_parc(3), /* pszName */ + (ULONG) hb_parnl(4), /* flStyle */ + (LONG) hb_parnl(5), /* x */ + (LONG) hb_parnl(6), /* y */ + (LONG) hb_parnl(7), /* cx */ + (LONG) hb_parnl(8), /* cy */ + (HWND) hb_parnl(9), /* hwndOwner */ + (HWND) hb_parnl(10), /* hwndInsertBehind */ + (ULONG) hb_parnl(11), /* id */ + (PVOID) hb_parnl(12), /* pCtlData, */ + (PVOID) hb_parnl(13))); /* pPresParams */ } HB_FUNC( WINCREATESTDWINDOW ) { ULONG lFrame = hb_parnl( 3 ); - HWND hWndClient, hWndFrame; + HWND hWndClient; - hWndFrame = WinCreateStdWindow( ( HWND ) hb_parnl( 1 ), /* hWndParent */ - hb_parnl( 2 ), /* style */ - &lFrame, /* lFrame */ - hb_parc( 4 ), /* cClassName */ - hb_parc( 5 ), /* cCaption */ - hb_parnl( 6 ), /* lStyleClient */ - hb_parnl( 7 ), /* hModule */ - hb_parnl( 8 ), /* nId */ - ( PHWND ) &hWndClient ); /* Window client handle */ + hb_retnl( (LONG) WinCreateStdWindow( ( HWND ) hb_parnl( 1 ), /* hWndParent */ + hb_parnl( 2 ), /* style */ + &lFrame, /* lFrame */ + hb_parc( 4 ), /* cClassName */ + hb_parc( 5 ), /* cCaption */ + hb_parnl( 6 ), /* lStyleClient */ + hb_parnl( 7 ), /* hModule */ + hb_parnl( 8 ), /* nId */ + ( PHWND ) &hWndClient )); /* Window client handle */ - hb_retnl( (LONG) hWndFrame); hb_stornl( ( LONG ) hWndClient, 9 ); } @@ -166,9 +158,7 @@ HB_FUNC( HB_FORMSHOWMODAL ) WinShowWindow( ( HWND ) hb_parnl( 1 ), 1 ); while( WinGetMsg( hab, &qmsg, 0, 0, 0 ) ) - { WinDispatchMsg( hab, &qmsg ); - } } @@ -195,7 +185,7 @@ HB_FUNC( WINGETTEXT ) { BYTE bBuffer[ 255 ]; - WinQueryWindowText( ( HWND ) hb_parnl( 1 ), 254, bBuffer ); + WinQueryWindowText( ( HWND ) hb_parnl( 1 ), sizeof( bBuffer ) - 1, bBuffer ); hb_retc( bBuffer ); } @@ -210,11 +200,9 @@ HB_FUNC( MSGINFO ) } -HAB hb_pm_GetHab() { - - HWND hWnd = WinQueryActiveWindow( HWND_DESKTOP); - return WinQueryAnchorBlock(hWnd); - +HAB hb_pm_GetHab() +{ + return WinQueryAnchorBlock( WinQueryActiveWindow( HWND_DESKTOP ) ); } @@ -232,7 +220,7 @@ HB_FUNC( WINCREATEMENU ) /* Some xBase for C language */ -#define IF(x,y,z) ((x)?(y):(z)) +#define IIF(x,y,z) ((x)?(y):(z)) HB_FUNC( WINADDMENUITEM ) @@ -240,8 +228,8 @@ HB_FUNC( WINADDMENUITEM ) MENUITEM mit; mit.iPosition = hb_parni( 3 ); - mit.afStyle = IF( ISCHAR( 2 ), MIS_TEXT, MIS_SEPARATOR ); - mit.afAttribute = IF( ! hb_parl( 6 ), MIA_DISABLED, 0 ); + mit.afStyle = IIF( ISCHAR( 2 ), MIS_TEXT, MIS_SEPARATOR ); + mit.afAttribute = IIF( ! hb_parl( 6 ), MIA_DISABLED, 0 ); mit.id = hb_parni( 5 ); mit.hwndSubMenu = hb_parnl( 4 ); mit.hItem = 0; @@ -258,11 +246,11 @@ HB_FUNC( WINMAKESUBMENUITEM ) { MENUITEM mit; MRESULT rc; - char text[100]; + char text[ 100 ]; rc = WinSendMsg((HWND) hb_parnl(1), MM_QUERYITEM, MPFROM2SHORT(hb_parni(2), FALSE ), &mit ); if ((BOOL)rc) { - WinSendMsg((HWND) hb_parnl(1), MM_QUERYITEMTEXT, MPFROM2SHORT(hb_parni(2), 100), &text ); + WinSendMsg((HWND) hb_parnl(1), MM_QUERYITEMTEXT, MPFROM2SHORT(hb_parni(2), sizeof( text ) ), &text ); WinSendMsg((HWND) hb_parnl(1), MM_DELETEITEM, MPFROM2SHORT(hb_parni(2), FALSE ), 0L ); mit.hwndSubMenu = hb_parnl(3); @@ -291,8 +279,8 @@ HB_FUNC( WINSETOWNER ) HB_FUNC( WINSENDMSG ) { hb_retnl( ( LONG ) WinSendMsg( ( HWND ) hb_parnl( 1 ), hb_parnl( 2 ), - ( MPARAM ) IF( ISCHAR( 3 ), (ULONG) hb_parc( 3 ), (ULONG) hb_parnl( 3 ) ), - ( MPARAM ) IF( ISCHAR( 4 ), (ULONG) hb_parc( 4 ), (ULONG) hb_parnl( 4 ) ) ) ); + ( MPARAM ) IIF( ISCHAR( 3 ), (ULONG) hb_parc( 3 ), (ULONG) hb_parnl( 3 ) ), + ( MPARAM ) IIF( ISCHAR( 4 ), (ULONG) hb_parc( 4 ), (ULONG) hb_parnl( 4 ) ) ) ); } diff --git a/harbour/contrib/hbgf/hbgfos2/os2pm.ch b/harbour/contrib/hbgf/hbgfos2/os2pm.ch index 1fd8e03be7..af1117e86b 100644 --- a/harbour/contrib/hbgf/hbgfos2/os2pm.ch +++ b/harbour/contrib/hbgf/hbgfos2/os2pm.ch @@ -2,7 +2,6 @@ * $Id$ */ - /* * Harbour Project source code: * Harbour GUI framework for IBM OS/2 Presentation Manager diff --git a/harbour/contrib/hbgf/hbgfw32/win32.c b/harbour/contrib/hbgf/hbgfw32/win32.c index 9c1df8e540..2b88bf3ae5 100644 --- a/harbour/contrib/hbgf/hbgfw32/win32.c +++ b/harbour/contrib/hbgf/hbgfw32/win32.c @@ -52,16 +52,18 @@ */ #define _WIN32_WINNT 0x0400 -#include + +#define HB_OS_WIN_32_USED + #include "hbapi.h" #include "hbvm.h" #include "hbstack.h" -LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; +LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); HB_FUNC( WINREGISTERCLASS ) { - WNDCLASS wndclass ; + WNDCLASS wndclass; wndclass.lpszClassName = hb_parc( 1 ); wndclass.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW; // hb_parnl( 2 ); @@ -96,7 +98,7 @@ HB_FUNC( HB_FORMSHOWMODAL ) ShowWindow( ( HWND ) hb_parnl( 1 ), 1 ); while( GetMessage( &msg, NULL, 0, 0 ) ) { - TranslateMessage( &msg ); + TranslateMessage( &msg ); DispatchMessage( &msg ); } } @@ -124,7 +126,7 @@ HB_FUNC( WINGETTEXT ) { BYTE bBuffer[ 255 ]; - GetWindowText( ( HWND ) hb_parnl( 1 ), (char*) bBuffer, 254 ); + GetWindowText( ( HWND ) hb_parnl( 1 ), (char*) bBuffer, sizeof( bBuffer ) - 1 ); hb_retc( (char*) bBuffer ); } @@ -144,7 +146,7 @@ HB_FUNC( WINCREATEMENU ) /* Some xBase for C language */ -#define IF(x,y,z) ((x)?(y):(z)) +#define IIF(x,y,z) ((x)?(y):(z)) HB_FUNC( WINADDMENUITEM ) @@ -155,7 +157,7 @@ HB_FUNC( WINADDMENUITEM ) mii.cbSize = sizeof( MENUITEMINFO ); mii.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID | ((hSubMenu)? MIIM_SUBMENU:0); - mii.fState = IF( ! hb_parl( 6 ), MFS_DISABLED, 0 ); + mii.fState = IIF( ! hb_parl( 6 ), MFS_DISABLED, 0 ); mii.wID = hb_parni( 5 ); mii.hSubMenu = hSubMenu; if( ISCHAR( 2 ) ) diff --git a/harbour/contrib/hbmsql/msql.c b/harbour/contrib/hbmsql/msql.c index 2fe1c480f7..d83392a86f 100644 --- a/harbour/contrib/hbmsql/msql.c +++ b/harbour/contrib/hbmsql/msql.c @@ -60,8 +60,8 @@ #include "msql.h" -#define HB_PARPTR( n ) hb_parnl( n ) -#define HB_RETPTR( n ) hb_retnl( n ) +#define HB_PARPTR( n ) hb_parptr( n ) +#define HB_RETPTR( n ) hb_retptr( n ) HB_FUNC( MSQLCONNEC ) /* int msqlConnect(char *) */ { diff --git a/harbour/contrib/hbmsql/tmsql.prg b/harbour/contrib/hbmsql/tmsql.prg index c068449c18..33f802e442 100644 --- a/harbour/contrib/hbmsql/tmsql.prg +++ b/harbour/contrib/hbmsql/tmsql.prg @@ -381,7 +381,7 @@ METHOD New(nSocket, cQuery, cTableName) CLASS TmSQLTable nRes := msqlListFi(nSocket, cTableName) - if nRes > 0 + if !Empty( nRes ) for i := 1 to msqlNumFie(nRes) aField := msqlFetchF(nRes) // don't count indexes as real fields @@ -804,7 +804,7 @@ METHOD TableStruct(cTable) CLASS TmSQLServer aStruct := {} nRes := msqlListFi(::nSocket, cTable) - if nRes > 0 + if !Empty( nRes ) for i := 1 to msqlNumFie(nRes) aField := msqlFetchF(nRes) diff --git a/harbour/contrib/hbmysql/mysql.c b/harbour/contrib/hbmysql/mysql.c index 13aea71e89..c9b272dd8c 100644 --- a/harbour/contrib/hbmysql/mysql.c +++ b/harbour/contrib/hbmysql/mysql.c @@ -75,8 +75,8 @@ /* TODO: Use hb_retptrGC() */ -#define HB_PARPTR( n ) hb_parnl( n ) -#define HB_RETPTR( n ) hb_retnl( n ) +#define HB_PARPTR( n ) hb_parptr( n ) +#define HB_RETPTR( n ) hb_retptr( n ) HB_FUNC( SQLVERSION ) /* long mysql_get_server_version( MYSQL * ) */ { diff --git a/harbour/contrib/hbmysql/tmysql.prg b/harbour/contrib/hbmysql/tmysql.prg index cd4a9b379f..c9e43958d7 100644 --- a/harbour/contrib/hbmysql/tmysql.prg +++ b/harbour/contrib/hbmysql/tmysql.prg @@ -350,7 +350,7 @@ METHOD New(nSocket, cQuery) CLASS TMySQLQuery if (rc := sqlQuery(nSocket, cQuery)) == 0 // save result set - if (::nResultHandle := sqlStoreR(nSocket)) > 0 + if !Empty(::nResultHandle := sqlStoreR(nSocket)) ::nNumRows := sqlNRows(::nResultHandle) ::nNumFields := sqlNumFi(::nResultHandle) @@ -1373,7 +1373,7 @@ METHOD New(cServer, cUser, cPassword) CLASS TMySQLServer ::nSocket := sqlConnect(cServer, cUser, cPassword) ::lError := .F. - if ::nSocket == 0 + if Empty( ::nSocket ) ::lError := .T. endif @@ -1622,7 +1622,7 @@ METHOD Error() CLASS TMySQLServer ::lError := .F. -return iif(::nSocket > 0, sqlGetErr(::nSocket), "No connection to server") +return iif(Empty( ::nSocket ), "No connection to server", sqlGetErr(::nSocket)) METHOD ListDBs() CLASS TMySQLServer