* *
* partial sync with the 3.4 fork codebase. These are the things
synces for the most part:
- copyright headers
- grammar/typos in comments and some readmes
- comment/whitespace/decorations
- variable scoping in C files
- DO CASE/SWITCH and some other alternate syntax usage
- minimal amount of human readable text in strings
- minor code updates
- HB_TRACE() void * casts for pointers and few other changes to
avoid C compiler warnings
- various other, minor code cleanups
- only Harbour/C code/headers were touched in src, utils, contrib,
include. No 3rd party code, no make files, and with just a few
exceptions, no 'tests' code was touched.
- certain components were not touched were 3.4 diverged too much
already, like f.e. hbmk2, hbssl, hbcurl, hbexpat
- the goal was that no actual program logic should be altered by
these changes. Except some possible minor exceptions, any such
change is probably a bug in this patch.
It's a massive patch, if you find anything broken after it, please
open an Issue with the details. Build test was done on macOS.
The goal is make it easier to see what actual code/logic was changed
in 3.4 compared to 3.2 and to make patches easier to apply in both
ways.
* *
% remove brandings and homepage [1] from copyright header. Pass 1 - using script.
[1] nobody has access to it anymore AFAIK - and it's also just
a redirect since long
! update url in copyright header
; this should make the diff between 3.4 and 3.2 easier to manage
* include/hbapifs.h
* src/rtl/filebufd.c
* moved HB_FILE_ERR_UNSUPPORTED macro to header file
* include/hbapifs.h
* src/rtl/filebuf.c
* added new C function hb_fileLoad() - it can be used to load data
from regular files and streams
* src/rtl/memofile.c
* modified [hb_]Memo{Read|Writ}() to work with streams, i.e. now
this code works:
REQUEST HB_PIPEIO
cDir := hb_memoRead( "|ls -la" )
? upper( cDir )
or:
cData := hb_memoRead( "|xz -c data.gz" )
? hb_memoWrit( "data2.txt", cData )
? hb_memoWrit( "|sh -c 'xz -9 -e > data2.xz'", cData )
* src/rtl/fscopy.c
* removed not used in current code unix header files
* 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
* contrib/hbtcpio/tcpio.c
* contrib/hbpipeio/pipeio.c
* modified hb_fileWrite() to return 0 in case of timeout or unblocking
write and -1 on other errors.
* contrib/hbcomio/comio.c
* modified hb_fileRead() to return 0 in case of timeout or unblocking
read and -1 on other errors.
* src/rtl/filesys.c
* return -1 instead of 0 from hb_fsPipeWrite() in MS-Windows and OS2
builds if PIPE state cannot be read
* ChangeLog.txt
! c&p typo in previous ChangeLog entry
+ 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.