2015-08-31 13:26 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* src/rtl/hbsockhb.c
    + added new PRG function:
         hb_socketAutoShutdown( hSocket, [ lNewSetting ] ) --> lPrevSetting
      it allows to enable/disable automatic shutdown when connected socket
      is closed.

  * contrib/hbpipeio/pipeio.c
    * removed trailing space

  * contrib/hbpipeio/tests/test.prg
    * cleaned the code and messages
This commit is contained in:
Przemysław Czerpak
2015-08-31 13:26:26 +02:00
parent 2606996d15
commit f90e0be4fd
4 changed files with 36 additions and 10 deletions

View File

@@ -10,6 +10,19 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2015-08-31 13:26 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* src/rtl/hbsockhb.c
+ added new PRG function:
hb_socketAutoShutdown( hSocket, [ lNewSetting ] ) --> lPrevSetting
it allows to enable/disable automatic shutdown when connected socket
is closed.
* contrib/hbpipeio/pipeio.c
* removed trailing space
* contrib/hbpipeio/tests/test.prg
* cleaned the code and messages
2015-08-31 12:45 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbtcpio/tcpio.c
* contrib/hbpipeio/pipeio.c

View File

@@ -167,7 +167,7 @@ static HB_SIZE s_fileWrite( PHB_FILE pFile, const void * data,
if( pFile->hPipeWR == FS_ERROR )
hb_fsSetError( 6 );
else
else
{
if( timeout == -1 )
timeout = pFile->timeout;

View File

@@ -22,7 +22,7 @@ PROCEDURE Main()
cData := hb_tsToStr( hb_dateTime() ) + hb_eol() + ;
Version() + hb_eol() + ;
OS() + hb_eol() + ;
replicate( "0123456789" + hb_eol(), 1000 ) + ;
Replicate( "0123456789" + hb_eol(), 1000 ) + ;
"END" + hb_eol()
nDone := 0
WHILE nDone < hb_BLen( cData ) .AND. ;
@@ -32,7 +32,7 @@ PROCEDURE Main()
ENDDO
? "total bytes written: " + hb_ntos( nDone ) + ;
", error: " + hb_ntos( FError() )
/* close input stream fro GZIP process to indicate end of data */
/* close input stream for GZIP process to indicate end of data */
hb_vfConfig( pFile, HB_VF_SHUTDOWN, FO_WRITE )
?
@@ -40,10 +40,10 @@ PROCEDURE Main()
? "reading..."
cBuffer := Space( 1000 )
WHILE ( nLen := hb_vfRead( pFile, @cBuffer ) ) > 0
cResult += left( cBuffer, nLen )
cResult += hb_BLeft( cBuffer, nLen )
? "read: " + hb_ntos( nLen )
ENDDO
? "total bytes read: " + hb_ntos( Len( cResult ) ) + ;
? "total bytes read: " + hb_ntos( hb_BLen( cResult ) ) + ;
", error: " + hb_ntos( FError() )
/* close the pipe file and wait for child process termination */
@@ -53,14 +53,14 @@ PROCEDURE Main()
?
hb_vfErase( "data.gz" )
? "write data.gz " + hb_ntos( len( cResult ) ) + " "
?? iif( len( cResult ) == 0, ( hb_vfErase( "data.gz" ), .f. ), ;
hb_memoWrit( "data.gz", cResult ) )
? "write data.gz " + hb_ntos( hb_BLen( cResult ) ) + " -> " + ;
iif( hb_BLen( cResult ) > 0 .AND. hb_memoWrit( "data.gz", cResult ), ;
"OK", "ERROR" )
/* check if we can decode data compressed by GZIP */
IF hb_ZUncompress( cResult ) == cData
? "OK, GZIP output decompressed correctly and much the source"
? "OK, GZIP output decompressed correctly and muches the source"
ELSE
? "ERROR, decompressed GZIP output not much the source"
? "ERROR, decompressed GZIP output does not much the source"
ENDIF
ENDIF
?

View File

@@ -90,6 +90,7 @@
* hb_socketWrite( hSocket, cBuffer, [ nLen = Len( cBuffer ) ], [ nTimeout = FOREVER ] ) --> nBytesWritten
* hb_socketFlush( hSocket, [ nTimeout = FOREVER ], [ lSync ] ) --> nBytesLeft
* hb_socketAutoFlush( hSocket, [ nNewSetting ] ) --> nPrevSetting
* hb_socketAutoShutdown( hSocket, [ lNewSetting ] ) --> lPrevSetting
*/
/* this has to be declared before hbsocket.h is included */
@@ -1483,3 +1484,15 @@ HB_FUNC( HB_SOCKETAUTOFLUSH )
hb_sockexSetAutoFlush( pSock, hb_parni( 2 ) );
}
}
HB_FUNC( HB_SOCKETAUTOSHUTDOWN )
{
PHB_SOCKEX pSock = hb_sockexParam( 1 );
if( pSock )
{
hb_retl( hb_sockexGetShutDown( pSock ) );
if( HB_ISLOG( 2 ) )
hb_sockexSetShutDown( pSock, hb_parl( 2 ) );
}
}