2007-11-03 02:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/contrib/bmdbfcdx/bmdbfcdx1.c
    * replaced all direct access to hb_set structure with functions
      Now it's possible to link bmdbfcdx with harbour.dll but because
      it still access hb_cdp_page then only if linker supports auto
      import conversions

  * harbour/source/common/hbfsapi.c
  * harbour/source/main/harbour.c
  * harbour/source/pp/hbppgen.c
  * harbour/utils/hbpp/hbpp.c
    * added filename conversion (hb_fsNameConv()) to hb_fsFileExists()
      function

  * harbour/include/hbapifs.h
  + harbour/source/common/hbfopen.c
  * harbour/source/common/Makefile
  * harbour/common.mak
    + added hb_fopen() function - it's a wrapper to fopen() function but
      calls internally hb_fsNameConv()

  * harbour/source/pp/hbppgen.c
  * harbour/source/pp/ppcore.c
  * harbour/source/common/hbtrace.c
  * harbour/source/compiler/hbmain.c
  * harbour/source/compiler/genhrb.c
  * harbour/source/compiler/gencobj.c
  * harbour/source/compiler/genobj32.c
  * harbour/source/compiler/genc.c
  * harbour/source/rtl/gtchrmap.c
  * harbour/source/vm/fm.c
    * use hb_fopen() instead of fopen()
This commit is contained in:
Przemyslaw Czerpak
2007-11-03 01:35:47 +00:00
parent cfdacbcef1
commit 13427dd60a
19 changed files with 169 additions and 36 deletions

View File

@@ -8,6 +8,39 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-11-03 02:35 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/bmdbfcdx/bmdbfcdx1.c
* replaced all direct access to hb_set structure with functions
Now it's possible to link bmdbfcdx with harbour.dll but because
it still access hb_cdp_page then only if linker supports auto
import conversions
* harbour/source/common/hbfsapi.c
* harbour/source/main/harbour.c
* harbour/source/pp/hbppgen.c
* harbour/utils/hbpp/hbpp.c
* added filename conversion (hb_fsNameConv()) to hb_fsFileExists()
function
* harbour/include/hbapifs.h
+ harbour/source/common/hbfopen.c
* harbour/source/common/Makefile
* harbour/common.mak
+ added hb_fopen() function - it's a wrapper to fopen() function but
calls internally hb_fsNameConv()
* harbour/source/pp/hbppgen.c
* harbour/source/pp/ppcore.c
* harbour/source/common/hbtrace.c
* harbour/source/compiler/hbmain.c
* harbour/source/compiler/genhrb.c
* harbour/source/compiler/gencobj.c
* harbour/source/compiler/genobj32.c
* harbour/source/compiler/genc.c
* harbour/source/rtl/gtchrmap.c
* harbour/source/vm/fm.c
* use hb_fopen() instead of fopen()
2007-11-02 18:52 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* harbour/source/common/hbfsapi.c
! fixed hb_fsFileExists() to return TRUE for files only

View File

@@ -288,6 +288,7 @@ COMMON_LIB_OBJS = \
$(OBJ_DIR)\hbarch$(OBJEXT) \
$(OBJ_DIR)\hbfhnd$(OBJEXT) \
$(OBJ_DIR)\hbfsapi$(OBJEXT) \
$(OBJ_DIR)\hbfopen$(OBJEXT) \
$(OBJ_DIR)\hbgete$(OBJEXT) \
$(OBJ_DIR)\hbwince$(OBJEXT) \
$(OBJ_DIR)\hbhash$(OBJEXT) \

View File

