2008-06-08 12:14 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

* contrib/hbmysql/tmysql.prg
   * contrib/hbmysql/mysql.c
   * contrib/hbmysql/mysql.ch
   * contrib/hbtpathy/telepath.ch
   * contrib/hbtpathy/tplinux.c
   * contrib/hbtpathy/tpwin32.c
   * contrib/hbtpathy/tpos2.c
   * contrib/hbtpathy/tpcommon.c
   * contrib/hbmsql/msql.h
   * contrib/hbmsql/msql.ch
   * contrib/hbmsql/msql.c
   * contrib/hbfbird/firebird.c
   * contrib/hbfbird/tests/test.prg
   * contrib/hbapollo/apollo.c
   * contrib/hbmisc/hb_f.c
     * General code cleanup, formatting, minor optimizations, 
       Harbour API usage cleanup, ANSI comments.
     ! Several minor fixes to Firebird interface code, but it 
       still doesn't seem to work, and the code is very unclear, 
       partly because of the strange/unsafe Firebird API.
     ! Firebird test.prg fixes: Variable name typos, undeclared 
       vars, hard-coded paths.

   * contrib/hbfbird/make_b32.bat
   * contrib/hbfbird/make_vc.bat
     * Fixed location where .libs are looked for.
       [TOMERGE RC1]

   * contrib/hbcurl/hbcurl.c
     % Minor cleanups.
       [TOMERGE RC1]
This commit is contained in:
Viktor Szakats
2008-06-08 10:22:37 +00:00
parent 8643634adb
commit 3b5dfde38c
19 changed files with 1110 additions and 1475 deletions

View File

@@ -8,6 +8,39 @@
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-06-08 12:14 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/hbmysql/tmysql.prg
* contrib/hbmysql/mysql.c
* contrib/hbmysql/mysql.ch
* contrib/hbtpathy/telepath.ch
* contrib/hbtpathy/tplinux.c
* contrib/hbtpathy/tpwin32.c
* contrib/hbtpathy/tpos2.c
* contrib/hbtpathy/tpcommon.c
* contrib/hbmsql/msql.h
* contrib/hbmsql/msql.ch
* contrib/hbmsql/msql.c
* contrib/hbfbird/firebird.c
* contrib/hbfbird/tests/test.prg
* contrib/hbapollo/apollo.c
* contrib/hbmisc/hb_f.c
* General code cleanup, formatting, minor optimizations,
Harbour API usage cleanup, ANSI comments.
! Several minor fixes to Firebird interface code, but it
still doesn't seem to work, and the code is very unclear,
partly because of the strange/unsafe Firebird API.
! Firebird test.prg fixes: Variable name typos, undeclared
vars, hard-coded paths.
* contrib/hbfbird/make_b32.bat
* contrib/hbfbird/make_vc.bat
* Fixed location where .libs are looked for.
[TOMERGE RC1]
* contrib/hbcurl/hbcurl.c
% Minor cleanups.
[TOMERGE RC1]
2008-06-07 15:32 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com
* harbour/source/rtl/gtwvt/gtwvt.c
* harbour/source/rtl/gtwvt/gtwvt.h

View File

