Note that both, constructors and destructors of the subclasses may print error messages (via out_c) - in case the open or close does not work correctly. Also the read method may print an error message. One should check is_open before calling read.
int read(char *buf, int size)
;buf
and size size
.
It returns the number of characters actually read.
As long as this is greater than zero,
everything is ok.
If it is zero,
the end of file was reached.
If it is negative,
some error occurred.
The function will print an error message itself
(by calling the appropriate function from
out_c).
So if a negative result is returned,
the caller may simply treat it like an end of file.
Note that the input in the buffer is not null-terminated.
bool_t is_open(void)
;BOOL_TRUE
if this object is currently associated with an open input stream,
and BOOL_FALSE
otherwise
(i.e. the open failed or close
was called).
Note the the constructors print an error message themselves
(by calling the appropriate function from
out_c).
However,
one should check is_open before trying
to read from the input stream.
bool_t close(void)
;BOOL_TRUE
if the close was successful.
Otherwise,
BOOL_FALSE
is returned
and an error message is printed.
The destructor of this class implicitly calls close
(if this was not done before).
However,
by using the implicit method,
one has no chance of checking the error status.
(Probably, for input files this is not very important,
but I don't like such limitations.)
Of course,
for standard input the close is simply ignored.
str_t filename(void)
;STR_NIL
if the input stream comes from the keyboard
or the common gateway interface (CGI).