@@ -3928,7 +3928,7 @@ static BOOL hb_cdxCheckRecordFilter( CDXAREAP pArea, ULONG ulRecNo )
if( pArea->ulRecNo != ulRecNo || pArea->lpdbPendingRel )
SELF_GOTO( ( AREAP ) pArea, ulRecNo );
if( hb_set.HB_SET_DELETED )
if( hb_setGetL( HB_SET_DELETED ) )
SUPER_DELETED( ( AREAP ) pArea, &lResult );
if( !lResult && pArea->dbfi.itmCobExpr )
@@ -3948,12 +3948,12 @@ static BOOL hb_cdxCheckRecordFilter( CDXAREAP pArea, ULONG ulRecNo )
else
lResult = TRUE;
}
else if ( pArea->dbfi.itmCobExpr || hb_set.HB_SET_DELETED )
else if ( pArea->dbfi.itmCobExpr || hb_setGetL( HB_SET_DELETED ) )
{
if( pArea->ulRecNo != ulRecNo || pArea->lpdbPendingRel )
SELF_GOTO( ( AREAP ) pArea, ulRecNo );
if( hb_set.HB_SET_DELETED )
if( hb_setGetL( HB_SET_DELETED ) )
SUPER_DELETED( ( AREAP ) pArea, &lResult );
if( !lResult && pArea->dbfi.itmCobExpr )
@@ -4884,7 +4884,7 @@ static void hb_cdxCreateFName( CDXAREAP pArea, char * szBagName, BOOL * fProd,
szBaseName[ 0 ] = '\0';
}
if( ( hb_set.HB_SET_DEFEXTENSIONS && !pFileName->szExtension ) || !fName )
if( ( hb_setGetL( HB_SET_DEFEXTENSIONS ) && !pFileName->szExtension ) || !fName )
{
DBORDERINFO pExtInfo;
memset( &pExtInfo, 0, sizeof( pExtInfo ) );
@@ -7289,7 +7289,7 @@ static ERRCODE hb_cdxFlush( CDXAREAP pArea )
uiError = SUPER_FLUSH( ( AREAP ) pArea );
if ( hb_set.HB_SET_HARDCOMMIT )
if ( hb_setGetL( HB_SET_HARDCOMMIT ) )
{
pIndex = pArea->lpIndexes;
while ( pIndex )
@@ -7632,7 +7632,7 @@ static ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo )
}
/* open (production) structural index */
if( CDXAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_set.HB_SET_AUTOPEN )
if( CDXAREA_DATA( pArea )->fStrictStruct ? pArea->fHasTags : hb_setGetL( HB_SET_AUTOPEN ) )
{
char szFileName[ _POSIX_PATH_MAX + 1 ];
@@ -7650,7 +7650,7 @@ static ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo )
errCode = SELF_ORDLSTADD( ( AREAP ) pArea, &pOrderInfo );
if( errCode == SUCCESS )
{
pOrderInfo.itmOrder = hb_itemPutNI( NULL, hb_set.HB_SET_AUTORDER );
pOrderInfo.itmOrder = hb_itemPutNI( NULL, hb_setGetL( HB_SET_AUTORDER ) );
errCode = SELF_ORDLSTFOCUS( ( AREAP ) pArea, &pOrderInfo );
hb_itemRelease( pOrderInfo.itmOrder );
if( errCode == SUCCESS )
@@ -7850,7 +7850,7 @@ static ERRCODE hb_cdxOrderListClear( CDXAREAP pArea )
return FAILURE;
hb_cdxOrdListClear( pArea, !( CDXAREA_DATA( pArea )->fStrictStruct ?
pArea->fHasTags : hb_set.HB_SET_AUTOPEN ), NULL );
pArea->fHasTags : hb_setGetL( HB_SET_AUTOPEN ) ), NULL );
pArea->uiTag = 0;
return SUCCESS;
@@ -8087,7 +8087,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo
if ( !pArea->lpdbOrdCondInfo ||
( pArea->lpdbOrdCondInfo->fAll && !pArea->lpdbOrdCondInfo->fAdditive ) )
hb_cdxOrdListClear( pArea, !( CDXAREA_DATA( pArea )->fStrictStruct ?
pArea->fHasTags : hb_set.HB_SET_AUTOPEN ), NULL );
pArea->fHasTags : hb_setGetL( HB_SET_AUTOPEN ) ), NULL );
pIndex = hb_cdxFindBag( pArea, szFileName );
@@ -8207,7 +8207,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo
!pArea->lpdbOrdCondInfo->fAdditive ) )
{
hb_cdxOrdListClear( pArea, !( CDXAREA_DATA( pArea )->fStrictStruct ?
pArea->fHasTags : hb_set.HB_SET_AUTOPEN ), NULL );
pArea->fHasTags : hb_setGetL( HB_SET_AUTOPEN ) ), NULL );
}
hb_cdxIndexUnLockWrite( pIndex );
/* Update DBF header */
@@ -8215,7 +8215,7 @@ static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo
{
pArea->fHasTags = TRUE;
if ( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) == 0 &&
( hb_set.HB_SET_AUTOPEN || CDXAREA_DATA( pArea )->fStrictStruct ) )
( hb_setGetL( HB_SET_AUTOPEN ) || CDXAREA_DATA( pArea )->fStrictStruct ) )
SELF_WRITEDBHEADER( ( AREAP ) pArea );
}
else
@@ -8282,7 +8282,7 @@ static ERRCODE hb_cdxOrderDestroy( CDXAREAP pArea, LPDBORDERINFO pOrderInfo )
{
pArea->fHasTags = FALSE;
if ( !pArea->fReadonly && ( pArea->dbfHeader.bHasTags & 0x01 ) != 0 &&
( hb_set.HB_SET_AUTOPEN ||
( hb_setGetL( HB_SET_AUTOPEN ) ||
CDXAREA_DATA( pArea )->fStrictStruct ) )
SELF_WRITEDBHEADER( ( AREAP ) pArea );
}
@@ -9970,7 +9970,7 @@ static void hb_cdxTagDoIndex( LPCDXTAG pTag, BOOL fReindex )
pArea->uiTag = 0;
}
}
fDirectRead = !hb_set.HB_SET_STRICTREAD && /* !pArea->lpdbRelations && */
fDirectRead = !hb_setGetL( HB_SET_STRICTREAD ) && /* !pArea->lpdbRelations && */
( !pArea->lpdbOrdCondInfo || pArea->lpdbOrdCondInfo->fAll ||
( pArea->uiTag == 0 && !fUseFilter ) );

