From ffc82a2bfd8b2124f05aaf2f303eb1db447faaf6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 8 Mar 2010 11:32:16 +0000 Subject: [PATCH] 2010-03-08 12:28 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/diskspac.c * src/rtl/disksphb.c + Added comment about the reason why GetDiskFreeSpaceEx() is called dynamically (win95 first edition support). + Added support for HB_NO_WIN95 build-time flag to drop Win95 compatibility. Unfortunately current dynamic load trick fails with UNICOWS, returning zero for disk space related calls in this scenario. If we drop the dynamic call, we lose support for Win95 first edition, but these functions will work properly on Win95b/98/ME in return. I'm still thinking about it, but maybe it's better to drop Win95 first edition support altogether and make newer versions work properly. Any opinions? * contrib/hbwin/wapi_winbase.c * contrib/hbwin/wapi_wingdi_font.c ! Fixed to use WIDE/ANSI versions of dynamically executed functions according to UNICODE setting. * bin/hb-mkdyn.sh * bin/hb-func.sh * utils/hbmk2/hbmk2.prg * config/win/global.mk ! Stepping back to link against wsock32 instead of ws2_32. The only reason is Win95 (even OSR2) compatibility. This is a little bit less efficient unfortunately. * src/rtl/hbsocket.c ! Fixed to use WSAioctl via dynamic call for non WinCE builds, and if HB_NO_WIN95 macro is no defined. WSAioctl is present in ws2_32.dll, which .dll isn't available on Win95. ; Not tested since I don't know how to test it, pls review and test. ; NOTE: There seem to exist a package which add ws2_32 support for Win95, but I couldn't find it, if someone has, we can drop this ugly trick and simply document the requirement. * src/rtl/gtwin/gtwin.c * Formatting. --- harbour/ChangeLog | 43 ++++++++++++++++++++++++ harbour/bin/hb-func.sh | 4 +-- harbour/bin/hb-mkdyn.sh | 2 +- harbour/config/win/global.mk | 4 +-- harbour/contrib/hbwin/wapi_winbase.c | 6 +++- harbour/contrib/hbwin/wapi_wingdi_font.c | 14 ++++++-- harbour/src/rtl/diskspac.c | 4 ++- harbour/src/rtl/disksphb.c | 4 ++- harbour/src/rtl/gtwin/gtwin.c | 2 +- harbour/src/rtl/hbsocket.c | 9 +++++ harbour/utils/hbmk2/hbmk2.prg | 2 +- 11 files changed, 82 insertions(+), 12 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 24fdfb58d9..9701023522 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,49 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-03-08 12:28 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/diskspac.c + * src/rtl/disksphb.c + + Added comment about the reason why GetDiskFreeSpaceEx() + is called dynamically (win95 first edition support). + + Added support for HB_NO_WIN95 build-time flag to drop + Win95 compatibility. Unfortunately current dynamic load + trick fails with UNICOWS, returning zero for disk + space related calls in this scenario. If we drop the + dynamic call, we lose support for Win95 first edition, + but these functions will work properly on Win95b/98/ME + in return. I'm still thinking about it, but maybe it's + better to drop Win95 first edition support altogether + and make newer versions work properly. Any opinions? + + * contrib/hbwin/wapi_winbase.c + * contrib/hbwin/wapi_wingdi_font.c + ! Fixed to use WIDE/ANSI versions of dynamically executed + functions according to UNICODE setting. + + * bin/hb-mkdyn.sh + * bin/hb-func.sh + * utils/hbmk2/hbmk2.prg + * config/win/global.mk + ! Stepping back to link against wsock32 instead of ws2_32. + The only reason is Win95 (even OSR2) compatibility. + This is a little bit less efficient unfortunately. + + * src/rtl/hbsocket.c + ! Fixed to use WSAioctl via dynamic call for non WinCE + builds, and if HB_NO_WIN95 macro is no defined. + WSAioctl is present in ws2_32.dll, which .dll isn't + available on Win95. + ; Not tested since I don't know how to test it, pls + review and test. + ; NOTE: There seem to exist a package which add ws2_32 + support for Win95, but I couldn't find it, if + someone has, we can drop this ugly trick and + simply document the requirement. + + * src/rtl/gtwin/gtwin.c + * Formatting. + 2010-03-08 09:48 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/gtqtc/gtqtcs.hbc * contrib/hbqt/gtqtc/gtqtc.hbc diff --git a/harbour/bin/hb-func.sh b/harbour/bin/hb-func.sh index 0d7d07d0fb..a261515761 100755 --- a/harbour/bin/hb-func.sh +++ b/harbour/bin/hb-func.sh @@ -209,7 +209,7 @@ mk_hbtools() fi if [ "${HB_COMPILER}" = "mingw" ] || \ [ "${HB_COMPILER}" = "mingw64" ]; then - HB_SYS_LIBS="${HB_SYS_LIBS} -luser32 -lwinspool -lgdi32 -lcomctl32 -ladvapi32 -lcomdlg32 -lole32 -loleaut32 -luuid -lws2_32" + HB_SYS_LIBS="${HB_SYS_LIBS} -luser32 -lwinspool -lgdi32 -lcomctl32 -ladvapi32 -lcomdlg32 -lole32 -loleaut32 -luuid -lwsock32" elif [ "${HB_COMPILER}" = "mingwarm" ]; then HB_SYS_LIBS="${HB_SYS_LIBS} -lwininet -lws2 -lcommdlg -lcommctrl -luuid -lole32 -loleaut32" elif [ "${HB_COMPILER}" = "djgpp" ]; then @@ -823,7 +823,7 @@ mk_hblibso() hb_libs="${hb_libs//hbzlib/}" fi if [ "${HB_COMPILER}" = "mingw" ] || [ "${HB_COMPILER}" = "mingw64" ]; then - linker_options="${linker_options} -luser32 -lwinspool -lgdi32 -lcomctl32 -ladvapi32 -lcomdlg32 -lole32 -loleaut32 -luuid -lws2_32" + linker_options="${linker_options} -luser32 -lwinspool -lgdi32 -lcomctl32 -ladvapi32 -lcomdlg32 -lole32 -loleaut32 -luuid -lwsock32" elif [ "${HB_COMPILER}" = "mingwarm" ]; then linker_options="${linker_options} -lwininet -lws2 -lcommdlg -lcommctrl -luuid -lole32 -loleaut32" elif [ "${HB_COMPILER}" = "djgpp" ]; then diff --git a/harbour/bin/hb-mkdyn.sh b/harbour/bin/hb-mkdyn.sh index bea15a8351..845d197d7d 100755 --- a/harbour/bin/hb-mkdyn.sh +++ b/harbour/bin/hb-mkdyn.sh @@ -137,7 +137,7 @@ elif [ "${SLIB_EXT}" = ".dll" ]; then if [ "$HB_COMPILER" = "mingwarm" ]; then SYSLIBS="-lws2" else - SYSLIBS="-luser32 -lws2_32 -ladvapi32 -lgdi32" + SYSLIBS="-luser32 -lwsock32 -ladvapi32 -lgdi32" fi # -Wl,--output-def,testdll.def,--out-implib,libtestdll.a ${HB_CCPATH}${HB_CCPREFIX}gcc -shared -o "${FULLNAME}" $OBJLST ${linker_options} ${HB_USER_DFLAGS} ${SYSLIBS} ${HB_DLLIBS} && \ diff --git a/harbour/config/win/global.mk b/harbour/config/win/global.mk index b68104fae3..dff4e81ec7 100644 --- a/harbour/config/win/global.mk +++ b/harbour/config/win/global.mk @@ -11,7 +11,7 @@ HB_GT_LIBS += gtwvt gtgui gtwin # kernel32: needed by some compilers (pocc/watcom) # user32: *Clipboard*(), GetKeyState(), GetKeyboardState(), SetKeyboardState(), gtwvt stuff -# ws2_32: hbsocket +# wsock32: hbsocket # advapi32: GetUserName() # gdi32: gtwvt -SYSLIBS += kernel32 user32 ws2_32 advapi32 gdi32 +SYSLIBS += kernel32 user32 wsock32 advapi32 gdi32 diff --git a/harbour/contrib/hbwin/wapi_winbase.c b/harbour/contrib/hbwin/wapi_winbase.c index 41439887a9..f8affe788e 100644 --- a/harbour/contrib/hbwin/wapi_winbase.c +++ b/harbour/contrib/hbwin/wapi_winbase.c @@ -366,7 +366,11 @@ HB_FUNC( WAPI_GETLONGPATHNAME ) { s_getPathNameAddr = ( _HB_GETPATHNAME ) GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ), - "GetLongPathName" ); +#if defined( UNICODE ) + "GetLongPathNameW" ); +#else + "GetLongPathNameA" ); +#endif if( !s_getPathNameAddr ) s_getPathNameAddr = GetShortPathName; } diff --git a/harbour/contrib/hbwin/wapi_wingdi_font.c b/harbour/contrib/hbwin/wapi_wingdi_font.c index 53c6abb536..85e1276608 100644 --- a/harbour/contrib/hbwin/wapi_wingdi_font.c +++ b/harbour/contrib/hbwin/wapi_wingdi_font.c @@ -63,7 +63,12 @@ HB_FUNC( WAPI_ADDFONTRESOURCEEX ) static _HB_ADDFONTRESOURCEEX s_pAddFontResourceEx = NULL; if( ! s_pAddFontResourceEx ) - s_pAddFontResourceEx = ( _HB_ADDFONTRESOURCEEX ) GetProcAddress( GetModuleHandle( TEXT( "gdi32.dll" ) ), "AddFontResourceEx" ); + s_pAddFontResourceEx = ( _HB_ADDFONTRESOURCEEX ) GetProcAddress( GetModuleHandle( TEXT( "gdi32.dll" ) ), +#if defined( UNICODE ) + "AddFontResourceExW" ); +#else + "AddFontResourceExA" ); +#endif if( s_pAddFontResourceEx ) { @@ -88,7 +93,12 @@ HB_FUNC( WAPI_REMOVEFONTRESOURCEEX ) static _HB_REMOVEFONTRESOURCEEX s_pRemoveFontResourceEx = NULL; if( ! s_pRemoveFontResourceEx ) - s_pRemoveFontResourceEx = ( _HB_REMOVEFONTRESOURCEEX ) GetProcAddress( GetModuleHandle( TEXT( "gdi32.dll" ) ), "RemoveFontResourceEx" ); + s_pRemoveFontResourceEx = ( _HB_REMOVEFONTRESOURCEEX ) GetProcAddress( GetModuleHandle( TEXT( "gdi32.dll" ) ), +#if defined( UNICODE ) + "RemoveFontResourceExW" ); +#else + "RemoveFontResourceExA" ); +#endif if( s_pRemoveFontResourceEx ) { diff --git a/harbour/src/rtl/diskspac.c b/harbour/src/rtl/diskspac.c index a2eb74cbda..7dd837f15c 100644 --- a/harbour/src/rtl/diskspac.c +++ b/harbour/src/rtl/diskspac.c @@ -144,7 +144,7 @@ HB_FUNC( DISKSPACE ) lpPath[ 2 ] = TEXT( '\\' ); lpPath[ 3 ] = TEXT( '\0' ); -#if defined( HB_OS_WIN_CE ) +#if defined( HB_OS_WIN_CE ) || defined( HB_NO_WIN95 ) bError = ! GetDiskFreeSpaceEx( lpPath, ( PULARGE_INTEGER ) &i64FreeBytesToCaller, @@ -153,6 +153,8 @@ HB_FUNC( DISKSPACE ) if( ! bError ) dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller ); #else + /* NOTE: We need to call this function dynamically to maintain support + Win95 first edition. It was introduced in Win95B (aka OSR2) [vszakats] */ { typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER ); diff --git a/harbour/src/rtl/disksphb.c b/harbour/src/rtl/disksphb.c index 74f7ace31f..c126db19da 100644 --- a/harbour/src/rtl/disksphb.c +++ b/harbour/src/rtl/disksphb.c @@ -180,7 +180,7 @@ HB_FUNC( HB_DISKSPACE ) LPTSTR lpPath = HB_TCHAR_CONVTO( szPath ); -#if defined( HB_OS_WIN_CE ) +#if defined( HB_OS_WIN_CE ) || defined( HB_NO_WIN95 ) fResult = GetDiskFreeSpaceEx( lpPath, ( PULARGE_INTEGER ) &i64FreeBytesToCaller, @@ -211,6 +211,8 @@ HB_FUNC( HB_DISKSPACE ) } } #else + /* NOTE: We need to call this function dynamically to maintain support + Win95 first edition. It was introduced in Win95B (aka OSR2) [vszakats] */ { typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER ); diff --git a/harbour/src/rtl/gtwin/gtwin.c b/harbour/src/rtl/gtwin/gtwin.c index 30445a6cea..66929f0f99 100644 --- a/harbour/src/rtl/gtwin/gtwin.c +++ b/harbour/src/rtl/gtwin/gtwin.c @@ -225,7 +225,7 @@ typedef struct _CLIPKEYCODE /* Keypad keys */ -static const CLIPKEYCODE stdKeyTab[CLIP_STDKEY_COUNT] = { +static const CLIPKEYCODE stdKeyTab[ CLIP_STDKEY_COUNT ] = { { 32, 0, 0, 0, 0}, /* ' ' */ { 33, 0, 0, 0, 0}, /* '!' */ { 34, 0, 0, 0, 0}, /* '"' */ diff --git a/harbour/src/rtl/hbsocket.c b/harbour/src/rtl/hbsocket.c index ec81d1c0e9..bcad31f720 100644 --- a/harbour/src/rtl/hbsocket.c +++ b/harbour/src/rtl/hbsocket.c @@ -3199,8 +3199,17 @@ PHB_ITEM hb_socketGetIFaces( int af, HB_BOOL fNoAliases ) void * pBuffer = hb_xgrab( dwBuffer ); LPINTERFACE_INFO pIfInfo = ( LPINTERFACE_INFO ) pBuffer; +#if defined( HB_OS_WIN_CE ) || defined( HB_NO_WIN95 ) if( WSAIoctl( sd, SIO_GET_INTERFACE_LIST, NULL, 0, pIfInfo, dwBuffer, &dwBuffer, 0, 0 ) != SOCKET_ERROR ) +#else + LPFN_WSAIOCTL pWSAIoctl = + ( LPFN_WSAIOCTL ) GetProcAddress( GetModuleHandle( TEXT( "ws2_32.dll" ) ), "WSAIoctl" ); + + if( pWSAIoctl && + pWSAIoctl( sd, SIO_GET_INTERFACE_LIST, NULL, 0, pIfInfo, dwBuffer, + &dwBuffer, 0, 0 ) != SOCKET_ERROR ) +#endif { int iCount = dwBuffer / sizeof( INTERFACE_INFO ); diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 9a05b2d25d..ad9373a556 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -1110,7 +1110,7 @@ FUNCTION hbmk2( aArgs, /* @ */ lPause ) cBinExt := ".exe" cOptPrefix := "-/" /* NOTE: Some targets (watcom, pocc/xcc) need kernel32 explicitly. */ - l_aLIBSYSCORE := { "kernel32", "user32", "gdi32", "advapi32", "ws2_32" } + l_aLIBSYSCORE := { "kernel32", "user32", "gdi32", "advapi32", "wsock32" } l_aLIBSYSMISC := { "winspool", "comctl32", "comdlg32", "shell32", "uuid", "ole32", "oleaut32", "mpr", "winmm", "mapi32", "imm32", "msimg32", "wininet" } CASE hbmk[ _HBMK_cPLAT ] == "wce" #if ! defined( __PLATFORM__UNIX )