+ contrib/hbpipeio/hbpipeio.hbc
+ contrib/hbpipeio/hbpipeio.hbp
+ contrib/hbpipeio/hbpipeio.hbx
+ contrib/hbpipeio/pipeio.c
+ contrib/hbpipeio/tests/hbmk.hbm
+ contrib/hbpipeio/tests/test.prg
+ added PIPEIO new Harbour FILE IO redirector
As file name prefix "PIPE:" and "|" can be used.
This redirector executes command passed as file name with its
stdin and stdout handles redirected to Harbour FILE handle, i.e.:
REQUEST HB_PIPEIO
pFile := hb_vfOpen( "PIPE:ls -la", 0 )
? upper( hb_vfReadLen( pFile, 10000 ) )
hb_vfClose( pFile )
PIPEIO has also two new PRG functions:
hb_vfFromPipes( [<hReads>], [<hWrite>], [<hProcess>], ;
[<nTimeout>] -> <pHandle> | NIL
hb_vfOpenProcess( <cCommand>, [<nMode>=FO_READ], ;
[<nTimeout>], [<lDetach>] ) -> <pHandle> | NIL
The first one can be used to create Harbour file redirector for
process created by hb_processOpen(), i.e.:
hProcess := hb_processOpen( cCommand, @hStdIn, @hStdOut )
pFile := hb_vfFromPipes( hStdOut, hStdIn, hProcess, 5000 )
The second one can be used directly:
pFile := hb_vfFromPipes( cCommand, FO_READWRITE, 5000 )
Usually process which reads from its stdin works until its input
stream is closed by other process. If user wants to close input
stream for command redirected to Harbour PIPE FILE IO then he can
execute:
hb_vfConfig( pFile, HB_VF_SHUTDOWN, FO_WRITE )
Look at the test code for real life example. It opens 'gzip' command
in FO_READWRITE mode, sends data to gzip, reads gzip output and finally
decompress it using hb_ZUncompress() to check if result is equal to
initial data.
33 lines
1.0 KiB
Plaintext
33 lines
1.0 KiB
Plaintext
/* --------------------------------------------------------------------
|
|
* NOTE: You can add manual override which functions to include or
|
|
* exclude from automatically generated EXTERNAL/DYNAMIC list.
|
|
* Syntax: // HB_FUNC_INCLUDE <func>
|
|
* // HB_FUNC_EXCLUDE <func>
|
|
*/
|
|
|
|
/* --------------------------------------------------------------------
|
|
* WARNING: Automatically generated code below. DO NOT EDIT! (except casing)
|
|
* Regenerate using hbmk2 '-hbx=' option.
|
|
*/
|
|
|
|
#ifndef __HBEXTERN_CH__HBPIPEIO__
|
|
#define __HBEXTERN_CH__HBPIPEIO__
|
|
|
|
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBPIPEIO__ANNOUNCE )
|
|
ANNOUNCE __HBEXTERN__HBPIPEIO__
|
|
#endif
|
|
|
|
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBPIPEIO__REQUEST )
|
|
#command DYNAMIC <fncs,...> => EXTERNAL <fncs>
|
|
#endif
|
|
|
|
DYNAMIC HB_PIPEIO
|
|
DYNAMIC hb_vfFromPipes
|
|
DYNAMIC hb_vfOpenProcess
|
|
|
|
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBPIPEIO__REQUEST )
|
|
#uncommand DYNAMIC <fncs,...> => EXTERNAL <fncs>
|
|
#endif
|
|
|
|
#endif
|