| M E M _ S C A N F I L E ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English PORTA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_scanfile() - Allows to work on data stream using
callback.
SYNOPSIS
res = mem_scanfile(
buflen, fd, termsig, userdata, usercode);
LONG mem_scanfile(ULONG, LONG, ULONG, void *,
LONG (*)(struct mem_sfe_cb *));
FUNCTION
This is general puprose function that streams the data on
a given file descriptor until EOF. Buffer is orginised in
such a way that the former buffer is divided by two, so
each time there is a need to read new portion of data,
lower halve of the buffer(block) is being copied to the
upper halve and then new data is being read to the lower
halve. This way there is an illusion of continuous data.
User can hook in thru a callback in which all the magic
can be done.
INPUTS
buflen - Buffer len. Passing 0 will enforce hardcoded
buffer size(see function source).
fd - File desc./handle as obtained with 'Open()'.
termsig - Optional termination signal, 0 means no term.
sig.. Private signal as obtained with
'mysig = AllocSignal()' must be '(1L << mysig)'
before passing!
userdata - General purpose argument, user will want to
pass its variable or structure here.
usercode - Callback function that returns LONG aligned
result.
RETURNS
Function returns -2 if memory allocation failed. Value of
-1 must be used to indicate FALSE and 0 and up for TRUE
in the callback.
BASES
SysBase, DOSBase
NOTES
Callback structure is described in the header file.
If termination signal was used then it must be cleared
('Signal(0L, signal)') after the function returns or
else it will trigger some exception handler or something
similar further.
SEE ALSO
mem_findinfile()
EXAMPLE
See source code of 'a-mem_findinfile.c' for a practical
application.
BUGS
None known.
----------------------------------------------------------------------------
| |
| |