buffio.h

Go to the documentation of this file.
00001 #ifndef __BUFFIO_H__
00002 #define __BUFFIO_H__
00003 
00004 /** @file buffio.h - Treat buffer as an I/O stream.
00005 
00006   (c) 1998-2005 (W3C) MIT, ERCIM, Keio University
00007   See tidy.h for the copyright notice.
00008 
00009   CVS Info :
00010 
00011     $Author: arnaud02 $ 
00012     $Date: 2005/04/08 09:11:12 $ 
00013     $Revision: 1.5 $ 
00014 
00015   Requires buffer to automatically grow as bytes are added.
00016   Must keep track of current read and write points.
00017 
00018 */
00019 
00020 #include "platform.h"
00021 #include "tidy.h"
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /** TidyBuffer - A chunk of memory */
00028 TIDY_STRUCT
00029 struct _TidyBuffer 
00030 {
00031     byte* bp;           /**< Pointer to bytes */
00032     uint  size;         /**< # bytes currently in use */
00033     uint  allocated;    /**< # bytes allocated */ 
00034     uint  next;         /**< Offset of current input position */
00035 };
00036 
00037 /** Zero out data structure */
00038 TIDY_EXPORT void TIDY_CALL tidyBufInit( TidyBuffer* buf );
00039 
00040 /** Free current buffer, allocate given amount, reset input pointer */
00041 TIDY_EXPORT void TIDY_CALL tidyBufAlloc( TidyBuffer* buf, uint allocSize );
00042 
00043 /** Expand buffer to given size. 
00044 **  Chunk size is minimum growth. Pass 0 for default of 256 bytes.
00045 */
00046 TIDY_EXPORT void TIDY_CALL tidyBufCheckAlloc( TidyBuffer* buf,
00047                                              uint allocSize, uint chunkSize );
00048 
00049 /** Free current contents and zero out */
00050 TIDY_EXPORT void TIDY_CALL tidyBufFree( TidyBuffer* buf );
00051 
00052 /** Set buffer bytes to 0 */
00053 TIDY_EXPORT void TIDY_CALL tidyBufClear( TidyBuffer* buf );
00054 
00055 /** Attach to existing buffer */
00056 TIDY_EXPORT void TIDY_CALL tidyBufAttach( TidyBuffer* buf, byte* bp, uint size );
00057 
00058 /** Detach from buffer.  Caller must free. */
00059 TIDY_EXPORT void TIDY_CALL tidyBufDetach( TidyBuffer* buf );
00060 
00061 
00062 /** Append bytes to buffer.  Expand if necessary. */
00063 TIDY_EXPORT void TIDY_CALL tidyBufAppend( TidyBuffer* buf, void* vp, uint size );
00064 
00065 /** Append one byte to buffer.  Expand if necessary. */
00066 TIDY_EXPORT void TIDY_CALL tidyBufPutByte( TidyBuffer* buf, byte bv );
00067 
00068 /** Get byte from end of buffer */
00069 TIDY_EXPORT int TIDY_CALL  tidyBufPopByte( TidyBuffer* buf );
00070 
00071 
00072 /** Get byte from front of buffer.  Increment input offset. */
00073 TIDY_EXPORT int TIDY_CALL  tidyBufGetByte( TidyBuffer* buf );
00074 
00075 /** At end of buffer? */
00076 TIDY_EXPORT Bool TIDY_CALL tidyBufEndOfInput( TidyBuffer* buf );
00077 
00078 /** Put a byte back into the buffer.  Decrement input offset. */
00079 TIDY_EXPORT void TIDY_CALL tidyBufUngetByte( TidyBuffer* buf, byte bv );
00080 
00081 
00082 /**************
00083    TIDY
00084 **************/
00085 
00086 /* Forward declarations
00087 */
00088 
00089 /** Initialize a buffer input source */
00090 TIDY_EXPORT void TIDY_CALL initInputBuffer( TidyInputSource* inp, TidyBuffer* buf );
00091 
00092 /** Initialize a buffer output sink */
00093 TIDY_EXPORT void TIDY_CALL initOutputBuffer( TidyOutputSink* outp, TidyBuffer* buf );
00094 
00095 #ifdef __cplusplus
00096 }
00097 #endif
00098 #endif /* __BUFFIO_H__ */

Generated on Mon Nov 27 23:21:08 2006 for HTML Tidy by  doxygen 1.3.9.1