View File

@@ -229,6 +229,9 @@ 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 );
/* wrapper to fopen() which calls hb_fsNameConv() */
extern FILE * hb_fopen( const char *path, const char *mode );
HB_EXTERN_END
#endif /* HB_APIFS_H_ */

View File

@@ -7,6 +7,7 @@ ROOT = ../../
C_SOURCES=\
hbfhnd.c \
hbfsapi.c \
hbfopen.c \
hbgete.c \
hbwince.c \
hbhash.c \

View File

@@ -0,0 +1,65 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
*
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "hbapifs.h"
FILE * hb_fopen( const char *path, const char *mode )
{
BOOL fFree;
char * pszFile = ( char * ) hb_fsNameConv( ( BYTE * ) path, &fFree );
FILE * file = fopen( pszFile, mode );
if( fFree )
hb_xfree( pszFile );
return file;
}

View File

@@ -279,11 +279,16 @@ HB_EXPORT char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName )
HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName )
{
BOOL fExist;
BOOL fFree;
HB_TRACE(HB_TR_DEBUG, ("hb_fsFileExists(%p)", pszFileName));
if( pszFileName == NULL )
return FALSE;
pszFileName = ( char * ) hb_fsNameConv( ( BYTE * ) pszFileName, &fFree );
#if defined( HB_OS_DOS )
{
union REGS regs;
@@ -295,26 +300,34 @@ HB_EXPORT BOOL hb_fsFileExists( const char * pszFileName )
HB_DOS_INT86X( 0x21, &regs, &regs, &sregs );
return regs.x.cflag == 0;
fExist = regs.x.cflag == 0;
}
#elif defined( HB_OS_WIN_32 )
{
DWORD dwAttr;
dwAttr = GetFileAttributesA( pszFileName );
return ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
( dwAttr & ( FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE ) ) == 0;
fExist = ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
( dwAttr & ( FILE_ATTRIBUTE_DIRECTORY |
FILE_ATTRIBUTE_DEVICE ) ) == 0;
}
#elif defined( HB_OS_UNIX )
{
struct stat statbuf;
return stat( pszFileName, &statbuf ) == 0 &&
( statbuf.st_mode & S_IFMT ) == S_IFREG;
fExist = stat( pszFileName, &statbuf ) == 0 &&
S_ISREG( statbuf.st_mode );
}
#else
{
return FALSE;
int TODO; /* To force warning */
fExist = FALSE;
}
#endif
if( fFree )
hb_xfree( ( void * ) pszFileName );
return fExist;
}

