From ba531f861f87f1e87964cd73205e25c049f4025c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 21 Jun 2000 12:19:00 +0000 Subject: [PATCH] 20000322-16:33 GMT+1 Victor Szakats --- harbour/ChangeLog | 72 ++++++ harbour/doc/whatsnew.txt | 2 +- harbour/include/fileio.ch | 9 +- harbour/include/hbapigt.h | 22 +- harbour/include/hbclass.ch | 6 +- harbour/include/hbextern.ch | 3 + harbour/makefile.bc | 5 + harbour/makefile.vc | 1 + harbour/source/lang/msgit.c | 5 +- harbour/source/rtl/Makefile | 1 + harbour/source/rtl/diskspac.c | 367 ++++++++--------------------- harbour/source/rtl/filesys.c | 60 ++--- harbour/source/rtl/gt_tpl/gt_tpl.c | 63 +++-- harbour/source/rtl/gtapi.c | 8 +- harbour/source/rtl/gtapiu.c | 36 ++- harbour/source/rtl/gtwin/gtwin.c | 2 - harbour/source/vm/extend.c | 14 +- 17 files changed, 297 insertions(+), 379 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index baafa6fd4d..7e7266174a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,75 @@ +2000-06-21 14:19 UTC+0100 Victor Szakats + + * include/hbextern.ch + * include/fileio.ch + + source/rtl/disksphb.c + * source/rtl/Makefile + * makefile.bc + * makefile.vc + * DISKSPACE() made 100% CA-Clipper compatible, so that the second optional + extension parameter was removed. The UNIX support has been removed + since the first parameter should always be a numeric value. + + HB_DISKSPACE() extension function added, with the optional second + parameter. This function will always need a string as the first + parameter, you can also query space data for a specific directory + on the systems where this is supported (Unix, Win32). + This version will also support the Retry operation on error. + + Please test it on your platform. + WARNING! Please update the docs. + + * include/fileio.ch + - Removed non-Clipper compatible macros. + + Add these to your local headers if you need them, as I've already + noted here: 20000322-16:33 GMT+1 Victor Szakats + + #define CD( d ) DIRCHANGE( d ) + #define MD( d ) MAKEDIR( d ) + #define RD( d ) DIRREMOVE( d ) + #define DISKUSED( d ) HB_DISKSPACE( d, HB_DISK_USED ) + #define DISKFREE( d ) HB_DISKSPACE( d, HB_DISK_FREE ) + #define DISKFULL( d ) HB_DISKSPACE( d, HB_DISK_TOTAL ) + + (Note that this change had no trace in the ChangeLogs) + + * source/rtl/gt_tpl/gt_tpl.c + ! Fixed several bugs. + + * source/rtl/filesys.c + ! Rearranged the OS/2 hb_fsSeek() support, to not contain redundant + code, and use the Harbour standard for multiplatform code. + + * source/vm/extend.c + ! Fixed hb_stornl() (storing an int instead of long). + ! Fixed some formatting. + % Minor optimization for arrays in hb_parni(). + + * include/hbapigt.h + * source/rtl/gtapiu.c + * Minor fixes. + + * source/rtl/gtwin/gtwin.c + * ... + + * include/hbapigt.h + * source/rtl/gtapi.c + ! Renamed some Harbour constants to avoid name collision: + _B_SINGLE_V -> HB_B_SINGLE_V + _B_SINGLE_H -> HB_B_SINGLE_H + _B_DOUBLE_V -> HB_B_DOUBLE_V + _B_DOUBLE_H -> HB_B_DOUBLE_H + + * source/lang/msgit.c + ! Fixed missing commas. + + * doc/whatsnew.txt + ! Someone has overwritten the file with a previous version. Fixed. + (Note that this change had no trace in the ChangeLogs) + + * include/hbclass.ch + - Documentation copyright removed. + 2000-06-20 08:45 UTC-0800 Ron Pinkas * source/pp/ppcore.c * Removed some /* reported as nested comments diff --git a/harbour/doc/whatsnew.txt b/harbour/doc/whatsnew.txt index a1511e7d95..ef1c2457d9 100644 --- a/harbour/doc/whatsnew.txt +++ b/harbour/doc/whatsnew.txt @@ -11,7 +11,7 @@ Version 0.34 Build 34 (2000-06-02) - MEMOEDIT support started - CONTRIBs better separated from core Harbour (TOOLS moved there) - Simplified and enhanced base for multiplatform coding -- Language API (link/compile time language modul selection) +- Language API (link/compile time language module selection) - Several small optimizations, enhancements and fixes (compiler, macro, GT, inkey, make and build systems, more strict compiler warnings) - Compiler pcode size optimizations (new compact pcode versions added and diff --git a/harbour/include/fileio.ch b/harbour/include/fileio.ch index 6f0ac52060..d8daaecbdc 100644 --- a/harbour/include/fileio.ch +++ b/harbour/include/fileio.ch @@ -72,18 +72,11 @@ /* File system error codes */ #define F_ERROR ( -1 ) /* Unspecified error */ -/* DISKSPACE() types */ +/* HB_DISKSPACE() types */ #define HB_DISK_AVAIL 0 #define HB_DISK_FREE 1 #define HB_DISK_USED 2 #define HB_DISK_TOTAL 3 -#define CD( d ) DIRCHANGE( d ) -#define MD( d ) MAKEDIR( d ) -#define RD( d ) DIRREMOVE( d ) -#define DISKUSED( d ) DISKSPACE( d, HB_DISK_USED ) -#define DISKFREE( d ) DISKSPACE( d, HB_DISK_FREE ) -#define DISKFULL( d ) DISKSPACE( d, HB_DISK_TOTAL ) - #endif /* _FILEIO_CH */ diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index af4d35eef9..a938458acc 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -43,6 +43,7 @@ * * Copyright 1999 Victor Szakats * Mouse related declarations + * Undocumented GT API declarations * * See doc/license.txt for licensing terms. * @@ -79,10 +80,10 @@ extern "C" { #define _B_DOUBLE "ͻȺ" #define _B_SINGLE_DOUBLE "ķӺ" #define _B_DOUBLE_SINGLE "͸Գ" -#define _B_SINGLE_V '' -#define _B_SINGLE_H '' -#define _B_DOUBLE_V '' -#define _B_DOUBLE_H '' +#define HB_B_SINGLE_V '' +#define HB_B_SINGLE_H '' +#define HB_B_DOUBLE_V '' +#define HB_B_DOUBLE_H '' /* Keyboard filters */ @@ -114,7 +115,7 @@ typedef enum extern void hb_gtInit( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ); extern void hb_gtExit( void ); extern void hb_gtAdjustPos( int iHandle, char * pStr, ULONG ulLen ); -extern USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyBoxString ); +extern USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyFrame ); extern USHORT hb_gtBoxD( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ); extern USHORT hb_gtBoxS( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ); extern USHORT hb_gtColorSelect( USHORT uiColorIndex ); @@ -179,9 +180,9 @@ extern USHORT hb_gtSetBorder( HB_GT_RGB * color ); extern void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr ); extern void hb_gt_Exit( void ); extern BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen ); -extern USHORT hb_gt_Box( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyBox, BYTE attrib ); -extern USHORT hb_gt_BoxD( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyBox, BYTE attrib ); -extern USHORT hb_gt_BoxS( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyBox, BYTE attrib ); +extern USHORT hb_gt_Box( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyFrame, BYTE byAttr ); +extern USHORT hb_gt_BoxD( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyFrame, BYTE byAttr ); +extern USHORT hb_gt_BoxS( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyFrame, BYTE byAttr ); extern SHORT hb_gt_Col( void ); extern void hb_gt_DispBegin( void ); extern USHORT hb_gt_DispCount( void ); @@ -265,14 +266,13 @@ extern void hb_mouse_GetBounds( int * piTop, int * piLeft, int * piBottom, int /* Public interface. These should never change, only be added to. */ -extern void hb_setkeyInit( void ); -extern void hb_setkeyExit( void ); +extern void hb_setkeyInit( void ); +extern void hb_setkeyExit( void ); /* Private interface listed below. these are common to all platforms */ /* none as of yet */ - #if defined(HB_EXTERN_C) } #endif diff --git a/harbour/include/hbclass.ch b/harbour/include/hbclass.ch index 6ea92f8f78..376d9aa7c0 100644 --- a/harbour/include/hbclass.ch +++ b/harbour/include/hbclass.ch @@ -44,9 +44,6 @@ * Delegating, DATA Shared * Support of 10 Chars limits * - * Copyright 2000 Brian Hays - * Documentation for the commands - * * See doc/license.txt for licensing terms. * */ @@ -339,4 +336,5 @@ #endif /* HB_SHORTNAMES */ -#endif /* HB_CLASS_CH_ */ \ No newline at end of file +#endif /* HB_CLASS_CH_ */ + diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 0e23f64ab2..fb6ceeaf37 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -302,6 +302,9 @@ EXTERNAL FILE EXTERNAL FREADSTR EXTERNAL CURDIR EXTERNAL DISKSPACE +#ifdef HB_EXTENSION +EXTERNAL HB_DISKSPACE +#endif EXTERNAL HB_FNAMESPLIT EXTERNAL HB_FNAMEMERGE #ifdef HB_COMPAT_XPP diff --git a/harbour/makefile.bc b/harbour/makefile.bc index 85b2f7c88c..9264df909c 100644 --- a/harbour/makefile.bc +++ b/harbour/makefile.bc @@ -185,6 +185,7 @@ RTL_LIB_OBJS = \ $(OBJ_DIR)\dir.obj \ $(OBJ_DIR)\dirdrive.obj \ $(OBJ_DIR)\diskspac.obj \ + $(OBJ_DIR)\disksphb.obj \ $(OBJ_DIR)\do.obj \ $(OBJ_DIR)\empty.obj \ $(OBJ_DIR)\errorapi.obj \ @@ -1097,6 +1098,10 @@ $(OBJ_DIR)\diskspac.obj : $(RTL_DIR)\diskspac.c $(CC) $(CLIBFLAGS) -o$@ $** tlib $(RTL_LIB) $(ARFLAGS) -+$@,, +$(OBJ_DIR)\disksphb.obj : $(RTL_DIR)\disksphb.c + $(CC) $(CLIBFLAGS) -o$@ $** + tlib $(RTL_LIB) $(ARFLAGS) -+$@,, + $(OBJ_DIR)\dircmd.c : $(RTL_DIR)\dircmd.prg $(HARBOUR_EXE) $(HARBOURFLAGS) $** -o$@ diff --git a/harbour/makefile.vc b/harbour/makefile.vc index 9967a77464..6f3b352b4c 100644 --- a/harbour/makefile.vc +++ b/harbour/makefile.vc @@ -210,6 +210,7 @@ RTL_LIB_OBJS = \ $(OBJ_DIR)\dir.obj \ $(OBJ_DIR)\dirdrive.obj \ $(OBJ_DIR)\diskspac.obj \ + $(OBJ_DIR)\disksphb.obj \ $(OBJ_DIR)\do.obj \ $(OBJ_DIR)\empty.obj \ $(OBJ_DIR)\errorapi.obj \ diff --git a/harbour/source/lang/msgit.c b/harbour/source/lang/msgit.c index 0b5468f5dc..1ff3a8ff7a 100644 --- a/harbour/source/lang/msgit.c +++ b/harbour/source/lang/msgit.c @@ -53,7 +53,6 @@ static HB_LANG s_lang = /* Month names */ - "Gennaio", "Febbraio", "Marzo", @@ -65,7 +64,7 @@ static HB_LANG s_lang = "Settembre", "Ottobre", "Novembre", - "Dicembre" + "Dicembre", /* Day names */ @@ -75,7 +74,7 @@ static HB_LANG s_lang = "Mercoled", "Gioved", "Venerd", - "Sabato" + "Sabato", /* CA-Cl*pper compatible natmsg items */ diff --git a/harbour/source/rtl/Makefile b/harbour/source/rtl/Makefile index 01a8291a1c..ff991e5fcd 100644 --- a/harbour/source/rtl/Makefile +++ b/harbour/source/rtl/Makefile @@ -25,6 +25,7 @@ C_SOURCES=\ dir.c \ dirdrive.c \ diskspac.c \ + disksphb.c \ do.c \ empty.c \ errorapi.c \ diff --git a/harbour/source/rtl/diskspac.c b/harbour/source/rtl/diskspac.c index ac0c43e799..010e2b81b8 100644 --- a/harbour/source/rtl/diskspac.c +++ b/harbour/source/rtl/diskspac.c @@ -47,321 +47,152 @@ #include "hbapierr.h" #include "hbapifs.h" -#if defined( HB_OS_UNIX ) - #include -#endif - -/* NOTE: The second parameter is a Harbour extension, check fileio.ch for - the possible values. */ - HB_FUNC( DISKSPACE ) { USHORT uiDrive = ISNUM( 1 ) ? hb_parni( 1 ) : 0; - USHORT uiType = ISNUM( 2 ) ? hb_parni( 2 ) : HB_DISK_AVAIL; double dSpace = 0.0; - - if( uiType > HB_DISK_TOTAL ) - uiType = HB_DISK_TOTAL; + BOOL bError = FALSE; #if defined(HB_OS_DOS) { - while( TRUE ) - { - union REGS regs; + union REGS regs; - regs.HB_XREGS.dx = uiDrive; - regs.h.ah = 0x36; - HB_DOS_INT86( 0x21, ®s, ®s ); + regs.HB_XREGS.dx = uiDrive; + regs.h.ah = 0x36; + HB_DOS_INT86( 0x21, ®s, ®s ); - if( regs.HB_XREGS.ax != 0xFFFF ) - { - USHORT uiClusterTotal = regs.HB_XREGS.dx; - USHORT uiClusterFree = regs.HB_XREGS.bx; - USHORT uiSecPerCluster = regs.HB_XREGS.ax; - USHORT uiSectorSize = regs.HB_XREGS.cx; - - switch( uiType ) - { - case HB_DISK_AVAIL: - case HB_DISK_FREE: - dSpace = ( double ) uiClusterFree * - ( double ) uiSecPerCluster * - ( double ) uiSectorSize; - break; - - case HB_DISK_USED: - case HB_DISK_TOTAL: - dSpace = ( double ) uiClusterTotal * - ( double ) uiSecPerCluster * - ( double ) uiSectorSize; - - if( uiType == HB_DISK_USED ) - dSpace -= ( double ) uiClusterFree * - ( double ) uiSecPerCluster * - ( double ) uiSectorSize; - break; - } - } - else - { - USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT ); - - /* NOTE: Under 'Standard' behaviour, this error does not allow 'retry' - but if you should wish to make it so, then or EF_CANRETRY - with EF_CANDEFAULT above) - */ - - if( uiAction == E_RETRY ) - continue; - } - break; - } + if( regs.HB_XREGS.ax != 0xFFFF ) + dSpace = ( double ) regs.HB_XREGS.bx * + ( double ) regs.HB_XREGS.ax * + ( double ) regs.HB_XREGS.cx; + else + bError = TRUE; } #elif defined(HB_OS_WIN_32) { - while( TRUE ) + typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER, + PULARGE_INTEGER, PULARGE_INTEGER ); + + char szPath[ 4 ]; + P_GDFSE pGetDiskFreeSpaceEx; + UINT uiErrMode; + + /* Get the default drive */ + + if( uiDrive == 0 ) { - typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER, - PULARGE_INTEGER, PULARGE_INTEGER); + USHORT uiErrorOld = hb_fsError(); - char szPath[ 4 ]; - P_GDFSE pGetDiskFreeSpaceEx; - UINT uiErrMode; + uiDrive = hb_fsCurDrv() + 1; - /* Get the default drive */ + hb_fsSetError( uiErrorOld ); + } - if( uiDrive == 0 ) + szPath[ 0 ] = uiDrive + 'A' - 1; + szPath[ 1 ] = ':'; + szPath[ 2 ] = '\\'; + szPath[ 3 ] = '\0'; + + uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS ); + + SetLastError( 0 ); + + pGetDiskFreeSpaceEx = ( P_GDFSE ) GetProcAddress( GetModuleHandle( "kernel32.dll" ), + "GetDiskFreeSpaceExA"); + + if( pGetDiskFreeSpaceEx ) + { + ULARGE_INTEGER i64FreeBytesToCaller, + i64TotalBytes, + i64FreeBytes, + i64RetVal; + + if( pGetDiskFreeSpaceEx( szPath, + ( PULARGE_INTEGER ) &i64FreeBytesToCaller, + ( PULARGE_INTEGER ) &i64TotalBytes, + ( PULARGE_INTEGER ) &i64FreeBytes ) ) { - USHORT uiErrorOld = hb_fsError(); + memcpy( &i64RetVal, &i64FreeBytesToCaller, sizeof( ULARGE_INTEGER ) ); - uiDrive = hb_fsCurDrv() + 1; + #if (defined(__GNUC__) || defined(_MSC_VER)) && !defined(__RSXNT__) - hb_fsSetError( uiErrorOld ); + dSpace = ( double ) i64RetVal.LowPart + + ( double ) i64RetVal.HighPart + + ( double ) i64RetVal.HighPart * + ( double ) 0xFFFFFFFF; + + #else + + /* NOTE: Borland doesn't seem to deal with the un-named + struct that is part of ULARGE_INTEGER + [pt] */ + + dSpace = ( double ) i64RetVal.u.LowPart + + ( double ) i64RetVal.u.HighPart + + ( double ) i64RetVal.u.HighPart * + ( double ) 0xFFFFFFFF; + + #endif } - - szPath[ 0 ] = uiDrive + 'A' - 1; - szPath[ 1 ] = ':'; - szPath[ 2 ] = '\\'; - szPath[ 3 ] = '\0'; - - uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS ); + } + else + { + DWORD dwSectorsPerCluster; + DWORD dwBytesPerSector; + DWORD dwNumberOfFreeClusters; + DWORD dwTotalNumberOfClusters; SetLastError( 0 ); - pGetDiskFreeSpaceEx = ( P_GDFSE ) GetProcAddress( GetModuleHandle( "kernel32.dll" ), - "GetDiskFreeSpaceExA"); - - if( pGetDiskFreeSpaceEx ) - { - ULARGE_INTEGER i64FreeBytesToCaller, - i64TotalBytes, - i64FreeBytes, - i64RetVal; - - if( pGetDiskFreeSpaceEx( szPath, - ( PULARGE_INTEGER ) &i64FreeBytesToCaller, - ( PULARGE_INTEGER ) &i64TotalBytes, - ( PULARGE_INTEGER ) &i64FreeBytes ) ) - { - switch( uiType ) - { - case HB_DISK_AVAIL: - memcpy( &i64RetVal, &i64FreeBytesToCaller, sizeof( ULARGE_INTEGER ) ); - break; - - case HB_DISK_FREE: - memcpy( &i64RetVal, &i64FreeBytes, sizeof( ULARGE_INTEGER ) ); - break; - - case HB_DISK_USED: - case HB_DISK_TOTAL: - memcpy( &i64RetVal, &i64TotalBytes, sizeof( ULARGE_INTEGER ) ); - } - - #if (defined(__GNUC__) || defined(_MSC_VER)) && !defined(__RSXNT__) - - dSpace = ( double ) i64RetVal.LowPart + - ( double ) i64RetVal.HighPart + - ( double ) i64RetVal.HighPart * - ( double ) 0xFFFFFFFF; - - if( uiType == HB_DISK_USED ) - { - dSpace -= ( double ) i64FreeBytes.LowPart + - ( double ) i64FreeBytes.HighPart + - ( double ) i64FreeBytes.HighPart * - ( double ) 0xFFFFFFFF; - } - - #else - - /* NOTE: Borland doesn't seem to deal with the un-named - struct that is part of ULARGE_INTEGER - [pt] */ - - dSpace = ( double ) i64RetVal.u.LowPart + - ( double ) i64RetVal.u.HighPart + - ( double ) i64RetVal.u.HighPart * - ( double ) 0xFFFFFFFF; - - if( uiType == HB_DISK_USED ) - { - dSpace -= ( double ) i64FreeBytes.u.LowPart + - ( double ) i64FreeBytes.u.HighPart + - ( double ) i64FreeBytes.u.HighPart * - ( double ) 0xFFFFFFFF; - } - - #endif - } - } - else - { - DWORD dwSectorsPerCluster; - DWORD dwBytesPerSector; - DWORD dwNumberOfFreeClusters; - DWORD dwTotalNumberOfClusters; - - SetLastError( 0 ); - - if( GetDiskFreeSpace( szPath, - &dwSectorsPerCluster, - &dwBytesPerSector, - &dwNumberOfFreeClusters, - &dwTotalNumberOfClusters ) ) - { - switch( uiType ) - { - case HB_DISK_AVAIL: - case HB_DISK_FREE: - dSpace = ( double ) dwNumberOfFreeClusters * - ( double ) dwSectorsPerCluster * - ( double ) dwBytesPerSector; - break; - - case HB_DISK_USED: - case HB_DISK_TOTAL: - dSpace = ( double ) dwTotalNumberOfClusters * - ( double ) dwSectorsPerCluster * - ( double ) dwBytesPerSector; - - if( uiType == HB_DISK_USED ) - dSpace -= ( double ) dwNumberOfFreeClusters * - ( double ) dwSectorsPerCluster * - ( double ) dwBytesPerSector; - break; - - } - } - } - - SetErrorMode( uiErrMode ); - - if( GetLastError() != 0 ) - { - USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT ); - - /* NOTE: Under 'Standard' behaviour, this error does not allow 'retry' - but if you should wish to make it so, then or EF_CANRETRY - with EF_CANDEFAULT above) - */ - - if( uiAction == E_RETRY ) - continue; - } - break; + if( GetDiskFreeSpace( szPath, + &dwSectorsPerCluster, + &dwBytesPerSector, + &dwNumberOfFreeClusters, + &dwTotalNumberOfClusters ) ) + dSpace = ( double ) dwNumberOfFreeClusters * + ( double ) dwSectorsPerCluster * + ( double ) dwBytesPerSector; } + + SetErrorMode( uiErrMode ); + + if( GetLastError() != 0 ) + bError = TRUE; } #elif defined(HB_OS_OS2) { struct _FSALLOCATE fsa; - USHORT rc; /* Query level 1 info from filesystem */ - while( ( rc = DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) ) != 0 ) - { - USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT ); - - /* NOTE: Under 'Standard' behaviour, this error does not allow 'retry' - but if you should wish to make it so, then or EF_CANRETRY with - EF_CANDEFAULT above) - */ - - if( uiAction != E_RETRY ) - break; - } - - if( rc == 0 ) - { - switch( uiType ) - { - case HB_DISK_AVAIL: - case HB_DISK_FREE: - dSpace = ( double ) fsa.cUnitAvail * - ( double ) fsa.cSectorUnit * - ( double ) fsa.cbSector; - break; - - case HB_DISK_USED: - case HB_DISK_TOTAL: - dSpace = ( double ) fsa.cUnit * - ( double ) fsa.cSectorUnit * - ( double ) fsa.cbSector; - - if( uiType == HB_DISK_USED ) - dSpace -= ( double ) fsa.cUnitAvail * - ( double ) fsa.cSectorUnit * - ( double ) fsa.cbSector; - break; - } - } + if( DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) == 0 ) + dSpace = ( double ) fsa.cUnitAvail * + ( double ) fsa.cSectorUnit * + ( double ) fsa.cbSector; + else + bError = TRUE; } #elif defined(HB_OS_UNIX) - { - /* NOTE: U*ix like file systems don't use drive letters */ - HB_SYMBOL_UNUSED( uiDrive ); - if( ISCHAR( 1 ) ) - { - struct statfs sf; - - statfs( hb_parc( 1 ), &sf ); - - switch( uiType ) - { - case HB_DISK_AVAIL: - dSpace = ( double ) sf.f_bavail * ( double ) sf.f_bsize; - break; - case HB_DISK_FREE: - dSpace = ( double ) sf.f_bfree * ( double ) sf.f_bsize; - break; - - case HB_DISK_USED: - dSpace = ( double ) ( sf.f_blocks - sf.f_bfree ) * - ( double ) sf.f_bsize; - break; - - case HB_DISK_TOTAL: - dSpace = ( double ) sf.f_blocks * ( double ) sf.f_bsize; - break; - } - } - } + { + HB_SYMBOL_UNUSED( uiDrive ); + } #else { HB_SYMBOL_UNUSED( uiDrive ); - HB_SYMBOL_UNUSED( uiType ); } #endif + if( bError ) + hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT ); + hb_retnlen( dSpace, -1, 0 ); } diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 69c98343e5..35e873a040 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -685,37 +685,6 @@ ULONG hb_fsWriteLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ) return ulWritten; } - -#if defined(HB_OS_OS2) -/* 19/06/2000 - maurilio.longo@libero.it */ -ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) -{ - ULONG ulPos; - USHORT Flags; - APIRET ret; - - HB_TRACE(HB_TR_DEBUG, ("hb_fsSeek(%p, %ld, %hu)", hFileHandle, lOffset, uiFlags)); - - Flags = convert_seek_flags( uiFlags ); - - if( lOffset < 0 && Flags == SEEK_SET ) { - ret = DosSetFilePtr(hFileHandle, 0, SEEK_CUR, &ulPos); - - } else { - ret = DosSetFilePtr(hFileHandle, lOffset, Flags, &ulPos); - - } - - if( ret != 0 ) { - ulPos = 0; - s_uiErrorLast = ret; - } - - return ulPos; -} - -#else - ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) { ULONG ulPos; @@ -728,7 +697,19 @@ ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) if( lOffset < 0 && Flags == SEEK_SET ) { - #if defined(HB_FS_FILE_IO) + #if defined(HB_OS_OS2) + + { + APIRET ret = DosSetFilePtr(hFileHandle, 0, SEEK_CUR, &ulPos); + + if( ret != 0 ) + { + ulPos = 0; + s_uiErrorLast = ( USHORT ) ret; + } + } + + #elif defined(HB_FS_FILE_IO) /* get current offset */ errno = 0; @@ -752,7 +733,19 @@ ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) else { - #if defined(HB_FS_FILE_IO) + #if defined(HB_OS_OS2) + + { + APIRET ret = DosSetFilePtr(hFileHandle, lOffset, Flags, &ulPos); + + if( ret != 0 ) + { + ulPos = 0; + s_uiErrorLast = ( USHORT ) ret; + } + } + + #elif defined(HB_FS_FILE_IO) errno = 0; ulPos = lseek( hFileHandle, lOffset, Flags ); @@ -774,7 +767,6 @@ ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) return ulPos; } -#endif ULONG hb_fsTell( FHANDLE hFileHandle ) { diff --git a/harbour/source/rtl/gt_tpl/gt_tpl.c b/harbour/source/rtl/gt_tpl/gt_tpl.c index 7e310b8cb4..ce9dd45fa0 100644 --- a/harbour/source/rtl/gt_tpl/gt_tpl.c +++ b/harbour/source/rtl/gt_tpl/gt_tpl.c @@ -70,15 +70,15 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask ) BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen ) { - USHORT row = s_usRow; - USHORT col = s_usCol; + USHORT row = hb_gt_Row(); + USHORT col = hb_gt_Col(); ULONG ulCount; HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos(%s, %lu)", pStr, ulLen )); for( ulCount = 0; ulCount < ulLen; ulCount++ ) { - switch( *pStr++ ) + switch( *pStr++ ) { case HB_CHAR_BEL: break; @@ -88,14 +88,14 @@ BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen ) col--; else { - col = s_usMaxCol; + col = hb_gt_GetScreenWidth(); if( row ) row--; } break; case HB_CHAR_LF: - if( row < s_usMaxRow ) + if( row < hb_gt_GetScreenHeight() ) row++; break; @@ -104,12 +104,12 @@ BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen ) break; default: - if( col < s_usMaxCol ) + if( col < hb_gt_GetScreenWidth() ) col++; else { col = 0; - if( row < s_usMaxRow ) + if( row < hb_gt_GetScreenHeight() ) row++; } } @@ -172,31 +172,29 @@ SHORT hb_gt_Row( void ) USHORT hb_gt_GetCursorStyle( void ) { - /* TODO: What shape is the cursor? */ - USHORT uiStyle = 0; + USHORT uiStyle; HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetCursorStyle()")); - /* example from the dos driver */ -/* - hb_gt_GetCursorSize( &start, &end ) + /* TODO: What shape is the cursor? */ - if( start == 32 && end == 32 ) - uiStyle = SC_NONE; + /* example from the dos driver */ - else if( start == 6 && end == 7 ) - uiStyle = SC_NORMAL; + hb_gt_GetCursorSize( &start, &end ) - else if( start == 4 && end == 7 ) - uiStyle = SC_INSERT; - - else if( start == 0 && end == 7 ) - uiStyle = SC_SPECIAL1; - - else if( start == 0 && end == 3 ) - uiStyle = SC_SPECIAL2; - } -*/ + if( start == 32 && end == 32 ) + uiStyle = SC_NONE; + else if( start == 6 && end == 7 ) + uiStyle = SC_NORMAL; + else if( start == 4 && end == 7 ) + uiStyle = SC_INSERT; + else if( start == 0 && end == 7 ) + uiStyle = SC_SPECIAL1; + else if( start == 0 && end == 3 ) + uiStyle = SC_SPECIAL2; + else + uiStyle = 0; + return uiStyle; } @@ -382,21 +380,20 @@ USHORT hb_gt_DispCount() void hb_gt_Replicate( USHORT uiRow, USHORT uiCol, BYTE byAttr, BYTE byChar, ULONG nLength ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Replicate(%hu, %hu, %i, %i, %lu)", uiRow, uiCol, byAttr, byChar, nLength)); - { - /* TODO: replace it with native (optimized) version */ - while( nLength-- ) - hb_gt_xPutch( uiRow, uiCol++, byAttr, byChar ); - } + + /* TODO: replace it with native (optimized) version */ + while( nLength-- ) + hb_gt_xPutch( uiRow, uiCol++, byAttr, byChar ); } USHORT hb_gt_Box( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, - BYTE * szBox, BYTE byAttr ) + BYTE * pbyFrame, BYTE byAttr ) { HB_SYMBOL_UNUSED( uiTop ); HB_SYMBOL_UNUSED( uiLeft ); HB_SYMBOL_UNUSED( uiBottom ); HB_SYMBOL_UNUSED( uiRight ); - HB_SYMBOL_UNUSED( szBox ); + HB_SYMBOL_UNUSED( pbyFrame ); HB_SYMBOL_UNUSED( byAttr ); return 0; diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index a07ab480d1..36d4a807a1 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -215,10 +215,10 @@ USHORT hb_gtBoxD( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ) if( uiLeft != uiRight ) hb_gt_BoxD( uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) _B_DOUBLE, ( BYTE ) s_pColor[ s_uiColorIndex ] ); else - hb_gt_VertLine( uiLeft, uiTop, uiBottom, _B_DOUBLE_H, ( BYTE ) s_pColor[ s_uiColorIndex ] ); + hb_gt_VertLine( uiLeft, uiTop, uiBottom, HB_B_DOUBLE_H, ( BYTE ) s_pColor[ s_uiColorIndex ] ); } else - hb_gt_HorizLine( uiTop, uiLeft, uiRight, _B_DOUBLE_V, ( BYTE ) s_pColor[ s_uiColorIndex ] ); + hb_gt_HorizLine( uiTop, uiLeft, uiRight, HB_B_DOUBLE_V, ( BYTE ) s_pColor[ s_uiColorIndex ] ); hb_gtSetPos( uiTop + 1, uiLeft + 1 ); @@ -244,10 +244,10 @@ USHORT hb_gtBoxS( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ) if( uiLeft != uiRight ) hb_gt_BoxS( uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) _B_SINGLE, ( BYTE ) s_pColor[ s_uiColorIndex ] ); else - hb_gt_VertLine( uiLeft, uiTop, uiBottom, _B_SINGLE_V, ( BYTE ) s_pColor[ s_uiColorIndex ] ); + hb_gt_VertLine( uiLeft, uiTop, uiBottom, HB_B_SINGLE_V, ( BYTE ) s_pColor[ s_uiColorIndex ] ); } else - hb_gt_HorizLine( uiTop, uiLeft, uiRight, _B_SINGLE_H, ( BYTE ) s_pColor[ s_uiColorIndex ] ); + hb_gt_HorizLine( uiTop, uiLeft, uiRight, HB_B_SINGLE_H, ( BYTE ) s_pColor[ s_uiColorIndex ] ); hb_gtSetPos( uiTop + 1, uiLeft + 1 ); diff --git a/harbour/source/rtl/gtapiu.c b/harbour/source/rtl/gtapiu.c index 543b48054a..33c5ea4741 100644 --- a/harbour/source/rtl/gtapiu.c +++ b/harbour/source/rtl/gtapiu.c @@ -37,38 +37,52 @@ void hb_gtWCreate( HB_GT_RECT * rect, HB_GT_WND ** wnd ) { + /* TODO: */ + HB_SYMBOL_UNUSED( rect ); HB_SYMBOL_UNUSED( wnd ); } void hb_gtWDestroy( HB_GT_WND * wnd ) { + /* TODO: */ + HB_SYMBOL_UNUSED( wnd ); } BOOL hb_gtWFlash( void ) { + /* TODO: */ + return FALSE; } void hb_gtWApp( HB_GT_WND ** wnd ) { + /* TODO: */ + HB_SYMBOL_UNUSED( wnd ); } void hb_gtWCurrent( HB_GT_WND * wnd ) { + /* TODO: */ + HB_SYMBOL_UNUSED( wnd ); } void hb_gtWPos( HB_GT_WND * wnd, HB_GT_RECT * rect ) { + /* TODO: */ + HB_SYMBOL_UNUSED( wnd ); HB_SYMBOL_UNUSED( rect ); } BOOL hb_gtWVis( HB_GT_WND * wnd, USHORT uiStatus ) { + /* TODO: */ + HB_SYMBOL_UNUSED( wnd ); HB_SYMBOL_UNUSED( uiStatus ); @@ -77,8 +91,8 @@ BOOL hb_gtWVis( HB_GT_WND * wnd, USHORT uiStatus ) USHORT hb_gtSLR( HB_GT_SLR * pSLR ) /* System Level Request */ { - /* Do nothing in Harbour, since it the low-level GT API is - implemented with a different method. */ + /* Do nothing in Harbour, since the low-level GT API is + implemented with a different method than in CA-Cl*pper. */ HB_SYMBOL_UNUSED( pSLR ); @@ -87,6 +101,8 @@ USHORT hb_gtSLR( HB_GT_SLR * pSLR ) /* System Level Request */ USHORT hb_gtModalRead( void * dummy ) { + /* TODO: */ + HB_SYMBOL_UNUSED( dummy ); return 1; @@ -94,21 +110,29 @@ USHORT hb_gtModalRead( void * dummy ) USHORT hb_gtBeginWrite( void ) { - return 1; + /* Do nothing in Harbour */ + + return 0; } USHORT hb_gtEndWrite( void ) { - return 1; + /* Do nothing in Harbour */ + + return 0; } USHORT hb_gtFlushCursor( void ) { + /* TODO: */ + return 1; } USHORT hb_gtSetColor( HB_GT_RGB * color ) { + /* TODO: */ + HB_SYMBOL_UNUSED( color ); return 1; @@ -116,6 +140,8 @@ USHORT hb_gtSetColor( HB_GT_RGB * color ) USHORT hb_gtGetColor( HB_GT_RGB * color ) { + /* TODO: */ + HB_SYMBOL_UNUSED( color ); return 1; @@ -123,6 +149,8 @@ USHORT hb_gtGetColor( HB_GT_RGB * color ) USHORT hb_gtSetBorder( HB_GT_RGB * color ) { + /* TODO: */ + HB_SYMBOL_UNUSED( color ); return 1; diff --git a/harbour/source/rtl/gtwin/gtwin.c b/harbour/source/rtl/gtwin/gtwin.c index 49e532306d..72ea445427 100644 --- a/harbour/source/rtl/gtwin/gtwin.c +++ b/harbour/source/rtl/gtwin/gtwin.c @@ -43,8 +43,6 @@ * * Copyright 1999 David G. Holm * hb_gt_Tone() - * - * Copyright 1999 David G. Holm * hb_gt_ReadKey() * * See doc/license.txt for licensing terms. diff --git a/harbour/source/vm/extend.c b/harbour/source/vm/extend.c index edef5fe375..84906800d6 100644 --- a/harbour/source/vm/extend.c +++ b/harbour/source/vm/extend.c @@ -336,7 +336,7 @@ int hb_parni( int iParam, ... ) ulArrayIndex = va_arg( va, ULONG ); va_end( va ); - return ( int ) hb_arrayGetNL( pItem, ulArrayIndex ); + return hb_arrayGetNI( pItem, ulArrayIndex ); } } @@ -559,7 +559,7 @@ void hb_storc( char * szText, int iParam, ... ) va_end( va ); hb_itemRelease( pItemNew ); } - else if( HB_IS_BYREF( pItem ) || iParam == -1 ) + else if( HB_IS_BYREF( pItem ) || iParam == -1 ) hb_itemPutC( hb_itemUnRef( pItem ), szText ); } } @@ -581,7 +581,7 @@ void hb_storclen( char * szText, ULONG ulLen, int iParam, ... ) va_end( va ); hb_itemRelease( pItemNew ); } - else if( HB_IS_BYREF( pItem ) || iParam == -1 ) + else if( HB_IS_BYREF( pItem ) || iParam == -1 ) hb_itemPutCL( hb_itemUnRef( pItem ), szText, ulLen ); } } @@ -605,7 +605,7 @@ void hb_stords( char * szDate, int iParam, ... ) va_end( va ); hb_itemRelease( pItemNew ); } - else if( HB_IS_BYREF( pItem ) || iParam == -1 ) + else if( HB_IS_BYREF( pItem ) || iParam == -1 ) hb_itemPutDS( hb_itemUnRef( pItem ), szDate ); } } @@ -627,7 +627,7 @@ void hb_storl( int iLogical, int iParam, ... ) va_end( va ); hb_itemRelease( pItemNew ); } - else if( HB_IS_BYREF( pItem ) || iParam == -1 ) + else if( HB_IS_BYREF( pItem ) || iParam == -1 ) hb_itemPutL( hb_itemUnRef( pItem ), iLogical ? TRUE : FALSE ); } } @@ -649,7 +649,7 @@ void hb_storni( int iValue, int iParam, ... ) va_end( va ); hb_itemRelease( pItemNew ); } - else if( HB_IS_BYREF( pItem ) || iParam == -1 ) + else if( HB_IS_BYREF( pItem ) || iParam == -1 ) hb_itemPutNI( hb_itemUnRef( pItem ), iValue ); } } @@ -672,7 +672,7 @@ void hb_stornl( long lValue, int iParam, ... ) hb_itemRelease( pItemNew ); } else if( HB_IS_BYREF( pItem ) || iParam == -1 ) - hb_itemPutNI( hb_itemUnRef( pItem ), lValue ); + hb_itemPutNL( hb_itemUnRef( pItem ), lValue ); } }