diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e0743d903e..4bffce2d92 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,42 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-03 20:34 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/fstemp.c + * include/hbapifs.h + * include/hbextern.ch + + Added HB_DIRTEMP() .prg level function. Returns name of temp dir, + with closing backslash. + + Added hb_fsTempDir() .c level function. + ; Please review, especially MS-DOS, OS/2, which I won't be able + to test. + + * src/rtl/fstemp.c + * Cleanup: Deleted hb_fsCreateTempLow(), made layout more clear. + ; TOFIX: For some builds, MS-DOS, OS/2 and WIN without WIN IO + the temp directory will be wrongly calculated by checking + TMPDIR envvar. Such envvar seems *nix specific. + If new hb_fsTempDir() will be tested, above can be fixed + by using this new function. + + * package/winuni/RELNOTES + + Noted update to Firebird 2.5.0rc1 + + * contrib/hbpgsql/postgres.c + + Marked recently deprecated function as HB_LEGACY_LEVEL3. + + * contrib/hbfbird/firebird.c + * Cleanup for a macro. + + * contrib/hbnetio/utils/netiosrv.prg + + Using HB_HRB_BIND_FORCELOCAL when loading .hrb. + + * contrib/hbnetio/utils/modules/test.prg + + Marked function as STATIC. + + * ChangeLog + * Old TODO marked DONE. + 2010-02-03 19:08 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbvm.h * harbour/src/vm/hvm.c @@ -95363,7 +95399,7 @@ + Added support for MSVC for all above libs. + Added "implib" for rdd_ads. TOFIX: Doesn't work for MSVC. ; TOFIX: directx won't build under MSVC with an error. - ; TOFIX: I couldn't compile pgsql using latest 8.2.5. + ; TOFIX: I couldn't compile pgsql using latest 8.2.5. [DONE] * contrib/samples/gauge.c ! Fixed MSVC warning. diff --git a/harbour/contrib/hbfbird/firebird.c b/harbour/contrib/hbfbird/firebird.c index 2a4665ec83..ca157133a0 100644 --- a/harbour/contrib/hbfbird/firebird.c +++ b/harbour/contrib/hbfbird/firebird.c @@ -71,7 +71,7 @@ #define MAX_LEN 256 #define MAX_BUFFER 1024 -#define ERREXIT( status ) { hb_retnl( isc_sqlcode( status ) ); return; } +#define HB_RETNL_FBERROR( status ) { hb_retnl( isc_sqlcode( status ) ); return; } #ifndef ISC_INT64_FORMAT #define ISC_INT64_FORMAT PFLL @@ -267,9 +267,7 @@ HB_FUNC( FBQUERY ) trans = ( isc_tr_handle ) ( HB_PTRDIFF ) hb_parptr( 4 ); } else if( isc_start_transaction( status, &trans, 1, &db, 0, NULL ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); /* Allocate an output SQLDA. Just to check number of columns */ sqlda = ( XSQLDA * ) hb_xgrab( XSQLDA_LENGTH ( 1 ) ); @@ -278,21 +276,15 @@ HB_FUNC( FBQUERY ) /* Allocate a statement */ if( isc_dsql_allocate_statement( status, &db, &stmt ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); /* Prepare the statement. */ if( isc_dsql_prepare( status, &trans, &stmt, 0, sel_str, dialect, sqlda ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); /* Describe sql contents */ if( isc_dsql_describe( status, &stmt, dialect, sqlda ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); num_cols = sqlda->sqld; aNew = hb_itemArrayNew( num_cols ); @@ -309,9 +301,7 @@ HB_FUNC( FBQUERY ) sqlda->version = 1; if( isc_dsql_describe( status, &stmt, dialect, sqlda ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); } for( i = 0, var = sqlda->sqlvar; i < sqlda->sqld; i++, var++ ) @@ -355,16 +345,12 @@ HB_FUNC( FBQUERY ) { /* Execute and commit non-select querys */ if( isc_dsql_execute( status, &trans, &stmt, dialect, NULL ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); } else { if( isc_dsql_execute( status, &trans, &stmt, dialect, sqlda ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); } qry_handle = hb_itemArrayNew( 6 ); @@ -399,9 +385,7 @@ HB_FUNC( FBFETCH ) fetch_stat = isc_dsql_fetch( status, &stmt, dialect, sqlda ); if( fetch_stat != 100L ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); } hb_retnl( 0 ); @@ -419,16 +403,12 @@ HB_FUNC( FBFREE ) ISC_STATUS status[ MAX_FIELDS ]; if( isc_dsql_free_statement( status, &stmt, DSQL_drop ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); if( trans ) { if( isc_commit_transaction( status, &trans ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); } /* TOFIX: Freeing pointer received as parameter? We should at least set the item NULL. */ @@ -457,9 +437,7 @@ HB_FUNC( FBGETDATA ) ISC_QUAD * blob_id; if( ( pos + 1 ) > sqlda->sqln ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); var = sqlda->sqlvar + pos; dtype = var->sqltype & ~1; @@ -617,21 +595,15 @@ HB_FUNC( FBGETBLOB ) ISC_STATUS blob_stat; if( HB_ISPOINTER( 3 ) ) - { trans = ( isc_tr_handle ) ( HB_PTRDIFF ) hb_parptr( 3 ); - } else { if( isc_start_transaction( status, &trans, 1, &db, 0, NULL ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); } if( isc_open_blob2( status, &db, &trans, &blob_handle, blob_id, 0, NULL ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); /* Get blob segments and their lengths and print each segment. */ blob_stat = isc_get_segment( status, &blob_handle, @@ -663,15 +635,11 @@ HB_FUNC( FBGETBLOB ) } if( isc_close_blob( status, &blob_handle ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); if( ! HB_ISPOINTER( 3 ) ) { if( isc_commit_transaction( status, &trans ) ) - { - ERREXIT( status ); - } + HB_RETNL_FBERROR( status ); } } diff --git a/harbour/contrib/hbnetio/utils/modules/test.prg b/harbour/contrib/hbnetio/utils/modules/test.prg index 6fdd5f011b..192c02fb3a 100644 --- a/harbour/contrib/hbnetio/utils/modules/test.prg +++ b/harbour/contrib/hbnetio/utils/modules/test.prg @@ -2,7 +2,7 @@ * $Id$ */ -FUNCTION HBNETIOSRV_RPCMAIN( sFunc, ... ) +STATIC FUNCTION HBNETIOSRV_RPCMAIN( sFunc, ... ) OutStd( "DO", sFunc:name, "WITH", ..., hb_osNewLine() ) diff --git a/harbour/contrib/hbnetio/utils/netiosrv.prg b/harbour/contrib/hbnetio/utils/netiosrv.prg index 0a0a097cac..4e544ccf52 100644 --- a/harbour/contrib/hbnetio/utils/netiosrv.prg +++ b/harbour/contrib/hbnetio/utils/netiosrv.prg @@ -93,7 +93,7 @@ PROCEDURE Main( ... ) hb_StrClear( @cParam ) CASE Lower( Left( cParam, 5 ) ) == "-rpc=" netiosrv[ _NETIOSRV_cRPCFFileName ] := SubStr( cParam, 6 ) - netiosrv[ _NETIOSRV_cRPCFHRB ] := hb_hrbLoad( netiosrv[ _NETIOSRV_cRPCFFileName ] ) + netiosrv[ _NETIOSRV_cRPCFHRB ] := hb_hrbLoad( HB_HRB_BIND_FORCELOCAL, netiosrv[ _NETIOSRV_cRPCFFileName ] ) netiosrv[ _NETIOSRV_lRPC ] := ! Empty( netiosrv[ _NETIOSRV_cRPCFHRB ] ) .AND. ! Empty( hb_hrbGetFunSym( netiosrv[ _NETIOSRV_cRPCFHRB ], _RPC_FILTER ) ) IF ! netiosrv[ _NETIOSRV_lRPC ] netiosrv[ _NETIOSRV_cRPCFFileName ] := NIL diff --git a/harbour/contrib/hbpgsql/postgres.c b/harbour/contrib/hbpgsql/postgres.c index f92bc167b0..67f9f3dd4a 100644 --- a/harbour/contrib/hbpgsql/postgres.c +++ b/harbour/contrib/hbpgsql/postgres.c @@ -295,6 +295,8 @@ HB_FUNC( PQSETDBLOGIN ) hb_parcx( 7 ) /* pwd */ ) ); } +#if defined( HB_LEGACY_LEVEL3 ) + /* NOTE: Deprecated */ HB_FUNC( PQCLOSE ) { @@ -311,6 +313,8 @@ HB_FUNC( PQCLOSE ) } } +#endif + HB_FUNC( PQRESET ) { PGconn * conn = hb_PGconn_par( 1 ); @@ -455,6 +459,8 @@ HB_FUNC( PQSTATUS ) * Query handling functions */ +#if defined( HB_LEGACY_LEVEL3 ) + /* NOTE: Deprecated */ HB_FUNC( PQCLEAR ) { @@ -471,6 +477,8 @@ HB_FUNC( PQCLEAR ) } } +#endif + HB_FUNC( PQEXEC ) { PGconn * conn = hb_PGconn_par( 1 ); @@ -1032,6 +1040,8 @@ HB_FUNC( PQCREATETRACE ) #endif } +#if defined( HB_LEGACY_LEVEL3 ) + /* NOTE: Deprecated */ HB_FUNC( PQCLOSETRACE ) { @@ -1050,6 +1060,8 @@ HB_FUNC( PQCLOSETRACE ) #endif } +#endif + HB_FUNC( PQTRACE ) { #ifdef NODLL diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index e00fe24804..fe05927c20 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -162,6 +162,7 @@ extern HB_EXPORT HB_FHANDLE hb_fsCreate ( const char * pszFileName, HB_FATT extern HB_EXPORT HB_FHANDLE hb_fsCreateEx ( const char * pszFilename, HB_FATTR ulAttr, USHORT uiFlags ); /* create a file, with specific open mode */ extern HB_EXPORT HB_FHANDLE hb_fsCreateTemp ( const char * pszDir, const char * pszPrefix, HB_FATTR ulAttr, char * pszName ); /* create a temporary file from components */ extern HB_EXPORT HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * pszPrefix, const char * pszExt, HB_FATTR ulAttr ); /* create a temporary file from components */ +extern HB_EXPORT HB_ERRCODE hb_fsTempDir ( char * pszDir ); /* full buffer with system temp directory (or empty on error) */ extern HB_EXPORT const char * hb_fsCurDir ( USHORT uiDrive ); /* retrieve a static pointer containing current directory for specified drive */ extern HB_EXPORT HB_ERRCODE hb_fsCurDirBuff ( USHORT uiDrive, char * pbyBuffer, HB_SIZE ulLen ); /* copy current directory for given drive into a buffer */ extern HB_EXPORT void hb_fsBaseDirBuff ( char * pbyBuffer ); /* retrieve the base dir of the executable */ diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 650df1437f..7e0ce32936 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -822,6 +822,7 @@ EXTERNAL SIGNAL EXTERNAL HB_PROGNAME EXTERNAL HB_DIRBASE +EXTERNAL HB_DIRTEMP EXTERNAL HB_ARGC EXTERNAL HB_ARGCHECK EXTERNAL HB_ARGSTRING diff --git a/harbour/package/winuni/RELNOTES b/harbour/package/winuni/RELNOTES index b3857c0e42..faeb0c4ef3 100644 --- a/harbour/package/winuni/RELNOTES +++ b/harbour/package/winuni/RELNOTES @@ -59,7 +59,7 @@ Tool/lib versions used to create this package: Blat 2.6.2 Cairo 1.8.8 libcurl 7.19.6 - Firebird 2.1.3 + Firebird 2.5.0rc1 FreeImage 3.13.0 GD 2.0.35 MySQL 5.1.41 @@ -76,6 +76,7 @@ Changes since previous (2.0.0) release: for users who obtained commercial license for QT, which means for majority of users, it isn't. It can easily be built from source though. +- Built against Firebird 2.5.0rc1. Changes since previous (2.0.0beta3 20090905) release: ----------------------------------------------------------------------- diff --git a/harbour/src/rtl/fstemp.c b/harbour/src/rtl/fstemp.c index c07f66794a..9a924c5305 100644 --- a/harbour/src/rtl/fstemp.c +++ b/harbour/src/rtl/fstemp.c @@ -7,7 +7,7 @@ * HB_FTEMPCREATE() function * * Copyright 2000-2001 Jose Lalin - * Viktor Szakats (harbour.01 syenar.hu) + * Copyright 2000-2010 Viktor Szakats (harbour.01 syenar.hu) * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -133,7 +133,7 @@ static HB_BOOL fsGetTempDirByCase( char * pszName, const char * pszTempDir ) } #endif -static HB_FHANDLE hb_fsCreateTempLow( const char * pszDir, const char * pszPrefix, HB_FATTR ulAttr, char * pszName, const char * pszExt ) +HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * pszPrefix, const char * pszExt, HB_FATTR ulAttr ) { /* less attemps */ int iAttemptLeft = 99, iLen; @@ -318,10 +318,18 @@ static HB_BOOL hb_fsTempName( char * pszBuffer, const char * pszDir, const char return fResult; } +#endif + /* NOTE: The pszName buffer must be at least HB_PATH_MAX chars long */ HB_FHANDLE hb_fsCreateTemp( const char * pszDir, const char * pszPrefix, HB_FATTR ulAttr, char * pszName ) { +#if defined( HB_OS_UNIX ) + return hb_fsCreateTempEx( pszName, pszDir, pszPrefix, NULL, ulAttr ); +#else + /* If there was no special extension requested, we're using + native temp file generation functions on systems where such + API exist. */ int iAttemptLeft = 999; while( --iAttemptLeft ) @@ -351,16 +359,85 @@ HB_FHANDLE hb_fsCreateTemp( const char * pszDir, const char * pszPrefix, HB_FATT } return FS_ERROR; -} - -#else /* HB_OS_UNIX */ - -HB_FHANDLE hb_fsCreateTemp( const char * pszDir, const char * pszPrefix, HB_FATTR ulAttr, char * pszName ) -{ - return hb_fsCreateTempLow( pszDir, pszPrefix, ulAttr, pszName, NULL ); -} - #endif +} + +/* NOTE: pszTempDir must be at least HB_PATH_MAX long. */ +HB_ERRCODE hb_fsTempDir( char * pszTempDir ) +{ + HB_ERRCODE nResult = FS_ERROR; + + pszTempDir[ 0 ] = '\0'; + +#if defined( HB_OS_UNIX ) + { + char * pszTempDirEnv = hb_getenv( "TMPDIR" ); + + if( ! fsGetTempDirByCase( pszTempDir, pszTempDirEnv ) ) + { +#ifdef P_tmpdir + if( ! fsGetTempDirByCase( pszTempDir, P_tmpdir ) ) +#endif + { + pszTempDir[ 0 ] = '.'; + pszTempDir[ 1 ] = '\0'; + } + else + nResult = 0; + } + + if( pszTempDirEnv ) + hb_xfree( pszTempDirEnv ); + + if( pszTempDir[ 0 ] != '\0' ) + { + int len = ( int ) strlen( pszTempDir ); + if( pszTempDir[ len - 1 ] != HB_OS_PATH_DELIM_CHR ) + { + pszTempDir[ len ] = HB_OS_PATH_DELIM_CHR; + pszTempDir[ len + 1 ] = '\0'; + } + } + } +#elif defined( HB_IO_WIN ) + { + TCHAR lpDir[ HB_PATH_MAX ]; + + if( GetTempPath( HB_PATH_MAX, lpDir ) ) + { + nResult = 0; + lpDir[ HB_PATH_MAX - 1 ] = TEXT( '\0' ); + HB_TCHAR_GETFROM( pszTempDir, lpDir, HB_PATH_MAX ); + } + } +#else + { + char szBuffer[ L_tmpnam ]; + + if( tmpnam( szBuffer ) != NULL ) + { + nResult = 0; + +# if defined( __DJGPP__ ) + { + /* convert '/' to '\' */ + char * pszDelim; + while( ( pszDelim = strchr( szBuffer, '/' ) ) != NULL ) + *pszDelim = '\\'; + } +# endif + + { + PHB_FNAME pTempName = hb_fsFNameSplit( szBuffer ); + hb_strncpy( pszTempDir, pTempName->szPath, HB_PATH_MAX - 1 ); + hb_xfree( pTempName ); + } + } + } +#endif + + return nResult; +} HB_FUNC( HB_FTEMPCREATE ) { @@ -374,11 +451,6 @@ HB_FUNC( HB_FTEMPCREATE ) hb_storc( szName, 4 ); } -HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * pszPrefix, const char * pszExt, HB_FATTR ulAttr ) -{ - return hb_fsCreateTempLow( pszDir, pszPrefix, ulAttr, pszName, pszExt ); -} - HB_FUNC( HB_FTEMPCREATEEX ) { char szName[ HB_PATH_MAX ]; @@ -391,3 +463,13 @@ HB_FUNC( HB_FTEMPCREATEEX ) hb_storc( szName, 1 ); } + +HB_FUNC( HB_DIRTEMP ) +{ + char szTempDir[ HB_PATH_MAX ]; + + if( hb_fsTempDir( szTempDir ) != ( HB_ERRCODE ) FS_ERROR ) + hb_retc( szTempDir ); + else + hb_retc_null(); +}