diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 69bf6f8a8f..26806d0cc1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,23 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-03-17 12:22 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + + tests/server.prg + * tests/Makefile + + Added inet example from xhb. + + * source/vm/thread.c + ! Fixed nested comment. + + * contrib/xhb/hbcompat.ch + * contrib/xhb/xhb.ch + ! Moved xhb.lib dependent translation to xhb.ch. + + * contrib/examples/hbdoc/examples/core_es/Makefile + * contrib/examples/hbdoc/examples/core_en/genhtm.bat + - contrib/examples/hbdoc/examples/core_en/genhtm.sh + * Cleanup. + 2009-03-17 10:00 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * debian/rules * harbour-win-spec diff --git a/harbour/contrib/examples/hbdoc/examples/core_en/genhtm.bat b/harbour/contrib/examples/hbdoc/examples/core_en/genhtm.bat index f1d6d4419e..a40932f96f 100644 --- a/harbour/contrib/examples/hbdoc/examples/core_en/genhtm.bat +++ b/harbour/contrib/examples/hbdoc/examples/core_en/genhtm.bat @@ -3,6 +3,6 @@ rem rem $Id$ rem -..\..\bin\hbdoc -htm genhtm.lnk genhtm.rsp +..\..\hbdoc -htm genhtm.lnk genhtm.rsp cd htm ren harbour.htm index.htm diff --git a/harbour/contrib/examples/hbdoc/examples/core_en/genhtm.sh b/harbour/contrib/examples/hbdoc/examples/core_en/genhtm.sh deleted file mode 100755 index 2b131ea725..0000000000 --- a/harbour/contrib/examples/hbdoc/examples/core_en/genhtm.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# -# $Id$ -# - -../../bin/hbdoc -htm genhtm.lnk genhtm.rsp -cd htm -# -echo "renaming harbour.htm to index.htm" -mv harbour.htm index.htm -rm -f genwww.lnk -mv genwww.old genwww.lnk diff --git a/harbour/contrib/examples/hbdoc/examples/core_es/Makefile b/harbour/contrib/examples/hbdoc/examples/core_es/Makefile index de38150324..ea7edf02cb 100644 --- a/harbour/contrib/examples/hbdoc/examples/core_es/Makefile +++ b/harbour/contrib/examples/hbdoc/examples/core_es/Makefile @@ -2,7 +2,7 @@ # $Id$ # -ROOT = ../../ +ROOT = ../../../../../ DOC_SUBDIR=/es diff --git a/harbour/contrib/xhb/hbcompat.ch b/harbour/contrib/xhb/hbcompat.ch index 4ec1101b02..51113e6c4e 100644 --- a/harbour/contrib/xhb/hbcompat.ch +++ b/harbour/contrib/xhb/hbcompat.ch @@ -227,9 +227,6 @@ #xtranslate hb_MutexTimeOutLock( , ) => hb_MutexLock( , / 1000 ) #xtranslate Notify( ) => hb_mutexNotify( ) #xtranslate NotifyAll( ) => hb_mutexNotifyAll( ) - #xtranslate Subscribe( ) => xhb_mutexSubscribe( ) - #xtranslate SubscribeNow( ) => xhb_mutexSubscribeNow( ) - #xtranslate StartThread( ) => xhb_StartThread( ) /* not possible to well replicate xHarbour behavior because its buggy these function results are different on different platform, chosen diff --git a/harbour/contrib/xhb/xhb.ch b/harbour/contrib/xhb/xhb.ch index 0ef9e929ab..f0c7df310b 100644 --- a/harbour/contrib/xhb/xhb.ch +++ b/harbour/contrib/xhb/xhb.ch @@ -61,8 +61,12 @@ #pragma -ks+ REQUEST XHB_LIB - #xtranslate __Keyboard([]) => xhb__Keyboard() - #xtranslate __CopyFile([]) => xhb_CopyFile() + #xtranslate __Keyboard([]) => xhb__Keyboard() + #xtranslate __CopyFile([]) => xhb_CopyFile() + + #xtranslate Subscribe( ) => xhb_mutexSubscribe( ) + #xtranslate SubscribeNow( ) => xhb_mutexSubscribeNow( ) + #xtranslate StartThread( ) => xhb_StartThread( ) #endif #endif /* __HARBOUR__ */ diff --git a/harbour/source/vm/thread.c b/harbour/source/vm/thread.c index bc3f579864..1b38fcebc1 100644 --- a/harbour/source/vm/thread.c +++ b/harbour/source/vm/thread.c @@ -58,7 +58,7 @@ hb_threadId( [ ] ) -> hb_threadJoin( [, @ ] ) -> hb_threadDetach( ) -> -* hb_threadQuitRequest( ) -> /* may be ignored !!! */ +* hb_threadQuitRequest( ) -> hb_threadTerminateAll() -> NIL hb_threadWaitForAll() -> NIL hb_threadWait( | , [ ] [, ] ) => | | 0 diff --git a/harbour/tests/Makefile b/harbour/tests/Makefile index ef91e7e8eb..f21b8443a5 100644 --- a/harbour/tests/Makefile +++ b/harbour/tests/Makefile @@ -112,6 +112,7 @@ PRG_SOURCES=\ scroll.prg \ sdf_test.prg \ seconds.prg \ + server.prg \ setkeys.prg \ set_num.prg \ set_test.prg \ diff --git a/harbour/tests/server.prg b/harbour/tests/server.prg new file mode 100644 index 0000000000..8481e6e9f9 --- /dev/null +++ b/harbour/tests/server.prg @@ -0,0 +1,139 @@ +/* + * $Id$ + */ + +*************************************************** +* X harbour Inet demo server program +* +* Giancarlo Niccolai +* +* In this program, the server uses just one thread +* to demonstrate how to use timeout sockets. +* + +Procedure Main( cPort ) + LOCAL Socket, s + LOCAL nResponse, cResponse + LOCAL nTurn := 0, nTurn1 := 0 + LOCAL CRLF := hb_InetCRLF() + LOCAL bCont := .T. + + CLS + + IF Empty( cPort ) + cPort := "2000" + ENDIF + + hb_InetInit() + + @ 1, 15 SAY "X H A R B O U R - Inet Api Server Demo" + @ 2, 5 SAY "Contact this server using telnet or the xHarbour Inet Client demo" + @ 3, 5 SAY "Press a [KEY] to terminate the program" + @ 5, 5 SAY "Server listening on port " + cPort + "..." + Socket := hb_InetServer( Val( cPort ) ) + hb_InetTimeout( Socket, 500 ) + + DO WHILE bCont + + @ 6, 5 SAY Space( 70 ) + @ 7, 5 SAY Space( 70 ) + @ 8, 5 SAY Space( 70 ) + @ 9, 5 SAY Space( 70 ) + @ 6, 5 + + * Accepting a connection + DO WHILE bCont + Progress( @nTurn, 5, 39 ) + s := hb_InetAccept( Socket ) + IF hb_InetErrorCode( Socket ) == 0 + EXIT + ENDIF + IF Inkey() != 0 + bCont := .f. + ENDIF + ENDDO + + IF .not. bCont + EXIT + ENDIF + + hb_InetTimeout( s, 500 ) + + @ 6, 5 SAY "Connection from: " + hb_InetAddress( s ) + ":" + Str( hb_InetPort( s ), 5 ) + @ 7, 5 SAY "Receiving: " + @ 8, 5 + + nResponse := hb_InetSend( s, "Welcome to my server!" + CRLF ) + + DO WHILE bCont + // This timeout ... + hb_InetTimeout( s, 250 ) + // ... will trigger this periodic callback, + hb_InetPeriodCallback( s, { @Progress(), @nTurn, 6, 39 } ) + // that will be called each TIMEOUT Milliseconds. + cResponse := hb_InetRecvLine( s, @nResponse ) + // hb_InetRecvLine won't return until the periodic callback returns .F., + // or the Timelimit has been reached. Timelimit is currently -1, so + // hb_InetRecvLine will wait forever. + + DO CASE + CASE hb_InetErrorCode( s ) == 0 + IF Lower( cResponse ) == "quit" + bCont := .F. + ENDIF + @ 8, 5 SAY space(70) + @ 8, 5 SAY cResponse + cResponse := "Count: " + Str( nResponse ) + " characters" + CRLF + hb_InetSend( s, cResponse ) + + CASE hb_InetErrorCode( s ) == -1 + * idle (timed out) + Progress( @nTurn1, 7, 17 ) + + OTHERWISE + @7, 5 SAY "Received Error " + Str( hb_InetErrorCode( s ) ) + ": " + hb_InetErrorDesc( s ) + @ 8, 5 SAY space(70) + @ 9, 5 SAY space(70) + @ 9, 5 SAY "Press a key to continue" + Inkey( 0 ) + EXIT + + END CASE + + IF Inkey() != 0 + bCont := .f. + ENDIF + ENDDO + ENDDO + + hb_InetCleanup() + +RETURN + + +PROCEDURE Progress( nProgress, nDrow, nDcol ) + + LOCAL nRow := Row(), nCol := Col() + + @ nDrow, nDcol SAY "[ ]" + + DO CASE + CASE nProgress = 0 + @ nDrow, nDcol + 1 SAY "-" + CASE nProgress = 1 + @ nDrow, nDcol + 1 SAY "\" + CASE nProgress = 2 + @ nDrow, nDcol + 1 SAY "|" + CASE nProgress = 3 + @ nDrow, nDcol + 1 SAY "/" + ENDCASE + + nProgress++ + + IF nProgress == 4 + nProgress := 0 + ENDIF + + @ nRow, nCol + +RETURN