@@ -73,7 +73,7 @@
* --------------------------------------------------*/
HB_FUNC( SX_APPENDBLANK )
{
sx_AppendBlank( );
sx_AppendBlank();
}
@@ -82,7 +82,7 @@ HB_FUNC( SX_APPENDBLANK )
* --------------------------------------------------*/
HB_FUNC( SX_CLOSE )
{
sx_Close( ) ;
sx_Close();
}
@@ -91,7 +91,7 @@ HB_FUNC( SX_CLOSE )
* --------------------------------------------------*/
HB_FUNC( SX_COMMIT )
{
sx_Commit( );
sx_Commit();
}
@@ -101,7 +101,7 @@ HB_FUNC( SX_COMMIT )
* --------------------------------------------------*/
HB_FUNC( SX_CREATEEXEC )
{
sx_CreateExec( );
sx_CreateExec();
}
@@ -123,11 +123,11 @@ HB_FUNC( SX_CREATEFIELD )
* --------------------------------------------------*/
HB_FUNC( SX_CREATENEW )
{
hb_retni(
sx_CreateNew( ( PBYTE ) hb_parc( 1 ), /* Field name */
( PBYTE ) hb_parc( 2 ), /* Alias */
hb_parni( 3 ), /* RDE Type */
hb_parni( 4 ) ) ); /* The maximum number of fields to be added to the file structure */
hb_retni(
sx_CreateNew( ( PBYTE ) hb_parc( 1 ), /* Field name */
( PBYTE ) hb_parc( 2 ), /* Alias */
hb_parni( 3 ), /* RDE Type */
hb_parni( 4 ) ) ); /* The maximum number of fields to be added to the file structure */
}
@@ -136,7 +136,7 @@ HB_FUNC( SX_CREATENEW )
* --------------------------------------------------*/
HB_FUNC( SX_EOF )
{
hb_retl( sx_Eof( ) );
hb_retl( sx_Eof() );
}
@@ -148,8 +148,7 @@ HB_FUNC( SX_EOF )
* --------------------------------------------------*/
HB_FUNC( SX_GETDATEJULIAN )
{
hb_retni(
sx_GetDateJulian( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
hb_retni( sx_GetDateJulian( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
@@ -159,8 +158,7 @@ HB_FUNC( SX_GETDATEJULIAN )
* --------------------------------------------------*/
HB_FUNC( SX_GETLOGICAL )
{
hb_retl(
sx_GetLogical( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
hb_retl( sx_GetLogical( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
@@ -169,8 +167,7 @@ HB_FUNC( SX_GETLOGICAL )
* --------------------------------------------------*/
HB_FUNC( SX_GETSTRING )
{
hb_retc(
( char * )sx_GetString( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
hb_retc( ( char * ) sx_GetString( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
@@ -179,8 +176,7 @@ HB_FUNC( SX_GETSTRING )
* --------------------------------------------------*/
HB_FUNC( SX_GETVARIANT )
{
hb_retc(
( char * )sx_GetVariant( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
hb_retc( ( char * ) sx_GetVariant( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
@@ -189,7 +185,7 @@ HB_FUNC( SX_GETVARIANT )
* --------------------------------------------------*/
HB_FUNC( SX_GO )
{
sx_Go( hb_parni( 1 ) ); /* The record number to go */
sx_Go( hb_parni( 1 ) ); /* The record number to go */
}
@@ -198,7 +194,7 @@ HB_FUNC( SX_GO )
* --------------------------------------------------*/
HB_FUNC( SX_GOBOTTOM )
{
sx_GoBottom( ) ;
sx_GoBottom();
}
@@ -207,7 +203,7 @@ HB_FUNC( SX_GOBOTTOM )
* --------------------------------------------------*/
HB_FUNC( SX_GOTOP )
{
sx_GoTop( ) ;
sx_GoTop();
}
@@ -216,13 +212,13 @@ HB_FUNC( SX_GOTOP )
* --------------------------------------------------*/
HB_FUNC( SX_INDEXTAG )
{
hb_retni(
sx_IndexTag( ( PBYTE ) hb_parc( 1 ), /* Field name */
( PBYTE ) hb_parc( 2 ), /* Tag name */
( PBYTE ) hb_parc( 3 ), /* Index expression as a string */
hb_parni( 4 ), /* Option (0=Standard) (1=Unique) (2=Roll-Your-Own) */
hb_parl( 5 ), /* True for a descend index */
( PBYTE ) hb_parc( 6) ) ); /* Condition */
hb_retni(
sx_IndexTag( ( PBYTE ) hb_parc( 1 ), /* Field name */
( PBYTE ) hb_parc( 2 ), /* Tag name */
( PBYTE ) hb_parc( 3 ), /* Index expression as a string */
hb_parni( 4 ), /* Option (0=Standard) (1=Unique) (2=Roll-Your-Own) */
hb_parl( 5 ), /* True for a descend index */
( PBYTE ) hb_parc( 6) ) ); /* Condition */
}
@@ -231,8 +227,7 @@ HB_FUNC( SX_INDEXTAG )
* --------------------------------------------------*/
HB_FUNC( SX_RECCOUNT )
{
hb_retni(
sx_RecCount( ) );
hb_retni( sx_RecCount() );
}
@@ -241,8 +236,7 @@ HB_FUNC( SX_RECCOUNT )
* --------------------------------------------------*/
HB_FUNC( SX_RECNO )
{
hb_retni(
sx_RecNo( ) );
hb_retni( sx_RecNo() );
}
@@ -251,7 +245,7 @@ HB_FUNC( SX_RECNO )
* --------------------------------------------------*/
HB_FUNC( SX_REINDEX )
{
sx_Reindex( );
sx_Reindex();
}
@@ -260,28 +254,26 @@ HB_FUNC( SX_REINDEX )
* --------------------------------------------------*/
HB_FUNC( SX_REPLACE )
{
switch ( hb_parni( 2 ) )
{
case R_INTEGER :
case R_JULIAN : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parni( 3) ) ; break;
case R_LOGICAL : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parni( 3) ) ; break; /* TODO: somthing is wrong here... */
case R_LONG : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parnl( 3) ) ; break;
case R_DOUBLE :
{
double d = hb_parnd( 3 );
sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) &d );
break;
}
case R_CHAR :
case R_DATESTR :
case R_MEMO :
case R_BITMAP :
case R_BLOBFILE:
case R_BLOBPTR : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parc( 3) ) ; break;
default: sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parc( 3) );
}
switch( hb_parni( 2 ) )
{
case R_INTEGER :
case R_JULIAN : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parni( 3) ); break;
case R_LOGICAL : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parni( 3) ); break; /* TODO: somthing is wrong here... */
case R_LONG : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parnl( 3) ); break;
case R_DOUBLE :
{
double d = hb_parnd( 3 );
sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) &d );
break;
}
case R_CHAR :
case R_DATESTR :
case R_MEMO :
case R_BITMAP :
case R_BLOBFILE:
case R_BLOBPTR : sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parc( 3) ); break;
default: sx_Replace( ( PBYTE ) hb_parc( 1 ), hb_parni( 2 ), ( void * ) hb_parc( 3) );
}
}
@@ -290,7 +282,7 @@ switch ( hb_parni( 2 ) )
* --------------------------------------------------*/
HB_FUNC( SX_RLOCK )
{
sx_Rlock( hb_parni( 1 ) ); /* The physical record number of the record to be locked. */
sx_Rlock( hb_parni( 1 ) ); /* The physical record number of the record to be locked. */
}
@@ -299,8 +291,7 @@ HB_FUNC( SX_RLOCK )
* --------------------------------------------------*/
HB_FUNC( SX_SEEK )
{
hb_retl(
sx_Seek( ( PBYTE ) hb_parc( 1 ) ) ); /* The value to search for as a string */
hb_retl( sx_Seek( ( PBYTE ) hb_parc( 1 ) ) ); /* The value to search for as a string */
}
@@ -310,8 +301,7 @@ HB_FUNC( SX_SEEK )
* --------------------------------------------------*/
HB_FUNC( SX_SELECT )
{
hb_retni(
sx_Seek( ( PBYTE ) hb_parc( 1 ) ) ); /* The work area number returned when the file was opened. */
hb_retni( sx_Seek( ( PBYTE ) hb_parc( 1 ) ) ); /* The work area number returned when the file was opened. */
}
@@ -323,8 +313,8 @@ HB_FUNC( SX_SELECT )
* --------------------------------------------------*/
HB_FUNC( SX_SETCENTURY )
{
sx_SetCentury( hb_parl( 1 ) ); /* If True, the century digits will be returned.
* If False, they will not. */
sx_SetCentury( hb_parl( 1 ) ); /* If True, the century digits will be returned.
* If False, they will not. */
}
@@ -334,8 +324,8 @@ HB_FUNC( SX_SETCENTURY )
* --------------------------------------------------*/
HB_FUNC( SX_SETDATEFORMAT )
{
sx_SetDateFormat( hb_parni( 1 ) ); /* If True, the century digits will be returned.
* If False, they will not. */
sx_SetDateFormat( hb_parni( 1 ) ); /* If True, the century digits will be returned.
* If False, they will not. */
}
@@ -344,8 +334,8 @@ HB_FUNC( SX_SETDATEFORMAT )
* --------------------------------------------------*/
HB_FUNC( SX_SETMEMOBLOCKSIZE )
{
sx_SetMemoBlockSize( hb_parni( 1 ) ); /* The new default block size.
* The size must be a value from 1 through 1024. */
sx_SetMemoBlockSize( hb_parni( 1 ) ); /* The new default block size.
* The size must be a value from 1 through 1024. */
}
/* -----------------20/01/2002 13:33-----------------
@@ -354,8 +344,7 @@ HB_FUNC( SX_SETMEMOBLOCKSIZE )
* --------------------------------------------------*/
HB_FUNC( SX_SETORDER )
{
hb_retni(
sx_SetOrder( hb_parni( 1 ) ) ); /* Selects an existing order as the controlling index order. */
hb_retni( sx_SetOrder( hb_parni( 1 ) ) ); /* Selects an existing order as the controlling index order. */
}
@@ -364,7 +353,7 @@ HB_FUNC( SX_SETORDER )
* --------------------------------------------------*/
HB_FUNC( SX_SETSOFTSEEK )
{
sx_SetSoftSeek( hb_parl( 1 ) ); /* True to set softseek ON */
sx_SetSoftSeek( hb_parl( 1 ) ); /* True to set softseek ON */
}
@@ -373,7 +362,7 @@ HB_FUNC( SX_SETSOFTSEEK )
* --------------------------------------------------*/
HB_FUNC( SX_SKIP )
{
sx_Skip( hb_parni( 1 ) ); /* Number of records to skip */
sx_Skip( hb_parni( 1 ) ); /* Number of records to skip */
}
@@ -383,16 +372,16 @@ HB_FUNC( SX_SKIP )
* --------------------------------------------------*/
HB_FUNC( SX_SYSPROP )
{
int i = hb_parni( 2 );
hb_retni(
sx_SysProp( hb_parni( 1 ), /* One of the predefined constant values. See Apollo.ch */
( void * ) &i ));
int i = hb_parni( 2 );
hb_retni(
sx_SysProp( hb_parni( 1 ), /* One of the predefined constant values. See Apollo.ch */
( void * ) &i ));
}
/*
HB_FUNC( SX_DISABLEAUTOOPEN )
{
int i = 1;
sx_SysProp( 1013, ( void * ) &i );
int i = 1;
sx_SysProp( 1013, ( void * ) &i );
}
*/
@@ -403,7 +392,7 @@ HB_FUNC( SX_DISABLEAUTOOPEN )
* --------------------------------------------------*/
HB_FUNC( SX_USE )
{
hb_retni(
hb_retni(
sx_Use( ( PBYTE ) hb_parc( 1 ), /* Filename */
( PBYTE ) hb_parc( 2 ), /* Alias */
hb_parni( 3 ), /* OpenMode */
@@ -416,8 +405,7 @@ HB_FUNC( SX_USE )
* --------------------------------------------------*/
HB_FUNC( SX_VERSION )
{
hb_retc(
( char * ) sx_Version() );
hb_retc( ( char * ) sx_Version() );
}
@@ -426,7 +414,7 @@ HB_FUNC( SX_VERSION )
* --------------------------------------------------*/
HB_FUNC( SX_ZAP )
{
sx_Zap( );
sx_Zap();
}

View File

@@ -379,56 +379,50 @@ static void hb_curl_buff_dl_free( PHB_CURL hb_curl )
static void PHB_CURL_free( PHB_CURL hb_curl, BOOL bFree )
{
if( hb_curl->curl )
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSFUNCTION, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSDATA, NULL );
/* Some extra safety. Set these to NULL, before freeing their pointers. */
curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPPOST, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPHEADER, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP200ALIASES, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_QUOTE, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_POSTQUOTE, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_PREQUOTE, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_TELNETOPTIONS, NULL );
hb_curl_form_free( &hb_curl->pHTTPPOST_First );
hb_curl_form_free( &hb_curl->pHTTPPOST_Last );
hb_curl_slist_free( &hb_curl->pHTTPHEADER );
hb_curl_slist_free( &hb_curl->pHTTP200ALIASES );
hb_curl_slist_free( &hb_curl->pQUOTE );
hb_curl_slist_free( &hb_curl->pPOSTQUOTE );
hb_curl_slist_free( &hb_curl->pPREQUOTE );
hb_curl_slist_free( &hb_curl->pTELNETOPTIONS );
hb_curl_file_ul_free( hb_curl );
hb_curl_file_dl_free( hb_curl );
hb_curl_buff_ul_free( hb_curl );
hb_curl_buff_dl_free( hb_curl );
if( hb_curl->pProgressBlock )
{
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSFUNCTION, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSDATA, NULL );
/* Some extra safety. Set these to NULL, before freeing their pointers. */
curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPPOST, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPHEADER, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP200ALIASES, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_QUOTE, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_POSTQUOTE, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_PREQUOTE, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_TELNETOPTIONS, NULL );
hb_curl_form_free( &hb_curl->pHTTPPOST_First );
hb_curl_form_free( &hb_curl->pHTTPPOST_Last );
hb_curl_slist_free( &hb_curl->pHTTPHEADER );
hb_curl_slist_free( &hb_curl->pHTTP200ALIASES );
hb_curl_slist_free( &hb_curl->pQUOTE );
hb_curl_slist_free( &hb_curl->pPOSTQUOTE );
hb_curl_slist_free( &hb_curl->pPREQUOTE );
hb_curl_slist_free( &hb_curl->pTELNETOPTIONS );
hb_curl_file_ul_free( hb_curl );
hb_curl_file_dl_free( hb_curl );
hb_curl_buff_ul_free( hb_curl );
hb_curl_buff_dl_free( hb_curl );
if( hb_curl->pProgressBlock )
{
hb_itemRelease( hb_curl->pProgressBlock );
hb_curl->pProgressBlock = NULL;
}
if( bFree )
{
curl_easy_cleanup( hb_curl->curl );
hb_curl->curl = NULL;
}
else
curl_easy_reset( hb_curl->curl );
hb_itemRelease( hb_curl->pProgressBlock );
hb_curl->pProgressBlock = NULL;
}
if( bFree )
{
curl_easy_cleanup( hb_curl->curl );
hb_xfree( hb_curl );
}
else
curl_easy_reset( hb_curl->curl );
}
/* NOTE: Will create a new one. If 'from' is specified, the new one
@@ -1347,7 +1341,7 @@ HB_FUNC( CURL_EASY_DL_BUFF_GET )
#define HB_CURL_INFO_TYPE_SLIST 5
#define HB_CURL_EASY_GETINFO( hb_curl, n, p ) \
( ( hb_curl && hb_curl->curl ) ? curl_easy_getinfo( hb_curl->curl, n, p ) : ( CURLcode ) HB_CURLE_ERROR )
( hb_curl ? curl_easy_getinfo( hb_curl->curl, n, p ) : ( CURLcode ) HB_CURLE_ERROR )
/* NOTE: curl_easy_getinfo( curl, x, @nError ) -> xValue */
HB_FUNC( CURL_EASY_GETINFO )

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ if "%1" == "INSTALL" goto POST_INSTALL
:POST_BUILD
rem Use supplied .lib file.
if not exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib copy "%HB_DIR_FIREBIRD%\%_HB_DLL_NAME%_bor.lib" ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib > nul
if not exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib copy "%HB_DIR_FIREBIRD%\lib\%_HB_DLL_NAME%_bor.lib" ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib > nul
goto POST_EXIT
:POST_CLEAN

View File

@@ -40,7 +40,7 @@ if "%1" == "INSTALL" goto POST_INSTALL
:POST_BUILD
rem Use supplied .lib file.
if not exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib copy "%HB_DIR_FIREBIRD%\%_HB_DLL_NAME%_ms.lib" ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib > nul
if not exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib copy "%HB_DIR_FIREBIRD%\lib\%_HB_DLL_NAME%_ms.lib" ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib > nul
goto POST_EXIT
:POST_CLEAN

View File

@@ -5,73 +5,78 @@
#include "common.ch"
Function Main()
LOCAL cDir, cName
LOCAL cDBName
LOCAL nDialect := 1
nDialect := 1
if File('test.gdb')
FErase('test.gdb')
end
? FBCreateDB('test.gdb','sysdba', 'masterkey', 1024, 'ASCII', nDialect )
/* Connect rdbms */
db := FBConnect("127.0.0.1:d:\firebird\test\test.gdb", "sysdba", "masterkey")
if ISNUMBER(db)
? 'Error'
quit
end
? FBExecute(db, 'sldjfs;ldjs;djf', dialect)
? FBClose(db)
trans := FBStartTransaction(db)
qry := FBQuery(db, 'create table teste (code smallint)', dialect, trans)
FBCommit(trans)
? "Status Execute: ", FBExecute( db, 'insert into customer(customer) values ("test 1")', dialect, trans)
? "Status no Rollback: ", FBRollback(trans)
trans := FBStartTransaction(db)
? "Status Execute: ", FBExecute( db, 'insert into customer(customer) values ("test 2")', dialect, trans )
? "Status commit: ", FBCommit(trans)
? "Status Execute: ", FBExecute( db, 'insert into customer(customer) values ("test 3")', dialect )
// FIX WINDOWS GPF BELOW
qry := FBQuery(db, "SELECT * FROM sales", dialect)
num_cols := qry[4]
columns := qry[6]
For x := 1 to num_cols
? x, "> "
For y := 1 to len(columns[x])
?? columns[x,y], ' '
Next
Next
? '---'
do while (fetch_stat := FBFetch(qry)) == 0
? fetch_stat
for x := 1 to num_cols
?? FBGetData(qry,x), ', '
next
end
? 'Fetch code:', fetch_stat
? "Status Free sql: ", FBFree(qry)
LOCAL trans, qry
hb_FNameSplit( hb_argv( 0 ), @cDir, @cName, NIL )
cDBName := hb_FNameMerge( cDir, cName, ".gdb" )
/* Close connection with rdbms */
? "Status Fechar Database: ", FBClose(db)
if File( cDBName )
FErase( cDBName )
endif
? FBCreateDB(cDBName, 'sysdba', 'masterkey', 1024, 'ASCII', nDialect )
/* Connect rdbms */
db := FBConnect("127.0.0.1:" + cDBName, "sysdba", "masterkey")
if ISNUMBER(db)
? 'Error'
quit
endif
? FBExecute(db, 'sldjfs;ldjs;djf', nDialect)
? FBClose(db)
trans := FBStartTransaction(db)
qry := FBQuery(db, 'create table teste (code smallint)', nDialect, trans)
FBCommit(trans)
? "Status Execute: ", FBExecute( db, 'insert into customer(customer) values ("test 1")', nDialect, trans)
? "Status no Rollback: ", FBRollback(trans)
trans := FBStartTransaction(db)
? "Status Execute: ", FBExecute( db, 'insert into customer(customer) values ("test 2")', nDialect, trans )
? "Status commit: ", FBCommit(trans)
? "Status Execute: ", FBExecute( db, 'insert into customer(customer) values ("test 3")', nDialect )
// FIX WINDOWS GPF BELOW
qry := FBQuery(db, "SELECT * FROM sales", nDialect)
num_cols := qry[4]
columns := qry[6]
For x := 1 to num_cols
? x, "> "
For y := 1 to len(columns[x])
?? columns[x,y], ' '
Next
Next
? '---'
do while (fetch_stat := FBFetch(qry)) == 0
? fetch_stat
for x := 1 to num_cols
?? FBGetData(qry,x), ', '
next
enddo
? 'Fetch code:', fetch_stat
? "Status Free sql: ", FBFree(qry)
/* Close connection with rdbms */
? "Status Fechar Database: ", FBClose(db)
Return Nil
Return Nil

View File

@@ -50,7 +50,7 @@
*
*/
/* please run $(HARBOUR)\tests\testhbf.prg for testing */
/* please run tests\testhbf.prg for testing */
#include "hbapifs.h"

View File

@@ -2,7 +2,6 @@
* $Id$
*/
/*
* Harbour Project source code:
* mSQL DBMS low level (client api) interface code.
@@ -54,193 +53,131 @@
#include "hbapi.h"
#include "hbapiitm.h"
#ifdef HB_OS_WIN_32
#if defined( HB_OS_WIN_32 ) && !defined( _OS_WIN32 )
/* This is needed by msql.h to indicate the platform. */
#define _OS_WIN32
#endif
#include "msql.h"
HB_FUNC(MSQLCONNEC) /* int msqlConnect(char *) */
HB_FUNC( MSQLCONNEC ) /* int msqlConnect(char *) */
{
hb_retni(msqlConnect(hb_parc(1)));
hb_retni( msqlConnect( hb_parc( 1 ) ) );
}
HB_FUNC(MSQLCLOSE) /* void msqlClose(int) */
HB_FUNC( MSQLCLOSE ) /* void msqlClose(int) */
{
msqlClose(hb_parni(1));
msqlClose( hb_parni( 1 ) );
}
HB_FUNC(MSQLSELECT) /* int msqlSelectDB(int, char *) */
HB_FUNC( MSQLSELECT ) /* int msqlSelectDB(int, char *) */
{
hb_retni(msqlSelectDB(hb_parni(1), hb_parc(2)));
hb_retni( msqlSelectDB( hb_parni( 1 ), hb_parc( 2 ) ) );
}
HB_FUNC(MSQLQUERY) /* int msqlQuery(int, char *) */
HB_FUNC( MSQLQUERY ) /* int msqlQuery(int, char *) */
{
hb_retni(msqlQuery(hb_parni(1), hb_parc(2)));
hb_retni( msqlQuery( hb_parni( 1 ), hb_parc( 2 ) ) );
}
HB_FUNC(MSQLSTORER) /* m_result *msqlStoreResult() */
HB_FUNC( MSQLSTORER ) /* m_result *msqlStoreResult() */
{
hb_retnl((long) msqlStoreResult());
hb_retptr( ( void * ) msqlStoreResult() );
}
HB_FUNC(MSQLFREER) /* void msqlFreeResult(m_result *) */
HB_FUNC( MSQLFREER ) /* void msqlFreeResult(m_result *) */
{
msqlFreeResult((m_result *)hb_parnl(1));
msqlFreeResult( ( m_result * ) hb_parptr( 1 ) );
}
/* NOTE: need number of retrieved fields */
HB_FUNC(MSQLFETCHR) /* m_row msqlFetchRow(m_result *, int) */
HB_FUNC( MSQLFETCHR ) /* m_row msqlFetchRow(m_result *, int) */
{
m_result *mresult = (m_result *)hb_parnl(1);
int num_fields = hb_parnl(2);
PHB_ITEM aRow = hb_itemArrayNew(num_fields);
PHB_ITEM temp;
m_row mrow;
m_result * mresult = ( m_result * ) hb_parptr( 1 );
int num_fields = hb_parnl( 2 );
PHB_ITEM aRow = hb_itemArrayNew( num_fields );
m_row mrow = msqlFetchRow( mresult );
int i;
mrow = msqlFetchRow(mresult);
for( i = 0; i < num_fields; i++ )
hb_itemArrayPut( aRow, i + 1, mrow[ i ] );
for (i = 0; i < num_fields; i++) {
/* if field is not empty */
if (mrow[i] != NULL) {
temp = hb_itemPutC(NULL, mrow[i]);
} else {
temp = hb_itemPutC(NULL, "");
}
hb_itemArrayPut(aRow, i + 1, temp);
hb_itemRelease(temp);
}
hb_itemReturnRelease(aRow);
hb_itemReturnRelease( aRow );
}
HB_FUNC( MSQLDATASE ) /* void msqlDataSeek(m_result *, int) */
{
msqlDataSeek( ( m_result * ) hb_parptr( 1 ), hb_parni( 2 ) );
}
HB_FUNC(MSQLDATASE) /* void msqlDataSeek(m_result *, int) */
HB_FUNC( MSQLNUMROW ) /* int msqlNumRows(m_result *) */
{
msqlDataSeek((m_result *)hb_parnl(1), hb_parni(2));
hb_retni( msqlNumRows( ( ( m_result * ) hb_parptr( 1 ) ) ) );
}
HB_FUNC(MSQLNUMROW) /* int msqlNumRows(m_result *) */
HB_FUNC( MSQLFETCHF ) /* m_field *msqlFetchField(m_result *) */
{
hb_retni(msqlNumRows(((m_result *)hb_parnl(1))));
}
m_field * mfield = msqlFetchField( ( m_result * ) hb_parptr( 1 ) );
PHB_ITEM aField = hb_itemArrayNew( 5 ); /* NOTE: m_field structure of mSQL 2.x has 5 members */
HB_FUNC(MSQLFETCHF) /* m_field *msqlFetchField(m_result *) */
{
/* NOTE: m_field structure of mSQL 2.x has 5 members */
PHB_ITEM aField = hb_itemArrayNew(5);
PHB_ITEM temp;
m_field *mfield;
mfield = msqlFetchField((m_result *)hb_parnl(1));
if (!(mfield == NULL)) {
temp = hb_itemPutC(NULL, mfield->name);
hb_itemArrayPut(aField, 1, temp);
hb_itemRelease(temp);
temp = hb_itemPutC(NULL, mfield->table);
hb_itemArrayPut(aField, 2, temp);
hb_itemRelease(temp);
temp = hb_itemPutNL(NULL, mfield->type);
hb_itemArrayPut(aField, 3, temp);
hb_itemRelease(temp);
temp = hb_itemPutNL(NULL, mfield->length);
hb_itemArrayPut(aField, 4, temp);
hb_itemRelease(temp);
temp = hb_itemPutNL(NULL, mfield->flags);
hb_itemArrayPut(aField, 5, temp);
hb_itemRelease(temp);
}
hb_itemReturnRelease(aField);
}
HB_FUNC(MSQLFIELDS) /* void msqlFieldSeek(m_result *, int) */
{
msqlFieldSeek((m_result *)hb_parnl(1), hb_parni(2));
}
HB_FUNC(MSQLNUMFIE) /* int msqlNumFields(m_result *) */
{
hb_retni(msqlNumFields(((m_result *)hb_parnl(1))));
}
HB_FUNC(MSQLLISTFI) /* m_result *msqlListFields(int, char *); */
{
hb_retnl((long) msqlListFields(hb_parni(1), hb_parc(2)));
}
HB_FUNC(MSQLGETERR) /* char *msqlGetErrMsg(char *); */
{
hb_retc(msqlGetErrMsg(NULL));
}
HB_FUNC(MSQLLISTDB) /* m_result * msqlListDBs(int); */
{
int sock = hb_parnl(1);
m_result *mresult;
m_row mrow;
long nr, i;
PHB_ITEM aDBs;
PHB_ITEM temp;
mresult = msqlListDBs(sock);
nr = msqlNumRows(mresult);
aDBs = hb_itemArrayNew(nr);
for (i = 0; i < nr; i++) {
mrow = msqlFetchRow(mresult);
temp = hb_itemPutC(NULL, mrow[0]);
hb_itemArrayPut(aDBs, i + 1, temp);
hb_itemRelease(temp);
if( mfield )
{
hb_arraySetC( aField, 1, mfield->name );
hb_arraySetC( aField, 2, mfield->table );
hb_arraySetNL( aField, 3, mfield->type );
hb_arraySetNL( aField, 4, mfield->length );
hb_arraySetNL( aField, 5, mfield->flags );
}
msqlFreeResult(mresult);
hb_itemReturnRelease(aDBs);
hb_itemReturnRelease( aField );
}
HB_FUNC(MSQLLISTTA) /* m_result * msqlListTables(int); */
HB_FUNC( MSQLFIELDS ) /* void msqlFieldSeek(m_result *, int) */
{
int sock = hb_parnl(1);
m_result *mresult;
m_row mrow;
long nr, i;
PHB_ITEM aTables;
PHB_ITEM temp;
mresult = msqlListTables(sock);
nr = msqlNumRows(mresult);
aTables = hb_itemArrayNew(nr);
for (i = 0; i < nr; i++) {
mrow = msqlFetchRow(mresult);
temp = hb_itemPutC(NULL, mrow[0]);
hb_itemArrayPut(aTables, i + 1, temp);
hb_itemRelease(temp);
}
msqlFreeResult(mresult);
hb_itemReturnRelease(aTables);
msqlFieldSeek( ( m_result * ) hb_parptr( 1 ), hb_parni( 2 ) );
}
HB_FUNC( MSQLNUMFIE ) /* int msqlNumFields(m_result *) */
{
hb_retni( msqlNumFields( ( ( m_result * ) hb_parptr( 1 ) ) ) );
}
HB_FUNC( MSQLLISTFI ) /* m_result *msqlListFields(int, char *); */
{
hb_retptr( ( void * ) msqlListFields( hb_parni( 1 ), hb_parc( 2 ) ) );
}
HB_FUNC( MSQLGETERR ) /* char *msqlGetErrMsg(char *); */
{
hb_retc( msqlGetErrMsg( NULL ) );
}
HB_FUNC( MSQLLISTDB ) /* m_result * msqlListDBs(int); */
{
int sock = hb_parnl( 1 );
m_result * mresult = msqlListDBs( sock );
long nr = msqlNumRows( mresult );
PHB_ITEM aDBs = hb_itemArrayNew( nr );
long i;
for( i = 0; i < nr; i++ )
hb_arraySetC( aDBs, i + 1, msqlFetchRow( mresult )[ 0 ] );
msqlFreeResult( mresult );
hb_itemReturnRelease( aDBs );
}
HB_FUNC( MSQLLISTTA ) /* m_result * msqlListTables(int); */
{
int sock = hb_parnl( 1 );
m_result * mresult = msqlListTables( sock );
long nr = msqlNumRows( mresult );
PHB_ITEM aTables = hb_itemArrayNew( nr );
long i;
for( i = 0; i < nr; i++ )
hb_arraySetC( aTables, i + 1, msqlFetchRow( mresult )[ 0 ] );
msqlFreeResult( mresult );
hb_itemReturnRelease( aTables );
}

View File

@@ -2,7 +2,6 @@
* $Id$
*/
/*
* Harbour Project source code:
* mSQL DBMS defines
@@ -52,8 +51,7 @@
*
*/
// mSQL fields type
/* mSQL fields type */
#define MSQL_INT_TYPE 1
#define MSQL_CHAR_TYPE 2
#define MSQL_REAL_TYPE 3
@@ -62,7 +60,7 @@
#define MSQL_TEXT_TYPE 6
#define MSQL_DATE_TYPE 7
// NOTE: UINT is used to map clipper logical values to mSQL tables, so 0 == .F., 1 == .T.
/* NOTE: UINT is used to map clipper logical values to mSQL tables, so 0 == .F., 1 == .T. */
#define MSQL_UINT_TYPE 8
#define MSQL_MONEY_TYPE 9
#define MSQL_TIME_TYPE 10
@@ -71,14 +69,10 @@
#define MSQL_SYSVAR_TYPE 254
#define MSQL_ANY_TYPE 255
// mSQL field structure item number (C level structure is translated
// to a clipper array)
/* mSQL field structure item number
(C level structure is translated to a clipper array) */
#define MSQL_FS_NAME 1
#define MSQL_FS_TABLE 2
#define MSQL_FS_TYPE 3
#define MSQL_FS_LENGTH 4
#define MSQL_FS_FLAGS 5

View File

@@ -54,7 +54,7 @@
#endif
#if (defined(__STDC__) || defined(__cplusplus) || defined(__BORLANDC__) || defined(_MSC_VER))
#if defined(__STDC__) || defined(__cplusplus) || defined(__BORLANDC__) || defined(_MSC_VER)
# define __ANSI_PROTO(x) x
#else
# define __ANSI_PROTO(x) ()

View File

@@ -73,35 +73,32 @@
#include <hb_io.h>
#include <fcntl.h>
/* NOTE: OS/2 EMX port of MySQL needs libmysqlclient.a from 3.21.33b build which has st and mt
versions of client library. I'm using ST version since harbour is single threaded. You need
also .h files from same distribution
*/
versions of client library. I'm using ST version since harbour is single threaded.
You need also .h files from same distribution. */
/* TODO: Use hb_retptrGC() */
HB_FUNC( SQLVERSION ) /* long mysql_get_server_version(MYSQL *) */
HB_FUNC( SQLVERSION ) /* long mysql_get_server_version( MYSQL * ) */
{
hb_retnl( (long) mysql_get_server_version((MYSQL *)hb_parptr(1)) );
hb_retnl( ( long ) mysql_get_server_version( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLCONNECT ) /* MYSQL *mysql_real_connect(MYSQL*, char * host, char * user, char * password, char * db, uint port, char *, uint flags) */
{
MYSQL * mysql;
const char *szHost=hb_parc(1);
const char *szUser=hb_parc(2);
const char *szPass=hb_parc(3);
const char * szHost = hb_parc( 1 );
const char * szUser = hb_parc( 2 );
const char * szPass = hb_parc( 3 );
#if MYSQL_VERSION_ID > 32200
unsigned int port = ISNUM( 4 ) ? ( unsigned int ) hb_parni(4) : MYSQL_PORT;
unsigned int flags = ISNUM( 5 ) ? ( unsigned int ) hb_parni(5) : 0;
MYSQL * mysql;
unsigned int port = ISNUM( 4 ) ? ( unsigned int ) hb_parni( 4 ) : MYSQL_PORT;
unsigned int flags = ISNUM( 5 ) ? ( unsigned int ) hb_parni( 5 ) : 0;
if( ( mysql = mysql_init( ( MYSQL * ) NULL ) ) )
{
/* from 3.22.x of MySQL there is a new parameter in mysql_real_connect() call, that is char * db
which is not used here */
if( ( mysql = mysql_init((MYSQL*) 0) ) != NULL )
{
if( mysql_real_connect( mysql, szHost, szUser, szPass, 0, port, NULL, flags ) )
hb_retptr( ( void * ) mysql );
else
@@ -113,61 +110,53 @@ HB_FUNC( SQLCONNECT ) /* MYSQL *mysql_real_connect(MYSQL*, char * host, char * u
else
hb_retptr( NULL );
#else
mysql = mysql_real_connect( NULL, szHost, szUser, szPass, 0, NULL, 0 );
hb_retptr( ( void * ) mysql);
hb_retptr( ( void * ) mysql_real_connect( NULL, szHost, szUser, szPass, 0, NULL, 0 ) );
#endif
}
HB_FUNC( SQLCLOSE ) /* void mysql_close(MYSQL *mysql) */
{
mysql_close((MYSQL *)hb_parptr(1));
mysql_close( ( MYSQL * ) hb_parptr( 1 ) );
}
HB_FUNC( SQLCOMMIT ) /* bool mysql_commit(MYSQL *mysql) */
{
hb_retnl((long) mysql_commit((MYSQL *)hb_parptr(1)));
hb_retnl( ( long ) mysql_commit( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLROLLBACK ) /* bool mysql_rollback(MYSQL *mysql) */
{
hb_retnl((long) mysql_rollback((MYSQL *)hb_parptr(1)));
hb_retnl( ( long ) mysql_rollback( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLSELECTD ) /* int mysql_select_db(MYSQL *, char *) */
{
hb_retnl((long) mysql_select_db((MYSQL *)hb_parptr(1), (const char *)hb_parc(2) ));
hb_retnl( ( long ) mysql_select_db( ( MYSQL * ) hb_parptr( 1 ), ( const char * ) hb_parc( 2 ) ) );
}
HB_FUNC( SQLQUERY ) /* int mysql_query(MYSQL *, char *) */
{
hb_retnl((long) mysql_query((MYSQL *)hb_parptr(1), hb_parc(2)));
hb_retnl( ( long ) mysql_query( ( MYSQL * ) hb_parptr( 1 ), hb_parc( 2 ) ) );
}
HB_FUNC( SQLSTORER ) /* MYSQL_RES *mysql_store_result(MYSQL *) */
HB_FUNC( SQLSTORER ) /* MYSQL_RES *mysql_store_result( MYSQL * ) */
{
hb_retptr((void *) mysql_store_result((MYSQL *)hb_parptr(1)));
hb_retptr( ( void * ) mysql_store_result( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLUSERES ) /* MYSQL_RES *mysql_use_result(MYSQL *) */
HB_FUNC( SQLUSERES ) /* MYSQL_RES *mysql_use_result( MYSQL * ) */
{
hb_retptr((void *) mysql_use_result((MYSQL *)hb_parptr(1)));
hb_retptr( ( void * ) mysql_use_result( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLFREER ) /* void mysql_free_result(MYSQL_RES *) */
{
mysql_free_result((MYSQL_RES *)hb_parptr(1));
mysql_free_result( ( MYSQL_RES * ) hb_parptr( 1 ) );
}
HB_FUNC( SQLFETCHR ) /* MYSQL_ROW *mysql_fetch_row(MYSQL_RES *) */
{
MYSQL_RES *mresult = (MYSQL_RES *)hb_parptr( 1 );
MYSQL_RES * mresult = ( MYSQL_RES * ) hb_parptr( 1 );
int num_fields = mysql_num_fields( mresult );
PHB_ITEM aRow = hb_itemArrayNew( num_fields );
MYSQL_ROW mrow = mysql_fetch_row( mresult );
@@ -176,36 +165,34 @@ HB_FUNC( SQLFETCHR ) /* MYSQL_ROW *mysql_fetch_row(MYSQL_RES *) */
{
int i;
for( i = 0; i < num_fields; i++ )
hb_arraySetC( aRow, i + 1, mrow[i] );
hb_arraySetC( aRow, i + 1, mrow[ i ] );
}
hb_itemReturnRelease( aRow );
}
HB_FUNC( SQLDATAS ) /* void mysql_data_seek(MYSQL_RES *, unsigned int) */
{
mysql_data_seek((MYSQL_RES *)hb_parptr(1), (unsigned int)hb_parni(2));
mysql_data_seek( ( MYSQL_RES * ) hb_parptr( 1 ), ( unsigned int ) hb_parni( 2 ) );
}
HB_FUNC( SQLNROWS ) /* my_ulongulong mysql_num_rows(MYSQL_RES *) */
{
hb_retnint(mysql_num_rows(((MYSQL_RES *)hb_parptr(1))));
hb_retnint( mysql_num_rows( ( ( MYSQL_RES * ) hb_parptr( 1 ) ) ) );
}
HB_FUNC( SQLFETCHF ) /* MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *) */
{
/* NOTE: field structure of MySQL has 8 members as of MySQL 3.22.x */
PHB_ITEM aField = hb_itemArrayNew( 8 );
MYSQL_FIELD *mfield = mysql_fetch_field( (MYSQL_RES *)hb_parptr(1) );
MYSQL_FIELD * mfield = mysql_fetch_field( ( MYSQL_RES * ) hb_parptr( 1 ) );
if( mfield )
{
hb_arraySetC( aField, 1, mfield->name );
hb_arraySetC( aField, 2, mfield->table );
hb_arraySetC( aField, 3, mfield->def );
hb_arraySetNL( aField, 4, (long)mfield->type );
hb_arraySetC( aField, 1, mfield->name );
hb_arraySetC( aField, 2, mfield->table );
hb_arraySetC( aField, 3, mfield->def );
hb_arraySetNL( aField, 4, ( long ) mfield->type );
hb_arraySetNL( aField, 5, mfield->length );
hb_arraySetNL( aField, 6, mfield->max_length );
hb_arraySetNL( aField, 7, mfield->flags );
@@ -215,49 +202,47 @@ HB_FUNC( SQLFETCHF ) /* MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *) */
hb_itemReturnRelease( aField );
}
HB_FUNC( SQLFSEEK ) /* MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *, MYSQL_FIELD_OFFSET) */
{
mysql_field_seek((MYSQL_RES *)hb_parptr(1), (MYSQL_FIELD_OFFSET)hb_parni(2));
mysql_field_seek( ( MYSQL_RES * ) hb_parptr( 1 ), ( MYSQL_FIELD_OFFSET ) hb_parni( 2 ) );
}
HB_FUNC( SQLNUMFI ) /* unsigned int mysql_num_fields(MYSQL_RES *) */
{
hb_retnl(mysql_num_fields(((MYSQL_RES *)hb_parptr(1))));
hb_retnl( mysql_num_fields( ( ( MYSQL_RES * ) hb_parptr( 1 ) ) ) );
}
#if MYSQL_VERSION_ID > 32200
HB_FUNC( SQLFICOU ) /* unsigned int mysql_field_count(MYSQL *) */
HB_FUNC( SQLFICOU ) /* unsigned int mysql_field_count( MYSQL * ) */
{
hb_retnl(mysql_field_count(((MYSQL *)hb_parptr(1))));
hb_retnl( mysql_field_count( ( ( MYSQL * ) hb_parptr( 1 ) ) ) );
}
#endif
HB_FUNC( SQLLISTF ) /* MYSQL_RES *mysql_list_fields(MYSQL *, char *); */
{
hb_retnl((long) mysql_list_fields((MYSQL *)hb_parptr(1), hb_parc(2), NULL));
hb_retnl( ( long ) mysql_list_fields( ( MYSQL * ) hb_parptr( 1 ), hb_parc( 2 ), NULL ) );
}
HB_FUNC( SQLGETERR ) /* char *mysql_error(MYSQL *); */
HB_FUNC( SQLGETERR ) /* char *mysql_error( MYSQL * ); */
{
hb_retc(mysql_error((MYSQL *)hb_parptr(1)));
hb_retc( mysql_error( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLLISTDB ) /* MYSQL_RES * mysql_list_dbs(MYSQL *, char * wild); */
{
MYSQL * mysql = (MYSQL *)hb_parptr(1);
MYSQL * mysql = ( MYSQL * ) hb_parptr( 1 );
MYSQL_RES * mresult = mysql_list_dbs( mysql, NULL );
long nr = (LONG) mysql_num_rows( mresult );
long nr = ( long ) mysql_num_rows( mresult );
PHB_ITEM aDBs = hb_itemArrayNew( nr );
long i;
for( i = 0; i < nr; i++ )
{
MYSQL_ROW mrow = mysql_fetch_row( mresult );
hb_arraySetC( aDBs, i + 1, mrow[0] );
hb_arraySetC( aDBs, i + 1, mrow[ 0 ] );
}
mysql_free_result( mresult );
@@ -265,20 +250,19 @@ HB_FUNC( SQLLISTDB ) /* MYSQL_RES * mysql_list_dbs(MYSQL *, char * wild); */
hb_itemReturnRelease( aDBs );
}
HB_FUNC( SQLLISTTBL ) /* MYSQL_RES * mysql_list_tables(MYSQL *, char * wild); */
{
MYSQL * mysql = (MYSQL *)hb_parptr(1);
char * cWild = hb_parc(2);
MYSQL * mysql = ( MYSQL * ) hb_parptr( 1 );
char * cWild = hb_parc( 2 );
MYSQL_RES * mresult = mysql_list_tables( mysql, cWild );
long nr = (LONG) mysql_num_rows(mresult);
long nr = ( long ) mysql_num_rows( mresult );
PHB_ITEM aTables = hb_itemArrayNew( nr );
long i;
for( i = 0; i < nr; i++ )
{
MYSQL_ROW mrow = mysql_fetch_row( mresult );
hb_arraySetC( aTables, i + 1, mrow[0] );
hb_arraySetC( aTables, i + 1, mrow[ 0 ] );
}
mysql_free_result( mresult );
@@ -288,31 +272,31 @@ HB_FUNC( SQLLISTTBL ) /* MYSQL_RES * mysql_list_tables(MYSQL *, char * wild); */
/* returns bitwise and of first parameter with second */
HB_FUNC( SQLAND )
{
hb_retnl(hb_parnl(1) & hb_parnl(2));
hb_retnl( hb_parnl( 1 ) & hb_parnl( 2 ) );
}
HB_FUNC( SQLAFFROWS )
{
hb_retnl( (LONG) mysql_affected_rows( (MYSQL *)hb_parptr(1) ) );
hb_retnl( ( long ) mysql_affected_rows( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLHOSTINFO )
{
hb_retc( mysql_get_host_info( (MYSQL *)hb_parptr(1) ) );
hb_retc( mysql_get_host_info( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( SQLSRVINFO )
{
hb_retc( mysql_get_server_info( (MYSQL *)hb_parptr(1) ) );
hb_retc( mysql_get_server_info( ( MYSQL * ) hb_parptr( 1 ) ) );
}
HB_FUNC( DATATOSQL )
{
const char *from=hb_parc(1);
int iSize = hb_parclen(1);
char *buffer = (char*)hb_xgrab( (iSize*2)+1 );
const char * from = hb_parc( 1 );
int iSize = hb_parclen( 1 );
char * buffer = ( char * ) hb_xgrab( iSize * 2 + 1 );
iSize = mysql_escape_string( buffer, from, iSize );
hb_retclen_buffer( (char*)buffer, iSize );
hb_retclen_buffer( ( char * ) buffer, iSize );
}
static char * filetoBuff( char * fname, int * size )
@@ -322,15 +306,15 @@ static char * filetoBuff( char * fname, int * size )
if( handle != FS_ERROR )
{
* size = ( int ) hb_fsSeek( handle, 0, FS_END );
* size -= ( int ) hb_fsSeek( handle, 0, FS_SET );
*size = ( int ) hb_fsSeek( handle, 0, FS_END );
*size -= ( int ) hb_fsSeek( handle, 0, FS_SET );
buffer = ( char * ) hb_xgrab( * size + 1 );
* size = hb_fsReadLarge( handle, ( BYTE * ) buffer, * size );
buffer[ * size ] = '\0';
*size = hb_fsReadLarge( handle, ( BYTE * ) buffer, *size );
buffer[ *size ] = '\0';
hb_fsClose( handle );
}
else
* size = NULL;
*size = NULL;
return buffer;
}
@@ -338,7 +322,7 @@ static char * filetoBuff( char * fname, int * size )
HB_FUNC( FILETOSQLBINARY )
{
int iSize;
char *from = filetoBuff( hb_parc(1), &iSize );
char * from = filetoBuff( hb_parc( 1 ), &iSize );
if( from )
{

View File

@@ -2,7 +2,6 @@
* $Id$
*/
/*
* Harbour Project source code:
* MySQL DBMS defines
@@ -52,12 +51,8 @@
*
*/
// MySQL field types
// NOTE: TINY is used to map clipper logical values to MySQL tables, so 0 == .F., 1 == .T.
#define MYSQL_TINY_TYPE 1
/* MySQL field types */
#define MYSQL_TINY_TYPE 1 /* NOTE: TINY is used to map clipper logical values to MySQL tables, so 0 == .F., 1 == .T. */
#define MYSQL_SHORT_TYPE 2
#define MYSQL_LONG_TYPE 3
#define MYSQL_FLOAT_TYPE 4
@@ -81,11 +76,8 @@
#define MYSQL_VAR_STRING_TYPE 253
#define MYSQL_STRING_TYPE 254
// MySQL field structure item number (C level structure is translated
// to a clipper array)
/* MySQL field structure item number
(C level structure is translated to a clipper array) */
#define MYSQL_FS_NAME 1 /* Name of column */
#define MYSQL_FS_TABLE 2 /* Table of column if column was a field */
#define MYSQL_FS_DEF 3 /* Default value (set by mysql_list_fields) */
@@ -95,9 +87,7 @@
#define MYSQL_FS_FLAGS 7 /* Div flags */
#define MYSQL_FS_DECIMALS 8 /* Number of decimals in field */
// MySQL field flags
/* MySQL field flags */
#define NOT_NULL_FLAG 1 /* Field can't be NULL */
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */
#define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */
@@ -113,7 +103,5 @@
#define PART_KEY_FLAG 16384 /* Intern; Part of some key */
#define GROUP_FLAG 32768 /* Intern group field */
// Extension to DBS_xxx defines to encompass NOT NULL fields, needed by indexes
#define DBS_NOTNULL 5 /* True if field has to be NOT NULL */
/* Extension to DBS_xxx defines to encompass NOT NULL fields, needed by indexes */
#define DBS_NOTNULL 5 /* True if field has to be NOT NULL */

View File

@@ -116,13 +116,7 @@ return Self
METHOD FieldGet(cnField) CLASS TMySQLRow
local nNum
if ValType(cnField) == "C"
nNum := ::FieldPos(cnField)
else
nNum := cnField
endif
local nNum := iif( ISCHARACTER( cnField ), ::FieldPos(cnField), cnField )
if nNum > 0 .AND. nNum <= Len(::aRow)
@@ -140,17 +134,10 @@ return nil
METHOD FieldPut(cnField, Value) CLASS TMySQLRow
local nNum
if ValType(cnField) == "C"
nNum := ::FieldPos(cnField)
else
nNum := cnField
endif
local nNum := iif( ISCHARACTER( cnField ), ::FieldPos(cnField), cnField )
if nNum > 0 .AND. nNum <= Len(::aRow)
//DAVID: if Valtype(Value) == Valtype(::aRow[nNum]) .OR. Empty(::aRow[nNum])
if Valtype(Value) == Valtype(::aRow[nNum]) .OR. ::aRow[nNum]==NIL
// if it is a char field remove trailing spaces
@@ -176,45 +163,20 @@ return nil
// Given a field name returns it's position
METHOD FieldPos(cFieldName) CLASS TMySQLRow
local cUpperName, nPos := 0
local cUpperName := Upper(cFieldName)
cUpperName := Upper(cFieldName)
//DAVID: nPos := AScan(::aFieldStruct, {|aItem| iif(Upper(aItem[MYSQL_FS_NAME]) == cUpperName, .T., .F.)})
nPos := AScan(::aFieldStruct, {|aItem| (Upper(aItem[MYSQL_FS_NAME]) == cUpperName)})
/*while ++nPos <= Len(::aFieldStruct)
if Upper(::aFieldStruct[nPos][MYSQL_FS_NAME]) == cUpperName
exit
endif
enddo
// I haven't found field name
if nPos > Len(::aFieldStruct)
nPos := 0
endif*/
return nPos
return AScan(::aFieldStruct, {|aItem| (Upper(aItem[MYSQL_FS_NAME]) == cUpperName)})
// Returns name of field N
METHOD FieldName(nNum) CLASS TMySQLRow
if nNum >=1 .AND. nNum <= Len(::aFieldStruct)
return ::aFieldStruct[nNum][MYSQL_FS_NAME]
endif
return ""
return iif( nNum >=1 .AND. nNum <= Len(::aFieldStruct), ::aFieldStruct[nNum][MYSQL_FS_NAME], "" )
METHOD FieldLen(nNum) CLASS TMySQLRow
if nNum >=1 .AND. nNum <= Len(::aFieldStruct)
return ::aFieldStruct[nNum][MYSQL_FS_LENGTH]
endif
//DAVID: return ""
return 0
return iif( nNum >=1 .AND. nNum <= Len(::aFieldStruct), ::aFieldStruct[nNum][MYSQL_FS_LENGTH], 0 )
METHOD FieldDec(nNum) CLASS TMySQLRow
@@ -227,7 +189,6 @@ METHOD FieldDec(nNum) CLASS TMySQLRow
endif
endif
//DAVID: return ""
return 0

View File

@@ -53,79 +53,74 @@
#define TP_MAXPORTS 8
#define TPFP_NAME 1 // Structure of ports array
#define TPFP_NAME 1 // Structure of ports array
#define TPFP_HANDLE 2
#define TPFP_BAUD 3
#define TPFP_DBITS 4
#define TPFP_PARITY 5
#define TPFP_SBITS 6
#define TPFP_OC 7 // Open/Close Flag
#define TPFP_OC 7 // Open/Close Flag
#define TPFP_INBUF 8
#define TPFP_INBUF_SIZE 9 // Size of input buffer
#define TPFP_INBUF_SIZE 9 // Size of input buffer
// Error code definitions
#define TE_PARAM -1 // Bad parameter
#define TE_NOPORT -2 // No such port
#define TE_CLOSED -3 // Port not open
#define TE_CONFL -4 // IRQ conflict
#define TE_TMOUT -5 // Timeout
#define TE_NDCD -6 // Lost DCD
#define TE_ESCAPE -7 // User escape
#define TE_LENGTH -8 // Length limit
#define TE_CANCEL -9 // Input canceled
#define TE_NOHDL -10 // Out of handles
#define TE_PARAM -1 // Bad parameter
#define TE_NOPORT -2 // No such port
#define TE_CLOSED -3 // Port not open
#define TE_CONFL -4 // IRQ conflict
#define TE_TMOUT -5 // Timeout
#define TE_NDCD -6 // Lost DCD
#define TE_ESCAPE -7 // User escape
#define TE_LENGTH -8 // Length limit
#define TE_CANCEL -9 // Input canceled
#define TE_NOHDL -10 // Out of handles
#define TE_UCANCEL -50 // Canceled by user
#define TE_RCANCEL -51 // Canceled by remote
#define TE_STARTTM -52 // Timeout waiting to start
#define TE_BLOCKTM -53 // Timeout waiting for block
#define TE_ACKTM -54 // Timeout waiting for acknowledge
#define TE_SENDTM -55 // Timeout waiting to send
#define TE_CLEARTM -56 // Timeout waiting for sender to stop
#define TE_NAK -57 // Negative acknowledge
#define TE_BADACK -58 // Bad acknowledge character
#define TE_BADBLK -59 // Bad block format
#define TE_LONGBLK -60 // Long block received
#define TE_ERRMAX -61 // Too many errors
#define TE_DUPBLK -62 // Duplicate block
#define TE_PROTO -63 // Protocol failure
#define TE_CKSUM -64 // Checksum error
#define TE_HDRTM -65 // Timeout waiting for Zmodem header
#define TE_UCANCEL -50 // Canceled by user
#define TE_RCANCEL -51 // Canceled by remote
#define TE_STARTTM -52 // Timeout waiting to start
#define TE_BLOCKTM -53 // Timeout waiting for block
#define TE_ACKTM -54 // Timeout waiting for acknowledge
#define TE_SENDTM -55 // Timeout waiting to send
#define TE_CLEARTM -56 // Timeout waiting for sender to stop
#define TE_NAK -57 // Negative acknowledge
#define TE_BADACK -58 // Bad acknowledge character
#define TE_BADBLK -59 // Bad block format
#define TE_LONGBLK -60 // Long block received
#define TE_ERRMAX -61 // Too many errors
#define TE_DUPBLK -62 // Duplicate block
#define TE_PROTO -63 // Protocol failure
#define TE_CKSUM -64 // Checksum error
#define TE_HDRTM -65 // Timeout waiting for Zmodem header
#define TE_DISKFULL -100 // Disk full
#define TE_NOFILE -102 // File not found
#define TE_NOPATH -103 // Path not found
#define TE_MFILE -104 // Too many open files
#define TE_ACCESS -105 // Access denied
#define TE_DISKFULL -100 // Disk full
#define TE_NOFILE -102 // File not found
#define TE_NOPATH -103 // Path not found
#define TE_MFILE -104 // Too many open files
#define TE_ACCESS -105 // Access denied
// File transfer status
#define TXS_START 1 // Start of transfer
#define TXS_SFILE 2 // Start of file
#define TXS_NEWNAME 3 // File renamed
#define TXS_SDATA 4 // Start of file data
#define TXS_BLOCK 5 // End of block
#define TXS_ERROR 6 // Error
#define TXS_ABFILE 7 // Aborting file
#define TXS_ABORT 8 // Aborting transfer
#define TXS_WEND 9 // Waiting for end of file
#define TXS_EFILE 10 // End of file
#define TXS_END 11 // End of transfer
#define TP_32MAGIC 558161692
#define TXS_START 1 // Start of transfer
#define TXS_SFILE 2 // Start of file
#define TXS_NEWNAME 3 // File renamed
#define TXS_SDATA 4 // Start of file data
#define TXS_BLOCK 5 // End of block
#define TXS_ERROR 6 // Error
#define TXS_ABFILE 7 // Aborting file
#define TXS_ABORT 8 // Aborting transfer
#define TXS_WEND 9 // Waiting for end of file
#define TXS_EFILE 10 // End of file
#define TXS_END 11 // End of transfer
#define TP_32MAGIC 558161692
// Handshaking flags for tp_hshk()
#define THS_RDSR 1 // Require DSR
#define THS_RCTS 2 // Require CTS
#define THS_RXOFF 4 // Respect XON/XOFF
#define THS_RDCD 8 // Require DCD
#define THS_ADTR 16 // Assert DTR
#define THS_CDTR 32 // Flow control with DTR
#define THS_ARTS 64 // Assert RTS
#define THS_CRTS 128 // Flow control with RTS
#define THS_SXOFF 256 // Send XON/XOFF
#define THS_RDSR 1 // Require DSR
#define THS_RCTS 2 // Require CTS
#define THS_RXOFF 4 // Respect XON/XOFF
#define THS_RDCD 8 // Require DCD
#define THS_ADTR 16 // Assert DTR
#define THS_CDTR 32 // Flow control with DTR
#define THS_ARTS 64 // Assert RTS
#define THS_CRTS 128 // Flow control with RTS
#define THS_SXOFF 256 // Send XON/XOFF

View File

@@ -95,26 +95,22 @@ static unsigned short crctab[ 256 ] = {
/* updcrc() macro by Pete Disdale */
#define updcrc(cp, crc) ( ( crc << 8 ) ^ ( crctab[ ( ( crc >> 8 ) ^ cp ) & 0xFF ] ) )
HB_FUNC( P_CRC16 ) {
#define updcrc( cp, crc ) ( ( crc << 8 ) ^ ( crctab[ ( ( crc >> 8 ) ^ cp ) & 0xFF ] ) )
HB_FUNC( P_CRC16 )
{
char *ptr = hb_parc( 1 );
int count = hb_parclen( 1 );
register unsigned short crc = 0;
while ( count-- > 0 ) {
while ( count-- > 0 )
crc = updcrc( *ptr++, crc );
}
/* swap Hi and Lo byte */
hb_retnl( ( crc >> 8 ) | ( ( crc << 8 ) & 0xFF00 ) );
}
/* Taken from: contrib/unicode/hbcrc32.c
* Harbour Unicode Support
@@ -164,20 +160,17 @@ static ULONG crc32tbl[ 256 ] = {
0xB3667A2El,0xC4614AB8l,0x5D681B02l,0x2A6F2B94l,0xB40BBE37l,0xC30C8EA1l,0x5A05DF1Bl,0x2D02EF8Dl };
#define updcrc32( cp, crc ) ( crc32tbl[ ( crc ^ cp ) & 0xff ] ^ ( crc >> 8 ) )
#define updcrc32(cp, crc) ( crc32tbl[ ( crc ^ cp ) & 0xff ] ^ ( crc >> 8 ) )
HB_FUNC( P_CRC32 ) {
char *ptr = hb_parc( 1 );
HB_FUNC( P_CRC32 )
{
char * ptr = hb_parc( 1 );
int count = hb_parclen( 1 );
register ULONG crc = CRC32INIT;
while ( count-- > 0 ) {
while( count-- > 0 )
crc = updcrc32( *ptr++, crc );
}
hb_retnl( crc ^ CRC32INIT );
}

View File

@@ -68,21 +68,16 @@
#include <termios.h> /* POSIX terminal control definitions */
#include <sys/ioctl.h>
HB_FUNC( P_OPEN ) {
HB_FUNC( P_OPEN )
{
int fd = open( hb_parcx( 1 ), O_RDWR | O_NOCTTY | O_NDELAY ); /* File descriptor for the port */
int fd; /* File descriptor for the port */
fd = open( hb_parcx( 1 ), O_RDWR | O_NOCTTY | O_NDELAY );
if (fd != -1) {
if( fd != -1 )
fcntl( fd, F_SETFL, 0 );
}
hb_retnl( fd );
}
/*
p_InitPortSpeed( aPorts[ nPort, TPFP_HANDLE ] ,;
aPorts[ nPort, TPFP_BAUD ] ,;
@@ -90,90 +85,37 @@ p_InitPortSpeed( aPorts[ nPort, TPFP_HANDLE ] ,;
aPorts[ nPort, TPFP_PARITY ] ,;
aPorts[ nPort, TPFP_SBITS ] )
*/
HB_FUNC( P_INITPORTSPEED ) {
HB_FUNC( P_INITPORTSPEED )
{
struct termios options;
int port = hb_parnl( 1 );
int baud = B300;
char *ptr = hb_parcx( 4 );
char * ptr = hb_parcx( 4 );
int rc;
tcgetattr( port, &options );
/* let's set baud rate */
switch ( hb_parnl( 2 ) ) {
case 0:
baud = B0; /* Drop line */
break;
case 50:
baud = B50;
break;
case 75:
baud = B75;
break;
case 110:
baud = B110;
break;
case 150:
baud = B150;
break;
case 200:
baud = B200;
break;
case 300:
baud = B300;
break;
case 600:
baud = B600;
break;
case 1200:
baud = B1200;
break;
case 1800:
baud = B1800;
break;
case 2400:
baud = B2400;
break;
case 4800:
baud = B4800;
break;
case 9600:
baud = B9600;
break;
case 19200:
baud = B19200;
break;
case 38400:
baud = B38400;
break;
case 57600:
baud = B57600;
break;
case 115200:
baud = B115200;
break;
case 230400:
baud = B230400;
break;
switch( hb_parnl( 2 ) )
{
case 0: baud = B0; break; /* Drop line */
case 50: baud = B50; break;
case 75: baud = B75; break;
case 110: baud = B110; break;
case 150: baud = B150; break;
case 200: baud = B200; break;
case 300: baud = B300; break;
case 600: baud = B600; break;
case 1200: baud = B1200; break;
case 1800: baud = B1800; break;
case 2400: baud = B2400; break;
case 4800: baud = B4800; break;
case 9600: baud = B9600; break;
case 19200: baud = B19200; break;
case 38400: baud = B38400; break;
case 57600: baud = B57600; break;
case 115200: baud = B115200; break;
case 230400: baud = B230400; break;
}
cfsetispeed( &options, baud );
@@ -189,23 +131,18 @@ HB_FUNC( P_INITPORTSPEED ) {
options.c_cflag &= ~CSIZE;
/* Data bits */
if ( hb_parni( 3 ) == 8 ) {
if( hb_parni( 3 ) == 8 )
options.c_cflag |= CS8;
} else {
else
options.c_cflag |= CS7;
}
/* Stop bits */
if ( hb_parni( 5 ) == 1 ) {
if( hb_parni( 5 ) == 1 )
options.c_cflag &= ~CSTOPB;
}
/* Parity, only No, Even, Odd supported */
switch ( *ptr ) {
switch ( *ptr )
{
case 'N':
case 'n':
options.c_cflag &= ~PARENB;
@@ -230,7 +167,6 @@ HB_FUNC( P_INITPORTSPEED ) {
break;
}
/* Every read() call returns as soon as a char is available OR after 3 tenths of a second */
options.c_cc[ VMIN ] = 0;
options.c_cc[ VTIME ] = 3;
@@ -241,62 +177,42 @@ HB_FUNC( P_INITPORTSPEED ) {
hb_retnl( rc );
}
HB_FUNC( P_READPORT ) {
char Buffer[512];
HB_FUNC( P_READPORT )
{
char Buffer[ 512 ];
int nRead = read( hb_parnl( 1 ), Buffer, sizeof( Buffer ) );
if ( nRead < 0 )
hb_retc( NULL );
else
hb_retclen( Buffer, nRead );
hb_retclen( nRead > 0 ? Buffer : NULL, nRead );
}
HB_FUNC( P_WRITEPORT ) {
HB_FUNC( P_WRITEPORT )
{
long n = write( hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ) );
if ( n < 0 )
hb_retnl( -1 );
else
hb_retnl( n );
hb_retnl( n < 0 ? -1 : n );
}
HB_FUNC( P_DRAIN ) {
HB_FUNC( P_DRAIN )
{
hb_retnl( tcdrain( hb_parnl( 1 ) ) );
}
HB_FUNC( P_OUTFREE ) {
HB_FUNC( P_OUTFREE )
{
/*
APIRET rc;
RXQUEUE rxqueue = { 0 };
if ( ( rc = DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETOUTQUECOUNT,
NULL, 0L, NULL, &rxqueue, sizeof(RXQUEUE), NULL ) ) == NO_ERROR ) {
if ( ( rc = DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETOUTQUECOUNT,
NULL, 0L, NULL, &rxqueue, sizeof( RXQUEUE ), NULL ) ) == NO_ERROR )
hb_retnl( rxqueue.cb - rxqueue.cch );
} else {
/* Put GetLastError() here, or better a second byref param? */
hb_retnl( -1 );
}
else
hb_retnl( -1 ); /* Put GetLastError() here, or better a second byref param? */
*/
}
HB_FUNC( P_ISDCD ) {
HB_FUNC( P_ISDCD )
{
int status;
if ( ioctl( hb_parnl( 1 ), TIOCMGET, &status ) == 0 )
@@ -305,10 +221,8 @@ HB_FUNC( P_ISDCD ) {
hb_retl( FALSE );
}
HB_FUNC( P_ISRI ) {
HB_FUNC( P_ISRI )
{
int status;
if ( ioctl( hb_parnl( 1 ), TIOCMGET, &status ) == 0 )
@@ -317,10 +231,8 @@ HB_FUNC( P_ISRI ) {
hb_retl( FALSE );
}
HB_FUNC( P_ISDSR ) {
HB_FUNC( P_ISDSR )
{
int status;
if ( ioctl( hb_parnl( 1 ), TIOCMGET, &status ) == 0 )
@@ -329,10 +241,8 @@ HB_FUNC( P_ISDSR ) {
hb_retl( FALSE );
}
HB_FUNC( P_ISCTS ) {
HB_FUNC( P_ISCTS )
{
int status;
if ( ioctl( hb_parnl( 1 ), TIOCMGET, &status ) == 0 )
@@ -341,7 +251,6 @@ HB_FUNC( P_ISCTS ) {
hb_retl( FALSE );
}
HB_FUNC( P_CTRLCTS ) {
struct termios options;
@@ -353,20 +262,15 @@ HB_FUNC( P_CTRLCTS ) {
tcgetattr( port, &options );
curvalue = ( options.c_cflag & CRTSCTS ) == CRTSCTS;
if ( newvalue == 0 ) {
if( newvalue == 0 )
options.c_cflag &= ~CRTSCTS;
else if( newvalue == 1 )
options.c_cflag |= CRTSCTS;
} else {
if ( newvalue == 1 ) {
options.c_cflag |= CRTSCTS;
}
}
if ( newvalue >= 0 ) {
if( newvalue >= 0 )
rc = tcsetattr( port, TCSAFLUSH, &options );
}
hb_retni( curvalue ? 1 : 0 );
}
#endif /* HB_OS_UNIX */

View File

@@ -65,21 +65,20 @@
#include <stdio.h>
HB_FUNC( P_INITPORTSPEED ) {
HB_FUNC( P_INITPORTSPEED )
{
APIRET rc;
LINECONTROL lctl;
DCBINFO dcb;
USHORT Baud;
char *ptr = hb_parcx(4);
USHORT Baud = ( USHORT ) hb_parnl( 2 );
char * ptr = hb_parcx( 4 );
memset( &dcb, 0, sizeof(dcb) );
memset( &lctl, 0, sizeof(lctl) );
Baud = (USHORT) hb_parnl(2);
memset( &dcb, 0, sizeof( dcb ) );
memset( &lctl, 0, sizeof( lctl ) );
/* OS/2 has Mark and Space parity options */
switch ( *ptr ) {
switch( *ptr )
{
case 'N':
case 'n':
lctl.bParity = 0;
@@ -105,19 +104,12 @@ HB_FUNC( P_INITPORTSPEED ) {
lctl.bStopBits = hb_parnl( 5 ) == 1 ? 0 : hb_parnl( 5 ); /* 1 == 1.5 stop bits only valid with 5 data bits */
lctl.fTransBreak = 0;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETBAUDRATE, &Baud,
sizeof(USHORT), NULL, NULL, 0L, NULL) != NO_ERROR ) {
hb_retnl( -1 );
} else {
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETLINECTRL,
&lctl, sizeof(LINECONTROL), NULL, NULL, 0L, NULL) != NO_ERROR ) {
hb_retnl( -2 );
} else {
if( DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETBAUDRATE, &Baud,
sizeof( USHORT ), NULL, NULL, 0L, NULL ) == NO_ERROR )
{
if( DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETLINECTRL,
&lctl, sizeof( LINECONTROL ), NULL, NULL, 0L, NULL ) == NO_ERROR )
{
/* tp_ help says: on port open
DTR ON (value 1)
CTS OFF
@@ -133,145 +125,96 @@ HB_FUNC( P_INITPORTSPEED ) {
dcb.fbTimeout = MODE_NO_WRITE_TIMEOUT | MODE_NOWAIT_READ_TIMEOUT;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb,
sizeof(DCBINFO), 0L, NULL, 0L, NULL) == NO_ERROR ) {
if( DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb,
sizeof(DCBINFO), 0L, NULL, 0L, NULL ) == NO_ERROR )
hb_retnl( 0 );
} else {
else
hb_retnl( -3 );
}
}
else
hb_retnl( -2 );
}
}
HB_FUNC( P_READPORT ) {
char Buffer[512];
ULONG nRead = 0;
APIRET rc;
rc = DosRead( (HFILE) hb_parnl( 1 ), Buffer, 512, &nRead );
if ( rc == NO_ERROR ) {
hb_retclen( Buffer, nRead );
} else {
hb_retclen( "", 0 );
}
}
HB_FUNC( P_WRITEPORT ) {
ULONG nWritten = 0;
APIRET rc;
rc = DosWrite( (HFILE) hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten );
if ( rc == NO_ERROR ) {
hb_retnl( nWritten );
} else {
/* Put GetLastError() here, or better a second byref param? */
else
hb_retnl( -1 );
}
}
HB_FUNC( P_READPORT )
{
char Buffer[ 512 ];
ULONG nRead = 0;
APIRET rc = DosRead( ( HFILE ) hb_parnl( 1 ), Buffer, sizeof( Buffer ), &nRead );
hb_retclen( rc == NO_ERROR ? Buffer : NULL, nRead );
}
HB_FUNC( P_OUTFREE ) {
HB_FUNC( P_WRITEPORT )
{
ULONG nWritten = 0;
APIRET rc = DosWrite( ( HFILE ) hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten );
hb_retnl( rc == NO_ERROR ? nWritten : -1 ); /* Put GetLastError() on error, or better a second byref param? */
}
HB_FUNC( P_OUTFREE )
{
APIRET rc;
RXQUEUE rxqueue = { 0 };
if ( ( rc = DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETOUTQUECOUNT,
NULL, 0L, NULL, &rxqueue, sizeof(RXQUEUE), NULL ) ) == NO_ERROR ) {
if( ( rc = DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETOUTQUECOUNT,
NULL, 0L, NULL, &rxqueue, sizeof(RXQUEUE), NULL ) ) == NO_ERROR )
hb_retnl( rxqueue.cb - rxqueue.cch );
} else {
/* Put GetLastError() here, or better a second byref param? */
hb_retnl( -1 );
}
else
hb_retnl( -1 ); /* Put GetLastError() here, or better a second byref param? */
}
HB_FUNC( P_ISDCD ) {
HB_FUNC( P_ISDCD )
{
BYTE instat;
/* if DosDevIOCtl() returns an error, return no DCD */
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
if( DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof( instat ), NULL ) == NO_ERROR )
hb_retl( ( instat & DCD_ON ) == DCD_ON );
} else {
else
hb_retl( FALSE );
}
}
HB_FUNC( P_ISRI ) {
HB_FUNC( P_ISRI )
{
BYTE instat;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
if( DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof( instat ), NULL ) == NO_ERROR )
hb_retl( ( instat & RI_ON ) == RI_ON );
} else {
else
hb_retl( FALSE );
}
}
HB_FUNC( P_ISDSR ) {
HB_FUNC( P_ISDSR )
{
BYTE instat;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
if( DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof( instat ), NULL ) == NO_ERROR )
hb_retl( ( instat & DSR_ON ) == DSR_ON );
} else {
else
hb_retl( FALSE );
}
}
HB_FUNC( P_ISCTS ) {
HB_FUNC( P_ISCTS )
{
BYTE instat;
if ( DosDevIOCtl( (HFILE) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof(instat), NULL) == NO_ERROR ) {
if( DosDevIOCtl( ( HFILE ) hb_parnl( 1 ), IOCTL_ASYNC, ASYNC_GETMODEMINPUT,
NULL, 0, NULL, &instat, sizeof( instat ), NULL ) == NO_ERROR )
hb_retl( ( instat & CTS_ON ) == CTS_ON );
} else {
else
hb_retl( FALSE );
}
}
HB_FUNC( P_CTRLCTS ) {
HB_FUNC( P_CTRLCTS )
{
hb_retni( 0 );
}
#endif /* HB_OS_OS2 */

View File

@@ -64,21 +64,17 @@
HB_FUNC( P_INITPORTSPEED ) {
DCB dcb;
char values[20];
char values[ 20 ];
FillMemory(&dcb, sizeof(dcb), 0);
dcb.DCBlength = sizeof(dcb);
FillMemory( &dcb, sizeof( dcb ), 0 );
dcb.DCBlength = sizeof( dcb );
snprintf(values, sizeof( values ), "%u,%1s,%1u,%1u", hb_parnl(2), hb_parcx(4), hb_parnl(3), hb_parnl(5));
snprintf( values, sizeof( values ), "%u,%1s,%1u,%1u", hb_parnl( 2 ), hb_parcx( 4 ), hb_parnl( 3 ), hb_parnl( 5 ) );
if ( ! BuildCommDCB(values, &dcb)) {
hb_retnl(-1);
} else {
if ( ! SetCommState( (HANDLE) hb_parnl(1), &dcb) ) {
hb_retnl(-1);
} else {
if( BuildCommDCB( values, &dcb ) )
{
if( SetCommState( ( HANDLE ) hb_parnl( 1 ), &dcb ) )
{
COMMTIMEOUTS timeouts;
/* read/write operations return immediatly */
@@ -88,49 +84,32 @@ HB_FUNC( P_INITPORTSPEED ) {
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
if ( SetCommTimeouts( (HANDLE) hb_parnl(1), &timeouts ) ) {
hb_retnl(0);
} else {
hb_retnl(-1);
}
hb_retnl( SetCommTimeouts( ( HANDLE ) hb_parnl( 1 ), &timeouts ) ? 0 : -1 );
}
else
hb_retnl( -1 );
}
}
HB_FUNC( P_READPORT ) {
char Buffer[512];
DWORD nRead = 0;
BOOL bRet;
OVERLAPPED Overlapped = {0};
bRet = ReadFile( (HANDLE) hb_parnl( 1 ), Buffer, 512, &nRead, &Overlapped );
if ( bRet ) {
hb_retclen( Buffer, nRead );
} else {
hb_retc( NULL );
}
}
HB_FUNC( P_WRITEPORT ) {
DWORD nWritten = 0;
BOOL bRet;
OVERLAPPED Overlapped = {0};
bRet = WriteFile( (HANDLE) hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten, &Overlapped );
if ( bRet ) {
hb_retnl( nWritten );
} else {
/* Put GetLastError() here, or better a second byref param? */
else
hb_retnl( -1 );
}
}
HB_FUNC( P_READPORT )
{
char Buffer[ 512 ];
DWORD nRead = 0;
OVERLAPPED Overlapped = { 0 };
BOOL bRet = ReadFile( ( HANDLE ) hb_parnl( 1 ), Buffer, sizeof( Buffer ), &nRead, &Overlapped );
hb_retclen( bRet ? Buffer : NULL, nRead );
}
HB_FUNC( P_WRITEPORT )
{
DWORD nWritten = 0;
OVERLAPPED Overlapped = { 0 };
BOOL bRet = WriteFile( ( HANDLE ) hb_parnl( 1 ), hb_parcx( 2 ), hb_parclen( 2 ), &nWritten, &Overlapped );
hb_retnl( bRet ? nWritten : -1 ); /* Put GetLastError() on error, or better a second byref param? */
}
#endif /* HB_OS_WIN_32 */