20000321-15:08 GMT+1 Victor Szakats <info@szelvesz.hu>

This commit is contained in:
Viktor Szakats
2000-03-21 14:12:00 +00:00
parent 3e5ebf8882
commit 17795ae485
15 changed files with 109 additions and 42 deletions

View File

@@ -1,3 +1,28 @@
20000321-15:08 GMT+1 Victor Szakats <info@szelvesz.hu>
* source/rtl/diskspac.c
+ Supports larger disks than 2GB by design.
+ Support added for Win95B, Win98, WinNT, Win2K to return the correct
free space for >2GB disks. (Wewwh, Win32 API *is* a strange beast ;)
* source/rtl/seconds.c
include/hbdate.h
* hb_secondsToday() -> hb_seconds() Hack to avoid name collision removed.
* include/hbdefs.h
pp/pplib.c
rtl/gtdos/gtdos.c
rtl/gtos2/gtos2.c
rtl/gtwin/gtwin.c
rtl/ampm.c
rtl/gtapi.c
rtl/memoline.c
rtl/round.c
vm/arrayshb.c
vm/fm.c
* HB_MIN_() -> HB_MIN()
HB_MAX_() -> HB_MAX()
20000321-12:32 GMT+1 Victor Szakats <info@szelvesz.hu>
* include/hbdefs.h

View File

@@ -40,7 +40,7 @@
extern char * hb_monthsname [];
extern char * hb_daysname [];
extern double hb_secondsToday( void );
extern double hb_seconds( void );
extern char * hb_cmonth( int iMonth );
extern char * hb_cdow( int iDay );
extern long hb_dow( long lDay, long lMonth, long lYear );

View File

@@ -102,10 +102,8 @@
#endif /* HB_DONT_DEFINE_BASIC_TYPES */
/* NOTE: Underscore postfix needed to avoid conflict with the functions
named HB_MIN() and HB_MAX() [vszakats] */
#define HB_MAX_( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
#define HB_MIN_( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
#define HB_MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
#define HB_MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
#define HB_LOBYTE( w ) ( ( BYTE ) ( w ) )
#define HB_HIBYTE( w ) ( ( BYTE ) ( ( ( USHORT ) ( w ) >> 8 ) & 0xFF ) )
@@ -145,10 +143,18 @@ typedef BYTE HB_ATTR;
typedef HARBOUR ( * PHB_FUNC )( void );
typedef PHB_FUNC HB_FUNC_PTR;
/* Function declaration macro */
/* Function declaration macros */
/* NOTE: The prefix is "HB_FUN_" currently, this is needed to
avoid collision with any other declared symbol.
Note that "HB_" is not enough, since the Harbour internals
are also prefixed with HB_. [vszakats] */
#define HB_FUNCNAME( funcname ) HB_FUN_##funcname
#define HB_FUNC( funcname ) HARBOUR HB_FUN_##funcname ( void )
/* */
typedef ULONG HB_HANDLE; /* handle to memvar value */
typedef char HB_SYMBOLSCOPE; /* stores symbol's scope */

View File

@@ -86,7 +86,7 @@ HB_FUNC( __PREPROCESS )
hb_pp_Init();
slen = HB_MIN_( hb_parclen( 1 ), HB_PP_STR_SIZE - 1 );
slen = HB_MIN( hb_parclen( 1 ), HB_PP_STR_SIZE - 1 );
memcpy( pText, hb_parc( 1 ), slen );
pText[ slen ] = 0; /* Preprocessor expects null-terminated string */
memset( pOut, 0, HB_PP_STR_SIZE );

View File

