2014-10-01 22:24 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* include/hbapi.h
  * src/common/hbstr.c
    + added new function hb_strAtI() - it works like hb_strAt() but it
      ignores the case of the ASCII characters

  * src/rtl/ati.c
    * renamed local static function hb_strAtI() to s_strAtI() to avoid
      conflict with new public hb_strAtI() function.

  * contrib/xhb/xhbat.c
    - removed local static function hb_strAtI() - current public hb_strAtI()
      is compatible with it.

  * contrib/sddsqlt3/core.c
    + added new code to set column type giving the highest priority SQLITE3
      declared column types.
      Please test - I haven't made any.
    ! do not cast floating point values to integer

  * contrib/hbwin/hbwin.hbx
  * contrib/hbwin/win_prn2.c
    ! fixed win_printerGetDefault() in Win9x builds - fix and some
      formatting and casting borrowed from Viktor's fork.
    + added new PRG function:
         win_PrintDataRaw( <cPrinter>, <cData> [, <cDocName>] )
                           -> <nBytesPrinted>
      It's similar to win_PrintFileRaw() but sends to given printer passed
      in 2-nd parameter <cData> instead of file body.
      On error it returns negative value.
    * cleaned casting and minor formatting

  * src/rtl/gtxwc/gtxwc.c
    + added support for HB_GTI_DISPIMAGE. It's slightly modified code sent
      by Rolf to Harbour devel list. In comparison to original version it
      supports <nDepth> as 4-th item of array with bitmap description to use
      with some other GTs which can support different color depths or can
      make conversion. It also supports bitmaps passed as strings.
    % slightly improved HB_GFX_GETPIXEL
This commit is contained in:
Przemysław Czerpak
2014-10-01 22:24:56 +02:00
parent b346e248e0
commit 36973e8622
9 changed files with 361 additions and 133 deletions

View File

@@ -10,6 +10,46 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2014-10-01 22:24 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/hbapi.h
* src/common/hbstr.c
+ added new function hb_strAtI() - it works like hb_strAt() but it
ignores the case of the ASCII characters
* src/rtl/ati.c
* renamed local static function hb_strAtI() to s_strAtI() to avoid
conflict with new public hb_strAtI() function.
* contrib/xhb/xhbat.c
- removed local static function hb_strAtI() - current public hb_strAtI()
is compatible with it.
* contrib/sddsqlt3/core.c
+ added new code to set column type giving the highest priority SQLITE3
declared column types.
Please test - I haven't made any.
! do not cast floating point values to integer
* contrib/hbwin/hbwin.hbx
* contrib/hbwin/win_prn2.c
! fixed win_printerGetDefault() in Win9x builds - fix and some
formatting and casting borrowed from Viktor's fork.
+ added new PRG function:
win_PrintDataRaw( <cPrinter>, <cData> [, <cDocName>] )
-> <nBytesPrinted>
It's similar to win_PrintFileRaw() but sends to given printer passed
in 2-nd parameter <cData> instead of file body.
On error it returns negative value.
* cleaned casting and minor formatting
* src/rtl/gtxwc/gtxwc.c
+ added support for HB_GTI_DISPIMAGE. It's slightly modified code sent
by Rolf to Harbour devel list. In comparison to original version it
supports <nDepth> as 4-th item of array with bitmap description to use
with some other GTs which can support different color depths or can
make conversion. It also supports bitmaps passed as strings.
% slightly improved HB_GFX_GETPIXEL
2014-09-26 15:34 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* contrib/rddads/ads1.c
! extended and fixed CANDEFAULT error processing for data width error

View File

@@ -366,6 +366,7 @@ DYNAMIC win_osNetRegOk
DYNAMIC win_osNetVRedirOk
DYNAMIC win_osVersionInfo
DYNAMIC win_P2N
DYNAMIC win_PrintDataRaw
DYNAMIC win_PrintDlgDC
DYNAMIC win_printerExists
DYNAMIC win_printerGetDefault

View File

