Annotation of libwww/Library/src/HTStream.c, revision 2.4

2.1       frystyk     1: /*                                                                 HTStream.c
                      2: **     BASIC STREAMS
                      3: **
                      4: **     (c) COPYRIGHT MIT 1995.
                      5: **     Please first read the full copyright statement in the file COPYRIGH.
2.4     ! frystyk     6: **     @(#) $Id: HTStream.c,v 2.3 1998/05/04 19:37:21 frystyk Exp $
2.1       frystyk     7: **
                      8: **     This version of the stream object just writes to a C file.
                      9: **     The file is assumed open and left open.
                     10: **
                     11: */
                     12: 
                     13: /* Library include files */
2.3       frystyk    14: #include "wwwsys.h"
2.1       frystyk    15: #include "HTUtils.h"
                     16: #include "HTStream.h"                                   /* Implemented here */
                     17: 
                     18: struct _HTStream {
                     19:     const HTStreamClass *      isa;
                     20: };
                     21: 
2.2       frystyk    22: PRIVATE HTStream HTBlackHoleStreamInstance;                  /* Made static */
                     23: PRIVATE HTStream HTErrorStreamInstance;
2.1       frystyk    24: 
                     25: /* ------------------------------------------------------------------------- */
                     26: 
                     27: /*
                     28: **
                     29: **             B L A C K    H O L E    C L A S S
                     30: **
                     31: **     There is only one black hole instance shared by anyone
                     32: **     who wants a black hole.  These black holes don't radiate,
                     33: **     they just absorb data.
                     34: */
                     35: PRIVATE int HTBlackHole_put_character (HTStream * me, char c)
                     36: {
                     37:     return HT_OK;
                     38: }
                     39: 
                     40: PRIVATE int HTBlackHole_put_string (HTStream * me, const char * s)
                     41: {
                     42:     return HT_OK;
                     43: }
                     44: 
                     45: PRIVATE int HTBlackHole_write (HTStream * me, const char * s, int l)
                     46: {
                     47:     return HT_OK;
                     48: }
                     49: 
                     50: PRIVATE int HTBlackHole_flush (HTStream * me)
                     51: {
                     52:     return HT_OK;
                     53: }
                     54: 
                     55: PRIVATE int HTBlackHole_free (HTStream * me)
                     56: {
                     57:     return HT_OK;
                     58: }
                     59: 
                     60: PRIVATE int HTBlackHole_abort (HTStream * me, HTList * e)
                     61: {
                     62:     return HT_ERROR;
                     63: }
                     64: 
                     65: 
                     66: /*     Black Hole stream
                     67: **     -----------------
                     68: */
                     69: PRIVATE const HTStreamClass HTBlackHoleClass =
                     70: {              
                     71:     "BlackHole",
                     72:     HTBlackHole_flush,
                     73:     HTBlackHole_free,
                     74:     HTBlackHole_abort,
                     75:     HTBlackHole_put_character,
                     76:     HTBlackHole_put_string,
                     77:     HTBlackHole_write
                     78: }; 
                     79: 
                     80: PUBLIC HTStream * HTBlackHole (void)
                     81: {
2.2       frystyk    82:     HTBlackHoleStreamInstance.isa = &HTBlackHoleClass;      /* The rest is random */
                     83:     return &HTBlackHoleStreamInstance;
2.1       frystyk    84: }
                     85: 
                     86: /*
                     87: **     ERROR STREAM
                     88: **     ------------
                     89: **     There is only one error stream shared by anyone who wants a
                     90: **     generic error returned from all stream methods.
                     91: */
                     92: PRIVATE int HTErrorStream_put_character (HTStream * me, char c)
                     93: {
                     94:     return HT_ERROR;
                     95: }
                     96: 
                     97: PRIVATE int HTErrorStream_put_string (HTStream * me, const char * s)
                     98: {
                     99:     return HT_ERROR;
                    100: }
                    101: 
                    102: PRIVATE int HTErrorStream_write (HTStream * me, const char * s, int l)
                    103: {
                    104:     return HT_ERROR;
                    105: }
                    106: 
                    107: PRIVATE int HTErrorStream_flush (HTStream * me)
                    108: {
                    109:     return HT_ERROR;
                    110: }
                    111: 
                    112: PRIVATE int HTErrorStream_free (HTStream * me)
                    113: {
2.4     ! frystyk   114:     return HT_OK;
2.1       frystyk   115: }
                    116: 
                    117: PRIVATE int HTErrorStream_abort (HTStream * me, HTList * e)
                    118: {
                    119:     return HT_ERROR;
                    120: }
                    121: 
                    122: PRIVATE const HTStreamClass HTErrorStreamClass =
                    123: {              
                    124:     "ErrorStream",
                    125:     HTErrorStream_flush,
                    126:     HTErrorStream_free,
                    127:     HTErrorStream_abort,
                    128:     HTErrorStream_put_character,
                    129:     HTErrorStream_put_string,
                    130:     HTErrorStream_write
                    131: }; 
                    132: 
                    133: PUBLIC HTStream * HTErrorStream (void)
                    134: {
2.2       frystyk   135:     HTErrorStreamInstance.isa = &HTErrorStreamClass;    /* The rest is random */
                    136:     return &HTErrorStreamInstance;
2.1       frystyk   137: }

Webmaster