2010-02-27 20:07 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbodbc/odbc.c
  * contrib/rddsql/sddodbc/sddodbc.c
    ! Silenced warnings.

  * contrib/rddsql/sddoci/sddoci.c
  * contrib/rddsql/sddoci/tests/test1.prg
    + Finished type mapping and value translation.
    ; Not being an Oracle user, I only have the few sample
      tables, so no testing was made with these types.
    ; TOFIX: decimal position retrieval is currently wrong.
    ; TOFIX: date/time/timestamp doesn't seem to get through.

  * config/win/global.mk
  * config/rules.mk
    * Moved HB_BUILD_UNICODE handling here for win platform,
      to allow disabling it for potential 3rd party libs which
      don't support UNICODE mode.

  * src/common/hbffind.c
    * Formatting.
This commit is contained in:
Viktor Szakats
2010-02-27 19:09:47 +00:00
parent 1a4249b8e1
commit ae2d28bbc8
8 changed files with 151 additions and 92 deletions

View File

@@ -17,6 +17,28 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-02-27 20:07 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbodbc/odbc.c
* contrib/rddsql/sddodbc/sddodbc.c
! Silenced warnings.
* contrib/rddsql/sddoci/sddoci.c
* contrib/rddsql/sddoci/tests/test1.prg
+ Finished type mapping and value translation.
; Not being an Oracle user, I only have the few sample
tables, so no testing was made with these types.
; TOFIX: decimal position retrieval is currently wrong.
; TOFIX: date/time/timestamp doesn't seem to get through.
* config/win/global.mk
* config/rules.mk
* Moved HB_BUILD_UNICODE handling here for win platform,
to allow disabling it for potential 3rd party libs which
don't support UNICODE mode.
* src/common/hbffind.c
* Formatting.
2010-02-27 18:55 UTC+0100 Maurilio Longo (maurilio.longo@libero.it)
* src/common/hbffind.c
* optimized OS/2 hb_fsFindNextLow() to grab as many files as it can

View File

@@ -14,6 +14,13 @@ endif
HB_CFLAGS := -DHB_LEGACY_TYPES_OFF $(HB_CFLAGS)
# Handle it here, so that it can be disabled for individual libs
ifeq ($(HB_PLATFORM),win)
ifneq ($(HB_BUILD_UNICODE),no)
HB_CFLAGS += -DUNICODE
endif
endif
ifeq ($(HB_DYN_COPT),)
OBJ_DYN_POSTFIX :=
else

View File

@@ -7,10 +7,6 @@ all : first
BIN_EXT := .exe
DYN_EXT := .dll
ifneq ($(HB_BUILD_UNICODE),no)
HB_CFLAGS += -DUNICODE
endif
HB_GT_LIBS += gtwvt gtgui gtwin
# kernel32: needed by some compilers (pocc/watcom)

View File

