| M E M _ S C A N L B L ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
PORTA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_scanlbl() - Allows to work on lines as read from
file.
SYNOPSIS
res = mem_scanlbl(buflen, fd, termsig, userdata,
usercode);
LONG mem_scanlbl(ULONG, LONG, ULONG, void *,
LONG (*)(struct mem_lbl_cb *));
FUNCTION
This is general puprose function that streams the data
on a given file descriptor line by line until EOF.
User can hook in thru a callback in which all the magic
can be done.
INPUTS
buflen - Total line length. 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
Please note, this func. allocates twice the 'buflen',
so if you add 'lc_bufptr + lc_buflen' you will be able
to access the other half!
There is also 'mem_scanlblncc()' variant of this func.
that filters out C style comments. Beware, this func.
swaps 'lc_lineptr', so it points to the other half of
'lc_bufptr', which means you dont sum vars like above
in order to access extra space, you just use it as it
is! This function also informs about broken comments
by returning 0!
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 else further.
SEE ALSO
EXAMPLE
See source code of 'a-mem_scanlblncc.c' on how to use
callbacks.
BUGS
None known.
----------------------------------------------------------------------------
| |
| |