2012-11-23 14:07 UTC+0100 Viktor Szakats (harbour syenar.net)

* contrib/hbfbird/firebird.c
  * contrib/hbmisc/hb_f.c
  * contrib/hbpgsql/hbpgsql.h
  * contrib/hbpgsql/postgres.c
  * contrib/hbpgsql/rddcopy.c
  * contrib/hbsqlit3/core.c
  * contrib/hbtip/encurlc.c
    * various code cleanups and minor fixes
      (var scopes, excessive {}, commented code,
      bad formatting, uncrustify friendliness, 
      while( HB_TRUE ), missing HB_EXTERN*, missing 
      HB_EXPORT, missing header self-guard, etc)

  + contrib/hbmisc/dates.c
  - contrib/hbmisc/dates2.c
  * contrib/hbmisc/hbmisc.hbp
    * renamed
This commit is contained in:
Viktor Szakats
2012-11-23 13:11:52 +00:00
parent 39998b8b97
commit ef46ac3a3a
10 changed files with 283 additions and 277 deletions

View File

@@ -10,6 +10,25 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2012-11-23 14:07 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/hbfbird/firebird.c
* contrib/hbmisc/hb_f.c
* contrib/hbpgsql/hbpgsql.h
* contrib/hbpgsql/postgres.c
* contrib/hbpgsql/rddcopy.c
* contrib/hbsqlit3/core.c
* contrib/hbtip/encurlc.c
* various code cleanups and minor fixes
(var scopes, excessive {}, commented code,
bad formatting, uncrustify friendliness,
while( HB_TRUE ), missing HB_EXTERN*, missing
HB_EXPORT, missing header self-guard, etc)
+ contrib/hbmisc/dates.c
- contrib/hbmisc/dates2.c
* contrib/hbmisc/hbmisc.hbp
* renamed
2012-11-23 12:50 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/xhb/hbcompat.h
+ added compatibility macros from xhb repository

View File

