📄 htstream.h
字号:
/* W3C Sample Code Library libwww Generic Stream Class! Generic Stream Class!*//*** (c) COPYRIGHT MIT 1995.** Please first read the full copyright statement in the file COPYRIGH.*//*The Stream class defines objects which accepts a sequence of characters.Streams may also have an output in which case multiple stream objects canbe cascaded to build a stream pipe where the output of a stream is directedinto the input of the next stream object "down the line". Of course, oneof the main features of streams is that they can perform a data conversionon the data before piping it to the output. As multiple streams may becascaded, the complete data conversion is then the sum of each individualdata conversion performed by the stream objects being part of the streampipe.It is not required that a stream has a target, it might as well bea black hole that just accepts data without ever giving it out again. Thegeneric stream class is subclassed multiple places in the Library and a goodexample is the structured stream definition whichcreates a SGML object.All stream class methods return an integer status code telling whether theoperation succeeded or not.. This is the way for a stream to pass controlinformation upstream to the caller which may also be a stream. The generalreturn codes from the methods are: o HT_WOULD_BLOCK o HT_ERROR o HT_OK o >0 - any return greater than 0 will result in that the return code will be parsed through all stream objects. This can be used to pass back information to the protocol modules, for example It is in general not relevant to return how much data has been written inthe stream, as there often will be a relationship other than 1:1 betweenindata and outdata. However, it is important that a stream keeps state (eitheron the incoming data or the outgoing data stream) so that it can accept aHT_WOULD_BLOCK and continue at a later time when the blockingsituation has stopped.This module is implemented by HTStream.c, and itis a part of the W3C Sample CodeLibrary.*/#ifndef HTSTREAM_H#define HTSTREAM_H#include "HTList.h"typedef struct _HTStream HTStream;typedef struct _HTStreamClass { char * name;/*This field is for diagnostics only*/ int (*flush) (HTStream * me);/*The flush method is introduced in order to allow the stream to putany buffered data down the stream pipe but without taking the stream pipedown. 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 downthe target as the date might be relevant for this stream only.*/ int (*_free) (HTStream * me);/*The free method is like the flush method but it alsofrees the current stream object and all stream objects down stream. Whenthe free method has been called, the whole stream pipe(not only this obejct) should not accept any more data.*/ int (*abort) (HTStream * me, HTList * errorlist);/*The abort method should only be used if a stream is interrupted, forexample by the user, or an error occurs.*/ int (*put_character)(HTStream * me, char ch); int (*put_string) (HTStream * me, const char * str); int (*put_block) (HTStream * me, const char * str, int len);/*These methods are for actually putting data down the stream. It is importantthat the most efficient method is chosen (often put_block). There is no guaranteethat a stream won't change method, for example fromput_character to put_block*/} HTStreamClass;/*. Basic Utility Streams.These streams can be plugged in everywhere in a stream pipe.( Black Hole Stream)This stream simply absorbs data without doing anything what so ever.*/extern HTStream * HTBlackHole (void);/*( Generic Error Stream)The Error stream simply returns HT_ERROR on all methods. Thiscan be used to stop a stream as soon as data arrives, for example from thenetwork.*/extern HTStream * HTErrorStream (void);/**/#endif /* HTSTREAM_H *//* @(#) $Id: HTStream.html,v 2.24 1998/05/14 02:11:05 frystyk Exp $*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -