From 5de7824e15fbef5529341fefffe5928305ae3783 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 12 Nov 2007 15:10:28 +0000 Subject: [PATCH] 2007-11-12 16:09 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbapifs.h * harbour/source/common/hbfsapi.c + added hb_fsMaxFilesError() * harbour/source/pp/ppcore.c * harbour/utils/hbpp/hbppcore.c * use hb_fsMaxFilesError() to avoid direct accessing of errno value - some compilers/platforms do not support errno * harbour/include/hbdate.h * harbour/source/rtl/seconds.c + added hb_dateMilliSeconds() * harbour/source/rtl/hbgtcore.c * harbour/source/rtl/idle.c * harbour/source/rtl/inkey.c * use hb_dateMilliSeconds() to avoid using clock_t clock() some compilers/platforms do not support it * harbour/include/hbwince.h * harbour/source/common/hbwince.c * disabled clock_t clock() emulation - it's not longer used + added some declarations for ANSI functions emulated by us for WinCE and some defines - code sent by Marek Paliwoda * harbour/include/hbwmain.c * harbour/source/vm/mainwin.c * always use unicode translations with WinMain() parameters for compilers which do not set UNICODE macro for WinCE * harbour/source/rtl/fserror.c * do not include errno.h for HB_WIN32_IO - it's not necessary * harbour/utils/hbver/hbverfix.c * do not include errno.h for _MSC_VER and HB_WINCE builds * harbour/contrib/libmisc/dates2.c - commented DATETIME() function - this was not standard DATETIME() value but raw ctime() function output and some compilers/platforms do not support ctime() * harbour/contrib/libnf/getenvrn.c + added HB_OS_WIN_32_USED * harbour/contrib/mtpl.mak * harbour/contrib/pdflib/pdflib.h * replaced TABs with SPACEs * harbour/include/hbsetup.ch ! reenabled HB_EXTENSION in default builds - disabling it makes a lot of RDD code unusable and breaks default builds due to insufficient dependences --- harbour/ChangeLog | 54 ++++++++++++++++++++ harbour/contrib/libmisc/dates2.c | 2 + harbour/contrib/libnf/getenvrn.c | 2 + harbour/contrib/mtpl.mak | 2 +- harbour/contrib/pdflib/pdflib.h | 84 ++++++++++++++++---------------- harbour/include/hbapifs.h | 1 + harbour/include/hbdate.h | 1 + harbour/include/hbsetup.ch | 2 +- harbour/include/hbwince.h | 84 ++++++++++++++++++++++++++++++-- harbour/include/hbwmain.c | 4 +- harbour/source/common/hbfsapi.c | 15 +++++- harbour/source/common/hbwince.c | 36 +++++++------- harbour/source/pp/ppcore.c | 7 +-- harbour/source/rtl/fserror.c | 2 +- harbour/source/rtl/hbgtcore.c | 32 +++++++----- harbour/source/rtl/idle.c | 23 +++------ harbour/source/rtl/inkey.c | 25 ++-------- harbour/source/rtl/seconds.c | 41 ++++++++++++++-- harbour/source/vm/mainwin.c | 4 +- harbour/utils/hbpp/hbppcore.c | 41 ++++++---------- harbour/utils/hbver/hbverfix.c | 4 +- 21 files changed, 308 insertions(+), 158 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b7bed0eaa6..e536e7fdd9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,60 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-12 16:09 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbapifs.h + * harbour/source/common/hbfsapi.c + + added hb_fsMaxFilesError() + + * harbour/source/pp/ppcore.c + * harbour/utils/hbpp/hbppcore.c + * use hb_fsMaxFilesError() to avoid direct accessing of errno + value - some compilers/platforms do not support errno + + * harbour/include/hbdate.h + * harbour/source/rtl/seconds.c + + added hb_dateMilliSeconds() + + * harbour/source/rtl/hbgtcore.c + * harbour/source/rtl/idle.c + * harbour/source/rtl/inkey.c + * use hb_dateMilliSeconds() to avoid using clock_t clock() + some compilers/platforms do not support it + + * harbour/include/hbwince.h + * harbour/source/common/hbwince.c + * disabled clock_t clock() emulation - it's not longer used + + added some declarations for ANSI functions emulated by us + for WinCE and some defines - code sent by Marek Paliwoda + + * harbour/include/hbwmain.c + * harbour/source/vm/mainwin.c + * always use unicode translations with WinMain() parameters for compilers + which do not set UNICODE macro for WinCE + + * harbour/source/rtl/fserror.c + * do not include errno.h for HB_WIN32_IO - it's not necessary + + * harbour/utils/hbver/hbverfix.c + * do not include errno.h for _MSC_VER and HB_WINCE builds + + * harbour/contrib/libmisc/dates2.c + - commented DATETIME() function - this was not standard DATETIME() + value but raw ctime() function output and some compilers/platforms + do not support ctime() + + * harbour/contrib/libnf/getenvrn.c + + added HB_OS_WIN_32_USED + + * harbour/contrib/mtpl.mak + * harbour/contrib/pdflib/pdflib.h + * replaced TABs with SPACEs + + * harbour/include/hbsetup.ch + ! reenabled HB_EXTENSION in default builds - disabling it makes + a lot of RDD code unusable and breaks default builds due to + insufficient dependences + 2007-11-12 01:25 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmake/hbmake.prg ! Fixed warnings. diff --git a/harbour/contrib/libmisc/dates2.c b/harbour/contrib/libmisc/dates2.c index fa8109b909..e06b3bf034 100644 --- a/harbour/contrib/libmisc/dates2.c +++ b/harbour/contrib/libmisc/dates2.c @@ -301,6 +301,7 @@ HB_FUNC( BOY ) hb_retdl( 0 ); } +/* HB_FUNC( DATETIME ) { time_t current_time; @@ -309,3 +310,4 @@ HB_FUNC( DATETIME ) hb_retc( ctime( ¤t_time ) ); } +*/ diff --git a/harbour/contrib/libnf/getenvrn.c b/harbour/contrib/libnf/getenvrn.c index a4f69a1920..050563e7bc 100644 --- a/harbour/contrib/libnf/getenvrn.c +++ b/harbour/contrib/libnf/getenvrn.c @@ -101,6 +101,8 @@ #include "extend.api" #include "fm.api" */ + +#define HB_OS_WIN_32_USED #include "hbapi.h" #if defined(OS_UNIX_COMPATIBLE) diff --git a/harbour/contrib/mtpl.mak b/harbour/contrib/mtpl.mak index a2418e4dd1..eaa8c515d7 100644 --- a/harbour/contrib/mtpl.mak +++ b/harbour/contrib/mtpl.mak @@ -9,7 +9,7 @@ #********************************************************** # NOTE: "echo." intentionally used instead of "echo", to avoid conflicts -# with external commands named echo. +# with external commands named echo. !ifndef ECHO ECHO = echo. diff --git a/harbour/contrib/pdflib/pdflib.h b/harbour/contrib/pdflib/pdflib.h index 08b390373e..43764b5eaf 100644 --- a/harbour/contrib/pdflib/pdflib.h +++ b/harbour/contrib/pdflib/pdflib.h @@ -49,25 +49,25 @@ #ifdef WIN32 -#define PDFLIB_CALL __cdecl +#define PDFLIB_CALL __cdecl #ifdef PDFLIB_EXPORTS -#define PDFLIB_API __declspec(dllexport) /* prepare a DLL (PDFlib-internal use only) */ +#define PDFLIB_API __declspec(dllexport) /* prepare a DLL (PDFlib-internal use only) */ #elif defined(PDFLIB_DLL) -#define PDFLIB_API __declspec(dllimport) /* PDFlib clients - import PDFlib DLL fcts. */ +#define PDFLIB_API __declspec(dllimport) /* PDFlib clients - import PDFlib DLL fcts. */ -#else /* !PDFLIB_DLL */ -#define PDFLIB_API /* */ /* default: generate or use static library */ +#else /* !PDFLIB_DLL */ +#define PDFLIB_API /* */ /* default: generate or use static library */ -#endif /* !PDFLIB_DLL */ +#endif /* !PDFLIB_DLL */ -#else /* !WIN32 */ +#else /* !WIN32 */ #if (((defined __IBMC__) || (defined __IBMCPP__)) && (defined __DLL__)) #define PDFLIB_CALL _Export #define PDFLIB_API -#endif /* IBM VisualAge C++ DLL */ +#endif /* IBM VisualAge C++ DLL */ #ifndef PDFLIB_CALL #define PDFLIB_CALL @@ -76,7 +76,7 @@ #define PDFLIB_API #endif -#endif /* !WIN32 */ +#endif /* !WIN32 */ /* Make our declarations C++ compatible */ #ifdef __cplusplus @@ -103,11 +103,11 @@ typedef struct PDF_s PDF; */ /* PDFlib version number, major part */ -#define PDFLIB_MAJORVERSION 3 +#define PDFLIB_MAJORVERSION 3 /* PDFlib version number, minor part (must use two decimal places if != 0) */ -#define PDFLIB_MINORVERSION 02 -#define PDFLIB_VERSIONSTRING "3.02" +#define PDFLIB_MINORVERSION 02 +#define PDFLIB_VERSIONSTRING "3.02" /* * ActiveX uses the Class ID; @@ -152,7 +152,7 @@ PDF_new2(errorproc errorhandler, PDFLIB_API void * PDFLIB_CALL PDF_get_opaque(PDF *p); -#endif /* !SWIG */ +#endif /* !SWIG */ /* Create a new PDF object. */ PDFLIB_API PDF * PDFLIB_CALL @@ -180,7 +180,7 @@ PDF_open_fp(PDF *p, FILE *fp); /* Open a new PDF in memory, and install a callback for fetching the data */ PDFLIB_API void PDFLIB_CALL PDF_open_mem(PDF *p, size_t (*writeproc)(PDF *p, void *data, size_t size)); -#endif /* !defined(SWIG) */ +#endif /* !defined(SWIG) */ /* Get the contents of the PDF output buffer. The result must be used by the client before calling any other PDFlib function. Must not be @@ -211,7 +211,7 @@ PDF_end_page(PDF *p); #define PDF_NonfatalError 11 #define PDF_UnknownError 12 -#endif /* !SWIG */ +#endif /* !SWIG */ /* Set some PDFlib parameter with string type */ PDFLIB_API void PDFLIB_CALL @@ -332,7 +332,7 @@ PDF_setpolydash(PDF *p, float *dasharray, int length); #ifndef SWIG /* Maximum length of dash arrays */ -#define MAX_DASH_LENGTH 8 +#define MAX_DASH_LENGTH 8 #endif /* Set the flatness to a value between 0 and 100 inclusive. */ @@ -536,7 +536,7 @@ PDF_close_image(PDF *p, int image); help with preparing the thumbnail, but simply places it in the output. */ PDFLIB_API void PDFLIB_CALL PDF_add_thumbnail(PDF *p, int im); -#endif /* PDF_THUMBNAILS_SUPPORTED */ +#endif /* PDF_THUMBNAILS_SUPPORTED */ /* * ---------------------------------------------------------------------- @@ -648,34 +648,34 @@ Acrobat 4 maximum page size: 200" = 14400 pt = 508 cm /* The page sizes are only available to the C and C++ bindings */ #ifndef SWIG -#define a0_width (float) 2380.0 -#define a0_height (float) 3368.0 -#define a1_width (float) 1684.0 -#define a1_height (float) 2380.0 -#define a2_width (float) 1190.0 -#define a2_height (float) 1684.0 -#define a3_width (float) 842.0 -#define a3_height (float) 1190.0 -#define a4_width (float) 595.0 -#define a4_height (float) 842.0 -#define a5_width (float) 421.0 -#define a5_height (float) 595.0 -#define a6_width (float) 297.0 -#define a6_height (float) 421.0 -#define b5_width (float) 501.0 -#define b5_height (float) 709.0 -#define letter_width (float) 612.0 -#define letter_height (float) 792.0 -#define legal_width (float) 612.0 -#define legal_height (float) 1008.0 -#define ledger_width (float) 1224.0 -#define ledger_height (float) 792.0 -#define p11x17_width (float) 792.0 -#define p11x17_height (float) 1224.0 +#define a0_width (float) 2380.0 +#define a0_height (float) 3368.0 +#define a1_width (float) 1684.0 +#define a1_height (float) 2380.0 +#define a2_width (float) 1190.0 +#define a2_height (float) 1684.0 +#define a3_width (float) 842.0 +#define a3_height (float) 1190.0 +#define a4_width (float) 595.0 +#define a4_height (float) 842.0 +#define a5_width (float) 421.0 +#define a5_height (float) 595.0 +#define a6_width (float) 297.0 +#define a6_height (float) 421.0 +#define b5_width (float) 501.0 +#define b5_height (float) 709.0 +#define letter_width (float) 612.0 +#define letter_height (float) 792.0 +#define legal_width (float) 612.0 +#define legal_height (float) 1008.0 +#define ledger_width (float) 1224.0 +#define ledger_height (float) 792.0 +#define p11x17_width (float) 792.0 +#define p11x17_height (float) 1224.0 #endif #ifdef __cplusplus } // extern "C" #endif -#endif /* PDFLIB_H */ +#endif /* PDFLIB_H */ diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index 9b3fe9fb56..cc58c73bb9 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -229,6 +229,7 @@ extern USHORT hb_fsAttrEncode( const char * szAttr ); extern char * hb_fsAttrDecode( USHORT uiAttr, char * szAttr ); extern HB_EXPORT BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ); extern HB_EXPORT BYTE * hb_fileNameConv( char *str ); +extern HB_EXPORT BOOL hb_fsMaxFilesError( void ); /* wrapper to fopen() which calls hb_fsNameConv() */ extern FILE * hb_fopen( const char *path, const char *mode ); diff --git a/harbour/include/hbdate.h b/harbour/include/hbdate.h index 2881dde015..229aaa7e10 100644 --- a/harbour/include/hbdate.h +++ b/harbour/include/hbdate.h @@ -58,6 +58,7 @@ HB_EXTERN_BEGIN extern HB_EXPORT double hb_dateSeconds( void ); +extern HB_EXPORT HB_ULONG hb_dateMilliSeconds( void ); extern HB_EXPORT double hb_secondsCPU( int n ); extern HB_EXPORT void hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec ); extern HB_EXPORT char * hb_timeStampStr( char * szTime, LONG lMillisec ); diff --git a/harbour/include/hbsetup.ch b/harbour/include/hbsetup.ch index e9241f2638..bd2ea06f78 100644 --- a/harbour/include/hbsetup.ch +++ b/harbour/include/hbsetup.ch @@ -59,7 +59,7 @@ /* NOTE: You can select here, which features you want to include of the different Clipper implementations. */ -/* #define HB_EXTENSION */ /* Enable Harbour extensions */ +#define HB_EXTENSION /* Enable Harbour extensions */ #define HB_C52_UNDOC /* Enable CA-Cl*pper 5.2e undocumented features */ /* #define HB_C52_STRICT */ /* Enable CA-Cl*pper 5.2e strict compatibility */ #define HB_COMPAT_C53 /* Enable CA-Cl*pper 5.3x extensions */ diff --git a/harbour/include/hbwince.h b/harbour/include/hbwince.h index d546217490..ec026ccd97 100644 --- a/harbour/include/hbwince.h +++ b/harbour/include/hbwince.h @@ -53,6 +53,8 @@ #ifndef HB_WINCE_H_ #define HB_WINCE_H_ +#if defined(HB_OS_WIN_32) + HB_EXTERN_BEGIN #if defined(HB_WINCE) @@ -60,7 +62,7 @@ HB_EXTERN_BEGIN /* defined(__CEGCC__) || defined(__MINGW32CE__) */ -#if defined(__MINGW32CE__) +#if defined(__MINGW32CE__) && 0 typedef long clock_t; extern clock_t clock( void ); #endif @@ -70,9 +72,81 @@ extern int access( const char *pathname, int mode ); extern int system( const char *string ); extern char *strerror( int errnum ); -#endif /* HB_WINCE */ +#if defined( HB_OS_WIN_32_USED ) && defined( _MSC_VER ) -#if defined(HB_OS_WIN_32) + #ifndef MAX_COMPUTERNAME_LENGTH + #define MAX_COMPUTERNAME_LENGTH 31 + #define SEM_FAILCRITICALERRORS 0x0001 + #define FILE_TYPE_CHAR 0x0002 + #define FILE_ATTRIBUTE_DEVICE 0x00000040 + #define STD_INPUT_HANDLE (DWORD)-10 + #define STD_OUTPUT_HANDLE (DWORD)-11 + #define STD_ERROR_HANDLE (DWORD)-12 + #define LOCKFILE_FAIL_IMMEDIATELY 0x00000001 + #define LOCKFILE_EXCLUSIVE_LOCK 0x00000002 + #define OEM_FIXED_FONT SYSTEM_FONT + #define WM_NCMOUSEMOVE 0x00A0 + #define WM_QUERYENDSESSION 0x0011 + #define WM_ENTERIDLE 0x0121 + #define SM_CMOUSEBUTTONS 43 + #define PROOF_QUALITY 2 + #define LR_LOADFROMFILE 0x0010 + #endif + + DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size ); + LPSTR WINAPI GetEnvironmentStringsA( void ); + BOOL WINAPI GetProcessTimes( HANDLE hprocess, + LPFILETIME lpCreationTime, LPFILETIME lpExitTime, + LPFILETIME lpKernelTime, LPFILETIME lpUserTime ); + BOOL WINAPI GetUserNameA( LPSTR buffer, LPDWORD len ); + BOOL WINAPI GetComputerNameA( LPSTR buffer, LPDWORD len ); + DWORD WINAPI GetCurrentDirectoryA( DWORD len, LPSTR buffer ); + BOOL WINAPI SetCurrentDirectoryA( LPCSTR dirname ); + BOOL WINAPI LockFile( HANDLE hFile, + DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh ); + BOOL WINAPI LockFileEx( HANDLE hFile, + DWORD dwFlags, DWORD dwReserved, + DWORD nNumberOfBytesToLockLow, + DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped ); + BOOL WINAPI UnlockFile( HANDLE hFile, + DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh ); + BOOL WINAPI UnlockFileEx( HANDLE hFile, DWORD dwReserved, + DWORD nNumberOfBytesToUnlockLow, + DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped ); + BOOL WINAPI GetVolumeInformationA( LPCSTR p1, LPSTR p2, DWORD p3, PDWORD p4, + PDWORD p5, PDWORD p6, LPSTR p7, DWORD p8 ); + UINT WINAPI SetErrorMode( UINT mode ); + HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, + DWORD sharing, LPSECURITY_ATTRIBUTES sa, + DWORD creation, DWORD attributes, HANDLE template ); + BOOL WINAPI MoveFileA( LPCSTR fn1, LPCSTR fn2 ); + BOOL WINAPI DeleteFileA( LPCSTR path ); + BOOL WINAPI RemoveDirectoryA( LPCSTR path ); + BOOL WINAPI CreateDirectoryA( LPCSTR path, LPSECURITY_ATTRIBUTES attr ); + BOOL WINAPI CharToOemBuffA( LPCSTR src, LPSTR dst, DWORD len ); + BOOL WINAPI OemToCharBuffA( LPCSTR src, LPSTR dst, DWORD len ); + HANDLE WINAPI FindFirstFileA( LPCSTR path, WIN32_FIND_DATAA * data ); + BOOL WINAPI FindNextFileA( HANDLE handle, WIN32_FIND_DATAA * data ); + BOOL WINAPI GetVersionExA( OSVERSIONINFOA * v ); + HANDLE WINAPI GetStdHandle( DWORD nStdHandle ); + DWORD WINAPI GetFileType( HANDLE handle ); + HMODULE WINAPI GetModuleHandleA( LPCSTR modulename ); + HINSTANCE WINAPI LoadLibraryA( LPCSTR libname ); + DWORD WINAPI GetTempPathA( DWORD size, LPSTR buffer ); + UINT WINAPI GetTempFileNameA( LPCSTR tmpdir, LPCSTR prefix, UINT unique, LPSTR filename ); + BOOL WINAPI GetDiskFreeSpaceA( LPCSTR path, PDWORD pdwSectorsPerCluster, + PDWORD pdwBytesPerSector, + PDWORD pdwNumberOfFreeClusters, PDWORD pdwTotalNumberOfClusters ); + BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDurat ); + int WINAPI SetTextCharacterExtra( HDC hdc, int i ); + BOOL WINAPI GetKeyboardState( PBYTE p ); + BOOL WINAPI SetKeyboardState( PBYTE p ); + +#endif /* HB_OS_WIN_32_USED && _MSC_VER */ + +#endif /* HB_WINCE */ extern wchar_t * hb_mbtowc( const char *srcA ); extern char * hb_wctomb( const wchar_t *srcW ); @@ -106,8 +180,8 @@ extern void hb_wctombget( char *dstA, const wchar_t *srcW, unsigned long ulLen ) #endif /* UNICODE */ -#endif /* HB_OS_WIN_32 */ - HB_EXTERN_END +#endif /* HB_OS_WIN_32 */ + #endif /* HB_WINCE_H_ */ diff --git a/harbour/include/hbwmain.c b/harbour/include/hbwmain.c index 166e877327..fe6d6d0f93 100644 --- a/harbour/include/hbwmain.c +++ b/harbour/include/hbwmain.c @@ -84,9 +84,9 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ pArg = NULL; #if defined( HB_WINCE ) - pSrc = pFree = HB_TCHAR_CONVFROM( lpCmdLine ); + pSrc = pFree = hb_wctomb( lpCmdLine ); #else - pSrc = pFree = lpCmdLine; + pSrc = pFree = HB_TCHAR_CONVFROM( lpCmdLine ); #endif pDst = pArgs = ( LPSTR ) LocalAlloc( LMEM_FIXED, strlen( pFree ) + 1 ); fQuoted = FALSE; diff --git a/harbour/source/common/hbfsapi.c b/harbour/source/common/hbfsapi.c index a1ccfae2a3..9637d23807 100644 --- a/harbour/source/common/hbfsapi.c +++ b/harbour/source/common/hbfsapi.c @@ -64,6 +64,9 @@ #include #include #endif +#if !defined( HB_WIN32_IO ) + #include +#endif /* NOTE: Not really belongs here, but until we can't find a better place it will do it. [vszakats] */ @@ -330,7 +333,6 @@ HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName ) return fExist; } - HB_EXPORT BOOL hb_fsDirExists( const char * pszDirName ) { BOOL fExist; @@ -382,3 +384,14 @@ HB_EXPORT BOOL hb_fsDirExists( const char * pszDirName ) return fExist; } + +HB_EXPORT BOOL hb_fsMaxFilesError( void ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_fsMaxFilesError()")); + +#if defined( HB_WIN32_IO ) + return GetLastError() == ERROR_TOO_MANY_OPEN_FILES; +#else + return errno == EMFILE; +#endif +} diff --git a/harbour/source/common/hbwince.c b/harbour/source/common/hbwince.c index 16bf8962bb..5a9703f4c5 100644 --- a/harbour/source/common/hbwince.c +++ b/harbour/source/common/hbwince.c @@ -65,7 +65,7 @@ #if defined(HB_WINCE) -#if defined(__MINGW32CE__) +#if defined(__MINGW32CE__) && 0 clock_t clock( void ) { SYSTEMTIME st; @@ -100,7 +100,7 @@ int access( const char *filename, int mode ) int system( const char *cmd ) { LPWSTR wcmd; - STARTUPINFO si; + STARTUPINFOW si; PROCESS_INFORMATION pi; BOOL b; @@ -111,16 +111,16 @@ int system( const char *cmd ) wcmd = hb_mbtowc( cmd ); /* Start the child process. */ - b = CreateProcess( NULL, /* No module name (use command line) */ - wcmd, /* Command line */ - NULL, /* Process handle not inheritable */ - NULL, /* Thread handle not inheritable */ - FALSE, /* Set handle inheritance to FALSE */ - 0, /* No creation flags */ - NULL, /* Use parent's environment block */ - NULL, /* Use parent's starting directory */ - &si, /* Pointer to STARTUPINFO structure */ - &pi ); /* Pointer to PROCESS_INFORMATION structure */ + b = CreateProcessW( NULL, /* No module name (use command line) */ + wcmd, /* Command line */ + NULL, /* Process handle not inheritable */ + NULL, /* Thread handle not inheritable */ + FALSE, /* Set handle inheritance to FALSE */ + 0, /* No creation flags */ + NULL, /* Use parent's environment block */ + NULL, /* Use parent's starting directory */ + &si, /* Pointer to STARTUPINFO structure */ + &pi ); /* Pointer to PROCESS_INFORMATION structure */ hb_xfree( wcmd ); @@ -137,7 +137,7 @@ int system( const char *cmd ) return b ? 0 : -1; } -char *strerror( int errnum ) +char * strerror( int errnum ) { HB_SYMBOL_UNUSED( errnum ); @@ -148,7 +148,7 @@ char *strerror( int errnum ) #if defined(HB_OS_WIN_32) -void hb_mbtowccpy( wchar_t * dstW, const char *srcA, ULONG ulLen ) +void hb_mbtowccpy( wchar_t *dstW, const char *srcA, ULONG ulLen ) { MultiByteToWideChar( CP_ACP, 0, srcA, -1, dstW, ulLen / sizeof( wchar_t ) ); } @@ -237,7 +237,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size ) cbData = MAX_PATH * sizeof( *buf ); wname = hb_mbtowc( name ); - lret = RegQueryValueEx( hk, wname, NULL, &dwType, lpData, &cbData ); + lret = RegQueryValueExW( hk, wname, NULL, &dwType, lpData, &cbData ); RegCloseKey( hk ); if( lret != ERROR_SUCCESS ) @@ -248,7 +248,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size ) return 0; } - avalue = hb_wctomb( ( LPCTSTR ) lpData ); + avalue = hb_wctomb( ( LPCWSTR ) lpData ); if( value && size ) hb_strncpy( value, avalue, size - 1 ); size = strlen( avalue ); @@ -575,7 +575,7 @@ HINSTANCE WINAPI LoadLibraryA( LPCSTR libname ) DWORD WINAPI GetTempPathA( DWORD size, LPSTR buffer ) { - TCHAR wbuffer[MAX_PATH] = { 0 }; + WCHAR wbuffer[MAX_PATH] = { 0 }; char *abuffer; DWORD dw; @@ -590,7 +590,7 @@ DWORD WINAPI GetTempPathA( DWORD size, LPSTR buffer ) UINT WINAPI GetTempFileNameA( LPCSTR tmpdir, LPCSTR prefix, UINT unique, LPSTR filename ) { LPWSTR wtmpdir, wprefix; - TCHAR wfilename[MAX_PATH] = { 0 }; + WCHAR wfilename[MAX_PATH] = { 0 }; UINT u; wtmpdir = hb_mbtowc( tmpdir ); diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 280e5a7742..9111a7fd96 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -58,9 +58,6 @@ #include "hbpp.h" #include "hbdate.h" -#if !defined(__MINGW32CE__) && !defined(HB_WINCE) -# include -#endif #define HB_PP_WARN_DEFINE_REDEF 1 /* C1005 */ @@ -1805,9 +1802,7 @@ static PHB_PP_FILE hb_pp_FileNew( PHB_PP_STATE pState, char * szFileName, } file_in = hb_fopen( szFileName, "r" ); -#if !defined(__MINGW32CE__) && !defined(HB_WINCE) - fNested = errno == EMFILE; -#endif + fNested = file_in == NULL && hb_fsMaxFilesError(); } if( !file_in ) diff --git a/harbour/source/rtl/fserror.c b/harbour/source/rtl/fserror.c index 0d09ab2f90..162e5ba9bc 100644 --- a/harbour/source/rtl/fserror.c +++ b/harbour/source/rtl/fserror.c @@ -55,7 +55,7 @@ #include "hbapi.h" #include "hbapifs.h" #include "hb_io.h" -#if !defined(__MINGW32CE__) +#if !(defined(HB_WIN32_IO) || defined(HB_OS_WIN_32)) # include #endif diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index 55e2390cb9..7453e37c4c 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -58,14 +58,12 @@ #define HB_GT_NAME NUL -#include #include "hbgtcore.h" #include "hbapiitm.h" #include "hbapifs.h" #include "hbapierr.h" #include "hbapicdp.h" - -#include +#include "hbdate.h" static PHB_GT_BASE s_curGT = NULL; static BOOL s_fVgaCell = TRUE; @@ -100,9 +98,9 @@ static int s_iDoubleClickSpeed = 168; /* In milliseconds */ static BOOL s_fMouseVisible = FALSE; static int s_iMouseLastRow; static int s_iMouseLastCol; -static clock_t s_iMouseLeftTimer; -static clock_t s_iMouseRightTimer; -static clock_t s_iMouseMiddleTimer; +static HB_LONG s_iMouseLeftTimer; +static HB_LONG s_iMouseRightTimer; +static HB_LONG s_iMouseMiddleTimer; static void * hb_gt_def_New( void ) { @@ -323,7 +321,7 @@ static const char * hb_gt_def_ColorDecode( const char * szColorString, int * piC while( ( c = *szColorString++ ) != 0 ) { - switch( toupper( ( UCHAR ) c ) ) + switch( c ) { case '*': nColor |= 0x80; @@ -340,36 +338,44 @@ static const char * hb_gt_def_ColorDecode( const char * szColorString, int * piC bFore = FALSE; break; + case 'b': case 'B': nColor |= bFore ? 0x01: 0x10; break; + case 'g': case 'G': nColor |= bFore ? 0x02: 0x20; break; + case 'r': case 'R': nColor |= bFore ? 0x04: 0x40; break; + case 'w': case 'W': nColor |= bFore ? 0x07: 0x70; break; + case 'n': case 'N': nColor &= bFore ? 0xFFF8: 0xFF8F; break; + case 'i': case 'I': bFore = FALSE; nColor &= 0x88; nColor |= 0x70; break; + case 'x': case 'X': nColor &= 0x88; break; + case 'u': case 'U': if( bFore ) nColor = ( nColor & 0xF0F8 ) | 0x0801; @@ -2314,8 +2320,8 @@ static int hb_gt_def_MouseReadKey( int iEventMask ) { if( iEventMask & INKEY_LDOWN && hb_mouse_ButtonPressed( 0, &iRow, &iCol ) ) { - clock_t timer = clock(); - if( timer - s_iMouseLeftTimer <= ( clock_t ) hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) + HB_ULONG timer = hb_dateMilliSeconds(); + if( timer - s_iMouseLeftTimer <= ( HB_ULONG ) hb_mouse_GetDoubleClickSpeed() ) iKey = K_LDBLCLK; else iKey = K_LBUTTONDOWN; @@ -2327,8 +2333,8 @@ static int hb_gt_def_MouseReadKey( int iEventMask ) } else if( iEventMask & INKEY_RDOWN && hb_mouse_ButtonPressed( 1, &iRow, &iCol ) ) { - clock_t timer = clock(); - if( timer - s_iMouseRightTimer <= ( clock_t ) hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) + HB_ULONG timer = hb_dateMilliSeconds(); + if( timer - s_iMouseRightTimer <= ( HB_ULONG ) hb_mouse_GetDoubleClickSpeed() ) iKey = K_RDBLCLK; else iKey = K_RBUTTONDOWN; @@ -2340,8 +2346,8 @@ static int hb_gt_def_MouseReadKey( int iEventMask ) } else if( iEventMask & INKEY_MMIDDLE && hb_mouse_ButtonPressed( 2, &iRow, &iCol ) ) { - clock_t timer = clock(); - if( timer - s_iMouseMiddleTimer <= ( clock_t ) hb_mouse_GetDoubleClickSpeed() * 1000 / CLOCKS_PER_SEC ) + HB_ULONG timer = hb_dateMilliSeconds(); + if( timer - s_iMouseMiddleTimer <= ( HB_ULONG ) hb_mouse_GetDoubleClickSpeed() ) iKey = K_MDBLCLK; else iKey = K_MBUTTONDOWN; diff --git a/harbour/source/rtl/idle.c b/harbour/source/rtl/idle.c index d8644d85a6..27fd5c6de0 100644 --- a/harbour/source/rtl/idle.c +++ b/harbour/source/rtl/idle.c @@ -71,6 +71,7 @@ #include "hbapiitm.h" #include "hbset.h" #include "hbvm.h" +#include "hbdate.h" #include "error.ch" #if defined( HB_OS_UNIX ) #ifndef __USE_POSIX199309 @@ -213,23 +214,15 @@ void hb_idleShutDown( void ) void hb_idleSleep( double dSeconds ) { -#if defined( HB_OS_UNIX ) - /* NOTE: clock() returns a time used by a program - if it is suspended - * then this time will be zero - */ - clock_t end_clock; - struct tms tm; - - end_clock = times( &tm ) + ( clock_t ) ( dSeconds * sysconf(_SC_CLK_TCK) ); - while( times( &tm ) < end_clock ) -#else - clock_t end_clock = clock() + ( clock_t ) ( dSeconds * CLOCKS_PER_SEC ); - while( clock() < end_clock ) -#endif + if( dSeconds >= 0 ) { - hb_idleState(); + HB_ULONG end_timer = hb_dateMilliSeconds() + ( HB_ULONG ) dSeconds * 1000; + + while( hb_dateMilliSeconds() < end_timer ) + hb_idleState(); + + hb_idleReset(); } - hb_idleReset(); } /* signal that the user code is in idle state */ diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index 253912ad1e..2810fdff88 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -83,14 +83,9 @@ #include "hbapigt.h" #include "hbvm.h" #include "hbset.h" +#include "hbdate.h" #include "inkey.ch" -#include -#if defined( HB_OS_UNIX ) - #include - #include -#endif - static int s_defaultKeyBuffer[ HB_DEFAULT_INKEY_BUFSIZE + 1 ]; static int * s_inkeyBuffer = s_defaultKeyBuffer; @@ -302,27 +297,15 @@ HB_EXPORT int hb_inkeyNext( int iEventMask ) HB_EXPORT int hb_inkey( BOOL fWait, double dSeconds, int iEventMask ) { - clock_t end_clock = 0; + HB_ULONG end_timer = 0; BOOL fPop; -#if defined( HB_OS_UNIX ) - /* NOTE: clock() returns a time used by a program - if it is suspended - * then this time will be zero - */ - struct tms tm; - #define _HB_CUR_CLOCK() times( &tm ) - #define _HB_CLOCK_TICK sysconf(_SC_CLK_TCK) -#else - #define _HB_CUR_CLOCK() clock() - #define _HB_CLOCK_TICK CLOCKS_PER_SEC -#endif - HB_TRACE(HB_TR_DEBUG, ("hb_inkey(%d, %f, %d)", (int) fWait, dSeconds, iEventMask)); /* Wait forever ?, Use fixed value 100 for strict Clipper compatibility */ if( fWait && dSeconds * 100 >= 1 ) { - end_clock = _HB_CUR_CLOCK() + ( clock_t ) ( dSeconds * _HB_CLOCK_TICK ); + end_timer = hb_dateMilliSeconds() + ( HB_ULONG ) ( dSeconds * 1000 ); } do @@ -343,7 +326,7 @@ HB_EXPORT int hb_inkey( BOOL fWait, double dSeconds, int iEventMask ) hb_idleState(); } - while( end_clock == 0 || end_clock > _HB_CUR_CLOCK() ); + while( end_timer == 0 || end_timer > hb_dateMilliSeconds() ); hb_idleReset(); diff --git a/harbour/source/rtl/seconds.c b/harbour/source/rtl/seconds.c index f905071929..14a66f7b34 100644 --- a/harbour/source/rtl/seconds.c +++ b/harbour/source/rtl/seconds.c @@ -59,7 +59,7 @@ #if ( defined( HB_OS_BSD ) || defined( HB_OS_LINUX ) ) && !defined( __WATCOMC__ ) #include -#else +#elif !( defined( HB_WINCE ) && defined( _MSC_VER ) ) #include #endif #if defined( OS_UNIX_COMPATIBLE ) @@ -128,6 +128,37 @@ HB_EXPORT void hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec ) #endif } +HB_EXPORT HB_ULONG hb_dateMilliSeconds( void ) +{ +#if defined(HB_OS_WIN_32) + SYSTEMTIME st; + + HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()")); + + GetLocalTime( &st ); + + return ( HB_ULONG ) hb_dateEncode( st.wYear, st.wMonth, st.wDay ) * 86400000L + + ( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 + + st.wMilliseconds; +#elif ( defined( HB_OS_LINUX ) || defined( HB_OS_BSD ) ) && !defined( __WATCOMC__ ) + struct timeval tv; + + HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()")); + + gettimeofday( &tv, NULL ); + + return ( HB_ULONG ) tv.tv_sec * 1000 * tv.tv_usec / 1000; +#else + struct timeb tb; + + HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()")); + + ftime( &tb ); + + return ( HB_ULONG ) tb.time * 1000 * tb.millitm; +#endif +} + HB_EXPORT double hb_dateSeconds( void ) { #if defined(HB_OS_WIN_32) @@ -194,7 +225,11 @@ HB_FUNC( SECONDS ) HB_FUNC( HB_CLOCKS2SECS ) { - hb_retnd((double) hb_parnl( 1 ) / CLOCKS_PER_SEC ); +#ifdef CLOCKS_PER_SEC + hb_retnd( ( double ) hb_parnint( 1 ) / CLOCKS_PER_SEC ); +#else + hb_retnd( ( double ) hb_parnint( 1 ) / 1000 ); +#endif } /* @@ -211,7 +246,7 @@ HB_FUNC( HB_CLOCKS2SECS ) HB_EXPORT double hb_secondsCPU( int n ) { double d = 0.0; -#if defined( HB_OS_WIN_32 ) +#if defined( HB_OS_WIN_32 ) && !defined( OS_UNIX_COMPATIBLE ) FILETIME Create, Exit, Kernel, User; #endif diff --git a/harbour/source/vm/mainwin.c b/harbour/source/vm/mainwin.c index ecb54250f0..9c51494e7b 100644 --- a/harbour/source/vm/mainwin.c +++ b/harbour/source/vm/mainwin.c @@ -107,9 +107,9 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ pArg = NULL; #if defined( HB_WINCE ) - pSrc = pFree = HB_TCHAR_CONVFROM( lpCmdLine ); + pSrc = pFree = hb_wctomb( lpCmdLine ); #else - pSrc = pFree = lpCmdLine; + pSrc = pFree = HB_TCHAR_CONVFROM( lpCmdLine ); #endif pDst = pArgs = ( LPSTR ) LocalAlloc( LMEM_FIXED, strlen( pFree ) + 1 ); fQuoted = FALSE; diff --git a/harbour/utils/hbpp/hbppcore.c b/harbour/utils/hbpp/hbppcore.c index 7dcc812927..764446f558 100644 --- a/harbour/utils/hbpp/hbppcore.c +++ b/harbour/utils/hbpp/hbppcore.c @@ -75,19 +75,13 @@ #endif #endif -#include -#if !defined(__MINGW32CE__) +#if !defined(__MINGW32CE__) && !( defined( _MSC_VER ) && defined( HB_WINCE ) ) # include #endif #include "hbppdef.h" #include "hbcomp.h" - -#if defined( OS_UNIX_COMPATIBLE ) -#include -#else -#include -#endif +#include "hbdate.h" int hb_pp_ParseDefine_( char * ); /* Process #define directive */ @@ -448,17 +442,20 @@ void hb_pp_Init( void ) } { + int iYear, iMonth, iDay; char szResult[11]; - time_t t; - struct tm *oTime; - time( &t ); - oTime = localtime( &t ); - - snprintf( szResult, sizeof( szResult ), "\"%04d%02d%02d\"", oTime->tm_year + 1900, oTime->tm_mon + 1, oTime->tm_mday ); + hb_dateToday( &iYear, &iMonth, &iDay ); + hb_dateStrPut( szResult + 1, iYear, iMonth, iDay ); + szResult[ 0 ] = '"'; + szResult[ 9 ] = '"'; + szResult[ 10 ] = '\0'; hb_pp_AddDefine_( "__DATE__", szResult ); - snprintf( szResult, sizeof( szResult ), "\"%02d:%02d:%02d\"", oTime->tm_hour, oTime->tm_min, oTime->tm_sec ); + hb_dateTimeStr( szResult + 1 ); + szResult[ 0 ] = '"'; + szResult[ 9 ] = '"'; + szResult[ 10 ] = '\0'; hb_pp_AddDefine_( "__TIME__", szResult ); } @@ -559,13 +556,11 @@ int hb_pp_ParseDirective_( char *sLine ) if( !OpenInclude( sLine, hb_comp_pIncludePath, hb_comp_pFileName, ( cDelimChar == '>' ), szInclude ) ) { -#if !defined(__MINGW32CE__) - if( errno == 0 || errno == EMFILE ) + if( hb_fsMaxFilesError() ) hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_TOO_MANY_INCLUDES, sLine, NULL ); else -#endif { -#if defined(__CYGWIN__) || defined(__MINGW32CE__) || defined(__IBMCPP__) || defined(__LCC__) +#if defined(__CYGWIN__) || defined(__IBMCPP__) || defined(__LCC__) || defined( HB_WINCE ) hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_CANNOT_OPEN, sLine, "" ); #else hb_compGenError( NULL, hb_pp_szErrors, 'F', HB_PP_ERR_CANNOT_OPEN, sLine, strerror( errno ) ); @@ -4738,7 +4733,7 @@ static BOOL OpenInclude( char *szFileName, HB_PATHNAMES * pSearch, PHB_FNAME pMa HB_TRACE( HB_TR_DEBUG, ( "OpenInclude(%s, %p, %p, %d, %s)", szFileName, pSearch, pMainFileName, ( int ) bStandardOnly, szInclude ) ); -#if !defined(__MINGW32CE__) +#if !defined(__MINGW32CE__) && !( defined( _MSC_VER ) && defined( HB_WINCE ) ) errno = 0; #endif if( bStandardOnly ) @@ -4759,11 +4754,7 @@ static BOOL OpenInclude( char *szFileName, HB_PATHNAMES * pSearch, PHB_FNAME pMa hb_xfree( pFileName ); } -#if defined(__MINGW32CE__) - if( !fptr && pSearch ) -#else - if( !fptr && pSearch && errno != EMFILE ) -#endif + if( !fptr && pSearch && !hb_fsMaxFilesError() ) { pFileName = hb_fsFNameSplit( szFileName ); pFileName->szName = szFileName; diff --git a/harbour/utils/hbver/hbverfix.c b/harbour/utils/hbver/hbverfix.c index 5dbeb1f7b5..6af08d4d63 100644 --- a/harbour/utils/hbver/hbverfix.c +++ b/harbour/utils/hbver/hbverfix.c @@ -64,7 +64,7 @@ #include #include #include -#if ! defined(__MINGW32CE__) +#if !defined(__MINGW32CE__) && !( defined( _MSC_VER ) && defined( HB_WINCE ) ) # include #endif @@ -233,7 +233,7 @@ int main( int argc, char * argv[] ) fhChangeLog = fopen( cszChangeLogName, "rt" ); if( fhChangeLog == NULL ) { -#if defined(__MINGW32CE__) +#if defined(__MINGW32CE__) || ( defined( _MSC_VER ) && defined( HB_WINCE ) ) perror( szErrBuf ); return 4; #else