@@ -504,13 +504,10 @@ HB_FUNC( FBFREE )
return;
}
if( trans )
if( trans && isc_commit_transaction( status, &trans ) )
{
if( isc_commit_transaction( status, &trans ) )
{
hb_retnl( isc_sqlcode( status ) );
return;
}
hb_retnl( isc_sqlcode( status ) );
return;
}
/* TOFIX: Freeing pointer received as parameter? We should at least set the item NULL. */
@@ -698,10 +695,9 @@ HB_FUNC( FBGETBLOB )
ISC_STATUS_ARRAY status;
isc_tr_handle trans = ( isc_tr_handle ) 0;
isc_blob_handle blob_handle = ( isc_blob_handle ) 0;
short blob_seg_len;
char blob_segment[ 512 ];
short blob_seg_len;
char blob_segment[ 512 ];
ISC_QUAD * blob_id = ( ISC_QUAD * ) hb_parptr( 2 );
char p[ 1024 ];
ISC_STATUS blob_stat;
if( HB_ISPOINTER( 3 ) )
@@ -732,6 +728,7 @@ HB_FUNC( FBGETBLOB )
while( blob_stat == 0 || status[ 1 ] == isc_segment )
{
char p[ 1024 ];
PHB_ITEM temp;
hb_snprintf( p, sizeof( p ), "%*.*s", blob_seg_len, blob_seg_len, blob_segment );

View File

@@ -187,9 +187,7 @@ static long hb_hbfskip( PFT_TEXT ft_text, char * buffer, HB_SIZE bufsize, int re
{
if( ( ( *( buffer + x ) == 13 ) && ( *( buffer + x + 1 ) == 10 ) ) ||
( ( *( buffer + x ) == 10 ) && ( *( buffer + x + 1 ) == 13 ) ) )
{
break;
}
}
if( x < 0 )
{
@@ -236,9 +234,7 @@ HB_FUNC( HB_FREADLN )
if( ( ( *( buffer + x ) == 13 ) && ( *( buffer + x + 1 ) == 10 ) ) ||
( ( *( buffer + x ) == 10 ) && ( *( buffer + x + 1 ) == 13 ) ) ||
( *( buffer + x ) == 26 ) || x >= read )
{
break;
}
}
hb_retclen( buffer, x );

View File

@@ -12,7 +12,7 @@
hbmisc.hbx
bbabble.c
dates2.c
dates.c
ffind.c
hb_f.c
hbeditc.c

View File

@@ -53,40 +53,49 @@
*
*/
#ifndef __HBPGSQL_H
#define __HBPGSQL_H
#include "hbapi.h"
#include "libpq-fe.h"
#include "pg_config.h"
#define VARHDRSZ 4
#define BOOLOID 16
#define INT8OID 20
#define INT2OID 21
#define INT4OID 23
#define TEXTOID 25
#define OIDOID 26
#define FLOAT4OID 700
#define FLOAT8OID 701
#define CASHOID 790
#define BPCHAROID 1042
#define VARCHAROID 1043
#define DATEOID 1082
#define TIMEOID 1083
#define TIMESTAMPOID 1114
#define TIMESTAMPTZOID 1184
#define TIMETZOID 1266
#define BITOID 1560
#define VARBITOID 1562
#define NUMERICOID 1700
#define VARHDRSZ 4
#define BOOLOID 16
#define INT8OID 20
#define INT2OID 21
#define INT4OID 23
#define TEXTOID 25
#define OIDOID 26
#define FLOAT4OID 700
#define FLOAT8OID 701
#define CASHOID 790
#define BPCHAROID 1042
#define VARCHAROID 1043
#define DATEOID 1082
#define TIMEOID 1083
#define TIMESTAMPOID 1114
#define TIMESTAMPTZOID 1184
#define TIMETZOID 1266
#define BITOID 1560
#define VARBITOID 1562
#define NUMERICOID 1700
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
#ifndef PG_VERSION_NUM
#define PG_VERSION_NUM 0
#define PG_VERSION_NUM 0
#endif
extern void hb_PGconn_ret( PGconn * p );
extern PGconn * hb_PGconn_par( int iParam );
extern void hb_PGresult_ret( PGresult * p );
extern PGresult * hb_PGresult_par( int iParam );
HB_EXTERN_BEGIN
extern HB_EXPORT void hb_PGconn_ret( PGconn * p );
extern HB_EXPORT PGconn * hb_PGconn_par( int iParam );
extern HB_EXPORT void hb_PGresult_ret( PGresult * p );
extern HB_EXPORT PGresult * hb_PGresult_par( int iParam );
HB_EXTERN_END
#endif /* __HBPGSQL_H */

View File

@@ -1176,40 +1176,40 @@ HB_FUNC( PQPUTCOPYEND )
#endif
}
/*
#if 0
TODO: Implement Full Large Objects Support
TODO: Implement Prepared Query handling
TODO: Implement Full Large Objects Support
TODO: Implement Prepared Query handling
extern int lo_open(PGconn *conn, Oid lobjId, int mode);
extern int lo_close(PGconn *conn, int fd);
extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
extern int lo_write(PGconn *conn, int fd, char *buf, size_t len);
extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
extern Oid lo_creat(PGconn *conn, int mode);
extern int lo_tell(PGconn *conn, int fd);
extern int lo_open( PGconn * conn, Oid lobjId, int mode );
extern int lo_close( PGconn * conn, int fd );
extern int lo_read( PGconn * conn, int fd, char * buf, size_t len );
extern int lo_write( PGconn * conn, int fd, char * buf, size_t len );
extern int lo_lseek( PGconn * conn, int fd, int offset, int whence );
extern Oid lo_creat( PGconn * conn, int mode );
extern int lo_tell( PGconn * conn, int fd );
int PQsendQueryParams(PGconn *conn,
const char *command,
int nParams,
const Oid *paramTypes,
const char * const *paramValues,
const int *paramLengths,
const int *paramFormats,
int resultFormat);
int PQsendQueryParams( PGconn * conn,
const char * command,
int nParams,
const Oid * paramTypes,
const char * const * paramValues,
const int * paramLengths,
const int * paramFormats,
int resultFormat );
int PQsendPrepare(PGconn *conn,
const char *stmtName,
const char *query,
int nParams,
const Oid *paramTypes);
int PQsendPrepare( PGconn * conn,
const char * stmtName,
const char * query,
int nParams,
const Oid * paramTypes );
int PQsendQueryPrepared(PGconn *conn,
const char *stmtName,
int nParams,
const char * const *paramValues,
const int *paramLengths,
const int *paramFormats,
int resultFormat);
int PQsendQueryPrepared( PGconn * conn,
const char * stmtName,
int nParams,
const char * const * paramValues,
const int * paramLengths,
const int * paramFormats,
int resultFormat );
*/
#endif

View File

@@ -81,6 +81,7 @@ static HB_BOOL addToContext( pgCopyContext * context, const char c )
context->position = 0;
}
context->buffer[ context->position++ ] = ( HB_BYTE ) c;
return HB_TRUE;
}
static HB_BOOL addStrToContext( pgCopyContext * context, const char * str )
@@ -96,6 +97,7 @@ static HB_BOOL addStrToContext( pgCopyContext * context, const char * str )
}
context->buffer[ context->position++ ] = ( HB_BYTE ) *str++;
}
return HB_TRUE;
}
static HB_BOOL addStrnToContext( pgCopyContext * context, const char * str, HB_SIZE size )
@@ -112,6 +114,7 @@ static HB_BOOL addStrnToContext( pgCopyContext * context, const char * str, HB_S
}
context->buffer[ context->position++ ] = ( HB_BYTE ) str[ nSize++ ];
}
return HB_TRUE;
}
@@ -196,7 +199,9 @@ static HB_BOOL exportBufSqlVar( pgCopyContext * context, PHB_ITEM pValue, const
}
case HB_IT_LOGICAL:
/* if(! addStrToContext( context, szQuote ) || ! addToContext( context, hb_itemGetL( pValue ) ? 'Y' : 'N' ) || ! addStrToContext( context, szQuote ) ) */
#if 0
if( ! addStrToContext( context, szQuote ) || ! addToContext( context, hb_itemGetL( pValue ) ? 'Y' : 'N' ) || ! addStrToContext( context, szQuote ) )
#endif
if( ! addToContext( context, hb_itemGetL( pValue ) ? 'Y' : 'N' ) )
return HB_FALSE;
break;
@@ -238,37 +243,37 @@ static HB_BOOL exportBufSqlVar( pgCopyContext * context, PHB_ITEM pValue, const
HB_FUNC( HB_PQCOPYFROMWA )
{
#if PG_VERSION_NUM >= 80000
PGconn * pConn = hb_PGconn_par( 1 );
const char * szTable = hb_parcx( 2 );
PHB_ITEM pWhile = hb_param( 3, HB_IT_BLOCK );
PHB_ITEM pFor = hb_param( 4, HB_IT_BLOCK );
PHB_ITEM pFields = hb_param( 5, HB_IT_ARRAY );
HB_ULONG nCount = hb_parnldef( 6, 0 );
HB_BOOL str_rtrim = hb_parldef( 7, HB_TRUE );
HB_ULONG nBufLen = hb_parnldef( 8, 1 );
HB_USHORT uiFields;
HB_ULONG uiRecCount = 0;
/* HB_ULONG uiRecNo = 0;
DBORDERINFO pInfo;
int iOrd; */
HB_BOOL bNoFieldPassed = ( pFields == NULL || hb_arrayLen( pFields ) == 0 );
HB_BOOL bEof = HB_FALSE;
AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
PHB_ITEM pItem;
HB_USHORT uiFieldCopy = 0;
HB_USHORT uiIter;
pgCopyContext * context;
char * szInit;
static const char * s_szQuote = "\"";
static const char * s_szEsc = "\"";
static const char * s_szDelim = ",";
char * szFields = NULL;
char * szTmp = NULL;
PGresult * pgResult = NULL;
HB_BOOL bFail = HB_FALSE;
AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();
if( pArea )
{
static const char * sc_szQuote = "\"";
static const char * sc_szEsc = "\"";
static const char * sc_szDelim = ",";
PGconn * pConn = hb_PGconn_par( 1 );
const char * szTable = hb_parcx( 2 );
PHB_ITEM pWhile = hb_param( 3, HB_IT_BLOCK );
PHB_ITEM pFor = hb_param( 4, HB_IT_BLOCK );
PHB_ITEM pFields = hb_param( 5, HB_IT_ARRAY );
HB_ULONG nCount = hb_parnldef( 6, 0 );
HB_BOOL str_rtrim = hb_parldef( 7, HB_TRUE );
HB_ULONG nBufLen = hb_parnldef( 8, 1 );
HB_USHORT uiFields;
HB_ULONG uiRecCount;
HB_BOOL bNoFieldPassed = ( pFields == NULL || hb_arrayLen( pFields ) == 0 );
HB_BOOL bEof = HB_FALSE;
PHB_ITEM pItem;
HB_USHORT uiFieldCopy = 0;
HB_USHORT uiIter;
pgCopyContext * context;
char * szInit;
char * szFields = NULL;
char * szTmp = NULL;
PGresult * pgResult = NULL;
HB_BOOL bFail = HB_FALSE;
pItem = hb_itemNew( NULL );
context = ( pgCopyContext * ) hb_xgrab( sizeof( pgCopyContext ) );
@@ -301,7 +306,7 @@ HB_FUNC( HB_PQCOPYFROMWA )
szFields = szTmp;
if( uiIter != uiFieldCopy )
{
szTmp = hb_xstrcpy( NULL, szFields, s_szDelim, NULL );
szTmp = hb_xstrcpy( NULL, szFields, sc_szDelim, NULL );
hb_xfree( szFields );
szFields = szTmp;
}
@@ -329,11 +334,11 @@ HB_FUNC( HB_PQCOPYFROMWA )
if( szFields )
{
szInit = hb_xstrcpy( NULL, "COPY ", szTable, " ", szFields, " FROM STDIN WITH DELIMITER '", s_szDelim, "' CSV QUOTE AS '", s_szQuote, "' ESCAPE AS '", s_szEsc, "'", NULL );
szInit = hb_xstrcpy( NULL, "COPY ", szTable, " ", szFields, " FROM STDIN WITH DELIMITER '", sc_szDelim, "' CSV QUOTE AS '", sc_szQuote, "' ESCAPE AS '", sc_szEsc, "'", NULL );
hb_xfree( szFields );
}
else
szInit = hb_xstrcpy( NULL, "COPY ", szTable, " FROM STDIN WITH DELIMITER '", s_szDelim, "' CSV QUOTE AS '", s_szQuote, "' ESCAPE AS '", s_szEsc, "'", NULL );
szInit = hb_xstrcpy( NULL, "COPY ", szTable, " FROM STDIN WITH DELIMITER '", sc_szDelim, "' CSV QUOTE AS '", sc_szQuote, "' ESCAPE AS '", sc_szEsc, "'", NULL );
pgResult = PQexec( context->connection, szInit );
if( PQresultStatus( pgResult ) != PGRES_COPY_IN )
@@ -347,7 +352,8 @@ HB_FUNC( HB_PQCOPYFROMWA )
PQclear( pgResult );
hb_xfree( szInit );
/* uiRecCount = 0; */
uiRecCount = 0;
while( ( nCount == 0 || uiRecCount < nCount ) &&
( ! pWhile || hb_itemGetL( hb_vmEvalBlock( pWhile ) ) ) )
{
@@ -365,7 +371,7 @@ HB_FUNC( HB_PQCOPYFROMWA )
for( uiIter = 1; uiIter <= uiFields; uiIter++ )
{
SELF_GETVALUE( pArea, uiIter, pItem );
if( ! exportBufSqlVar( context, pItem, s_szQuote, s_szEsc ) || ! addStrToContext( context, s_szDelim ) )
if( ! exportBufSqlVar( context, pItem, sc_szQuote, sc_szEsc ) || ! addStrToContext( context, sc_szDelim ) )
{
bFail = HB_TRUE;
break;
@@ -377,7 +383,7 @@ HB_FUNC( HB_PQCOPYFROMWA )
for( uiIter = 1; uiIter <= uiFieldCopy; uiIter++ )
{
SELF_GETVALUE( pArea, ( HB_USHORT ) hb_arrayGetNI( pFields, uiIter ), pItem );
if( ! exportBufSqlVar( context, pItem, s_szQuote, s_szEsc ) || ! addStrToContext( context, s_szDelim ) )
if( ! exportBufSqlVar( context, pItem, sc_szQuote, sc_szEsc ) || ! addStrToContext( context, sc_szDelim ) )
{
bFail = HB_TRUE;
break;
@@ -402,7 +408,7 @@ HB_FUNC( HB_PQCOPYFROMWA )
break;
}
while( HB_TRUE )
for(;; )
{
if( bFail )
{

View File

@@ -667,9 +667,7 @@ HB_FUNC( SQLITE3_TEMP_DIRECTORY )
const char * pszDirName = hb_fsNameConv( hb_parcx( 1 ), &pszFree );
if( hb_fsIsDirectory( pszDirName ) )
{
bResult = HB_TRUE;
}
else
{
if( hb_parl( 2 ) ) /* create temp directory if not exist */
@@ -785,16 +783,12 @@ HB_FUNC( SQLITE3_EXEC )
int rc;
if( HB_ISBLOCK( 3 ) || HB_ISSYMBOL( 3 ) )
{
rc = sqlite3_exec( pHbSqlite3->db, hb_parstr_utf8( 2, &hSQLText,
NULL ), callback, ( void * ) hb_param( 3, HB_IT_BLOCK | HB_IT_SYMBOL ),
&pszErrMsg );
}
else
{
rc = sqlite3_exec( pHbSqlite3->db, hb_parstr_utf8( 2, &hSQLText,
NULL ), NULL, 0, &pszErrMsg );
}
if( rc != SQLITE_OK )
{
@@ -828,9 +822,9 @@ HB_FUNC( SQLITE3_PREPARE )
void * hSQLText;
HB_SIZE nSQLText;
const char * pszSQLText = hb_parstr_utf8( 2, &hSQLText, &nSQLText );
const char * pszSQLText = hb_parstr_utf8( 2, &hSQLText, &nSQLText );
psqlite3_stmt pStmt;
const char * pszTail;
const char * pszTail;
if( sqlite3_prepare_v2( pHbSqlite3->db, pszSQLText, ( int ) nSQLText, &pStmt, &pszTail ) == SQLITE_OK )
hb_retptr( pStmt );
@@ -1362,9 +1356,7 @@ HB_FUNC( SQLITE3_ENABLE_LOAD_EXTENSION )
HB_SQLITE3 * pHbSqlite3 = ( HB_SQLITE3 * ) hb_sqlite3_param( 1, HB_SQLITE3_DB, HB_TRUE );
if( pHbSqlite3 && pHbSqlite3->db )
{
hb_retni( sqlite3_enable_load_extension( pHbSqlite3->db, hb_parl( 2 ) ) );
}
else
hb_errRT_BASE_SubstR( EG_ARG, 0, NULL, HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) );
#else
@@ -1484,21 +1476,16 @@ HB_FUNC( SQLITE3_TABLE_COLUMN_METADATA )
void * hTableName;
void * hColumnName;
if
(
sqlite3_table_column_metadata
(
pHbSqlite3->db,
hb_parstr_utf8( 2, &hDbName, NULL ),
hb_parstr_utf8( 3, &hTableName, NULL ),
hb_parstr_utf8( 4, &hColumnName, NULL ),
&pzDataType /* pzDataDtype */,
&pzCollSeq /* pzCollSeq */,
&iNotNull,
&iPrimaryKey,
&iAutoinc
) == SQLITE_OK
)
if( sqlite3_table_column_metadata(
pHbSqlite3->db,
hb_parstr_utf8( 2, &hDbName, NULL ),
hb_parstr_utf8( 3, &hTableName, NULL ),
hb_parstr_utf8( 4, &hColumnName, NULL ),
&pzDataType /* pzDataDtype */,
&pzCollSeq /* pzCollSeq */,
&iNotNull,
&iPrimaryKey,
&iAutoinc ) == SQLITE_OK )
{
PHB_ITEM pArray = hb_itemArrayNew( 5 );
@@ -1597,22 +1584,15 @@ HB_FUNC( SQLITE3_BLOB_OPEN )
void * hTableName;
void * hColumnName;
if
(
sqlite3_blob_open
(
pHbSqlite3->db,
hb_parstr_utf8( 2, &hDbName, NULL ),
hb_parstr_utf8( 3, &hTableName, NULL ),
hb_parstr_utf8( 4, &hColumnName, NULL ),
( sqlite3_int64 ) hb_parnint( 5 ) /* iRow */,
hb_parni( 6 ) /* flags */,
&ppBlob
) == SQLITE_OK
)
{
if( sqlite3_blob_open(
pHbSqlite3->db,
hb_parstr_utf8( 2, &hDbName, NULL ),
hb_parstr_utf8( 3, &hTableName, NULL ),
hb_parstr_utf8( 4, &hColumnName, NULL ),
( sqlite3_int64 ) hb_parnint( 5 ) /* iRow */,
hb_parni( 6 ) /* flags */,
&ppBlob ) == SQLITE_OK )
hb_retptr( ppBlob );
}
else
hb_retptr( NULL );
@@ -1865,7 +1845,7 @@ HB_FUNC( SQLITE3_INTERRUPT )
/**
A Callback To Handle SQLITE_BUSY Errors
sqlite3_busy_handler( db, nNumOfOpCodes, [Nil]|[cFunc]|[sFunc] )
sqlite3_busy_handler( db, nNumOfOpCodes, [cFunc|sFunc] )
*/
HB_FUNC( SQLITE3_BUSY_HANDLER )
@@ -1896,7 +1876,7 @@ HB_FUNC( SQLITE3_BUSY_HANDLER )
/**
Query Progress Callbacks
sqlite3_progress_handler( db, nNumOfOpCodes, [Nil]|[cFunc]|[sFunc] )
sqlite3_progress_handler( db, nNumOfOpCodes, [cFunc|sFunc] )
*/
HB_FUNC( SQLITE3_PROGRESS_HANDLER )
@@ -1927,8 +1907,8 @@ HB_FUNC( SQLITE3_PROGRESS_HANDLER )
/**
Commit And Rollback Notification Callbacks
sqlite3_commit_hook( db, [Nil]|[cFunc]|[sFunc] )
sqlite3_rollback_hook( db, [Nil]|[cFunc]|[sFunc] )
sqlite3_commit_hook( db, [cFunc|sFunc] )
sqlite3_rollback_hook( db, [cFunc|sFunc] )
*/
HB_FUNC( SQLITE3_COMMIT_HOOK )
@@ -1983,7 +1963,7 @@ HB_FUNC( SQLITE3_ROLLBACK_HOOK )
/**
Compile-Time Authorization Callbacks
sqlite3_set_authorizer( pDb, [Nil]|[cFunc]|[sFunc] )
sqlite3_set_authorizer( pDb, [cFunc|sFunc] )
*/
HB_FUNC( SQLITE3_SET_AUTHORIZER )
@@ -2060,8 +2040,10 @@ HB_FUNC( SQLITE3_BACKUP_STEP )
if( pBackup )
hb_retni( sqlite3_backup_step( pBackup, hb_parni( 2 ) ) );
else
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
hb_retni( -1 );
#else
hb_retni( -1 );
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
}
HB_FUNC( SQLITE3_BACKUP_FINISH )
@@ -2073,8 +2055,10 @@ HB_FUNC( SQLITE3_BACKUP_FINISH )
if( pBackup )
hb_retni( sqlite3_backup_finish( pBackup ) );
else
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
hb_retni( -1 );
#else
hb_retni( -1 );
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
}
HB_FUNC( SQLITE3_BACKUP_REMAINING )
@@ -2086,8 +2070,10 @@ HB_FUNC( SQLITE3_BACKUP_REMAINING )
if( pBackup )
hb_retni( sqlite3_backup_remaining( pBackup ) );
else
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
hb_retni( -1 );
#else
hb_retni( -1 );
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
}
HB_FUNC( SQLITE3_BACKUP_PAGECOUNT )
@@ -2099,8 +2085,10 @@ HB_FUNC( SQLITE3_BACKUP_PAGECOUNT )
if( pBackup )
hb_retni( sqlite3_backup_pagecount( pBackup ) );
else
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
hb_retni( -1 );
#else
hb_retni( -1 );
#endif /* SQLITE_VERSION_NUMBER >= 3006011 */
}
/**
@@ -2165,8 +2153,10 @@ HB_FUNC( SQLITE3_STATUS )
hb_storni( iHighwater, 3 );
}
else
#endif /* SQLITE_VERSION_NUMBER >= 3006000 */
hb_retni( -1 );
#else
hb_retni( -1 );
#endif /* SQLITE_VERSION_NUMBER >= 3006000 */
}
/**
@@ -2191,8 +2181,10 @@ HB_FUNC( SQLITE3_DB_STATUS )
hb_storni( iHighwater, 4 );
}
else
#endif /* SQLITE_VERSION_NUMBER >= 3006001 */
hb_retni( -1 );
#else
hb_retni( -1 );
#endif /* SQLITE_VERSION_NUMBER >= 3006001 */
}
/**
@@ -2209,8 +2201,10 @@ HB_FUNC( SQLITE3_LIMIT )
if( pHbSqlite3 && pHbSqlite3->db && ( hb_pcount() > 2 ) && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) )
hb_retni( sqlite3_limit( pHbSqlite3->db, hb_parni( 2 ), hb_parni( 3 ) ) );
else
#endif /* SQLITE_VERSION_NUMBER >= 3005008 */
hb_retni( -1 );
#else
hb_retni( -1 );
#endif /* SQLITE_VERSION_NUMBER >= 3005008 */
}
/**
@@ -2242,23 +2236,10 @@ HB_FUNC( SQLITE3_COMPILEOPTION_GET )
/**
Create Or Redefine SQL Functions
sqlite3_create_function( db, cFuncName, nArg, [Nil]|[cFunc]|[sFunc] )
sqlite3_create_function( db, cFuncName, nArg, [cFunc|sFunc] )
Only scalar function creation now supported.
*/
/*
int sqlite3_create_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
*/
HB_FUNC( SQLITE3_CREATE_FUNCTION )
{
HB_SQLITE3 * pHbSqlite3 = ( HB_SQLITE3 * ) hb_sqlite3_param( 1, HB_SQLITE3_DB, HB_TRUE );
@@ -2287,7 +2268,6 @@ HB_FUNC( SQLITE3_CREATE_FUNCTION )
func, NULL, NULL ) );
}
else
{
hb_retni(
sqlite3_create_function( pHbSqlite3->db,
hb_parstr_utf8( 2, &hFuncName, NULL ),
@@ -2295,7 +2275,6 @@ HB_FUNC( SQLITE3_CREATE_FUNCTION )
SQLITE_UTF8,
NULL,
NULL, NULL, NULL ) );
}
if( hFuncName )
hb_strfree( hFuncName );

View File

@@ -56,124 +56,124 @@
HB_FUNC( TIP_URLENCODE )
{
const char * cData = hb_parc( 1 );
HB_ISIZ nLen = hb_parclen( 1 );
HB_BOOL bComplete = hb_parldef( 2, HB_TRUE );
char * cRet;
HB_ISIZ nPos = 0, nPosRet = 0, nVal;
char cElem;
const char * cData = hb_parc( 1 );
if( ! cData )
if( cData )
{
HB_ISIZ nLen = hb_parclen( 1 );
if( nLen )
{
HB_BOOL bComplete = hb_parldef( 2, HB_TRUE );
char * cRet;
HB_ISIZ nPos = 0, nPosRet = 0, nVal;
char cElem;
/* Giving maximum final length possible */
cRet = ( char * ) hb_xgrab( nLen * 3 + 1 );
while( nPos < nLen )
{
cElem = cData[ nPos ];
if( cElem == ' ' )
{
cRet[ nPosRet ] = '+';
}
else if(
( cElem >= 'A' && cElem <= 'Z' ) ||
( cElem >= 'a' && cElem <= 'z' ) ||
( cElem >= '0' && cElem <= '9' ) ||
cElem == '.' || cElem == ',' || cElem == '&' ||
cElem == '/' || cElem == ';' || cElem == '_' )
{
cRet[ nPosRet ] = cElem;
}
else if( ! bComplete && ( cElem == ':' || cElem == '?' || cElem == '=' ) )
{
cRet[ nPosRet ] = cElem;
}
else /* encode! */
{
cRet[ nPosRet++ ] = '%';
nVal = ( ( HB_UCHAR ) cElem ) >> 4;
cRet[ nPosRet++ ] = nVal < 10 ? '0' + ( char ) nVal : 'A' + ( char ) nVal - 10;
nVal = ( ( HB_UCHAR ) cElem ) & 0x0F;
cRet[ nPosRet ] = nVal < 10 ? '0' + ( char ) nVal : 'A' + ( char ) nVal - 10;
}
nPosRet++;
nPos++;
}
hb_retclen_buffer( cRet, nPosRet );
}
else
hb_retc_null();
}
else
hb_errRT_BASE( EG_ARG, 3012, NULL,
HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) );
return;
}
if( ! nLen )
{
hb_retc_null();
return;
}
/* Giving maximum final length possible */
cRet = ( char * ) hb_xgrab( nLen * 3 + 1 );
while( nPos < nLen )
{
cElem = cData[ nPos ];
if( cElem == ' ' )
{
cRet[ nPosRet ] = '+';
}
else if(
( cElem >= 'A' && cElem <= 'Z' ) ||
( cElem >= 'a' && cElem <= 'z' ) ||
( cElem >= '0' && cElem <= '9' ) ||
cElem == '.' || cElem == ',' || cElem == '&' ||
cElem == '/' || cElem == ';' || cElem == '_' )
{
cRet[ nPosRet ] = cElem;
}
else if( ! bComplete && ( cElem == ':' || cElem == '?' || cElem == '=' ) )
{
cRet[ nPosRet ] = cElem;
}
else /* encode! */
{
cRet[ nPosRet++ ] = '%';
nVal = ( ( HB_UCHAR ) cElem ) >> 4;
cRet[ nPosRet++ ] = nVal < 10 ? '0' + ( char ) nVal : 'A' + ( char ) nVal - 10;
nVal = ( ( HB_UCHAR ) cElem ) & 0x0F;
cRet[ nPosRet ] = nVal < 10 ? '0' + ( char ) nVal : 'A' + ( char ) nVal - 10;
}
nPosRet++;
nPos++;
}
hb_retclen_buffer( cRet, nPosRet );
}
HB_FUNC( TIP_URLDECODE )
{
const char * cData = hb_parc( 1 );
HB_ISIZ nLen = hb_parclen( 1 );
char * cRet;
HB_ISIZ nPos = 0, nPosRet = 0;
char cElem;
if( ! cData )
if( cData )
{
hb_errRT_BASE( EG_ARG, 3012, NULL,
HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) );
return;
}
HB_ISIZ nLen = hb_parclen( 1 );
if( ! nLen )
{
hb_retc_null();
return;
}
/* maximum possible lenght */
cRet = ( char * ) hb_xgrab( nLen );
while( nPos < nLen )
{
cElem = cData[ nPos ];
if( cElem == '+' )
if( nLen )
{
cRet[ nPosRet ] = ' ';
}
else if( cElem == '%' )
{
if( nPos < nLen - 2 )
{
cElem = cData[ ++nPos ];
cRet[ nPosRet ] = cElem < 'A' ? cElem - '0' : cElem - 'A' + 10;
cRet[ nPosRet ] *= 16;
char * cRet;
HB_ISIZ nPos = 0, nPosRet = 0;
char cElem;
cElem = cData[ ++nPos ];
cRet[ nPosRet ] |= cElem < 'A' ? cElem - '0' : cElem - 'A' + 10;
}
else
/* maximum possible lenght */
cRet = ( char * ) hb_xgrab( nLen );
while( nPos < nLen )
{
if( nPosRet > 0 )
break;
cElem = cData[ nPos ];
if( cElem == '+' )
{
cRet[ nPosRet ] = ' ';
}
else if( cElem == '%' )
{
if( nPos < nLen - 2 )
{
cElem = cData[ ++nPos ];
cRet[ nPosRet ] = cElem < 'A' ? cElem - '0' : cElem - 'A' + 10;
cRet[ nPosRet ] *= 16;
cElem = cData[ ++nPos ];
cRet[ nPosRet ] |= cElem < 'A' ? cElem - '0' : cElem - 'A' + 10;
}
else
{
if( nPosRet > 0 )
break;
}
}
else
cRet[ nPosRet ] = cElem;
nPos++;
nPosRet++;
}
/* this function also adds a zero */
/* hopefully reduce the size of cRet */
cRet = ( char * ) hb_xrealloc( cRet, nPosRet + 1 );
hb_retclen_buffer( cRet, nPosRet );
}
else
cRet[ nPosRet ] = cElem;
nPos++;
nPosRet++;
hb_retc_null();
}
/* this function also adds a zero */
/* hopefully reduce the size of cRet */
cRet = ( char * ) hb_xrealloc( cRet, nPosRet + 1 );
hb_retclen_buffer( cRet, nPosRet );
else
hb_errRT_BASE( EG_ARG, 3012, NULL,
HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) );
}