2009-08-04 19:43 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* source/pp/pplib.c
* source/compiler/hbstripl.c
+ Added HB_EXTERN_BEGIN/END plus explicit declaration of
some static functions to make SunPro C++ mode happy.
There are still *tons* of warnings messages, most of them
complaining about function declaration 'extern "C"' and
const differences, even in Harbour generated C code.
These fixes are experimental and address just the tip
of the iceberg.
Please review me.
* contrib/hbwin/wapi_winbase.c
+ Added WAPI_FORMATMESSAGE(). Unicode support implemented, but
not tested, last parameter not implemented. This should replace
limited FORMATMESSAGE() implementation found in win_prt.c.
* contrib/hbwin/hbwin.ch
* contrib/hbwin/win_tprt.prg
* contrib/hbwin/tests/testprt1.prg
* contrib/hbwin/tests/testprt2.prg
* contrib/hbwin/win_prt.c
* Functions and class renamed to have "win_" prefix.
% Other minor cleanups.
+ win_portopen() returns -1 if the port number was out of
range, so MAXSERIAL constant could be elminiated.
% INVALID_HANDLE_VALUE constant is in reality an explicit
-1 used by low-level lib layer, so I've elminiated it,
and high-level lib layer also uses plain -1 now.
Could be replaces by some macros, but it shouldn't
use a Windows specific name.
- Deleted FORMATMESSAGE().
* Using WAPI_FORMATMESSAGE() instead of local FORMATMESSAGE().
(they are not compatible)
* contrib/hbwin/wce_smsc.c
! Added TOFIX for an lstrcpy() function. This is unsafe
and can easily cause buffer overrun. Until someone
fixes this properly, I've added a workaround where input
string lenght is checked to be smaller than approriate
buffer size. Only compilation was tested using poccarm,
I have no WinCE decide.
Jose, please have a look at it.
* contrib/hbwin/olecore.c
* Minor formatting.
This commit is contained in:
@@ -17,6 +17,53 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-08-04 19:43 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* source/pp/pplib.c
|
||||
* source/compiler/hbstripl.c
|
||||
+ Added HB_EXTERN_BEGIN/END plus explicit declaration of
|
||||
some static functions to make SunPro C++ mode happy.
|
||||
There are still *tons* of warnings messages, most of them
|
||||
complaining about function declaration 'extern "C"' and
|
||||
const differences, even in Harbour generated C code.
|
||||
These fixes are experimental and address just the tip
|
||||
of the iceberg.
|
||||
Please review me.
|
||||
|
||||
* contrib/hbwin/wapi_winbase.c
|
||||
+ Added WAPI_FORMATMESSAGE(). Unicode support implemented, but
|
||||
not tested, last parameter not implemented. This should replace
|
||||
limited FORMATMESSAGE() implementation found in win_prt.c.
|
||||
|
||||
* contrib/hbwin/hbwin.ch
|
||||
* contrib/hbwin/win_tprt.prg
|
||||
* contrib/hbwin/tests/testprt1.prg
|
||||
* contrib/hbwin/tests/testprt2.prg
|
||||
* contrib/hbwin/win_prt.c
|
||||
* Functions and class renamed to have "win_" prefix.
|
||||
% Other minor cleanups.
|
||||
+ win_portopen() returns -1 if the port number was out of
|
||||
range, so MAXSERIAL constant could be elminiated.
|
||||
% INVALID_HANDLE_VALUE constant is in reality an explicit
|
||||
-1 used by low-level lib layer, so I've elminiated it,
|
||||
and high-level lib layer also uses plain -1 now.
|
||||
Could be replaces by some macros, but it shouldn't
|
||||
use a Windows specific name.
|
||||
- Deleted FORMATMESSAGE().
|
||||
* Using WAPI_FORMATMESSAGE() instead of local FORMATMESSAGE().
|
||||
(they are not compatible)
|
||||
|
||||
* contrib/hbwin/wce_smsc.c
|
||||
! Added TOFIX for an lstrcpy() function. This is unsafe
|
||||
and can easily cause buffer overrun. Until someone
|
||||
fixes this properly, I've added a workaround where input
|
||||
string lenght is checked to be smaller than approriate
|
||||
buffer size. Only compilation was tested using poccarm,
|
||||
I have no WinCE decide.
|
||||
Jose, please have a look at it.
|
||||
|
||||
* contrib/hbwin/olecore.c
|
||||
* Minor formatting.
|
||||
|
||||
2009-08-04 14:59 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* source/rtl/gtsln/kbsln.c
|
||||
! Silenced linux/sunpro warning.
|
||||
@@ -41,7 +88,7 @@
|
||||
is generated now.
|
||||
+ Extended number of ports to 32 (from 16). F.e. on my system
|
||||
the Nokia phone gets installed on COM22.
|
||||
; TODO: Rename functions/class to comply with rest of lib.
|
||||
; TODO: Rename functions/class to comply with rest of lib. [DONE]
|
||||
|
||||
2009-08-04 03:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* source/vm/fm.c
|
||||
|
||||
@@ -106,10 +106,6 @@
|
||||
#define RTS_CONTROL_HANDSHAKE 0x02
|
||||
#define RTS_CONTROL_TOGGLE 0x03
|
||||
|
||||
#ifndef INVALID_HANDLE_VALUE
|
||||
#define INVALID_HANDLE_VALUE -1
|
||||
#endif
|
||||
|
||||
/* win_Prn() related values */
|
||||
|
||||
#define FORM_A4 9
|
||||
|
||||
@@ -489,12 +489,12 @@ HB_FUNC( __OLECREATEOBJECT ) /* ( cOleName | cCLSID [, cIID ] ) */
|
||||
if( cID[ 0 ] == '{' )
|
||||
{
|
||||
cCLSID = AnsiToWide( cID );
|
||||
lOleError = CLSIDFromString( (LPOLESTR) cCLSID, &iid );
|
||||
lOleError = CLSIDFromString( ( LPOLESTR ) cCLSID, &iid );
|
||||
hb_xfree( cCLSID );
|
||||
}
|
||||
else if( hb_parclen( 2 ) == ( ULONG ) sizeof( iid ) )
|
||||
{
|
||||
memcpy( (LPVOID) &iid, cID, sizeof( iid ) );
|
||||
memcpy( ( LPVOID ) &iid, cID, sizeof( iid ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,11 +54,11 @@
|
||||
|
||||
procedure main(cPortName)
|
||||
|
||||
local oWinPort := WinPort():Init(cPortName, CBR_9600, NOPARITY, 8, ONESTOPBIT)
|
||||
local oWinPort := Win_Port():Init(cPortName, CBR_9600, NOPARITY, 8, ONESTOPBIT)
|
||||
local cString := "ATE0" + chr(13) + "ATI3" + chr(13)
|
||||
local nResult
|
||||
|
||||
if !oWinPort:Open
|
||||
if !oWinPort:Open()
|
||||
? "Open() failed :", oWinPort:Error()
|
||||
else
|
||||
? "Open() succeeded"
|
||||
|
||||
@@ -69,8 +69,8 @@ procedure main(cPortName)
|
||||
?
|
||||
inkey(0)
|
||||
|
||||
oWinPort := WinPort():Init(cPortName, CBR_9600, ODDPARITY, 7, ONESTOPBIT)
|
||||
if !oWinPort:Open
|
||||
oWinPort := Win_Port():Init(cPortName, CBR_9600, ODDPARITY, 7, ONESTOPBIT)
|
||||
if !oWinPort:Open()
|
||||
? "Open() failed :", oWinPort:Error()
|
||||
else
|
||||
? "Open() succeeded"
|
||||
|
||||
@@ -160,3 +160,30 @@ HB_FUNC( WAPI_OUTPUTDEBUGSTRING )
|
||||
if( lpOutputString )
|
||||
HB_TCHAR_FREE( lpOutputString );
|
||||
}
|
||||
|
||||
HB_FUNC( WAPI_FORMATMESSAGE )
|
||||
{
|
||||
LPTSTR lpSource = HB_ISCHAR( 2 ) ? HB_TCHAR_CONVTO( hb_parc( 2 ) ) : NULL;
|
||||
ULONG nBufferLen = hb_parclen( 5 );
|
||||
LPTSTR lpBuffer = nBufferLen > 0 ? ( LPTSTR ) hb_xgrab( nBufferLen * sizeof( LPTSTR ) ) : NULL;
|
||||
|
||||
hb_retnl( FormatMessage( ( DWORD ) hb_parnldef( 1, FORMAT_MESSAGE_FROM_SYSTEM ) /* dwFlags */,
|
||||
( LPCVOID ) ( HB_ISCHAR( 2 ) ? lpSource : hb_parptr( 2 ) ),
|
||||
HB_ISNUM( 3 ) ? ( DWORD ) hb_parnl( 3 ) : GetLastError() /* dwMessageId */,
|
||||
( DWORD ) hb_parnldef( 4, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ) ) /* dwLanguageId */,
|
||||
( LPTSTR ) lpBuffer,
|
||||
nBufferLen,
|
||||
NULL /* TODO: Add support for this parameter. */ ) );
|
||||
|
||||
if( lpBuffer )
|
||||
{
|
||||
char * buffer = HB_TCHAR_CONVFROM( lpBuffer );
|
||||
hb_storc( buffer, 5 );
|
||||
HB_TCHAR_FREE( buffer );
|
||||
|
||||
hb_xfree( lpBuffer );
|
||||
}
|
||||
|
||||
if( lpSource )
|
||||
HB_TCHAR_FREE( lpSource );
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ HB_FUNC( SMSSENDMESSAGE ) /* cMessage, cNumber */
|
||||
SMS_HANDLE smshHandle = 0;
|
||||
HRESULT hr = SmsOpen( SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL ); /* try to open an SMS Handle */
|
||||
|
||||
if( hr == ERROR_SUCCESS )
|
||||
if( hr == ERROR_SUCCESS && hb_parclen( 2 ) <= SMS_MAX_ADDRESS_LENGTH )
|
||||
{
|
||||
SMS_ADDRESS smsaDestination;
|
||||
TEXT_PROVIDER_SPECIFIC_DATA tpsd;
|
||||
@@ -76,6 +76,9 @@ HB_FUNC( SMSSENDMESSAGE ) /* cMessage, cNumber */
|
||||
/* Create the destination address */
|
||||
memset( &smsaDestination, 0, sizeof( smsaDestination ) );
|
||||
smsaDestination.smsatAddressType = bInternational ? SMSAT_INTERNATIONAL : SMSAT_NATIONAL;
|
||||
/* TOFIX: lstrcpy() unsafe and may cause buffer overrun.
|
||||
Worked around using hb_parclen( 2 ) check against SMS_MAX_ADDRESS_LENGTH.
|
||||
[vszakats]. */
|
||||
lstrcpy( smsaDestination.ptsAddress, sztPhoneNumber );
|
||||
|
||||
/* Set up provider specific data */
|
||||
|
||||
@@ -56,8 +56,6 @@
|
||||
#include "hbapierr.h"
|
||||
#include "hbwin.h"
|
||||
|
||||
//#include <stdlib.h>
|
||||
|
||||
/* Waste some space ! */
|
||||
static struct
|
||||
{
|
||||
@@ -119,7 +117,7 @@ static int s_iInQueue = -1;
|
||||
static int s_iOutQueue = -1;
|
||||
|
||||
|
||||
HB_FUNC( WINPORTOPEN )
|
||||
HB_FUNC( WIN_PORTOPEN )
|
||||
{
|
||||
int Port = hb_parni( 1 );
|
||||
int iPort = hb_parni( 1 );
|
||||
@@ -296,10 +294,10 @@ HB_FUNC( WINPORTOPEN )
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
hb_retnl( -1 );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTCLOSE )
|
||||
HB_FUNC( WIN_PORTCLOSE )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -344,7 +342,7 @@ HB_FUNC( WINPORTCLOSE )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTWRITE )
|
||||
HB_FUNC( WIN_PORTWRITE )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -369,7 +367,7 @@ HB_FUNC( WINPORTWRITE )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTREAD )
|
||||
HB_FUNC( WIN_PORTREAD )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -399,7 +397,7 @@ HB_FUNC( WINPORTREAD )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTSTATUS )
|
||||
HB_FUNC( WIN_PORTSTATUS )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -429,7 +427,7 @@ HB_FUNC( WINPORTSTATUS )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTPURGE )
|
||||
HB_FUNC( WIN_PORTPURGE )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -453,7 +451,7 @@ HB_FUNC( WINPORTPURGE )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTQUEUESTATUS )
|
||||
HB_FUNC( WIN_PORTQUEUESTATUS )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -490,7 +488,7 @@ HB_FUNC( WINPORTQUEUESTATUS )
|
||||
/* If handshaking is enabled, it is an error for the application to adjust the line by
|
||||
using the EscapeCommFunction function */
|
||||
|
||||
HB_FUNC( WINPORTSETRTS )
|
||||
HB_FUNC( WIN_PORTSETRTS )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -516,7 +514,7 @@ HB_FUNC( WINPORTSETRTS )
|
||||
/* If handshaking is enabled, it is an error for the application to adjust the line by
|
||||
using the EscapeCommFunction function */
|
||||
|
||||
HB_FUNC( WINPORTSETDTR )
|
||||
HB_FUNC( WIN_PORTSETDTR )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -539,7 +537,7 @@ HB_FUNC( WINPORTSETDTR )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTRTSFLOW )
|
||||
HB_FUNC( WIN_PORTRTSFLOW )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -594,7 +592,7 @@ HB_FUNC( WINPORTRTSFLOW )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTDTRFLOW )
|
||||
HB_FUNC( WIN_PORTDTRFLOW )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -649,7 +647,7 @@ HB_FUNC( WINPORTDTRFLOW )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTXONXOFFFLOW )
|
||||
HB_FUNC( WIN_PORTXONXOFFFLOW )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
@@ -695,7 +693,7 @@ HB_FUNC( WINPORTXONXOFFFLOW )
|
||||
|
||||
/* You can leave some out. If you pass them by reference you can save the current setting. */
|
||||
|
||||
HB_FUNC( WINPORTTIMEOUTS )
|
||||
HB_FUNC( WIN_PORTTIMEOUTS )
|
||||
{
|
||||
int iTmp;
|
||||
|
||||
@@ -747,38 +745,24 @@ HB_FUNC( WINPORTTIMEOUTS )
|
||||
|
||||
/* You must set both! */
|
||||
|
||||
HB_FUNC( WINPORTBUFFERS )
|
||||
HB_FUNC( WIN_PORTBUFFERS )
|
||||
{
|
||||
s_iInQueue = hb_parni( 1 );
|
||||
s_iOutQueue = hb_parni( 2 );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTERROR )
|
||||
HB_FUNC( WIN_PORTERROR )
|
||||
{
|
||||
hb_retnl( s_dwWinError );
|
||||
s_dwWinError = 0; /* Note - reset */
|
||||
s_dwWinError = 0; /* NOTE: reset */
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTFCN )
|
||||
HB_FUNC( WIN_PORTFCN )
|
||||
{
|
||||
hb_retni( s_iWinFcn );
|
||||
}
|
||||
|
||||
HB_FUNC( FORMATMESSAGE )
|
||||
{
|
||||
char buffer[ 256 ] = "";
|
||||
DWORD dwMessageid = HB_ISNUM( 1 ) ? ( DWORD ) hb_parnl( 1 ) : GetLastError();
|
||||
|
||||
if( FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMessageid, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), /* Default language */
|
||||
( LPTSTR ) buffer, sizeof( buffer ), NULL) == 0 )
|
||||
{
|
||||
hb_snprintf( buffer, sizeof( buffer ), "FormatMessage() failed for message %ld.", dwMessageid );
|
||||
}
|
||||
|
||||
hb_retc( buffer );
|
||||
}
|
||||
|
||||
HB_FUNC( WINPORTDEBUGDCB )
|
||||
HB_FUNC( WIN_PORTDEBUGDCB )
|
||||
{
|
||||
int iPort = hb_parni( 1 );
|
||||
|
||||
|
||||
@@ -55,8 +55,6 @@
|
||||
|
||||
#include "hbwin.ch"
|
||||
|
||||
#define MAXSERIAL 32
|
||||
|
||||
//
|
||||
// The class is a VERY thin layer over the xHarbour functions and the xHarbour functions
|
||||
// are a VERY thin layer over the Win functions, almost no parameter checking! You get what you
|
||||
@@ -71,7 +69,7 @@
|
||||
// Really Windows comms should be done with threads and/or OVERLAPPED I/O - and I haven't.
|
||||
//
|
||||
|
||||
CREATE CLASS WinPort
|
||||
CREATE CLASS Win_Port
|
||||
|
||||
// if this is not true something didn't work!
|
||||
ACCESS Open() INLINE ::lOpen
|
||||
@@ -85,47 +83,47 @@ CREATE CLASS WinPort
|
||||
METHOD Read( cString, nLength )
|
||||
METHOD Recv( nLength )
|
||||
METHOD RecvTo( cDelim, nMaxlen )
|
||||
METHOD Write( cString ) INLINE WinPortWrite( ::nPort, cString )
|
||||
METHOD Status( lCTS, lDSR, lRing, lDCD ) INLINE WinPortStatus( ::nPort, @lCTS, @lDSR, @lRing, @lDCD )
|
||||
METHOD Write( cString ) INLINE Win_PortWrite( ::nPort, cString )
|
||||
METHOD Status( lCTS, lDSR, lRing, lDCD ) INLINE Win_PortStatus( ::nPort, @lCTS, @lDSR, @lRing, @lDCD )
|
||||
METHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue ) INLINE ;
|
||||
WinPortQueueStatus( ::nPort, @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )
|
||||
Win_PortQueueStatus( ::nPort, @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )
|
||||
// boolean return is the status of the call not the line!
|
||||
METHOD SetRTS( lCTS ) INLINE WinPortSetRTS( ::nPort, lCTS )
|
||||
METHOD SetRTS( lCTS ) INLINE Win_PortSetRTS( ::nPort, lCTS )
|
||||
// boolean return is the status of the call not the line!
|
||||
METHOD SetDTR( lDTR ) INLINE WinPortSetDTR( ::nPort, lDTR )
|
||||
METHOD RTSFlow( nRTS ) INLINE WinPortRTSFlow( ::nPort, nRTS )
|
||||
METHOD DTRFlow( nDTR ) INLINE WinPortDTRFlow( ::nPort, nDTR )
|
||||
METHOD XonXoffFlow( lXonXoff ) INLINE WinPortXonXoffFlow( ::nPort, lXonXoff )
|
||||
METHOD Purge( lRXBuffer, lTXBuffer ) INLINE WinPortPurge( ::nPort, lRXBuffer, lTXBuffer )
|
||||
METHOD PurgeRX() INLINE WinPortPurge( ::nPort, .T., .F. )
|
||||
METHOD PurgeTX() INLINE WinPortPurge( ::nPort, .F., .T. )
|
||||
METHOD Close( nDrain ) INLINE WinPortClose( ::nPort, iif( Empty( nDrain ), 0, nDrain ) )
|
||||
METHOD SetDTR( lDTR ) INLINE Win_PortSetDTR( ::nPort, lDTR )
|
||||
METHOD RTSFlow( nRTS ) INLINE Win_PortRTSFlow( ::nPort, nRTS )
|
||||
METHOD DTRFlow( nDTR ) INLINE Win_PortDTRFlow( ::nPort, nDTR )
|
||||
METHOD XonXoffFlow( lXonXoff ) INLINE Win_PortXonXoffFlow( ::nPort, lXonXoff )
|
||||
METHOD Purge( lRXBuffer, lTXBuffer ) INLINE Win_PortPurge( ::nPort, lRXBuffer, lTXBuffer )
|
||||
METHOD PurgeRX() INLINE Win_PortPurge( ::nPort, .T., .F. )
|
||||
METHOD PurgeTX() INLINE Win_PortPurge( ::nPort, .F., .T. )
|
||||
METHOD Close( nDrain ) INLINE Win_PortClose( ::nPort, iif( Empty( nDrain ), 0, nDrain ) )
|
||||
METHOD Error()
|
||||
METHOD DebugDCB( nDebug ) INLINE WinPortDebugDCB(::nPort, nDebug )
|
||||
METHOD DebugDCB( nDebug ) INLINE Win_PortDebugDCB(::nPort, nDebug )
|
||||
METHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant ) INLINE ;
|
||||
WinPortTimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )
|
||||
METHOD Buffers( nInQueue, nOutQueue ) INLINE WinPortBuffers( nInQueue, nOutQueue )
|
||||
Win_PortTimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )
|
||||
METHOD Buffers( nInQueue, nOutQueue ) INLINE Win_PortBuffers( nInQueue, nOutQueue )
|
||||
|
||||
ENDCLASS
|
||||
|
||||
|
||||
METHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits ) CLASS WinPort
|
||||
METHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits ) CLASS Win_Port
|
||||
|
||||
::cPortName := Upper( cPortName )
|
||||
IF Left( ::cPortName, 3 ) == "COM" .AND. ( ::nPort := Val( SubStr( ::cPortName, 4 ) ) ) >= 1 .AND. ::nPort <= MAXSERIAL
|
||||
::nPort--
|
||||
IF WinPortOpen( ::nPort, nBaudRate, nParity, nByteSize, nStopBits ) != INVALID_HANDLE_VALUE
|
||||
IF Left( ::cPortName, 3 ) == "COM"
|
||||
::nPort := Val( SubStr( ::cPortName, 4 ) ) - 1
|
||||
IF Win_PortOpen( ::nPort, nBaudRate, nParity, nByteSize, nStopBits ) != -1
|
||||
::lOpen := .T.
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
RETURN self
|
||||
|
||||
METHOD Read( /* @ */ cString, nLength ) CLASS WinPort
|
||||
METHOD Read( /* @ */ cString, nLength ) CLASS Win_Port
|
||||
LOCAL nResult
|
||||
|
||||
cString := Space( nlength )
|
||||
IF ( nResult := WinPortRead( ::nPort, @cString ) ) != INVALID_HANDLE_VALUE
|
||||
IF ( nResult := Win_PortRead( ::nPort, @cString ) ) != -1
|
||||
cString := Left( cString, nResult )
|
||||
ELSE
|
||||
cString := ""
|
||||
@@ -133,11 +131,11 @@ METHOD Read( /* @ */ cString, nLength ) CLASS WinPort
|
||||
|
||||
RETURN nResult
|
||||
|
||||
METHOD Recv( nLength ) CLASS WinPort
|
||||
METHOD Recv( nLength ) CLASS Win_Port
|
||||
LOCAL nResult
|
||||
LOCAL cString := Space( nlength )
|
||||
|
||||
IF ( nResult := WinPortRead( ::nPort, @cString ) ) != INVALID_HANDLE_VALUE
|
||||
IF ( nResult := Win_PortRead( ::nPort, @cString ) ) != -1
|
||||
cString := Left( cString, nResult )
|
||||
ELSE
|
||||
cString := ""
|
||||
@@ -145,7 +143,7 @@ METHOD Recv( nLength ) CLASS WinPort
|
||||
|
||||
RETURN cString
|
||||
|
||||
METHOD RecvTo( cDelim, nMaxlen ) CLASS WinPort
|
||||
METHOD RecvTo( cDelim, nMaxlen ) CLASS Win_Port
|
||||
LOCAL nResult
|
||||
LOCAL cRecv := ""
|
||||
|
||||
@@ -153,7 +151,7 @@ METHOD RecvTo( cDelim, nMaxlen ) CLASS WinPort
|
||||
|
||||
DO WHILE .T.
|
||||
cString := Space( 1 )
|
||||
IF ( nResult := WinPortRead( ::nPort, @cString ) ) != INVALID_HANDLE_VALUE
|
||||
IF ( nResult := Win_PortRead( ::nPort, @cString ) ) != -1
|
||||
IF nResult == 0
|
||||
EXIT
|
||||
ELSE
|
||||
@@ -173,14 +171,15 @@ METHOD RecvTo( cDelim, nMaxlen ) CLASS WinPort
|
||||
RETURN cRecv
|
||||
|
||||
//
|
||||
// Since the WinPort functions are an amalgamation of Win functions this allows
|
||||
// Since the Win_Port functions are an amalgamation of Win functions this allows
|
||||
// you to see what call did the deed when things go wrong.
|
||||
//
|
||||
|
||||
METHOD Error() CLASS WinPort
|
||||
LOCAL nFcn := WinPortFcn()
|
||||
METHOD Error() CLASS Win_Port
|
||||
LOCAL nFcn := Win_PortFcn()
|
||||
LOCAL cString
|
||||
LOCAL nError
|
||||
LOCAL cMsg
|
||||
LOCAL aWinPortFcns := { ;
|
||||
"CreateFile", ;
|
||||
"GetCommState", ;
|
||||
@@ -204,6 +203,8 @@ METHOD Error() CLASS WinPort
|
||||
ENDIF
|
||||
|
||||
// WinPortError clears the error - don't call it twice
|
||||
cString += "error (" + hb_ntos( nError := WinPortError() ) + ") : " + FormatMessage( nError )
|
||||
cMsg := Space( 256 )
|
||||
wapi_FormatMessage( NIL, NIL, nError := Win_PortError(), NIL, @cMsg )
|
||||
cString += "error (" + hb_ntos( nError ) + ") : " + cMsg
|
||||
|
||||
RETURN cString
|
||||
|
||||
@@ -54,12 +54,16 @@
|
||||
#include "hbcomp.h"
|
||||
#include "hbassert.h"
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
typedef void HB_STRIP_INFO, * PHB_STRIP_INFO;
|
||||
|
||||
#define HB_STRIP_FUNC( func ) HB_PCODE_FUNC( func, PHB_STRIP_INFO )
|
||||
typedef HB_STRIP_FUNC( HB_STRIP_FUNC_ );
|
||||
typedef HB_STRIP_FUNC_ * PHB_STRIP_FUNC;
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
static HB_STRIP_FUNC( hb_p_line )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
@@ -58,6 +58,18 @@
|
||||
#include "hbapierr.h"
|
||||
#include "hbvm.h"
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
|
||||
static HB_GARBAGE_FUNC( hb_pp_Destructor );
|
||||
static void hb_pp_ErrorMessage( void * cargo, const char * szMsgTable[],
|
||||
char cPrefix, int iCode,
|
||||
const char * szParam1, const char * szParam2 );
|
||||
static void hb_pp_Disp( void * cargo, const char * szMessage );
|
||||
static BOOL hb_pp_CompilerSwitch( void * cargo, const char * szSwitch,
|
||||
int iValue );
|
||||
|
||||
HB_EXTERN_END
|
||||
|
||||
static void hb_pp_ErrorMessage( void * cargo, const char * szMsgTable[],
|
||||
char cPrefix, int iCode,
|
||||
const char * szParam1, const char * szParam2 )
|
||||
|
||||
Reference in New Issue
Block a user