@@ -88,7 +88,7 @@ HB_FUNC( WIN_PRINTEREXISTS )
{
DWORD dwNeeded = 0, dwReturned = 0;
EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, ( LPBYTE ) NULL, 0, &dwNeeded, &dwReturned );
EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, NULL, 0, &dwNeeded, &dwReturned );
if( dwNeeded )
{
PRINTER_INFO_5 * pPrinterEnumBak;
@@ -124,7 +124,7 @@ static void hb_GetDefaultPrinter( PHB_ITEM pPrinterName )
hb_itemPutC( pPrinterName, NULL );
if( hb_iswin2k() ) /* Windows 2000 or later */
if( hb_iswin2k() ) /* Windows 2000 or later */
{
typedef BOOL( WINAPI * DEFPRINTER ) ( LPTSTR, LPDWORD );
DEFPRINTER fnGetDefaultPrinter;
@@ -182,17 +182,15 @@ static void hb_GetDefaultPrinter( PHB_ITEM pPrinterName )
*/
DWORD dwNeeded = 0, dwReturned = 0;
if( EnumPrinters( PRINTER_ENUM_DEFAULT, NULL, 2, NULL, 0, &dwNeeded, &dwReturned ) )
EnumPrinters( PRINTER_ENUM_DEFAULT, NULL, 2, NULL, 0, &dwNeeded, &dwReturned );
if( dwNeeded )
{
if( dwNeeded )
{
PRINTER_INFO_2 * pPrinterInfo = ( PRINTER_INFO_2 * ) hb_xgrab( dwNeeded );
PRINTER_INFO_2 * pPrinterInfo = ( PRINTER_INFO_2 * ) hb_xgrab( dwNeeded );
if( EnumPrinters( PRINTER_ENUM_DEFAULT, NULL, 2, ( LPBYTE ) pPrinterInfo, dwNeeded, &dwNeeded, &dwReturned ) && dwReturned )
HB_ITEMPUTSTR( pPrinterName, pPrinterInfo->pPrinterName );
if( EnumPrinters( PRINTER_ENUM_DEFAULT, NULL, 2, ( LPBYTE ) pPrinterInfo, dwNeeded, &dwNeeded, &dwReturned ) && dwReturned )
HB_ITEMPUTSTR( pPrinterName, pPrinterInfo->pPrinterName );
hb_xfree( pPrinterInfo );
}
hb_xfree( pPrinterInfo );
}
}
#else
@@ -210,35 +208,34 @@ HB_FUNC( WIN_PRINTERGETDEFAULT )
}
#if ! defined( HB_OS_WIN_CE )
static HB_BOOL hb_GetJobs( HANDLE hPrinter, JOB_INFO_2 ** ppJobInfo, long * plJobs )
static HB_BOOL hb_GetJobs( HANDLE hPrinter, JOB_INFO_2 ** ppJobInfo, DWORD * pdwJobs )
{
HB_BOOL bResult = HB_FALSE;
DWORD dwByteNeeded = 0;
DWORD dwNeeded = 0;
GetPrinter( hPrinter, 2, NULL, 0, &dwByteNeeded );
if( dwByteNeeded )
GetPrinter( hPrinter, 2, NULL, 0, &dwNeeded );
if( dwNeeded )
{
PRINTER_INFO_2 * pPrinterInfo = ( PRINTER_INFO_2 * ) hb_xgrab( dwByteNeeded );
DWORD dwByteUsed = 0;
PRINTER_INFO_2 * pPrinterInfo = ( PRINTER_INFO_2 * ) hb_xgrab( dwNeeded );
DWORD dwUsed = 0;
if( GetPrinter( hPrinter, 2, ( LPBYTE ) pPrinterInfo, dwByteNeeded, &dwByteUsed ) )
if( GetPrinter( hPrinter, 2, ( LPBYTE ) pPrinterInfo, dwNeeded, &dwUsed ) )
{
DWORD dwReturned = 0;
EnumJobs( hPrinter, 0, pPrinterInfo->cJobs, 2, NULL, 0, &dwByteNeeded, &dwReturned );
if( dwByteNeeded )
EnumJobs( hPrinter, 0, pPrinterInfo->cJobs, 2, NULL, 0, &dwNeeded, &dwReturned );
if( dwNeeded )
{
JOB_INFO_2 * pJobStorage = ( JOB_INFO_2 * ) hb_xgrab( dwByteNeeded );
JOB_INFO_2 * pJobInfo = ( JOB_INFO_2 * ) hb_xgrab( dwNeeded );
if( EnumJobs( hPrinter, 0, dwReturned, 2, ( LPBYTE ) pJobStorage, dwByteNeeded, &dwByteUsed, &dwReturned ) )
if( EnumJobs( hPrinter, 0, dwReturned, 2, ( LPBYTE ) pJobInfo, dwNeeded, &dwUsed, &dwReturned ) )
{
*plJobs = ( long ) dwReturned;
*ppJobInfo = pJobStorage;
*pdwJobs = dwReturned;
*ppJobInfo = pJobInfo;
bResult = HB_TRUE;
}
else
hb_xfree( pJobStorage );
hb_xfree( pJobInfo );
}
}
hb_xfree( pPrinterInfo );
@@ -266,15 +263,14 @@ HB_FUNC( WIN_PRINTERSTATUS )
if( OpenPrinter( ( LPTSTR ) lpPrinterName, &hPrinter, NULL ) )
{
DWORD dwByteNeeded = 0;
DWORD dwNeeded = 0;
GetPrinter( hPrinter, 2, NULL, 0, &dwByteNeeded );
if( dwByteNeeded )
GetPrinter( hPrinter, 2, NULL, 0, &dwNeeded );
if( dwNeeded )
{
PRINTER_INFO_2 * pPrinterInfo = ( PRINTER_INFO_2 * ) hb_xgrab( dwByteNeeded );
PRINTER_INFO_2 * pPrinterInfo = ( PRINTER_INFO_2 * ) hb_xgrab( dwNeeded );
if( GetPrinter( hPrinter, 2, ( LPBYTE ) pPrinterInfo, dwByteNeeded, &dwByteNeeded ) )
if( GetPrinter( hPrinter, 2, ( LPBYTE ) pPrinterInfo, dwNeeded, &dwNeeded ) )
nStatus = ( long ) pPrinterInfo->Status;
hb_xfree( pPrinterInfo );
@@ -283,13 +279,13 @@ HB_FUNC( WIN_PRINTERSTATUS )
if( nStatus == 0 )
{
JOB_INFO_2 * pJobs;
long lJobs = 0;
DWORD dwJobs = 0;
if( hb_GetJobs( hPrinter, &pJobs, &lJobs ) )
if( hb_GetJobs( hPrinter, &pJobs, &dwJobs ) )
{
long i;
DWORD i;
for( i = 0; nStatus == 0 && i < lJobs; ++i )
for( i = 0; nStatus == 0 && i < dwJobs; ++i )
{
if( pJobs[ i ].Status & JOB_STATUS_ERROR )
nStatus = -20;
@@ -326,7 +322,7 @@ HB_FUNC( WIN_PRINTERPORTTONAME )
{
DWORD dwNeeded = 0, dwReturned = 0;
EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, ( LPBYTE ) NULL, 0, &dwNeeded, &dwReturned );
EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, NULL, 0, &dwNeeded, &dwReturned );
if( dwNeeded )
{
PRINTER_INFO_5 * pPrinterEnumBak;
@@ -366,7 +362,7 @@ HB_FUNC( WIN_PRINTERPORTTONAME )
HB_FUNC( WIN_PRINTFILERAW )
{
int iResult = -1;
HB_ISIZ nResult = -1;
#if ! defined( HB_OS_WIN_CE )
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
@@ -380,11 +376,12 @@ HB_FUNC( WIN_PRINTFILERAW )
if( OpenPrinter( ( LPTSTR ) lpDeviceName, &hPrinter, NULL ) != 0 )
{
void * hDocName;
DOC_INFO_1 DocInfo;
DocInfo.pDocName = ( LPTSTR ) HB_PARSTR( HB_ISCHAR( 3 ) ? 3 : 2, &hDocName, NULL );
DocInfo.pOutputFile = NULL;
DocInfo.pDatatype = ( LPTSTR ) TEXT( "RAW" );
if( StartDocPrinter( hPrinter, 1, ( LPBYTE ) &DocInfo ) != 0 )
{
if( StartPagePrinter( hPrinter ) != 0 )
@@ -396,19 +393,18 @@ HB_FUNC( WIN_PRINTFILERAW )
HB_BYTE * pbyBuffer = ( HB_BYTE * ) hb_xgrab( HB_PRINT_BUFFER_SIZE );
HB_SIZE nRead;
iResult = 1;
nResult = 1;
while( ( nRead = hb_fsReadLarge( fhnd, pbyBuffer, HB_PRINT_BUFFER_SIZE ) ) > 0 )
{
DWORD nWritten = 0;
HB_SIZE nWritten = 0;
#if 0
/* TOFIX: This check seems wrong for any input files
/* TOFIX: This check seems wrong for any input file
larger than our read buffer, in such case it
will strip Chr( 26 ) from inside the file, which
means it will corrupt it. [vszakats] */
if( pbyBuffer[ nRead - 1 ] == 26 )
nRead--; /* Skip the Eof() character */
--nRead; /* Skip the EOF character */
#endif
while( nWritten < nRead )
@@ -418,12 +414,12 @@ HB_FUNC( WIN_PRINTFILERAW )
( DWORD ) ( nRead - nWritten ),
&dwWritten ) )
{
iResult = -7;
nResult = -7;
break;
}
else if( dwWritten == 0 )
{
iResult = -8;
nResult = -8;
break;
}
nWritten += dwWritten;
@@ -436,30 +432,87 @@ HB_FUNC( WIN_PRINTFILERAW )
hb_xfree( pbyBuffer );
}
else
iResult = -6;
nResult = -6;
EndPagePrinter( hPrinter );
}
else
iResult = -4;
nResult = -4;
EndDocPrinter( hPrinter );
}
else
iResult = -3;
nResult = -3;
ClosePrinter( hPrinter );
hb_strfree( hDocName );
}
else
iResult = -2;
nResult = -2;
hb_strfree( hDeviceName );
}
#endif
hb_retni( iResult );
hb_retns( nResult );
}
HB_FUNC( WIN_PRINTDATARAW )
{
HB_ISIZ nResult = -1;
#if ! defined( HB_OS_WIN_CE )
if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) )
{
HANDLE hPrinter;
void * hDeviceName;
LPCTSTR lpDeviceName = HB_PARSTR( 1, &hDeviceName, NULL );
if( OpenPrinter( ( LPTSTR ) lpDeviceName, &hPrinter, NULL ) != 0 )
{
void * hDocName;
DOC_INFO_1 DocInfo;
DocInfo.pDocName = ( LPTSTR ) HB_PARSTR( 3, &hDocName, NULL );
DocInfo.pOutputFile = NULL;
DocInfo.pDatatype = ( LPTSTR ) TEXT( "RAW" );
if( DocInfo.pDocName == NULL )
DocInfo.pDocName = DocInfo.pDatatype;
if( StartDocPrinter( hPrinter, 1, ( LPBYTE ) &DocInfo ) != 0 )
{
if( StartPagePrinter( hPrinter ) != 0 )
{
HB_BYTE * pbData = ( HB_BYTE * ) hb_parc( 2 );
HB_SIZE nLen = hb_parclen( 2 );
nResult = 0;
while( ( HB_SIZE ) nResult < nLen )
{
DWORD dwWritten = 0;
if( ! WritePrinter( hPrinter, &pbData[ nResult ],
( DWORD ) ( nLen - nResult ),
&dwWritten ) || dwWritten == 0 )
break;
nResult += dwWritten;
}
EndPagePrinter( hPrinter );
}
else
nResult = -4;
EndDocPrinter( hPrinter );
}
else
nResult = -3;
ClosePrinter( hPrinter );
hb_strfree( hDocName );
}
else
nResult = -2;
hb_strfree( hDeviceName );
}
#endif
hb_retns( nResult );
}
/* Positions for win_printerList() array */
#define HB_WINPRN_NAME 1
@@ -479,7 +532,7 @@ HB_FUNC( WIN_PRINTERLIST )
HB_BOOL bLocalPrintersOnly = hb_parl( 2 );
DWORD dwNeeded = 0, dwReturned = 0, i;
EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, ( LPBYTE ) NULL, 0, &dwNeeded, &dwReturned );
EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, NULL, 0, &dwNeeded, &dwReturned );
if( dwNeeded )
{
PRINTER_INFO_5 * pPrinterEnumBak;

View File

@@ -182,6 +182,63 @@ static char * sqlite3GetError( sqlite3 * pDb, HB_ERRCODE * pErrCode )
}
static HB_USHORT sqlite3DeclType(sqlite3_stmt * st, HB_USHORT uiIndex )
{
const char * szDeclType;
szDeclType = sqlite3_column_decltype( st, uiIndex );
/* the order of comparisons below is important to replicate
* type precedence used by SQLITE3
*/
if( szDeclType != NULL )
{
HB_SIZE nLen = strlen( szDeclType );
if( hb_strAtI( "INT", 3, szDeclType, nLen ) != 0 )
return HB_FT_INTEGER;
if( hb_strAtI( "CHAR", 4, szDeclType, nLen ) != 0 ||
hb_strAtI( "TEXT", 4, szDeclType, nLen ) != 0 ||
hb_strAtI( "CLOB", 4, szDeclType, nLen ) != 0 )
return HB_FT_STRING;
if( hb_strAtI( "BLOB", 4, szDeclType, nLen ) != 0 )
return HB_FT_ANY;
if( hb_strAtI( "REAL", 4, szDeclType, nLen ) != 0 ||
hb_strAtI( "FLOA", 4, szDeclType, nLen ) != 0 ||
hb_strAtI( "DOUB", 4, szDeclType, nLen ) != 0 )
return HB_FT_LONG;
}
#ifdef HB_SQLT3_MAP_UNDECLARED_TYPES_AS_ANY
return HB_FT_ANY;
#else
switch( sqlite3_column_type( st, uiIndex ) )
{
case SQLITE_TEXT:
return HB_FT_STRING;
break;
case SQLITE_FLOAT:
return HB_FT_LONG;
break;
case SQLITE_INTEGER:
return HB_FT_INTEGER;
break;
case SQLITE_BLOB:
return HB_FT_BLOB;
break;
case SQLITE_NULL:
return HB_FT_ANY;
break;
}
return HB_FT_NONE;
#endif
}
/*============= SDD METHODS =============================================================*/
static HB_ERRCODE sqlite3Connect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
@@ -307,11 +364,11 @@ static HB_ERRCODE sqlite3Open( SQLBASEAREAP pArea )
pName = S_HB_ITEMPUTSTR( NULL, sqlite3_column_name( st, uiIndex ) );
pFieldInfo.atomName = hb_itemGetCPtr( pName );
iDataType = sqlite3_column_type( st, uiIndex );
iDataType = sqlite3DeclType( st, uiIndex );
iSize = sqlite3_column_bytes( st, uiIndex );
iDec = 0;
pFieldInfo.uiType = ( HB_USHORT ) iDataType;
pFieldInfo.uiLen = ( HB_USHORT ) iSize;
pFieldInfo.uiDec = ( HB_USHORT ) iDec;
@@ -319,34 +376,14 @@ static HB_ERRCODE sqlite3Open( SQLBASEAREAP pArea )
HB_TRACE( HB_TR_ALWAYS, ( "field: name=%s type=%d len=%d dec=%d nullable=%d", pFieldInfo.atomName, iDataType, iSize, iDec ) );
#endif
switch( iDataType )
if( pFieldInfo.uiType == HB_FT_NONE )
{
case SQLITE_TEXT:
pFieldInfo.uiType = HB_FT_STRING;
break;
case SQLITE_FLOAT:
case SQLITE_INTEGER:
pFieldInfo.uiType = HB_FT_LONG;
break;
case SQLITE_BLOB:
pFieldInfo.uiType = HB_FT_BLOB;
break;
case SQLITE_NULL:
pFieldInfo.uiType = HB_FT_ANY;
break;
default:
#if 0
HB_TRACE( HB_TR_ALWAYS, ( "new sql type=%d", iDataType ) );
HB_TRACE( HB_TR_ALWAYS, ( "new sql type=%d", iDataType ) );
#endif
bError = HB_TRUE;
errCode = ( HB_ERRCODE ) iDataType;
pFieldInfo.uiType = 0;
pFieldInfo.uiType = HB_FT_STRING;
break;
bError = HB_TRUE;
errCode = ( HB_ERRCODE ) iDataType;
pFieldInfo.uiType = HB_FT_NONE;
}
if( ! bError )
@@ -366,11 +403,12 @@ static HB_ERRCODE sqlite3Open( SQLBASEAREAP pArea )
pItem = hb_itemPutC( NULL, NULL );
break;
case HB_FT_INTEGER:
pItem = hb_itemPutNIntLen( NULL, 0, pFieldInfo.uiLen );
break;
case HB_FT_LONG:
if( pFieldInfo.uiDec == 0 )
pItem = hb_itemPutNLLen( NULL, 0, pFieldInfo.uiLen );
else
pItem = hb_itemPutNDLen( NULL, 0.0, pFieldInfo.uiLen, pFieldInfo.uiDec );
pItem = hb_itemPutNDLen( NULL, 0.0, pFieldInfo.uiLen, pFieldInfo.uiDec );
break;
case HB_FT_ANY:
@@ -477,16 +515,13 @@ static HB_ERRCODE sqlite3GoTo( SQLBASEAREAP pArea, HB_ULONG ulRecNo )
pItem = S_HB_ITEMPUTSTR( NULL, ( const char * ) sqlite3_column_text( st, ui ) );
break;
case HB_FT_LONG:
case HB_FT_INTEGER:
if( pField->uiDec == 0 )
#if HB_VMLONG_MAX == INT32_MAX || defined( HB_LONG_LONG_OFF )
pItem = hb_itemPutNIntLen( NULL, sqlite3_column_int( st, ui ), pField->uiLen );
#else
pItem = hb_itemPutNIntLen( NULL, sqlite3_column_int64( st, ui ), pField->uiLen );
#if HB_VMLONG_MAX > INT32_MAX && ! defined( HB_LONG_LONG_OFF )
pItem = hb_itemPutNIntLen( NULL, sqlite3_column_int64( st, ui ), pField->uiLen );
break;
#endif
else
pItem = hb_itemPutNDLen( NULL, sqlite3_column_double( st, ui ), pField->uiLen, pField->uiDec );
case HB_FT_LONG:
pItem = hb_itemPutNDLen( NULL, sqlite3_column_double( st, ui ), pField->uiLen, pField->uiDec );
break;
case HB_FT_BLOB:

View File

@@ -171,39 +171,6 @@ HB_FUNC( ATSKIPSTRINGS ) /* cFind, cWhere, nStart */
hb_retns( 0 );
}
/* Case insensitive hb_strAt() function */
static HB_SIZE hb_strAtI( const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_strAtI(%s, %" HB_PFS "u, %s, %" HB_PFS "u)", szSub, nSubLen, szText, nLen ) );
if( nSubLen > 0 && nLen >= nSubLen )
{
HB_SIZE nPos = 0;
HB_SIZE nSubPos = 0;
while( nPos < nLen && nSubPos < nSubLen )
{
if( HB_TOLOWER( ( HB_BYTE ) szText[ nPos ] ) == HB_TOLOWER( ( HB_BYTE ) szSub[ nSubPos ] ) )
{
nSubPos++;
nPos++;
}
else if( nSubPos )
{
/* Go back to the first character after the first match,
or else tests like "22345" $ "012223456789" will fail. */
nPos -= ( nSubPos - 1 );
nSubPos = 0;
}
else
nPos++;
}
return ( nSubPos < nSubLen ) ? 0 : ( nPos - nSubLen + 1 );
}
else
return 0;
}
/* Case insensitive At() function */
HB_FUNC( ATI )
{

View File

@@ -964,6 +964,7 @@ extern HB_EXPORT HB_BOOL hb_strMatchCaseWildExact( const char * szString, cons
extern HB_EXPORT HB_BOOL hb_strEmpty( const char * szText, HB_SIZE nLen ); /* returns whether a string contains only white space */
extern HB_EXPORT void hb_strDescend( char * szStringTo, const char * szStringFrom, HB_SIZE nLen ); /* copy a string to a buffer, inverting each character */
extern HB_EXPORT HB_SIZE hb_strAt( const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen ); /* returns an index to a sub-string within another string */
extern HB_EXPORT HB_SIZE hb_strAtI( const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen ); /* returns an index to a sub-string within another, ignore the case of the characters */
extern HB_EXPORT HB_ISIZ hb_strAtTBM( const char * needle, HB_ISIZ m, const char * haystack, HB_ISIZ n );
/* Warning: this functions works only with byte oriented CPs */

View File

@@ -106,6 +106,33 @@ HB_SIZE hb_strAt( const char * szSub, HB_SIZE nSubLen, const char * szText, HB_S
return 0;
}
HB_SIZE hb_strAtI( const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_strAt(%s, %" HB_PFS "u, %s, %" HB_PFS "u)", szSub, nSubLen, szText, nLen ) );
if( nSubLen > 0 && nLen >= nSubLen )
{
HB_SIZE nPos = 0;
nLen -= nSubLen;
do
{
if( HB_TOUPPER( szText[ nPos ] ) == HB_TOUPPER( *szSub ) )
{
HB_SIZE nSubPos = nSubLen;
do
{
if( --nSubPos == 0 )
return nPos + 1;
}
while( HB_TOUPPER( szText[ nPos + nSubPos ] ) == HB_TOUPPER( szSub[ nSubPos ] ) );
}
}
while( nPos++ < nLen );
}
return 0;
}
HB_BOOL hb_strEmpty( const char * szText, HB_SIZE nLen )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_strEmpty(%s, %" HB_PFS "u)", szText, nLen ) );

View File

@@ -53,9 +53,9 @@
#include "hbapicdp.h"
#include "hbapierr.h"
static HB_SIZE hb_strAtI( PHB_CODEPAGE cdp, const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen )
static HB_SIZE s_strAtI( PHB_CODEPAGE cdp, const char * szSub, HB_SIZE nSubLen, const char * szText, HB_SIZE nLen )
{
HB_TRACE( HB_TR_DEBUG, ( "hb_strAtI(%p, %s, %" HB_PFS "u, %s, %" HB_PFS "u)", cdp, szSub, nSubLen, szText, nLen ) );
HB_TRACE( HB_TR_DEBUG, ( "s_strAtI(%p, %s, %" HB_PFS "u, %s, %" HB_PFS "u)", cdp, szSub, nSubLen, szText, nLen ) );
if( nSubLen > 0 && nLen >= nSubLen )
{
@@ -125,8 +125,8 @@ HB_FUNC( HB_ATI )
if( nTo > 0 )
{
nPos = hb_strAtI( cdp, hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
pszText, nTo );
nPos = s_strAtI( cdp, hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
pszText, nTo );
if( nPos > 0 )
nPos += HB_CDP_ISCHARIDX( cdp ) ? nStart : nFrom;
}

View File

@@ -5563,6 +5563,110 @@ static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
}
break;
case HB_GTI_DISPIMAGE:
if( wnd->window && pInfo->pNewVal && HB_IS_ARRAY( pInfo->pNewVal ) &&
hb_arrayLen( pInfo->pNewVal ) ==
( hb_arrayGetType( pInfo->pNewVal, 4 ) & HB_IT_NUMERIC ? 4 : 3 ) )
{
XImage * xImage = NULL;
/* { pBitmap, iWidth, iHeight [, iDepth ] } */
if( ( hb_arrayGetType( pInfo->pNewVal, 1 ) & ( HB_IT_POINTER | HB_IT_STRING ) ) &&
( hb_arrayGetType( pInfo->pNewVal, 2 ) & HB_IT_NUMERIC ) &&
( hb_arrayGetType( pInfo->pNewVal, 3 ) & HB_IT_NUMERIC ) )
{
HB_SIZE nSize = hb_arrayGetCLen( pInfo->pNewVal, 1 );
int iWidth = hb_arrayGetNI( pInfo->pNewVal, 2 );
int iHeight = hb_arrayGetNI( pInfo->pNewVal, 3 );
int iDepth = hb_arrayGetNI( pInfo->pNewVal, 4 );
int iPad = 32;
char * pFreeImage = NULL;
if( iDepth == 0 )
iDepth = DefaultDepth( wnd->dpy, DefaultScreen( wnd->dpy ) );
if( iWidth > 0 && iHeight > 0 && iDepth > 0 )
{
if( nSize > 0 )
{
while( pFreeImage == NULL && iPad >= 8 )
{
int iPitch = ( iWidth * iDepth + iPad - 1 ) / iPad;
if( nSize == ( HB_SIZE ) ( iHeight * iPitch ) )
pFreeImage = ( char * ) hb_arrayGetCPtr( pInfo->pNewVal, 1 );
else
iPad >>= 1;
}
}
else
pFreeImage = ( char * ) hb_arrayGetPtr( pInfo->pNewVal, 1 );
}
if( pFreeImage != NULL )
{
xImage = XCreateImage( wnd->dpy, DefaultVisual( wnd->dpy, DefaultScreen( wnd->dpy ) ),
iDepth, ZPixmap, 0, pFreeImage, iWidth, iHeight, iPad, 0 );
}
}
if( xImage )
{
XWC_RECT rx;
rx.left = rx.top = 0;
rx.right = xImage->width;
rx.bottom = xImage->height;
/* fetch & validate area for displaying */
if( pInfo->pNewVal2 && HB_IS_ARRAY( pInfo->pNewVal2 ) )
{
switch( hb_arrayLen( pInfo->pNewVal2 ) )
{
case 2:
rx.left = hb_arrayGetNI( pInfo->pNewVal2, 1 );
rx.top = hb_arrayGetNI( pInfo->pNewVal2, 2 );
rx.right += rx.left;
rx.bottom += rx.top;
break;
case 4:
rx.left = hb_arrayGetNI( pInfo->pNewVal2, 1 );
rx.top = hb_arrayGetNI( pInfo->pNewVal2, 2 );
rx.right = hb_arrayGetNI( pInfo->pNewVal2, 3 );
rx.bottom = hb_arrayGetNI( pInfo->pNewVal2, 4 );
if( rx.right >= rx.left + xImage->width )
rx.right = rx.left + xImage->width - 1;
if( rx.bottom >= rx.top + xImage->height )
rx.bottom = rx.top + xImage->height - 1;
break;
}
}
if( rx.left >= 0 && rx.top >= 0 &&
rx.left <= rx.right && rx.top <= rx.bottom )
{
HB_GTSELF_REFRESH( pGT );
if( rx.right > wnd->width )
rx.right = wnd->width;
if( rx.bottom > wnd->height )
rx.bottom = wnd->height;
HB_XWC_XLIB_LOCK();
XPutImage( wnd->dpy, wnd->pm, wnd->gc, xImage, 0, 0,
rx.left, rx.top, rx.right - rx.left + 1, rx.bottom - rx.top + 1 );
HB_XWC_XLIB_UNLOCK();
hb_gt_xwc_InvalidatePts( wnd, rx.left, rx.top, rx.left, rx.top );
if( HB_GTSELF_DISPCOUNT( pGT ) == 0 )
hb_gt_xwc_RealRefresh( wnd, HB_FALSE );
}
/* !NOT! use XDestroyImage(), char * xImage->data is [ eg hbfimage ] external managed */
if( xImage->obdata )
XFree( xImage->obdata );
XFree( xImage );
}
}
break;
default:
return HB_GTSUPER_INFO( pGT, iType, pInfo );
}
@@ -5648,9 +5752,9 @@ static int hb_gt_xwc_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
{
color.pixel = XGetPixel( image, 0, 0 );
XQueryColor( wnd->dpy, wnd->colorsmap, &color );
iRet = ( ( color.red / 256 ) & 0xFF ) << 16 |
( ( color.green / 256 ) & 0xFF ) << 8 |
( ( color.blue / 256 ) & 0xFF );
iRet = ( ( color.red >> 8 ) & 0xFF ) << 16 |
( ( color.green >> 8 ) & 0xFF ) << 8 |
( ( color.blue >> 8 ) & 0xFF );
XDestroyImage( image );
}
else