/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */A stream object is something which accepts a stream of text. Generally streams are cascaded into stream pipes where the output of a stream is directed into the input of the down stream object. The input and output streams differs from other streams in that they are used to communicate directly with a transport.
This module is a part of the W3C Reference Library.
All methods in the stream definition return an integer. The general return codes from the methods are:
#ifndef HTIOSTREAM_H #define HTIOSTREAM_H typedef struct _HTInputStream HTInputStream; typedef struct _HTOutputStream HTOutputStream; #include "HTList.h" #include "HTStream.h" #include "HTChannl.h" #include "HTNet.h"
typedef struct _HTInputStreamClass {
char * name;
This field is for diagnostics only
int (*flush) (HTInputStream * me);
The flush method is introduced in order to allow the
stream to put any buffered data down the stream pipe but without
taking the stream pipe down. It is for the stream to decide whether it
has buffered data or not. In some situations, the stream might not
want to send buffered data down the target as the date might be
relevant for this stream only.
int (*_free) (HTInputStream * me);
The free method is like the flush method but
it also frees the current stream object and all stream objects down
stream. When the free method has been called, the
whole stream pipe (not only this object) should not accept
any more data. See also the close method below
int (*abort) (HTInputStream * me, HTList * errorlist);
The abort method should only be used if a stream is
interrupted, for example by the user, or an error occurs.
int (*read) (HTInputStream * me);
The read method is the method by which we can read data
from the transport layer.
int (*close) (HTInputStream * me);
The close method closes the transport and deletes the
input stream object. Note that this is different than the free method
which doesn't have to delete the input stream object itself.
} HTInputStreamClass;
param parameter and the mode parameter can
be used for whatever purpose suited.
typedef struct _HTOutputStreamClass {
char * name;
int (*flush) (HTOutputStream * me);
int (*_free) (HTOutputStream * me);
int (*abort) (HTOutputStream * me, HTList * errorlist);
int (*put_character)(HTOutputStream * me, char ch);
int (*put_string) (HTOutputStream * me, const char * str);
int (*put_block) (HTOutputStream * me, const char * str, int len);
See the Generic Stream Definition for an
explanation of these methods. Note that they all have a
HTOutputStream object a the parameter, not a generic
stream. This is to avoid incompatible pointer warnings
int (*close) (HTOutputStream * me);
The close method closes the transport and deletes the
input stream object. Note that this is different than the free method
which doesn't have to delete the input stream object itself.
} HTOutputStreamClass;
select() call or
equivalent and the PULL is suitable in a real thread
environment. In the latter case it doesn't matter if a read procedure
blocks as this only concerns a single thread.
typedef HTInputStream * HTInput_new (HTNet * net, HTChannel * ch, HTStream * target, void * param, int mode);
typedef HTOutputStream * HTOutput_new (HTNet * net, HTChannel * ch, void * param, int mode);
#endif /* HTIOSTREAM_H */