View File

@@ -56,6 +56,7 @@
#include <string.h>
#include "hbapi.h"
#include "hbapifs.h"
#include "hb_io.h"
#include "hbtrace.h"
@@ -115,7 +116,7 @@ int hb_tr_level( void )
env = hb_getenv( "HB_TR_OUTPUT" );
if( env != NULL && env[ 0 ] != '\0' )
{
s_fp = fopen( env, "w" );
s_fp = hb_fopen( env, "w" );
if( s_fp == NULL )
s_fp = stderr;

View File

@@ -70,7 +70,7 @@ void hb_compGenCCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the
pFileName->szExtension = ".c";
hb_fsFNameMerge( szFileName, pFileName );
yyc = fopen( szFileName, "wb" );
yyc = hb_fopen( szFileName, "wb" );
if( ! yyc )
{
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CREATE_OUTPUT, szFileName, NULL );

View File

@@ -163,7 +163,7 @@ void hb_compGenCObj( HB_COMP_DECL, PHB_FNAME pFileName )
if( pszEnv && *hb_searchpath( pszCfgFileName, pszEnv, pszTemp ) )
{
filecfg = fopen( pszTemp, "rt" );
filecfg = hb_fopen( pszTemp, "rt" );
if( ! filecfg )
{
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_OPEN_CFG, szFileName, NULL );

View File

@@ -141,7 +141,7 @@ void hb_compGenPortObj( HB_COMP_DECL, PHB_FNAME pFileName )
pFileName->szExtension = ".hrb";
hb_fsFNameMerge( szFileName, pFileName );
yyc = fopen( szFileName, "wb" );
yyc = hb_fopen( szFileName, "wb" );
if( ! yyc )
{
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CREATE_OUTPUT, szFileName, NULL );

View File

@@ -72,7 +72,7 @@ void hb_compGenObj32( HB_COMP_DECL, PHB_FNAME pFileName )
pFileName->szExtension = ".obj";
hb_fsFNameMerge( szFileName, pFileName );
if( ( hObjFile = fopen( szFileName, "wb" ) ) == NULL )
if( ( hObjFile = hb_fopen( szFileName, "wb" ) ) == NULL )
{
hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CREATE_OUTPUT, szFileName, NULL );
return;

View File

@@ -209,7 +209,7 @@ static int hb_compProcessRSPFile( HB_COMP_DECL, char * szRspName )
szRspName = szFile;
}
inFile = fopen( szRspName, "r" );
inFile = hb_fopen( szRspName, "r" );
if( !inFile )
{
char buffer[ _POSIX_PATH_MAX + 80 ];

View File

@@ -51,6 +51,7 @@
*/
#include "hbcomp.h"
#include "hbapifs.h"
#include "hbmemory.ch"
int main( int argc, char * argv[] )
@@ -360,3 +361,11 @@ char * hb_conNewLine( void )
{
return "\n";
}
HB_EXPORT BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree )
{
if( pfFree )
* pfFree = FALSE;
return szFileName;
}

View File

@@ -65,6 +65,7 @@
void * hb_xgrab( ULONG ulSize ) { return malloc( ulSize ); }
void * hb_xrealloc( void * pMem, ULONG ulSize ) { return realloc( pMem, ulSize ); }
void hb_xfree( void * pMem ) { free( pMem ); }
BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) { if( pfFree ) * pfFree = FALSE; return szFileName; }
/*
@@ -275,7 +276,7 @@ static int hb_pp_preprocesfile( PHB_PP_STATE pState, char * szRuleFile )
{
FILE * foutr;
foutr = fopen( szRuleFile, "w" );
foutr = hb_fopen( szRuleFile, "w" );
if( !foutr )
{
#if !defined(__MINGW32CE__) && !defined(HB_WINCE)

View File

@@ -1804,7 +1804,7 @@ static PHB_PP_FILE hb_pp_FileNew( PHB_PP_STATE pState, char * szFileName,
}
}
file_in = fopen( szFileName, "r" );
file_in = hb_fopen( szFileName, "r" );
#if !defined(__MINGW32CE__) && !defined(HB_WINCE)
fNested = errno == EMFILE;
#endif
@@ -1825,7 +1825,7 @@ static PHB_PP_FILE hb_pp_FileNew( PHB_PP_STATE pState, char * szFileName,
{
pFileName->szPath = pPath->szPath;
hb_fsFNameMerge( szFileNameBuf, pFileName );
file_in = fopen( szFileNameBuf, "r" );
file_in = hb_fopen( szFileNameBuf, "r" );
pPath = pPath->pNext;
}
}
@@ -5223,7 +5223,7 @@ BOOL hb_pp_outFile( PHB_PP_STATE pState, const char * szOutFileName,
if( file_out )
pState->file_out = file_out;
else
pState->file_out = fopen( szOutFileName, "w" );
pState->file_out = hb_fopen( szOutFileName, "w" );
if( pState->file_out )
{
@@ -5252,7 +5252,7 @@ BOOL hb_pp_traceFile( PHB_PP_STATE pState, const char * szTraceFileName, FILE *
if( file_trace )
pState->file_trace = file_trace;
else
pState->file_trace = fopen( szTraceFileName, "w" );
pState->file_trace = hb_fopen( szTraceFileName, "w" );
if( pState->file_trace )
{

View File

@@ -55,10 +55,7 @@
/* NOTE: User programs should never call this layer directly! */
#include "hbgtcore.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hbapifs.h"
#define MAX_CHAR_VAL 0xff
#define HB_CHRMAP(a,c) ( ( (a) << 16 ) | (c) )
@@ -377,7 +374,7 @@ static int hb_gt_chrmapread( const char *pszFile, const char *pszTerm, int *nTra
char buf[256], *ptr, *pTerm;
int isTerm = -1;
fp = fopen( pszFile, "r" );
fp = hb_fopen( pszFile, "r" );
if( fp != NULL )
{

View File

@@ -82,6 +82,7 @@
#include "hbvmopt.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapifs.h"
#include "hbstack.h"
#include "hbapierr.h"
#include "hbmemory.ch"
@@ -582,7 +583,7 @@ HB_EXPORT void hb_xexit( void ) /* Deinitialize fixed memory subsystem */
FILE *hLog = NULL;
if( s_lMemoryBlocks )
hLog = fopen( "fm.log", "a+" );
hLog = hb_fopen( "fm.log", "a+" );
hb_conOutErr( hb_conNewLine(), 0 );
hb_conOutErr( "----------------------------------------", 0 );

View File

@@ -519,6 +519,14 @@ void hb_xfree( void * pMem ) /* frees fixed memory */
hb_compGenError( NULL, hb_pp_szErrors, 'P', HB_PP_ERR_MEMFREE, NULL, NULL );
}
BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree )
{
if( pfFree )
* pfFree = FALSE;
return szFileName;
}
static BOOL hb_pp_fopen( char * szFileName )
{
PFILE pFile;