@@ -113,6 +113,7 @@
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStrU16( itm, HB_CDP_ENDIAN_NATIVE, phstr, plen )
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str )
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
#define O_HB_CHAR HB_WCHAR
#else
#define O_HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
#define O_HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) )
@@ -123,6 +124,7 @@
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStr( itm, hb_setGetOSCP(), phstr, plen )
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str )
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len )
#define O_HB_CHAR char
#endif
HB_FUNC( SQLALLOCENV ) /* @hEnv --> nRetCode */
@@ -159,7 +161,7 @@ HB_FUNC( SQLDRIVERCONNECT ) /* hDbc, @cConnectString --> nRetCode */
hb_strfree( hConnStr );
O_HB_STORSTR( buffer, 3 );
O_HB_STORSTR( ( O_HB_CHAR * ) buffer, 3 );
hb_retni( ret );
}
@@ -333,7 +335,7 @@ HB_FUNC( SQLDESCRIBECOL ) /* hStmt, nCol, @cName, nLen, @nBufferLen, @nDataType,
if( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO )
{
O_HB_STORSTRLEN( buffer, ( HB_SIZE ) wBufLen, 3 );
O_HB_STORSTRLEN( ( O_HB_CHAR * ) buffer, ( HB_SIZE ) wBufLen, 3 );
hb_storni( ( int ) wBufLen, 5 );
hb_storni( ( int ) wDataType, 6 );
hb_stornint( wColSize, 7 );
@@ -435,9 +437,9 @@ HB_FUNC( SQLERROR ) /* hEnv, hDbc, hStmt, @cErrorClass, @nType, @cErrorMsg */
( SQLSMALLINT ) sizeof( szErrorMsg ),
( SQLSMALLINT * ) &wLen ) );
O_HB_STORSTR( buffer, 4 );
O_HB_STORSTR( ( O_HB_CHAR * ) buffer, 4 );
hb_stornl( ( long ) lError, 5 );
O_HB_STORSTR( szErrorMsg, 6 );
O_HB_STORSTR( ( O_HB_CHAR * ) szErrorMsg, 6 );
}
HB_FUNC( SQLROWCOUNT )
@@ -608,8 +610,7 @@ HB_FUNC( SQLMORERESULTS ) /* hEnv, hDbc */
hb_retni( SQLMoreResults( ( SQLHSTMT ) hb_parptr( 1 ) ) );
}
#if 0
HB_FUNC( SQLBINDOUTPARAM ) /* nStatementHandle, nParameterNumber, nParameterType, ColumnSize, DecimalDigits, @ParamValue, @ParamLength --> nRetCode */
HB_FUNC( SQLBINDPARAMETER ) /* nStatementHandle, nParameterNumber, nParameterType, ColumnSize, DecimalDigits, @ParamValue, @ParamLength --> nRetCode */
{
SQLLEN lLen = hb_parnint( 7 );
hb_retni( SQLBindParameter( ( SQLHSTMT ) hb_parptr( 1 ),
@@ -620,11 +621,10 @@ HB_FUNC( SQLBINDOUTPARAM ) /* nStatementHandle, nParameterNumber, nParameterType
( SQLULEN ) hb_parnint( 4 ),
( SQLSMALLINT ) hb_parni( 5 ),
( SQLPOINTER ) hb_parcx( 6 ),
( SQLINTEGER ) hb_parclen( 6 ),
( SQLLEN ) hb_parclen( 6 ),
( SQLLEN * ) &lLen ) );
hb_stornint( lLen, 7 );
}
#endif
HB_FUNC( SQLSTOD )
{

View File

@@ -72,12 +72,14 @@
#define M_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStrU16( itm, HB_CDP_ENDIAN_NATIVE, phstr, plen )
#define M_HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str )
#define M_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
#define M_HB_CHAR HB_WCHAR
#else
#define M_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStr( arr, n, hb_setGetOSCP(), phstr, plen )
#define M_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStr( itm, hb_setGetOSCP(), str, len )
#define M_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStr( itm, hb_setGetOSCP(), phstr, plen )
#define M_HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str )
#define M_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len )
#define M_HB_CHAR char
#endif
#if defined( OCI_CHARSET_UNICODE ) || defined( OCI_CHARSET_MIXED )
@@ -86,12 +88,14 @@
#define D_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStrU16( itm, HB_CDP_ENDIAN_NATIVE, phstr, plen )
#define D_HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str )
#define D_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
#define D_HB_CHAR HB_WCHAR
#else
#define D_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStr( arr, n, hb_setGetOSCP(), phstr, plen )
#define D_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStr( itm, hb_setGetOSCP(), str, len )
#define D_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStr( itm, hb_setGetOSCP(), phstr, plen )
#define D_HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str )
#define D_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len )
#define D_HB_CHAR char
#endif
static HB_ERRCODE ocilibConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem );
@@ -355,22 +359,30 @@ static HB_ERRCODE ocilibOpen( SQLBASEAREAP pArea )
pFieldInfo.uiLen = ( HB_USHORT ) uiSize;
pFieldInfo.uiDec = ( HB_USHORT ) iDec;
/* HB_TRACE( HB_TR_ALWAYS, ("field: name=%s type=%d len=%d dec=%d nullable=%d", pFieldInfo.atomName, uiDataType, uiSize, iDec, bNullable ) ); */
HB_TRACE( HB_TR_ALWAYS, ("field: name=%s type=%d len=%d dec=%d nullable=%d %d %d %d %d", pFieldInfo.atomName, uiDataType, uiSize, iDec, bNullable, OCI_ColumnGetScale( col ), OCI_ColumnGetPrecision( col ), OCI_ColumnGetFractionalPrecision( col ), OCI_ColumnGetLeadingPrecision( col ) ) );
switch( uiDataType )
{
/* TOFIX/TODO: Type mapping */
case OCI_CDT_TEXT:
pFieldInfo.uiType = HB_FT_STRING;
break;
case OCI_CDT_NUMERIC:
pFieldInfo.uiType = HB_FT_INTEGER;
pFieldInfo.uiType = HB_FT_LONG;
break;
case OCI_CDT_LONG:
pFieldInfo.uiType = HB_FT_VARLENGTH;
break;
case OCI_CDT_RAW:
pFieldInfo.uiType = HB_FT_BLOB;
break;
case OCI_CDT_DATETIME:
case OCI_CDT_TIMESTAMP:
pFieldInfo.uiType = HB_FT_TIMESTAMP;
case OCI_CDT_INTERVAL:
pFieldInfo.uiType = HB_FT_TIME;
break;
default:
@@ -392,11 +404,12 @@ static HB_ERRCODE ocilibOpen( SQLBASEAREAP pArea )
memset( pStr, ' ', pFieldInfo.uiLen );
pStr[ pFieldInfo.uiLen ] = '\0';
pItem = hb_itemPutCL( NULL, pStr, pFieldInfo.uiLen );
hb_xfree( pStr );
pItem = hb_itemPutCLPtr( NULL, pStr, pFieldInfo.uiLen );
break;
}
case HB_FT_MEMO:
case HB_FT_VARLENGTH:
case HB_FT_BLOB:
pItem = hb_itemPutC( NULL, NULL );
break;
@@ -424,10 +437,7 @@ static HB_ERRCODE ocilibOpen( SQLBASEAREAP pArea )
break;
case HB_FT_TIME:
pItem = hb_itemPutTDT( NULL, 0, 0 );
break;
case HB_FT_TIMESTAMP:
case HB_FT_TIMESTAMP:
pItem = hb_itemPutTDT( NULL, 0, 0 );
break;
@@ -499,87 +509,105 @@ static HB_ERRCODE ocilibGoTo( SQLBASEAREAP pArea, HB_ULONG ulRecNo )
}
pArray = hb_itemArrayNew( pArea->area.uiFieldCount );
for( ui = 1; ui <= pArea->area.uiFieldCount; ++ui )
{
pItem = NULL;
if( ! OCI_IsNull( rs, ui ) )
{
pField = pArea->area.lpFields + ui - 1;
pField = pArea->area.lpFields + ui - 1;
switch( pField->uiType )
{
case HB_FT_STRING:
switch( pField->uiType )
{
case HB_FT_STRING:
if( OCI_IsNull( rs, ui ) )
{
char * pStr = ( char * ) hb_xgrab( ( HB_SIZE ) pField->uiLen + 1 );
memset( pStr, ' ', pField->uiLen );
pStr[ pField->uiLen ] = '\0';
pItem = hb_itemPutCLPtr( NULL, pStr, pField->uiLen );
}
else
{
const dtext * val;
if( ( val = OCI_GetString( rs, ui ) ) != NULL )
pItem = D_HB_ITEMPUTSTRLEN( NULL, val, ( HB_SIZE ) dtslen( val ) );
break;
pItem = D_HB_ITEMPUTSTRLEN( NULL, val, ( HB_SIZE ) dtslen( val ) ); /* TODO: Pad it to pField->uiLen size with spaces? */
}
break;
case HB_FT_INTEGER:
case HB_FT_LONG:
case HB_FT_INTEGER:
if( pField->uiDec == 0 )
#if HB_LONG_MAX == INT32_MAX || defined( HB_LONG_LONG_OFF )
pItem = hb_itemPutNIntLen( NULL, OCI_GetInt( rs, ui ), pField->uiLen );
#else
pItem = hb_itemPutNIntLen( NULL, OCI_GetBigInt( rs, ui ), pField->uiLen );
#endif
else
pItem = hb_itemPutNDLen( NULL, OCI_GetDouble( rs, ui ), pField->uiLen, pField->uiDec );
break;
case HB_FT_VARLENGTH:
case HB_FT_MEMO:
{
OCI_Long * val = OCI_GetLong( rs, ui );
if( val )
{
pItem = hb_itemPutNLLen( NULL, OCI_GetInt( rs, ui ), pField->uiLen );
break;
}
/* TODO: Type conversions */
/*
case HB_FT_LONG:
if( pField->uiDec == 0 )
{
long int val = 0;
if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_LONG, &val, sizeof( val ), &iLen ) ) )
pItem = hb_itemPutNLLen( NULL, val, pField->uiLen );
}
unsigned int uiSize = OCI_LongGetSize( val );
if( OCI_LongGetType( val ) == OCI_CLONG )
pItem = D_HB_ITEMPUTSTRLEN( NULL, ( D_HB_CHAR * ) OCI_LongGetBuffer( val ), uiSize );
else
{
double val = 0.0;
if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_DOUBLE, &val, sizeof( val ), &iLen ) ) )
pItem = hb_itemPutNDLen( NULL, val, pField->uiLen, pField->uiDec );
}
break;
case HB_FT_DOUBLE:
{
double val = 0.0;
if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_DOUBLE, &val, sizeof( val ), &iLen ) ) )
pItem = hb_itemPutNDLen( NULL, val, pField->uiLen, pField->uiDec );
break;
pItem = hb_itemPutCL( NULL, ( char * ) OCI_LongGetBuffer( val ), uiSize );
}
break;
}
case HB_FT_LOGICAL:
{
unsigned char val = 0;
if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_BIT, &val, sizeof( val ), &iLen ) ) )
pItem = hb_itemPutL( NULL, val != 0 );
break;
}
case HB_FT_IMAGE:
case HB_FT_BLOB:
case HB_FT_OLE:
{
OCI_Long * val = OCI_GetLong( rs, ui );
if( val )
pItem = hb_itemPutCL( NULL, ( char * ) OCI_LongGetBuffer( val ), OCI_LongGetSize( val ) );
break;
}
case HB_FT_DATE:
{
DATE_STRUCT val = {0,0,0};
if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_DATE, &val, sizeof( val ), &iLen ) ) )
pItem = hb_itemPutD( NULL, val.year, val.month, val.day );
break;
}
case HB_FT_CURRENCY:
case HB_FT_CURDOUBLE:
case HB_FT_FLOAT:
case HB_FT_DOUBLE:
{
pItem = hb_itemPutNDLen( NULL, OCI_GetDouble( rs, ui ), pField->uiLen, pField->uiDec );
break;
}
case HB_FT_TIME:
{
TIME_STRUCT val = {0,0,0};
if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_TIME, &val, sizeof( val ), &iLen ) ) )
pItem = hb_itemPutTDT( NULL, 0, hb_timeEncode( val.hour, val.minute, val.second, 0 ) );
break;
}
case HB_FT_DATE:
{
OCI_Date * date = OCI_GetDate( rs, ui );
int iYear, iMonth, iDay;
if( date && OCI_DateGetDate( date, &iYear, &iMonth, &iDay ) )
pItem = hb_itemPutD( NULL, iYear, iMonth, iDay );
break;
}
case HB_FT_TIMESTAMP:
{
TIMESTAMP_STRUCT val = { 0, 0, 0, 0, 0, 0, 0 };
if( SQL_SUCCEEDED( res = SQLGetData( hStmt, ui, SQL_C_TIMESTAMP, &val, sizeof( val ), &iLen ) ) )
pItem = hb_itemPutTDT( NULL, hb_dateEncode( val.year, val.month, val.day ),
hb_timeEncode( val.hour, val.minute, val.second, val.fraction / 1000000 ) );
break;
}
*/
case HB_FT_TIME:
{
OCI_Date * date = OCI_GetDate( rs, ui );
int iHour, iMin, iSec;
if( date && OCI_DateGetTime( date, &iHour, &iMin, &iSec ) )
pItem = hb_itemPutTDT( NULL, 0,
hb_timeEncode( iHour, iMin, iSec, 0 ) );
break;
}
case HB_FT_TIMESTAMP:
{
OCI_Timestamp * ts = OCI_GetTimestamp( rs, ui );
int iYear, iMonth, iDay, iHour, iMin, iSec, iFSec;
if( ts && OCI_TimestampGetDateTime( ts, &iYear, &iMonth, &iDay, &iHour, &iMin, &iSec, &iFSec ) )
pItem = hb_itemPutTDT( NULL, hb_dateEncode( iYear, iMonth, iDay ),
hb_timeEncode( iHour, iMin, iSec, iFSec / 1000000 ) );
break;
}
}

View File

@@ -27,6 +27,10 @@ PROCEDURE Main()
? "-4-"
? "DB struct:", HB_VALTOEXP( DBSTRUCT() )
? "-5-"
FOR tmp := 1 TO FCount()
? FIELDNAME( tmp ), HB_FIELDTYPE( tmp )
NEXT
? "-6-"
INKEY( 0 )
BROWSE()

View File

@@ -88,12 +88,14 @@
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStrU16( itm, HB_CDP_ENDIAN_NATIVE, phstr, plen )
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str )
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len )
#define O_HB_CHAR HB_WCHAR
#else
#define O_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStr( arr, n, hb_setGetOSCP(), phstr, plen )
#define O_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStr( itm, hb_setGetOSCP(), str, len )
#define O_HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStr( itm, hb_setGetOSCP(), phstr, plen )
#define O_HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str )
#define O_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len )
#define O_HB_CHAR char
#endif
static HB_ERRCODE odbcConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem );
@@ -178,7 +180,7 @@ static char * odbcGetError( SQLHENV hEnv, SQLHDBC hConn, SQLHSTMT hStmt, HB_ERRC
szError[ 5 ] = ' ';
pRet = O_HB_ITEMPUTSTR( NULL, szError );
pRet = O_HB_ITEMPUTSTR( NULL, ( O_HB_CHAR * ) szError );
szRet = hb_strdup( hb_itemGetCPtr( pRet ) );
hb_itemRelease( pRet );
}

View File

@@ -496,12 +496,12 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
&info->findCount,
FIL_STANDARD ) == NO_ERROR && info->findCount > 0;
if ( bFound )
if( bFound )
info->next = info->entry;
}
else
{
if ( info->findCount > 0 )
if( info->findCount > 0 )
bFound = HB_TRUE;
else
{
@@ -511,7 +511,7 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
info->entry,
4 * 1024,
&info->findCount ) == NO_ERROR && info->findCount > 0;
if ( bFound )
if( bFound )
info->next = info->entry;
}
}
@@ -530,9 +530,9 @@ static HB_BOOL hb_fsFindNextLow( PHB_FFIND ffind )
iMin = info->next->ftimeLastWrite.minutes;
iSec = info->next->ftimeLastWrite.twosecs;
if ( info->next->oNextEntryOffset > 0 )
if( info->next->oNextEntryOffset > 0 )
{
info->next = (PFILEFINDBUF3)( (char *)info->next + info->next->oNextEntryOffset );
info->next = ( PFILEFINDBUF3 )( ( char * ) info->next + info->next->oNextEntryOffset );
info->findCount--;
}
else