diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 40419162c0..c45ae02428 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,14 @@ +2000-06-22 03:23 UTC+0100 Victor Szakats + + * source/rtl/filesys.c + * Some formatting and cleanups. + + * contrib/hbclip/hbclip.ch + + Some HB_ constants added. + + * include/inkey.ch + * K_HB_KEYCODES -> HB_K_MULTICODE + 2000-06-21 10:58 UTC-0800 Ron Pinkas * source/pp/ppcore.c ! getExpReal() to not return invalid Clipper Expression like unterminated '([{'. This will solve many PP problems. diff --git a/harbour/contrib/hbclip/hbclip.ch b/harbour/contrib/hbclip/hbclip.ch index 90e6a9a3bf..3481de81dd 100644 --- a/harbour/contrib/hbclip/hbclip.ch +++ b/harbour/contrib/hbclip/hbclip.ch @@ -48,7 +48,7 @@ #ifndef HB_CLIP_CH_ #define HB_CLIP_CH_ -/* TODO: Rewrite as much of these in C or Clipper */ +/* TODO: Rewrite as much of these in C or Clipper as possible */ #xtranslate HB_ARGCHECK( ) => ( .F. ) #xtranslate HB_ARGSTRING( ) => "" @@ -60,6 +60,12 @@ #xtranslate HB_SETKEYCHECK( [, [, [, ]]] ) => ( .F. ) #xtranslate HB_SETKEYARRAY( [, ] ) => AEval( , {| tmp | SetKey( tmp, ) } ) +/* HB_DISKSPACE() types */ +#define HB_DISK_AVAIL 0 +#define HB_DISK_FREE 1 +#define HB_DISK_USED 2 +#define HB_DISK_TOTAL 3 + /* Strong typing */ #translate AS ARRAY [OF ] => diff --git a/harbour/include/inkey.ch b/harbour/include/inkey.ch index 530841a8fd..781e0ca8f2 100644 --- a/harbour/include/inkey.ch +++ b/harbour/include/inkey.ch @@ -65,7 +65,7 @@ /* Harbour extension - this marks that multi-characters keycode will be returned - call INKEY() until ZERO will be returned */ -#define K_HB_KEYCODES 4096 +#define HB_K_MULTICODE 4096 /* Cursor movement keys */ diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 35e873a040..8d0bb4ff6b 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -700,7 +700,7 @@ ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) #if defined(HB_OS_OS2) { - APIRET ret = DosSetFilePtr(hFileHandle, 0, SEEK_CUR, &ulPos); + APIRET ret = DosSetFilePtr( hFileHandle, 0, SEEK_CUR, &ulPos ); if( ret != 0 ) { @@ -736,7 +736,7 @@ ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags ) #if defined(HB_OS_OS2) { - APIRET ret = DosSetFilePtr(hFileHandle, lOffset, Flags, &ulPos); + APIRET ret = DosSetFilePtr( hFileHandle, lOffset, Flags, &ulPos ); if( ret != 0 ) { @@ -881,38 +881,39 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart, #elif defined(HB_OS_OS2) - { - /* 08/04/2000 - maurilio.longo@libero.it */ - struct _FILELOCK fl, ful; + { + struct _FILELOCK fl, ful; errno = 0; - switch(uiMode) { - case FL_LOCK: + switch( uiMode ) + { + case FL_LOCK: - fl.lOffset = ulStart; - fl.lRange = ulLength; - ful.lOffset = 0; - ful.lRange = 0; + fl.lOffset = ulStart; + fl.lRange = ulLength; + ful.lOffset = 0; + ful.lRange = 0; - /* lock region, 2 seconds timeout, exclusive access - no atomic */ - iResult = (int) DosSetFileLocks(hFileHandle, &ful, &fl, 2000L, 0L); - break; + /* lock region, 2 seconds timeout, exclusive access - no atomic */ + iResult = ( int ) DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L ); + break; - case FL_UNLOCK: + case FL_UNLOCK: - fl.lOffset = 0; - fl.lRange = 0; - ful.lOffset = ulStart; - ful.lRange = ulLength; + fl.lOffset = 0; + fl.lRange = 0; + ful.lOffset = ulStart; + ful.lRange = ulLength; - /* unlock region, 2 seconds timeout, exclusive access - no atomic */ - iResult = (int) DosSetFileLocks(hFileHandle, &ful, &fl, 2000L, 0L); - break; + /* unlock region, 2 seconds timeout, exclusive access - no atomic */ + iResult = ( int ) DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L ); + break; + + default: + iResult = 0; + } - default: - iResult = 0; - } s_uiErrorLast = errno; } @@ -965,12 +966,14 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart, } #elif defined(__GNUC__) && defined(HB_OS_UNIX) - errno = 0; + { /* TODO: check for append locks (SEEK_END) */ struct flock lock_info; + errno = 0; + switch( uiMode ) { case FL_LOCK: @@ -980,11 +983,13 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart, lock_info.l_len = ulLength; lock_info.l_whence = SEEK_SET; /* start from the beginning of the file */ lock_info.l_pid = getpid(); + iResult = fcntl( hFileHandle, F_SETLK, &lock_info ); + if( iResult < 0 ) - iResult = FALSE; /* lock failed */ + iResult = 1; /* lock failed */ else - iResult = TRUE; /* lock was successful */ + iResult = 0; /* lock was successful */ } break; @@ -995,7 +1000,9 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart, lock_info.l_len = ulLength; lock_info.l_whence = SEEK_SET; lock_info.l_pid = getpid(); + iResult = fcntl( hFileHandle, F_SETLK, &lock_info ); + if( iResult < 0 ) iResult = 0; /* lock failed */ } @@ -1004,8 +1011,10 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart, default: iResult = 0; } + + s_uiErrorLast = errno; } - s_uiErrorLast = errno; + #else iResult = 1; @@ -1013,7 +1022,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart, #endif - return ( iResult ? FALSE : TRUE ); + return iResult == 0; } void hb_fsCommit( FHANDLE hFileHandle ) @@ -1040,32 +1049,29 @@ void hb_fsCommit( FHANDLE hFileHandle ) #elif defined(HB_OS_OS2) - { + { errno = 0; - /* 08/04/2000 - maurilio.longo@libero.it - TODO: what about error code from DosResetBuffer() call? */ - DosResetBuffer(hFileHandle); + /* TODO: what about error code from DosResetBuffer() call? */ + DosResetBuffer( hFileHandle ); s_uiErrorLast = errno; } #elif defined(HB_OS_UNIX) + /* NOTE: close() functions releases all lock regardles if it is an * original or duplicated file handle */ #if defined(_POSIX_SYNCHRONIZED_IO) - /* faster - flushes data buffers only, without updating directory info - */ - if( fdatasync( hFileHandle ) < -1 ) + /* faster - flushes data buffers only, without updating directory info + */ + s_uiErrorLast = ( fdatasync( hFileHandle ) < -1 ) ? FS_ERROR : 0; #else - /* slower - flushes all file data buffers and i-node info - */ - if( fsync( hFileHandle ) < -1 ) + /* slower - flushes all file data buffers and i-node info + */ + s_uiErrorLast = ( fsync( hFileHandle ) < -1 ) ? FS_ERROR : 0; #endif - s_uiErrorLast = FS_ERROR; /* failure */ - else - s_uiErrorLast = 0; #else @@ -1099,7 +1105,7 @@ BOOL hb_fsMkDir( BYTE * pDirname ) #endif - return ( iResult ? FALSE : TRUE ); + return iResult == 0; } BOOL hb_fsChDir( BYTE * pDirname ) @@ -1121,7 +1127,7 @@ BOOL hb_fsChDir( BYTE * pDirname ) #endif - return ( iResult ? FALSE : TRUE ); + return iResult == 0; } BOOL hb_fsRmDir( BYTE * pDirname ) @@ -1143,7 +1149,7 @@ BOOL hb_fsRmDir( BYTE * pDirname ) #endif - return ( iResult ? FALSE : TRUE ); + return iResult == 0; } /* NOTE: This is not thread safe function, it's there for compatibility. */