@@ -39,7 +39,7 @@ HB_FUNC( AMPM )
{
char * pszTime = hb_parc( 1 );
ULONG ulTimeLen = hb_parclen( 1 );
char * pszResult = ( char * ) hb_xgrab( HB_MAX_( ulTimeLen, 2 ) + 3 + 1 );
char * pszResult = ( char * ) hb_xgrab( HB_MAX( ulTimeLen, 2 ) + 3 + 1 );
USHORT uiHour = ( USHORT ) hb_strVal( pszTime );
BOOL bAM;

View File

@@ -44,11 +44,16 @@
*
*/
/* NOTE: DISKSPACE() supports larger disks than 2GB. CA-Cl*pper will always
return a (long) value, Harbour may return a (double) for large
values, the decimal places are always set to zero, though. */
#define HB_OS_WIN_32_USED
#include "hbapi.h"
#include "hbapierr.h"
#include "hbapifs.h"
#include "hbapiitm.h"
#if defined(HB_OS_DOS) || defined(__WATCOMC__)
#include <dos.h>
@@ -56,7 +61,7 @@
HB_FUNC( DISKSPACE )
{
ULONG ulSpaceFree = 0;
double dSpaceFree = 0.0;
USHORT uiDrive = ISNUM( 1 ) ? hb_parni( 1 ) : 0;
#if defined(HB_OS_DOS) || defined(__WATCOMC__)
@@ -73,19 +78,19 @@ HB_FUNC( DISKSPACE )
}
if( uiResult != 0 )
ulSpaceFree = ( ULONG ) disk.avail_clusters *
( ULONG ) disk.sectors_per_cluster *
( ULONG ) disk.bytes_per_sector;
dSpaceFree = ( double ) disk.avail_clusters *
( double ) disk.sectors_per_cluster *
( double ) disk.bytes_per_sector;
#elif defined(HB_OS_WIN_32)
{
char szPath[ 4 ];
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER);
char szPath[ 4 ];
P_GDFSE pGetDiskFreeSpaceEx;
/* Get the default drive */
@@ -103,15 +108,39 @@ HB_FUNC( DISKSPACE )
szPath[ 2 ] = '\\';
szPath[ 3 ] = '\0';
if( GetDiskFreeSpace( szPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters ) )
pGetDiskFreeSpaceEx = ( P_GDFSE ) GetProcAddress( GetModuleHandle( "kernel32.dll" ),
"GetDiskFreeSpaceExA");
if( pGetDiskFreeSpaceEx )
{
ulSpaceFree = dwNumberOfFreeClusters *
dwSectorsPerCluster *
dwBytesPerSector;
ULARGE_INTEGER i64FreeBytesToCaller;
ULARGE_INTEGER i64TotalBytes;
ULARGE_INTEGER i64FreeBytes;
if( pGetDiskFreeSpaceEx( szPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes ) )
dSpaceFree = ( double ) i64FreeBytesToCaller.QuadPart ;
}
else
{
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
if( GetDiskFreeSpace( szPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters ) )
{
dSpaceFree = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
}
}
}
@@ -121,6 +150,13 @@ HB_FUNC( DISKSPACE )
#endif
hb_retnl( ( long ) ulSpaceFree );
{
PHB_ITEM pRetVal;
pRetVal = hb_itemNew( NULL );
hb_itemPutNLen( pRetVal, dSpaceFree, -1, 0 );
hb_itemReturn( pRetVal );
hb_itemRelease( pRetVal );
}
}

View File

