2009-07-10 15:56 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* examples/terminal/trm_cli.prg
* examples/terminal/trm_cli.hbp
* examples/terminal/terminal.prg
* examples/terminal/trm_srv.prg
* examples/terminal/trm_srv.hbp
* examples/terminal/terminal.hbc
* examples/terminal/trm_app.prg
* examples/terminal/trm_app.hbp
+ Changed to use portable solutions instead of GTWVG/Windows facilites.
This means that these programs should now build and run on
all OSes with MT support and they will work with any full screen
GTs. I didn't test yet on other platforms and stopping the server
is a bit messy yet due to the newly added threads.
* contrib/hbct/ctwin.c
! Silenced MSVC warning.
This commit is contained in:
@@ -17,6 +17,24 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-07-10 15:56 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* examples/terminal/trm_cli.prg
|
||||
* examples/terminal/trm_cli.hbp
|
||||
* examples/terminal/terminal.prg
|
||||
* examples/terminal/trm_srv.prg
|
||||
* examples/terminal/trm_srv.hbp
|
||||
* examples/terminal/terminal.hbc
|
||||
* examples/terminal/trm_app.prg
|
||||
* examples/terminal/trm_app.hbp
|
||||
+ Changed to use portable solutions instead of GTWVG/Windows facilites.
|
||||
This means that these programs should now build and run on
|
||||
all OSes with MT support and they will work with any full screen
|
||||
GTs. I didn't test yet on other platforms and stopping the server
|
||||
is a bit messy yet due to the newly added threads.
|
||||
|
||||
* contrib/hbct/ctwin.c
|
||||
! Silenced MSVC warning.
|
||||
|
||||
2009-07-10 14:42 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* source/rtl/gtwvt/gtwvt.c
|
||||
* Added one parenthesis (sync with GTWVG).
|
||||
|
||||
@@ -1416,8 +1416,8 @@ static void hb_ctw_gt_WriteCon( PHB_GT pGT, const char * pText, ULONG ulLength )
|
||||
{
|
||||
HB_GTSELF_SCROLL( pGT, 0, 0, iMaxRow, iMaxCol,
|
||||
HB_GTSELF_GETCOLOR( pGT ),
|
||||
HB_GTSELF_GETCLEARCHAR( pGT ),
|
||||
iRow - iMaxRow, 0 );
|
||||
( USHORT ) HB_GTSELF_GETCLEARCHAR( pGT ),
|
||||
iRow - iMaxRow, 0 );
|
||||
iRow = iMaxRow;
|
||||
iCol = 0;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# $Id$
|
||||
#
|
||||
|
||||
incpaths=../../contrib/gtwvg
|
||||
{win}libs=gtwvg hbwin
|
||||
{win}libs=hbwin
|
||||
libs=hbct
|
||||
mt=yes
|
||||
gui=yes
|
||||
|
||||
@@ -62,9 +62,10 @@
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
#include "common.ch"
|
||||
#include "wvtwin.ch"
|
||||
#include "terminal.ch"
|
||||
|
||||
//#include "wvtwin.ch"
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
#define TOP t_[ 1 ]
|
||||
@@ -86,16 +87,17 @@
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
STATIC srvrSocket
|
||||
STATIC commSocket
|
||||
STATIC lSendingClient := .f.
|
||||
STATIC s_srvrSocket
|
||||
STATIC s_commSocket
|
||||
STATIC s_lSendingClient := .F.
|
||||
STATIC s_mutexSend := hb_mutexCreate()
|
||||
|
||||
Function RmtSvrInitialize( cServerInfo, nTimeoutClient, nTimeRefresh )
|
||||
Local lExit := .t.
|
||||
Local nTimeOut := 50 // PICK FROM EXTERNASL SOURCE
|
||||
|
||||
srvrSocket := NIL
|
||||
commSocket := NIL
|
||||
s_srvrSocket := NIL
|
||||
s_commSocket := NIL
|
||||
|
||||
DEFAULT nTimeoutClient TO 60 // 60 SECONDS
|
||||
DEFAULT nTimeRefresh TO .5 // 0.5 SECONDS
|
||||
@@ -103,33 +105,37 @@ Function RmtSvrInitialize( cServerInfo, nTimeoutClient, nTimeRefresh )
|
||||
nTimeRefresh := 0.1
|
||||
|
||||
if !empty( cServerInfo )
|
||||
if RmtSvrInitAsServer( cServerInfo, @srvrSocket, nTimeOutClient*1000 )
|
||||
if RmtSvrInitAsServer( cServerInfo, @s_srvrSocket, nTimeOutClient*1000 )
|
||||
|
||||
if RmtSvrAcceptClient( srvrSocket, @commSocket )
|
||||
if RmtSvrAcceptClient( s_srvrSocket, @s_commSocket )
|
||||
// Very Important Factor 20-50 No more
|
||||
//
|
||||
Hb_INetTimeout( commSocket, 10 )
|
||||
Hb_INetTimeout( s_commSocket, 10 )
|
||||
|
||||
lExit := .f.
|
||||
|
||||
RmtSvrRunning( .t. )
|
||||
|
||||
Wvt_SetTimer( TIMER_RECEIVE, 50 ) // 50 ok 1/20 of a second
|
||||
Wvt_SetTimer( TIMER_SEND , nTimeRefresh*1000 )
|
||||
Wvt_SetTimer( TIMER_PING , 3000 )
|
||||
hb_threadStart( @Thread_Receive(), 0.05 )
|
||||
hb_threadStart( @Thread_Send() , nTimeRefresh )
|
||||
hb_threadStart( @Thread_Ping() , 3 )
|
||||
|
||||
// Wvt_SetTimer( TIMER_RECEIVE, 50 ) // 50 ok 1/20 of a second
|
||||
// Wvt_SetTimer( TIMER_SEND , nTimeRefresh*1000 )
|
||||
// Wvt_SetTimer( TIMER_PING , 3000 )
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if lExit
|
||||
if srvrSocket != NIL
|
||||
if Hb_INetErrorCode( srvrSocket ) == 0
|
||||
Hb_InetClose( srvrSocket )
|
||||
if s_srvrSocket != NIL
|
||||
if Hb_INetErrorCode( s_srvrSocket ) == 0
|
||||
Hb_InetClose( s_srvrSocket )
|
||||
endif
|
||||
endif
|
||||
if commSocket != NIL
|
||||
if Hb_INetErrorCode( commSocket ) == 0
|
||||
Hb_InetClose( commSocket )
|
||||
if s_commSocket != NIL
|
||||
if Hb_INetErrorCode( s_commSocket ) == 0
|
||||
Hb_InetClose( s_commSocket )
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -206,8 +212,8 @@ Function RmtSvrSendClient( nMode, xData )
|
||||
n++
|
||||
|
||||
if RmtSvrRunning()
|
||||
if !( lSendingClient )
|
||||
lSendingClient := .t.
|
||||
if !( s_lSendingClient )
|
||||
s_lSendingClient := .t.
|
||||
|
||||
do case
|
||||
case nMode == SND_SCREEN
|
||||
@@ -274,10 +280,10 @@ Function RmtSvrSendClient( nMode, xData )
|
||||
if len( cData ) > 0
|
||||
cData += ENDBLOCK
|
||||
nBytesToSend := len( cData )
|
||||
nBytesSent := hb_INetSendAll( commSocket, cData, nBytesToSend )
|
||||
nBytesSent := hb_INetSendAll( s_commSocket, cData, nBytesToSend )
|
||||
|
||||
if nBytesSent <> nBytesToSend
|
||||
nError := hb_INetErrorCode( commSocket )
|
||||
nError := hb_INetErrorCode( s_commSocket )
|
||||
TrmDebug( n,'E','VouchServer - SvrSendClient : ', nError, nBytesSent, nBytesToSend )
|
||||
|
||||
do case
|
||||
@@ -292,7 +298,7 @@ TrmDebug( n,'Q','VouchServer - SvrSendClient : ', nError, nBytesSent, nBytesToSe
|
||||
endif
|
||||
endif
|
||||
|
||||
lSendingClient := .f.
|
||||
s_lSendingClient := .f.
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -306,20 +312,20 @@ Static Function RmtSvrReceiveClient()
|
||||
static lInProcess := .f.
|
||||
|
||||
if !lInProcess
|
||||
if hb_INetDataReady( commSocket ) > 0
|
||||
if hb_INetDataReady( s_commSocket ) > 0
|
||||
lInProcess := .t.
|
||||
|
||||
cKey := hb_INetRecvLine( commSocket, @nBytes )
|
||||
cKey := hb_INetRecvLine( s_commSocket, @nBytes )
|
||||
|
||||
if nBytes > 0
|
||||
Wvt_Keyboard( val( cKey ) )
|
||||
hb_KeyPut( cKey )
|
||||
|
||||
elseif nBytes == 1
|
||||
|
||||
else
|
||||
nError := hb_INetErrorCode( commSocket )
|
||||
nError := hb_INetErrorCode( s_commSocket )
|
||||
if ascan( { -2, WSAECONNABORTED, WSAECONNRESET }, nError ) > 0
|
||||
TrmDebug( 'VouchAsServer - Quitting : Error =', hb_INetErrorCode( commSocket ), 'nBytes =', nBytes )
|
||||
TrmDebug( 'VouchAsServer - Quitting : Error =', hb_INetErrorCode( s_commSocket ), 'nBytes =', nBytes )
|
||||
DbCloseAll()
|
||||
Quit
|
||||
endif
|
||||
@@ -347,8 +353,8 @@ Function Wvt_Timer( wParam )
|
||||
exit
|
||||
|
||||
case TIMER_PING
|
||||
if !( lSendingClient )
|
||||
hb_INetSendAll( commSocket, ENDBLOCK )
|
||||
if !( s_lSendingClient )
|
||||
hb_INetSendAll( s_commSocket, ENDBLOCK )
|
||||
endif
|
||||
exit
|
||||
|
||||
@@ -356,6 +362,37 @@ Function Wvt_Timer( wParam )
|
||||
|
||||
Return ( 0 )
|
||||
|
||||
STATIC PROCEDURE Thread_Receive( nWait )
|
||||
|
||||
DO WHILE .T.
|
||||
RmtSvrReceiveClient()
|
||||
hb_idleSleep( nWait )
|
||||
ENDDO
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE Thread_Send( nWait )
|
||||
|
||||
DO WHILE .T.
|
||||
hb_mutexLock( s_mutexSend )
|
||||
RmtSvrSendClient( 1, NIL )
|
||||
hb_mutexUnlock( s_mutexSend )
|
||||
hb_idleSleep( nWait )
|
||||
ENDDO
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE Thread_Ping( nWait )
|
||||
|
||||
DO WHILE .T.
|
||||
hb_mutexLock( s_mutexSend )
|
||||
hb_INetSendAll( s_commSocket, ENDBLOCK )
|
||||
hb_mutexUnlock( s_mutexSend )
|
||||
hb_idleSleep( nWait )
|
||||
ENDDO
|
||||
|
||||
RETURN
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
Function RmtSvrSetInfo( cnInfo )
|
||||
@@ -443,7 +480,9 @@ Function TrmDebug( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 )
|
||||
cDebug += ' ' + TrmXtoS( p10 )
|
||||
endif
|
||||
|
||||
#if defined( __PLATFORM__WINDOWS )
|
||||
wapi_OutputDebugString( cDebug )
|
||||
#endif
|
||||
|
||||
Return nil
|
||||
|
||||
@@ -479,3 +518,9 @@ Function TrmDummy()
|
||||
Return nil
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
STATIC PROCEDURE GETSCREENATTRIB( nT, nL, nB, nR, cOdd, cEvn )
|
||||
LOCAL s := SaveScreen( nT, nL, nB, nR )
|
||||
cOdd := CharOdd( s )
|
||||
cEvn := CharEven( s )
|
||||
RETURN
|
||||
|
||||
@@ -4,4 +4,3 @@
|
||||
|
||||
trm_app.prg
|
||||
terminal.prg
|
||||
trm_misc.c
|
||||
|
||||
@@ -128,14 +128,6 @@ FUNCTION Main( cServerInfo )
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
FUNCTION HB_GTSys()
|
||||
|
||||
REQUEST HB_GT_WVG_DEFAULT
|
||||
|
||||
RETURN NIL
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
FUNCTION App_DispClock()
|
||||
|
||||
RETURN nil
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
#
|
||||
|
||||
trm_cli.prg
|
||||
trm_misc.c
|
||||
|
||||
@@ -154,14 +154,6 @@ Function Main( cAddress, cPort, cAppln, cParams, cDirectory )
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
FUNCTION HB_GTSys()
|
||||
|
||||
REQUEST HB_GT_WVG_DEFAULT
|
||||
|
||||
RETURN nil
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
STATIC FUNCTION ResolveParams( cAddress, cPort, cAppln, cParams, cDirectory )
|
||||
Local i, n, cLine, cVal, nLines, cTxt, cPath, cFile
|
||||
Local lFile := .f.
|
||||
@@ -281,14 +273,20 @@ Function TrmServeServer( Socket, cAddress, cServerInfo )
|
||||
Hb_INetSend( Socket, "ARCONNECTED" + CR_LF )
|
||||
Hb_INetClose( Socket )
|
||||
|
||||
Wvt_SetTimer( TIMER_RECEIVE, 10 )
|
||||
Wvt_SetTimer( TIMER_SEND , 1 )
|
||||
Wvt_SetTimer( TIMER_CLOCK , 5000 )
|
||||
Wvt_SetTimer( TIMER_PING , 3000 )
|
||||
// Wvt_SetTimer( TIMER_RECEIVE, 10 )
|
||||
// Wvt_SetTimer( TIMER_SEND , 1 )
|
||||
// Wvt_SetTimer( TIMER_CLOCK , 5000 )
|
||||
// Wvt_SetTimer( TIMER_PING , 3000 )
|
||||
|
||||
hb_threadStart( @Thread_Receive(), 0.01 )
|
||||
hb_threadStart( @Thread_Send() , 1 / 1000 )
|
||||
hb_threadStart( @Thread_Ping() , 3 )
|
||||
hb_threadStart( @Thread_Clock() , 5 )
|
||||
|
||||
nSeconds := Seconds()
|
||||
do while .t.
|
||||
Wvt_ProcessMessages()
|
||||
// Wvt_ProcessMessages()
|
||||
hb_idleSleep()
|
||||
|
||||
nError := Hb_INetErrorCode( commSocket )
|
||||
if ascan( { -2, WSAECONNABORTED, 10054 }, nError ) > 0
|
||||
@@ -296,10 +294,10 @@ Function TrmServeServer( Socket, cAddress, cServerInfo )
|
||||
endif
|
||||
enddo
|
||||
|
||||
Wvt_KillTimer( TIMER_RECEIVE )
|
||||
Wvt_KillTimer( TIMER_SEND )
|
||||
Wvt_KillTimer( TIMER_CLOCK )
|
||||
Wvt_KillTimer( TIMER_PING )
|
||||
// Wvt_KillTimer( TIMER_RECEIVE )
|
||||
// Wvt_KillTimer( TIMER_SEND )
|
||||
// Wvt_KillTimer( TIMER_CLOCK )
|
||||
// Wvt_KillTimer( TIMER_PING )
|
||||
|
||||
Return nil
|
||||
|
||||
@@ -339,7 +337,7 @@ Function TrmReceiveServer()
|
||||
cEvn1 := substr( a_[ 2 ], b_[ 5 ]+1 )
|
||||
cEvn := hb_zuncompress( cEvn1, n )
|
||||
|
||||
PUTSCREENATTRIB( b_[ 1 ], b_[ 2 ], b_[ 3 ], b_[ 4 ], cOdd, cEvn )
|
||||
RestScreen( b_[ 1 ], b_[ 2 ], b_[ 3 ], b_[ 4 ], CharMix( cOdd, cEvn ) )
|
||||
|
||||
case cCommand == "CRS"
|
||||
a_:= hb_aTokens( @cData, ";" )
|
||||
@@ -399,6 +397,42 @@ Function WVT_TIMER( wParam )
|
||||
|
||||
Return 0
|
||||
|
||||
STATIC PROCEDURE Thread_Receive( nWait )
|
||||
|
||||
DO WHILE .T.
|
||||
TrmReceiveServer()
|
||||
hb_idleSleep( nWait )
|
||||
ENDDO
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE Thread_Send( nWait )
|
||||
|
||||
DO WHILE .T.
|
||||
inkey()
|
||||
hb_idleSleep( nWait )
|
||||
ENDDO
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE Thread_Ping( nWait )
|
||||
|
||||
DO WHILE .T.
|
||||
Keyboard( 1021 )
|
||||
hb_idleSleep( nWait )
|
||||
ENDDO
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC PROCEDURE Thread_Clock( nWait )
|
||||
|
||||
DO WHILE .T.
|
||||
DispClock()
|
||||
hb_idleSleep( nWait )
|
||||
ENDDO
|
||||
|
||||
RETURN
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
Function Wvt_Key( nKey )
|
||||
@@ -574,6 +608,7 @@ Static Function uiXtos( xVar )
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
Static Function TrmInitFont()
|
||||
#define __JUSTGT__
|
||||
#ifdef __JUSTGT__
|
||||
/* set OEM font encoding for non unicode modes */
|
||||
hb_gtInfo( HB_GTI_CODEPAGE, 255 )
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
#
|
||||
|
||||
trm_srv.prg
|
||||
trm_misc.c
|
||||
|
||||
@@ -287,7 +287,12 @@ PROCEDURE ServeClient( Socket )
|
||||
|
||||
Function SvrExecuteApp( cAppln, cParams, cDirectory )
|
||||
|
||||
#if defined( __PLATFORM__WINDOWS )
|
||||
RETURN wapi_ShellExecute( NIL, "open", cAppln, cParams, cDirectory )
|
||||
#else
|
||||
HB_SYMBOL_UNUSED( cDirectory )
|
||||
RETURN hb_run( cAppln + " " + cParams )
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
//
|
||||
@@ -416,7 +421,9 @@ Function uiDebug( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 )
|
||||
cDebug += ' ' + uiXtos( p10 )
|
||||
endif
|
||||
|
||||
#if defined( __PLATFORM__WINDOWS )
|
||||
wapi_OutputDebugString( cDebug )
|
||||
#endif
|
||||
|
||||
Return nil
|
||||
|
||||
@@ -445,9 +452,3 @@ Function uiXtos( xVar )
|
||||
endcase
|
||||
|
||||
Return cVar
|
||||
|
||||
//----------------------------------------------------------------------//
|
||||
|
||||
Function HB_GTSYS()
|
||||
REQUEST HB_GT_WVG_DEFAULT
|
||||
Return nil
|
||||
|
||||
Reference in New Issue
Block a user