@@ -964,7 +964,7 @@ USHORT hb_gtDrawShadow( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiR
/* Draw the bottom edge */
if( uiBottom <= uiMaxRow && uiLeft <= uiMaxCol )
hb_gt_SetAttribute( uiBottom, uiLeft, uiBottom, HB_MIN_( uiRight, uiMaxCol ), byAttr );
hb_gt_SetAttribute( uiBottom, uiLeft, uiBottom, HB_MIN( uiRight, uiMaxCol ), byAttr );
uiRight++;
uiTop++;
@@ -972,7 +972,7 @@ USHORT hb_gtDrawShadow( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiR
/* Draw the right edge */
if( uiTop <= uiMaxRow && uiRight <= uiMaxCol )
hb_gt_SetAttribute( uiTop, uiRight, uiBottom, HB_MIN_( uiRight + 1, uiMaxCol ), byAttr );
hb_gt_SetAttribute( uiTop, uiRight, uiBottom, HB_MIN( uiRight + 1, uiMaxCol ), byAttr );
return 0;
}

View File

@@ -1029,7 +1029,7 @@ void hb_gt_Tone( double dFrequency, double dDuration )
/* The conversion from Clipper timer tick units to
milliseconds is * 1000.0 / 18.2. */
dFrequency = HB_MIN_( HB_MAX_( 0.0, dFrequency ), 32767.0 );
dFrequency = HB_MIN( HB_MAX( 0.0, dFrequency ), 32767.0 );
dDuration = dDuration * CLOCKS_PER_SEC / 18.2 ; /* clocks */
#if defined(__BORLANDC__) || defined(__WATCOMC__)
@@ -1042,7 +1042,7 @@ void hb_gt_Tone( double dFrequency, double dDuration )
{
/* Use USHORT, because this variable gets added to clock()
to form end_clock and we want to minimize overflow risk */
USHORT temp = ( USHORT ) HB_MIN_( HB_MAX_( 0, dDuration ), USHRT_MAX );
USHORT temp = ( USHORT ) HB_MIN( HB_MAX( 0, dDuration ), USHRT_MAX );
clock_t end_clock;
dDuration -= temp;

View File

@@ -584,12 +584,12 @@ void hb_gt_Tone( double dFrequency, double dDuration )
/* The conversion from Clipper timer tick units to
milliseconds is * 1000.0 / 18.2. */
dFrequency = HB_MIN_( HB_MAX_( 0.0, dFrequency ), 32767.0 );
dFrequency = HB_MIN( HB_MAX( 0.0, dFrequency ), 32767.0 );
dDuration = dDuration * 1000.0 / 18.2; /* milliseconds */
while( dDuration > 0.0 )
{
USHORT temp = ( USHORT ) HB_MIN_( HB_MAX_( 0, dDuration ), USHRT_MAX );
USHORT temp = ( USHORT ) HB_MIN( HB_MAX( 0, dDuration ), USHRT_MAX );
dDuration -= temp;
if( temp <= 0 )

View File

@@ -1146,10 +1146,10 @@ void hb_gt_Tone( double dFrequency, double dDuration )
milliseconds is * 1000.0 / 18.2. */
dDuration = dDuration * 1000.0 / 18.2; /* milliseconds */
dDuration = HB_MIN_( HB_MAX_( 0, dDuration ), ULONG_MAX );
dDuration = HB_MIN( HB_MAX( 0, dDuration ), ULONG_MAX );
if( dDuration > 0.0 )
Beep( ( ULONG ) HB_MIN_( HB_MAX_( 0.0, dFrequency ), 32767.0 ),
Beep( ( ULONG ) HB_MIN( HB_MAX( 0.0, dFrequency ), 32767.0 ),
( ULONG ) dDuration );
}

View File

@@ -70,7 +70,7 @@ HB_FUNC( MEMOLINE )
case HB_CHAR_LF:
ulCurLength = 0;
ulLastSpace = 0;
ulLineEnd = HB_MAX_( ulPos - 2, ulLineBegin );
ulLineEnd = HB_MAX( ulPos - 2, ulLineBegin );
ulLines++;
if( ulLines < ulLineNumber )
{

View File

@@ -121,7 +121,7 @@ HB_FUNC( ROUND )
{
int iDec = hb_parni( 2 );
hb_retndlen( hb_numRound( hb_parnd( 1 ), iDec ), 0, HB_MAX_( iDec, 0 ) );
hb_retndlen( hb_numRound( hb_parnd( 1 ), iDec ), 0, HB_MAX( iDec, 0 ) );
}
else
{

View File

@@ -42,7 +42,7 @@
#include <sys\timeb.h>
#endif
double hb_secondsToday( void )
double hb_seconds( void )
{
#if defined(_MSC_VER)
#define timeb _timeb
@@ -51,7 +51,7 @@ double hb_secondsToday( void )
struct timeb tb;
struct tm * oTime;
HB_TRACE(HB_TR_DEBUG, ("hb_secondsToday()"));
HB_TRACE(HB_TR_DEBUG, ("hb_seconds()"));
ftime( &tb );
oTime = localtime( &tb.time );
@@ -64,6 +64,6 @@ double hb_secondsToday( void )
HB_FUNC( SECONDS )
{
hb_retnd( hb_secondsToday() );
hb_retnd( hb_seconds() );
}

View File

@@ -127,7 +127,7 @@ HB_FUNC( ASIZE )
{
long lSize = hb_parnl( 2 );
hb_arraySize( pArray, HB_MAX_( lSize, 0 ) );
hb_arraySize( pArray, HB_MAX( lSize, 0 ) );
hb_itemReturn( pArray ); /* ASize() returns the array itself */
}

View File

@@ -507,7 +507,7 @@ ULONG hb_xquery( USHORT uiMode )
{
MEMORYSTATUS memorystatus;
GlobalMemoryStatus( &memorystatus );
ulResult = HB_MIN_( memorystatus.dwAvailPhys, ULONG_MAX ) / 1024;
ulResult = HB_MIN( memorystatus.dwAvailPhys, ULONG_MAX ) / 1024;
}
#else
ulResult = 9999;